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 |
|---|---|---|---|---|---|---|
test initialization of OriginalSourceCodeTest'model.
|
def test_ut_diff_result_02
original_source_code = OriginalSourceCode.new(
:original_file_id => 10,
:line_number => 349898,
:error_line => 4564,
:line_content => "123456"
)
assert_equal(10,original_source_code.original_file_id)
assert_equal(349898,original_source_code.line_number)
assert_equal(4564,original_source_code.error_line)
assert_equal("123456",original_source_code.line_content)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def test_original_source_code_01\n original_source_code = OriginalSourceCode.new(:original_file_id => 1,\n :line_number => 2,\n :line_content => \"y1\",\n :error_line => 45)\n assert original_source_code.save\n orginal_source_code_copy = OriginalSourceCode.find(original_source_code.id)\n assert_equal original_source_code.line_number,orginal_source_code_copy.line_number \n assert original_source_code.valid?\n assert original_source_code.destroy\n end",
"def initialize(source); end",
"def initialize()\n #@source = aSourceTemplate\n #@representation = compile(aSourceTemplate)\n end",
"def initialize(code)\n @original_code = code\n end",
"def initialize(source_string='')\n @source = source_string\n end",
"def initialize(source)\r\n @source = source\r\n end",
"def initialize source\n @source = source\n end",
"def initialize_model\n # let's create our new empty model\n @model = OpenStudio::Model::Model.new if @model.nil?\n end",
"def initialize(source)\n @source = source\n end",
"def initialize(source)\n @source = source\n end",
"def initialize(_src)\n\t\t@tokenizer = Lexer.new(_src)\n\t\t@token = nil\n\t\t@blocklevel = 0\n\t\t@node = nil\n\t\t@sav = nil\n\tend",
"def test_initialize\n @not_restore = true\n @active_items = NSArrayController.alloc\n @saved_items = NSArrayController.alloc\n awakeFromNib\n @active_items.initWithContent(@active_items_model)\n @saved_items.initWithContent(@saved_items_model)\n end",
"def initialize_copy(original)\n initialize(original.repository, original.model, original.options)\n end",
"def initialize(source)\n @source = source\n end",
"def initialize(data_source_config)\n end",
"def initialize_model\n end",
"def initialize(source, options); end",
"def init; end",
"def init; end",
"def init; end",
"def init; end",
"def initialize(model)\n @model = model\n\n instance_eval(&self.class.setup_model_blk) if model\n \n @templates = if model\n self.class.generated_files.models\n else\n self.class.generated_files.global\n end\n end",
"def initialize(source_text = nil)\n @tags = []\n @rows = []\n\n super(source_text)\n\n return unless source_text\n\n parsed_example_data = parse_source(source_text)\n populate_example(self, parsed_example_data)\n end",
"def initialize(source_text = nil)\n @tags = []\n @tests = []\n\n super(source_text)\n\n return unless source_text\n\n parsed_rule_data = parse_source(source_text)\n populate_rule(self, parsed_rule_data)\n end",
"def initialize() end",
"def initialize(content); end",
"def initialize(content); end",
"def initialize(model, year) #metodo constructor permite definir como se contruiran los objetos\n @model = model #guarda lo que sea que tenga en la variable \"model\"\n @year = year\n end",
"def initialize(source)\n @source = File.expand_path(source)\n end",
"def pre_testdata\n RVTEST_DATA_BEGIN()\n TEST_DATA()\n RVTEST_DATA_END()\n end",
"def initialize(src = 'm')\n @src = src\n end",
"def init\n end",
"def init\n end",
"def init\n end",
"def initialize(source = nil)\n parsed_example = process_source(source)\n\n super(parsed_example)\n\n @tags = []\n @tag_elements = []\n @rows = []\n @parameters = []\n @row_elements = []\n\n build_example(parsed_example) if parsed_example\n end",
"def initialize(source_text = nil)\n @steps = []\n @tags = []\n @examples = []\n\n super(source_text)\n\n if source_text\n parsed_outline_data = parse_source(source_text)\n populate_outline(self, parsed_outline_data)\n end\n end",
"def initTestCase\n # It is possible to call it several times. Protect it from it.\n if ((!defined?(@AlreadyInit)) or\n (!@AlreadyInit))\n @AlreadyInit = true\n # The possible variables replaced in regression test files (command lines, repositories...)\n # map< Symbol, Object >\n @ContextVars = {}\n # Mute any output except for terminal output.\n set_log_errors_stack([])\n set_log_messages_stack([])\n # Clear variables set in tests\n # map< Symbol, Object >\n $Variables = {}\n # Clear the context that might be used to pilot some regression specific objects\n # map< Symbol, Object >\n $Context = {}\n # list< list< list< String > > >\n $WEACERegression_DummySQLAnswers = nil\n # Initialize instance variables used to identify the Test case\n initTestDetails\n\n begin\n yield\n rescue Exception\n set_log_file(nil)\n @AlreadyInit = false\n raise\n end\n set_log_file(nil)\n @AlreadyInit = false\n else\n yield\n end\n end",
"def initialize(source, target_model)\n @source = source\n @target_model = target_model\n end",
"def test_ut_diff_source_code_o1\n assert @diff_source_code_1.save\n diff_source_code_copy = DiffSourceCode.find(@diff_source_code_1.id)\n assert_equal @diff_source_code_1.diff_file_id, diff_source_code_copy.diff_file_id \n assert @diff_source_code_1.valid?\n assert @diff_source_code_1.destroy\n end",
"def initialize(source)\n @source = source.dup\n end",
"def initialize(source)\n self.source = source\n self.fields = []\n self.lines = []\n self.parse!\n end",
"def init\n puts '####### Recon Snippets Marked For Testing #######'\n Dir.glob(\"**/\") do |directory|\n next !File.exist?(\"#{directory}meta.json\")\n snippetModel = SnippetModel.new(\"#{directory}meta.json\")\n next unless snippetModel.testeable?\n #Add this model to those to be tested\n @snippets_models.put(snippetModel)\n puts snippetModel\n end\n end",
"def test_extract_data_06\n OriginalSourceCode.destroy_all\n file = original_files(:original_files_002)\n assert file.extract_data(file.normal_result_id)\n original_source_code_1 = OriginalSourceCode.find(:all,\n :conditions => {\n :original_file_id => file.id,\n :line_number => 1,\n :line_content => \"\\t/*\\r\",\n :error_line => 1}\n )\n assert_not_equal [],original_source_code_1\n original_source_code_2 = OriginalSourceCode.find(:all,\n :conditions => {\n :original_file_id =>file.id,\n :line_number => 2,\n :line_content => \"\\t File:\\r\",\n :error_line => 0}\n )\n assert_not_equal [],original_source_code_2\n end",
"def init\n\n end",
"def from_string(original_source); end",
"def initialize(content = '')\n super(content)\n @source = nil\n end",
"def initialize(src,trgt,rootpackage,test_url = \"http://localhost:3000\")\r\n @source,@target,@package_root,@test_base_url = src,trgt,rootpackage,test_url\r\n \r\n @typemap = {}\r\n @typemap[:integer] = 'int'\r\n @typemap[:float] = 'Number'\r\n @typemap[:datetime] = 'Date'\r\n @typemap[:date] = 'Day'\r\n @typemap[:time] = 'Time'\r\n @typemap[:string] = 'String'\r\n @typemap[:text] = 'String'\r\n @typemap[:boolean] = 'Boolean'\r\n \r\n @defaultvaluemap = {}\r\n @defaultvaluemap[:integer] = '0'\r\n @defaultvaluemap[:float] = '0.0'\r\n @defaultvaluemap[:datetime] = 'new Date()'\r\n @defaultvaluemap[:date] = 'new Day()'\r\n @defaultvaluemap[:time] = 'new Time()'\r\n @defaultvaluemap[:string] = '\"\"'\r\n @defaultvaluemap[:text] = '\"\"'\r\n @defaultvaluemap[:boolean] = 'false' \r\n \r\n # template variables hash\r\n @tmap = { 'timestamp' => Time.now.httpdate}\r\n @tmap['testbaseurl'] = test_url\r\n end",
"def initialize(code)\n @code = code\n end",
"def initialize(code)\n @code = code\n end",
"def initialize_copy(source)\n super\n @ob = OpenBabel::OBMol.new(source.ob)\n self\n end",
"def test_initialize\n assert_nothing_raised { Spoonerize::Cli.new(fixtures['default_words']) }\n end",
"def initialize(source = nil)\n parsed_outline = process_source(source)\n\n super(parsed_outline)\n\n @tags = []\n @tag_elements = []\n @examples = []\n\n build_outline(parsed_outline) if parsed_outline\n end",
"def setup\n @controller = SourceDataController.new\n @request = ActionController::TestRequest.new\n @response = ActionController::TestResponse.new\n \n @source_name = 'something'\n @unexistent_name = 'somewhat'\n end",
"def initialize(test_path)\n @spec = ::Utils.load_spec_yaml_file(test_path)\n @description = File.basename(test_path)\n @data = @spec['data']\n end",
"def new\n @source = Source.new\n\n end",
"def initialize_copy( original )\n\t\t\t@template = original.template\n\t\t\t@options = original.options.dup\n\t\t\t@tree = @tree.map( &:dup )\n\t\t\t@node_stack = [ @tree ]\n\t\t\t@include_stack = original.include_stack.dup\n\t\tend",
"def test_load\n @valid_source.save\n source_loaded = Source.find(@valid_source.uri)\n assert_kind_of(Source, source_loaded)\n assert_equal(@valid_source.primary_source, source_loaded.primary_source)\n assert_equal(@valid_source.uri, source_loaded.uri)\n end",
"def initialize()\n end",
"def pre_initialize; end",
"def initialize(original_result)\n @original_result = original_result.freeze\n @files = original_result.map {|filename, coverage|\n SimpleCov::SourceFile.new(filename, coverage) if File.file?(filename)\n }.compact.sort_by(&:filename)\n @file_whitelist = FileWhitelist.new\n filter!\n end",
"def initialize(code)\n @code = code\n end",
"def initialize(uploaded_path, output_path_without_extension, original_filename, model_id)\n @model_id = model_id\n init_model\n \n @uploaded_path = uploaded_path\n @output_path_without_extension = output_path_without_extension\n @original_filename = original_filename\n end",
"def initialize(code, expected, actual, expecting_error: false, filename: nil)\n @code = code\n @expected = expected\n @actual = actual\n @expecting_error = expecting_error\n @filename = filename\n end",
"def initialize\n initialize!\n end",
"def initialize\n initialize!\n end",
"def initialize source:, example_mode:, example_num:, ig_name:\n @source = source\n @failures, @successes = [], []\n @example_num = example_num\n @ig_name = ig_name\n\n if File.exist? @source\n @json_data = JSON.parse(File.read(@source))\n else\n puts \"FILE NOT FOUND #{@source}\"\n return\n end\n snapshot = @json_data.dig(\"snapshot\", \"element\").dup\n @resource_name = @json_data[\"type\"]\n @resource_id = @json_data[\"id\"]\n\n # Look for complex data types to add into the snapshot.\n snapshot_with_types = clean_snapshot snapshot\n\n @example = FieldSet.new(name: @resource_name, \n full_name: @resource_name, \n snapshot: snapshot_with_types, \n example_mode: example_mode,\n parent: self\n )\n end",
"def init; end",
"def test_ut_diff_source_code_02\n assert_equal(1,@diff_source_code_1.diff_result_id)\n assert_equal(1,@diff_source_code_1.original_file_id)\n assert_equal(1,@diff_source_code_1.diff_file_id)\n assert_equal(nil,@diff_source_code_1.added_lines)\n assert_equal(\"7;8;9;25;390;396;397;400;404\",@diff_source_code_1.deleted_lines)\n assert_equal(\"1,1;2,2;3,3;4,4;6,6;10,10;11,11;12,12;13,13;14,14;15,15;\",@diff_source_code_1.common_lines)\n end",
"def initialize()\n\t\tend",
"def initialize(testing_template = TestingTemplate.new)\n @testing_template = testing_template\n end",
"def initialize(source_text = nil)\n super(source_text)\n\n if source_text\n parsed_step_data = parse_source(source_text)\n populate_step(self, parsed_step_data)\n end\n end",
"def initialize(data, test)\n @pre_data = data\n @description = test['description']\n @upload_date = Time.now\n if test['assert']['error']\n @operation = UnsuccessfulOp.new(self, test)\n else\n @operation = SuccessfulOp.new(self, test)\n end\n @result = nil\n end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def testNormalWithKnownContent\n initTestCase do\n $Context[:WikiContent] = \"UnknownContent - Line 1\\n=== Current ===\\n\\nUnknownContent - Line 3\"\n $Context[:NewWikiContentRegExp] =\n Regexp.escape(\"UnknownContent - Line 1\\n=== Current ===\\n\\n* <code><small>[\") +\n '....-..-.. ..:..:..' +\n Regexp.escape(\"]</small></code> - Commit DummyCommitID by DummyCommitUser: DummyCommitComment\\nUnknownContent - Line 3\")\n execTest(\n 'DummyUserID',\n [\n 'BranchName',\n 'DummyCommitID',\n 'DummyCommitUser',\n 'DummyCommitComment'\n ]\n )\n end\n end",
"def initialize()\n end",
"def initialize()\n end",
"def initialize()\n end",
"def initialize()\n end",
"def initialize()\n end",
"def initialize()\n end",
"def initialize()\n end",
"def initialize()\n end",
"def initialize(original_result); end",
"def initialize(anything)\n @content = anything\n end",
"def test_input_method_creates_a_new_input_target\n Crd::Spec.new 'Testing' do |s|\n s.input = 'test/fixtures/target/Input.as'\n assert_instance_of( Crd::Target, s.input )\n end\n end",
"def initialize\r\n @code = ''\r\n @tags = []\r\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(content) \r\n @content = content\r\n end",
"def test_01_initialisation\n\n\t\tassert_nothing_raised {\n\t\t\tMonosaccharide.Load_Definitions('data/dictionary.xml')\n\t\t}\n\t\n\tend",
"def load_source!\n @source = load_file_contents\n end"
] |
[
"0.6654709",
"0.65798503",
"0.64541215",
"0.6097681",
"0.60935074",
"0.6088076",
"0.6052738",
"0.60485315",
"0.5981326",
"0.5981326",
"0.5964102",
"0.593474",
"0.58965594",
"0.5889463",
"0.586842",
"0.58099186",
"0.5796693",
"0.5782361",
"0.5782361",
"0.5782361",
"0.5782361",
"0.5772346",
"0.57669485",
"0.57388365",
"0.5730675",
"0.57296896",
"0.57296896",
"0.56995475",
"0.5684383",
"0.5674696",
"0.56712145",
"0.56711435",
"0.56711435",
"0.56711435",
"0.5669569",
"0.5667618",
"0.56644535",
"0.5655273",
"0.5652623",
"0.56421196",
"0.56125605",
"0.56073767",
"0.5598293",
"0.55922794",
"0.558111",
"0.5565824",
"0.55626184",
"0.5561007",
"0.5561007",
"0.5554368",
"0.5538037",
"0.5537503",
"0.5531231",
"0.5530454",
"0.5528923",
"0.5525245",
"0.5512846",
"0.5505962",
"0.5504167",
"0.5501243",
"0.5491031",
"0.54902697",
"0.54810643",
"0.5479557",
"0.5479557",
"0.54749143",
"0.54691684",
"0.546188",
"0.54610443",
"0.54568833",
"0.5449965",
"0.5444584",
"0.5441849",
"0.5441849",
"0.5441849",
"0.5441849",
"0.5441849",
"0.5441849",
"0.5441849",
"0.5441849",
"0.5441849",
"0.5441849",
"0.5441849",
"0.5434619",
"0.5432935",
"0.5432935",
"0.5432935",
"0.5432935",
"0.5432935",
"0.5432935",
"0.5432935",
"0.5432935",
"0.54278255",
"0.5427286",
"0.54181224",
"0.54140085",
"0.53959787",
"0.53940016",
"0.5392196",
"0.5390187"
] |
0.62550867
|
3
|
GET /components or /components.json
|
def index
if params[:model]
@components = Component.filtermodel(params[:model])
elsif params[:serial_number]
@components = Component.filterserial(params[:serial_number])
elsif params[:rgb]
@components = Component.where(:rgb.to_s => params[:rgb].to_s) unless params[:rgb].blank?
elsif params[:type]
@components = Component.filtertype(params[:type])
elsif params[:brand_id]
@components = Component.where(:brand_id => params[:brand_id]) unless params[:brand_id].blank?
else
@components = Component.all
end
@types = ["Motherboard", "CPU", "GPU", "RAM", "SSD", "HDD", "PSU", "Cabinet", "Monitor", "Keyboard", "Mouse", "Mousepad", "Headset"]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def show\n @component = service.components.find_by(slug: params[:id])\n\n render json: @component\n end",
"def index\n respond_with(components)\n end",
"def show\n @component = CustomComponent.find(params[:id])\n render json: @component\n end",
"def index\n @components = CustomComponent.where(:active => true)\n render json: @components\n end",
"def show\n @componente = Componente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @componente }\n end\n end",
"def show\n @component = Component.find(params[:id].to_i) rescue nil\n respond_to do |format|\n unless @component.blank?\n # to provide a component specific and secure representation of an object, wrap it in a presenter\n \n format.xml { render :xml => component_presenter }\n format.json { render :json => component_presenter }\n else\n format.xml { head :not_found }\n format.json { head :not_found }\n end\n end\n end",
"def show\n @finding_component = FindingComponent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @finding_component }\n end\n end",
"def components\r\n params = {\r\n method: :get,\r\n url: '/report/components',\r\n params: {\r\n reportUUID: @uuid\r\n }\r\n }\r\n @session.request(params).perform!\r\n end",
"def get(path, params={})\n params = merge_set_up_params(params)\n @token = \"b3688c52-9235-45ca-b01f-c5b2b83a4f4f\"\n @result = Typhoeus::Request.get(API_URL + path, :params => params,\n :headers => {\"Authorization\" => \"Basic#{@token}\"})\n puts @result.body\n # check if the url looks correct in the log\n puts @result.effective_url\n # parse the result to json\n return JSON.parse(@result.body)\n end",
"def get(user_name, repo_name, component_id, params={})\n update_and_validate_user_repo_params(user_name, repo_name)\n normalize! params\n\n get_request(\"/2.0/repositories/#{user}/#{repo.downcase}/components/#{component_id}\", params)\n end",
"def show\n @component = Component.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @component }\n end\n end",
"def index\n @component_props = ComponentProp.all\n # @page_components = PageComponent.all\n end",
"def show\n @structure_component = StructureComponent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @structure_component }\n end\n end",
"def show\n @component_widget = ComponentWidget.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @component_widget }\n end\n end",
"def list\n get('/')\n end",
"def index\n endpoint(get(services_url).body)\n end",
"def index\n # Check for filters\n @courses = Course.getCourseInformation(params[:dept],params[:course])\n @page_title = \"Browse Courses\"\n respond_to do |format|\n format.html\n format.json {render json: @courses }\n end\n end",
"def show\n @comp = Comp.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comp }\n end\n end",
"def get(path='', filter=nil)\n # remove the leading slash\n path = path.gsub(/\\A\\//, '')\n\n response = if filter\n categories = filter.categories.collect { |category| category.to_text }.join(',')\n attributes = filter.entities.collect { |entity| entity.attributes.combine.collect { |k, v| k + '=' + v } }.join(',')\n\n headers = self.class.headers.clone\n headers['Content-Type'] = 'text/occi'\n headers['Category'] = categories unless categories.empty?\n headers['X-OCCI-Attributes'] = attributes unless attributes.empty?\n\n self.class.get(@endpoint + path, :headers => headers)\n else\n self.class.get(@endpoint + path)\n end\n\n response_msg = response_message response\n raise \"HTTP GET failed! #{response_msg}\" unless response.code.between? 200, 300\n\n Occi::Log.debug \"Response location: #{('/' + path).match(/\\/.*\\//).to_s}\"\n kind = @model.get_by_location(('/' + path).match(/\\/.*\\//).to_s) if @model\n\n Occi::Log.debug \"Response kind: #{kind}\"\n\n if kind\n kind.related_to? Occi::Core::Resource ? entity_type = Occi::Core::Resource : entity_type = nil\n entity_type = Occi::Core::Link if kind.related_to? Occi::Core::Link\n end\n\n entity_type = Occi::Core::Resource unless entity_type\n\n Occi::Log.debug \"Parser call: #{response.content_type} #{path.include?('-/')} #{entity_type} #{response.headers.inspect}\"\n collection = Occi::Parser.parse(response.content_type, response.body, path.include?('-/'), entity_type, response.headers)\n\n Occi::Log.debug \"Parsed collection: empty? #{collection.empty?}\"\n collection\n end",
"def get(path='', filter=nil)\n # remove the leading slash\n path = path.gsub(/\\A\\//, '')\n\n response = if filter\n categories = filter.categories.collect { |category| category.to_text }.join(',')\n attributes = filter.entities.collect { |entity| entity.attributes.combine.collect { |k, v| k + '=' + v } }.join(',')\n\n headers = self.class.headers.clone\n headers['Content-Type'] = 'text/occi'\n headers['Category'] = categories unless categories.empty?\n headers['X-OCCI-Attributes'] = attributes unless attributes.empty?\n\n self.class.get(@endpoint + path, :headers => headers)\n else\n self.class.get(@endpoint + path)\n end\n\n response_msg = response_message response\n raise \"HTTP GET failed! #{response_msg}\" unless response.code.between? 200, 300\n\n Occi::Log.debug \"Response location: #{('/' + path).match(/\\/.*\\//).to_s}\"\n kind = @model.get_by_location(('/' + path).match(/\\/.*\\//).to_s) if @model\n\n Occi::Log.debug \"Response kind: #{kind}\"\n\n if kind\n kind.related_to? Occi::Core::Resource ? entity_type = Occi::Core::Resource : entity_type = nil\n entity_type = Occi::Core::Link if kind.related_to? Occi::Core::Link\n end\n\n Occi::Log.debug \"Parser call: #{response.content_type} #{entity_type} #{path.include?('-/')}\"\n collection = Occi::Parser.parse(response.content_type, response.body, path.include?('-/'), entity_type, response.headers)\n\n Occi::Log.debug \"Parsed collection: empty? #{collection.empty?}\"\n collection\n end",
"def index\n @articulocomps = Articulocomp.all\n\n respond_to do |format|\n format.html # index.html.erb\n #format.json { render json: @articulocomps }\n end\n end",
"def index\n @components_front_levers = Components::FrontLever.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @components_front_levers }\n end\n end",
"def index\n @courts = Court.by_name\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courts }\n end\n end",
"def list_active_aos_versions(args = {}) \n get(\"/aosversions.json/\", args)\nend",
"def index\n @courses = Course.all\n render json: @courses, status: :ok\n end",
"def show\n render json: @course, status: :found\n end",
"def show\n @avatarcomponent = Avatarcomponent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @avatarcomponent }\n end\n end",
"def index\n @courses = Course.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courses }\n end\n end",
"def index\n @courses = Course.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courses }\n end\n end",
"def index\n @courses = Course.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courses}\n end\n end",
"def get(path, params={})\n params = merge_set_up_params(params)\n JSON.parse(Typhoeus::Request.get(API_URL + path, :params => params).body)[\"response\"]\n end",
"def index\n @gets = Get.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gets }\n end\n end",
"def info\n get '/'\n end",
"def get(url, params = {})\n client.get(url, params).body\n end",
"def index\n query = params[:q]\n @courses = query ? Course.search(query) : Course.all.order(:id)\n\n render json: @courses\n end",
"def create\n @component = service.components.new(component_params)\n\n if @component.save\n render json: @component, status: :created, location: @component\n else\n render json: @component.errors, status: :unprocessable_entity\n end\n end",
"def get_component\n @component = Component.find(params[:id])\n end",
"def new\n @finding_component = FindingComponent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @finding_component }\n end\n end",
"def index\n\t\t@courses = Course.all\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json { render json: @courses }\n\t\tend\n\tend",
"def index\n @component_lists = ComponentList.all\n end",
"def json_get(path, params={})\n json_request(:get, path, params)\n end",
"def view\n res = @client.get(path)\n @attributes = res.json if res.success?\n end",
"def index\n @opponent = Opponent.all\n render json: @opponent\n end",
"def get endpoint\n do_request :get, endpoint\n end",
"def get(url, options={})\n resp = RestClient.get url, rest_client_options(options)\n Representation.new self, MultiJson.load(resp)\n end",
"def index\n @apps = @client.apps\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @apps }\n end\n end",
"def get(params={})\n rpc_call :get, params\n end",
"def get url, params={}, headers={}\n uri = URI.parse(url)\n path = uri.path + \"?\" + query_string(default_params.merge(params))\n response = http(uri.host, uri.port).get(path, default_headers.merge(headers))\n JSON.parse(response.body)\n end",
"def index\n @clients = Client.where(params.except(:action, :controller, :format)).to_a # TODO: remove .to_a when Rails to_json bug fixed\n respond_with(@clients)\n end",
"def get(endpoint, url, args, version = 'v1')\n qs = build_qs(args)\n req_url = \"#{url}/api/#{version}/#{endpoint}?#{qs}\"\n\n request(req_url, :GET)\n end",
"def index\n @ivn_components = IvnComponent.all\n end",
"def index\n @components_saddles = Components::Saddle.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @components_saddles }\n end\n end",
"def index\n render json: Client.all\n end",
"def index\n @clues = Clue.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clues }\n end\n end",
"def get(route='', params = {}, filter = nil)\n url = base_url + route\n unless filter.nil?\n url << '/' + \"(#{ERB::Util.url_encode(filter)})\"\n end\n url << '.json'\n begin\n JSON.parse(RestClient.get(url, params: params))\n rescue RestClient::ResourceNotFound => e\n Object.new\n end\n end",
"def get(api, params={})\n url2json(:GET, \"#{@endpoint}#{api}\", params)\n end",
"def new\n @componente = Componente.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @componente }\n end\n end",
"def index\n get('')\n end",
"def index\n @competencies = Competency.all\n respond_to do |format|\n format.json { render json: @competencies }\n end\n end",
"def show\n @comp_info = CompInfo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comp_info }\n end\n end",
"def index\n @components_front_tubes = Components::FrontTube.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @components_front_tubes }\n end\n end",
"def get(path, query={})\n request_json :get, path, query\n end",
"def get(path, params)\n parse_response @client[path].get(:params => params)\n end",
"def index\n @url_connectors = UrlConnector.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @url_connectors }\n end\n end",
"def index\n @courts = Court.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courts }\n end\n end",
"def get(*args)\n params = args.extract_options!\n @connection.get do |req|\n req.url versioned_path(args), params\n end\n end",
"def index\n @react_components = ReactComponent.all\n end",
"def index\n @commemts = Commemt.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @commemts }\n end\n end",
"def index\n course = Course.find(params[:course_id])\n sections = course.sections.all\n render json: sections.order(:id)\n end",
"def api_get(path, params = {})\n api_request(:get, path, :params => params)\n end",
"def show\n @compliment = Compliment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @compliment }\n end\n end",
"def get(*args)\n prepare_request(:get, args)\n @@client.add(:get, @path, *args)\n end",
"def get\n url = prefix + \"get\"\n return response(url)\n end",
"def get\n url = prefix + \"get\"\n return response(url)\n end",
"def api_get(action, data)\n api_request(action, data, 'GET')\n end",
"def api_get(action, data)\n api_request(action, data, 'GET')\n end",
"def index\n @clients = Client.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n end",
"def get\n start { |connection| connection.request http :Get }\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course }\n end\n end",
"def index\n\n get_collections\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @temples }\n format.js {}\n end\n end",
"def show\n @installed_component = InstalledComponent.find(params[:id].to_i) rescue nil\n respond_to do |format|\n if @installed_component.present?\n # to provide a installed_component specific and secure representation of an object, wrap it in a presenter\n\n format.xml { render :xml => installed_component_presenter }\n format.json { render :json => installed_component_presenter }\n else\n format.xml { head :not_found }\n format.json { head :not_found }\n end\n end\n end",
"def index\n apis = site_account.api_docs_services\n .published\n .with_system_names((params[:services] || \"\").split(\",\"))\n .select{ |api| api.specification.swagger_1_2? }\n\n respond_with({\n swaggerVersion: \"1.2\",\n apis: apis.map!{ |service| swagger_spec_for(service) },\n basePath: \"#{request.protocol}#{request.host}\"\n })\n end",
"def index\n @electors = Elector.all\n\n render json: @electors\n end",
"def get(path, params = {})\n path = File.join(@prefix, path)\n JSON.parse @conn.get(path, params).body\n end",
"def index\n @clients = Client.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n\n end",
"def get(path, params={}, options={})\n request(:get, api_path(path), params, options)\n end",
"def components\n\n end",
"def index\n @sections = params[:path].nil? ? Section.all : Section.where(path: params[:path])\n\n respond_to do |format|\n format.html { render html: @sections }\n format.json { render json: @sections }\n end\n end",
"def show\n @blobs_component = BlobsComponent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @blobs_component }\n end\n end",
"def index\n @resources = Resource.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @resources }\n end\n end",
"def index\n get\n end",
"def index\n @clients = current_user.clients\n render json: @clients\n end",
"def index\n @programs = Program.all(:include => :category)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @programs }\n end\n end",
"def show\n @requests_transferences_components_detail = Requests::Transferences::Components::Detail.find(params[:id])\n respond_to do |format|\n format.html\n end\n end",
"def get_part_by_category\n @categorys = PartsController::PartService.get_part_by_category(params[:param]);\n respond_to do |format|\n format.json { render json: @categorys }\n end \n end",
"def index\n @courses = Course.order(:name).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => Course.all }\n end\n end",
"def index\n\n get_collections\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @deities }\n format.js {}\n end\n end",
"def index\n @clientes = Cliente.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clientes }\n end\n end",
"def index\n @props = Prop.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @props }\n end\n end",
"def index\n @rooms = Room.all\n respond_to do | format |\n format.html\n format.json\n end\n \n end",
"def index\n @slug = params[:slug]\n @page = Page.where(:slug => @slug).includes(:page_component).first\n\n @components = Hash.new\n\n @page.page_component.each_with_index do |component, index|\n props_hash = Hash.new\n component.component_content.each_with_index do |prop, prop_index|\n props_hash.merge!({prop.name => prop.value})\n # component_props.push(props_hash)\n end\n @components[@page.page_component[index].react_component.component_name] = props_hash\n end\n\n\n render \"renders/index\"\n end"
] |
[
"0.71747875",
"0.6927493",
"0.6743073",
"0.6665426",
"0.64892614",
"0.63499594",
"0.6302068",
"0.6293612",
"0.61323285",
"0.6020784",
"0.60112333",
"0.5947259",
"0.5934678",
"0.5919645",
"0.59106606",
"0.58839697",
"0.58804095",
"0.5860231",
"0.58440787",
"0.5810696",
"0.58061355",
"0.57841516",
"0.57806575",
"0.5772862",
"0.5759977",
"0.57472914",
"0.57356906",
"0.5732481",
"0.5732481",
"0.5731962",
"0.5717896",
"0.5716813",
"0.5714701",
"0.571266",
"0.5711128",
"0.57087034",
"0.57051474",
"0.56913555",
"0.5686452",
"0.566914",
"0.56648046",
"0.56578857",
"0.5639819",
"0.5637051",
"0.5634159",
"0.56205374",
"0.5618221",
"0.561511",
"0.5613804",
"0.5604696",
"0.5603967",
"0.558952",
"0.5584647",
"0.5584063",
"0.55777043",
"0.5570352",
"0.5565545",
"0.55651283",
"0.55611885",
"0.5534141",
"0.5534087",
"0.5533879",
"0.5523284",
"0.5521279",
"0.5518923",
"0.5516473",
"0.5510638",
"0.55089986",
"0.5503355",
"0.5496232",
"0.5491714",
"0.5490468",
"0.548823",
"0.548823",
"0.54874694",
"0.54874694",
"0.5482323",
"0.5480609",
"0.54779905",
"0.5473964",
"0.54730266",
"0.54711735",
"0.5470244",
"0.5469103",
"0.54679364",
"0.5464474",
"0.54630816",
"0.54575515",
"0.54502773",
"0.5444001",
"0.5443377",
"0.5442179",
"0.5437525",
"0.54354095",
"0.5434142",
"0.54325676",
"0.5429718",
"0.5428772",
"0.5428128",
"0.54238915",
"0.54192644"
] |
0.0
|
-1
|
GET /components/1 or /components/1.json
|
def show
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def show\n @component = service.components.find_by(slug: params[:id])\n\n render json: @component\n end",
"def show\n @component = CustomComponent.find(params[:id])\n render json: @component\n end",
"def index\n respond_with(components)\n end",
"def index\n @components = CustomComponent.where(:active => true)\n render json: @components\n end",
"def show\n @componente = Componente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @componente }\n end\n end",
"def show\n @component = Component.find(params[:id].to_i) rescue nil\n respond_to do |format|\n unless @component.blank?\n # to provide a component specific and secure representation of an object, wrap it in a presenter\n \n format.xml { render :xml => component_presenter }\n format.json { render :json => component_presenter }\n else\n format.xml { head :not_found }\n format.json { head :not_found }\n end\n end\n end",
"def show\n @finding_component = FindingComponent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @finding_component }\n end\n end",
"def components\r\n params = {\r\n method: :get,\r\n url: '/report/components',\r\n params: {\r\n reportUUID: @uuid\r\n }\r\n }\r\n @session.request(params).perform!\r\n end",
"def show\n @structure_component = StructureComponent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @structure_component }\n end\n end",
"def get(user_name, repo_name, component_id, params={})\n update_and_validate_user_repo_params(user_name, repo_name)\n normalize! params\n\n get_request(\"/2.0/repositories/#{user}/#{repo.downcase}/components/#{component_id}\", params)\n end",
"def show\n @component_widget = ComponentWidget.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @component_widget }\n end\n end",
"def get_component\n @component = Component.find(params[:id])\n end",
"def show\n @component = Component.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @component }\n end\n end",
"def show\n @comp = Comp.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comp }\n end\n end",
"def show\n @avatarcomponent = Avatarcomponent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @avatarcomponent }\n end\n end",
"def get(path, params={})\n params = merge_set_up_params(params)\n @token = \"b3688c52-9235-45ca-b01f-c5b2b83a4f4f\"\n @result = Typhoeus::Request.get(API_URL + path, :params => params,\n :headers => {\"Authorization\" => \"Basic#{@token}\"})\n puts @result.body\n # check if the url looks correct in the log\n puts @result.effective_url\n # parse the result to json\n return JSON.parse(@result.body)\n end",
"def update\n @component = service.components.find_by!(slug: params[:id])\n\n if @component.update(component_params)\n head :no_content\n else\n render json: @component.errors, status: :unprocessable_entity\n end\n end",
"def create\n @component = service.components.new(component_params)\n\n if @component.save\n render json: @component, status: :created, location: @component\n else\n render json: @component.errors, status: :unprocessable_entity\n end\n end",
"def list_active_aos_versions(args = {}) \n get(\"/aosversions.json/\", args)\nend",
"def new\n @finding_component = FindingComponent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @finding_component }\n end\n end",
"def index\n @articulocomps = Articulocomp.all\n\n respond_to do |format|\n format.html # index.html.erb\n #format.json { render json: @articulocomps }\n end\n end",
"def index\n @component_props = ComponentProp.all\n # @page_components = PageComponent.all\n end",
"def show\n render json: @course, status: :found\n end",
"def index\n @courts = Court.by_name\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courts }\n end\n end",
"def show\n @installed_component = InstalledComponent.find(params[:id].to_i) rescue nil\n respond_to do |format|\n if @installed_component.present?\n # to provide a installed_component specific and secure representation of an object, wrap it in a presenter\n\n format.xml { render :xml => installed_component_presenter }\n format.json { render :json => installed_component_presenter }\n else\n format.xml { head :not_found }\n format.json { head :not_found }\n end\n end\n end",
"def new\n @componente = Componente.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @componente }\n end\n end",
"def get(path='', filter=nil)\n # remove the leading slash\n path = path.gsub(/\\A\\//, '')\n\n response = if filter\n categories = filter.categories.collect { |category| category.to_text }.join(',')\n attributes = filter.entities.collect { |entity| entity.attributes.combine.collect { |k, v| k + '=' + v } }.join(',')\n\n headers = self.class.headers.clone\n headers['Content-Type'] = 'text/occi'\n headers['Category'] = categories unless categories.empty?\n headers['X-OCCI-Attributes'] = attributes unless attributes.empty?\n\n self.class.get(@endpoint + path, :headers => headers)\n else\n self.class.get(@endpoint + path)\n end\n\n response_msg = response_message response\n raise \"HTTP GET failed! #{response_msg}\" unless response.code.between? 200, 300\n\n Occi::Log.debug \"Response location: #{('/' + path).match(/\\/.*\\//).to_s}\"\n kind = @model.get_by_location(('/' + path).match(/\\/.*\\//).to_s) if @model\n\n Occi::Log.debug \"Response kind: #{kind}\"\n\n if kind\n kind.related_to? Occi::Core::Resource ? entity_type = Occi::Core::Resource : entity_type = nil\n entity_type = Occi::Core::Link if kind.related_to? Occi::Core::Link\n end\n\n entity_type = Occi::Core::Resource unless entity_type\n\n Occi::Log.debug \"Parser call: #{response.content_type} #{path.include?('-/')} #{entity_type} #{response.headers.inspect}\"\n collection = Occi::Parser.parse(response.content_type, response.body, path.include?('-/'), entity_type, response.headers)\n\n Occi::Log.debug \"Parsed collection: empty? #{collection.empty?}\"\n collection\n end",
"def index\n endpoint(get(services_url).body)\n end",
"def show\n @requests_transferences_components_detail = Requests::Transferences::Components::Detail.find(params[:id])\n respond_to do |format|\n format.html\n end\n end",
"def index\n @component_lists = ComponentList.all\n end",
"def index\n @clients = Client.all\n @uuid = params[:uuid]\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n end",
"def get(path='', filter=nil)\n # remove the leading slash\n path = path.gsub(/\\A\\//, '')\n\n response = if filter\n categories = filter.categories.collect { |category| category.to_text }.join(',')\n attributes = filter.entities.collect { |entity| entity.attributes.combine.collect { |k, v| k + '=' + v } }.join(',')\n\n headers = self.class.headers.clone\n headers['Content-Type'] = 'text/occi'\n headers['Category'] = categories unless categories.empty?\n headers['X-OCCI-Attributes'] = attributes unless attributes.empty?\n\n self.class.get(@endpoint + path, :headers => headers)\n else\n self.class.get(@endpoint + path)\n end\n\n response_msg = response_message response\n raise \"HTTP GET failed! #{response_msg}\" unless response.code.between? 200, 300\n\n Occi::Log.debug \"Response location: #{('/' + path).match(/\\/.*\\//).to_s}\"\n kind = @model.get_by_location(('/' + path).match(/\\/.*\\//).to_s) if @model\n\n Occi::Log.debug \"Response kind: #{kind}\"\n\n if kind\n kind.related_to? Occi::Core::Resource ? entity_type = Occi::Core::Resource : entity_type = nil\n entity_type = Occi::Core::Link if kind.related_to? Occi::Core::Link\n end\n\n Occi::Log.debug \"Parser call: #{response.content_type} #{entity_type} #{path.include?('-/')}\"\n collection = Occi::Parser.parse(response.content_type, response.body, path.include?('-/'), entity_type, response.headers)\n\n Occi::Log.debug \"Parsed collection: empty? #{collection.empty?}\"\n collection\n end",
"def show\n @comp_info = CompInfo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comp_info }\n end\n end",
"def index\n @opponent = Opponent.all\n render json: @opponent\n end",
"def get(path, params={})\n params = merge_set_up_params(params)\n JSON.parse(Typhoeus::Request.get(API_URL + path, :params => params).body)[\"response\"]\n end",
"def get_company_by_company_part\n @parts = CompaniesController::CompanyService.get_company_by_company_part(params[:param_part])\n if !@parts.nil?\n respond_to do |format|\n format.json{ render json: @parts}\n end \n else\n #não foi encontrado as informacoes\n end\n\tend",
"def components(key)\n response = fetch({:key => \"#{key}/components\"})\n Field.new(response.parsed_response)\n end",
"def show\n @compliment = Compliment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @compliment }\n end\n end",
"def index\n @ivn_components = IvnComponent.all\n end",
"def set_component\n # Loads a Component object with associated rules, reviews,\n # descriptions, checks and additional answers where ID is equal to params id.\n @component = Component.eager_load(\n rules: [:reviews, :disa_rule_descriptions, :rule_descriptions, :checks,\n :additional_answers, :satisfies, :satisfied_by, {\n srg_rule: %i[disa_rule_descriptions rule_descriptions checks]\n }]\n ).find_by(id: params[:id])\n\n # Returns out of the method If the Component instance variable does exist.\n return if @component.present?\n\n message = 'The requested component could not be found.'\n respond_to do |format|\n # Return an HTML response with an alert flash message if request format is HTML.\n format.html do\n flash.alert = message\n redirect_back(fallback_location: root_path)\n end\n # Return a JSON response with a toast message if request formt is JSON.\n format.json do\n render json: {\n toast: {\n title: 'Control not found',\n message: message,\n variant: 'danger'\n }\n }, status: :not_found\n end\n end\n end",
"def index\n @apps = @client.apps\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @apps }\n end\n end",
"def index\n @courses = Course.all\n render json: @courses, status: :ok\n end",
"def view\n res = @client.get(path)\n @attributes = res.json if res.success?\n end",
"def index\n @gets = Get.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gets }\n end\n end",
"def show\n @components_item = Components::Item.find(params[:id])\n respond_to do |format|\n# format.html # show.html.erb\n# format.json { render json: @components_item }\n format.js\n end\n end",
"def json_get(path, params={})\n json_request(:get, path, params)\n end",
"def index\n @courses = Course.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courses }\n end\n end",
"def index\n @courses = Course.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courses }\n end\n end",
"def index\n # Check for filters\n @courses = Course.getCourseInformation(params[:dept],params[:course])\n @page_title = \"Browse Courses\"\n respond_to do |format|\n format.html\n format.json {render json: @courses }\n end\n end",
"def index\n @courses = Course.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courses}\n end\n end",
"def show\n @complaint = Complaint.find(params[:id])\n\n render json: @complaint\n end",
"def index\n @components_front_levers = Components::FrontLever.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @components_front_levers }\n end\n end",
"def show\n @blobs_component = BlobsComponent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @blobs_component }\n end\n end",
"def get(url, options={})\n resp = RestClient.get url, rest_client_options(options)\n Representation.new self, MultiJson.load(resp)\n end",
"def index\n @components_saddles = Components::Saddle.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @components_saddles }\n end\n end",
"def index\n @slug = params[:slug]\n @page = Page.where(:slug => @slug).includes(:page_component).first\n\n @components = Hash.new\n\n @page.page_component.each_with_index do |component, index|\n props_hash = Hash.new\n component.component_content.each_with_index do |prop, prop_index|\n props_hash.merge!({prop.name => prop.value})\n # component_props.push(props_hash)\n end\n @components[@page.page_component[index].react_component.component_name] = props_hash\n end\n\n\n render \"renders/index\"\n end",
"def get_aos_version(args = {}) \n get(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def index\n render json: Client.all\n end",
"def get_part_by_category\n @categorys = PartsController::PartService.get_part_by_category(params[:param]);\n respond_to do |format|\n format.json { render json: @categorys }\n end \n end",
"def index\n @react_components = ReactComponent.all\n end",
"def show\n @graded_component = GradedComponent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @graded_component }\n end\n end",
"def get(params={})\n rpc_call :get, params\n end",
"def index\n @competencies = Competency.all\n respond_to do |format|\n format.json { render json: @competencies }\n end\n end",
"def get(endpoint, url, args, version = 'v1')\n qs = build_qs(args)\n req_url = \"#{url}/api/#{version}/#{endpoint}?#{qs}\"\n\n request(req_url, :GET)\n end",
"def index\n @clues = Clue.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clues }\n end\n end",
"def index\n get('')\n end",
"def info\n get '/'\n end",
"def get(url, params = {})\n client.get(url, params).body\n end",
"def get_part_by_car\n @cars = PartsController::PartService.get_part_by_car(params[:param]);\n respond_to do |format|\n format.json { render json: @cars }\n end \n end",
"def new\n @components_blob = BlobsComponent.new\n @component = Component.find( params[:component_id] )\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @components_blob }\n end\n end",
"def index\n query = params[:q]\n @courses = query ? Course.search(query) : Course.all.order(:id)\n\n render json: @courses\n end",
"def get(path, params)\n parse_response @client[path].get(:params => params)\n end",
"def show\n @opponent = Opponent.find(params[:id])\n render json: @opponent\n end",
"def show\n @component_category = ComponentCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @component_category }\n end\n end",
"def show\n @composition = Composition.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @composition }\n end\n end",
"def show\n @core = Core.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @core }\n end\n end",
"def index\n @equipos = Equipo.all\n render json: @equipos, status: :ok\n end",
"def show\n @requests_purchases_components_detail = Requests::Purchases::Components::Detail.find(params[:id])\n respond_to do |format|\n format.html\n end\n end",
"def index\n @commemts = Commemt.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @commemts }\n end\n end",
"def get(path, params = {})\n path = File.join(@prefix, path)\n JSON.parse @conn.get(path, params).body\n end",
"def index\n course = Course.find(params[:course_id])\n sections = course.sections.all\n render json: sections.order(:id)\n end",
"def procurement_catalog_id_components_component_id_get_with_http_info(id, component_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: CatalogComponentsApi.procurement_catalog_id_components_component_id_get ...\"\n end\n # verify the required parameter 'id' is set\n fail ArgumentError, \"Missing the required parameter 'id' when calling CatalogComponentsApi.procurement_catalog_id_components_component_id_get\" if id.nil?\n # verify the required parameter 'component_id' is set\n fail ArgumentError, \"Missing the required parameter 'component_id' when calling CatalogComponentsApi.procurement_catalog_id_components_component_id_get\" if component_id.nil?\n # resource path\n local_var_path = \"/procurement/catalog/{id}/components/{componentId}\".sub('{format}','json').sub('{' + 'id' + '}', id.to_s).sub('{' + 'componentId' + '}', component_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = []\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n 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 => 'CatalogComponent')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: CatalogComponentsApi#procurement_catalog_id_components_component_id_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n @props = Prop.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @props }\n end\n end",
"def index\n @clients = Client.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n end",
"def index\n @clients = Client.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n\n end",
"def get_component_any(componentName, componentInfo=nil)\n return $marathon.getComponent_any(ComponentId.new(componentName, componentInfo))\nend",
"def new\n @structure_component = StructureComponent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @structure_component }\n end\n end",
"def index(**params)\n params.stringify_keys!\n path = nest_path_within_parent(plural_resource_path, params)\n api_request(:get, path, params: params)\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml # index.xml.builder\n format.json { render :json => ServiceCatalographer::Api::Json.index(\"service_providers\", json_api_params, @service_providers).to_json }\n format.bljson { render :json => ServiceCatalographer::Api::Bljson.index(\"service_providers\", @service_providers).to_json }\n end\n end",
"def new\n @components_photo = ComponentsPhoto.new\n @component = Component.find( params[:component_id] )\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @components_photo }\n end\n end",
"def get_aos_version_by_name(args = {}) \n get(\"/aosversions.json/version/#{args[:aosVersionName]}\", args)\nend",
"def get_component_any(componentName, componentInfo=nil)\n return $marathon.getComponent_any(ComponentId.new(componentName, componentInfo))\nend",
"def show\n @court = Court.friendly.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @court }\n end\n end",
"def index\n @courts = Court.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courts }\n end\n end",
"def get(route='', params = {}, filter = nil)\n url = base_url + route\n unless filter.nil?\n url << '/' + \"(#{ERB::Util.url_encode(filter)})\"\n end\n url << '.json'\n begin\n JSON.parse(RestClient.get(url, params: params))\n rescue RestClient::ResourceNotFound => e\n Object.new\n end\n end",
"def index\n @clients = Client.where(params.except(:action, :controller, :format)).to_a # TODO: remove .to_a when Rails to_json bug fixed\n respond_with(@clients)\n end",
"def get(*args)\n params = args.extract_options!\n @connection.get do |req|\n req.url versioned_path(args), params\n end\n end",
"def get(entity)\n @components[entity.id] \n end",
"def index\n @colegios = Colegio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @colegios }\n end\n end",
"def list\n get('/')\n end",
"def index\n apis = site_account.api_docs_services\n .published\n .with_system_names((params[:services] || \"\").split(\",\"))\n .select{ |api| api.specification.swagger_1_2? }\n\n respond_with({\n swaggerVersion: \"1.2\",\n apis: apis.map!{ |service| swagger_spec_for(service) },\n basePath: \"#{request.protocol}#{request.host}\"\n })\n end"
] |
[
"0.74488866",
"0.6933603",
"0.66943616",
"0.6623955",
"0.65852815",
"0.64780265",
"0.6385005",
"0.6161339",
"0.61601275",
"0.61301696",
"0.6104537",
"0.60741526",
"0.60249203",
"0.5866941",
"0.58461773",
"0.5841321",
"0.58016646",
"0.5797771",
"0.57730633",
"0.57729113",
"0.57704896",
"0.57385993",
"0.5680328",
"0.5654562",
"0.56480247",
"0.56454766",
"0.5617694",
"0.5616649",
"0.56140196",
"0.55975604",
"0.5586094",
"0.5581083",
"0.55622995",
"0.5554261",
"0.5552183",
"0.55501837",
"0.55492884",
"0.55386704",
"0.5513946",
"0.55117536",
"0.5510352",
"0.5503756",
"0.5500895",
"0.5486492",
"0.5486004",
"0.548048",
"0.54778296",
"0.54778296",
"0.5470438",
"0.54701895",
"0.5465714",
"0.5458122",
"0.54574156",
"0.54564196",
"0.54548347",
"0.54511446",
"0.5450535",
"0.5447055",
"0.54433626",
"0.54407585",
"0.5438698",
"0.54245734",
"0.5421773",
"0.54189223",
"0.54122025",
"0.54060847",
"0.5403117",
"0.5399778",
"0.53982705",
"0.53928417",
"0.5392503",
"0.5385684",
"0.5383122",
"0.5373187",
"0.53707546",
"0.5369311",
"0.5368707",
"0.53649306",
"0.53649217",
"0.53643537",
"0.5363701",
"0.5360145",
"0.5358666",
"0.53527504",
"0.5352141",
"0.534685",
"0.5346775",
"0.5341498",
"0.5341221",
"0.5338205",
"0.53366536",
"0.53353584",
"0.533525",
"0.5334956",
"0.53326064",
"0.5321329",
"0.5318555",
"0.5318485",
"0.5315495",
"0.5313561",
"0.53066385"
] |
0.0
|
-1
|
POST /components or /components.json
|
def create
@component = Component.new(component_params)
respond_to do |format|
if @component.save
format.html { redirect_to @component, notice: "Component was successfully created." }
format.json { render :show, status: :created, location: @component }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @component.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n @component = service.components.new(component_params)\n\n if @component.save\n render json: @component, status: :created, location: @component\n else\n render json: @component.errors, status: :unprocessable_entity\n end\n end",
"def create\n flash[:notice] = 'The component was successfully created.' if component.save\n respond_with(component)\n end",
"def create\n @componente = Componente.new(params[:componente])\n\n respond_to do |format|\n if @componente.save\n format.html { redirect_to @componente, notice: 'Componente was successfully created.' }\n format.json { render json: @componente, status: :created, location: @componente }\n else\n format.html { render \"new\" }\n format.json { render json: @componente.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @component = Component.new(params[:component])\n\n respond_to do |format|\n if @component.save\n flash[:notice] = 'Component was successfully created.'\n format.html { redirect_to(edit_component_path(@component)) }\n format.xml { render :xml => @component, :status => :created, :location => @component }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @component.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @component = Component.new(component_params)\n if @component.save\n flash[:notice] = 'Successfully created component!'\n redirect_to components_path and return\n else\n render action: 'new'\n end\n end",
"def create\n @react_component = ReactComponent.new(react_component_params)\n\n respond_to do |format|\n if @react_component.save\n format.html { redirect_to @react_component, notice: 'React component was successfully created.' }\n format.json { render :show, status: :created, location: @react_component }\n else\n format.html { render :new }\n format.json { render json: @react_component.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @finding_component = FindingComponent.new(params[:finding_component])\n\n respond_to do |format|\n if @finding_component.save\n format.html { redirect_to @finding_component, :notice => 'Finding component was successfully created.' }\n format.json { render :json => @finding_component, :status => :created, :location => @finding_component }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @finding_component.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @page = Page.new(page_params)\n\n # TwitterUser.create(\n # @users_array.map do |u|\n # { username: u.username, display_name: u.name }\n # end\n # )\n # puts @page.components.first\n # puts format.json {page_params}\n # @page.components do |comp|\n # @page.components.build(comp)\n # end\n # @component = Component.new(page_id: @page.id, component: {name:page_params.component.name})\n # @component = Component.new(page_id: @page.id)\n # @page = Page.find(params[:page_id])\n # @page.save\n # @page.update_attributes(@page.components)\n respond_to do |format|\n if @page.save\n format.html { redirect_to @page, notice: 'Page was successfully created.' }\n format.json { render :show, status: :created, location: @page }\n else\n format.html { render :new }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n respond_with(component)\n end",
"def post_component\n @assessment = Assessment.find(params[:id])\n @structure_component = StructureComponent.new\n @structure_component.assessment_id = @assessment.id\n @structure_component.assessment_component_id = params[:assessment_component]\n @structure_component.tenant_id = @assessment.tenant_id\n @structure_component.save\n redirect_to(\"/structure_components/create_structure/#{@assessment.id}\")\n end",
"def create\n @structure_component = StructureComponent.new(params[:structure_component])\n\n respond_to do |format|\n if @structure_component.save\n format.html { redirect_to @structure_component, notice: 'Structure component was successfully created.' }\n format.json { render json: @structure_component, status: :created, location: @structure_component }\n else\n format.html { render action: \"new\" }\n format.json { render json: @structure_component.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @component = Component.new(component_params)\n\n respond_to do |format|\n if @component.save\n format.html { redirect_to components_path,:trackingsheet_id=>component_params[:trackingsheet], notice: 'Component was successfully created.' }\n format.json { render :show, status: :created, location: @component }\n else\n format.html { render :new }\n format.json { render json: @component.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @componente = Componente.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @componente }\n end\n end",
"def index\n respond_with(components)\n end",
"def add_components\n #Checks if parent_id is a Product or Component based on a string value\n @parent = get_parent(params[:parent_id])\n\n #Components to Add\n if(!@parent.components.nil?)\n @parent.components.clear\n end\n if(!params[:component_parent_ids].nil?)\n for id in params[:component_parent_ids]\n @parent.components.push(Component.find(id))\n end\n end\n respond_to do |format|\n if @parent.save\n format.html { redirect_to session[:rq], notice: 'Component was successfully added.' }\n format.json { render json: @parent, status: :created, location: @parent }\n else\n format.html { render action: \"\" }\n format.json { render json: @parent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @component = service.components.find_by!(slug: params[:id])\n\n if @component.update(component_params)\n head :no_content\n else\n render json: @component.errors, status: :unprocessable_entity\n end\n end",
"def create\n @component_widget = ComponentWidget.new(params[:component_widget])\n\n respond_to do |format|\n if @component_widget.save\n format.html { redirect_to @component_widget, notice: 'Component widget was successfully created.' }\n format.json { render json: @component_widget, status: :created, location: @component_widget }\n else\n format.html { render action: \"new\" }\n format.json { render json: @component_widget.errors, status: :unprocessable_entity }\n end\n end\n end",
"def component_params\n params.require(:component).permit(:name)\n end",
"def new\n @finding_component = FindingComponent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @finding_component }\n end\n end",
"def component_params\n params.require(:component).permit(:kind, :list_id, :part_id)\n end",
"def create\n process_fields\n @components_item = Components::Item.new(params[:components_item])\n index\n respond_to do |format|\n if @components_item.save\n Stocks::Component.create!({ component: @components_item, quantity: params[:initial_stock_qty], price: params[:components_item][:price] })\n format.js { @notice = 'Componente creado correctamente.'\n render 'index' }\n else\n format.js { \n render action: \"new\"}\n end\n end\n end",
"def create\n @component = CustomComponent.new(component_params)\n if (params[:preview])\n @component.cache_view_data(false)\n render json: @component\n else\n if @component.save && @component.cache_view_data\n render json: @component\n else\n render json: {errors: @component.errors.full_messages}, status: :bad_request\n end\n end\n end",
"def create\n @component_list = ComponentList.new(component_list_params)\n\n respond_to do |format|\n if @component_list.save\n format.html { redirect_to @component_list, notice: 'Component list was successfully created.' }\n format.json { render :show, status: :created, location: @component_list }\n else\n format.html { render :new }\n format.json { render json: @component_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @structure_component = StructureComponent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @structure_component }\n end\n end",
"def create\n @component_prop = ComponentProp.new(component_prop_params)\n\n respond_to do |format|\n if @component_prop.save\n format.html { redirect_to @component_prop, notice: 'Component prop was successfully created.' }\n format.json { render :show, status: :created, location: @component_prop }\n else\n format.html { render :new }\n format.json { render json: @component_prop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @doc = Doc.new(params[:doc])\n\n respond_to do |format|\n if @doc.save\n format.html { redirect_to @doc, notice: \"\\\"#{@doc.component}\\\" was successfully created.\" }\n format.json { render json: @doc, status: :created, location: @doc }\n else\n format.html { render action: \"new\" }\n format.json { render json: @doc.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @component_widget = ComponentWidget.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @component_widget }\n end\n end",
"def create\n @comp = Comp.new(comp_params)\n\n respond_to do |format|\n if @comp.save\n format.html { redirect_to @comp, notice: 'Comp was successfully created.' }\n format.json { render action: 'show', status: :created, location: @comp }\n else\n format.html { render action: 'new' }\n format.json { render json: @comp.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @component = Component.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @component }\n end\n end",
"def create\n @project_component = ProjectComponent.new(project_component_params)\n\n respond_to do |format|\n if @project_component.save\n format.html { redirect_to project_project_component_path(@project_component.project, @project_component), notice: 'Project component was successfully created.' }\n format.json { render :show, status: :created, location: @project_component }\n else\n format.html { render :new }\n format.json { render json: @project_component.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @avatarcomponent = Avatarcomponent.new(params[:avatarcomponent])\n\n respond_to do |format|\n if @avatarcomponent.save\n format.html { redirect_to @avatarcomponent, notice: 'Avatarcomponent was successfully created.' }\n format.json { render json: @avatarcomponent, status: :created, location: @avatarcomponent }\n else\n format.html { render action: \"new\" }\n format.json { render json: @avatarcomponent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ivn_component = IvnComponent.new(ivn_component_params)\n\n respond_to do |format|\n if @ivn_component.save\n format.html { redirect_to admin_ivn_component_url(@ivn_component), notice: \"Ivn component was successfully created.\" }\n format.json { render :show, status: :created, location: @ivn_component }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @ivn_component.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @component.update_attributes(component_params)\n format.html { redirect_to @component, notice: \"Component was successfully updated.\" }\n format.json { render :show, status: :ok, location: @component }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @component.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(component_params)\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to @user, notice: 'UserComponent was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @compliment = Compliment.new(compliment_params)\n\n if @compliment.save\n render :show, status: :created, location: @compliment\n else\n render json: @compliment.errors, status: :unprocessable_entity\n end\n end",
"def create\r\n @ph_electric_component = PhElectricComponent.new(params[:ph_electric_component])\r\n\r\n respond_to do |format|\r\n if @ph_electric_component.save\r\n format.html { redirect_to(@ph_electric_component) }\r\n format.xml { render :xml => @ph_electric_component, :status => :created, :location => @ph_electric_component }\r\n else\r\n format.html { render :action => \"new\" }\r\n format.xml { render :xml => @ph_electric_component.errors, :status => :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @blobs_component = BlobsComponent.new(params[:blobs_component])\n\n respond_to do |format|\n if @blobs_component.save\n flash[:notice] = 'BlobsComponent was successfully created.'\n format.html { redirect_to( edit_blobs_component_url(@blobs_component) ) }\n format.xml { render :xml => @blobs_component, :status => :created, :location => @blobs_component }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @blobs_component.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post_rest_api(endpoint, data, http)\n rest_api_endpoint = \"/classifier-api/v1/#{endpoint}\"\n\n # Create an HTTP POST request against the specified REST API endpoint\n request = Net::HTTP::Post.new(rest_api_endpoint)\n # Set the Content-Type and data of the HTTP POST request\n request.content_type = \"application/json\"\n request.body = data\n # Submit the request\n response = http.request(request)\n # Return the response bosy (JSON containing the result of the POST operation)\n response.body\nend",
"def create\n @kicad_component = KicadComponent.new( params[:kicad_component] )\n\n respond_to do |format|\n if @kicad_component.save\n flash[:notice] = 'KicadComponent was successfully created.'\n format.html { redirect_to(kicad_components_url) }\n format.xml { render :xml => @kicad_component, :status => :created, :location => @kicad_component }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @kicad_component.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def component_params\n params.permit(:component_name)\n end",
"def post(path, json, params = {})\n if path.include?('covid19')\n request = Net::HTTP::Post.new(path, @headers)\n else\n request = Net::HTTP::Post.new('/v2' + path, @headers)\n end\n request.add_field('Content-Type', 'application/json')\n request.body = json\n params.each do |k, v|\n request[k] = v\n end\n send_request(request)\n end",
"def create\n render json: Company.create(params[\"company\"])\n end",
"def create\n\n client = Cliente.new\n\n client.nombre = params[:nombre]\n client.cedula = params[:cedula]\n client.pagina = params[:pagina]\n\n client.dirrecion = params[:dirrecion]\n client.telefono = params[:telefono]\n \n client.sector = params[:sector]\n \n\n if client.save\n \n\n render(json: client,status: 201 ,location: client)\n else\n\n render(json: client.errors,status: 422 )\n\n end\n end",
"def create\n @course = Course.new(course_params)\n @course.save\n render_jsonapi_response(@course)\n end",
"def create\n @complaint = Complaint.new(params[:complaint])\n\n if @complaint.save\n render json: @complaint, status: :created, location: @complaint\n else\n render json: @complaint.errors, status: :unprocessable_entity\n end\n end",
"def new\n @components_blob = BlobsComponent.new\n @component = Component.find( params[:component_id] )\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @components_blob }\n end\n end",
"def update\n flash[:notice] = 'The component was successfully updated.' if component.update_attributes(params[:component])\n respond_with(component)\n end",
"def new\n @components_category = Components::Category.new\n respond_to do |format|\n format.html\n# format.json { render json: @components_category }\n format.js\n end\n end",
"def create\n respond_to do |format|\n if handle_component && @generator.save\n format.html { redirect_to @generator, notice: 'Generator was successfully created.' }\n format.json { render action: 'show', status: :created, location: @generator }\n else\n format.html { render action: 'new' }\n format.json { render json: {status: :unprocessable_entity, errors: 'Could Not Create Generator'} }\n end\n end\n end",
"def create\n client= Client.new\n client.cedula= params[:cedula]\n client.sector= params[:sector]\n client.nombre= params[:nombre]\n client.telefono= params[:telefono]\n client.pagina= params[:pagina]\n client.direccion= params[:direccion]\n if client.save\n render(json: client, status: 201 , location: client)\n else \n render(json: client.errors, status: 422)\n end\n end",
"def create\n @comp_todo = CompTodo.new(comp_todo_params)\n\n respond_to do |format|\n if @comp_todo.save\n format.html { redirect_to component_path(@comp_todo.component_id), notice: 'Task was successfully created.' }\n format.json { render action: 'show', status: :created, location: @comp_todo }\n else\n format.html { redirect_to component_path(@comp_todo.component_id), alert: 'Task was not created please fill inn all the fields when making a task.' }\n format.json { render json: @comp_todo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @component = service.components.find_by(slug: params[:id])\n\n render json: @component\n end",
"def create\n @components_photo = ComponentsPhoto.new( params[:components_photo] )\n\n respond_to do |format|\n if @components_photo.save\n flash[:notice] = 'ComponentsPhoto was successfully created.'\n format.html { redirect_to( edit_component_path(@components_photo.component) ) }\n format.xml { render :xml => @components_photo, :status => :created, :location => @components_photo }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @components_photo.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def react_component_params\n params.require(:react_component).permit(:nickname, :component_name)\n\n end",
"def post(json)\n with_endpoint do |endpoint|\n url = [endpoint, @resource_name].compact.join('/')\n url += \"/\"\n return HTTParty.post(url, :body => json, :timeout => 4, :headers => { 'Content-Type' => 'application/json' })\n end\n end",
"def new\n @kicad_component = KicadComponent.new\n\n if params[:component_id]\n component = Component.find( params[:component_id] )\n end\n @kicad_component.component = component\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @kicad_component }\n end\n end",
"def add_tenant_circle(args = {}) \n post(\"/tenantcircles.json/\", args)\nend",
"def create\n @compte = Compte.new(compte_params)\n\n respond_to do |format|\n if @compte.save\n format.html { redirect_to @compte, notice: 'Compte was successfully created.' }\n format.json { render :show, status: :created, location: @compte }\n else\n format.html { render :new }\n format.json { render json: @compte.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_form\n verify_ajax_request\n require_parameters :component\n render :partial => 'issue/create_form'\n end",
"def destroy\n @component.destroy\n respond_to do |format|\n format.html { redirect_to components_url, notice: \"Component was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @component.destroy\n respond_to do |format|\n format.html { redirect_to components_url, notice: 'Component was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def create\n @component_fund = ComponentFund.new(component_fund_params)\n\n respond_to do |format|\n if @component_fund.save\n format.html { redirect_to @component_fund, notice: 'Component fund was successfully created.' }\n format.json { render :show, status: :created, location: @component_fund }\n else\n format.html { render :new }\n format.json { render json: @component_fund.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @owner_salary_component = OwnerSalaryComponent.new(owner_salary_component_params)\n\n respond_to do |format|\n if @owner_salary_component.save\n format.html { redirect_to @owner_salary_component, notice: 'Owner salary component was successfully created.' }\n format.json { render :show, status: :created, location: @owner_salary_component }\n else\n format.html { render :new }\n format.json { render json: @owner_salary_component.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @compliment = Compliment.new(params[:compliment])\n\n respond_to do |format|\n if @compliment.save\n format.html { redirect_to @compliment, notice: 'Compliment was successfully created.' }\n format.json { render json: @compliment, status: :created, location: @compliment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @compliment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_component\n # Loads a Component object with associated rules, reviews,\n # descriptions, checks and additional answers where ID is equal to params id.\n @component = Component.eager_load(\n rules: [:reviews, :disa_rule_descriptions, :rule_descriptions, :checks,\n :additional_answers, :satisfies, :satisfied_by, {\n srg_rule: %i[disa_rule_descriptions rule_descriptions checks]\n }]\n ).find_by(id: params[:id])\n\n # Returns out of the method If the Component instance variable does exist.\n return if @component.present?\n\n message = 'The requested component could not be found.'\n respond_to do |format|\n # Return an HTML response with an alert flash message if request format is HTML.\n format.html do\n flash.alert = message\n redirect_back(fallback_location: root_path)\n end\n # Return a JSON response with a toast message if request formt is JSON.\n format.json do\n render json: {\n toast: {\n title: 'Control not found',\n message: message,\n variant: 'danger'\n }\n }, status: :not_found\n end\n end\n end",
"def create\n @course = Course.new(course_params)\n\n #section_chunks = get_chunks(params)\n sections = JSON.parse(params['sections'])\n\n # The course has been created by the signed-in user.\n @course.user_id = current_user.id\n respond_to do |format|\n if @course.save\n # Save the course's subcomponents to the course.\n update_section_chunks(sections)\n\n format.html { redirect_to @course }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render new_course_path }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def component_params\n params.require(:component).permit(:model, :category, :serial_number, :rgb, :brand_id)\n end",
"def post(path, data = {})\n request 'POST', path, body: data.to_json\n end",
"def new\n @avatarcomponent = Avatarcomponent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @avatarcomponent }\n end\n end",
"def show\n @component = CustomComponent.find(params[:id])\n render json: @component\n end",
"def post\n Salesforce.set_http(session[:accesstoken], session[:accessurl])\n \t@response = Salesforce.create_post(params)\n \trespond_to do |format|\n format.json { render :json => @response.to_json}\n # example of multiple reponses mapped to one object\n # format.json { render :json => {:data => @response, :meta => @describe}.to_json}\n \tend\n end",
"def create\n @graded_component = GradedComponent.new(params[:graded_component])\n\n respond_to do |format|\n if @graded_component.save\n flash[:notice] = 'GradedComponent was successfully created.'\n format.html { redirect_to(@graded_component) }\n format.xml { render :xml => @graded_component, :status => :created, :location => @graded_component }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @graded_component.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n render \"status/501_not_implemented\", status: :not_implemented\n #@course = Course.new(course_params)\n #\n #if @course.save\n # render :show, status: :created, location: @course\n #else\n # render json: @course.errors, status: :unprocessable_entity\n #end\n end",
"def create\n response = Codeclimate::Api.client.post(@path)\n response.code == \"200\"\n end",
"def create\n res = self.class.post('/', body: attrs)\n res.created?\n end",
"def components(opts = {})\n opts[:hash_form] ? hash_form_array(:component) : object_form(:component)\n end",
"def create\n @entity = Entity.new(params[:entity])\n\n respond_to do |format|\n if @entity.save\n format.html { redirect_to @entity, notice: 'Entity was successfully created.' }\n format.json { render json: @entity, status: :created, location: @entity }\n else\n format.html { render action: \"new\" }\n format.json { render json: @entity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def POST; end",
"def create\n model = params[:model]\n #NOTE: Pay attention how the data is passed as a hash. This is how locomotive expects it. Not obvious.\n # req.set_form_data('content_entry[name]' => data['name'], 'content_entry[summary]' => data['summary'], 'model' => model)\n form_data = {}\n params[:content_entry].each do |key,val|\n form_data[\"content_entry[#{key}]\"] = val\n end\n #data = params[:content_entry]\n\n uri = URI(\"#{@cms_url}/locomotive/api/content_types/#{model}/entries.json?auth_token=#{APP_CONFIG['locomotive']['auth_token']}\")\n\n req = Net::HTTP::Post.new(uri)\n req.set_form_data(form_data)\n res = Net::HTTP.start(uri.hostname, uri.port) do |http|\n http.request(req)\n end\n case res\n when Net::HTTPSuccess, Net::HTTPRedirection\n render :json => res.body\n else\n # examine response code and generate appropriate error message\n render :json => res.value\n end\n\n end",
"def create\n @elector = Elector.new(elector_params)\n\n if @elector.save\n render json: @elector, status: :created, location: @elector\n else\n render json: @elector.errors, status: :unprocessable_entity\n end\n end",
"def components\r\n params = {\r\n method: :get,\r\n url: '/report/components',\r\n params: {\r\n reportUUID: @uuid\r\n }\r\n }\r\n @session.request(params).perform!\r\n end",
"def create\n @components_saddle = Components::Saddle.new(params[:components_saddle])\n\n respond_to do |format|\n if @components_saddle.save\n format.html { redirect_to(@components_saddle, :notice => 'Saddle was successfully created.') }\n format.xml { render :xml => @components_saddle, :status => :created, :location => @components_saddle }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @components_saddle.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def component_list_params\n params[:component_list][:components_array] = params[:component_list][:components].split(\" \")\n params.require(:component_list).permit(:name, :components, :components_array)\n end",
"def create!(params={})\n raise ArgumentError, \"Error: product, component, summary, version are required args\" unless check_params([:product, :component, :summary, :version], params)\n rpc_call :create, params\n end",
"def create\n components = params[:components]\n str = ''\n i = 0\n components.each do |c|\n str = if i == 0\n c.to_s\n else\n str.to_s + ',' + c.to_s\n end\n i += 1\n end\n @c_off_cash_master = COffCashMaster.new(c_off_cash_master_params)\n @c_off_cash_master.base_component = str\n @c_off_cash_masters = COffCashMaster.all\n @c_off_cash_master.save\n @c_off_cash_master = COffCashMaster.new\n end",
"def post endpoint, data\n do_request :post, endpoint, data\n end",
"def component_op(addr, user, password, id, op)\n req_path = \"/system/console/components/#{id}\"\n payload = { 'action' => op }\n\n http_post(addr, req_path, user, password, payload)\n end",
"def create\n @comprobante = Comprobante.new(params[:comprobante])\n\n respond_to do |format|\n if @comprobante.save\n format.html { redirect_to @comprobante, notice: 'Comprobante was successfully created.' }\n format.json { render json: @comprobante, status: :created, location: @comprobante }\n else\n format.html { render action: \"new\" }\n format.json { render json: @comprobante.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(*args)\n super(*wrap_for_json_api(*args))\n end",
"def create\n # Consider request as illegal if performing POST on identifiable resource\n if params[entities_key] && params[entities_key][:id]\n render json: { errors: process_errors([\"Creation of resource with id\"], 404) }, status: :conflict\n return\n end\n \n # Upsert the entity\n entity = ConnecEntity.new(group_id: @group_id, entity_name: entities_key)\n entity.document = (entity.document || {}).merge(params[entities_key])\n entity.save\n \n if entity && entity.errors.empty?\n logger.info(\"INSPECT: #{entities_key} => #{process_entity(entity).to_json}\")\n render json: { entities_key => process_entity(entity.reload) }, status: :created, location: resource_url(entity)\n else\n render json: { errors: process_errors(entity.errors.full_messages, 400, entity) }, status: :bad_request\n end\n \n end",
"def create\n @component_in_machine = ComponentInMachine.new(component_in_machine_params)\n\n respond_to do |format|\n if @component_in_machine.save\n format.html { redirect_to @component_in_machine, notice: 'Component in machine was successfully created.' }\n format.json { render :show, status: :created, location: @component_in_machine }\n else\n format.html { render :new }\n format.json { render json: @component_in_machine.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @components_photo = ComponentsPhoto.new\n @component = Component.find( params[:component_id] )\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @components_photo }\n end\n end",
"def create(entity)\n post(resource_path_for_entity(entity), entity.to_json)\n end",
"def create\n @ba_spec = BaSpec.new(params[:ba_spec])\n\n respond_to do |format|\n if @ba_spec.save\n format.html { redirect_to ba_specs_path }\n format.json { render json: @ba_spec, status: :created, location: @ba_spec }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ba_spec.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @thing_with_react_form = ThingWithReactForm.new(thing_with_react_form_params)\n\n respond_to do |format|\n if @thing_with_react_form.save\n format.html { redirect_to @thing_with_react_form, notice: 'Thing with react form was successfully created.' }\n format.json { render :show, status: :created, location: @thing_with_react_form }\n else\n format.html { render :new }\n format.json { render json: @thing_with_react_form.errors, status: :unprocessable_entity }\n end\n end\n end",
"def component_params\n params.require(:component).permit(:fiber,:trackingsheet, :countryoforgin, :customer, :mill, :code, :hangtag2, :hangtag3, :mainlabel, :carecontentlabel, :upcsticker, :glovehanger, :hatjhook, :sizelabel)\n end",
"def create\n @composing = Composing.new(composing_params)\n\n respond_to do |format|\n if @composing.save\n format.html { redirect_to @composing, notice: 'Composing was successfully created.' }\n format.json { render :show, status: :created, location: @composing }\n else\n format.html { render :new }\n format.json { render json: @composing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def json_create_feedback\n\n @feedback = Feedback.new()\n @feedback.name = params[:name] unless params[:name].nil?\n @feedback.email = params[:email] unless params[:email].nil?\n @feedback.description = params[:description] unless params[:description].nil?\n @feedback.user_id = params[:user_id] unless params[:user_id].nil?\n\n respond_to do |format|\n if @feedback.save\n format.json { render json: @feedback, status: :created, location: @feedback }\n else\n format.json { render json: @feedback.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n components = params[:components]\n str = ''\n i = 0\n components.each do |c|\n str = if i == 0\n c.to_s\n else\n str.to_s + ',' + c.to_s\n end\n i += 1\n end\n @pf_master = PfMaster.new(pf_master_params)\n @pf_master.base_component = str\n @pf_masters = PfMaster.all\n @pf_master.save\n @pf_master = PfMaster.new\n end",
"def create\n @outlet = Outlet.new(outlet_params)\n if @outlet.save\n render json: {status:\"Successfully added!\", outlet: @outlet}\n else\n render json: {status:\"Couldn't add outlet\", outlet: @outlet}\n end\n # end\n end"
] |
[
"0.7546477",
"0.66862917",
"0.6500564",
"0.6288414",
"0.6229747",
"0.6143371",
"0.6063302",
"0.6036099",
"0.60085887",
"0.59940445",
"0.598912",
"0.5938024",
"0.5937408",
"0.5909762",
"0.5889818",
"0.5868632",
"0.5840807",
"0.5839643",
"0.5777752",
"0.5724854",
"0.57138485",
"0.5686478",
"0.56678057",
"0.5656546",
"0.56402093",
"0.5635657",
"0.56332386",
"0.56325054",
"0.5624912",
"0.5621594",
"0.56102484",
"0.56054556",
"0.5589285",
"0.5582341",
"0.5582228",
"0.55678916",
"0.5554803",
"0.55519074",
"0.5551157",
"0.5549418",
"0.553893",
"0.55008554",
"0.54898554",
"0.54708254",
"0.5468838",
"0.5449931",
"0.5439061",
"0.5439048",
"0.54370964",
"0.54325485",
"0.54241",
"0.54040235",
"0.54024464",
"0.5390455",
"0.5381363",
"0.53715813",
"0.5363393",
"0.5359374",
"0.5358245",
"0.5341812",
"0.53352237",
"0.53278375",
"0.53119236",
"0.53067195",
"0.5291068",
"0.5289916",
"0.52894634",
"0.52563316",
"0.5255727",
"0.52536494",
"0.5250657",
"0.524981",
"0.52495944",
"0.52431864",
"0.5241557",
"0.52360487",
"0.5233429",
"0.5231691",
"0.5217178",
"0.5213155",
"0.5200216",
"0.5191835",
"0.5191604",
"0.51884663",
"0.5185954",
"0.51793945",
"0.517704",
"0.517644",
"0.517375",
"0.5172186",
"0.51652354",
"0.5155864",
"0.51484156",
"0.5142432",
"0.5136417",
"0.51350635",
"0.51341385",
"0.51280266",
"0.512712",
"0.5125465"
] |
0.6787954
|
1
|
PATCH/PUT /components/1 or /components/1.json
|
def update
respond_to do |format|
if @component.update_attributes(component_params)
format.html { redirect_to @component, notice: "Component was successfully updated." }
format.json { render :show, status: :ok, location: @component }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @component.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n @component = service.components.find_by!(slug: params[:id])\n\n if @component.update(component_params)\n head :no_content\n else\n render json: @component.errors, status: :unprocessable_entity\n end\n end",
"def update\n flash[:notice] = 'The component was successfully updated.' if component.update_attributes(params[:component])\n respond_with(component)\n end",
"def update!(**args)\n @components = args[:components] if args.key?(:components)\n end",
"def update!(**args)\n @components = args[:components] if args.key?(:components)\n end",
"def update\n @componente = Componente.find(params[:id])\n\n respond_to do |format|\n if @componente.update_attributes(params[:componente])\n format.html { redirect_to @componente, notice: 'Componente was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render \"edit\" }\n format.json { render json: @componente.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @react_component.update(react_component_params)\n format.html { redirect_to @react_component, notice: 'React component was successfully updated.' }\n format.json { render :show, status: :ok, location: @react_component }\n else\n format.html { render :edit }\n format.json { render json: @react_component.errors, status: :unprocessable_entity }\n end\n end\n end",
"def edit\n respond_with(component)\n end",
"def update\n @structure_component = StructureComponent.find(params[:id])\n\n respond_to do |format|\n if @structure_component.update_attributes(params[:structure_component])\n format.html { redirect_to @structure_component, notice: 'Structure component was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @structure_component.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @component = args[:component] if args.key?(:component)\n end",
"def update!(**args)\n @component = args[:component] if args.key?(:component)\n end",
"def update\n respond_to do |format|\n if @component_prop.update(component_prop_params)\n format.html { redirect_to @component_prop, notice: 'Component prop was successfully updated.' }\n format.json { render :show, status: :ok, location: @component_prop }\n else\n format.html { render :edit }\n format.json { render json: @component_prop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update # PATCH\n raise NotImplementedError\n end",
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def update\n @finding_component = FindingComponent.find(params[:id])\n\n respond_to do |format|\n if @finding_component.update_attributes(params[:finding_component])\n format.html { redirect_to @finding_component, :notice => 'Finding component was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @finding_component.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @component_widget = ComponentWidget.find(params[:id])\n\n respond_to do |format|\n if @component_widget.update_attributes(params[:component_widget])\n format.html { redirect_to @component_widget, notice: 'Component widget was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @component_widget.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end",
"def update\n respond_to do |format|\n if @comp.update(comp_params)\n format.html { redirect_to @comp, notice: 'Comp was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @comp.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @component_list.update(component_list_params)\n format.html { redirect_to @component_list, notice: 'Component list was successfully updated.' }\n format.json { render :show, status: :ok, location: @component_list }\n else\n format.html { render :edit }\n format.json { render json: @component_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ivn_component.update(ivn_component_params)\n format.html { redirect_to admin_ivn_component_url(@ivn_component), notice: \"Ivn component was successfully updated.\" }\n format.json { render :show, status: :ok, location: @ivn_component }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @ivn_component.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @major.update(major_params)\n format.html { redirect_to @major, notice: 'Major was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @major.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(&block)\n validate_request()\n\n # Params includes all of the PATCH data at the top level along with other\n # other Rails-injected params like 'id', 'action', 'controller'. These\n # are harmless given no namespace collision and we're only interested in\n # the 'Operations' key for the actual patch data.\n #\n render(json: yield(self.safe_params()[:id], self.safe_params().to_hash()))\n end",
"def update\n @complaint = Complaint.find(params[:id])\n\n if @complaint.update_attributes(params[:complaint])\n head :no_content\n else\n render json: @complaint.errors, status: :unprocessable_entity\n end\n end",
"def patch!\n request! :patch\n end",
"def update!(**args)\n @component = args[:component] if args.key?(:component)\n @mrf_index = args[:mrf_index] if args.key?(:mrf_index)\n end",
"def update\n respond_to do |format|\n if @project_component.update(project_component_params)\n format.html { redirect_to project_project_component_path(@project_component.project, @project_component), notice: 'Project component was successfully updated.' }\n format.json { render :show, status: :ok, location: @project_component }\n else\n format.html { render :edit }\n format.json { render json: @project_component.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @patch = Patch.find(params[:id])\n\n respond_to do |format|\n if @patch.update_attributes(params[:patch])\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def update\n respond_to do |format|\n if @user.update(component_params)\n format.html { redirect_to @user, notice: 'UserComponent was successfully updated.' }\n format.json { render :show, status: :ok, location: @user }\n else\n format.html { render :edit }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_concern.update(api_v1_concern_params)\n format.html { redirect_to @api_v1_concern, notice: 'Concern was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_concern }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_concern.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @avatarcomponent = Avatarcomponent.find(params[:id])\n\n respond_to do |format|\n if @avatarcomponent.update_attributes(params[:avatarcomponent])\n format.html { redirect_to @avatarcomponent, notice: 'Avatarcomponent was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @avatarcomponent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @patch.update(patch_params)\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @blobs_component = BlobsComponent.find(params[:id])\n\n respond_to do |format|\n if @blobs_component.update_attributes(params[:blobs_component])\n flash[:notice] = 'BlobsComponent was successfully updated.'\n format.html { redirect_to(@blobs_component) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @blobs_component.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n process_fields\n @components_item = Components::Item.find(params[:id])\n index\n respond_to do |format|\n if @components_item.update_attributes(params[:components_item])\n format.js { @notice = 'Componente actualizado correctamente.' \n render 'index'}\n else\n format.js { @notice = 'Error al actualizar componente.' \n render action: \"edit\"}\n end\n end\n end",
"def update\n respond_to do |format|\n if @major.update(major_params)\n format.html { redirect_to @major, notice: 'Major was successfully updated.' }\n format.json { render :show, status: :ok, location: @major }\n else\n format.html { render :edit }\n format.json { render json: @major.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @major = Major.find(params[:id])\n\n respond_to do |format|\n if @major.update_attributes(params[:major])\n format.html { redirect_to @major, notice: 'Major was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @major.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n render json: Company.update(params[\"id\"], params[\"company\"])\n end",
"def update\n if @compliment.update(compliment_params)\n render :show, status: :ok, location: @compliment\n else\n render json: @compliment.errors, status: :unprocessable_entity\n end\n end",
"def component_status_update(statuspage_id, component, container, details, current_status)\n request :method => :post,\n :url => @url + 'component/status/update',\n :payload => {\n 'statuspage_id' => statuspage_id,\n 'component' => component,\n 'container' => container,\n 'details' => details,\n 'current_status' => current_status\n }\n end",
"def update\n respond_with []\n end",
"def update\n respond_to do |format|\n if @react.update(react_params)\n format.html { redirect_to @react, notice: 'React was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @react.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @thing_with_react_form.update(thing_with_react_form_params)\n format.html { redirect_to @thing_with_react_form, notice: 'Thing with react form was successfully updated.' }\n format.json { render :show, status: :ok, location: @thing_with_react_form }\n else\n format.html { render :edit }\n format.json { render json: @thing_with_react_form.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bundle = Bundle.find(params[:id])\n\n respond_to do |format|\n if @bundle.update_attributes(params[:bundle])\n format.html { redirect_to @bundle, notice: 'Bundle was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bundle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comp_info = CompInfo.find(params[:id])\n\n respond_to do |format|\n if @comp_info.update_attributes(params[:comp_info])\n format.html { redirect_to @comp_info, notice: 'Comp info was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comp_info.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bundle = Bundle.find(params[:id])\n\n\n respond_to do |format|\n params[:bundle][:category] = params[:bundle][:category].strip.downcase\n params[:bundle][:style] = params[:bundle][:style].strip.downcase\n params[:bundle][:color] = params[:bundle][:color].strip.downcase\n params[:bundle][:brand] = params[:bundle][:brand].strip.downcase\n params[:bundle][:make] = params[:bundle][:make].strip.downcase\n params[:bundle][:location] = params[:bundle][:location].strip.downcase\n\n if @bundle.update_attributes(params[:bundle])\n format.html { redirect_to @bundle, notice: 'Bundle was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bundle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(path, params = {})\n request(:patch, path, params)\n end",
"def patch(path, params = {})\n request(:patch, path, params)\n end",
"def update\n render status: 501, json: { errors: ['Action not implemented yet!'] }\n end",
"def update\n components = params[:components]\n str = ''\n i = 0\n components.try(:each) do |c|\n str = if i == 0\n c.to_s\n else\n str.to_s + ',' + c.to_s\n end\n i += 1\n end\n @pf_master.base_component = str\n @pf_master.update(pf_master_params)\n @pf_masters = PfMaster.all\n @pf_master = PfMaster.new\n\n end",
"def patch(type, info)\n path, info = type_info(type, :path), force_case(info)\n ida = type == :client ? 'client_id' : 'id'\n raise ArgumentError, \"info must include #{ida}\" unless id = info[ida]\n hdrs = headers\n if info && info['meta'] && (etag = info['meta']['version'])\n hdrs.merge!('if-match' => etag)\n end\n reply = json_parse_reply(@key_style,\n *json_patch(@target, \"#{path}/#{Addressable::URI.encode(id)}\", info, hdrs))\n\n # hide client endpoints that are not quite scim compatible\n type == :client && !reply ? get(type, info['client_id']): reply\n end",
"def update(resource,identifier,json)\n raise 'Not Yet Implemented'\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end",
"def put!\n request! :put\n end",
"def update\n\t\t@components.each do |comp|\n\t\t\tcomp.update\n\t\tend\n\tend",
"def update\n # actions\n path = URI(@endpoint).path\n action = URI(@req.request_uri).path.sub(path, '').split('/')\n action -= ['']\n if action.include?('_history')\n @actions = [action[0], '_history']\n else\n @actions = [action[0]]\n end\n\n # search param\n req_query = URI(@req.request_uri).query\n unless req_query.nil?\n @req_params = URI::decode_www_form(req_query).to_h\n end\n\n # requst method\n if @req.request_method == \"GET\" and @actions.include? '_history'\n @req_method = 'vread'\n elsif @req.request_method == \"GET\" and @req_params != nil\n @req_method = 'search-type'\n elsif @req.request_method == \"PUT\"\n @req_method = 'update'\n elsif @req.request_method == \"POST\"\n @req_method = 'create'\n else\n @req_method = 'read'\n end\n\n # interaction\n int1 = Interaction.last type: @actions[0], code: @req_method\n if int1.nil?\n @present = 0\n else\n @present = int1.id\n @intCode = int1.valueCode\n end\n end",
"def update\n begin\n @resource = Entity.find params[:id]\n @resource.update_attributes! params[:entity]\n render :response => :PUT\n rescue Exception => e\n @error = process_exception(e)\n render :response => :error\n end\n end",
"def update\n @component = Component.find(params[:id])\n \n changed = false\n # in case the user have changed the category \n # to keep the counter cache always up to date\n if params[:component][:category_id] != @component.category_id \n Category.decrease_counter_cache_for(@component.category_id) \n changed = true\n end\n \n respond_to do |format|\n if @component.update_attributes(params[:component])\n\n # in case the user have changed the category\n # to keep the counter cache always up to date\n Category.increase_counter_cache_for(@component.category_id) if changed\n \n flash[:notice] = 'Component was successfully updated.'\n format.html { redirect_to(@component) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @component.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @course.update(course_params)\n render_jsonapi_response(@course)\n end",
"def update\n @jetty = Jetty.find(params[:id])\n\n respond_to do |format|\n if @jetty.update_attributes(params[:jetty])\n format.html { redirect_to @jetty, notice: 'Jetty was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @jetty.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cephalopod.update(cephalopod_params)\n format.html { redirect_to @cephalopod, notice: 'Cephalopod was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cephalopod.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @compliment = Compliment.find(params[:id])\n\n respond_to do |format|\n if @compliment.update_attributes(params[:compliment])\n format.html { redirect_to @compliment, notice: 'Compliment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @compliment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @composer = Composer.find(params[:id])\n\n respond_to do |format|\n if @composer.update_attributes(params[:composer])\n format.html { redirect_to @composer, notice: 'Composer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @composer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @specie = Specie.find(params[:id])\n\n respond_to do |format|\n if @specie.update_attributes(params[:specie])\n format.html { redirect_to @specie, notice: 'Specie was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @specie.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @meteor = Meteor.find(params[:id])\n\n respond_to do |format|\n if @meteor.update_attributes(params[:meteor])\n format.html { redirect_to @meteor, notice: 'Meteor was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @meteor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @component = service.components.find_by(slug: params[:id])\n\n render json: @component\n end",
"def update\n respond_to do |format|\n format.json { render json: { status: :not_implemented } }\n end\n end",
"def update\n components = params[:components]\n str = ''\n i = 0\n components.try(:each) do |c|\n str = if i == 0\n c.to_s\n else\n str.to_s + ',' + c.to_s\n end\n i += 1\n end\n @c_off_cash_master.base_component = str\n @c_off_cash_master.update(c_off_cash_master_params)\n @c_off_cash_masters = COffCashMaster.all\n @c_off_cash_master = COffCashMaster.new\n end",
"def component_update \n if request.xhr?\n # If this is an AJAX request then we just want to delegate to the component to rerender itself\n component\n else\n # If this is from a client without javascript we want to update the session parameters and then delegate\n # back to whatever page is displaying the scaffold, which will then rerender all scaffolds with these update parameters\n update_params :default_scaffold_id => \"recipe\", :default_sort => nil, :default_sort_direction => \"asc\"\n return_to_main\n end\n end",
"def update\n respond_to do |format|\n if @minor.update(minor_params)\n format.html { redirect_to :show, notice: 'Minor was successfully updated.' }\n format.json { render :show, status: :ok, location: @minor }\n else\n format.html { render :edit }\n format.json { render json: @minor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @lens = Lens.find(params[:id])\n attrb = select_params(lens_params)\n # linear_data is an array of Objects of Components Properties\n # that needs to be deserialized correctly\n attrb[\"linear_data\"] = JSON.parse(attrb[\"linear_data\"])\n lens = Lens.update(attrb)\n \n # @lens.update(lens_params)\n # render inline: \"<%= @lens.id %>\"\n end",
"def _fetch_and_patch component\n begin\n component.fetch\n rescue => ex\n @log.error(\"#{component.extended_name} could not be fetched.\")\n debug \"_fetch_and_patch: #{ex.message}\"\n return false\n end\n if component.has_patches?\n begin\n component.patch\n rescue => ex\n @log.error(\"#{component.extended_name}: #{ex.message}\")\n return false\n end\n end\n return true \n end",
"def update\n respond_to do |format|\n if @anything.update(anything_params)\n format.html { redirect_to @anything, notice: 'Anything was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @anything.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(path)\n output { patch(path, params) }\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\n @stuff = Stuff.find(params[:id])\n\n respond_to do |format|\n if @stuff.update_attributes(params[:stuff])\n format.html { redirect_to @stuff, :notice => 'Stuff was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @stuff.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n updated_resource = update_resource(resource, resource_params)\n if updated_resource.errors.blank?\n head :no_content\n else\n render json: serialize_invalid_attributes(updated_resource.errors),\n status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_resource.update(api_v1_resource_params)\n format.html { redirect_to @api_v1_resource, notice: 'Resource was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_resource }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @kicad_component = KicadComponent.find( params[:id] )\n\n respond_to do |format|\n if @kicad_component.update_attributes(params[:kicad_component])\n flash[:notice] = 'KicadComponent was successfully updated.'\n format.html { redirect_to(kicad_components_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @kicad_component.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @specification = Specification.find(params[:id])\n\n respond_to do |format|\n if @specification.update_attributes(params[:specification])\n format.html { redirect_to @specification, notice: 'Specification was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @specification.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @thing = Thing.find(params[:id])\n\n respond_to do |format|\n if @thing.update_attributes(params[:thing])\n format.html { redirect_to things_path, notice: 'Your thing was successfully updated!' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @thing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n head :ok\n end",
"def create\n @component = service.components.new(component_params)\n\n if @component.save\n render json: @component, status: :created, location: @component\n else\n render json: @component.errors, status: :unprocessable_entity\n end\n end",
"def update\n @content_partial = ContentPartial.find(params[:id])\n\n respond_to do |format|\n if @content_partial.update_attributes(params[:content_partial])\n format.html { redirect_to @content_partial, notice: 'Content partial was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @content_partial.errors, status: :unprocessable_entity }\n end\n end\n end",
"def rest_patch(base_uri,json_payload,params)\n begin\n @response = RestClient.patch(base_uri,json_payload,params)\n rescue => e\n puts @response.code\n end\n return @response\n end",
"def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @block_owner_deletion = args[:block_owner_deletion] if args.key?(:block_owner_deletion)\n @controller = args[:controller] if args.key?(:controller)\n @kind = args[:kind] if args.key?(:kind)\n @name = args[:name] if args.key?(:name)\n @uid = args[:uid] if args.key?(:uid)\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update(data = :object || :json)\n end",
"def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @kind = args[:kind] if args.key?(:kind)\n @metadata = args[:metadata] if args.key?(:metadata)\n @spec = args[:spec] if args.key?(:spec)\n end",
"def update\n put :update\n end",
"def update\n respond_to do |format|\n if @complu.update(complu_params)\n format.html { redirect_to @complu, notice: 'Complu was successfully updated.' }\n format.json { render :show, status: :ok, location: @complu }\n else\n format.html { render :edit }\n format.json { render json: @complu.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @patch.update(patch_params)\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { render :show, status: :ok, location: @patch }\n else\n format.html { render :edit }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_component\n # Loads a Component object with associated rules, reviews,\n # descriptions, checks and additional answers where ID is equal to params id.\n @component = Component.eager_load(\n rules: [:reviews, :disa_rule_descriptions, :rule_descriptions, :checks,\n :additional_answers, :satisfies, :satisfied_by, {\n srg_rule: %i[disa_rule_descriptions rule_descriptions checks]\n }]\n ).find_by(id: params[:id])\n\n # Returns out of the method If the Component instance variable does exist.\n return if @component.present?\n\n message = 'The requested component could not be found.'\n respond_to do |format|\n # Return an HTML response with an alert flash message if request format is HTML.\n format.html do\n flash.alert = message\n redirect_back(fallback_location: root_path)\n end\n # Return a JSON response with a toast message if request formt is JSON.\n format.json do\n render json: {\n toast: {\n title: 'Control not found',\n message: message,\n variant: 'danger'\n }\n }, status: :not_found\n end\n end\n end",
"def update\n # respond_to do |format|\n # if @thing.update(thing_params)\n # format.html { redirect_to @thing, notice: 'Thing was successfully updated.' }\n # format.json { render :show, status: :ok, location: @thing }\n # else\n # format.html { render :edit }\n # format.json { render json: @thing.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def partial_update(klass, id, patchset, options = {}, format = nil)\n headers = {}\n headers[:accept] = \"#{format}\" if format\n format ||= @default_format\n options = { resource: klass, id: id, format: format}.merge options\n if [FHIR::Formats::ResourceFormat::RESOURCE_XML, FHIR::Formats::ResourceFormat::RESOURCE_XML_DSTU2].include?(format)\n options[:format] = FHIR::Formats::PatchFormat::PATCH_XML\n headers[:content_type] = \"#{FHIR::Formats::PatchFormat::PATCH_XML}\"\n elsif [FHIR::Formats::ResourceFormat::RESOURCE_JSON, FHIR::Formats::ResourceFormat::RESOURCE_JSON_DSTU2].include?(format)\n options[:format] = FHIR::Formats::PatchFormat::PATCH_JSON\n headers[:content_type] = \"#{FHIR::Formats::PatchFormat::PATCH_JSON}\"\n end\n headers[:prefer] = @return_preference if @use_return_preference\n reply = patch resource_url(options), patchset, fhir_headers(headers)\n reply.resource = parse_reply(klass, format, reply)\n reply.resource_class = klass\n reply\n end",
"def patch\n end",
"def show\n @component = CustomComponent.find(params[:id])\n render json: @component\n end",
"def update\n @concern = Concern.find(params[:id])\n\n respond_to do |format|\n if @concern.update_attributes(params[:concern])\n format.html { redirect_to @concern, notice: 'Concern was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @concern.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @scomp.update(scomp_params)\n format.html { redirect_to @scomp, notice: 'Scomp was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @scomp.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ba_spec = BaSpec.find(params[:id])\n\n respond_to do |format|\n if @ba_spec.update_attributes(params[:ba_spec])\n format.html { redirect_to session[:return_to] }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ba_spec.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @components_photo = ComponentsPhoto.find(params[:id])\n #x = self.find( :first, :conditions = ‘product_id = ? and option_id = ?’, product.id, option.id] )\n\n respond_to do |format|\n if @components_photo.update_attributes(params[:components_photo])\n flash[:notice] = 'ComponentsPhoto was successfully updated.'\n format.html { redirect_to(@components_photo) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @components_photo.errors, :status => :unprocessable_entity }\n end\n end\n end"
] |
[
"0.72437364",
"0.6452081",
"0.64208704",
"0.64208704",
"0.64128953",
"0.6381774",
"0.62361735",
"0.6213064",
"0.62038606",
"0.62038606",
"0.6178921",
"0.6157307",
"0.61453146",
"0.6131692",
"0.60130215",
"0.6004166",
"0.5989117",
"0.5945427",
"0.5940296",
"0.59374315",
"0.59314024",
"0.59244365",
"0.5900362",
"0.58709097",
"0.5837252",
"0.57884806",
"0.5788273",
"0.57825583",
"0.57817334",
"0.577742",
"0.5764331",
"0.5736487",
"0.5735878",
"0.5721641",
"0.57203656",
"0.5710944",
"0.57103926",
"0.5701079",
"0.56425405",
"0.5633925",
"0.559947",
"0.55915016",
"0.55903447",
"0.5589251",
"0.55883783",
"0.55883783",
"0.5586538",
"0.55836076",
"0.55731755",
"0.55715036",
"0.55691594",
"0.5563528",
"0.55609757",
"0.55574846",
"0.555014",
"0.5541867",
"0.553935",
"0.5536507",
"0.552118",
"0.55192363",
"0.551878",
"0.55059713",
"0.5503328",
"0.5502808",
"0.54996574",
"0.54987144",
"0.5485441",
"0.5481786",
"0.5480653",
"0.5479949",
"0.5479023",
"0.5466768",
"0.54549193",
"0.5451088",
"0.5442093",
"0.5437595",
"0.54352236",
"0.5428697",
"0.5427858",
"0.5416945",
"0.54165035",
"0.54160273",
"0.54119307",
"0.5411904",
"0.5406057",
"0.5402804",
"0.5401986",
"0.5401255",
"0.539463",
"0.53922534",
"0.5391593",
"0.5386215",
"0.5385888",
"0.5383096",
"0.5379864",
"0.5372772",
"0.5366592",
"0.53665847",
"0.535815",
"0.5358113"
] |
0.6679688
|
1
|
DELETE /components/1 or /components/1.json
|
def destroy
@component.destroy
respond_to do |format|
format.html { redirect_to components_url, notice: "Component was successfully destroyed." }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @componente = Componente.find(params[:id])\n @componente.destroy\n\n respond_to do |format|\n format.html { redirect_to componentes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @component.destroy\n respond_to do |format|\n format.html { redirect_to components_url, notice: 'Component was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @component = Component.find(params[:id])\n @component.destroy\n\n respond_to do |format|\n format.html { redirect_to(components_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @structure_component = StructureComponent.find(params[:id])\n @structure_component.destroy\n\n respond_to do |format|\n format.html { redirect_to structure_components_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @component = Component.find_by(slug: params[:id])\n @component.destroy\n\n head :no_content\n end",
"def destroy\n @blobs_component = BlobsComponent.find(params[:id])\n @blobs_component.destroy\n\n respond_to do |format|\n format.html { redirect_to(blobs_components_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @react_component.destroy\n respond_to do |format|\n format.html { redirect_to react_components_url, notice: 'React component was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @finding_component = FindingComponent.find(params[:id])\n @finding_component.destroy\n\n respond_to do |format|\n format.html { redirect_to finding_components_url }\n format.json { head :no_content }\n end\n end",
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def destroy\n @graded_component = GradedComponent.find(params[:id])\n @graded_component.destroy\n\n respond_to do |format|\n format.html { redirect_to(graded_components_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @ivn_component.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_ivn_components_url, notice: \"Ivn component was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @avatarcomponent = Avatarcomponent.find(params[:id])\n @avatarcomponent.destroy\n\n respond_to do |format|\n format.html { redirect_to avatarcomponents_url }\n format.json { head :no_content }\n end\n end",
"def delete_component\n @structure_component = StructureComponent.find(params[:id])\n @structure_component.destroy\n @existing_structure = StructureComponent.find_all_by_assessment_id(@structure_component.assessment_id, :order => \"id\")\n redirect_to(\"/structure_components/create_structure/#{@structure_component.assessment_id}\")\n end",
"def destroy\r\n @ph_electric_component = PhElectricComponent.find(params[:id])\r\n @ph_electric_component.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(ph_electric_components_url) }\r\n format.xml { head :ok }\r\n end\r\n end",
"def destroy\n @comp.destroy\n respond_to do |format|\n format.html { redirect_to comps_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @component_list.destroy\n respond_to do |format|\n format.html { redirect_to component_lists_url, notice: 'Component list was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @component_widget = ComponentWidget.find(params[:id])\n @component_widget.destroy\n\n respond_to do |format|\n format.html { redirect_to component_widgets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cephalopod.destroy\n respond_to do |format|\n format.html { redirect_to cephalopods_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comp = Comp.find(params[:id])\n @comp.destroy\n\n respond_to do |format|\n format.html { redirect_to comps_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kicad_component = KicadComponent.find(params[:id])\n @kicad_component.destroy\n\n respond_to do |format|\n format.html { redirect_to(kicad_components_url) }\n format.xml { head :ok }\n end\n end",
"def delete!( opts = {} )\n http_action :delete, nil, opts\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @component_prop.destroy\n respond_to do |format|\n format.html { redirect_to component_props_url, notice: 'Component prop was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @component = Component.find(params[:id].to_i) rescue nil\n respond_to do |format|\n if @component\n success = @component.try(:deactivate!) rescue false\n \n if success\n format.xml { render :xml => component_presenter, :status => :accepted }\n format.json { render :json => component_presenter, :status => :accepted }\n else\n format.xml { render :xml => component_presenter, :status => :precondition_failed }\n format.json { render :json => component_presenter, :status => :precondition_failed }\n end\n else\n format.xml { head :not_found }\n format.json { head :not_found }\n end\n end\n end",
"def destroy\n @component_material.destroy\n respond_to do |format|\n format.html { redirect_to component_materials_url, notice: 'Component material was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @redirect_url = @project_component.project\n @project_component.destroy\n respond_to do |format|\n format.html { redirect_to project_path(@redirect_url), notice: 'Project component was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def delete(path, params)\n parse_response @client[path].delete(:params => params)\n end",
"def delete\n render json: Company.delete(params[\"id\"])\n end",
"def destroy\n @articulocomp = Articulocomp.find(params[:id])\n @articulocomp.destroy\n\n respond_to do |format|\n format.html { redirect_to articulocomps_url }\n #format.json { head :ok }\n end\n end",
"def delete(*rest) end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def delete\n render json: Item.delete(params[\"id\"])\n end",
"def destroy\n @comp_todo.destroy\n respond_to do |format|\n format.html { redirect_to component_path(@comp_todo.component), notice: \"Task was deleted\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @components_photo = ComponentsPhoto.find(params[:id])\n @components_photo.destroy\n\n respond_to do |format|\n format.html { redirect_to(components_photos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n # sorry but not delete is not allow\n #@bundle = Bundle.find(params[:id])\n #@bundle.destroy\n\n respond_to do |format|\n format.html { redirect_to bundles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ruby.destroy\n respond_to do |format|\n format.html { redirect_to rubies_url }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n repository = path.split(/\\//)[2]\n objectid = path.split(/\\//)[3]\n if storage_fetch(repository, objectid) && storage_delete(repository, objectid)\n ['200', {}, []]\n else\n ['404', {}, [\"Repository #{repository} or ObjectID #{objectid} not found: #{path}\"]]\n end\n end",
"def destroy\n @react.destroy\n respond_to do |format|\n format.html { redirect_to reacts_url }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def destroy\n @v1_chore = Chore.where(id: params[:id])\n if @v1_chore.destroy\n head(:ok)\n else\n head(:unprocessable_entity)\n end\n end",
"def api_delete(path, data = {})\n api_request(:delete, path, :data => data)\n end",
"def destroy\n @scomp.destroy\n respond_to do |format|\n format.html { redirect_to scomps_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @major.destroy\n respond_to do |format|\n format.html { redirect_to majors_url }\n format.json { head :no_content }\n end\n end",
"def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end",
"def destroy\n @comprobante = Comprobante.find(params[:id])\n @comprobante.destroy\n\n respond_to do |format|\n format.html { redirect_to comprobantes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @complu.destroy\n respond_to do |format|\n format.html { redirect_to complus_url, notice: 'Complu was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @component_fund.destroy\n respond_to do |format|\n format.html { redirect_to component_funds_url, notice: 'Component fund was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end",
"def destroy\n @json.destroy\n respond_to do |format|\n format.html { redirect_to jsons_url, notice: 'Json was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @json.destroy\n respond_to do |format|\n format.html { redirect_to jsons_url, notice: 'Json was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(params = {})\n Client.current.delete(resource_url, params)\n end",
"def destroy\n clients_delete(@entity)\n @entity.destroy\n respond_to do |format|\n format.html { redirect_to clients_path }\n format.json { render json: {success: true} }\n end\n end",
"def destroy\n @components_front_lever = Components::FrontLever.find(params[:id])\n @components_front_lever.destroy\n\n respond_to do |format|\n format.html { redirect_to(components_front_levers_url) }\n format.xml { head :ok }\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 http_delete(path, data = nil, content_type = 'application/json')\n http_methods(path, :delete, data, content_type)\n end",
"def destroy\n @composer = Composer.find(params[:id])\n @composer.destroy\n\n respond_to do |format|\n format.html { redirect_to composers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @compra_venta_normal.destroy\n respond_to do |format|\n format.html { redirect_to compra_venta_normals_url }\n format.json { head :no_content }\n end\n end",
"def destroy(params = {})\n client.delete(\"#{endpoint(params)}/#{attributes[:id]}\")\n end",
"def destroy\n @compte.destroy\n respond_to do |format|\n format.html { redirect_to comptes_url, notice: 'Compte was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @compliment = Compliment.find(params[:id])\n @compliment.destroy\n\n respond_to do |format|\n format.html { redirect_to compliments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bundle = Bundle.find(params[:id])\n @bundle.destroy\n\n respond_to do |format|\n format.html { redirect_to bundles_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @three60.destroy\n respond_to do |format|\n format.html { redirect_to edit_admin_good_url(@good, anchor: \"three60\") }\n format.json { head :no_content }\n end\n end",
"def delete\n item = FormTemplate.last\n id = item[:id]\n item.destroy\n render json: {id: id}\n end",
"def destroy\n @actum.destroy\n respond_to do |format|\n format.html { redirect_to acta_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @anything.destroy\n respond_to do |format|\n format.html { redirect_to anythings_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @major = Major.find(params[:id])\n @major.destroy\n\n respond_to do |format|\n format.html { redirect_to majors_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @verb.destroy\n respond_to do |format|\n format.html { redirect_to verbs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @component_category = ComponentCategory.find(params[:id])\n @component_category.destroy\n\n respond_to do |format|\n format.html { redirect_to(component_categories_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @comp_info = CompInfo.find(params[:id])\n @comp_info.destroy\n\n respond_to do |format|\n format.html { redirect_to comp_infos_url }\n format.json { head :no_content }\n end\n end",
"def delete\n raise \"Can't delete a resource without a REST Client\" unless @client\n @client.delete @path\n end",
"def delete\n raise \"Can't delete a resource without a REST Client\" unless @client\n @client.delete @path\n end",
"def delete(path, params = {})\n Chirpy.request params.merge({:path => path, :method => 'delete'}.merge(authentication))\n end",
"def destroy\n @htc.destroy\n respond_to do |format|\n format.html { redirect_to htcs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @section.destroy\n respond_to do |format|\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 destroy\n @core_nota = Core::Nota.find(params[:id])\n @core_nota.destroy\n\n respond_to do |format|\n format.html { redirect_to core_notas_url }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def delete_entity(entity)\n @components.where(eid: entity.id).delete\n end",
"def destroy\n @backend.destroy\n respond_to do |format|\n format.html { redirect_to backends_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @storage = @client.storages.find(params[:id])\n @storage.destroy\n\n respond_to do |format|\n format.html { redirect_to client_url(@client) }\n format.json { head :no_content }\n end\n end",
"def delete(path, params)\n request(:delete, path, {})\n end",
"def destroy\n @depot_fuel.destroy\n respond_to do |format|\n format.html { redirect_to depot_fuels_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @patchcord.destroy\n respond_to do |format|\n format.html { redirect_to patchcords_url, notice: 'Patchcord was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ba_spec = BaSpec.find(params[:id])\n @ba_spec.destroy\n\n respond_to do |format|\n format.html { redirect_to ba_specs_url }\n format.json { head :no_content }\n end\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def destroy\n @component_in_machine.destroy\n respond_to do |format|\n format.html { redirect_to component_in_machines_url, notice: 'Component in machine was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(path_part, additional_headers = {}, &block)\n api_request { @rest.delete('/REST/' + path_part, \"\", additional_headers, &block) }\n end",
"def destroy\n @portion = Portion.find(params[:id])\n @portion.destroy\n\n respond_to do |format|\n format.html { redirect_to portions_url }\n format.json { head :no_content }\n end\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def destroy\n @patch = Patch.find(params[:id])\n @patch.destroy\n\n respond_to do |format|\n format.html { redirect_to patches_url }\n format.json { head :no_content }\n end\n end"
] |
[
"0.7216769",
"0.7206919",
"0.7137377",
"0.7056512",
"0.7048621",
"0.6821791",
"0.68137157",
"0.6795859",
"0.6761204",
"0.67086035",
"0.66795343",
"0.6660593",
"0.6653648",
"0.66115165",
"0.65908563",
"0.6589922",
"0.653329",
"0.6528732",
"0.652714",
"0.65241337",
"0.6505982",
"0.6494815",
"0.6490365",
"0.6415819",
"0.6412847",
"0.6405703",
"0.6401446",
"0.63916016",
"0.637689",
"0.6356341",
"0.63485515",
"0.63451993",
"0.63386905",
"0.633135",
"0.633026",
"0.6327015",
"0.63247615",
"0.6322646",
"0.6274289",
"0.62695426",
"0.6260199",
"0.625829",
"0.6254813",
"0.62456846",
"0.62418294",
"0.6239135",
"0.6230606",
"0.6226086",
"0.6225706",
"0.6225706",
"0.62211096",
"0.6217324",
"0.62020075",
"0.62007356",
"0.62007356",
"0.62007356",
"0.62007356",
"0.6198584",
"0.61962134",
"0.61889136",
"0.618802",
"0.6178241",
"0.6172303",
"0.61695415",
"0.6165656",
"0.61629444",
"0.6160421",
"0.6158501",
"0.6153686",
"0.61533934",
"0.6152118",
"0.6146838",
"0.61434287",
"0.61434287",
"0.61423254",
"0.6136666",
"0.61309224",
"0.6130447",
"0.61286014",
"0.612711",
"0.61264163",
"0.61263734",
"0.6125114",
"0.61241406",
"0.6121138",
"0.61208713",
"0.6116422",
"0.61154497",
"0.61154497",
"0.61154497",
"0.61154497",
"0.61154497",
"0.61154497",
"0.61154497",
"0.61153597",
"0.6112614",
"0.61093456",
"0.61057657",
"0.61057657",
"0.61050534"
] |
0.7203496
|
2
|
Use callbacks to share common setup or constraints between actions.
|
def set_component
@component = Component.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 list of trusted parameters through.
|
def component_params
params.require(:component).permit(:model, :category, :serial_number, :rgb, :brand_id)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\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 strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def allow_params_authentication!; end",
"def whitelisted_args\n args.select &:allowed\n end",
"def safe_list_sanitizer; end",
"def safe_list_sanitizer; end",
"def safe_list_sanitizer; end",
"def filtered_parameters; end",
"def sanitize_params_for user, params, allowed_params\n params.each do |key, val|\n #if allowed_params.include?(key)\n #sanitize!(user, params, key) if key =~ /_attributes|_ids$/\n #else\n #params.delete(key)\n #end\n params.delete(key) unless allowed_params.include?(key.to_sym)\n end\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def expected_permitted_parameter_names; end",
"def sanitize_parameters!(sanitizer, params)\n # replace :readwrite with :onlyif\n if params.has_key?(:readwrite)\n warn \":readwrite is deprecated. Replacing with :onlyif\"\n params[:onlyif] = params.delete(:readwrite)\n end\n\n # add default parameters\n bindata_default_parameters.each do |k,v|\n params[k] = v unless params.has_key?(k)\n end\n\n # ensure mandatory parameters exist\n bindata_mandatory_parameters.each do |prm|\n if not params.has_key?(prm)\n raise ArgumentError, \"parameter ':#{prm}' must be specified \" +\n \"in #{self}\"\n end\n end\n\n # ensure mutual exclusion\n bindata_mutually_exclusive_parameters.each do |param1, param2|\n if params.has_key?(param1) and params.has_key?(param2)\n raise ArgumentError, \"params #{param1} and #{param2} \" +\n \"are mutually exclusive\"\n end\n end\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_list_sanitizer=(_arg0); 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 param_whitelist\n [:rating, :review]\n end",
"def check_params; true; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\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 allowed?(*_)\n true\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def secure_params\n return @secure_params if @secure_params\n\n defn = implementation_class.definition\n field_list = [:master_id] + defn.field_list_array\n\n res = params.require(controller_name.singularize.to_sym).permit(field_list)\n res[implementation_class.external_id_attribute.to_sym] = nil if implementation_class.allow_to_generate_ids?\n @secure_params = res\n end",
"def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permit( params, whitelist, name = nil )\n raise 'Parametrization not yet configured' unless @configured\n whitelist ||= []\n px = params.respond_to?( :permit ) ? params : ActionController::Parameters.new( params )\n px = dig(px, name)\n px.permit( *whitelist )\n end",
"def valid_params?; end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def url_allowlist=(_arg0); 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 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 list_params\n params.permit(:list_name)\n end",
"def valid_params_request?; end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def param_list(param_type, name, type, required, description = nil, allowed_values = [], hash = {})\n hash.merge!({allowable_values: {value_type: \"LIST\", values: allowed_values}})\n param(param_type, name, type, required, description, hash)\n end",
"def safelists; end",
"def authorize_own_lists\n authorize_lists current_user.lists\n end",
"def listed_params\n params.permit(:listed, :list_id, :listable_id, :listable_type, :campsite_id)\n end",
"def lists_params\n params.require(:list).permit(:name)\n\n end",
"def list_params\n params.require(:list).permit(:name, :user_id)\n end",
"def list_params\n params.require(:list).permit(:name, :description, :type, :privacy, :allow_edit, :rating, :votes_count, :user_id)\n end",
"def check_params\n true\n end",
"def authorize_own_or_shared_lists\n authorize_lists current_user.all_lists\n end",
"def user_pref_list_params\n\t\tparams.require(:user).permit(:preference_list)\n\tend",
"def may_contain!(*keys)\n self.allow_only_permitted = true\n self.permitted_keys = [*permitted_keys, *keys].uniq\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def whitelist; end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def list_params\n params.permit(:name)\n end",
"def recipient_list_params\n params.require(:recipient_list).permit(:name, :list, :references)\n end",
"def cancan_parameter_sanitizer\n resource = controller_name.singularize.to_sym\n method = \"#{resource}_params\"\n params[resource] &&= send(method) if respond_to?(method, true)\n end",
"def list_params\n params.require(:list).permit(:name).merge(user_id: current_user.id)\n end",
"def whitelist_place_params\n params.require(:place).permit(:place_name, :unlock, :auth, :is_deep_checked, :parent_ADM4, :parent_ADM3, :parent_ADM2, :parent_ADM1, :parent_country, feature_code: [], same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end",
"def list_params\n params.fetch(:list, {}).permit(:user_id, :name, :active)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def secure_params(require_param, permit_keys)\n params.require(require_param).permit(*permit_keys)\n end",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def permitted_params\n []\n end",
"def price_list_params\n params.fetch(:price_list, {}).permit(:name, :valid_from, :valid_to, :active,\n :all_warehouses, :all_users, :all_contact_groups,\n warehouse_ids: [], price_lists_user_ids: [], contact_group_ids: [])\n end",
"def params(list)\n @declared_params = list\n end",
"def admin_review_params\n params.fetch(:review, {}).permit(whitelisted_params)\n end",
"def saved_list_params\n params.require(:saved_list).permit(:user_id)\n end",
"def allow(ids); end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def filter_params(param_set, **kwargs)\r\n begin\r\n key = kwargs[:key]\r\n params.require(key).permit(*param_set)\r\n rescue Exception\r\n params.permit(*param_set)\r\n end\r\n end",
"def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end",
"def validate_paramified_params\n self.class.paramify_methods.each do |method|\n params = send(method)\n transfer_errors_from(params, TermMapper.scope(params.group)) if !params.valid?\n end\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def secure_params\n return @secure_params if @secure_params\n\n @implementation_class = implementation_class\n resname = @implementation_class.name.ns_underscore.gsub('__', '_').singularize.to_sym\n @secure_params = params.require(resname).permit(*permitted_params)\n end",
"def refine_permitted_params(param_list)\n res = param_list.dup\n\n ms_keys = res.select { |a| columns_hash[a.to_s]&.array }\n ms_keys.each do |k|\n res.delete(k)\n res << { k => [] }\n end\n\n res\n end",
"def recipient_list_params\n params.require(:recipient_list).permit(:name, :description, recipient_id_array: [])\n end",
"def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end",
"def safelist; end",
"def valid_for_params_auth?; end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def shopping_list_params\n params.require(:shopping_list).permit!\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def permitters\n @_parametrizr_permitters || {}\n end",
"def allow_params(action, keys: nil, except: nil, &blk)\n keys &&= Array.wrap(keys)\n keys ||= User.field_names\n except &&= Array.wrap(except)\n except ||= %i[id email]\n devise_parameter_sanitizer.permit(action, keys: keys, except: except, &blk)\n end",
"def list_params\n if current_user && current_user.role == 'admin'\n params.require(:list).permit(:name, :url, :description, :user_id,\n ideas_attributes: [:id, :list_id, :body, :due_date, :completion_status, :_destroy])\n else\n params.require(:list).permit(:name, :description,\n ideas_attributes: [:body, :due_date, :completion_status]) \n end\n end",
"def whitelist(params)\n send_request_of_type(GlobalConstant::PrivateOpsApi.private_ops_api_type, 'post', '/token-sale/whitelist', params)\n end",
"def valid_access_params\n params.require(:valid_access).permit(:wish_list_id, :user_id)\n end",
"def url_allowlist; end",
"def ensure_redirected_params_are_safe!(passed_params)\n unless passed_params.is_a?(ActionController::Parameters) && passed_params.permitted?\n error_message = if passed_params.is_a?(ActionController::Parameters)\n unsafe_parameters = passed_params.send(:unpermitted_keys, params)\n \"[Rails::Prg] Error - Must use permitted strong parameters. Unsafe: #{unsafe_parameters.join(', ')}\"\n else\n \"[Rails::Prg] Error - Must pass strong parameters.\"\n end\n raise error_message\n end\n end",
"def data_collection_params\n allow = [:name,:description,:institution,:collection_name,:country_id,:province_id,:city_id]\n params.require(:data_collection).permit(allow)\n end",
"def quote_params\n params.permit!\n end"
] |
[
"0.6949516",
"0.68133247",
"0.6803944",
"0.6795208",
"0.6745487",
"0.67407674",
"0.65270406",
"0.6520888",
"0.6491314",
"0.6430685",
"0.6430685",
"0.6430685",
"0.6398393",
"0.6355302",
"0.63544565",
"0.6347063",
"0.6343035",
"0.63376737",
"0.6326283",
"0.6326283",
"0.6326283",
"0.63138837",
"0.6299373",
"0.6265234",
"0.6260794",
"0.62575966",
"0.6235641",
"0.62269944",
"0.6221537",
"0.62200975",
"0.6209341",
"0.61993533",
"0.6196644",
"0.61734784",
"0.6157504",
"0.61563677",
"0.61531556",
"0.61367255",
"0.6121853",
"0.611264",
"0.6075028",
"0.6071518",
"0.6062771",
"0.60561144",
"0.60451925",
"0.6035775",
"0.6021841",
"0.6019149",
"0.60172117",
"0.60114187",
"0.6009556",
"0.6009536",
"0.6006603",
"0.60043883",
"0.60043883",
"0.5996597",
"0.59940183",
"0.59934527",
"0.59856695",
"0.5972229",
"0.5968881",
"0.59667784",
"0.59654486",
"0.596338",
"0.5961725",
"0.59338135",
"0.5928234",
"0.59239507",
"0.59099627",
"0.5905216",
"0.59046614",
"0.58938116",
"0.58887655",
"0.58830744",
"0.58830744",
"0.58830744",
"0.58728033",
"0.5861703",
"0.5853257",
"0.58460855",
"0.5843953",
"0.58364105",
"0.5832591",
"0.5829531",
"0.582919",
"0.58179677",
"0.58160007",
"0.5813908",
"0.581193",
"0.5803385",
"0.5803385",
"0.5799791",
"0.5795472",
"0.5784412",
"0.57823825",
"0.57773477",
"0.57751346",
"0.5768509",
"0.57671285",
"0.57628495",
"0.5757869"
] |
0.0
|
-1
|
Renders a template named `name` located in the templates folder.
|
def render(name, object = nil)
binding = get_binding
if object.respond_to?(:get_binding)
binding = object.get_binding
end
content = File.read(File.join(TEMPLATE_PATH, name))
ERB.new(content).result(binding)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def template(name,locals={})\n Tilt.new(Dir.glob(\"#{settings.service.templates_dir}/#{name}.*\").first)\n .render(self,locals)\n end",
"def template(name)\n ERB.new(File.read(File.join(File.dirname(__FILE__), \"views\", \"#{name}.erb\")))\n end",
"def template(name)\n ERB.new(File.read(File.join(File.dirname(__FILE__), \"../../../views/\", \"#{name}.erb\")))\n end",
"def template\n template_name = params[:template_name]\n\n render \"templates/#{template_name}\", locals: { }, :layout => nil\n end",
"def render(template_name)\n dir_path = File.dirname(__FILE__)\n template_fname = File.join(\n dir_path, \"..\",\n \"views\", self.class.to_s.underscore.chomp(\"_controller\"), \"#{template_name}.html.erb\"\n )\n\n template_code = File.read(template_fname)\n\n render_content(\n ERB.new(template_code).result(binding),\n \"text/html\"\n )\n end",
"def render_template(name, variables = {}, engine_options = {}, &blk)\n path = settings[:views] || './views'\n full_name = File.expand_path(File.join(path, name))\n\n # load and cache template\n @@cached_templates ||= {}\n t = @@cached_templates[full_name] =\n (Happy.env.production? && @@cached_templates[full_name]) || begin\n engine_options = {\n :default_encoding => 'utf-8',\n :outvar => \"@output_buffer\" # for erb\n }.merge(engine_options)\n Tilt.new(full_name, engine_options)\n end\n\n # render template\n t.render(self, variables, &blk)\n end",
"def render(template_name)\n template = ERB.new( \n File.read( full_template_path( template_name ) )\n )\n render_content( template.result( binding ), 'text/html' )\n end",
"def template( name )\n\t\ttemplate_name = \"#{name}.erb\"\n\t\ttemplate = self.template_search_path.\n\t\t\tmap {|dir| dir + template_name }.\n\t\t\tfind {|tmpl| tmpl.exist? }\n\n\t\ttemplate or raise Foreman::Export::Exception,\n\t\t\t\"Can't find the %p template in any of: %p\" %\n\t\t\t[ name, self.template_search_path.map(&:to_s) ]\n\n\t\terbtmpl = ERB.new( template.read, nil, '<%>' )\n\tend",
"def render file_name\n template_file = @template_dir + file_name\n\n template = template_for template_file, false, RDoc::ERBPartial\n\n template.filename = template_file.to_s\n\n template.result @context\n end",
"def render_template(name)\n locals = { :task => @task, :node => @node, :repo => @repo }\n content_type 'text/plain'\n template, opts = @task.find_template(name)\n erb template, opts.merge(locals: locals, layout: false)\n end",
"def template_named template_name\n\ttemplate_path = \"templates/#{template_name}.erb\"\n\tif File.exists? template_path\n\t\tERB.new(File.open(template_path).read)\n\telse\n\t\traise \"Template named '#{template_name}' not found at location #{template_path}!\"\n\tend\nend",
"def render(template_name)\n controller_name = self.class.name.underscore\n dir_path = File.dirname(__FILE__)\n\n file_path = File.join(dir_path, \"..\", 'views', controller_name, \"#{template_name}.html.erb\")\n file_content = File.read(file_path)\n\n template = ERB.new(file_content)\n render_content(template.result(binding), 'text/html')\n end",
"def use_template(name)\n call \"_#{name}\"\n end",
"def render(template_name)\n template = ERB.new(File.read(\"views/#{self.class.to_s.underscore}/#{template_name}.html.erb\"))\n bindings = binding()\n render_content(template.result(bindings), \"text/html\")\n end",
"def render(template_name)\n controller_name = self.class.to_s.underscore\n filepath = \"views/#{controller_name}/#{template_name}.html.erb\"\n file = File.read(filepath)\n\n to_render = ERB.new(file).result(binding)\n\n self.render_content(to_render, \"text/html\")\n end",
"def path_to_template name\n \"#{JSPEC_ROOT}/templates/#{name}/.\"\n end",
"def render( args )\n template_name\n end",
"def render(template_name)\n controller_name = self.class.to_s.underscore\n\n string = File.read(\"./views/#{controller_name}/#{template_name}.html.erb\")\n #\"./\" for project root dir\n\n template = ERB.new(string)\n capture = template.result(binding) #evaluate and bind\n\n render_content(capture, \"text/html\")\n end",
"def render(template_name)\n body_string = ''\n File.open(\"./app/views/#{controller_name}/#{template_name}.html.erb\", 'r') do |f|\n f.each_line do |line|\n body_string += line\n end\n end\n\n content = ERB.new(body_string).result(binding)\n render_content(content, 'text/html')\n end",
"def template(name)\n File.join TemplatePath, \"#{name}.rb\"\nend",
"def template(name); end",
"def get_template(name)\n if File.exists?(\"#{repository.path}/#{name}.mustache\")\n IO.read(\"#{repository.path}/#{name}.mustache\")\n else\n IO.read(File.join(File.dirname(__FILE__), \"templates/#{name}.mustache\"))\n end\n end",
"def render(template_name, options = {})\n file = File.read(\"views/#{self.class.to_s.underscore}/#{template_name}.html.erb\")\n template = ERB.new(file).result(binding)\n return template if options.include?(:partial)\n render_content(template, 'text/html')\n end",
"def render(name, opts={}, &block)\n \n # render @link\n if name.respond_to?(:created_by)\n path = Template.last_template_path.split('/')[1]\n eval \"@#{name.class.name.tableize.singularize} = name\"\n name = \"#{path}/#{name.class.name.tableize}/_#{name.class.name.downcase}\"\n else\n name = name.to_s\n name = \"#{Template.last_template_path}/#{name}\" unless name.index('/')\n end\n\n if block_given?\n name = \"#{name}/layout\" unless name.index('/')\n local_data = capture(&block)\n Template.new(name).part(instance_variables_hash) do\n local_data\n end\n else\n Template.new(name).part(instance_variables_hash.merge(opts))\n end\n end",
"def resolve_template_path(name)\n controller_name = self.class.name.gsub(/Controller$/, '').downcase\n return \"views/#{controller_name}/#{name}.html.erb\"\n end",
"def render(template_name)\n path = \"views/#{ActiveSupport::Inflector.underscore(self.class.to_s)}/#{template_name}.html.erb\"\n ftext = File.read(path)\n template = ERB.new(ftext).result(binding)\n render_content(template, 'text/html')\n# Let's write a #render(template_name) method that will:\n# Use controller and template names to construct paths to template files.\n# Use File.read to read the template file.\n# Create a new ERB template from the contents.\n# Evaluate the ERB template, using binding to capture the controller's\n# instance variables.\n# Pass the result to #render_content with a content_type of text/html.\n# We'll assume that any developers who use our framework are aware of\n# our template naming convention, which is as follows:\n# \"views/#{controller_name}/#{template_name}.html.erb\". Use\n# ActiveSupport's #underscore (require 'active_support/inflector')\n# method to convert the controller's class name to snake case. We'll be\n# lazy and not chop off the _controller bit at the end.\n end",
"def render(template_name)\n template_content = File.read(template_path(template_name))\n template = ERB.new(template_content)\n response_body = template.result(get_binding)\n render_content(response_body, 'text/html')\n end",
"def load_template(name)\n filename = locate_template(name)\n File.read(filename)\n end",
"def render(template_name)\n #Open template, put content into string-content\n cntrl_name = self.class.to_s.underscore\n\n erb_temp = File.read(\"views/#{cntrl_name}/#{template_name}.html.erb\")\n content = ERB.new(erb_temp).result(binding)\n\n render_content(content , 'text/html')\n end",
"def template(name, opts={})\n format = opts.fetch(:format, default_format)\n template_name = template_name_and_format_glob(name,format, opts)\n\n return _template_cache[template_name] if _template_cache[template_name]\n\n file = nil\n layout_dirs.detect do |dir|\n file = Dir[File.join(dir, template_name)].first\n end\n\n if file.nil?\n nil\n else\n _template_cache[template_name] = Tilt.new(file)\n end\n end",
"def render(name, options = {})\n options = options.merge(:request => request, :params => params)\n content = render_template(name, options)\n layout = options.delete(:layout)\n \n if name[0, 1] == '_'\n return content\n \n elsif layout == false\n response.body = content\n else\n options.merge!(:content => content)\n response.body = render_template(layout || \"layout.rhtml\", options)\n end\n\n response['Content-Length'] = response.body.size.to_s\n end",
"def template(template_name)\n\t\t@templates ||= {}\n\n\t\tif !@templates.has_key?(template_name)\n\t\t\ttemplate_file = template_name + \".erb\"\n\t\t\ttemplate_path = File.join(__dir__, \"templates\", template_file)\n\t\t\traise(ArgumentError, \"Attempting to find template #{template_file}, which does not exist.\") unless File.exists?(template_path)\n\n\t\t\t@templates[template_name] = File.read(template_path)\n\t\tend\n\t\t@templates[template_name]\n\tend",
"def template(name, options=nil, &block)\n opts[:named_templates][name.to_s] = [options, define_roda_method(\"named_templates_#{name}\", 0, &block)].freeze\n nil\n end",
"def render(template_name)\n path = File.join('views', self.class.name.underscore, \"#{template_name}.html.erb\")\n file = File.read(path)\n @flash = flash.now unless flash.now.empty?\n render_content(ERB.new(file).result(binding), 'text/html')\n end",
"def template(name)\n @conn.templates.get(name)\n end",
"def template(name, params: {})\n source_file = template_path(name)\n header_for(source_file, params.fetch(:header, true)) +\n ERB.new(File.read(source_file), trim_mode: '<>').result(binding).strip +\n \"\\n\"\n end",
"def render(template_name)\n controller_name = self.class.to_s.gsub(/Controller$/, '').underscore\n base_template = ERB.new File.read(\"app/views/layouts/application.html.erb\")\n page_template = ERB.new File.read(\"app/views/#{controller_name}/#{template_name}.html.erb\")\n page = page_template.result(call_binding)\n content = base_template.result(call_binding { page })\n render_content(content, \"text/html\")\n end",
"def find_template(name)\n \n # Search in theme path\n template_path = Themes::ThemeManager.instance.selected_theme.resource_path(\"#{name}.erb\",'template','ui') \n \n # Search in the project\n if not template_path\n path = app.get_path(name) #File.expand_path(File.join(File.dirname(__FILE__), '..', 'views', \"#{name}-fieldset-render.erb\")) \n template_path = path if File.exist?(path)\n end\n \n template_path\n \n end",
"def render(template_name)\n # \"views/#{controller_name}/#{template_name}.html.erb\"\n\n # format view path\n controller_name = self.class.to_s.underscore\n view_path = \"views/#{controller_name}/#{template_name}.html.erb\"\n\n # read in contents of view file and interpret embedded ruby\n view_content = File.read(view_path)\n template_content = ERB.new(view_content).result(binding) # binding gives erb access to ivars\n\n # html/text downloads output???\n render_content(template_content, \"text/html\")\n end",
"def templateForComponent(name)\n template = nil\n pfn = pathForName(name)\n if @templateCache.has_key? pfn\n if @templateCache[pfn].respond_to? :weakref_alive?\n rtc = 0\n begin\n template = @templateCache[pfn].self\n rescue Exception => e\n Logger[Ciowa_log].info \"Error: #{e}\\n#{e.backtrace.join(\"\\n\")}\"\n #reload(File.new(pathForName(name)))\n reload(File.new(pfn))\n rtc += 1\n if rtc < 3\n retry\n else\n raise e\n end\n end\n else\n template = @templateCache[pfn]\n end\n else\n \n #reload(File.new(pathForName(name)))\n reload(File.new(pfn)) if pfn\n template = @templateCache[pfn]\n end\n template\n end",
"def render_partial(name, options={})\n name = name.to_s\n if File.exists?(Rails.root.join(\"app\", \"views\", \"#{website.folder}/#{name.gsub(/\\/(?!.*\\/)/, \"/_\")}.html.erb\"))\n name = \"#{website.folder}/#{name}\"\n end\n eval(\"render '#{name}', options\")\n end",
"def render(template_name)\n contents = File.read(\"views/#{self.class.to_s.underscore}/#{template_name}.html.erb\")\n template = ERB.new(contents)\n # ivars = self.instance_variables\n new_content = template.result(binding)\n render_content(new_content, \"text/html\")\n end",
"def template(name, &b)\n @app.templates[name] = b\n end",
"def render_template(*args)\n options = args.extract_options!\n filename, content = *args\n render_tilt(filename, content, options) || render_static(filename)\n end",
"def template(name, description=nil, &block)\n Generator.templates[name.to_sym] = [description, block]\n end",
"def load_template(name)\r\n f = lam_path(name)\r\n if File.exist?(f)\r\n File.open(f).read\r\n else\r\n raise \"Missing template file #{f}\"\r\n end\r\n end",
"def render_partial(name, options={})\n if File.exists?(Rails.root.join(\"app\", \"views\", \"layouts\", \"#{name.gsub(/\\/(?!.*\\/)/, \"/_\")}.html.erb\"))\n name = \"#{website.folder}/#{name}\"\n end\n eval(\"render '#{name}', options\")\n end",
"def render_template(path)\n RenderTemplate.new(path.to_s, @controller)\n end",
"def render(template_name)\n #Use controller and template names to construct paths to template files.\n\n\n #Use File.read to read the template file.\n\n #Create a new ERB template from the contents.\n \n #Evaluate the ERB template, using binding to capture the controller's instance variables.\n\n #Pass the result to #render_content with a content_type of text/html.\n\n \n end",
"def render\n case File.extname(@template_file)\n when '.erb'\n render_erb\n else\n render_plain\n end\n end",
"def render(template_name, context=Context.new, layout=true)\n #context = Context.new(context) if context.is_a?(Hash)\n context = hook_context(context)\n while true\n template = get_template(template_name, context) # context is passed only for preprocessor\n _buf = context._buf\n output = template.render(context)\n context._buf = _buf\n unless context._layout.nil?\n layout = context._layout\n context._layout = nil\n end\n layout = @layout if layout == true or layout.nil?\n break unless layout\n template_name = layout\n layout = false\n context.instance_variable_set('@_content', output)\n end\n return output\n end",
"def compile_partial(name)\n klass = Mustache.classify(name)\n if Object.const_defined?(klass)\n ev(\"#{klass}.to_html\")\n else\n src = File.read(@template_path + '/' + name + '.html')\n compile(src)[1..-2]\n end\n end",
"def template(template_name = 'template.txt')\n File.read([File.dirname(__FILE__), template_name].join('/'))\n end",
"def template_path\n \"#{template_dir}/#{template_name}\"\n end",
"def template_file_name\n File.join(['structure', \"views\", \"#{controller_name}.html\"])\n end",
"def render_template(name, is_user_template, render_params)\n template_params, haml = load(name, is_user_template)\n renderer.render(\n inline: haml,\n type: :haml,\n locals: render_params.merge(@@locals))\n end",
"def render_template(template_name, locals={})\n parse_file_as_erb(\"#{Rails.root}/lib/tasks/templates/#{template_name}.erb\", locals)\nend",
"def render!\n render :file => template_path\n end",
"def render(template_name, options = {})\n template_file_path = get_sql_template_path(template_name)\n\n if !File.exists?(template_file_path)\n raise \"File #{template_file_path} does not exist\"\n end\n\n begin\n sql_template_path_stack.push(File.dirname(template_file_path))\n result = render_text(IO.read(template_file_path, {:mode => 'r:BOM|UTF-8'}), options)\n rescue => detail\n # Report errors in the template\n if detail.backtrace[0] =~ /^\\(erb\\)/\n raise \"Template error in #{template_name}:\\n#{detail.backtrace[0]} : #{detail.message}\\n\"\n else\n raise detail\n end\n ensure\n sql_template_path_stack.pop\n end\n\n result\n end",
"def find_template(name)\n TEMPLATES.find do |fn, _|\n fn == name || fn.split('.').first == name\n end\n end",
"def render\n template = ERB.new File.new(@template_path).read, nil, \"%\"\n template.result(binding)\n end",
"def render_template(path)\n render(path)\n exit\n end",
"def lookup_template(name)\n @templates.fetch(name.to_s) { |k| @parent ? @parent.lookup_template(k) : nil }\n end",
"def template_for path, engine=nil\n templates.cache([path, engine]) do\n if file = template_files(path).first\n ext = File.extname(file)\n ext = ext.empty? ? nil : ext[1..-1]\n engine ||= template_engines[ext].first\n engine.new(file) if engine\n end\n end\n end",
"def partial(name)\n partial_name = \"_#{name}.#{Config.template_extension}\"\n template_dir = Pathname.new(self.template_file).dirname\n partial_path = File.expand_path(\"#{template_dir}/#{partial_name}\")\n unless File.file?(partial_path)\n partial_path = \"#{Config.shared_path}/#{partial_name}\"\n end\n File.read(partial_path)\n end",
"def template(value)\n @template = Vedeu.config.base_path +\n \"/app/views/templates/#{value}.erb\"\n end",
"def index\n if params[:name]\n @template = Template.find_by_name(params[:name])\n if @template\n respond_ok \"template\", @template\n else\n respond_err \"template\", Template.new, \"i18> No template found\"\n end\n else\n @templates = Template.all\n if !@templates.empty?\n respond_ok \"template\", @templates\n else\n respond_err \"template\", @templates, \"i18> No template found\"\n end\n end\n end",
"def find(name)\n Template.find(name)\n end",
"def find_template(views, name, engine)\n filename = ::File.join(views, \"#{name}.#{engine}\")\n File.exists?(filename) ? filename : nil\n end",
"def built_in_template_for(template_name)\n File.join( File.dirname(__FILE__), 'templates', template_name )\n end",
"def template(filename, locals={})\n b = binding\n to_display = locals\n load_from = File.expand_path(\"../views/#{filename}.erb\", __FILE__)\n content = File.read(load_from)\n ERB.new(content).result(b)\n end",
"def render(template_name)\n if already_built_response? \n raise \"DoubleRenderError\"\n else \n controller_name = self.class.to_s.underscore \n dir = File.join(\"views\",controller_name, \"#{template_name}.html.erb\")\n # debugger\n content = File.read(dir).split(\"\\n\")\n content.map! do | statement | \n start_point = /<%/ =~ statement\n # debugger\n if start_point.nil? \n statement\n else \n front_part = statement[0...start_point]\n # returning = \n # start_point += statement[start_point+2] == \"=\" ? 2 : 1\n end_point = /%>/ =~ statement \n end_point += 1\n rear_part = statement[end_point+2..-1]\n front_part.to_s + ERB.new(statement[start_point..end_point]).result(binding) + rear_part.to_s\n end \n end \n render_content(content)\n end \n end",
"def render(*args)\n tpls_file = (@__caller_info__ || __caller_info__).first.first\n self._template_parser.load(tpls_file).parse.each do |template_name, raw_content|\n # no controller name if absolute view path\n ctrl_name = template_name.match(/^\\//) ? nil : self.controller_name\n path = Merb.dir_for(:view) / self._template_location(template_name.gsub(/^\\//,''), nil, ctrl_name)\n file = VirtualFile.new(raw_content, path)\n TEMPLATES[path.to_s] = file\n end\n super\n end",
"def load(name)\n render_rhtml [\"#{name}.rhtml\"]\n return \"\"\n end",
"def find_template(views, name, engine)\n filename = ::File.join(views, \"#{name}.#{engine}\")\n File.exist?(filename) ? filename : nil\n end",
"def template_content(name)\n templates.select { |t| t[:name] = name || 'index' }.first[:template]\n end",
"def cnfs_template(file_name)\n generated_files << template(templates_path.join(\"#{file_name}.erb\"), file_name)\n end",
"def template_path(name)\n name = name.to_s\n if name.include?('/') # Specific path like 'representers/somethingorother/foo.haml' given.\n name\n else\n File.join(self.class.representer_path, name)\n end\n end",
"def local_template(path)\n # Is there a better way to specify alternate template locations with sinatra?\n File.read(File.join(File.dirname(__FILE__), \"server/views/#{path}\"))\n end",
"def template(_template_name)\n \"This is a dummy template! <%= dummy %> \\n \"\\\n 'Here is a global value <%= dummy_global %>'\n end",
"def template_path(name)\n File.join(__dir__, 'config', \"#{name}.yml.erb\")\n end",
"def default_template(name)\n path = Rails.root.join('app', 'views', 'emails', \"#{name}.txt\")\n if File.exist?(path)\n File.read(path)\n else\n nil\n end\n end",
"def render template, options={}\n put_on_a_hat\n\n if options.has_key? :dir\n template = :\"#{options[:dir]}/#{template}\" if options[:dir]\n\n elsif view_dir\n template = :\"#{view_dir}/#{template}\"\n end\n\n return erubis template, options\n end",
"def local_template(path)\n # Is there a better way to specify alternate template locations with sinatra?\n File.read(File.join(File.dirname(__FILE__), \"server/views/#{path}\"))\n end",
"def template_path\n File.join path, 'templates'\n end",
"def prepare_template(name)\n if @loader.needs_compile?(name)\n lua = @compiler.compile(name, @loader.load_template(name))\n @loader.save_compiled(name, lua)\n end\n end",
"def template(*path); end",
"def read_template(name)\n File.open(\"#{resource_template_dir}/#{name}.yaml\").read\n end",
"def render_for( short_name, options = {})\n template = template_for(short_name)\n render options.merge(template.to_params)\n end",
"def _render filename\n\t\t\tFile.read(\"./views/_/#{filename}.html\")\n\t\tend",
"def read_template( name )\n\t\tname = \"%s.erb\" % [ name ] unless name.to_s.end_with?( '.erb' )\n\t\ttemplate_path = DEVEIATE_DATADIR + name\n\t\ttemplate_src = template_path.read( encoding: 'utf-8' )\n\n\t\treturn ERB.new( template_src, trim_mode: '-' )\n\tend",
"def scaffold_path(template_name)\n File.join(scaffold_template_dir, template_name+'.rhtml')\n end",
"def template(filename)\n File.binread(File.join(__dir__, 'templates', filename))\n end",
"def render(*names)\n v = ActionView::Base.new\n v.assigns(:x => :y)\n v.template_format\n v.view_paths\n v.pick_template_extension\n names.each do |name|\n v.file_exists?(name)\n end\n v.render_file(names.last, nil, nil)\n end",
"def find_template(views, name, engine, &block)\n\t\t \t#normal\n\t\t super(views, name, engine, &block)\n\t\t #_layout folder\n\t\t super(Paths.layout_path, name.to_s, engine, &block)\n\t\t end",
"def get(name, data = {})\n data = ERB::Context.new(data)\n template = template_root.join(\"#{name}.erb\").read unless name.is_a?(Pathutil)\n template = name.read if name.is_a?(Pathutil)\n template = ERB.new(template)\n\n return template.result(\n data._binding\n )\n end",
"def unique_template(name)\n File.read(unique_filename(name))\n end",
"def mrender(name, options={ layout: false })\n render_options = { views: settings.multi_tenant_views }.merge(options)\n erb name, render_options\n end",
"def unique_filename(name)\n File.join(VIEW_PATH, \"#{name}.erb\")\n end",
"def render_template(view, template, layout_name, locals); end"
] |
[
"0.8127833",
"0.7862208",
"0.78393674",
"0.7495167",
"0.74709857",
"0.7444906",
"0.74424815",
"0.7369953",
"0.7356984",
"0.72394866",
"0.7221205",
"0.72126186",
"0.70645887",
"0.70539564",
"0.70341736",
"0.702832",
"0.70088816",
"0.69900763",
"0.6983047",
"0.69444996",
"0.69273925",
"0.6912678",
"0.6911341",
"0.6890576",
"0.68897474",
"0.686583",
"0.6857583",
"0.6853504",
"0.6851487",
"0.6802969",
"0.6780773",
"0.6779145",
"0.6760593",
"0.6715226",
"0.6683465",
"0.6677858",
"0.6673743",
"0.6670626",
"0.66669273",
"0.6646515",
"0.66363746",
"0.65743554",
"0.6570368",
"0.65257716",
"0.6516991",
"0.64826185",
"0.6478361",
"0.64575446",
"0.64542645",
"0.6426012",
"0.64102006",
"0.64094865",
"0.639138",
"0.638571",
"0.6368638",
"0.6362551",
"0.6359461",
"0.6352968",
"0.634345",
"0.6326185",
"0.6306695",
"0.6301573",
"0.6298869",
"0.6289111",
"0.6273108",
"0.62487787",
"0.6246031",
"0.6225487",
"0.6211105",
"0.6206704",
"0.6206597",
"0.61951226",
"0.61864567",
"0.6184974",
"0.6181252",
"0.61605155",
"0.6129792",
"0.6127511",
"0.612737",
"0.6116491",
"0.6115892",
"0.61132437",
"0.61067647",
"0.61031634",
"0.6079779",
"0.6059719",
"0.60497713",
"0.60461885",
"0.60393894",
"0.6029964",
"0.6029245",
"0.6027379",
"0.601973",
"0.6017133",
"0.6014962",
"0.60049146",
"0.60013145",
"0.5988133",
"0.5978548",
"0.59747136"
] |
0.71112615
|
12
|
Return the ERB binding.
|
def get_binding
binding
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def thru_erb aBinding = Kernel.binding\n ERB.new(self).result(aBinding)\n end",
"def render_with_binding(binding)\n ERB.new(read, nil, '<>').result(binding)\n end",
"def _erb(templ, _binding)\n return ERB.new(templ, nil, \"<>\").result(_binding)\n end",
"def erb(vars = {})\n ERBResolve.new(vars).resolve(self)\n end",
"def erb(vars = {})\n ERBResolve.new(vars).resolve(self)\n end",
"def get_binding\n return binding()\n end",
"def get_binding\n return binding()\n end",
"def get_binding\n return binding()\n end",
"def get_binding\n return binding\n end",
"def get_binding\r\n binding()\r\n end",
"def get_binding\n binding()\n end",
"def get_binding\n binding()\n end",
"def get_binding\n return binding()\n end",
"def get_binding\n return binding()\n end",
"def get_binding\n binding\n end",
"def get_binding\n binding\n end",
"def get_binding\n binding\n end",
"def get_binding\n binding\n end",
"def get_binding\r\n binding\r\n end",
"def getbinding\n binding\n end",
"def get_binding\n binding\n end",
"def get_binding\n binding()\n end",
"def get_binding\n binding()\n end",
"def get_binding\n binding()\n end",
"def get_binding\n binding\n end",
"def get_binding\n binding\n end",
"def get_binding\n binding\n end",
"def get_binding\n binding\n end",
"def get_binding\n binding\n end",
"def get_binding\n binding\n end",
"def get_binding\n binding\n end",
"def get_binding\n binding\n end",
"def erb!(vars = {})\n ERBResolve.new(vars).resolve!(self)\n end",
"def erb!(vars = {})\n ERBResolve.new(vars).resolve!(self)\n end",
"def erb!(vars = {})\n ERBResolve.new(vars).resolve!(self)\n end",
"def get_binding\n\t\t\tbinding\n\t\tend",
"def _erb_buffer( the_binding )\n eval(\"_erbout\", the_binding, __FILE__, __LINE__)\n end",
"def _erb_buffer( the_binding )\n eval(\"_erbout\", the_binding, __FILE__, __LINE__)\n end",
"def erb(content)\n ERB.new(content).result(binding)\nend",
"def execute _binding = get_binding\n foo = 'local_erbout'\n erb = ERB.new compile, nil, nil, 'local_erbout'\n erb.result _binding\n end",
"def render(template)\n b = binding\n code = ERB.new template\n code.result b\n end",
"def erb_render( yml )\n # b = binding\n ERB.new( yml ).result binding \n end",
"def eb(string)\n renderer = ERB.new(string)\n return renderer.result(binding)\n end",
"def get_binding(str)\n binding\nend",
"def render\n ERB.new(load_resource(template)).result(bound.get_binding)\n end",
"def __eval_binding\n RUBY_VERSION < \"1.9\" ? binding : ::Kernel.binding\n end",
"def get_binding\n @binding ||= binding\n end",
"def get_renderer(template)\n renderer = ERB.new(template, 0, '-%>')\n renderer.result(get_binding)\n end",
"def get_renderer(template)\n renderer = ERB.new(template, 0, '-%>')\n renderer.result(get_binding)\n end",
"def binding\n Kernel.binding\n end",
"def erb(filename, locals={}, layout=nil)\n b = binding\n use_template = template(filename, locals)\n locals = locals\n if layout\n layout = File.expand_path(\"../views/#{layout}.erb\",__FILE__)\n content = File.read(layout)\n ERB.new(content).result(b)\n else\n use_template\n end\n end",
"def local_binding\n binding\n end",
"def command_binding\n if @command_binding != nil\n return @command_binding\n elsif block != nil\n return block.binding\n else\n return nil\n end\n end",
"def render\n return @template.result(@binding._binding)\n end",
"def getTemplate (pathTemplate, binding)\r\n fileTemplate = File.new( pathTemplate )\r\n filehtml = fileTemplate.read\r\n erb = ERB.new filehtml\r\n return erb.result(binding)\r\n end",
"def evaluate_template(template_name,bind)\n template_dir = File.expand_path('./scripts',File.dirname(__FILE__))\n template = File.read(File.expand_path(\"./#{template_name}\",template_dir))\n ERB.new(template, nil, '-').result(bind)\nend",
"def evaluate_template(template_name,bind)\n template_dir = File.expand_path('./scripts',File.dirname(__FILE__))\n template = File.read(File.expand_path(\"./#{template_name}\",template_dir))\n ERB.new(template, nil, '-').result(bind)\nend",
"def render_erb\n require 'erb'\n\n renderer = ERB.new(template_content, trim_mode: '-')\n renderer.filename = @template_file\n renderer.result(binding)\n end",
"def binding\n @binding ||= env_brine_vars\n end",
"def evaluate_erb; end",
"def render(binding)\n @template.render(binding)\n end",
"def bound_eval(source)\n self.generate_binding.eval source\n end",
"def render_template(template)\n doc = ERB.new(template, 0, \"%<>\")\n # doc.run(self.send(:binding))\n doc.result(self.send(:binding))\n end",
"def get_binding # rubocop: disable AccessorMethodName\n binding\n end",
"def render\n ERB.new(@template, nil, '-').result(binding)\n end",
"def render_erb(template, scope = {})\n\tt = \"#{ROOT}/templates/#{template}.erb\"\n\tb = binding\n\tscope.each{ |key, value| b.local_variable_set(key.to_sym, value) }\n\treturn ERB.new(File.read(t), nil, \"-\").result(b)\nend",
"def bind\n binding\n end",
"def binding\n @binding ||= {}\n end",
"def get_binding(param)\n binding\nend",
"def erb(template_path, vars)\n template = File.read(template_path)\n ERB.new(template).result(OpenStruct.new(vars).instance_eval { binding })\n end",
"def public_binding\n binding\n end",
"def body\n @binding&.body || \"\"\n end",
"def render(erb)\n erb.result(binding)\n end",
"def erb( content )\n puts \" Running embedded Ruby (erb) code/helpers...\"\n \n content = ERB.new( content ).result( binding() )\n content\n end",
"def render(template_content, hash)\n # create a new binding class\n cls = Class.new do\n hash.each do |key, value|\n define_method key.to_sym do\n value\n end\n end\n # expose binding\n define_method :bind do\n binding\n end\n end\n ERB.new(template_content).result(cls.new.bind)\n end",
"def bind\n binding\n end",
"def _binding() binding end",
"def _binding() binding end",
"def get_a_binding\n\tval = 123\n\tbinding\nend",
"def erb_string(erbfile, b = binding)\n template = File.read(erbfile)\n message = ERB.new(template, trim_mode: \"-\")\n message.result(b)\n .gsub(/[\\n]+{3,}/, \"\\n\\n\")\n .squeeze(\"\\s\")\n end",
"def erb(t)\n ERB.new( File.open(t).read, 0, '<>' ).result\nend",
"def render(source)\n ERB.new(source, nil, '-').result(binding)\n end",
"def erb(file, b=binding)\n require 'erb'\n erb = ERB.new(File.read(file))\n erb.result b\n end",
"def render()\n # WARNING! NO NEED TO UNDERSTAND THIS\n self.action = calling_method = caller[0].split(\"`\").pop.gsub(\"'\", \"\")\n template = File.read(view_filename)\n eruby = Erubis::Eruby.new(template)\n eruby.result(binding())\n end",
"def to_dot_label(binding_)\n template_path = File.expand_path(\"callback.dothtml.erb\", __dir__)\n erb = ERB.new(File.read(template_path))\n erb.filename = template_path\n erb.result(binding)\n end",
"def get_binding derby\n cabar = derby = derby\n binding\n end",
"def get_a_binding\n val = 123\n binding\nend",
"def binding\n return Binding.setup(\n Rubinius::VariableScope.of_sender,\n Rubinius::CompiledMethod.of_sender,\n Rubinius::StaticScope.of_sender)\n end",
"def load_template\n\t\traw = IO.read( __FILE__ ).split( /^__END__$/m, 2 ).last\n\t\treturn ERB.new( raw, nil, '<%>' )\n\tend",
"def partial(filename, binding)\n template_file = get_template_file(filename)\n ERB.new(template_file, nil, '-', '_erbout2').result(binding)\nend",
"def erb_path\n end",
"def result(b=new_toplevel)\n unless @_init.equal?(self.class.singleton_class)\n raise ArgumentError, \"not initialized\"\n end\n eval(@src, b, (@filename || '(erb)'), @lineno)\n end"
] |
[
"0.7632277",
"0.7319603",
"0.7198902",
"0.6844309",
"0.6844309",
"0.683822",
"0.683822",
"0.67694205",
"0.67636687",
"0.6715121",
"0.6711174",
"0.6711174",
"0.67098355",
"0.67098355",
"0.6702703",
"0.6702703",
"0.6702703",
"0.6702703",
"0.6654567",
"0.66515994",
"0.6649766",
"0.6600175",
"0.6600175",
"0.6600175",
"0.6583407",
"0.6583407",
"0.6583407",
"0.6583407",
"0.6583407",
"0.6583407",
"0.6583407",
"0.6583407",
"0.65125227",
"0.65125227",
"0.65125227",
"0.649874",
"0.6485475",
"0.6485475",
"0.645897",
"0.6445389",
"0.6440747",
"0.6355647",
"0.6330685",
"0.6295307",
"0.6293394",
"0.6275521",
"0.62184095",
"0.62151986",
"0.62151986",
"0.62039584",
"0.6090304",
"0.6032102",
"0.60121334",
"0.6007569",
"0.60052484",
"0.5973414",
"0.5973414",
"0.5971375",
"0.5970626",
"0.59671265",
"0.5962595",
"0.5937251",
"0.5909322",
"0.5898933",
"0.5873274",
"0.5830313",
"0.58027923",
"0.5795442",
"0.57906115",
"0.57736844",
"0.57411534",
"0.5728375",
"0.5714526",
"0.57051593",
"0.56849",
"0.566973",
"0.5664809",
"0.5664809",
"0.56588215",
"0.5647615",
"0.56189704",
"0.56179816",
"0.5586715",
"0.5584964",
"0.55807984",
"0.55795646",
"0.55783194",
"0.5575974",
"0.5541939",
"0.553172",
"0.5530291",
"0.5510527"
] |
0.66836536
|
25
|
Detects files affected during example execution based on line coverage. Transforms absolute paths to relative. Exclude paths outside of repository and in excluded prefixes
|
def detect(before, after)
file_names = after.keys
covered_files = file_names.reject { |file_name| same_coverage?(before, after, file_name) }
filter(covered_files)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def uncovered_relevant_lines\n lineno = 0\n File.open(@filename, \"rb\").each_line do |line|\n if @coverage[lineno] == Bashcov::Line::IGNORED && revelant?(line)\n yield lineno\n end\n lineno += 1\n end\n end",
"def coverage_exceeding_source_warn; end",
"def run_coverage(files)\n rm_f \"coverage\"\n rm_f \"coverage.data\"\n\n # turn the files we want to run into a string\n if files.empty?\n puts \"No files were specified for testing\"\n return\n end\n\n files = files.join(\" \")\n\n if RUBY_PLATFORM =~ /darwin/\n exclude = '--exclude \"gems/*\" --exclude \"Library/Frameworks/*\"'\n exclude << \" --exclude osx\\/objc,gems\\/,spec\\/,features\\/\"\n elsif RUBY_PLATFORM =~ /java/\n exclude = '--exclude \"rubygems/*,jruby/*,parser*,gemspec*,_DELEGATION*,eval*,recognize_optimized*,yaml,yaml/*,fcntl\"'\n else\n exclude = '--exclude \"rubygems/*\"'\n end\n\n # rake test:units:rcov SHOW_ONLY=models,controllers,lib,helpers\n # rake test:units:rcov SHOW_ONLY=m,c,l,h\n if ENV['SHOW_ONLY']\n params = String.new\n show_only = ENV['SHOW_ONLY'].to_s.split(',').map{|x|x.strip}\n if show_only.any?\n reg_exp = []\n for show_type in show_only\n reg_exp << case show_type\n when 'm', 'models' then 'app\\/models'\n when 'c', 'controllers' then 'app\\/controllers'\n when 'h', 'helpers' then 'app\\/helpers'\n when 'l', 'lib' then 'lib'\n else\n show_type\n end\n end\n reg_exp.map!{ |m| \"(#{m})\" }\n params << \" --exclude \\\"^(?!#{reg_exp.join('|')})\\\"\"\n end\n exclude << params\n end\n\n rcov_bin = RUBY_PLATFORM =~ /java/ ? \"jruby -S rcov\" : \"rcov\"\n rcov = \"#{rcov_bin} --rails -Ilib:test --sort coverage --text-report #{exclude} --aggregate coverage.data\"\n puts\n puts\n puts \"Running tests...\"\n cmd = \"#{rcov} #{files}\"\n puts cmd\n system cmd\nend",
"def complete_coverage\n lines = File.read(@filename).encode(\"utf-8\", invalid: :replace).lines\n\n lines.each_with_index do |line, lineno|\n # multi-line arrays\n mark_multiline(\n lines, lineno,\n /\\A[^\\n]*\\b=\\([^()]*\\)/,\n forward: false\n )\n\n # heredoc\n mark_multiline(\n lines, lineno,\n /\\A[^\\n]+<<-?'?(\\w+)'?.*$.*\\1/m\n )\n\n # multiline string concatenated with backslashes\n mark_multiline(\n lines, lineno,\n /\\A[^\\n]+\\\\$(\\s*['\"][^'\"]*['\"]\\s*\\\\$){1,}\\s*['\"][^'\"]*['\"]\\s*$/\n )\n\n # simple line continuations with backslashes\n mark_multiline(\n lines, lineno,\n /\\A([^\\n&|;]*[^\\\\&|;](\\\\\\\\)*\\\\\\n)+[^\\n&|;]*[^\\n\\\\&|;](\\\\\\\\)*$/\n )\n\n # multiline string concatenated with newlines\n %w[' \"].each do |char|\n mark_multiline(\n lines, lineno,\n /\\A[^\\n]+[\\s=]+#{char}[^#{char}]*#{char}/m,\n forward: false\n )\n end\n\n mark_line(line, lineno)\n end\n end",
"def find_bash_files!\n return if Bashcov.skip_uncovered\n\n Pathname.glob(\"#{Bashcov.root_directory}/**/*.sh\").each do |filename|\n @coverage[filename] = [] unless @coverage.include?(filename)\n end\n end",
"def each_result_arg\n match_all = ->(_) { true }\n changeset.file_paths.each do |relative_filename|\n next unless relative_filename.to_s.end_with?(\".rb\")\n path = case relative_filename\n when Pathname then relative_filename\n else\n File.expand_path(relative_filename, @relative_git_dir)\n end\n\n root_ast = Imagen::Node::Root.new.build_from_file(path)\n next if root_ast.children.empty?\n\n coverage = lcov.source_files[path.to_s]\n\n root_ast.children[0].find_all(match_all).each do |node|\n yield(path.to_s, coverage, node)\n end\n end\n end",
"def all_files_included?\n file_paths = files.map { |f| File.join(package_path, f[:path]) }\n \n package_files = if defined? package_id\n Dir.glob(File.join(package_path, package_id, \"**\", \"*\"))\n else\n Dir.glob(File.join(package_path, 'files', '**', '*'))\n end\n package_files = package_files.select { |f| File.file? f }\n\n package_files.each do |p|\n errors.add :coverage, \"#{p} is in the package but is not covered by the\" +\n \" representation(s)\" unless file_paths.include?(p) \n end\n \n return errors.on(:coverage).nil?\n\n end",
"def ignore_paths(options)\n source = options['source']\n destination = options['destination']\n config_files = Configuration[options].config_files(options)\n paths = config_files + Array(destination)\n ignored = []\n\n source_abs = Pathname.new(source).expand_path\n paths.each do |p|\n path_abs = Pathname.new(p).expand_path\n begin\n rel_path = path_abs.relative_path_from(source_abs).to_s\n ignored << Regexp.new(Regexp.escape(rel_path)) unless rel_path.start_with?('../')\n rescue ArgumentError\n # Could not find a relative path\n end\n end\n ignored\n end",
"def post_analyze!\n contents = File.open(self.name, 'r').readlines\n exelines = 0\n contents.each_with_index do |line, num|\n sline = line.strip\n \n case sline\n when '', /^#/\n lines << num + 1\n when /^\\s*(?:end|\\})\\s*(?:#.*)?$/, /^(public|private|protected)/,\n /^(?:begin\\s*(?:#.*)?|ensure\\s*(?:#.*)?|else\\s*(?:#.*)?)$/,\n /^(?:rescue)/, /^case\\s*(?:#.*)?$/, /^(\\)|\\]|\\})(?:#.*)?$/\n lines << num + 1\n exelines += 1\n else\n exelines += 1\n end\n \n end\n \n @coverage_percent = (exelines.to_f / contents.size) * 100.0\n end",
"def all_modified_files_coverage\n unless @project.nil?\n @all_modified_files_coverage ||= begin\n modified_files = git.modified_files.nil? ? [] : git.modified_files\n added_files = git.added_files.nil? ? [] : git.added_files\n all_changed_files = modified_files | added_files\n @project.coverage_files.select do |file|\n all_changed_files.include? file.source_file_pathname_relative_to_repo_root.to_s\n end\n end\n\n @all_modified_files_coverage\n end\n end",
"def should_ignore_source?(path)\n return false unless @config.ignore_entities\n base_path = File.basename(path)\n \n @config.ignore_entities.each do |pattern|\n if (File.fnmatch(pattern, path) or File.fnmatch(pattern, base_path) or path == pattern or base_path == pattern)\n return true\n end\n end\n \n false\n end",
"def find_matching_source_lines\n\t\tmatches = []\n\n\t\tsource_files = $hoespec.spec.files.grep( /\\.(h|c|rb)$/ )\n\t\tsource_files -= self.quality_check_whitelist\n\n\t\tsource_files.each do |filename|\n\t\t\tprevious_line = nil\n\n\t\t\tIO.foreach( filename ).with_index do |line, i|\n\t\t\t\tmatches << [filename, i + 1, line] if yield( line, previous_line )\n\t\t\t\tprevious_line = line\n\t\t\tend\n\t\tend\n\n\t\treturn matches\n\tend",
"def examine_uncovered_file(filename)\n # run it through the Loader\n # it will fill out the coverage data for this file\n @loader.load filename\n\n # re-get the lines\n coverage_data[filename]\n end",
"def test_files\n Dir.open(TESTS_CODE) do |dir|\n dir.entries.grep(/^#{TEST_PREFIX}/)\n end\nend",
"def coverage_path; end",
"def process_other_source_files\n files = @options[:include_source_files].flatten\n files.each do |f|\n FileUtils.cp Dir[f], @working_dir\n end\n end",
"def covered_lines\n covered_lines = 0\n @files.select { |f|\n @file_whitelist.include? f.filename\n }.each do |file|\n original_result[file.filename].each do |line_result|\n covered_lines += 1 if line_result and line_result > 0\n end\n end\n covered_lines\n end",
"def test_extract_data_06\n OriginalSourceCode.destroy_all\n file = original_files(:original_files_002)\n assert file.extract_data(file.normal_result_id)\n original_source_code_1 = OriginalSourceCode.find(:all,\n :conditions => {\n :original_file_id => file.id,\n :line_number => 1,\n :line_content => \"\\t/*\\r\",\n :error_line => 1}\n )\n assert_not_equal [],original_source_code_1\n original_source_code_2 = OriginalSourceCode.find(:all,\n :conditions => {\n :original_file_id =>file.id,\n :line_number => 2,\n :line_content => \"\\t File:\\r\",\n :error_line => 0}\n )\n assert_not_equal [],original_source_code_2\n end",
"def skip_paths; end",
"def files_to_analyze\n require 'find'\n ignore_dirs = ['.git','bin','test','assets','lib','log','vendor','tmp','img', 'images', 'uploads', 'fonts']\n ignore_files = Regexp.union(/^\\..*$/i, /^.*(.md)$/i, /^.*(.json)$/i, /^.*(.yml)$/i, /^.*(.log)$/i, /^.*(.png)$/i, /^.*(.jpg)$/i, /^.*(.jpeg)$/i)\n final_files = []\n # for every file in repository - keep the files to process\n Find.find('.') do |path|\n path_name = File.basename(path)\n if FileTest.directory?(path)\n if ignore_dirs.include?(path_name)\n Find.prune\n else\n next\n end\n else\n if path_name.match(ignore_files)\n next\n else\n path.gsub!(/^\\.\\//, '')\n final_files.push(path)\n end\n end\n end\n return final_files\n end",
"def test_can_add_paths_to_source_path\n Crd::Spec.new 'Testing' do |s|\n s.source_path << 'test/fixtures'\n assert_equal( [ 'test/fixtures' ], s.source_path )\n end\n end",
"def detect\n git_diff_files = (git.modified_files - git.deleted_files) + git.added_files\n result = `ruby #{config_file} ci`\n result_array = result.split(\"\\n\")\n indicating_files = []\n unusecode_exists_line = result_array.each do |x|\n diff_file = git_diff_files.find { |y| x.include? y }\n next unless diff_file\n matches = x.match(/\\.swift\\:([0-9]+)\\:[0-9]\\: +(.*)/)\n indicating_files.push [matches[2], diff_file, matches[1].to_i]\n end\n indicating_files.each do |file|\n send(:warn, file[0], file: file[1], line: file[2])\n end\n end",
"def testUselessProcessesSourceFiles\n execute_Mix_WithConf({\n :WaveFiles => {\n :FilesList => [\n {\n :Name => 'Wave.wav'\n }\n ]\n },\n :Mix => {\n 'Final' => {\n :Tracks => {\n 'Wave.wav' => {\n :Processes => [\n {\n :Name => 'VolCorrection',\n :Factor => '2db'\n },\n {\n :Name => 'VolCorrection',\n :Factor => '-2db'\n }\n ]\n }\n }\n }\n }\n },\n :PrepareFiles => [\n [ 'Wave/Empty.wav', 'Wave.wav' ]\n ]) do |iStdOUTLog, iStdERRLog, iExitStatus|\n assert_exitstatus 0, iExitStatus\n assert Dir.glob('05_Mix/*.wav').empty?\n assert_wave_lnk 'Empty', '05_Mix/Final/Final.wav'\n end\n end",
"def coverage(project_name)\n section \"coverage\", \"rm -rf hpc_report\", :condition => $tests_compiled_coverage, :noexception => true do\n hpc_excluded_modules = ((Dir.glob(\"test/**/*Spec.hs\") # skip all test-spec files\n .map { |k| k.gsub(/^test\\//, \"\") # ...converting path to namespace for HPC\n .gsub(/\\.hs$/,\"\")\n .gsub(\"/\",\".\")\n }\n ) << \"Main\" # and skip \"Main\", the entrypoint for tests\n ).map{|k| \"--exclude=#{k}\" }.join(\" \")\n command_interactive \"hpc report #{project_name}.tix #{hpc_excluded_modules}\"\n command_interactive \"hpc markup #{project_name}.tix --destdir=hpc_report #{hpc_excluded_modules}\"\n end\nend",
"def process_coverage \n\tif( File.exist?( \"#{$jtd_outputName}/#{COVERAGE_FILE_NAME }\") )\n\t\tputs \"[INFO] Processing Coverage File\"\n\t\tlcov = LCOVFile.new( \"#{$jtd_outputName}/#{COVERAGE_FILE_NAME }\" )\n\t\tlcov.outputToLCOV( \"#{$jtd_outputName}/#{COVERAGE_FILE_NAME }\" )\n\tend\nend",
"def test_automatically_sets_include_sources_argument\n assert_equal( 'test/fixtures/target', @cmd.include_sources )\n end",
"def modified_files_coverage_table\n unless @project.nil?\n line = ''\n if all_modified_files_coverage.count.positive?\n line += \"File | Coverage\\n\"\n line += \"-----|-----\\n\"\n all_modified_files_coverage.each do |coverage_file|\n file_name = coverage_file.source_file_pathname_relative_to_repo_root.to_s\n percentage = @project.decimal_f([coverage_file.percentage_lines_tested])\n line += \"#{file_name} | **`#{percentage}%`**\\n\"\n end\n end\n return line\n end\n end",
"def irrelevant_line(source_line); end",
"def run_on_change(paths)\n puts paths\n deploy_code\n paths.each do |path|\n run_test(path) if File.exists?(\"src/#{path}\")\n end\n end",
"def related_cuke_files(path)\n Dir['features/**/*.rb'].select { |file| file =~ /#{File.basename(path).split(\".\").first}.feature/ }\nend",
"def individual_report(coverage_path, current_project_path)\n if File.exist? coverage_path\n committed_files = git.modified_files + git.added_files\n\n unless current_project_path.nil?\n committed_files = committed_files.map do |s|\n current_project_path + '/' + s\n end\n end\n\n covered_files = JSON.parse(File.read(coverage_path), symbolize_names: true)[:files]\n .select { |f| committed_files.include?(f[:filename]) }\n\n unless current_project_path.nil?\n covered_files.each { |f| f[:filename].sub!(%r{^#{current_project_path}/?}, '') }\n end\n\n return if covered_files.nil? || covered_files.empty?\n markdown individual_coverage_message(covered_files)\n else\n fail('Code coverage data not found')\n end\n end",
"def apply_exclusions paths\n paths.reject do |path|\n excludes.any? do |pattern|\n globs = pattern.split(\"\\\\\")\n components = path.split(\"/\")\n\n # Inno Setup includes a feature in which you can anchor excludes at\n # the root by starting the exclude with a \"\\\". Since I don't want\n # to make this more complicated than I have to, I'm not implementing\n # this feature at this time.\n if globs[0] == \"\"\n raise \"Can't handle anchored exclude #{pattern}\"\n end\n \n globs_match_strings_anywhere? globs, components\n end\n end\n end",
"def declare_gitignore\n @flavor.class.do_declare_resources do\n # :nocov:\n content = Chef::DelayedEvaluator.new do\n gitignore_patterns.sort.uniq.join(\"\\n\") + \"\\n\"\n end\n # :nocov:\n add_files(%w(.gitignore), :create_if_missing, :file, content: content)\n end\n end",
"def analyse_modified_files\n modified_files = Config.feature_branch_collection.where(SourceControlSystem::Git.modified_files)\n analysed_modules = AnalysedModulesCollection.new(modified_files.map(&:path), modified_files)\n Config.root = Config.compare_root_directory\n report(analysed_modules)\n end",
"def process_skipped_lines(lines)\n skipping = false\n lines.each do |line|\n if SimpleCov::LinesClassifier.no_cov_line?(line.src)\n skipping = !skipping\n line.skipped!\n elsif skipping\n line.skipped!\n end\n end\n end",
"def get_source_files(info_files, root_dir)\n sources = {}\n total_lines_found = 0\n total_lines_hit = 0\n info_files.each do |file|\n @log.debug \"Processing tracefile: #{file}\"\n source_pathname = nil\n in_record = false\n lines_found = nil\n lines_hit = nil\n File.open(file).each do |line|\n @log.debug \"#{file}: #{line.rstrip}\"\n\n # SF:<absolute path to the source file>\n line.match('^SF:' + Regexp.quote(root_dir) + '/(.*)$') do |match|\n @log.warn 'Found source filename without preceding end_of_record' if in_record\n @log.debug \"Found source filename: #{match[1]}\"\n source_pathname = match[1]\n if !sources.has_key?(source_pathname) then\n source = File.read(match[1])\n sources[source_pathname] = {\n :name => source_pathname,\n :source => source,\n :coverage => Array.new(source.lines.count)\n }\n end\n in_record = true\n end\n\n # DA:<line number>,<execution count>[,<checksum>]\n line.match(/^DA:(?<line>\\d+),(?<count>\\d+)(,(?<checksum>.*))?$/) do |match|\n line_index = match[:line].to_i - 1\n if !sources[source_pathname][:coverage][line_index] then\n sources[source_pathname][:coverage][line_index] = 0\n end\n sources[source_pathname][:coverage][line_index] = \n sources[source_pathname][:coverage][line_index] + match[:count].to_i;\n end if in_record\n\n # LF:<lines found> or LH:<lines hit>\n line.match(/^LF:(?<count>\\d+)$/) { |match| lines_found = match[:count] }\n line.match(/^LH:(?<count>\\d+)$/) { |match| lines_hit = match[:count] }\n\n # end_of_record\n if line == \"end_of_record\\n\" and in_record then\n @log.info begin\n perc = get_percentage(lines_hit, lines_found)\n \"[#{perc}] #{source_pathname} (#{lines_hit}/#{lines_found})\"\n end\n total_lines_found = total_lines_found + lines_found.to_i\n total_lines_hit = total_lines_hit + lines_hit.to_i\n in_record = false\n lines_found = nil\n lines_hit = nil\n end\n end\n end\n\n @log.info begin\n perc = get_percentage(total_lines_hit, total_lines_found, true)\n \"[#{perc}] Total (#{total_lines_hit}/#{total_lines_found})\"\n end\n\n sources.values\n end",
"def setup_simplecov\n path = if config.dig(\"test_suite\") == \"minitest\"\n \"test/support\"\n else\n \"spec/support\"\n end\n\n template \"templates/simplecov.tt\", \"#{path}/simplecov.rb\"\n append_to_file \".gitignore\", \"\\n# Ignore Coverage files \\n/coverage\\n\"\n end",
"def clean_arb_samples(src)\n Find.find(src) do |path|\n next if File.basename(path) !~ /^sample$/i\n FileUtils.rm_r(path,$options) if File.directory? path\n end\nend",
"def should_be_skipped_by_paths?(filepath)\n exclude_by_paths = options[:exclude_by_paths]\n filter_by_paths = options[:filter_by_paths]\n exclude_by_paths.any? { |pattern| pattern.match?(filepath) } ||\n (filter_by_paths && !filter_by_paths.empty? && !filter_by_paths.any? { |pattern| pattern.match?(filepath) })\n end",
"def process_exclusions(globs); end",
"def least_covered_file; end",
"def touch_dependency source, specfile\n expect( cover_source_by( source, specfile)).to be_true\nend",
"def coverage; end",
"def coverage; end",
"def parse_test_file_source_include(test)\n return extract_source_include_from_file(test)\n end",
"def in_source_dir(*paths); end",
"def filter(file, fixture)\n # return ['affix_InterveningEmpty.json'].include?(File.basename(file))\n # File.basename(file) =~ /bugreports_greek/i\n # File.basename(file) =~ /sort_stripmark/i\n # return File.basename(file) =~ /^date_rawparsesimpledate/i\n true\nend",
"def exclude_paths\n @source_paths ||= []\n end",
"def filter_backtrace_with_lightning_test backtrace, prefix=nil\n rv = filter_backtrace_without_lightning_test(backtrace, prefix)\n rv = filter_backtrace_without_lightning_test(rv, File.dirname(__FILE__))\n rv\n end",
"def ignored\n [\n '.agignore',\n '.cvsignore',\n '.gitignore',\n '.hgignore',\n ].map do |file_with_ignore_patterns|\n if File.exist? file_with_ignore_patterns\n patterns = File.read(file_with_ignore_patterns).split(\"\\n\")\n patterns.map do |pattern|\n next if pattern =~ /^#/\n next if pattern =~ /^\\s*$/\n \"-not \\\\( -path \\\"*#{pattern}*\\\" -prune \\\\)\"\n end.compact.join(' ')\n else\n ''\n end\n end.join(' ') + [\n \"-not \\\\( -path \\\"*\\\\.git*\\\" -prune \\\\)\"\n ].join(' ')\nend",
"def check_results\n bin = prettier_path\n raise \"prettier is not installed\" unless bin\n return run_check(bin, \".\") unless filtering\n ((git.modified_files - git.deleted_files) + git.added_files)\n .select { |f| f[matching_file_regex] }\n .map { |f| f.gsub(\"#{Dir.pwd}/\", \"\") }\n .map { |f| run_check(bin, f) }\n end",
"def run_on_modifications(paths)\n UI.info \"Running tests on modified paths: #{paths}\" \n _really_run(Util.xcodebuild_command(options.merge(modified_paths: paths)))\n end",
"def examples_from(path) # rubocop:disable Metrics\n string = File.read(path)\n string = ERB.new(string).result\n\n examples_lines = string.lines.slice_before(/\\A\\s*!!!/)\n next_line_number = 1\n examples = examples_lines.flat_map do |example_lines|\n cur_line_number = next_line_number\n next_line_number += example_lines.size\n\n title_command = example_lines[0].strip\n # Remove the first example when the file starts with comments\n next unless title_command.start_with?('!!!')\n\n title = title_command.sub('!!!', '').lstrip\n example_string = example_lines[1..].join.rstrip + \"\\n\"\n\n # Completely remove lines with only a !# comment on them\n example_string = example_string.gsub(/^[ \\t]*!#.*\\n?/, '')\n\n # Remove !# comments\n example_string = example_string.gsub(/\\s*!#.*/, '')\n\n if example_string.include?('^')\n silent_example_string = example_string.gsub('^^', '').gsub('^', '-').gsub('%%', '')\n out_example_string = example_string.gsub('^^', 'HL.out = ')\n .gsub('%%', ' ')\n .gsub('^', '=')\n [\n Example.new(\"(^ as -)#{title}\", silent_example_string, path, cur_line_number),\n Example.new(\"(^ as =)#{title}\", out_example_string, path, cur_line_number),\n ]\n else\n Example.new(title, example_string, path, cur_line_number)\n end\n end\n\n examples.compact\n end",
"def start_coverage_tracking\n if ENV['CI']\n require 'codeclimate-test-reporter'\n CodeClimate::TestReporter.start\n else\n require 'simplecov'\n SimpleCov.start\n end\nend",
"def clean_paths\n cached_used = used_files\n glob_options = File::FNM_DOTMATCH | File::FNM_CASEFOLD\n files = Pathname.glob(root + \"**/*\", glob_options).map(&:to_s)\n\n files.reject! do |candidate|\n candidate = candidate.downcase\n candidate.end_with?('.', '..') || cached_used.any? do |path|\n path = path.downcase\n path.include?(candidate) || candidate.include?(path)\n end\n end\n files\n end",
"def cover_source_by source, specfile\n _source = File.expand_path( \"../../../#{source}\", __FILE__ )\n _spec = File.expand_path(\"../../#{specfile}\", __FILE__)\n FileUtils.touch(_spec) if File.mtime(_source) > File.mtime(_spec)\n File.mtime(_source) <= File.mtime(_spec)\nend",
"def file_to_codecov(file)\n # Initial nil is required to offset line numbers.\n [nil] + file.lines.map do |line|\n if line.skipped?\n nil\n else\n line.coverage\n end\n end\n end",
"def before_deploy_site \n Dir.chdir Origen.root do \n system \"origen examples -c\" \n dir = \"#{Origen.root}/web/output/coverage\" \n FileUtils.remove_dir(dir, true) if File.exists?(dir) \n system \"mv #{Origen.root}/coverage #{dir}\" \n end \n end",
"def path_to_coverage_report\n require 'pathname'\n Pathname.new(\"#{Origen.root}/coverage/index.html\").relative_path_from(Pathname.pwd)\nend",
"def find_files_without(source_path, ignored_paths, end_with = \"*.rb\")\n files_paths = Dir.glob(\"./#{source_path}/**/#{end_with}\")\n files_paths.select do |file_path|\n ignored_paths.map do |path|\n file_path.include?(\"/#{path}/\")\n end.none?\n end\n end",
"def combine_files(file1, file2)\n new_coverage = combine_coverages(file1.coverage, file2.coverage)\n # NOTE: It is possible that both don't exist but eventually either one does or it's just one of the names that was\n # used in the code\n new_filename = strict_file_exists?(file1.filename) ? file1.filename : file2.filename\n SimpleCov::SourceFile.new(new_filename, new_coverage)\n end",
"def lint_results\n bin = eslint_path\n raise 'eslint is not installed' unless bin\n return run_lint(bin, '.') unless filtering\n ((git.modified_files - git.deleted_files - git.renamed_files.map { |r| r[:before] }) + git.added_files + git.renamed_files.map { |r| r[:after] })\n .select { |f| target_extensions.include?(File.extname(f)) }\n .map { |f| f.gsub(\"#{Dir.pwd}/\", '') }\n .map { |f| run_lint(bin, f).first }\n end",
"def analyse_modified_files\n modified_files = ::RubyCritic::Config\n .feature_branch_collection\n .where(::RubyCritic::SourceControlSystem::Git.modified_files)\n ::RubyCritic::AnalysedModulesCollection.new(modified_files.map(&:path),\n modified_files)\n ::RubyCritic::Config.root = \"#{::RubyCritic::Config.root}/compare\"\n end",
"def start_coverage\n return unless sporkless? # Something funny about numbers right now under spork\n require 'simplecov'\nend",
"def analyze\n Core::Runner.base_path = @path\n Core::Runner.config_path = @options['config']\n @runner = Core::Runner.new\n\n analyze_source_codes\n analyze_vcs\n end",
"def test_files\n code_files_in(tests_dir, CPP_EXTENSIONS)\n end",
"def check_file(fn)\n File.foreach(fn) do |line|\n return $1 if line =~ /^\\s*require_relative\\s*['\"](.*spec_helper)['\"]/\n end\n nil\nend",
"def declare_chefignore\n @flavor.class.do_declare_resources do\n # :nocov:\n content = Chef::DelayedEvaluator.new do\n chefignore_patterns.sort.uniq.join(\"\\n\") + \"\\n\"\n end\n # :nocov:\n add_files(%w(chefignore), :create_if_missing, :file, content: content)\n end\n end",
"def file_patterns_errors_for_spec(spec, file, platform_name)\n Dir.chdir(config.project_pods_root + spec.name ) do\n messages = []\n messages += check_spec_files_exists(spec, :source_files, platform_name, '*.{h,m,mm,c,cpp}')\n messages += check_spec_files_exists(spec, :resources, platform_name)\n messages << \"license[:file] = '#{spec.license[:file]}' -> did not match any file\" if spec.license[:file] && Pathname.pwd.glob(spec.license[:file]).empty?\n messages.compact\n end\n end",
"def filter_nonexistent(modified_files); end",
"def filter!\n @files = SimpleCov.filtered(files)\n end",
"def filter!\n @files = SimpleCov.filtered(files)\n end",
"def filter!\n @files = SimpleCov.filtered(files)\n end",
"def clean_arb_dot_files(src)\n clean_list = $config[\"clean\"][\"remove_extentions\"].split(/,/)\n\n Find.find(src) do |path|\n next if File.basename(path) =~ /^\\._/\n clean_list.each do |ext|\n next if path !~ /\\.#{ext}/\n FileUtils.rm(path,$options) if File.exists? path\n end\n\n end\nend",
"def test_cases\n @test_cases ||= Dir.glob(model.spec_dir + '**/**/?*Spec.as')\n end",
"def run(args = ARGV)\n @options, paths = ::RuboCop::Options.new.parse(args)\n act_on_options\n\n target_finder = ::RuboCop::TargetFinder.new(@config_store)\n full_scan_files = target_finder.find('')\n @output.puts File.intersect(full_scan_files, Dir.pwd, paths, Dir.pwd)\n 0\n rescue StandardError => e\n $stderr.puts e.message\n $stderr.puts e.backtrace\n return 1\n end",
"def examples(path=\"./examples\")\n copy_dir(File.expand_path(File.dirname(__FILE__) + '/../../spec/source_code_examples'),path)\n end",
"def update_source_paths(fixture_result, from, to)\n fixture_result.each_with_object({}) do |(name, values), out|\n out[name] = {}\n values.each do |k, v|\n if k == \"coverage\"\n out[name][k] = {}\n v.each do |p, lines|\n path = p.sub(from, to)\n out[name][k][path] = lines\n end\n else\n out[name][k] = v\n end\n end\n end\n end",
"def ignored_file?(path); end",
"def add_source_files_references\n UI.message '- Adding source files' do\n add_file_accessors_paths_to_pods_group(:source_files, nil, true)\n end\n end",
"def relative(filename)\n filename.sub(%r{#{File.expand_path(File.join(File.dirname(__FILE__), \"..\", \"src\"))}/}, \"\")\nend",
"def test_ut_diff_source_code_02\n assert_equal(1,@diff_source_code_1.diff_result_id)\n assert_equal(1,@diff_source_code_1.original_file_id)\n assert_equal(1,@diff_source_code_1.diff_file_id)\n assert_equal(nil,@diff_source_code_1.added_lines)\n assert_equal(\"7;8;9;25;390;396;397;400;404\",@diff_source_code_1.deleted_lines)\n assert_equal(\"1,1;2,2;3,3;4,4;6,6;10,10;11,11;12,12;13,13;14,14;15,15;\",@diff_source_code_1.common_lines)\n end",
"def irrelevant_line?(source_line); end",
"def traite_inclusions_in code\n # On regarde si le fichier a des textes inclus\n if code.match(/^[ \\t]*<-/)\n code.gsub!(/^[ \\t]*<-([a-zA-Z0-9_\\/\\.]+)$/){\n finc = search_for_included_file(\"_#{$1}\", fpath)\n \"#{traite_inclusions_in(finc)}\"\n }\n end\n return code\n end",
"def process_specs\n source_path = configuration['specs']['source_path']\n destin_path = configuration['specs']['destin_path']\n ignored_paths = configuration['specs']['ignored_paths']\n ignored_methods = configuration['specs']['ignored_methods']\n\n find_files_without(source_path, ignored_paths).each do |path|\n next unless path.include?('/models/') || path.include?('/controllers/') || path.include?('/helpers/')\n @spec_template = indent_template(spec_template, 0)\n @spec_describe_template = spec_describe_template.gsub(' ' * 8, ' ' * 2).strip.prepend(' ' * 2)\n\n spath = path.split(\"./#{source_path}/\")[1]\n dpath = \"./#{destin_path}/#{spath}\".gsub('.rb', '_spec.rb')\n\n unless File.exists?(dpath)\n methods_names_source = extract_methods_names_from_file(path)\n specs_methods_to_string = methods_names_source.map do |method_name|\n @spec_describe_template.gsub('%{method_name}', method_name)\n end.join(\"\\n\\n\")\n\n @spec_template = @spec_template.gsub('%{class}', extract_spec_name(path))\n @spec_template = @spec_template.gsub('%{methods}', specs_methods_to_string)\n @spec_template = @spec_template.gsub('%{file_path}', path)\n @spec_template = @spec_template.gsub('%{class_type}', extract_spec_type(path))\n @spec_template = @spec_template.gsub('%{author_name}', extract_author_name)\n\n FileUtils.mkdir_p(File.dirname(dpath))\n File.new(dpath, 'w+').puts(@spec_template)\n end\n end\n end",
"def show_modified_files_coverage\n unless @project.nil?\n markdown modified_files_coverage_table\n end\n end",
"def sources\n @sources = Dir.glob(File.join(@test_cases_path,\"**\",\"*.txt\")).sort\n @sources\n end",
"def seperate_and_filter_trace(junit_test_file,\n files_path,\n peruser_files_path,\n student_file_name)\n code_and_trace = generate_backend_trace(junit_test_file,\n files_path,\n peruser_files_path,\n student_file_name)\n splitter = '\"' + 'trace' + '\"' + ':'\n user_code, whole_trace = code_and_trace.split(splitter)\n\n whole_trace = whole_trace[1..whole_trace.length]\n\n entire_json_file = code_analyzer(user_code, whole_trace)\n\n entire_json_file\nend",
"def process_exclusions globs\n remainder = globs.select do |glob|\n if glob_is_directory?(glob)\n exdir = File.join(directory, glob_to_directory(glob))\n included.delete_if { |file| file.start_with?(exdir) }\n false\n else\n true\n end\n end\n process_globs remainder\n end",
"def run\n files_to_inspect.each do |path|\n SourceFile.new(\n linter_config: linter_config,\n io: io,\n path: path,\n root: root\n ).process\n end\n end",
"def minimum_coverage_by_file(coverage = T.unsafe(nil)); end",
"def run!(options={})\n options[:exclude_paths] ||= []\n options[:include_paths].each do |path|\n DIR_PATTERS << path\n end if options[:include_paths]\n \n DIR_PATTERS.each do |main_dir|\n Dir.glob(main_dir).each do |path|\n # skip to the next file if this file matches exclude_paths\n next if options[:exclude_paths].detect { |pattern| File.fnmatch(pattern, path) }\n StampFile.new(path, options).stamp!\n end \n end\n true # return true (success)\n end",
"def match_golden_json(golden_filename,\n caller_path: caller_locations(1..1).first.path,\n excluded: nil)\n match_golden(golden_filename, caller_path: caller_path, formatter: JsonFormatter.new(excluded: excluded))\n end",
"def call(diff, _)\n super do\n diff.reject(&:deleted?).map(&:new_relative_path).grep(spec_pattern)\n end\n end",
"def find\r\n scanner = DirectoryScanner.new\r\n scanner.setBasedir(@context.root)\r\n scanner.setCaseSensitive(false)\r\n scanner.setIncludes(@includes.to_java :String) unless @includes.empty?\r\n scanner.setExcludes(@excludes.to_java :String) unless @excludes.empty?\r\n scanner.scan\r\n scanner.included_files.collect{|f| @context.filepath_from_root(f) }\r\n end",
"def test_file_must_contain_fuzzy()\n\t\tCfruby::FileEdit.file_must_contain(@multilinefilename, \"\\tnew line\", :position => Cfruby::FileEdit::APPEND)\n\t\tFile.open(@multilinefilename, File::RDONLY) { |fp|\n\t\t\tlines = fp.readlines()\n\t\t\tassert_equal(\"\\tnew line\\n\", lines[-1])\n\t\t}\n\n\t\tadded = Cfruby::FileEdit.file_must_contain(@multilinefilename, \"new line\", :fuzzymatch => true, :position => Cfruby::FileEdit::APPEND)\n\t\tassert_equal(false, added, \"file_must_contain added the fuzzy match when it shouldn't have\")\n\n\t\tadded = Cfruby::FileEdit.file_must_contain(@multilinefilename, \"new line\", :fuzzymatch => false, :position => Cfruby::FileEdit::APPEND)\n\t\tassert_equal(true, added, \"file_must_contain didn't add the strict match when it should have\")\n\t\t\n\t\t# test regexp escaping with fuzzymatch\n\t\tassert_nothing_raised() {\n\t\t\tCfruby::FileEdit.file_must_contain(@multilinefilename, '0 0 * * 5 /usr/local/sbin/pkg_version -v -L =', :fuzzymatch=>true)\n\t\t}\n\t\t\n\t\t@resolvfile = Tempfile.new('test')\n\t\t@resolvefilecontents = <<FILEBLOCK\n# our servers\nnameserver 69.9.164.130\nnameserver 69.9.164.131\nFILEBLOCK\n\t\t@resolvfile.write(@multilinefilecontents)\n\t\t@resolvfile.close(false)\n\n\t\tCfruby::FileEdit.file_must_contain(@resolvfile.path, 'domain titanresearch.com', :fuzzymatch=>true)\n\t\tCfruby::FileEdit.file_must_contain(@resolvfile.path, 'nameserver 69.9.164.130', :fuzzymatch=>true)\n\t\tCfruby::FileEdit.file_must_contain(@resolvfile.path, 'nameserver 69.9.164.131', :fuzzymatch=>true)\n\t\tCfruby::FileEdit.file_must_contain(@resolvfile.path, 'nameserver 66.180.175.18', :fuzzymatch=>true)\n\t\tCfruby::FileEdit.file_must_contain(@resolvfile.path, 'nameserver 69.9.191.4', :fuzzymatch=>true)\n\t\tCfruby::FileEdit.file_must_contain(@resolvfile.path, 'nameserver 69.9.160.191', :fuzzymatch=>true)\n\t\t\n\t\tassert_equal(true, Cfruby::FileEdit.contains?(@resolvfile.path, 'domain titanresearch.com'))\n\t\tassert_equal(true, Cfruby::FileEdit.contains?(@resolvfile.path, 'nameserver 69.9.164.130'))\n\t\tassert_equal(true, Cfruby::FileEdit.contains?(@resolvfile.path, 'nameserver 69.9.164.131'))\n\t\tassert_equal(true, Cfruby::FileEdit.contains?(@resolvfile.path, 'nameserver 66.180.175.18'))\n\t\tassert_equal(true, Cfruby::FileEdit.contains?(@resolvfile.path, 'nameserver 69.9.191.4'))\n\t\tassert_equal(true, Cfruby::FileEdit.contains?(@resolvfile.path, 'nameserver 69.9.160.191'))\n\tend",
"def pre_process_rubocop\n # copy over the .rubocop.yml file into the root directory of where this is running.\n shared_rubocop_file = File.expand_path('../../.rubocop.yml', File.dirname(__FILE__))\n dest_file = \"#{File.expand_path(@base_dir)}/.rubocop.yml\"\n if shared_rubocop_file != dest_file\n FileUtils.copy(shared_rubocop_file, dest_file)\n end\n\n puts \"Current directory is #{@base_dir}\"\n # puts \"Pre-processing tests run in #{@base_dir}\"\n puts \"Test results will be stored in: #{test_results_dir}\"\n\n FileUtils.rm_rf \"#{test_results_dir}/rubocop\" if Dir.exist? \"#{test_results_dir}/rubocop\"\n FileUtils.rm_rf \"#{@base_dir}/rubocop\" if Dir.exist? \"#{@base_dir}/rubocop\"\n\n # Call the test_results dir to create the directory and return it as a string.\n return test_results_dir\n end",
"def step2e_sources(path)\n return [path.sub(/^tmp/, 'out/bam').sub(/\\.step2e$/, '.bam')]\nend",
"def run_rspec(source, test_file)\n ForkProcess.run do\n Coverage.start(lines: true, branches: true)\n exit_code = RSpec::Core::Runner.run([test_file])\n Coverage.result.fetch(source.location.filename, {}).merge({ test_status: exit_code })\n end\n end",
"def get_non_flac_paths(source_path)\n non_flac_file_paths = Find.find(source_path).reject {|f| f.end_with?(\".flac\")}\n non_flac_file_paths.reject! {|e| !File.file?(e) }\n return non_flac_file_paths\nend"
] |
[
"0.62677276",
"0.57785356",
"0.5775404",
"0.5737828",
"0.5725156",
"0.5719086",
"0.56872344",
"0.5646256",
"0.5633359",
"0.5585594",
"0.5580334",
"0.5540335",
"0.55374",
"0.5489791",
"0.54888386",
"0.54700166",
"0.54642165",
"0.5463755",
"0.5461154",
"0.5457786",
"0.5448176",
"0.54481435",
"0.5408875",
"0.5389163",
"0.537052",
"0.53458726",
"0.53442776",
"0.53442276",
"0.530895",
"0.52739",
"0.52688473",
"0.5245509",
"0.5245003",
"0.5242048",
"0.52105325",
"0.5207194",
"0.52050453",
"0.5197811",
"0.51941293",
"0.5166252",
"0.5164218",
"0.5161471",
"0.5159563",
"0.5159563",
"0.51553845",
"0.51334244",
"0.51317483",
"0.5124464",
"0.5118326",
"0.511577",
"0.5113968",
"0.5113237",
"0.5101104",
"0.5096234",
"0.50853616",
"0.50666714",
"0.50640106",
"0.5061448",
"0.50585186",
"0.50567895",
"0.5052625",
"0.5048839",
"0.50274265",
"0.50222397",
"0.5020789",
"0.50183105",
"0.5014618",
"0.4999755",
"0.49984336",
"0.49974743",
"0.4996515",
"0.4996515",
"0.4996515",
"0.49919486",
"0.49843693",
"0.49810106",
"0.4965095",
"0.49617162",
"0.4961429",
"0.49612182",
"0.49600768",
"0.49482334",
"0.49416503",
"0.49387354",
"0.4936025",
"0.49304628",
"0.49292094",
"0.49194145",
"0.4918961",
"0.49178666",
"0.49094406",
"0.49070066",
"0.49062175",
"0.4905953",
"0.48998788",
"0.48976713",
"0.48968118",
"0.48867747",
"0.48862457",
"0.48817307"
] |
0.512841
|
47
|
Placeholder for ack received. You must override hsdq_request in your HsdqXxx class
|
def hsdq_ack(message, context); placeholder; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def ack\n @mq.callback do\n @mq.send Protocol::Basic::Ack.new({ :delivery_tag => @header_obj.properties[:delivery_tag] })\n end\n end",
"def ack(msg_info)\n end",
"def hsdq_send_ack(message)\n hsdq_send(message.merge(type: :ack))\n end",
"def req_ack(clk_e,req,ack,port)\n rst_req_ack(clk_e,nil,req,ack,port)\n end",
"def handle_ack_msg( their_msg )\r\n begin\r\n if their_msg.startup_ack\r\n super\r\n send_next_case\r\n warn \"Started, shouldn't see this again...\" if self.class.debug\r\n return\r\n end\r\n if their_msg.result\r\n self.class.lookup[:results][their_msg.result]||=0\r\n self.class.lookup[:results][their_msg.result]+=1\r\n if their_msg.result=='crash' and their_msg.crashdetail\r\n crashdetail=their_msg.crashdetail\r\n self.class.lookup[:buckets][DetailParser.hash( crashdetail )]=true\r\n # You might want to clear this when outputting status info.\r\n self.class.queue[:bugs] << DetailParser.long_desc( crashdetail )\r\n # Just initials - NOT EXPLOITABLE -> NE etc\r\n classification=DetailParser.classification( crashdetail).split.map {|e| e[0]}.join\r\n self.class.lookup[:classifications][classification]||=0\r\n self.class.lookup[:classifications][classification]+=1\r\n end\r\n else\r\n # Don't cancel the ack timeout here - this is the first ack\r\n # We wait to get the full result, post delivery.\r\n super\r\n send_next_case\r\n end\r\n rescue\r\n raise RuntimeError, \"#{COMPONENT}: Unknown error. #{$!}\"\r\n end\r\n end",
"def hsdq_callback(message, context); placeholder; end",
"def ack(subscription_headers, message)\n #p [:ack, message.headers[\"message-id\"]]\n if message.headers[\"message-id\"].to_s.strip != \"\" && subscription_headers[\"ack\"].to_s == \"client\"\n SMQueue.dbg { [:smqueue, :ack, :message, message].inspect }\n connection.ack message.headers[\"message-id\"], { }\n else\n SMQueue.dbg { [:smqueue, :ack, :not_acknowledging, message].inspect }\n end\n if ENV['PAUSE_SMQUEUE']\n $stderr.print \"press enter to continue> \"\n $stderr.flush\n $stdin.gets\n end\n end",
"def acked?; all_status?(:ack); end",
"def send_ack\n sock.put('+')\n vprint_status('Sending ack...')\n end",
"def ACK07=(arg)",
"def rst_req_ack(clk_e,rst,req,ack,port)\n if clk_e then\n # Ensures clk_e is an event.\n clk_e = clk_e.posedge unless clk_e.is_a?(Event)\n par(clk_e) do\n # Handle the reset.\n hif(rst) { port.reset } if rst\n ack <= 0\n # Control the start of the task.\n hif(req) { port.run }\n # Control the end of the task: set ack to 1.\n port.finish { ack <= 1 }\n end\n else\n par do\n # Handle the reset\n hif(rst) { port.reset } if rst\n # Control the start of the task.\n hif(req) { port.run }\n ack <= 0\n # Control the end of the task: set ack to 1.\n port.finish { ack <= 1 }\n end\n end\n end",
"def ack_frame *args\n create_ack_or_nack 'ACK', args\n end",
"def ACK08=(arg)",
"def ack\n unless acked?\n @acked = true\n @connection.future(:ack, delivery_info.delivery_tag).value\n end\n end",
"def ACK04=(arg)",
"def ACK06=(arg)",
"def ack(opts={})\n\t\t\t# Set delivery tag\n\t\t\tdelivery_tag = opts.delete(:delivery_tag)\n\t\t\tdelivery_tag ||= self.delivery_tag\n\t\t\traise Bunny::AcknowledgementError, \"No delivery tag received\" unless delivery_tag\n\t\t\t\n client.send_frame(\n Qrack::Protocol09::Basic::Ack.new({:delivery_tag => delivery_tag, :multiple => false}.merge(opts))\n )\n\n\t\t\t# reset delivery tag\n\t\t\tself.delivery_tag = nil if self.delivery_tag == delivery_tag\n end",
"def ACK10=(arg)",
"def ack msgid\n send_frame \"ACK\", 'message-id'=> msgid\n end",
"def acknowledge\n # do nothing\n end",
"def ACK05=(arg)",
"def ack_message(adapter, queue_url, msg)\n adapter.sqs_client.delete_message(\n queue_url: queue_url, receipt_handle: msg.receipt_handle\n )\n end",
"def acknowledge()\n\t\tend",
"def ACK01=(arg)",
"def ACK03=(arg)",
"def test_client_ack_with_symbol_10\n if @conn.protocol != Stomp::SPL_10\n assert true\n return\n end\n queue = make_destination()\n @conn.subscribe queue, :ack => :client\n @conn.publish queue, \"test_stomp#test_client_ack_with_symbol_10\"\n msg = @conn.receive\n assert_nothing_raised {\n # ACK has one required header, message-id, which must contain a value \n # matching the message-id for the MESSAGE being acknowledged.\n @conn.ack msg.headers['message-id']\n }\n checkEmsg(@conn)\n end",
"def send_ack(spark)\n return unless ['request', :request].include? spark[:type]\n ack_msg = spark.merge sent_to: spark[:sender], sender: channel\n hsdq_send_ack ack_msg\n end",
"def test_client_ack_with_symbol_12\n if @conn.protocol != Stomp::SPL_12\n assert true\n return\n end\n sid = @conn.uuid()\n queue = make_destination()\n @conn.subscribe queue, :ack => :client, :id => sid\n @conn.publish queue, \"test_stomp#test_client_ack_with_symbol_11\"\n msg = @conn.receive\n assert_nothing_raised {\n # The ACK frame MUST include an id header matching the ack header \n # of the MESSAGE being acknowledged.\n @conn.ack msg.headers['ack']\n }\n checkEmsg(@conn)\n end",
"def ACK09=(arg)",
"def ack(opts = {})\n # Set delivery tag\n if delivery_tag.nil? and opts[:delivery_tag].nil?\n raise Bunny::AcknowledgementError, \"No delivery tag received\"\n else\n self.delivery_tag = opts[:delivery_tag] if delivery_tag.nil?\n end\n\n opts = {:delivery_tag => delivery_tag, :multiple => false}.merge(opts)\n\n client.send_frame(Qrack::Protocol::Basic::Ack.new(opts))\n\n # reset delivery tag\n self.delivery_tag = nil\n end",
"def test_client_ack_with_symbol_11\n if @conn.protocol != Stomp::SPL_11\n assert true\n return\n end\n sid = @conn.uuid()\n queue = make_destination()\n @conn.subscribe queue, :ack => :client, :id => sid\n @conn.publish queue, \"test_stomp#test_client_ack_with_symbol_11\"\n msg = @conn.receive\n assert_nothing_raised {\n # ACK has two REQUIRED headers: message-id, which MUST contain a value \n # matching the message-id for the MESSAGE being acknowledged and \n # subscription, which MUST be set to match the value of the subscription's \n # id header.\n @conn.ack msg.headers['message-id'], :subscription => msg.headers['subscription']\n }\n checkEmsg(@conn)\n end",
"def ack_required?\n self.class.ack_required?(action)\n end",
"def ACK02=(arg)",
"def handle_heartbeat_ack(_payload)\n @heartbeat_acked = true\n end",
"def ack(msg)\n return unless msg.sub\n msg.sub.synchronize do\n ack_proto = STAN::Protocol::Ack.new({\n subject: msg.proto.subject,\n sequence: msg.proto.sequence\n }).to_proto\n nats.publish(msg.sub.ack_inbox, ack_proto)\n end\n end",
"def hsdq_feedback(message, context); placeholder; end",
"def nack\n @action = :nack\n end",
"def setup_shared_queue\n @amq.queue(@shared_queue).subscribe(:ack => true) do |info, msg|\n begin\n info.ack\n receive_request(@serializer.load(msg))\n rescue Exception => e\n RightLinkLog.error(\"RECV #{e.message}\")\n @callbacks[:exception].call(e, msg, self) rescue nil if @callbacks && @callbacks[:exception]\n end\n end\n true\n end",
"def on_message_ack(&handler)\n @on_message_ack_handler = handler\n end",
"def hsdq_send_request(message)\n hsdq_send(message.merge(type: :request))\n end",
"def work(raw_post)\n puts \"Msg received: \" + raw_post\n ack! # we need to let queue know that message was received\n end",
"def ack=(ack)\n raise 'Invalid ack flag. true or false expected' unless\n [true, false].include? ack\n @message[:ack] = ack\n end",
"def nack_message(adapter, queue_url, msg)\n adapter.sqs_client.change_message_visibility(\n queue_url: queue_url,\n receipt_handle: msg.receipt_handle,\n visibility_timeout: NACK_VISIBILITY_TIMEOUT\n )\n rescue StandardError => e\n Mimi::Messaging.logger&.error(\n \"#{self.class}: failed to NACK message from: #{queue_url},\" \\\n \" error: (#{e.class}) #{e}\"\n )\n # NOTE: error is recovered and the message is neither ACKed or NACKed\n end",
"def haseventack(key)\n @events_ack[key]\n end",
"def ack!\n @manager.ack(self)\n self\n end",
"def nack_frame *args\n create_ack_or_nack 'NACK', args\n end",
"def replyWithAck?(pduPacket)\n\n Utils_visiona.verifyInput(CFDP::PDUPacket, pduPacket.class)\n return unless isclass2?\n\n status = (@finishType.nil? ? 1 : 2)\n sourceID = MYID\n destinationID = DESTINATIONID\n direction = 0\n\n # This is a received PDU.\n case pduPacket.pduPayload\n when CFDP::PDUEOF\n \n # I only receive EOF packets in DOWNLINK events\n return unless @type.eql?(\"DOWNLINK\")\n direction = 1\n sourceID = destinationID\n destinationID = MYID\n when CFDP::PDUFinished\n\n # I only receive FINISHED packets in UPLINK events\n return unless @type.eql?(\"UPLINK\")\n # use default values from function start\n else\n return\n end\n\n ackPdu = CFDP.generatePDU(\"ACK\", directiveCode:pduPacket.pduPayload.class.class_variable_get(:@@fdCode),\n directiveSubtypeCode:0, conditionCode:pduPacket.pduPayload.conditionCode, transactionStatus:status,\n direction:direction, transmissionMode:0, sourceID:sourceID, destinationID:destinationID,\n sequenceNumber:pduPacket.pduHeader.sequenceNumber)\n\n writeLog(\"Generated ACK PDU: #{ackPdu.pack.to_s}\")\n CFDP::CFDPEngine.instance.insertIntoBuffer(ackPdu)\n end",
"def ack?\n Capp::TCP_ACK == flags & Capp::TCP_ACK\n end",
"def cmdh_ping_req(msg_details)\n @log.debug \"PINGREQ handler\"\n # response back\n send_ping_resp\n end",
"def receive_request(header, content)\n hash_header = headers_2_hash(header)\n if content.to_s.match(/:/)\n hash_content = headers_2_hash(content)\n else\n hash_content = content\n end\n session_header_and_content = HeaderAndContentResponse.new({:headers => hash_header, :content => hash_content})\n # If we're a new session, call session initiate\n if session.nil?\n establish_new_session(session_header_and_content)\n elsif @uuid_var and session_header_and_content.headers[:content_type] == \"api/response\"\n FSR::Log.info(\"@uuid_var is set => #{session_header_and_content.inspect} : #{content}\")\n r, @uuid_var = session_header_and_content.content.strip, nil\n @queue.pop.call(r) if @queue.size > 0\n elsif @api_request and session_header_and_content.headers[:content_type] == \"api/response\"\n @queue.pop.call if @queue.size > 0\n elsif session_header_and_content.content.class == Hash\n if session_header_and_content.content[:event_name] # If content includes an event_name, it must be a response from an api command\n check_for_updated_session(session_header_and_content, hash_content, hash_header)\n end\n else\n update_state_machine(session_header_and_content)\n end\n end",
"def acknowledge\n api_call(\"acknowledge\")\n self\n end",
"def test_creating_receive_ACK_message\n test_string = @mf.hex_string_to_string(\"82 00 82\")\n test_message = @msg_fac.new_incoming_message(test_string)\n assert_kind_of(HAIthermo::Message::ReceiveACK, test_message)\n end",
"def confirm_ack(conn, seq)\r\n return unless @queue[conn.user.id]\r\n @queue[conn.user.id].delete_if {|x| x[:seq] == seq}\r\n conn.empty_response\r\n end",
"def initialize(exchange_name = nil, routing_key: nil, connection: nil, context: nil, ident: nil, expiration: nil, persistent: true, durable: true, timeout: nil)\n super(connection: connection, context: context, ident: ident)\n\n @routing_key = routing_key\n @timeout = timeout\n\n @rpc_exchange = self.channel.direct(\n exchange_name || EXCHANGE_NAME_DEFAULT,\n durable: durable\n )\n\n @response_queue = self.channel.queue(\n @ident,\n durable: false,\n header: true,\n auto_delete: true\n )\n @expiration = expiration\n @persistent = !!persistent\n\n @callback = { }\n\n @consumer = Skein::Adapter.subscribe(@response_queue, block: false) do |payload, delivery_tag, reply_to|\n self.context.trap do\n if (ENV['SKEIN_DEBUG_JSON'])\n $stdout.puts(payload)\n end\n\n response = JSON.load(payload)\n\n if (callback = @callback.delete(response['id']))\n if (response['error'])\n exception =\n case (response['error'] and response['error']['code'])\n when -32601\n NoMethodError.new(\n \"%s from `%s' RPC call\" % [\n response.dig('error', 'message'),\n response.dig('error', 'data', 'method')\n ]\n )\n when -32602\n ArgumentError.new(\n response.dig('error', 'data', 'message') || 'wrong number of arguments'\n )\n else\n RPCException.new(\n response.dig('error', 'data', 'message') || response.dig('error', 'message')\n )\n end\n\n case (callback)\n when Skein::TimeoutQueue\n callback << exception\n when Proc\n callback.call(exception)\n end\n else\n case (callback)\n when Skein::TimeoutQueue\n callback << response['result']\n when Proc\n callback.call(response['result'])\n end\n end\n end\n\n self.channel.acknowledge(delivery_tag)\n end\n end\n end",
"def ack_block(cid)\n ws = @ws\n lambda do |error, data|\n ws.send(get_ack_object(error, data, cid))\n end\n end",
"def process_ack(data, reply, subject)\n # FIXME: This should handle errors asynchronously in case there are any\n\n # Process ack\n pub_ack = STAN::Protocol::PubAck.decode(data)\n unless pub_ack.error.empty?\n raise Error.new(pub_ack.error)\n end\n\n # Unblock publishing queue\n @pending_pub_acks.pop if @pending_pub_acks.size > 0\n\n synchronize do\n # yield the ack response back to original publisher caller\n if cb = @pub_ack_map[pub_ack.guid]\n cb.call(pub_ack)\n end\n end\n end",
"def enable_xack\n getok('XACK ON')\n @xack = true\n end",
"def acknowledge(info, &callback)\n EM.defer {\n @sqs.delete_message(\n queue_url: @settings[:consuming_sqs_queue_url],\n receipt_handle: info.receipt_handle,\n )\n statsd_incr(\"sqs.#{@settings[:consuming_sqs_queue_url]}.message.deleted\")\n callback.call(info) if callback\n }\n end",
"def on_verack\n log.debug { \">> verack\" }\n complete_handshake if outgoing?\n end",
"def screencast_frame_ack(session_id:)\n {\n method: \"Page.screencastFrameAck\",\n params: { sessionId: session_id }.compact\n }\n end",
"def ack_receipt\n Net::HTTP.get(URI(params[:response_url]))\n end",
"def subscribe_frame d, h\n h[:ack] = 'auto' unless ['client', 'client-individual'].include?(h[:ack])\n create_frame 'SUBSCRIBE', [{:id => OnStomp.next_serial}, h, {:destination => d}]\n end",
"def acknowledge(authcode = nil)\n true\n end",
"def acknowledge\n verify? params, KEY\n end",
"def acknowledge\n verify? params, KEY\n end",
"def started_request_message(request); end",
"def send_topic_acknowledge(msg, headers, timeout=60)\n #m=StompMessage::Message.new('stomp_BILLING', msg)\n open_connection\n s=rand*30 # scott - used to be 1000 but seem to create connections on activemq\n # open new topic to listen to reply...\n # was this but jms seems to blow up receipt_topic=\"/topic/receipt/client#{s.to_i}\"\n receipt_topic=\"/topic/rcpt_client#{s.to_i}\"\n receipt_flag = false\n # internal_conn = Stomp::Connection.open '', '', self.host, self.port, false \n self.conn.subscribe( receipt_topic, { :ack =>\"client\" }) {|msg|\n begin\n Timeout::timeout(timeout) {\n self.conn.acknowledge(msg,msg.headers)\n \t msg2= msg.body\n \t yield msg2\n }\n rescue Exception => e\n puts \"exception #{e.message}\"\n # raise \"timeout\" \n ensure\n receipt_flag=true\n self.conn.unsubscribe receipt_topic \n end \n }\n \n \n more_headers= {'persistent'=>'false', 'reply-to' => \"#{receipt_topic}\" }\n more_headers.merge headers\n self.conn.send(self.topic, msg.to_xml, more_headers ) \n Thread.new { sleep(timeout+1)\n puts \"calling unsubscribe on #{receipt_topic}\" if !receipt_flag\n self.conn.unsubscribe receipt_topic if !receipt_flag\n } \n end",
"def executeack(key, object, ack)\n function = @events_ack[key] if @events_ack.key?(key)\n function.call(key, object, ack) if function\n end",
"def emitack(event, object, ack)\n @ws.send(get_emit_ack_object(event, object, increment_cnt).to_json)\n @acks[@cnt] = [event, ack]\n end",
"def on_request( channel, request, want_reply, data )\n end",
"def initialize(response)\n super\n # XXX assign to :signal\n end",
"def ack(multiple = false)\n @channel.acknowledge(@method.delivery_tag, multiple)\n end",
"def get_ack_probe()\n tcp_ack_probe = get_tcp_packet()\n tcp_ack_probe.tcp_flags.syn = 0\n tcp_ack_probe.tcp_flags.ack = 1\n\n return tcp_ack_probe\n end",
"def basic_nack(delivery_tag, multiple: false, requeue: false)\n write_bytes FrameBytes.basic_nack(@id, delivery_tag, multiple, requeue)\n nil\n end",
"def parse_body(buffer)\n super(buffer)\n @id = shift_short(buffer)\n\n return if buffer.empty?\n raise ProtocolException, 'Extra bytes at end of Publish Acknowledgment packet'\n end",
"def receive_ping_request(request)\n request.reply(nil)\n end",
"def pre_initialize(**opts)\n @manual_ack = opts[:manual_ack].present?\n @on_cancellation = opts[:on_cancellation] || ->{}\n end",
"def parse_body(buffer)\n super(buffer)\n @id = shift_short(buffer)\n\n return if buffer.empty?\n raise ProtocolException, 'Extra bytes at end of Unsubscribe Acknowledgment packet'\n end",
"def ack(device_uuid, ack_keys)\n validate_device!(device_uuid)\n raise ArgumentError, \"ack_keys must not be nil and an array\" unless ack_keys && ack_keys.is_a?(Array)\n return true if ack_keys.empty?\n\n payload = {\n :ack_keys => ack_keys.map(&:to_s)\n }\n status, _, _ = @client.post('/sync/ack', payload, build_headers(device_uuid))\n status == 202\n end",
"def setup\n EM.kqueue\n #AMQP.logging = true\n @mq = MQ.new\n @requests = @mq.queue('jesus_nut',:auto_delete => true)\n @setup = true\n @mq.queue(@reply_to).subscribe { |info, response|\n resp = Marshal.load response\n callback = @pending.delete info.message_id\n callback.call resp\n }\n @id = 1\n end",
"def received message, headers={}\n end",
"def onack(key, function)\n @events_ack[key] = function\n end",
"def parse_body(buffer)\n super(buffer)\n @connack_flags = shift_bits(buffer)\n unless @connack_flags[1, 7] == [false, false, false, false, false, false, false]\n raise ProtocolException, 'Invalid flags in Connack variable header'\n end\n @return_code = shift_byte(buffer)\n\n return if buffer.empty?\n raise ProtocolException, 'Extra bytes at end of Connect Acknowledgment packet'\n end",
"def global_request(packet); end",
"def poll_req\n super # placeholder so that I can add some doc\n end",
"def started_request_message(*args)\n \"\"\n end",
"def response=(_arg0); end",
"def response=(_arg0); end",
"def response=(_arg0); end",
"def response=(_arg0); end",
"def receive_request(request)\n request.reply(\"You should override #{self.class.to_s}#receive_request.\")\n end",
"def acknowledge_response(response)\n id = response['message-response-id']\n http.delete(api_base_uri.path + \"/messages/#{id}\")\n end",
"def accept_kexinit(packet); end",
"def hsdq_error(message, context); placeholder; end",
"def acknowledge(authcode = nil)\n string = [params['_raw_action'],\n params['_raw_orderSumAmount'],\n params['_raw_orderSumCurrencyPaycash'],\n params['_raw_orderSumBankPaycash'],\n params['_raw_shopId'],\n params['_raw_invoiceId'],\n params['_raw_customerNumber'],\n authcode\n ].join(';')\n\n digest = Digest::MD5.hexdigest(string)\n res = params['_raw_md5'] == digest.upcase\n if res\n @response_code = '0'\n else\n @response_code = '1'\n end\n end",
"def send_request(data)\n \n if $DEBUG\n puts \"[request]data--------------\"\n puts data\n puts \"--------------------------\" \n end\n \n outgoing = Blix.to_binary_data(data)\n options = {}\n \n options[:key] = \"\"\n options[:reply_to] = @reply_to\n options[:content_type] = \"text/xml\"\n options[:message_id] = \"#{@time.to_i}#{rand(9999)}\"\n @out_exch.publish(outgoing, options )\n \n incoming = nil\n while (!incoming)\n msg = @in_queue.pop\n payload = msg[:payload]\n incoming = payload unless payload == :queue_empty\n end\n # \n if $DEBUG\n puts \"[request]response data-----\"\n puts incoming\n puts \"--------------------------\" \n end\n incoming\n end",
"def ack_message( tag, success, try_again=true )\n\t\treturn unless self.acknowledge\n\n\t\tchannel = self.consumer.channel\n\n\t\tif success\n\t\t\tself.log.debug \"ACKing message %s\" % [ tag ]\n\t\t\tchannel.acknowledge( tag )\n\t\telse\n\t\t\tself.log.debug \"NACKing message %s %s retry\" % [ tag, try_again ? 'with' : 'without' ]\n\t\t\tchannel.reject( tag, try_again )\n\t\tend\n\n\t\treturn success\n\tend",
"def process_msg(data, reply, subject)\n msg = Msg.new\n msg.proto = STAN::Protocol::MsgProto.decode(data)\n msg_ack = STAN::Protocol::Ack.new({\n subject: msg.proto.subject,\n sequence: msg.proto.sequence\n })\n\n # Lookup the subscription\n sub = nil\n synchronize do\n sub = @sub_map[subject]\n end\n # Check if sub is no longer valid\n return unless sub\n\n # Store in msg for backlink\n msg.sub = sub\n\n cb = nil\n ack_subject = nil\n using_manual_acks = nil\n sub.synchronize do\n cb = sub.cb\n ack_subject = sub.ack_inbox\n using_manual_acks = sub.options[:manual_acks]\n end\n\n # Perform the callback if sub still subscribed\n cb.call(msg) if cb\n\n # Process auto-ack if not done manually\n nats.publish(ack_subject, msg_ack.to_proto) if not using_manual_acks\n end",
"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 reset_reply_queue\n @reply_queue.delete if @reply_queue\n @reply_queue = channel.queue('', :exclusive => true, :auto_delete => true)\n\n @reply_queue.subscribe do |delivery_info, properties, payload|\n payload = self.parse_payload(payload)\n\n if properties[:correlation_id] == @correlation_id\n @response = payload\n @lock.synchronize{@condition.signal}\n end\n end\n end"
] |
[
"0.7028409",
"0.658635",
"0.65078974",
"0.63730556",
"0.63401514",
"0.63015056",
"0.6200988",
"0.6188497",
"0.61433804",
"0.61350363",
"0.6123512",
"0.60782903",
"0.6040169",
"0.5986932",
"0.59699655",
"0.59630936",
"0.59562784",
"0.59536606",
"0.5950276",
"0.592767",
"0.59198534",
"0.58821726",
"0.5852718",
"0.5802419",
"0.57950836",
"0.5778559",
"0.5772272",
"0.5731877",
"0.5729386",
"0.5722394",
"0.57060987",
"0.56504995",
"0.5646066",
"0.56366086",
"0.56359327",
"0.56275445",
"0.5612567",
"0.56053084",
"0.5517139",
"0.550325",
"0.5491896",
"0.54860604",
"0.54765594",
"0.54653937",
"0.54489833",
"0.54420424",
"0.54249144",
"0.5415336",
"0.5375767",
"0.5370232",
"0.5366737",
"0.5361987",
"0.53504115",
"0.53414327",
"0.5328505",
"0.5304414",
"0.52644986",
"0.52534425",
"0.5246678",
"0.52421796",
"0.5201254",
"0.5175686",
"0.51667064",
"0.5165366",
"0.5165366",
"0.5147023",
"0.5132491",
"0.51294744",
"0.5128313",
"0.5125961",
"0.512499",
"0.51095814",
"0.51074547",
"0.5100064",
"0.5083594",
"0.50676805",
"0.5066643",
"0.50445855",
"0.5039144",
"0.50196844",
"0.50184965",
"0.5006462",
"0.49997646",
"0.49971044",
"0.49818873",
"0.49662244",
"0.49255395",
"0.49255395",
"0.49255395",
"0.49255395",
"0.4923634",
"0.4909667",
"0.48994955",
"0.48897022",
"0.48705503",
"0.48704344",
"0.4869531",
"0.48655704",
"0.48621568",
"0.48551986"
] |
0.7449846
|
0
|
Placeholder for callback received. You must override hsdq_request in your HsdqXxx class
|
def hsdq_callback(message, context); placeholder; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def callback\n def_deferr = ::EventMachine::DefaultDeferrable.new\n proc_callback = Proc.new { |response| ::OnesnooperServer::Log.debug(\n \"[#{self.class.name}] Handled as: #{response}\"\n ) }\n\n def_deferr.callback &proc_callback\n def_deferr.errback &proc_callback\n\n def_deferr\n end",
"def hsdq_send_callback(message)\n hsdq_send(message.merge(type: :callback))\n end",
"def callback\n\n end",
"def callback\n end",
"def callback\n\tend",
"def on_request &b\n @request_proc = b\n self\n end",
"def callback=(_arg0); end",
"def set_callback\n if request.streaming?\n response = nil\n easy.on_headers do |easy|\n response = Response.new(Ethon::Easy::Mirror.from_easy(easy).options)\n request.execute_headers_callbacks(response)\n end\n request.on_body.each do |callback|\n easy.on_body do |chunk, easy|\n callback.call(chunk, response)\n end\n end\n else\n easy.on_headers do |easy|\n request.execute_headers_callbacks(Response.new(Ethon::Easy::Mirror.from_easy(easy).options))\n end\n end\n request.on_progress.each do |callback|\n easy.on_progress do |dltotal, dlnow, ultotal, ulnow, easy|\n callback.call(dltotal, dlnow, ultotal, ulnow, response)\n end\n end\n easy.on_complete do |easy|\n request.finish(Response.new(easy.mirror.options))\n Typhoeus::Pool.release(easy)\n if hydra && !hydra.queued_requests.empty?\n hydra.dequeue_many\n end\n end\n end",
"def default_callback\n lambda do |type, format, conv, hsz1, hsz2, data_handle, data1, data2|\n case type\n when XTYP_CONNECT # Request to connect from client, creating data exchange channel\n # format:: Not used.\n # conv:: Not used.\n # hsz1:: Handle to the topic name.\n # hsz2:: Handle to the service name.\n # data_handle:: Handle to DDE data. Meaning depends on the type of the current transaction.\n # data1:: Pointer to a CONVCONTEXT structure that contains context information for the conversation.\n # If the client is not a DDEML application, this parameter is 0.\n # data2:: Specifies whether the client is the same application instance as the server. If the parameter\n # is 1, the client is the same instance. If it is 0, the client is a different instance.\n # *Returns*:: A server callback function should return TRUE(1, but DDE_FACK works just fine too)\n # to allow the client to establish a conversation on the specified service name and topic\n # name pair, or the function should return FALSE to deny the conversation. If the callback\n # function returns TRUE and a conversation is successfully established, the system passes\n # the conversation handle to the server by issuing an XTYP_CONNECT_CONFIRM transaction to\n # the server's callback function (unless the server specified the CBF_SKIP_CONNECT_CONFIRMS\n # flag in the DdeInitialize function).\n\n if hsz2 == @service.handle\n cout \"Service #{@service}: connect requested by client\\n\"\n DDE_FACK # instead of true # Yes, this server supports requested (name) handle\n else\n cout \"Service #{@service} unable to process connection request for #{hsz2}\\n\"\n DDE_FNOTPROCESSED # 0 instead of false # No, server does not support requested (name) handle\n end\n\n when XTYP_POKE # Client initiated XTYP_POKE transaction to push unsolicited data to the server\n # format:: Specifies the format of the data sent from the server.\n # conv:: Handle to the conversation.\n # hsz1:: Handle to the topic name. (Excel: [topic]item ?!)\n # hsz2:: Handle to the item name.\n # data_handle:: Handle to the data that the client is sending to the server.\n # *Returns*:: A server callback function should return the DDE_FACK flag if it processes this\n # transaction, the DDE_FBUSY flag if it is too busy to process this transaction,\n # or the DDE_FNOTPROCESSED flag if it rejects this transaction.\n\n @data.topic = dde_query_string(@id, hsz1) # Convert hsz1 into \"[topic]item\" string and\n if @data.receive(data_handle) # Receive incoming DDE data and process it\n\n # Perform actions like :draw, :debug, :timer, :formats on received data (default :timer)\n @actions.each{|action| @data.send(action.to_sym)}\n DDE_FACK # Transaction successful\n else\n @data.debug\n cout \"Service #{@service} unable to process data request (XTYP_POKE) for #{hsz2}\"\n DDE_FNOTPROCESSED # 0 Transaction NOT successful - return (HDDEDATA)TRUE; ?!(why TRUE, not FALSE)\n end\n else\n DDE_FNOTPROCESSED # 0 - return((HDDEDATA)NULL);// is it the same as 0 ?!\n end\n end\n end",
"def send_channel_request(request_name, *data, &callback); end",
"def callback\n headers.clear\n if callbacks and not callbacks.empty?\n queue_name = callbacks.shift\n Minion.enqueue(queue_name, as_json)\n end\n end",
"def call_block_for_request(request, parsed_response)\n if parsed_response[\"body\"].nil?\n request.on_complete_block.call(parsed_response) if request.on_complete_block\n else\n case request.token.gsub(/:.*/, \"\")\n when \"subscribe\"\n request.on_datastream_block.call(parsed_response) if request.on_datastream_block\n when \"get\"\n request.on_get_block.call(parsed_response) if request.on_get_block\n end\n end\n end",
"def callback_type; end",
"def send_global_request(type, *extra, &callback); end",
"def on_response &b\n @response_proc = b\n self\n end",
"def callback\n logger.info ap params\n head :ok\n end",
"def initialize(exchange_name = nil, routing_key: nil, connection: nil, context: nil, ident: nil, expiration: nil, persistent: true, durable: true, timeout: nil)\n super(connection: connection, context: context, ident: ident)\n\n @routing_key = routing_key\n @timeout = timeout\n\n @rpc_exchange = self.channel.direct(\n exchange_name || EXCHANGE_NAME_DEFAULT,\n durable: durable\n )\n\n @response_queue = self.channel.queue(\n @ident,\n durable: false,\n header: true,\n auto_delete: true\n )\n @expiration = expiration\n @persistent = !!persistent\n\n @callback = { }\n\n @consumer = Skein::Adapter.subscribe(@response_queue, block: false) do |payload, delivery_tag, reply_to|\n self.context.trap do\n if (ENV['SKEIN_DEBUG_JSON'])\n $stdout.puts(payload)\n end\n\n response = JSON.load(payload)\n\n if (callback = @callback.delete(response['id']))\n if (response['error'])\n exception =\n case (response['error'] and response['error']['code'])\n when -32601\n NoMethodError.new(\n \"%s from `%s' RPC call\" % [\n response.dig('error', 'message'),\n response.dig('error', 'data', 'method')\n ]\n )\n when -32602\n ArgumentError.new(\n response.dig('error', 'data', 'message') || 'wrong number of arguments'\n )\n else\n RPCException.new(\n response.dig('error', 'data', 'message') || response.dig('error', 'message')\n )\n end\n\n case (callback)\n when Skein::TimeoutQueue\n callback << exception\n when Proc\n callback.call(exception)\n end\n else\n case (callback)\n when Skein::TimeoutQueue\n callback << response['result']\n when Proc\n callback.call(response['result'])\n end\n end\n end\n\n self.channel.acknowledge(delivery_tag)\n end\n end\n end",
"def hsdq_feedback(message, context); placeholder; end",
"def request_query(request_data)\n return @callback.call(:is_ready, nil)\n end",
"def response=(_arg0); end",
"def response=(_arg0); end",
"def response=(_arg0); end",
"def response=(_arg0); end",
"def callback\n @on_declare\n end",
"def callback\n head :ok\n end",
"def callbacks; end",
"def callbacks; end",
"def got_response(response)\n end",
"def hsdq_send_request(message)\n hsdq_send(message.merge(type: :request))\n end",
"def hsdq_ack(message, context); placeholder; end",
"def callback &block\n super\n end",
"def callback &block\n super\n end",
"def send_request; end",
"def hsdq_error(message, context); placeholder; end",
"def iq_callback(iq)\n if iq.type == :get\n if iq.query.kind_of?(IqQueryVersion)\n replyblock = lambda { |name,version,os|\n answer = iq.answer\n answer.type = :result\n answer.query.set_iname(name).set_version(version).set_os(os)\n\n @stream.send(answer)\n true\n }\n @versioncbs.process(iq, replyblock)\n else\n false\n end\n else\n false\n end\n end",
"def receive_response(response); end",
"def on_request( channel, request, want_reply, data )\n end",
"def on_global_request(type, &block); end",
"def started_request_message(request); end",
"def cheque_callback(params,&block)\n\t\t\n\tend",
"def query_callback_common(row_data)\n view = @requests[row_data[:cookie].address]\n\n if row_data[:rc] == :success\n value = JSON.parse(row_data[:row].read_string(row_data[:nrow]), DECODE_OPTIONS)\n\n if (row_data[:rflags] & Ext::RESPFLAGS[:resp_f_final]) > 0\n # We can assume this is JSON\n view.received_final(value)\n else\n view.received(value)\n end\n else\n error_klass = Error.lookup(row_data[:rc])\n if error_klass == Error::HttpError\n http_resp = row_data[:htresp]\n view.error error_klass.new(body_text(http_resp))\n else\n view.error error_klass.new\n end\n end\n end",
"def callback\n return response if called\n self.response = k.inject(\n env.merge(RESPONSE_BODY => body ,\n RESPONSE_STATUS => status,\n RESPONSE_HEADERS => headers,\n RESPONSE_SOCKET => socket,\n FAIL => ((env[FAIL]||[]) + [error]).compact,\n LOG => env[LOG] ||[])){ |r, i| i.call(r) }\n ensure\n self.called = true\n end",
"def handle_request request, usecase=Usecase, &block\n usecase = build_usecase( request, usecase, &block )\n usecase.response\n end",
"def request_data; end",
"def definecallback(&b)\r\n\t\t\t@callback = b\r\n\t\tend",
"def call_ok_handler; call_handler(:ok); end",
"def on_request( &block )\n @on_request = block\n end",
"def callback\n self.class.callback\n end",
"def callback\n self.class.callback\n end",
"def register_request_callback(&block)\n request_callbacks << block\n end",
"def gnp_handler request_uri, env\n op, name, entry_uri = (request_uri.to_s.split /;/)\n unless sub = @subscriptions.find { |s| s.name == name }\n raise \"no such subscription: #{name} :: #{entry_uri}\"#\\n#{@subscriptions.inspect}\"\n end\n\n begin\n req = Rack::Request.new(env)\n op, payload = (decode_gnp_body req.body.read)\n (sub.callback.call op, payload)\n rescue Exception => e\n callstack = \"#{e.backtrace.join \"\\n \"}\"\n puts \" ## Subscription::callback - #{e}\\n -> #{callstack}\"\n end \n\n # HTTP OK keeps the subscription alive, even in case of handler errors\n [200, {\"Content-Type\"=>\"text/plain\"}, [\"keep going dude!\"]]\n end",
"def set_request; end",
"def run(&callback)\n @serializer.run do |msg|\n debug(\"received #{msg.inspect}\")\n kind, *payload = msg\n\n case kind\n when 0\n handle_request(payload, callback)\n when 1\n handle_response(payload)\n when 2\n handle_notification(payload, callback)\n end\n end\n rescue => e\n fatal(\"got unexpected error #{e.inspect}\")\n debug(e.backtrace.join(\"\\n\"))\n end",
"def zz_request(*_)\n # Do nothing\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 callback\n @callback ||= ERB::Util.url_encode(\"#{request.url}&callback\")\n end",
"def handler; end",
"def handler; end",
"def callback\n return nil if !subscribed?\n\n @default_consumer.callback\n end",
"def request(endpoint, request, &block); end",
"def callback_get\n render nothing: true\n end",
"def request=(_arg0); end",
"def request=(_arg0); end",
"def request=(_arg0); end",
"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 call(request); end",
"def callback_response(callback,response)\n if callback.nil?\n response\n else\n callback + \"(\" + response + \")\"\n end\n end",
"def request(*)\n raise 'HttpApiBuilder::BaseClient#request must be implemented, see documentation'\n end",
"def do_request(request, want_reply, data); end",
"def call_handler(h)\n\t\t@handler[h].call if @handler[h]\n\tend",
"def request(*args, &block); end",
"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 receive(request); end",
"def request_result\n \n end",
"def viewquery_callback(handle, type, row)\n row_data = Ext::RESPVIEWQUERY.new row\n view = @requests[row_data[:cookie].address]\n\n if row_data[:rc] == :success\n if (row_data[:rflags] & Ext::RESPFLAGS[:resp_f_final]) > 0\n # We can assume this is JSON\n view.received_final(JSON.parse(row_data[:value].read_string(row_data[:nvalue]), DECODE_OPTIONS))\n else\n view.received(row_data)\n end\n else\n error_klass = Error.lookup(row_data[:rc])\n if error_klass == Error::HttpError\n http_resp = row_data[:htresp]\n view.error error_klass.new(body_text(http_resp))\n else\n view.error error_klass.new\n end\n end\n end",
"def callback\n connector_response_url(callback_options)\n end",
"def http_call(payload); end",
"def recv_callback\n @recv_callback ||= Proc.new {|message|}\n end",
"def syncCallback(response)\n response = $parser.parse_payload(response)\n if response != nil\n puts response\n else\n errors = $parser.get_last_errors()\n errors.each { |error|\n eCode = error[\"error\"]\n if eCode == ErrorCode::QUEUED\n jobID = error[\"jobID\"]\n sleep(2)\n $client.get_job_status(jobID, method(:syncCallback))\n elsif eCode == ErrorCode::IN_PROGRESS\n jobID = error[\"jobID\"]\n sleep(5)\n $client.get_job_status(jobID, method(:syncCallback))\n else\n puts eCode\n puts error[\"detail\"]\n puts error[\"reason\"]\n end\n }\n end\nend",
"def handle_response(response); end",
"def handle_response(response); end",
"def on_contact_request(&handler)\n @on_contact_request = handler\n end",
"def send_request(req); end",
"def initialize(response)\n super\n # XXX assign to :signal\n end",
"def response_from_service\n\n end",
"def service_request(service); end",
"def poll_req\n super # placeholder so that I can add some doc\n end",
"def callback\n result, message = handle_callback_params!\n status = result ? :ok : :bad_request\n render plain: message, status: status\n end",
"def s_request(index, offset, length, &cb)\n $log.debug \"#{self} -> request (#{index}, #{offset}, #{length})\"\n @req_cb[[index, offset, length]] = Proc.new {|*args| cb.call(*args)}\n self.send_msg(6, [index, offset, length].pack(\"L>L>L>\"))\n end",
"def response_proc(code=nil,&blk)\n Proc.new do | message |\n if code.nil? or code.empty? or code == message\n @logger.debug \"Calling proc. code: #{code} message: #{message}\"\n blk.call(message)\n end\n end\n end"
] |
[
"0.6535027",
"0.64699954",
"0.6435503",
"0.6331204",
"0.6268352",
"0.62193644",
"0.6136512",
"0.5965365",
"0.59640306",
"0.59458804",
"0.591139",
"0.5845023",
"0.58422947",
"0.5837795",
"0.5830636",
"0.582171",
"0.5798763",
"0.5781419",
"0.5761212",
"0.5753158",
"0.5753158",
"0.5753158",
"0.5753158",
"0.5744467",
"0.57441074",
"0.5737571",
"0.5737571",
"0.5734056",
"0.57314485",
"0.572478",
"0.572383",
"0.572383",
"0.5712453",
"0.5686916",
"0.56558824",
"0.5650687",
"0.5620457",
"0.5606764",
"0.56017715",
"0.5597492",
"0.55973315",
"0.5576331",
"0.55547494",
"0.55535233",
"0.55435336",
"0.5538341",
"0.5529437",
"0.5528476",
"0.5528476",
"0.5525362",
"0.5519982",
"0.5514678",
"0.5496283",
"0.5493795",
"0.54937243",
"0.54937243",
"0.54937243",
"0.54937243",
"0.54937243",
"0.54937243",
"0.54937243",
"0.54937243",
"0.54937243",
"0.54937243",
"0.54937243",
"0.5473419",
"0.54698515",
"0.54698515",
"0.54531753",
"0.5447923",
"0.54469824",
"0.54467803",
"0.54467803",
"0.54467803",
"0.54438305",
"0.54352653",
"0.54258525",
"0.54181474",
"0.5409986",
"0.53906626",
"0.53862417",
"0.53755414",
"0.5375408",
"0.53459024",
"0.5343474",
"0.5334175",
"0.5331478",
"0.5330864",
"0.5329663",
"0.5321145",
"0.5321145",
"0.5319571",
"0.53109443",
"0.5308544",
"0.52952236",
"0.52933836",
"0.5288717",
"0.5288434",
"0.5283746",
"0.52832174"
] |
0.7942339
|
0
|
Placeholder for feedback received. You must override hsdq_request in your HsdqXxx class
|
def hsdq_feedback(message, context); placeholder; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def hsdq_callback(message, context); placeholder; end",
"def hsdq_send_feedback(message)\n hsdq_send(message.merge(type: :feedback))\n end",
"def hsdq_ack(message, context); placeholder; end",
"def hsdq_error(message, context); placeholder; end",
"def hsdq_send_request(message)\n hsdq_send(message.merge(type: :request))\n end",
"def feedback\n end",
"def ask\n @poll_centre = PollCentre.find(@question.poll_centre_id)\n if @poll_centre.has_current_question?\n #then error\n output_error = {\"error\" => \"There is a question currently in progress. Please wait for it to finish\"}\n respond_to do |format|\n format.json { render json: output_error.to_json, status: :bad_request }\n end\n elsif @question.is_asked?\n output_error = {\"error\" => \"Question already asked\"}\n respond_to do |format|\n format.json { render json: output_error.to_json, status: :bad_request }\n end\n else\n @question.started = true\n if @question.save\n channel_name = @poll_centre.title\n Pusher[\"#{channel_name}\"].trigger('question-start', {\n question_text: @question.text,\n option_a: @question.option_a,\n option_b: @question.option_b,\n option_c: @question.option_c,\n option_d: @question.option_d,\n question_id: @question.id\n })\n respond_to do |format|\n format.json { render json: @question, status: :ok }\n end\n else\n output_error = {\"error\" => \"Couldn't ask question. Please try again.\"}\n respond_to do |format|\n format.json { render json: output_error.to_json, status: :bad_request }\n end\n end\n end\n end",
"def started_request_message(*args)\n \"\"\n end",
"def poll_req\n super # placeholder so that I can add some doc\n end",
"def skier_quest; end",
"def send_feedback_to_slack\n send_request_to_slack(make_positive_response)\n end",
"def process_help\n send_data \"250 Ok, but unimplemented\\r\\n\"\n end",
"def started_request_message(request); end",
"def ask\n if @help_request.valid?\n MyousicaMailer.deliver_help_request(@help_request)\n flash[:notice] = \"Thanks for contacting us! Your question has been sent to our help desk, you'll receive a reply in few hours.\"\n else\n flash[:error] = \"Your help request could not be sent. Please correct the errors and try again!\"\n end \n\n params[:return_to] ? redirect_to(:action => 'show', :id => params[:return_to]) : redirect_to(:action => 'index')\n end",
"def new_feedback\n\n end",
"def request_data; end",
"def feedback_request_params\n params.require(:feedback_request).permit(:user_id, :sender_id, :prompt, :b_read)\n end",
"def ask_for_feedback\n feedback = show do\n title \"We want your feedback\"\n \n note \"Notice anything weird with this protocol? Tell us below!\"\n \n get \"text\", var: \"feedback_user\", label: \"Enter your feedback here\", default: \"\"\n end\n feedback[:feedback_user] # return\n end",
"def prapor_quest; end",
"def get_protocol_feedback\n \n # Gets feedback from the user\n if debug\n feedback = \"testing for job id\"\n else\n feedback = ask_for_feedback\n end\n \n if(!feedback.blank?)\n associate_feedback feedback\n end\n \n if debug\n print_association\n end\n \n end",
"def send_request; end",
"def handle_request\n payload = @req.POST[\"payload\"]\n\n return rude_comment if payload.nil?\n\n puts payload unless $DEPLOYED # remove me!\n\n payload = JSON.parse(payload)\n# render_payload_to_hipchat(payload)\n @res.write THANK_YOU_COMMENT\n end",
"def on_request( channel, request, want_reply, data )\n end",
"def pending_feedback\n self.sub_requests.waiting_for_feedback.present?\n end",
"def reply\n end",
"def help_call_answer_params\n if params[:help_call_id]\n params.permit(:help_call_id, :device_id, :when, :lng, :lat)\n else\n params.require(:help_call_answer).permit(:device_id, :help_call_id, :when, :lng, :lat)\n end\n end",
"def generate_request\r\n end",
"def action_not_recognize(input)\n response = WxTextResponse.new\n set_common_response response\n response.Content = WxReplyMsg.get_msg_by_key 'help'\n response\n end",
"def show_message_request(text, type, actions, &block); end",
"def feedback_params\n params.require(:feedback).permit(:yes, :message)\n end",
"def zz_request(*_)\n # Do nothing\n end",
"def action_card_bd(input)\n utoken = params[:xml][:FromUserName]\n card_info = Card.where(:utoken=>utoken).order('updated_at desc').first\n return build_response_text_temp {|msg|\n msg.Content=t(:notbindinghelp)\n } if card_info.nil?\n card_info[:isbinded]=true\n card_info.save\n #persist user request\n log_use_request {|request|\n request.lastaction = RequestAction::ACTION_JF_BIND\n }\n return build_response_text_temp {|msg|\n msg.Content = t(:bindingsuccess)\n }\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 receive_request(request)\n request.reply(\"You should override #{self.class.to_s}#receive_request.\")\n end",
"def send_pending; end",
"def initialize(sender,question_with_parameters)\n @sender = sender\n process_question(question_with_parameters)\n end",
"def get_req_short_desc\n raise NotImplementedError\n end",
"def get_req_short_desc\n raise NotImplementedError\n end",
"def ask\n case attributes['ask']\n when 'subscribe' then :subscribe\n else nil\n end\n end",
"def request\n raise 'need to be implemented'\n end",
"def incomplete_request_message\n return \"Incomplete request\"\n end",
"def enq\n end",
"def enq\n end",
"def request_result\n \n end",
"def ask\n @question = params[:question]\n end",
"def feedback\n @feedback ||= APND::Settings::Feedback.new\n end",
"def mgs_hops_request_sent_message\n $tracer.trace(__method__)\n return ToolTag.new(div.id(\"hops_request_sent\").h4, __method__, self)\n\tend",
"def feedback_params\n #params.fetch(:feedback, {})\n params.require(:feedback).permit(:tenant_id, :date, :username, :age_type, :rating, :tenant_id, :favourite_dish, :least_dish, :comment, :reason)\n end",
"def set_request; end",
"def mechanic_quest; end",
"def respond_with_question(params, category = nil, value = nil, random_question = nil)\n channel_id = params[:channel_id]\n key = \"current_question:#{channel_id}\"\n catkey = \"current_categories:#{channel_id}\" # We'll need to match the categories\n question = \"\"\n unless $redis.exists(\"shush:question:#{channel_id}\")\n if rand.nil?\n if value.nil?\n return \"Typically, you would want to select a question on the board, not just a category.\"\n elsif category.nil?\n return \"And what question in what category would you like me to ask?\"\n else\n cat_response = compare_category(catkey, category)\n return \"That category isn't on the board.\" if cat_response == false\n val_response = compare_value(catkey, category, value)\n return \"That question is no longer on the board.\" if val_response == false\n end\n end\n unless $redis.exists(\"triggered_dd:#{channel_id}\")\n rand > ENV[\"DD_CHANCE\"].to_i ? dd = false : dd = true\n end\n question = handle_question_retrieval(channel_id, key, catkey, category, value, random_question, dd)\n end\n question\nend",
"def request\n nil\n end",
"def make_enq_data\r\n tmp = \"Enquiry:<BR>\"\r\n tmp += \"Client Name: \" + @e.client_name + \"<BR>\" if @e.client_name\r\n tmp += \"Client Email: \" + @e.client_email + \"<BR>\" if @e.client_email\r\n tmp += \"Client Phone: \" + @e.client_phone + \"<BR>\" if @e.client_phone\r\n tmp += \"Agent: \" + @e.agent + \"<BR>\" if @e.agent\r\n tmp += \"Aref: \" + @e.aref + \"<BR>\" if @e.aref\r\n tmp += \"Price: \" + @e.price + \"<BR>\" if @e.price\r\n tmp += \"Region: \" + @e.region + \"<BR>\" if @e.region\r\n tmp += \"Department: \" + @e.department + \"<BR>\" if @e.department\r\n tmp += \"Information Requested: \" + @e.info_req + \"<BR>\" if @e.info_req\r\n tmp += \"Viewing Info: \" + @e.viewing_info + \"<BR>\" if @e.viewing_info\r\n \r\n tmp\r\n end",
"def communicate_measure_result(_ = nil, _ = nil)\r\n end",
"def query_ask\n # NOTE: This trailing space at the end of the String obliquely instructs\n # Highline to keep the prompt on the same line as the question. If the\n # String did not end with a space or tab, Highline would move the input\n # prompt to the next line (which, for our purposes, looks confusing)\n value = ask( \"<%= color('#{@key}', WHITE, BOLD) %>: \",\n highline_question_type ) do |q|\n q.default = default_value unless default_value.to_s.empty?\n\n # validate input via the validate() method\n q.validate = lambda{ |x| validate( x )}\n\n # if the answer is not valid, construct a reply:\n q.responses[:not_valid] = \"<%= color( %q{Invalid answer!}, RED ) %>\\n\"\n q.responses[:not_valid] += \"<%= color( %q{#{ (not_valid_message || description) }}, YELLOW) %>\\n\"\n q.responses[:not_valid] += \"#{q.question} |#{q.default}|\"\n\n query_extras q\n end\n value\n end",
"def pending_response_requests; end",
"def feedback_params\n params.require(:feedback).permit(:title, :content, :comment, :responded)\n end",
"def feedback(app_id)\n raise ArgumentError, \"app_id must be provided\" unless app_id\n @xmlrpc.call_to_ruby('feedback', app_id)\n rescue Rapuncel::Response::Exception => e\n raise Error.new e.message\n 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 do_request(request, want_reply, data); end",
"def feedback_response_params\n params.require(:feedback_response).permit(\n :meeting_id, :one_thing_to_improve_on, :one_thing_done_well, :rating,\n :anything_else_to_share\n )\n end",
"def help_call_params\n help_call = params[:help_call]\n if help_call && !help_call.empty?\n params.require(:help_call).permit(:device_id, :when, :lng, :lat)\n else\n params.permit(:device_id, :when, :lng, :lat)\n end\n end",
"def xml_http_request?; end",
"def feedback_params\n params.fetch(:feedback, {})\n end",
"def request\n @req\n end",
"def feedback_params\n params.require(:feedback).permit(:quantiy_service, :comment, :traveller_id)\n end",
"def request_help\n @problem = Problem.find params[:problem_id], :include => :hints, :order => \"hints.position\"\n @hints = @problem.hints\n if @problem.has_scaffolds?\n ActiveRecord::Base.transaction do\n changed_and_notify_observers(:answer => { :incorrect => nil, :problem => @problem})\n flash[:message] = \"Let's move on and figure out this problem\"\n flash[:message_type] = :neutral\n help_student_out\n end\n else\n logger.info \"hint_count = #{session[:hint_count]}; total hints count = #{@hints.size}\"\n if (session[:hint_count] + 1) < @hints.size\n session[:hint_count] += 1\n logger.info \"hint_count incremeneted: #{session[:hint_count]}\"\n @hint = @hints[session[:hint_count]]\n ActiveRecord::Base.transaction do\n changed_and_notify_observers(:hint => @hint)\n end\n render_tutor :file => \"add_hint\"\n else\n # TODO: make this message to be a hint_notice_message\n @message = \"Sorry, the number of requested hints has exceeded the number of actual hints! Please let us know about this by commenting.\"\n render_tutor :file => \"notice_message\"\n end\n end\n end",
"def q_params\n params.fetch(:q, {}).permit(:name, :qn_id, :correct_flg)\n end",
"def jaeger_quest; end",
"def initialize(json_request)\n super\n @type = 'SESSION_ENDED_REQUEST'\n @reason = json_request['request']['reason']\n end",
"def pending_requests; end",
"def pending_requests; end",
"def pending_requests; end",
"def ask_question\n @game_id = params[:game_id]\n @current_game = Game.find(@game_id)\n @bonus = params[:bonus]\n unless @current_game.players_turn?(current_user.id)\n back_to_index and return\n end\n\n if @current_game.normal_round?\n subject_title = params[:subject]\n @subject = subject_title\n @questions = Question.questions_by_user_experience(current_user.experience_level, @subject)\n @question = @questions.sample\n elsif @current_game.challenge_round?\n @challenge = Challenge::get_ongoing_challenge_by_game(@current_game.id)\n if @challenge\n @question = Question.find(@challenge.get_question_id_by_counter)\n @subject = @question.subject_title\n elsif @challenge.nil?\n wager = params[:wager]\n prize = params[:prize]\n if wager && prize\n @challenge = Challenge.create_challenge(@current_game.id, current_user.id, @current_game.opponent_id(current_user.id), wager, prize)\n else\n redirect_to game_challenge_path(:game_id => @current_game.id)\n end\n end\n end\n if @question\n respond_to do |format|\n format.html\n format.xml { render :xml => @question }\n end\n end\n end",
"def feedback\n client.feedback app_id\n end",
"def send_request para\n raise NotImplementedError.new(\"method not overriden\")\n end",
"def ask_q\n @current_ans = generate_q\n end",
"def new_data_request_response(user_id, project_id)\n begin\n @project = Project.find(project_id)\n user = User.find(user_id)\n from DEFAULT_FROM\n reply_to DEFAULT_REPLY_TO\n subject \"SRDR - Update Regarding your Request for Data\"\n recipients user.email \n sent_on Time.now \n rescue Exception => e\n puts \"ERROR SENDING RESPONSE NOTICE: #{e.message}\\n#{e.backtrace}\\n\\n\"\n end\n end"
] |
[
"0.67383987",
"0.6363598",
"0.6160989",
"0.59689695",
"0.595466",
"0.5917709",
"0.5901353",
"0.58158934",
"0.5809793",
"0.57807577",
"0.57217646",
"0.5672317",
"0.56591624",
"0.56588054",
"0.565498",
"0.56109685",
"0.55991304",
"0.5583421",
"0.5541239",
"0.549523",
"0.54318285",
"0.5430144",
"0.5396045",
"0.53858256",
"0.5379341",
"0.5370012",
"0.5365588",
"0.5347102",
"0.53240234",
"0.53094697",
"0.53061634",
"0.5298474",
"0.5298432",
"0.5298432",
"0.5298432",
"0.5298432",
"0.5298432",
"0.5298432",
"0.5298432",
"0.5298432",
"0.5298432",
"0.5298432",
"0.5298432",
"0.5290583",
"0.5267869",
"0.5258543",
"0.5253823",
"0.5253823",
"0.5235361",
"0.5234326",
"0.5213392",
"0.52080727",
"0.52080727",
"0.5207799",
"0.52010685",
"0.51839554",
"0.5175204",
"0.5167763",
"0.516238",
"0.51573724",
"0.51540685",
"0.51532817",
"0.5151922",
"0.51416266",
"0.51253325",
"0.5124646",
"0.5123932",
"0.5123465",
"0.51192105",
"0.51192105",
"0.51192105",
"0.51192105",
"0.51192105",
"0.51192105",
"0.51192105",
"0.51192105",
"0.51192105",
"0.51192105",
"0.51192105",
"0.51192105",
"0.51192105",
"0.5118778",
"0.510481",
"0.510039",
"0.5100316",
"0.50994056",
"0.509326",
"0.50932175",
"0.5089581",
"0.5088892",
"0.5085767",
"0.5084222",
"0.5084172",
"0.5084172",
"0.5084172",
"0.50840884",
"0.5074469",
"0.5063149",
"0.5059743",
"0.5059287"
] |
0.8023943
|
0
|
Placeholder for error received. You must override hsdq_request in your HsdqXxx class
|
def hsdq_error(message, context); placeholder; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def error\n @error_response\n end",
"def connection_error(error, req, text = T.unsafe(nil)); end",
"def request_error( err_str )\n case err_str\n when \"MAINTENANCE COMPANY NOT SPECIFIED\"\n return \"יש לבחור חברת אחזקה\";\n else\n return translate( \"QUERY_ERROR_#{err_str}\" );\n end\n end",
"def check_error(response)\n raise NotImplementedError\n end",
"def api_error; end",
"def hsdq_callback(message, context); placeholder; end",
"def parameters_missing(error)\n response_error(code: 400, message: error.message)\n end",
"def client_error?; end",
"def unknown_error(error, req = T.unsafe(nil), text = T.unsafe(nil)); end",
"def error; end",
"def error; end",
"def error; end",
"def error; end",
"def error; end",
"def error; end",
"def error; end",
"def default_error req, endpoint, error\n msg = \"= #{error.class}:\\n<b>#{error.message}</b>\\n\\n\"\n msg << error.backtrace\n\n response HTTP_INTERNAL_ERROR, api_html(msg)\n end",
"def server_error?; end",
"def parse_error(error, req); end",
"def error(rcode:, question:nil)\n question = question || @questions[0]\n\n return Packet.new(\n trn_id: @trn_id,\n qr: QR_RESPONSE,\n opcode: OPCODE_QUERY,\n flags: FLAG_RD | FLAG_RA,\n rcode: rcode,\n questions: [question],\n answers: [],\n )\n end",
"def error\n end",
"def response_error(response)\n trace = \"Response \\n\\nbody : #{response.body}\\n\\ncode: #{response.code}\\n\\nmessage: #{response.message}\"\n case @base_url\n when BASE_URLS[:quote]\n raise InterfaceError, \"Error :: Could not get stock data \\n\\n#{trace}\"\n when BASE_URLS[:history]\n raise InterfaceError, \"Error :: Could not get historical data \\n\\n#{trace}\"\n when BASE_URLS[:scrip_symbol]\n raise InterfaceError, \"Error :: Could not get stock symbol \\n\\n#{trace}\"\n else\n raise InterfaceError, \"Error connecting to #{@base_url} \\n\\n#{trace}\"\n end\n end",
"def request_failure(packet); end",
"def error_message; end",
"def initialize(name, query, response)\n @query_name = name\n @query_parameters = query\n @db_response = response\n super(\"Query #{@query_name} failed with the following response: #{response.inspect}\")\n # set the backtrace to everything that's going on except this initialize method\n set_backtrace(caller[1...caller.length])\n end",
"def error(description, result)\n raise \"Implement this in a sub-class\"\n end",
"def hsdq_send_request(message)\n hsdq_send(message.merge(type: :request))\n end",
"def handle_request_error(exception)\n end",
"def hsdq_feedback(message, context); placeholder; end",
"def server_error\n\n end",
"def error\n return nil if reply_code == \"0000\" \n return \"#{reply_text}\"\n end",
"def invalid_request(obj, code, message=nil)\n $stderr.puts \"error #{code}: #{message}\"\n end",
"def default_validation_error req, endpoint, error\n response HTTP_INVALID, api_html(error.to_markup)\n end",
"def error\n end",
"def hsdq_ack(message, context); placeholder; end",
"def original_error; end",
"def original_error; end",
"def error(response)\n throw response.http_error? ? response.http_error : response.soap_fault\n end",
"def error!(error_hash = {}, status_code = 500)\n raise Errors::ApiError.new(error_hash, status_code)\n end",
"def gateway_error\n message\n end",
"def error=(_arg0); end",
"def error=(_arg0); end",
"def error=(_arg0); end",
"def error_reason\n @request['error']['reason']\n end",
"def error(_message)\n raise NotImplementedError.new\n end",
"def exc_msg_and_response(exc, response = T.unsafe(nil)); end",
"def error\n nil\n end",
"def error\n nil\n end",
"def error\n return unless id.nil?\n @error ||= @response['message']\n end",
"def add_request_error(error = {})\n @errors ||= []\n @errors << error\n end",
"def data_uri_error_messsage(uri, error)\n message = shrine_class.opts[:data_uri][:error_message]\n message = message.call(uri) if message.respond_to?(:call)\n message || error.message\n end",
"def test_service_error_response\n twerr = Twirp::Error.invalid_argument('foo')\n resp = Twirp::Service.error_response(twerr)\n assert_equal 400, resp[0]\n assert_equal 'application/json', resp[1]['Content-Type']\n assert_equal '{\"code\":\"invalid_argument\",\"msg\":\"foo\"}', resp[2][0]\n end",
"def server_errors; end",
"def bad_request_status\n status_message(400)\n end",
"def error?; end",
"def error?; end",
"def error?; end",
"def debug_error(error, req = T.unsafe(nil), text = T.unsafe(nil)); end",
"def error\r\n\t\t\t`#{BITS::BITSADMIN} /geterror {#{@id}}`\r\n\t\tend",
"def initialize(httpMsg, responseObj = nil)\n\n @response = responseObj\n super(\"An error occurred executing the HTTP request: #{httpMsg}\")\n\n end",
"def error msg\n @error = msg\n end",
"def error!\n throw NotImplementedError\n end",
"def error\n @error ||= @response['reject_reason']\n end",
"def validate_request_and_error(request, response_error, resource_prefix)\n request_id = validate_request(request, resource_prefix)\n validate_error(response_error, request_id)\nend",
"def client_error_status_code\n _undefined\n end",
"def error(x, status:200, type:\"request\", title:\"An error occurred\", message:\"\", args: [])\n x.res.status = status\n if App[:app_error][type.to_sym]\n App[:app_error][type.to_sym][:get][x, title, message, *args]\n else\n x << \"ERROR: #{title} - #{message}\"\n end\n end",
"def error_opt(request)\n {\n http_status: data[:status],\n http_code: status_code,\n http_response: content,\n http_message: data[:message],\n http_error_code: data[:error_code],\n http_request_params: request.body,\n http_method: request.method\n }\n end",
"def wrap_reply(h={})\n\n ms = super\n\n ioe = @node['in_on_error']\n ms[0]['from_on_error'] = ioe if ioe\n\n ms\n end",
"def handle_bad_request\n make_response(400, {message: 'Bad request (invalid input)'})\nend",
"def gateway_error_code\n nil\n end",
"def test_return_error_is_default\n _response, error = resolver_returning_error.query_raw(Dnsruby::Message.new)\n assert error.is_a?(CustomError)\n end",
"def handle(_request)\n fail NotImplementedError\n end",
"def _error(msg = nil)\n @api_error[:msg] = msg if msg\n logger.warn(@api_error[:loc]) { @api_error[:msg].message }\n end",
"def error\n \"#{self.fault_string} (#{self.fault_code})\" unless self.fault_code.blank?\n end",
"def bad_request(error)\n json_response({ message: error.message }, :bad_request)\n end",
"def error\n params[\"ErrDesc\"]\n end",
"def respond_bad_request; make_response(nil, false, 400, \"Bad Request\") end",
"def error(exception) nil ; end",
"def test_protocol_error\n @message.set_arg(OPENID_NS, 'expires_in', 'goats')\n assert_log_matches('Protocol error processing') {\n assert_equal(nil, make_request)\n }\n end",
"def handle_bad_request\n make_response(400, 'Bad request (invalid input)')\nend",
"def handle_bad_request\n make_response(400, 'Bad request (invalid input)')\nend",
"def initialize(error_reply)\n\t\t\tsuper(error_reply.value)\n\t\t\t@status_code = error_reply.status_code\n\t\tend",
"def error_string\n # This method should be overridden\n end",
"def postQueueError( queue_id, error)\n params = Hash.new\n params['queue_id'] = queue_id\n params['error'] = error\n return doCurl(\"post\",\"/queue/error\",params)\n end",
"def api_error\n return nil if @api_response.nil?\n\n m = \"#{@api_method.to_s.upcase} \"\n m << \"#{@api_url} : \"\n m << \"#{@api_status} - \"\n m << \"#{@api_message} (request Id: #{@api_request_id})\"\n m\n end",
"def error\r\n @error\r\n end",
"def extract_error_details response\n raise NotImplementedError\n end",
"def report_error(message, hsh = {})\n hsh[:message] = message\n @report.error(hsh)\n end",
"def initialize(error_type, error_code, error_message, display_message, request_id)\n @error_type = error_type\n @error_code = error_code\n @error_message = error_message\n @display_message = display_message\n @request_id = request_id\n\n super \"\\n\"\\\n \"Error Type : #{@error_type}\\n\"\\\n \"Error Code : #{@error_code}\\n\"\\\n \"Error Message : #{@error_message}\\n\"\\\n \"Display Message : #{@display_message}\\n\"\\\n \"Request ID : #{@request_id}\\n\"\n end",
"def client_error(e, client); end",
"def _error(message,code) \n status code\n response.headers['Content-Type'] = 'application/json'\n body({:error=>{:message=>message}}.to_json)\n end",
"def populate_error resp\n code = resp.http_response.status\n if EMPTY_BODY_ERRORS.include?(code) and empty_response_body?(resp.http_response.body)\n error_class = EMPTY_BODY_ERRORS[code]\n resp.error = error_class.new(resp.http_request, resp.http_response)\n else\n super\n end\n end",
"def error_hander\n @error_block\n end",
"def serialize_error\n case error\n when Common::Exceptions::BaseError\n base_error\n when Common::Client::Errors::ClientError\n client_error\n when EMISRedis::VeteranStatus::NotAuthorized\n emis_error(:not_authorized)\n when EMISRedis::VeteranStatus::RecordNotFound\n emis_error(:not_found)\n when MPI::Errors::RecordNotFound\n mpi_error(404)\n when MPI::Errors::FailedRequestError\n mpi_error(503)\n when MPI::Errors::DuplicateRecords\n mpi_error(404)\n else\n standard_error\n end\n end",
"def error_format(format)\n @request.env[\"HTTP_X_ERROR_FORMAT\"] = format\n end",
"def make_error(type, response, url: 'http://example.com', request_body: '{\"msg\": \"The request body\"}')\n error = nil\n\n begin\n begin\n raise Faraday::ClientError, \"The original error\"\n rescue Faraday::ClientError => e\n request = RestfulResource::Request.new(:get, url, body: request_body)\n raise type.new(request, response)\n end\n rescue Exception => e\n error = e\n end\n\n error\n end",
"def error_message\n @response.reason_phrase\n end",
"def respond_with_error(message: \"Not specified\", error_code: \"not_specified\", status: 400)\n render partial: \"api/error\", locals: { message: message, error_code: error_code }, status: status\n return false\n end",
"def error(event)\n Firehose.logger.error \"WS connection `#{@req.path}` error. Message: `#{event.message.inspect}`\"\n end",
"def test_handles_failure_to_create_request_object\n if defined?(ActionDispatch::Request)\n ActionDispatch::Request.stubs(:new).raises('bad news')\n\n assert_raises RuntimeError do\n get '/foo/bar?q=12'\n end\n\n assert_equal('unhandled error', last_error.message)\n assert_equal('/foo/bar', last_error.params[:request_uri])\n end\n end"
] |
[
"0.6218071",
"0.62142265",
"0.61370933",
"0.61193824",
"0.6116165",
"0.6082611",
"0.60430026",
"0.6030907",
"0.60243493",
"0.60064536",
"0.60064536",
"0.60064536",
"0.60064536",
"0.60064536",
"0.60064536",
"0.60064536",
"0.59876335",
"0.59619504",
"0.5928889",
"0.59055",
"0.5869164",
"0.58451414",
"0.58420205",
"0.5837602",
"0.5833395",
"0.5826812",
"0.5820443",
"0.5809098",
"0.58048856",
"0.58013976",
"0.5783812",
"0.57761073",
"0.5757682",
"0.5744624",
"0.57375705",
"0.5725151",
"0.5725151",
"0.5723645",
"0.5711445",
"0.5703982",
"0.5701303",
"0.5701303",
"0.5701303",
"0.56959325",
"0.5692481",
"0.5672463",
"0.5670643",
"0.56568944",
"0.565385",
"0.56220245",
"0.5575269",
"0.5568801",
"0.556605",
"0.55643135",
"0.55578655",
"0.55578655",
"0.55578655",
"0.55545694",
"0.5529984",
"0.55247426",
"0.5522638",
"0.5522425",
"0.5515017",
"0.5512065",
"0.5503441",
"0.5502701",
"0.550134",
"0.55003357",
"0.5489571",
"0.54839283",
"0.54750925",
"0.5469284",
"0.5464971",
"0.54515",
"0.5451454",
"0.5441358",
"0.5440881",
"0.54384065",
"0.54360485",
"0.5432452",
"0.5432452",
"0.5422119",
"0.54197097",
"0.540076",
"0.53953046",
"0.5392759",
"0.53830975",
"0.53729707",
"0.53635",
"0.5358817",
"0.5354795",
"0.53513706",
"0.53499365",
"0.5344461",
"0.5341979",
"0.5341816",
"0.5337214",
"0.53358734",
"0.53357583",
"0.5333114"
] |
0.8026948
|
0
|
Send the ACk and start the processing for the message just received. The processing will be either executed synchronously or a new thread will be started based on the configuration.
|
def hsdq_ignit(raw_spark, options)
spark = h_spark raw_spark
send_ack spark
if valid_spark? spark, options
if hsdq_opts[:threaded]
# :nocov:
hsdq_start_thread -> { sparkle spark, options }
# :nocov:
else
sparkle spark, options
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def start\r\n\t\t\tswdebug 'Started new thread for message processing.'\r\n\t\t\t# Start a new child Thread\r\n\t\t\t@thread = Thread.new {\r\n\t\t\t\tloop do\r\n\t\t\t\t\titems = process\r\n\t\t\t\t\tif items == 0\r\n\t\t\t\t\t\tsleep(0.1)\r\n\t\t\t\t\telse\r\n\t\t\t\t\t\tswdebug \"Processing #{items} items\"\r\n\t\t\t\t\tend\r\n\t\t\t\tend\r\n\t\t\t}\t\t\t\t\r\n\t\tend",
"def start\n validate!\n start_message\n build_threads\n start_threads\n end",
"def start\n channel.prefetch(10)\n queue.subscribe(manual_ack: true, exclusive: false) do |delivery_info, metadata, payload|\n begin\n body = JSON.parse(payload).with_indifferent_access\n status = run(body)\n rescue => e\n status = :error\n end\n\n if status == :ok\n channel.ack(delivery_info.delivery_tag)\n elsif status == :retry\n channel.reject(delivery_info.delivery_tag, true)\n else # :error, nil etc\n channel.reject(delivery_info.delivery_tag, false)\n end\n end\n\n wait_for_threads\n end",
"def start\n @session = Connection.create_consumer_session\n @consumer = @session.consumer(@real_destination_options)\n @session.start\n\n ModernTimes.logger.debug \"#{self}: Starting receive loop\"\n @status = nil\n while !@stopped && msg = @consumer.receive\n @time_track.perform do\n @message_mutex.synchronize do\n on_message(msg)\n msg.acknowledge\n end\n end\n ModernTimes.logger.info {\"#{self}::on_message (#{('%.1f' % (@time_track.last_time*1000.0))}ms)\"} if ModernTimes::JMS::Connection.log_times?\n ModernTimes.logger.flush if ModernTimes.logger.respond_to?(:flush)\n end\n @status = 'Exited'\n ModernTimes.logger.info \"#{self}: Exiting\"\n rescue Exception => e\n @status = \"Exited with exception #{e.message}\"\n ModernTimes.logger.error \"#{self}: Exception, thread terminating: #{e.message}\\n\\t#{e.backtrace.join(\"\\n\\t\")}\"\n ensure\n ModernTimes.logger.flush if ModernTimes.logger.respond_to?(:flush)\n end",
"def start!\n @_cancelled = false\n channel.prefetch(1)\n queue.subscribe(block: true, manual_ack: manual_ack?, on_cancellation: cancellation_handler) do |delivery_info, properties, body|\n begin\n logger.info(self.class.name) { \"#{self} received task: #{body}\" }\n self.perform_result = perform(delivery_info: delivery_info, properties: properties, body: body)\n done!(delivery_info)\n logger.info(self.class.name) { \"#{self} performed task!\" }\n rescue Exception => e\n logger.error \"Error when #{self} performing task: #{e.message}\"\n cancellation_handler.call\n fail(e)\n end\n end\n cancellation_handler.call\n perform_result\n end",
"def start\n Thread.new do\n loop do\n @connection.wait_for_notify do |channel|\n @actions[channel].call\n end\n end\n end\n end",
"def start\n # Synchronous (mutual exclusion) message processing is handled by a\n # producer-consumer approach. The socket pushes messages onto this queue,\n # which are processed by a consumer thread one at a time.\n @messages = Queue.new\n @message_consumer = Thread.new do\n loop do\n meths = @messages.pop\n begin\n meths.each { |meth, args| broadcast_sync meth, *args }\n rescue\n options[:logger].error $!\n end\n end\n end\n \n @socket = connect\n username = @options[:user]\n username ||= @nick\n realname = @options[:name]\n realname ||= @nick\n \n pass @options[:server_password] if @options[:server_password]\n user username, @nick, @nick, realname\n nick @nick\n \n while line = @socket.gets\n meths = receive line # parse the line and get a list of methods to call\n @messages.push meths # push the methods on the queue; the consumer thread will execute all the synchronous methods\n # then execute all the other methods in their own thread\n meths.each { |meth, args| broadcast meth, *args }\n end\n end",
"def start\n # Don't send asynchronously\n if Deimos.config.producers.backend == :kafka_async\n Deimos.config.producers.backend = :kafka\n end\n Deimos.config.logger.info('Starting...')\n @signal_to_stop = false\n retrieve_poll_info\n loop do\n if @signal_to_stop\n Deimos.config.logger.info('Shutting down')\n break\n end\n process_updates\n sleep 0.1\n end\n end",
"def processStanza\n @processing = true\n while @stanzaQueue.count > 0\n stanza = @stanzaQueue.shift\n Thread.new{\n jid = stanza.from.strip\n command = stanza.body\n\n response = @incomming.process command, jid\n\n msg = Message::new stanza.from\n msg.type = :chat\n html = msg.add(XHTML::HTML.new(response.gsub(\"\\n\",\"<br />\")))\n msg.body = html.to_text\n @client.send(msg)\n }\n end\n @processing = false\n end",
"def start\n @client.ping\n @state.set :run\n @thread ||= Thread.new{ work_loop }\n end",
"def process! non_block=false\n @running = true\n while @running && (message = shift(non_block))\n @transport.send_message(message)\n end\n message\n end",
"def run_thread\n receive do |message|\n process message\n end\n rescue => error\n error(error)\n\n retry\n end",
"def work(raw_post)\n puts \"Msg received: \" + raw_post\n ack! # we need to let queue know that message was received\n end",
"def start\n assign_globals\n register_space\n start_message\n build_actions\n start_threads\n end",
"def work(raw_post)\n email_params = JSON.parse(raw_post).with_indifferent_access\n send_simple_message(params)\n ack! # we need to let queue know that message was received\n end",
"def start\r\n @object.send(*@message)\r\n end",
"def start\n # Don't send asynchronously\n if Deimos.config.producers.backend == :kafka_async\n Deimos.config.producers.backend = :kafka\n end\n Deimos.config.logger.info('Starting...')\n @signal_to_stop = false\n ActiveRecord::Base.connection.reconnect! unless ActiveRecord::Base.connection.open_transactions.positive?\n\n retrieve_poll_info\n loop do\n if @signal_to_stop\n Deimos.config.logger.info('Shutting down')\n break\n end\n process_updates if should_run?\n sleep(0.1)\n end\n end",
"def run\n @logger.info(\"Started.\")\n begin\n loop do\n process_incoming\n @logger.debug(\"Sleeping between actions for \" +\n \"#{SLEEP_BETWEEN_ACTIONS} seconds.\")\n sleep SLEEP_BETWEEN_ACTIONS\n process_outgoing\n @logger.debug(\"Sleeping between cycles for \" +\n \"#{SLEEP_BETWEEN_CYCLES} seconds\")\n sleep SLEEP_BETWEEN_CYCLES\n end\n rescue Interrupt\n @logger.info(\"Quitting.\")\n exit\n end\n end",
"def process\n puts 'Bacground processor - %s' % self\n\n read do |func, data|\n Lux::DelayedJob.call func, data\n end\n end",
"def start()\n #start listening\n @transport.monitor do |rmsg,header,payload|\n consume(rmsg,header,payload)\n end\n end",
"def process(message, recipient)\n Astrotrain.callback(:pre_processing, message, self)\n Transport.process(message, self, recipient)\n \n end",
"def start_queue_processing\n return unless @queue_thread.nil?\n\n stop_overflow_watcher\n\n @queue_thread = Thread.new {\n info 'started processing'\n loop do\n begin\n item = @queue.pop\n client.send_message(MessagePack.dump(item).bytes)\n sleep 0.001\n rescue => exc\n logger.error exc.message\n end\n end\n }\n end",
"def enqueue\n Karafka.logger.info(\"Enqueuing #{self.class} - #{params}\")\n Karafka::Worker.perform_async(params)\n end",
"def perform_inline\n Karafka.monitor.notice(self.class, to_h)\n perform\n end",
"def start\n @producer.start\n self\n end",
"def start\n validate!\n start_messages\n create_workers\n Process.wait\n end",
"def start\n validate!\n start_messages\n create_workers\n Process.wait\n end",
"def start\n # subscribe is like a callback\n @server_queue.subscribe(block: @block) do |delivery_info, properties, payload|\n consume(delivery_info, properties, payload)\n end\n end",
"def start\n @publisher = Thread.new do\n while true\n puts \"Command? \"; #thread publishing commands\n publish $stdin.gets\n end\n end\n @reader = Thread.new { subscribe &Proc.new { |message| callback message } } #thread waiting for messages\n\n @publisher.join\n end",
"def process_messages\n sleep 0.05\nend",
"def start\n\t\tloop do\n\t\t\t@client = @server.accept # Wait for a client to connect\n\t\t\t@client.sendmsg \"220 ready\\r\\n\" # 220 - the server is ready\n\n\t\t\t# authentication (we assume that the client does this correctly)\n\t\t\t@user = @client.gets.gsub(\"\\r\\n\", \"\") # => USER\n\t\t\t@client.sendmsg \"331\\r\\n\" # => USER ok\n\n\t\t\t@pass = @client.gets.gsub(\"\\r\\n\", \"\") # => PASS\n\t\t\t@client.sendmsg \"230\\r\\n\" # => PASS ok\n\n\t\t\twhile req = @client.gets\n\t\t\t\treq.gsub!(\"\\r\\n\", \"\")\n\n\t\t\t\t# XXX not really needed since no QUIT signal is sent by FCP\n\t\t\t\tif req == \"QUIT\"\n\t\t\t\t\t@client.sendmsg \"221\\r\\n\" # => QUIT ok, bye!\n\t\t\t\t\t@client.close\n\t\t\t\t\t@client = nil\n\t\t\t\t\tbreak\n\t\t\t\tend\n\n\t\t\t\ttmp = req.split(\" \")\n\t\t\t\tcmd, args = tmp[0], tmp[1..tmp.length-1]\n\n\t\t\t\tif !SUPPORTED_CMD.include?(cmd)\n\t\t\t\t\t@client.sendmsg \"500\\r\\n\"\n\t\t\t\t\tnext\n\t\t\t\tend\n\n\t\t\t\tself.__send__(\"cmd_#{cmd.downcase}\", args)\n\t\t\tend\n\t\tend\n\tend",
"def start\n @running = true\n @thread = Thread.new do\n while running?\n process @queues.incoming.pop(false)\n end\n end\n self\n end",
"def execute_send\n record_start_time\n queue_attempt\n end",
"def start\n queue = channel.queue(\"\", :exclusive => true, :auto_delete => true)\n queue.bind(exchange_in, :routing_key => consumer.routing_key)\n queue.subscribe(&method(:handle_message))\n logger.info \"Bind queue with routing key '#{consumer.routing_key}' to exchange '#{exchange_in.name}', waiting for messages...\"\n end",
"def start\n start_messages\n flush_spaces\n create_workers\n Process.wait\n end",
"def execute\n return unless active\n process_outbound_messages\n end",
"def send_message!\n msg = Message::Request.from_job(self)\n msg.send!\n end",
"def running_phase\n loop do\n maybe_log(\"Waiting for message\")\n request = ::Ractor.receive\n next unless request.is_a?(Message)\n case request.type\n when :call\n @queue.enq(request)\n register_call(request)\n maybe_log(\"Queued method #{request.data.first} (transaction=#{request.transaction})\")\n when :thread_stopped\n maybe_log(\"Thread unexpectedly stopped: #{request.data}\")\n @thread_count -= 1\n break\n when :stop\n maybe_log(\"Received stop\")\n break\n end\n end\n end",
"def run\n start\n queue.subscribe do |msg|\n if fork\n Process.wait\n else\n self.handle(msg)\n exit!\n end\n end\n end",
"def handle_messages!\n self.logger.debug { \"Starting message handler.\" }\n \n loop do\n message = nil\n\n # reads data\n self.logger.debug { \"Waiting for messages.\" }\n message = self.protocol.wait_interaction!\n \n # if nil data arrived, it means termination\n if message.nil?\n break\n end\n \n self.logger.debug { \"Message of type '#{message.type}' received.\" }\n\n # calls processing method according to incoming message\n case message.type.to_sym\n when :order\n self.handle_order(message)\n end\n \n end\n \n self.logger.debug { \"Message handler terminated.\" }\n end",
"def run\n # Start the message handler\n @message_handler.start\n\n @worker_list.each { |t| t.join }\n end",
"def start\n # reset config\n @server_config = Message::ServerConfig.new\n @socket = (@opts.tcp_socket || TCPSocket).new(@host, @port)\n on_connected\n post PASS, @opts.pass if @opts.pass\n post NICK, @opts.nick\n post USER, @opts.user, \"0\", \"*\", @opts.real\n\n buffer = BufferedTokenizer.new(\"\\r\\n\")\n\n while data = @socket.readpartial(4096)\n buffer.extract(data).each do |line|\n l = \"#{line}\\r\\n\"\n begin\n @log.debug \"RECEIVE: #{l.chomp}\"\n m = Message.parse(l)\n next if on_message(m) === true\n name = \"on_#{(COMMANDS[m.command.upcase] || m.command).downcase}\"\n send(name, m) if respond_to?(name)\n rescue Exception => e\n warn e\n warn e.backtrace.join(\"\\r\\t\")\n raise\n rescue Message::InvalidMessage\n @log.error \"MessageParse: \" + l.inspect\n end\n end\n end\n rescue IOError\n ensure\n finish\n end",
"def start\n @thread = Thread.new do\n # pop a request\n while (job = @queue.pop) do\n if job.exist?\n # process the request\n result_type = process(job)\n archive_result(job, result_type)\n\n # push status message\n update_status(job.id, name: \"COMPLETED\")\n end\n\n # remove the request\n @jobs.delete(job.id)\n end\n end\n end",
"def communication_loop\n while connected? && line = readline\n ui.log :printer, :received, line\n\n line.downcase!\n if line.starts_with?(*greetings)\n @can_send = 1\n elsif line.starts_with?(\"ok\")\n # TODO: Implement Q: parameter from \n # http://reprap.org/wiki/GCODE_buffer_multiline_proposal\n @can_send = 1\n # eg: Error:Line Number is not Last Line Number+1, Last Line:15\n # Resend:16\n elsif line.starts_with?(\"rs\", \"resend\")\n # TODO: extract line number from response.\n line = @lines.length - 1 # Last command. \n\n @send_queue.unshift(@lines[line])\n @can_send = 1\n end\n\n send_commands_from_queue\n end\n rescue => e\n puts \"Got exception in event communication thread!\"\n puts \"#{e.class}: #{e}\\n #{e.backtrace.join(\"\\n \")}\"\n disconnect\n raise(e)\n end",
"def start\n receive(IO.new(3), IO.new(4)) do |f|\n f.when([:call, Array]) do |args|\n method = args[0]\n retype = args[1]\n args = args[2..-1]\n f.send! self.dispatch(method, retype, args)\n exit if Chassis.exit_after_current_dispatch\n f.receive_loop\n end\n \n f.when(:config) do\n f.send! [:result, self.config]\n f.receive_loop\n end\n \n f.when(:api) do\n f.send! [:result, self.api]\n f.receive_loop\n end\n \n f.when(:ping) do\n f.send! :pong\n f.receive_loop\n end\n \n f.when(:quit) do\n exit(0)\n end\n end\n end",
"def run\n setup\n\n @running = true\n\n self.idling_thread = Thread.start do\n while(running?) do\n success = protected_call do\n process_mailbox\n idle\n end if @imap\n\n unless success\n sleep(@backoff)\n protected_setup\n end\n end\n reset\n end\n\n idling_thread.abort_on_exception = true\n end",
"def dispatch!\n \n # negotiates initial configuration\n @meta = self.negotiate!\n \n # dispatches hash set to the server\n self.dispatch_hashing!\n self.dispatch_hashset!\n \n # dispatches orders\n self.dispatch_orders!\n \n # dispatches messages\n self.handle_messages!\n \n end",
"def call\n run_callbacks :call do\n enqueue\n end\n end",
"def start\n\t\tself.sender.start\n\tend",
"def perform_async\n Karafka.monitor.notice(self.class, to_h)\n # We use @params directly (instead of #params) because of lazy loading logic that is behind\n # it. See Karafka::Params::Params class for more details about that\n worker.perform_async(\n topic,\n interchanger.load(@params)\n )\n end",
"def start\n executor.post {read_loop}\n start_protocols\n super\n end",
"def run\n logger.debug \"[Cottontail] Connecting to client\"\n @client = Bunny.new( *settings(:client) )\n @client.start\n\n logger.debug \"[Cottontail] Declaring exchange\"\n exchange = @client.exchange( *settings(:exchange) )\n\n logger.debug \"[Cottontail] Declaring queue\"\n queue = @client.queue( *settings(:queue) )\n\n routes.keys.each do |key| \n logger.debug \"[Cottontail] Binding #{key.inspect} to exchange\"\n queue.bind( exchange, :key => key )\n end\n\n logger.debug \"[Cottontail] Entering subscribe loop\"\n subscribe! queue\n rescue => e\n @client.stop if @client\n reset!\n\n logger.error \"#{e.class}: #{e.message}\\n\\t#{e.backtrace.join(\"\\n\\t\")}\"\n\n # raise when no retries are defined\n raise( e, caller ) unless settings(:retries)\n\n logger.debug \"[Cottontail] Going to retry in #{settings(:delay_on_retry)} seconds...\"\n sleep settings(:delay_on_retry) if settings(:delay_on_retry)\n retry\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 start_processing\n\t\t@processing = true\n\t\twhile @processing\n\t\t\tevent = self.read_next_event or next\n\t\t\tself.log.debug \"Read event: %p\" % [ event ]\n\t\t\tself.store_event( event )\n\t\tend\n\tend",
"def run\n\t \tbegin \n\t \twrite_command_status(@cmd_queue_0)\n\t \t\n\t \t@log.info \"Processing command queue...\"\n\t \tloop do\n\t \t\tbegin\n\t \t\t\tstr = listen\n\t \t\trescue EOFError\n\t \t\t\t@log.error \"No more messages from pump\"\n\t \t\t\tbreak\n\t \t\tend\n\n\t \t\trep = parse_response(str)\n\n\t \t\t# Look at command response and wait or proceed on queue\n\n\t \t\t# Is it a status message\n\t \t\t# Yes\n\t \t\tif rep[:status]\n\t\t\t\tif process_status(rep)\n\t\t\t\t break\n\t\t\t\tend\n\t \t\t# No\n\t \t\telsif !rep[:status]\n\t \t\t\tprocess_command(rep)\n\t \t\telse\n\t \t\t\t@log.error \"Unknown message type\"\n\t \t\tend\n\t \tend\n\t \t@log.info \"...command queue complete\"\n\n\t \trescue IRB::Abort\n\t \t\t@log.error \"Abort\"\n\t\t\tsleep(0.25)\n\t\t\twrite_stop\n\t\t\t#flush comms?\n\t \trescue Interrupt\n\t \t\t@log.info \"Interupt\"\n\t \t\t#write_stop\n\t \tensure \n\t \t\t@log.info \"Closing\"\n\t\t\t#write_stop\n\t \tend\n\n\t end",
"def listen\n Thread.new do\n while true\n retrieve_messages\n sleep (0.1)\n end\n end\n end",
"def start!\n start\n blocking_thread.join\n end",
"def start\n self.join if @running\n @running=true\n @thread = Thread.new do\n while @running\n block=self.pop\n @processing=true\n block.call\n @processing=false\n end\n end\n end",
"def receive_code\n Thread.start do\n receive_start = Time.now # performance\n\n tracing_vars = message[:vars]\n language = message[:language].downcase\n code = message[:code]\n\n #tests if input isn't to large\n if code.length < 10000 and language.length < 50 and tracing_vars.length < 100\n\n tracing_vars.each do |e|\n if e.length > 100\n return\n end\n end\n\n @preprocessor = Preprocessor.new(language, code, tracing_vars)\n\n start_simulation(tracing_vars)\n\n end\n\n PERFORMANCE_LOGGER.track(connection.id, :receive_code, Time.now - receive_start)\n end\n end",
"def handle_incoming_messages\n pause_work_if_dequeuing_paused\n process_async do |message_info, payload|\n begin\n log.debug(\"Payload: #{payload.to_s}\")\n rescue StandardError => ex\n # Log and ignore all exceptions. We want other jobs in the queue\n # to still process even though this one is skipped.\n log.exception(ex)\n ensure\n # Acknowledge that this job was handled so we don't keep retrying and\n # failing, thus blocking the whole queue.\n ETL.queue.ack(message_info)\n end\n begin\n ETL::Job::Exec.new(payload).run\n rescue StandardError => ex\n # Log and ignore all exceptions. We want other jobs in the queue\n # to still process even though this one is skipped.\n log.exception(ex)\n end\n\n pause_work_if_dequeuing_paused\n end\n\n # Just sleep indefinitely so the program doesn't end. This doesn't pause the\n # above block.\n while true\n sleep(10)\n end\n end",
"def listen\n @logger.debug(\"Waiting for play/start message from sequencer..\")\n message_1 = @translator.translate(@input.gets)\n while message_1 != \"play\"\n message_1 = @translator.translate(@input.gets)\n end\n @logger.debug(\"Play/start message received from sequencer..\")\n action\n end",
"def run\n capture_signals\n load_config\n\n EM.synchrony do\n connect\n start_throttle\n end\n end",
"def init_messaging\n @read_thread = Thread.new { read_loop }\n end",
"def run!\n @client.logger.debug('RuGGby::Action::Mark')\n\n mark = Packet::Outgoing::Mark.new\n @client.socket.write(mark)\n @block.call if @block\n end",
"def perform_async\n Karafka.monitor.notice(\n self.class,\n params: @params,\n worker: self.class.worker,\n interchanger: self.class.interchanger\n )\n\n # We use @params directly (instead of #params) because of lazy loading logic that is behind\n # it. See Karafka::Params::Params class for more details about that\n self.class.worker.perform_async(\n self.class,\n self.class.interchanger.load(@params)\n )\n end",
"def talk\n \n #\n # The Listening Proc\n # \n # This proc loopingly accepts a piping hot TiscapTransmission,\n # interprets it, and acts upon it. It almost never exits by itself,\n # but will sometimes call #graceful to cause itself to be\n # indirectly terminated.\n # \n Concurrent.ly do\n \n loop do\n begin # like ‘try’\n \n # If we're no longer accepting, stop reading now.\n break unless @accepting\n \n # Pull a Transmission off the wire.\n # Execution usually waits here.\n received = TiscapTransmission.from @iost\n \n # Now that we have a transmission, interpret it\n # based on the verb at hand:\n \n case received.verb\n \n when :'/private' # Deliver a private message.\n \n raise BadSyntaxError.new unless username_arg_ok? received.argument\n raise BadSyntaxError.new if received.data.nil?\n \n # all messages go over the MessageDispatch Hub.\n MessageDispatch.hub.send_private received.argument, received.data, self.name\n \n \n when :'/public' # Broadcast a public message.\n \n raise BadSyntaxError.new unless received.argument.nil?\n raise BadSyntaxError.new if received.data.nil?\n \n # even public messages go over the MessageDispatch Hub.\n MessageDispatch.hub.send_public received.data, self.name\n \n \n when :'/users' # Prepare and send back the active user list.\n \n response = TiscapTransmission.new( :']activeusers',\n MessageDispatch.hub.users.join(','),\n nil )\n self.receive response\n \n \n when :'/close' # Close the connection.\n \n self.graceful\n \n \n else # probably a server verb. not cool.\n raise BadSyntaxError.new\n \n \n end\n \n \n # Mitigate overrunning the whole machinery, and don't\n # accept more data for a little bit:\n sleep 0.25\n \n \n \n rescue TiscapError => you_fucked_up\n # Syntax errors raised above land here.\n # These can be written to the client, and then ignored.\n self.error you_fucked_up\n \n rescue EOFError, IOError, SystemCallError => goodbye\n # I/O problems land here, as in when the input stream\n # gets terminated. We could kill the connection,\n # but it might not be so dire; and the #graceful procedure\n # is robust enough to bail out of an already-dead stream.\n self.graceful\n break\n \n rescue NoMethodError, JavaLang::NullPointerException => to_err\n # An error I haven't yet caught will hopefully land here,\n # barf its backtrace, and cause the handler to stop reading\n # from the client.\n puts to_err.inspect\n puts to_err.backtrace\n break\n \n end # try\n end # loop\n \n end # thread\n \n \n \n \n #\n # The Writing Proc\n # \n # This proc loopingly waits for things to say (in the @outbox)\n # and---gasp!---writes them out to the client. It's this proc\n # which is responsible for executing a graceful shutdown of the\n # connection. When it receives a HaltTransmission in the @outbox,\n # it breaks its run loop, closes the I/O stream, and instructs\n # the MessageDispatch Hub to disown the handler, thereby re-\n # moving itself from the chat circle.\n # \n Concurrent.ly do\n \n loop do\n begin\n \n # We don't break if inactive,\n # because we might have a few more messages to shove down the pipe.\n \n toGo = @outbox.take\n break if toGo.is_last? # Graceful shutdown\n \n @iost.write toGo.representation\n \n rescue EOFError, IOError, SystemCallError => goodbye\n # When the I/O stream breaks, we land here.\n # Just hop out of the loop for cleanup.\n break\n \n rescue NoMethodError, JavaLang::NullPointerException => to_err\n # Uh-oh. I missed something. Better fix it...\n # but first, break the connection.\n puts to_err.inspect\n puts to_err.backtrace\n break\n \n end # try\n end # loop\n \n \n #\n # As soon as the write-loop ends, break the pipe altogether:\n @iost.close rescue nil\n \n #\n # And then tell MessageDispatch to disown us:\n MessageDispatch.hub.disown self\n \n \n end # thread\n \n \n \n end",
"def process\n river = Pebblebed::River.new\n queue_options = {\n :name => \"#{@app_name}.security_listener\",\n :path => '**',\n :klass => 'access_group|access_group_membership|access_group_subtree',\n :event => '**',\n :interval => 1\n }\n queue = river.queue queue_options\n queue.subscribe(block: true) do |delivery_info, metadata, payload|\n consider({:payload => payload})\n end\n end",
"def input_thread_step\n case (obj = read_from_wire)\n when Block\n handle_block obj\n when Message\n handle_message obj\n else\n raise \"don't know what to do with #{obj.inspect}\"\n end\n\n ## to enable immediate response, if there are no rate limits,\n ## we'll send the blocks and reqs right here. otherwise, the\n ## controller will call this at intervals.\n send_blocks_and_reqs if @controller.dlratelim.nil? && @controller.ulratelim.nil?\n end",
"def run\n @connection.queue do |queue|\n puts(\"Client started. Listening on queue “#{queue.name}”.\")\n begin\n queue.listen do |message|\n puts(message)\n end\n rescue Interrupt\n return\n end\n end\n end",
"def start\n @state = STARTED\n logger.info \"Starting producer with host_params:#{@host_params}\"\n @connection_start_time = Time.new\n @stomp = start_server(@host_params, @options.user, @options.passwd)\n rescue => e\n logger.error \"Error occurred while starting a connection: #{e}\\n #{e.backtrace.join(\"\\n\")}\"\n end",
"def process\n if threaded?\n @request.threaded = true\n EventMachine.defer { post_process(pre_process) }\n else\n @request.threaded = false\n post_process(pre_process)\n end\n end",
"def process\n save_as(:processing)\n perform_checks\n initiate_delivery\n capture_payment\n save_as(:processed)\n end",
"def perform\n @logger.info({context: :monitor, action: :perfomed})\n @client.psubscribe(\"#{service}:*\") do |callback|\n callback.psubscribe(self.on_subscribed)\n callback.pmessage(self.on_message)\n callback.punsubscribe(self.on_unsubscribed)\n end\n end",
"def run\n @logger.info 'Running'\n @thread_status = :running\n\n register_self_with_zk\n register_callbacks\n watch\n loop do\n queue_event = @queue.pop\n GracefulTrap.critical_section(%w(INT TERM), @logger) do\n process_queue_event(\n queue_event[:type],\n queue_event[:value],\n queue_event[:meta]\n )\n end\n end\n @thread_status = :stopped\n end",
"def start\n @thread = Thread.new &@block\n @thread.eldritch_task = self\n end",
"def process_msgs\n end",
"def configure()\n yield(configuration)\n self.sender = Sender.new(configuration)\n self.sender\n end",
"def execute_middleware_chain\n self.process_started_at = Time.now\n\n Cloudenvoy.config.subscriber_middleware.invoke(self) do\n begin\n process(message)\n rescue StandardError => e\n logger.error([e, e.backtrace.join(\"\\n\")].join(\"\\n\"))\n try(:on_error, e)\n raise(e)\n end\n end\n ensure\n self.process_ended_at = Time.now\n end",
"def run\n @output.print \"Run, Forest, run!\"\n \n EM.synchrony do\n print \"Mapper has been started #{Time.now}\"\n AMQP.start do |connection|\n print \"AMQP started #{Time.now}\"\n channel = AMQP::Channel.new connection\n queue = channel.queue(@config[\"broker\"][\"queue-name\"], :auto_delete => true)\n queue.subscribe do |payload|\n print \"Received message #{payload}\"\n connection.close {EM.stop} if payload == \"stop\"\n Fiber.new{start}.resume if payload == \"start\"\n Fiber.new {match}.resume if payload == 'match'\n EM.defer {start_webserver} if payload == 'start_webserver'\n EM.defer {start_search_server} if payload == 'start_solr'\n EM.defer {stop_search_server} if payload == 'stop_solr'\n EM.defer {add_db_to_search_index} if payload == 'index'\n EM.defer {setup_storage} if payload == 'setup_storage'\n end\n end\n end\n end",
"def start\n start_message\n setup_options\n validate!\n setup_jobs\n boot_manager\n end",
"def start\n return if active?\n begin\n @subject.start\n rescue Errno::ECONNRESET\n raise EventSource::Protocols::Amqp::Error::ConnectionError,\n \"Connection failed. network error to: #{connection_params}\"\n rescue Bunny::TCPConnectionFailed\n raise EventSource::Protocols::Amqp::Error::ConnectionError,\n \"Connection failed to: #{connection_params}\"\n rescue Bunny::PossibleAuthenticationFailureError\n raise EventSource::Protocols::Amqp::Error::AuthenticationError,\n \"Likely athentication failure for account: #{@subject.user}\"\n rescue StandardError\n raise EventSource::Protocols::Amqp::Error::ConnectionError,\n \"Unable to connect to: #{connection_params}\"\n else\n sleep 1.0\n logger.info \"Connection #{connection_uri} started.\" if active?\n active?\n end\n end",
"def async_deliver\n if self.send_at.present?\n Sidekiq::Client.enqueue_to_in(\"medium\", self.send_at, DeliverySender, self.id)\n else\n Sidekiq::Client.enqueue_to(\"medium\", DeliverySender, self.id)\n end\n end",
"def start\n return if @continue_sending\n\n @continue_sending = true\n Thread.new do\n while @continue_sending\n if @subscriber && !empty_queue?\n payload = @sse_queue.pop\n stream_sse_payload(payload)\n end\n end\n\n unsubscribe\n end\n end",
"def run\n @running = true\n while @running do\n begin\n message = Hastur::Message.recv(@data_socket)\n envelope = message.envelope\n uuid = message.envelope.from\n Hastur::Cassandra.insert(@client, message.payload, envelope.type_symbol.to_s, :uuid => uuid)\n envelope.to_ack.send(@ack_socket) if envelope.ack?\n rescue Hastur::ZMQError => e\n @logger.error \"Error reading from ZeroMQ socket.\", { :exception => e, :backtrace => e.backtrace }\n rescue Exception => e\n @logger.error e.to_s, { :message => e.message, :backtrace => e.backtrace }\n end\n end\n end",
"def start\n self.send(:pre_start) if self.respond_to?(:pre_start, true)\n @thread = Thread.new do \n loop do\n receive(@actorQueue.shift)\n end\n end\n\n return self\n end",
"def process\n logger.info \"Beetle: received message #{message.inspect}\"\n end",
"def start!\n \t@initial_queue = Dispatch::Queue.current\n event :start\n end",
"def enable\n @queue << \"enable\"\n end",
"def submit(czk)\n state = czk.zkrb_state # check the state of the connection\n\n if @meth == :state # if the method is a state call\n @rval = [state] # we're done, no error\n return deliver!\n\n elsif state != ZOO_CONNECTED_STATE # otherwise, we must be connected\n @error = state # so set the error\n return deliver! # and we're out\n end\n\n rc, *_ = czk.__send__(:\"zkrb_#{@meth}\", *async_args)\n \n if user_callback? or (rc != ZOK) # async call, or we failed to submit it\n @rval = [rc] # create the repsonse\n deliver! # wake the caller and we're out\n end\n end",
"def start_broker()\n\n Thread.new do\n `ruby -r 'simplepubsub' -e \"SimplePubSub::Broker.start port: '55000'\"`\n end\n\n end",
"def call\n executor.consume\n end",
"def execute\n return unless active\n process_outbound_ack\n deactivate(@flag)\n end",
"def start_worker\n @trace_handler = ->(items, transport) { send_spans(items, transport) }\n @worker = Workers::AsyncTransport.new(\n transport: @transport,\n buffer_size: @buff_size,\n on_trace: @trace_handler,\n interval: @flush_interval\n )\n\n @worker.start\n end",
"def run\n Kernel.trap(\"CLD\") do \n pid = Process.wait\n remove_runner(pid)\n end\n \n until @finish\n deliveries = check_queue\n deliveries.each do |del|\n if slot_open?(del) && lock_delivery(del)\n puts \"Delivering #{del[\"class\"]}\\##{del[\"method\"]} at #{Time.now}\" unless quiet\n # Close our connection so that we don't get too many weird copies\n Candygram.connection = nil\n child = fork do\n # We're the runner\n set_status(del, 'running')\n package = Wrapper.unwrap(del[\"package\"])\n args = Wrapper.unwrap(del[\"arguments\"])\n result = package.send(del[\"method\"].to_sym, *args)\n finish_delivery(del, result)\n Candygram.connection = nil\n exit\n end\n # We're the parent\n add_runner del[\"class\"], child\n sleep(0.2) # Give connections time to wrap up\n end\n end\n sleep frequency\n end\n until @index.empty?\n sleep(0.1) # We trust our trap\n end\n end",
"def execute\n # TODO: Check update_id to ignore duplicates\n return send_keypad if given?(:message) && message.dig(\"text\") == \"/start\"\n return calculate if given?(:callback_query)\n end",
"def run\n @running = true\n\n while @running do\n message = Hastur::Message.recv(@data_socket)\n envelope = message.envelope\n uuid = message.envelope.from\n Hastur::Cassandra.insert(@client, message.payload, envelope.type_symbol.to_s, :uuid => uuid)\n envelope.to_ack.send(@ack_socket) if envelope.ack?\n end\n\n rescue Hastur::ZMQError => e\n @logger.error \"Error reading from ZeroMQ socket.\", { :exception => e, :backtrace => e.backtrace }\n rescue Exception => e\n @logger.warn \"unhandled exception! Dropped message: #{message}\"\n Hastur::Util.log_exception e, @logger\n raise e\n end",
"def ping!\n @transmission_state.enqueue_ping\n end",
"def call\n Karafka.monitor.instrument(\n 'connection.listener.before_fetch_loop',\n consumer_group: @consumer_group,\n client: client\n )\n fetch_loop\n end",
"def start\n EM::Iterator.new(1..8).each do |n,iter|\n size = n * 256\n message = Array.new(size, \"#\").join\n @consumer_channel.push pack_message_event({ :id => generate_message_id, :data => message })\n iter.next\n end\n end",
"def go\n while(true)\n process_event(wait_for_event)\n end\n end",
"def run\n if options(:object)\n loop{ options(:object).instance_exec(receive, &@receive_block) }\n elsif @receive_block\n loop{ @receive_block.call(receive) }\n else\n loop{ receive }\n end\n rescue Stop\n nil\n rescue Exception => e\n @exception = e\n @last_message = @message\n ensure\n @state = :finished\n notify_linked_of(@exception) if @exception\n end"
] |
[
"0.61254233",
"0.5846753",
"0.5843763",
"0.5705409",
"0.56589127",
"0.5556909",
"0.55074763",
"0.55064166",
"0.5461887",
"0.5443115",
"0.53966194",
"0.5388551",
"0.5388348",
"0.53880715",
"0.535887",
"0.5354482",
"0.53453535",
"0.5305684",
"0.5298877",
"0.5277103",
"0.5276255",
"0.52509546",
"0.5244422",
"0.52182305",
"0.5214148",
"0.521353",
"0.521353",
"0.5209616",
"0.5195269",
"0.5171883",
"0.51681197",
"0.5164746",
"0.51147836",
"0.5112157",
"0.5099466",
"0.50826323",
"0.5077764",
"0.5054306",
"0.50542814",
"0.5050769",
"0.50422335",
"0.50330293",
"0.503078",
"0.5017749",
"0.49886486",
"0.4987031",
"0.4979524",
"0.49783143",
"0.4963362",
"0.49487078",
"0.4937568",
"0.49312875",
"0.4929963",
"0.49256983",
"0.49238303",
"0.48744297",
"0.48732406",
"0.48569518",
"0.4854403",
"0.48543295",
"0.4853711",
"0.4848175",
"0.4830416",
"0.48292664",
"0.48289764",
"0.48263168",
"0.48193732",
"0.48143694",
"0.48117867",
"0.48108128",
"0.481045",
"0.48083758",
"0.48060423",
"0.48001078",
"0.47982603",
"0.47959638",
"0.47833252",
"0.47822547",
"0.47781512",
"0.47752923",
"0.47744665",
"0.47739056",
"0.47721612",
"0.47605133",
"0.47602174",
"0.47583795",
"0.47561622",
"0.47530302",
"0.47481003",
"0.474731",
"0.47429848",
"0.47330463",
"0.47298846",
"0.47279766",
"0.47076854",
"0.4704759",
"0.47044206",
"0.47040218",
"0.47002965",
"0.46999508",
"0.4699401"
] |
0.0
|
-1
|
blpop return an array [list_name, data]
|
def get_spark(raw_spark)
raw_spark.kind_of?(Array) ? raw_spark.last : raw_spark
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_list_data\n\t\tlist_data = Array.new\n\t\tlist = get_list\n\t\tlist.each do |item|\n\t\t\tvoc = Voc.find(item)\n\t\t\tvoc.wylie = Functions.disparse_a(voc.wylie)\t\n\t\t\tlist_data.push( voc )\n\t\tend\n\t\treturn list_data\n\tend",
"def pop()\n @data.pop\n end",
"def pop \r\n @data.pop\r\n end",
"def pop\n list.pop\n end",
"def blpop(*args)\n _bpop(:blpop, args)\n end",
"def pop\r\n # What does array.pop do? It takes the last \r\n # item of a list. We want this method to return\r\n # the last item. So maybe we can do something like:\r\n # return @data.last\r\n end",
"def pop() end",
"def blpop(*args)\n _bpop(:blpop, args)\n end",
"def get_last_pglist_data\n return @last_parsed_pglist_data\n end",
"def get_items\n\t\treturn @list\n\tend",
"def brpop(*args)\n _bpop(:brpop, args)\n end",
"def brpop(*args)\n _bpop(:brpop, args)\n end",
"def pop; end",
"def pop; end",
"def pop; end",
"def pop; end",
"def pop; end",
"def brpop(*args); end",
"def brpop(*args); end",
"def get_list\n \t@items\n end",
"def pop\n curr = items\n ret = curr.pop\n\n serialize(curr)\n\n ret.nil? ? nil : ret\n end",
"def to_a; @list; end",
"def populate\n storage = MultiJson.decode(collection.find_one['boom']) || []\n \n storage['lists'].each do |lists|\n lists.each do |list_name, items|\n @lists << list = List.new(list_name)\n\n items.each do |item|\n item.each do |name,value|\n list.add_item(Item.new(name,value))\n end\n end\n end\n end \n end",
"def parse_list; end",
"def parse_list; end",
"def get_list(list_name)\n @lib.get_list(list_name)\n end",
"def get_data\n @data = []\n end",
"def get_items\r\n @list\r\n end",
"def ll_pop()\n current = @head\n \n if @num_nodes == 0\n return nil\n elsif @num_nodes == 1\n @head = nil\n @tail = nil\n else\n second = @head.get_Next()\n @head = second\n end\n \n @num_nodes -= 1\n return current.get_Data()\n end",
"def list\n @list.dup\n end",
"def pop\n end",
"def list_data\n _check_and_get(@_data, Array)\n end",
"def pop()\n \n end",
"def pop()\n \n end",
"def pop()\n \n end",
"def list\n @list\n end",
"def pop\r\n # IMPLEMENT ME\r\n end",
"def pushAndPopToStack(list, newItem = nil, option)\n if (option == 'push')\n list.push(newItem)\n end\n if (option == 'pop')\n list.pop\n end\n\n return @theArray\n end",
"def list; end",
"def list; end",
"def list; end",
"def list; end",
"def list; end",
"def make_item_list\n @data = $game_party.all_items.select {|item| include?(item)}\n @data.push(nil) if include?(nil)\n end",
"def list\n return @list\n end",
"def pop\n\n outlen_op(:tclistpop)\n end",
"def get_data\n $test_logger.log(\"Get data\")\n\n if @data.is_a?(Array) \n data_copy = Array.new(@data.size)\n @data.each_with_index{|d, i|\n if !d.to_s.include? CmdManager::DONT_CARE\n data_copy[i] = BioPacket.swap_dword(d)\n else\n data_copy[i] = d\n end \n } \n else\n data_copy = Common.get_obj_copy(@data)\n end \n data_copy\n end",
"def _ls\n @response[:list] = []\n end",
"def unpack\n list_items\n @items.each do |type,list|\n @items.delete(type)\n end\n end",
"def \n \n using_pop(array)\n \n\n array.pop()\n \nend",
"def list_data_bag_items(data_bag_name)\n @items = {} if @items.nil?\n @items[data_bag_name] = @items[data_bag_name] || knife_output_as_array(\"data bag show #{data_bag_name}\")\nend",
"def using_pop (array)\n return array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def pop_blocking\n tag[:blocking_list].rpop\n end",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def get_list_item\n if @symbol_or_list.is_a? Symbol\n if @shop.shop_list.key?(@symbol_or_list)\n @list_item = @shop.shop_list[@symbol_or_list].keys\n @item_quantity = []\n @list_item.each {|id| @item_quantity << @shop.shop_list[@symbol_or_list][id]}\n else\n raise 'Shop with symbol :' + @symbol_or_list.to_s + ' must be created before calling it'\n @running = false\n end\n elsif @symbol_or_list.is_a? Array\n @list_item = @symbol_or_list\n check_if_shop_empty\n end\n @index = 0\n @last_index = @list_item.size - 1\n end",
"def make_item_list\n @data = $game_system.places_unlocked;\n end",
"def list\n @list ||= []\n end",
"def fetch\n\t\t\t\t[self.[], @args]\n\t\t\tend",
"def returnList\n\t\telements = []\n\t\tcurrent = @head\n\t\twhile current != nil\n\t\t\telements << current.value\n\t\t\tcurrent = current.nnode\n\t\tend\n\t\treturn elements\n\tend",
"def pop\n # IMPLEMENT ME\n end",
"def list\n return @lists\n end",
"def using_pop(array)\n array.pop()\nend",
"def using_pop(arr)\n arr.pop\nend",
"def pop\n raise EMPTY_STACK_ERROR if @data.empty?\n\n @data.pop\n end",
"def new_list\n list = {}\n return list\nend",
"def pop\n @data.delete_at @data.length - 1 if @data.length > 0\n end",
"def list\n @list ||= []\n end",
"def list\n @list ||= []\n end",
"def end_push\n ## empty\n return [[], []]\n end",
"def plist_multi( sp, key, list )\n p = []\n p.push \"#{sp}<#{key.to_s}>\"\n p.push list\n p.push \"#{sp}</#{key.to_s}>\"\n return p\n end",
"def get_items\r\n @arr.to_a\r\n end",
"def stack_pop\n\n r = stack_fetch\n stack_unstack if r.class != Rufus::Lua::Table\n\n r\n end",
"def to_a\n @list\n end",
"def get_items\n\t\t@arr\n\tend",
"def list\n @List\n end",
"def list_name\n @data['list_name']\n end",
"def make_item_list\n @data = $game_temp.forge_shop.products\n end",
"def to_a\n @list.clone\n end",
"def pop_server\n return get_server_by_algorithm(false) { |l| [ l.last, '' ] }\n end",
"def get_list \n\t\tlist = cookies[:\"eList\"] # liest Rohdaten (string) aus cookie\n\t\tif list == nil # Liste ist leer \n\t\t\tlist = Array.new # erzeuge neue Liste \n\t\telse # Liste enthält Eintrag \n\t\t\tif list.length > 0 \n\t\t\t\tlist = list.split(\" \") #erzeuge lesbare Liste (Array) aus Rohdatensatz\n\t\t\telse\n\t\t\t\tlist = Array.new \n\t\t\tend \n\t\tend \n\t\treturn list \n\tend",
"def copy_list \n\n\tend",
"def restore_pop\n\nend",
"def clone_list_to_array\n clone = Array.new\n self.items.each do |item| \n result.push(item.get_clone())\n end\n return clone\n end",
"def using_pop(array)\n element = array.pop\n element\nend",
"def get_list_items\n get_field_config['items']\n end",
"def pop\r\n # I RETURN A VALUE\r\n data1 = @data\r\n data1.next_node.previous = nil\r\n @data = data1.next_node\r\n return data1\r\n end",
"def list(*) end",
"def pop_stack\n raise ArgumentError if @array_list.empty?\n\n @array_list.pop\n end",
"def lists\n @lib.lists\n end",
"def list_values(bn, lists)\n raise \"no list\" unless lists.has_key?(bn)\n first, rest = lists[bn][RDF.first], lists[bn][RDF.rest]\n (rest == RDF.nil ? [] : list_values(rest, lists)).unshift(first)\n rescue\n lists.delete(bn)\n raise $!\n end",
"def using_pop(array)\n array = array.pop(1)\n array.pop\n\n\nend"
] |
[
"0.6211502",
"0.6063916",
"0.60359174",
"0.58774966",
"0.5837753",
"0.58364785",
"0.5821982",
"0.58210546",
"0.57783246",
"0.5774944",
"0.5766763",
"0.5739442",
"0.57384866",
"0.57384866",
"0.57384866",
"0.57384866",
"0.57384866",
"0.5711455",
"0.5711455",
"0.5690897",
"0.5633501",
"0.5630871",
"0.5597118",
"0.557946",
"0.557946",
"0.5556996",
"0.5550878",
"0.5507303",
"0.5499865",
"0.54953355",
"0.5485788",
"0.5475648",
"0.54643124",
"0.54643124",
"0.54643124",
"0.54372054",
"0.5423153",
"0.53987706",
"0.5385289",
"0.5385289",
"0.5385289",
"0.5385289",
"0.5385289",
"0.53619534",
"0.5356684",
"0.5351384",
"0.53407204",
"0.53248566",
"0.532382",
"0.531132",
"0.53056675",
"0.5281865",
"0.5273697",
"0.52548075",
"0.52451915",
"0.52439344",
"0.52439344",
"0.52439344",
"0.52439344",
"0.52439344",
"0.52439344",
"0.52439344",
"0.52439344",
"0.52439344",
"0.52422386",
"0.523287",
"0.52293044",
"0.5222242",
"0.52193874",
"0.5219114",
"0.5213257",
"0.5208403",
"0.5192886",
"0.5188762",
"0.5179243",
"0.5178521",
"0.51783925",
"0.51783925",
"0.5177477",
"0.51716614",
"0.51529205",
"0.51482874",
"0.5135264",
"0.51316166",
"0.51292557",
"0.51276404",
"0.5126391",
"0.5112137",
"0.5108866",
"0.5102028",
"0.5097594",
"0.50926864",
"0.50913185",
"0.50906676",
"0.5088004",
"0.50805295",
"0.507683",
"0.50744325",
"0.5055577",
"0.50555634",
"0.5041184"
] |
0.0
|
-1
|
return the spark (ephemeral part of the message) from the message list
|
def h_spark(raw_spark)
JSON.parse get_spark(raw_spark), {symbolize_names: true}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def build_spark(message)\n keys = [:sender, :uid, :spark_uid, :tstamp, :context, :previous_sender, :type, :topic, :task ]\n spark = keys.inject({}) { |memo, param| memo.merge(param => message[param]) }\n spark\n end",
"def get_spark(raw_spark)\n raw_spark.kind_of?(Array) ? raw_spark.last : raw_spark\n end",
"def send_message(message, spark)\n # avoid further processing into the multi redis command\n channel_name = message[:sent_to]\n h_key = hsdq_key message\n burst_j = message.to_json\n spark_j = spark.to_json\n bkey = burst_key(message)\n\n cx_data.multi do\n cx_data.hset h_key, bkey, burst_j\n cx_data.expire h_key, 259200 #3 days todo set by options\n cx_data.rpush channel_name, spark_j\n end\n end",
"def pluck_message\n pluck_queue_message(name)\n end",
"def read_message\n return @text_queue.shift\n end",
"def message_list\n list = []\n each do |k, v|\n list.concat(v.message_list)\n end\n list\n end",
"def next_msg\n @socket.readline.chomp.split(\" \")\n end",
"def sparkle(spark, options)\n puts spark.inspect\n burst, ctx_burst = get_burst spark, options\n context ctx_burst\n\n case spark[:type].to_sym\n when :ack\n hsdq_ack burst, context\n when :callback\n hsdq_callback burst, context\n when :feedback\n hsdq_feedback burst, context\n when :error\n hsdq_error burst, context\n when :request\n set_context spark\n\n hsdq_request burst, context\n end\n end",
"def receive_messages\n begin\n resp = @sqs.receive_message(\n message_attribute_names: PIPE_ARR,\n queue_url: @settings[:consuming_sqs_queue_url],\n wait_time_seconds: @settings[:wait_time_seconds],\n max_number_of_messages: @settings[:max_number_of_messages],\n )\n resp.messages.select do |msg|\n # switching whether to transform the message based on the existance of message_attributes\n # if this is a raw SNS message, it exists in the root of the message and no conversion is needed\n # if it doesn't, it is an encapsulated messsage (meaning the SNS message is a stringified JSON in the body of the SQS message)\n begin\n if !msg.key? 'message_attributes'\n # extracting original SNS message\n tmp_body = JSON.parse msg.body\n # if there is no Message, this isn't a SNS message and something has gone terribly wrong\n next if tmp_body.key? 'Message'\n # replacing the body with the SNS message (as it would be in a raw delivered SNS-SQS message)\n msg.body = tmp_body['Message']\n msg.message_attributes = {}\n # discarding messages without attributes, since this would lead to an exception in subscribe\n next if tmp_body.key? 'MessageAttributes'\n # parsing the message_attributes\n tmp_body['MessageAttributes'].each do |name, value|\n msg.message_attributes[name] = Aws::SQS::Types::MessageAttributeValue.new\n msg.message_attributes[name].string_value = value['Value']\n msg.message_attributes[name].data_type = 'String'\n end\n end\n msg\n rescue JSON::JSONError => e\n self.logger.info(e)\n end\n end\n rescue Aws::SQS::Errors::ServiceError => e\n self.logger.info(e)\n end\n end",
"def read_message(adapter, queue_url)\n result = adapter.sqs_client.receive_message(\n queue_url: queue_url,\n max_number_of_messages: 1,\n wait_time_seconds: adapter.options[:mq_aws_sqs_read_timeout],\n message_attribute_names: [\"All\"]\n )\n return nil if result.messages.count == 0\n return result.messages.first if result.messages.count == 1\n\n raise Mimi::Messaging::ConnectionError, \"Unexpected number of messages read\"\n end",
"def slice_message_tail(message_vector)\n vector.new(message_vector.vector[-HASH_LENGTH / 8..-1])\n end",
"def peek\n return nil if empty?\n _decode_message(self.first)\n end",
"def message\n response.body.match(/\"message\":\"(.*)\"/)[1]\n end",
"def receive\n @subscriber.recv_strings( parts = [] )\n #log.debug \"a queue item [%s]\\n\", parts.join(' ')\n parts\n end",
"def content_from(mesg)\n mesg.slice(6..mesg.length).split(',')\nend",
"def messages\n @zk.children(full_queue_path)\n end",
"def messages\n @queue.messages.select { |m| m.claim == self }\n end",
"def get_messages(packet_list)\n count = packet_list[:numPackets]\n first = packet_list[:packet][0]\n data = first[:data].to_a\n messages = []\n messages << data.slice!(0, first[:length])\n (count - 1).times do |i|\n length_index = find_next_length_index(data)\n message_length = data[length_index]\n unless message_length.nil?\n packet_start_index = length_index + 2\n packet_end_index = packet_start_index + message_length\n if data.length >= packet_end_index + 1\n packet = data.slice!(0..packet_end_index)\n message = packet.slice(packet_start_index, message_length)\n messages << message\n end\n end\n end\n messages\n end",
"def message\n @messages.first\n end",
"def get_burst(spark, _options={})\n # get the context parameters\n context_h = spark[:context]\n\n burst_p = -> { cx_data.hget hsdq_key(spark), burst_key(spark) }\n if response?(spark) && context_h\n # save previous_sender in thread_store for later reply\n sent_to context_h[:previous_sender]\n # set the proc for multi redis to pull the initial request\n burst_context_p = -> { cx_data.hget hsdq_key(spark), \"request_#{context_h[:spark_uid]}\" }\n # exec the redis multi\n burst_j, burst_context_j = pull_burst(burst_p, burst_context_p)\n else\n burst_j, burst_context_j = pull_burst_only burst_p\n end\n\n burst = burst_j ? (JSON.parse burst_j, {symbolize_names: true}) : {}\n burst_context = burst_context_j ? (JSON.parse burst_context_j, {symbolize_names: true}) : {}\n\n [burst, burst_context]\n end",
"def seperate_body()\n\t\t@stream.split(\"\\n\\n\", 2)[1]\n\tend",
"def message_from_queue\n if msg = @connection.pop\n message = msg.body.delete(\"\\n\")\n msg.finish\n message\n end\n end",
"def read(idx=1) \n messages[idx.to_i-1]\n end",
"def payload; message[:payload]; end",
"def message_buffer; end",
"def current_weixin_message\n Message.factory(request.body.read)\n end",
"def current_weixin_message\n Message.factory(request.body.read)\n end",
"def get_mmsparts()\n return @api.do_request(\"GET\", get_base_api_path() + \"/mms_parts\")\n end",
"def get_mmsparts()\n return @api.do_request(\"GET\", get_base_api_path() + \"/mms_parts\")\n end",
"def message\n data.message\n end",
"def message\n @data['message']\n end",
"def trim_capture_message(item_with_capture_message)\n item_with_capture_message[0,2]\n end",
"def extract_message(response)\n # Extract the message element\n # e.g. /Envelope/Body/ReadPublicationResponse/PublicationMessage\n soap_ns = 'http://schemas.xmlsoap.org/soap/envelope/'\n message = response.doc.xpath('s:Envelope/s:Body', s: soap_ns).first.first_element_child.first_element_child\n\n return nil unless message\n\n id = message.element_children[0].text\n content = message.element_children[1].first_element_child\n topics = message.element_children[2..-1].map {|e| e.text}\n\n # Retain any ancestor namespaces in case they are applicable for the element\n # and/or children. This is because content.to_xml does not output ancestor\n # namespaces.\n # There may be unnecessary namespaces carried across (e.g. ISBM, SOAP), but we\n # can't tell if the content uses them without parsing the content itself.\n content.namespaces.each do |key, value|\n # Don't replace default namespace if it already exists\n next if key == 'xmlns' && content['xmlns']\n content[key] = value\n end\n\n # Wrap content in a separate Nokogiri document. This allows the ability to\n # validate the content against a schema.\n doc = Nokogiri::XML(content.to_xml)\n\n IsbmAdaptor::Message.new(id, doc, topics)\n end",
"def read()\n\tloop {\n\t\t#puts (\"read list in : #{$reading}\")\n\t\trs, ws, es = IO.select($reading, nil, nil, 1)\n\t\tif (rs != nil)\n\t\t\trs.each { |r|\n\t\t\t\tmsg = r.gets\n\t\t\t\t#only reads in messages sent from a socket\n\t\t\t\tif (!(msg == nil))\n\t\t\t\t\tmsg_info = msg.split(\" \")\n\t\t\t\t\t#if msg_info[0] != \"LSP\"\n\t\t\t\t\t#puts(\"just recieved a message #{msg}\")\n\t\t\t\t\t#end\n\t\t\t\t\t#puts (\"just recieved a message #{msg}\")\n\t\t\t\t\tparseMsg(msg)\t\t\t\n\t\t\t\tend\n\t\t\t}\n\t\tend\n\t\t\n\t}\nend",
"def next_message\n socket.get_packet\n end",
"def take(count)\n buffer = []\n\n parts_count = self.partitions_size\n # No parts was scanned, yet\n last_scanned = -1\n\n while buffer.empty?\n last_scanned += 1\n buffer += context.run_job_with_command(self, [last_scanned], true, Spark::Command::Take, 0, -1)\n end\n\n # Assumption. Depend on batch_size and how Spark divided data.\n items_per_part = buffer.size\n left = count - buffer.size\n\n while left > 0 && last_scanned < parts_count\n parts_to_take = (left.to_f/items_per_part).ceil\n parts_for_scanned = Array.new(parts_to_take) do\n last_scanned += 1\n end\n\n # We cannot take exact number of items because workers are isolated from each other.\n # => once you take e.g. 50% from last part and left is still > 0 then its very\n # difficult merge new items\n items = context.run_job_with_command(self, parts_for_scanned, true, Spark::Command::Take, left, last_scanned)\n buffer += items\n\n left = count - buffer.size\n # Average size of all parts\n items_per_part = [items_per_part, items.size].reduce(0){|sum, x| sum + x.to_f/2}\n end\n\n buffer.slice!(0, count)\n end",
"def segments\n message.split(%r(\\n\\n(?=[<>])))\n end",
"def message_params\n m = params.require(:message)\n js = JSON.parse(m).with_indifferent_access\n res = js.slice(:context, :topic, :body, :begun_at, :success_at, :failed_at)\n res\n end",
"def message(message)\n get(\"inbox/messages/#{message}\").pop\n end",
"def take_msg(queue)\n msg = queue.reserve\n #by calling ybody we get the content of the message and convert it from yml\n count = msg.ybody.count\n result = count*count\n msg.delete\n return result\n end",
"def codes_from_message(message_array)\n message_array.collect { |st| st.split(':')[1] if st.include?(':') }.compact\n end",
"def read(idx=1)\n\n cmd('CMGR=' + idx.to_s) do |r| \n begin\n parse_msg r \n rescue SmsSerialError => e\n puts 'Invalid message no.'.warning\n nil\n end\n end\n\n end",
"def parse_body(buffer)\n super(buffer)\n @id = shift_short(buffer)\n @topics = []\n while buffer.bytesize > 0\n topic_name = shift_string(buffer)\n topic_qos = shift_byte(buffer)\n @topics << [topic_name, topic_qos]\n end\n end",
"def parse_body(buffer)\n super(buffer)\n @id = shift_short(buffer)\n @topics = []\n while buffer.bytesize > 0\n topic_name = shift_string(buffer)\n topic_qos = shift_byte(buffer)\n @topics << [topic_name, topic_qos]\n end\n end",
"def get_media_content_for_message(message_id)\n begin\n message_sql = \"SELECT * FROM mediacontent WHERE mediacontentid IN\";\n message_sql += \" (SELECT messagemediacontent.mediaid FROM messagemediacontent WHERE messageid = #{message_id})\";\n message_sql += \" AND (( iPodVideo IS NOT NULL AND iPodVideo != '') OR (HighQFilePath IS NOT NULL AND HighQFilePath != '' ))\";\n message_media_content_data = Immutable.dbh.execute(message_sql);\n\n return message_media_content_data;\n rescue DBI::DatabaseError => e\n Immutable.log.error \"Error code: #{e.err}\"\n Immutable.log.error \"Error message: #{e.errstr}\"\n Immutable.log.error \"Error SQLSTATE: #{e.state}\"\n abort('An error occurred while getting message media content data from DB, Check migration log for more details');\n end\n end",
"def segment_0; segments[0]; end",
"def get_audio_content_for_message(message_id)\n begin\n\n audio_sql = \"SELECT * FROM mediacontent WHERE mediacontentid\";\n audio_sql += \" IN (SELECT messagemediacontent.mediaid FROM messagemediacontent WHERE\";\n audio_sql += \" messageid = #{message_id}) AND ( HighQFilePath IS NOT NULL)\";\n audio_sql += \" AND (ContentTypeID = 5 OR ContentTypeID = 2) AND (HighQFilePath LIKE '%mp3')\";\n audio_sql += \" AND HighQFilePath != ''\"\n\n message_audio_content_data = Immutable.dbh.execute(audio_sql);\n return message_audio_content_data;\n rescue DBI::DatabaseError => e\n Immutable.log.error \"Error code: #{e.err}\"\n Immutable.log.error \"Error message: #{e.errstr}\"\n Immutable.log.error \"Error SQLSTATE: #{e.state}\"\n abort('An error occurred while getting audio content data from DB, Check migration log for more details');\n end\n end",
"def next_message; end",
"def next_message; end",
"def decode_message(message)\n # minimum size is header (4) + type (1)\n return if message.length < 5\n header, type = message.unpack('NC')\n # TODO: handle fragmented responses\n return if header != UNFRAGMENTED_HEADER\n [type, message[5, message.length]]\n end",
"def receive_message(queue_name_or_url, params={}, *attrs)\n doc = Adapter.receive_message(\n queue_url(queue_name_or_url),\n params,\n *attrs\n )['ReceiveMessageResponse']['ReceiveMessageResult']\n doc ? doc['Message'] : []\n end",
"def part(channels, message = nil)\n raw \"PART #{Array(channels).map(&:to_s).join ','} :#{message}\\r\\n\"\n end",
"def to_java\n\t @part\n\tend",
"def scan(mhead, mbody)\n return nil unless mhead['x-amz-sns-message-id']\n return nil if mhead['x-amz-sns-message-id'].empty?\n\n hasdivided = mbody.split(\"\\n\")\n jsonstring = ''\n jsonthings = nil\n foldedline = false\n\n while e = hasdivided.shift do\n # Find JSON string from the message body\n next if e.empty?\n break if e == '--'\n break if e == '__END_OF_EMAIL_MESSAGE__'\n\n # The line starts with \" \", continued from !\\n.\n e = e.lstrip if foldedline\n foldedline = false\n\n if e.end_with?('!')\n # ... long long line ...![\\n]\n e = e.chomp('!')\n foldedline = true\n end\n jsonstring << e\n end\n\n begin\n if RUBY_PLATFORM.start_with?('java')\n # java-based ruby environment like JRuby.\n require 'jrjackson'\n jsonobject = JrJackson::Json.load(jsonstring)\n\n # 'Message' => '{\"notificationType\":\"Bounce\",...\n jsonthings = JrJackson::Json.load(jsonobject['Message']) if jsonobject['Message']\n else\n # Matz' Ruby Implementation\n require 'oj'\n jsonobject = Oj.load(jsonstring)\n\n # 'Message' => '{\"notificationType\":\"Bounce\",...\n jsonthings = Oj.load(jsonobject['Message']) if jsonobject['Message']\n end\n jsonthings ||= jsonobject\n\n rescue StandardError => ce\n # Something wrong in decoding JSON\n warn ' ***warning: Failed to decode JSON: ' << ce.to_s\n return nil\n end\n\n return adapt(jsonthings)\n end",
"def scan_message(message)\n out = []\n out << 'recall_hold' if message =~ /Recall/i\n out << 'recall_hold' if message =~ /hold /\n out << 'borrow_direct' if message =~ /Borrow/\n out << 'ill' if message =~ /ILL/\n out << 'in_process' if message =~ /In Process/\n # ReCAP Partners\n out << 'offsite_valet' if message =~ /scsb/\n out\n end",
"def request_message\n return if @parts.empty?\n\n @request_message = Part.new do\n content_type 'multipart/related; type=\"text/xml\"'\n end\n\n soap_body = self.to_xml\n soap_message = Part.new do\n content_type 'text/xml; charset=utf-8'\n add_content_transfer_encoding\n body soap_body\n end\n soap_message.add_content_id \"<savon_soap_xml_part>\"\n @request_message.add_part(soap_message)\n @parts.each do |part|\n @request_message.add_part(part)\n end\n #puts @request_message\n @request_message\n end",
"def messages\n @messages ||= @message_list.map.with_index do |payload, index|\n Message.new(payload, @starting_channel_sequence + index)\n end\n end",
"def receive_message\n sqs = Aws::SQS::Client.new(region: ENV['AWS_REGION'])\n resp = sqs.receive_message(queue_url: ENV['SQS_ENDPOINT'])\n\n if resp.messages.count > 0\n process_message(resp.messages[0])\n end\n end",
"def read_interface \n \"\"\" Read messages from node(s) \"\"\"\n puts connected?\n arr = []\n arr2 = []\n\t str = String.new\n\t #data = arr[0]\n\t message = ZMQ::Message.create()\n\t #buffer = String.new\n\n Logger.instance.info(\"Waiting data...\")\n rc = @read_socket.recv_multipart(arr, arr2)\n #rc = @read_socket.recvmsg(message, flag = ZMQ::DONTWAIT)\n puts rc\n if rc == -1\n return nil\n end\n data = arr2[0].copy_out_string()\n data2 = data.dup()\n data[1] = data2[4]\n data[2] = data2[3]\n data[3] = data2[2]\n data[4] = data2[1]\n\t Logger.instance.info(data)\n read_interface_base(data)\n return data\n end",
"def messages()\n []\n end",
"def get_video_media_content_for_message(message_id)\n begin\n video_sql = \"SELECT * FROM mediacontent WHERE mediacontentid\";\n video_sql += \" IN (SELECT messagemediacontent.mediaid FROM messagemediacontent WHERE\";\n video_sql += \" messageid = #{message_id}) AND ( iPodVideo IS NOT NULL)\";\n video_sql += \" AND (ContentTypeID = 4 OR ContentTypeID = 1) AND (iPodVideo LIKE '%mp4')\";\n video_sql += \"AND iPodVideo!='' ORDER BY RecordDate ASC \";\n message_video_content_data = Immutable.dbh.execute(video_sql);\n\n return message_video_content_data;\n rescue DBI::DatabaseError => e\n Immutable.log.error \"Error code: #{e.err}\"\n Immutable.log.error \"Error message: #{e.errstr}\"\n Immutable.log.error \"Error SQLSTATE: #{e.state}\"\n abort('An error occurred while getting message video content data from DB, Check migration log for more details');\n end\n end",
"def to_s\n \"<TopicPartitionList: #{to_h}>\"\n end",
"def read_multipart(buffer = [])\n ZMQ.wait_readable(@socket) if ZMQ.evented?\n\n unless ::ZMQ::Util.resultcode_ok? @socket.recv_strings buffer\n raise IOError, \"error receiving ZMQ string: #{::ZMQ::Util.error_string}\"\n end\n buffer\n end",
"def restrict_msg_size\n if message.length > restriction\n message = message[0...restriction]\n end\n return message \n end",
"def get_dimming_elements(message)\n return message.values_at(* message.each_index.select(&:even?)) # Get even elements (dimming)\nend",
"def part_by_name(name)\n mbr.part.select { |i| i.name == name }.first\n end",
"def get_message\n @reply['message']\n end",
"def get_message\n db = SQLite3::Database.new(@fn)\n # db.busy_timeout=1000 # milliseconds?\n db.busy_timeout(1000) # milliseconds?\n db.transaction(:immediate)\n stmt = db.prepare(\"select msg_text from msg where user_id = ? order by id\")\n ps = Proc_sql.new();\n stmt.execute(@user_id){ |rs|\n ps.chew(rs)\n }\n stmt.close\n db.close()\n results = \"\"\n ps.loh.each { |hr|\n results.concat(\"\\n#{hr['msg_text']}\")\n }\n return results\n end",
"def message\n @message\n end",
"def message\n @values['message']\n end",
"def seperate_request_line()\n\t\t@stream.split(\"\\n\", 2)[0]\n\tend",
"def extract_message(item)\n # message = item[\"message\"]\n # timestamp = DateTime.parse(item[\"@timestamp\"]).strftime(\"%Y-%m-%d %H:%M:%S\") rescue nil\n # from = REGEX_EMAIL.match(REGEX_FROM_EMAIL.match(message)[0])[0] rescue nil\n # to = REGEX_EMAIL.match(REGEX_TO_EMAIL.match(message)[0])[0] rescue nil\n # status = REGEX_STATUS.match(message)[0].split(\"=\")[1] rescue nil\n # subject = REGEX_SUBJECT.match(message)[0].split(\" \")[1..-2].join(\" \") rescue nil\n # error_message = ( status == \"deferred\" || status == \"bounced\" ) ? ( REGEX_ERROR_MESSAGE.match(message)[0] rescue nil ) : nil\n { :timestamp => item[:timestamp],\n :status => item[:status],\n :from => item[:from] ,\n :to => item[:to] ,\n :subject => item[:subject],\n }.merge( item[:error_message] ? { error_message: item[:error_message].split(\" \")[1..-1].join(\" \") } : {})\n end",
"def got_MSG(message)\n @logger.info(\"got_MSG()\")\n @logger.info(\"got_MSG() - #{message['message']}\")\n self.fix_skiplist(message['channel'])\n @logger.info(\"got_MSG() - fix_skiplist()\")\n self.remove_from_skip_list(message['channel'], message['character'])\n @logger.info(\"got_MSG() - remove_from_skip_list()\")\n if message['message'] == '!skip'\n self.add_to_skip_list(message['channel'], message['character'])\n elsif message['message'] =~ /^!skip/\n person = message['message'].gsub(/^!skip/, '').strip\n self.add_to_skip_list(message['channel'], person)\n elsif message['message'] =~ /^!spin/\n @logger.info(\"got_MSG() - spinning the bottle\")\n players = self.spin_list(message['channel'], message['character'])\n @logger.info(\"got_MSG() - players: #{players}\")\n if players == []\n msg = \"/me can't find anyone to play with!\"\n else\n player = players.sample\n msg = \"/me spins around, and eventually lands on [b]#{player}[/b]\"\n end\n self.send('MSG',message['channel'],msg)\n else\n @logger.info(\"gotMSG() - parseFail\")\n end\n end",
"def send_other_kafka_message\n Rimless.message(data: { 'id' => 'id' }, topic: :test, schema: :include)\nend",
"def split_request_message(message)\n header_and_body = message.split(/\\n\\n/)\n if header_and_body[0]\n message_type = header_and_body[0].split(/\\n/)[0]\n header_element = header_to_hash(header_and_body[0])\n end\n return message_type, header_element, header_and_body[1]\n end",
"def mime_part\n message.mime_part\n end",
"def []( index )\n ret = nil\n if index.kind_of?(Range) || index.kind_of?(Numeric)\n ret = @segments[ index ]\n\n # JJL - support my PID-11.1 syntax\n elsif index.is_a?(String) && index.include?('-')\n (segment, delim, element)=index.partition('-')\n if matches=segment.match(/^(\\w+);(\\d+)/)\n segment=matches[1].to_sym\n index=matches[2].to_i\n else\n segment=segment.to_sym\n index=1\n end\n if @segments_by_name.has_key?(segment) && @segments_by_name[ segment ][index-1]\n if element.include?('.')\n (element, delim, item)=element.partition('.')\n element = segment==:MSH ? element.to_i - 1 : element.to_i\n ret = @segments_by_name[ segment ][index-1].e(element).to_s.split(@item_delim)[item.to_i-1]\n else\n element = segment==:MSH ? element.to_i - 1 : element.to_i\n ret = @segments_by_name[ segment ][index-1].e(element)\n end\n end\n # /JJL\n\n elsif (index.respond_to? :to_sym)\n ret = @segments_by_name[ index.to_sym ]\n ret = ret.first if ret && ret.length == 1\n end\n\n ret\n end",
"def make_sliced_file(flist)\n flist_sliced = []\n flist.each_with_index do |v, i|\n # 開始時のファイルはスライスしない\n if i == 0\n flist_sliced << v\n else\n tmp_file = \"/tmp/sound_#{i}.mp3\"\n silent_files = (Sound::SILENT_FILE_PATH + \" \") * i\n cmd = \"sox #{silent_files} #{v} #{tmp_file}\"\n result = `#{cmd}`\n flist_sliced << tmp_file\n end\n end\n return flist_sliced\n end",
"def lsp_read_message(io)\n @ext.data['lsp'].each_pair do |_k, v|\n next unless io == v.io\n\n headers, message = v.recv_message\n if headers == {}\n @logger.error \"server(#{v.server[:command]}) is not running\"\n v.status = :not_found\n # del_io_read_event(v.io)\n next\n end\n if message == nil\n @logger.error '[lsp] error'\n next\n end\n @logger.debug message.to_s\n if !message['id'].nil?\n # request or response\n id = message['id'].to_i\n if !v.request_buffer[id].nil?\n lsp_response(v, id, message)\n else # request?\n @logger.info '[LSP] recieve request???'\n @logger.info message.to_s\n end\n else # notification\n lsp_notification(v, message)\n end\n break\n end\n # end\n end",
"def hsdq_send(message)\n message = prepare_message message\n if valid_keys?(message) && valid_type?(message[:type])\n spark = build_spark(message)\n send_message message, spark\n else\n false\n end\n end",
"def message_content\n JSON.parse(body).with_indifferent_access\n end",
"def message\n @attributes[:message]\n end",
"def cutMsg(msg)\n if msg.length>160\n \n msg_arr = msg.split(\" \")\n msg_single = \"\"\n msg_cut = []\n for i in 0..msg_arr.count-1\n msg_single +=(msg_arr[i] + \" \")\n #cut message if longer than 160 char\n if msg_single.length>160\n #starting to build each message\n msg_single = msg_single[0..msg_single.length-1-(msg_arr[i].length+1)] # if over 160, cut the last word out\n msg_cut.push msg_single\n puts msg_single.length \n msg_single = msg_arr[i] + \" \" #start the next array element with the word just cut out\n end\n end\n msg_cut.push(msg[msg_cut.join(\" \").length-2..msg.length])\n else\n msg_cut = [msg]\n end\n end",
"def send_ack(spark)\n return unless ['request', :request].include? spark[:type]\n ack_msg = spark.merge sent_to: spark[:sender], sender: channel\n hsdq_send_ack ack_msg\n end",
"def message(params)\n params[\"text\"].scan(/\\w+:\\w+\\s(.*)/, 1)\n end",
"def message\n @message\n end",
"def do_something_with_BHS(msg)\n # puts \"My \" << msg[0].e0 << \" looks like this: \" << msg.to_s\nend",
"def messages\n msgs = []\n favorites.each do |fav|\n fav.messages.each do |message|\n msgs << message\n end\n end\n msgs\n end",
"def part(index)\n @parts[index]\n end",
"def decode(message)\n start_time= Time.now\n @message = message\n qio = QIO.new(@message)\n begin\n @length, @message_type = qio.message_header()\n @value = qio.read_item()\n rescue QException => qe\n @exception = qe\n end\n end",
"def get_part\n @part\n end",
"def messages_payload\n messages.order(created_at: :desc).includes(:user).map do |message|\n {\n message_id: message.id,\n username: message.user.username,\n channel_name: message.channel.name,\n content: message.content,\n created_at: message.created_at\n }\n end\n end",
"def enqueue_message(bytes, timestamp)\n if bytes.first.eql?(0xF0) || !@sysex_buffer.empty?\n @sysex_buffer += bytes\n if bytes.last.eql?(0xF7)\n bytes = @sysex_buffer.dup\n @sysex_buffer.clear\n end\n end\n # SINM ADDED\n @sysex_buffer.empty? ? get_message_formatted(bytes, timestamp) : nil\n # SINM COMMENTED OUT\n # @buffer << get_message_formatted(bytes, timestamp) if @sysex_buffer.empty?\n # @buffer\n end",
"def text\n @parts.join\n end",
"def unpack(message)\n payload = super\n if(self.is_a?(Jackal::Cfn::Resource))\n begin\n if(payload['Message'])\n payload = MultiJson.load(payload['Message']).to_smash\n payload = transform_parameters(payload)\n payload[:origin_type] = message[:message].get('Body', 'Type')\n payload[:origin_subject] = message[:message].get('Body', 'Subject')\n payload[:request_type] = snakecase(payload[:request_type])\n payload\n else\n payload.to_smash.fetch('Attributes', 'Body', payload.to_smash.fetch('Body', payload.to_smash))\n end\n rescue MultiJson::ParseError\n # Not our expected format so return empty payload\n Smash.new\n end\n else\n payload.to_smash.fetch('Attributes', 'Body', payload.to_smash.fetch('Body', payload.to_smash))\n end\n end",
"def message_from(response)\n response[:message]\n end",
"def serialize(message)\n message.to_msgpack\n end",
"def split_send(content)\n send_multiple(Discordrb.split_message(content))\n nil\n end",
"def __getobj__ #:nodoc:\n @sms_message ||= processed_smser.message\n end",
"def get_messages(&block)\n get(:messages) do |msgs|\n msgs = msgs.split ', '\n msgs.map! { |id| SkypeMessage.withId @skype, id.to_i }\n block.to_proc.call msgs\n end\n end"
] |
[
"0.64653647",
"0.6004747",
"0.53561693",
"0.5301743",
"0.5076641",
"0.50756043",
"0.49699196",
"0.49670097",
"0.4813249",
"0.4757134",
"0.4751784",
"0.47315294",
"0.47273046",
"0.471648",
"0.47117364",
"0.46999922",
"0.46761626",
"0.46488327",
"0.46466285",
"0.46375796",
"0.46269053",
"0.46250343",
"0.4581707",
"0.4528907",
"0.449928",
"0.44687936",
"0.44687936",
"0.44676173",
"0.44676173",
"0.44546565",
"0.44522905",
"0.44477853",
"0.44380146",
"0.44286928",
"0.44284296",
"0.44212356",
"0.44203508",
"0.44021124",
"0.44019938",
"0.43969247",
"0.43884438",
"0.43744618",
"0.4365525",
"0.4365525",
"0.4350449",
"0.43484297",
"0.43442896",
"0.43424106",
"0.43424106",
"0.4341937",
"0.43415734",
"0.43374172",
"0.43361443",
"0.43275434",
"0.43266302",
"0.4312997",
"0.43064493",
"0.43053406",
"0.4296572",
"0.42956766",
"0.4294489",
"0.42915675",
"0.42888978",
"0.4285878",
"0.42842636",
"0.42822248",
"0.42797974",
"0.42740875",
"0.42645764",
"0.42627877",
"0.42399305",
"0.42279553",
"0.4226603",
"0.42160463",
"0.42148215",
"0.4213433",
"0.42133152",
"0.42044544",
"0.41988036",
"0.41954052",
"0.41825718",
"0.4180025",
"0.41788462",
"0.41777566",
"0.4177415",
"0.41757837",
"0.41724578",
"0.4170888",
"0.417033",
"0.41624907",
"0.41612083",
"0.41544488",
"0.41541758",
"0.41503122",
"0.41437125",
"0.41428143",
"0.41398796",
"0.41353622",
"0.41353437",
"0.41349158"
] |
0.5122599
|
4
|
Entry point for the task to process, this is what is executed in the threads when a message is pulled. Pull the burst (line with the request or response) from the the hash Pull the context related to a response if it exist Set values for the next hop context in case of a request. Call one of the 5 methods (request, ack, callback, feedback, error) in your hsdqXxx class (or the placeholder) based on the message type
|
def sparkle(spark, options)
puts spark.inspect
burst, ctx_burst = get_burst spark, options
context ctx_burst
case spark[:type].to_sym
when :ack
hsdq_ack burst, context
when :callback
hsdq_callback burst, context
when :feedback
hsdq_feedback burst, context
when :error
hsdq_error burst, context
when :request
set_context spark
hsdq_request burst, context
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def input_thread_step\n case (obj = read_from_wire)\n when Block\n handle_block obj\n when Message\n handle_message obj\n else\n raise \"don't know what to do with #{obj.inspect}\"\n end\n\n ## to enable immediate response, if there are no rate limits,\n ## we'll send the blocks and reqs right here. otherwise, the\n ## controller will call this at intervals.\n send_blocks_and_reqs if @controller.dlratelim.nil? && @controller.ulratelim.nil?\n end",
"def run\n super\n\n config = _get_task_config \"control/collection_processor\"\n\n @sqs = Aws::SQS::Client.new({\n region: 'us-east-1',\n access_key_id: config[\"aws_access_key\"],\n secret_access_key: config[\"aws_secret_access_key\"]\n })\n\n @control_queue_uri = config[\"control_queue_uri\"]\n @status_queue_uri = config[\"status_queue_uri\"]\n sleep_interval = config[\"sleep\"] || 10\n max_seconds = config[\"max_seconds\"] || 36000\n\n handler = config[\"handler\"]\n\n # connect to the configured amazon queue & Grab one\n _set_status :available, nil\n instruction_data = nil\n iteration = 0\n while true\n\n # loop until we have something\n while !instruction_data\n\n _log \"Attempting to get an instruction from the queue!\"\n instruction_data = _get_queued_instruction # try again\n\n # kick it off if we got one, and break out of this loop\n if instruction_data\n _log \"[+] Executing #{instruction_data[\"id\"]} for #{sleep_interval} seconds! (expire in: ~#{max_seconds - (iteration * sleep_interval) }s)\"\n _set_status :start, \"#{instruction_data[\"id\"]}\"\n _execute_instruction(instruction_data)\n else\n _log \"Nothing to do, waiting!\"\n sleep sleep_interval\n end\n\n end\n\n # hold tight\n sleep sleep_interval\n\n # determine how we're doing\n task_count_left = _tasks_left\n seconds_elapsed = iteration * sleep_interval\n done = (iteration > 10 && task_count_left == 0 ) || (seconds_elapsed > max_seconds)\n\n _log \"Seconds elapsed: #{seconds_elapsed}\" if iteration % 10 == 0\n _log \"Tasks left: #{task_count_left}\" if iteration % 10 == 0\n\n if done\n _log_good \"Done with #{instruction_data[\"id\"]} after #{seconds_elapsed}s\"\n _set_status :end, {\n \"id\" => \"#{instruction_data[\"id\"]}\",\n \"elapsed\" => \"#{seconds_elapsed}\",\n \"entities\" => \"#{Intrigue::Model::Project.first(:name => instruction_data[\"id\"]).entities.count}\"\n }\n\n _log_good \"#{instruction_data[\"id\"]}\"\n _run_handlers instruction_data\n _set_status :sent, \"#{instruction_data[\"id\"]}\"\n\n instruction_data = nil\n iteration = -1\n\n end\n\n iteration +=1\n end\n\n end",
"def run\n\t \tbegin \n\t \twrite_command_status(@cmd_queue_0)\n\t \t\n\t \t@log.info \"Processing command queue...\"\n\t \tloop do\n\t \t\tbegin\n\t \t\t\tstr = listen\n\t \t\trescue EOFError\n\t \t\t\t@log.error \"No more messages from pump\"\n\t \t\t\tbreak\n\t \t\tend\n\n\t \t\trep = parse_response(str)\n\n\t \t\t# Look at command response and wait or proceed on queue\n\n\t \t\t# Is it a status message\n\t \t\t# Yes\n\t \t\tif rep[:status]\n\t\t\t\tif process_status(rep)\n\t\t\t\t break\n\t\t\t\tend\n\t \t\t# No\n\t \t\telsif !rep[:status]\n\t \t\t\tprocess_command(rep)\n\t \t\telse\n\t \t\t\t@log.error \"Unknown message type\"\n\t \t\tend\n\t \tend\n\t \t@log.info \"...command queue complete\"\n\n\t \trescue IRB::Abort\n\t \t\t@log.error \"Abort\"\n\t\t\tsleep(0.25)\n\t\t\twrite_stop\n\t\t\t#flush comms?\n\t \trescue Interrupt\n\t \t\t@log.info \"Interupt\"\n\t \t\t#write_stop\n\t \tensure \n\t \t\t@log.info \"Closing\"\n\t\t\t#write_stop\n\t \tend\n\n\t end",
"def run(&callback)\n @serializer.run do |msg|\n debug(\"received #{msg.inspect}\")\n kind, *payload = msg\n\n case kind\n when 0\n handle_request(payload, callback)\n when 1\n handle_response(payload)\n when 2\n handle_notification(payload, callback)\n end\n end\n rescue => e\n fatal(\"got unexpected error #{e.inspect}\")\n debug(e.backtrace.join(\"\\n\"))\n end",
"def processMessage\n\n loop do\n\n input = @processMessageQueue.pop\n\n Log::debug \"#{__method__}: #{input}\"\n\n case input[:type]\n when :send\n\n id = input[:id]\n to = input[:to]\n from = input[:from]\n\n output = packMessage(to, input[:message])\n\n if output\n \n @processJobQueue.push({\n :type=>:notifyPacked,\n :id=>id,\n :time => Time.now,\n :counter => output[:counter],\n :message => {\n :to => to,\n :from => from,\n :message => output[:data],\n :ip => input[:ip],\n :port => input[:port]\n } \n })\n\n else\n\n @processJobQueue.push({\n :type=>:notifyNotSent,\n :id=>id,\n :time => Time.now\n })\n\n end\n\n when :receive\n\n id = input[:id]\n \n result = unpackMessage(input[:data])\n\n if result\n\n case result[:recipient]\n when :PR6_RECIPIENT_CLIENT\n\n @processJobQueue.push({\n :type => :processMessage,\n :from => result[:from],\n :to => result[:to],\n :message => result[:data] \n })\n\n when :PR6_RECIPIENT_SERVER\n\n association = AssociationRecord.read(result[:to], result[:to], result[:from])\n\n if association\n\n output = packMessage(result[:from], Server.new(association, @objects).input(result[:counter], result[:data]))\n \n if output.size > 0\n\n @outputQueue.push({\n :to => result[:from],\n :from => result[:to],\n :ip => input[:ip],\n :port => input[:port],\n :message => output[:data]\n })\n\n end\n\n else\n\n Log::warning \"#{__method__}: assocation record removed since last read\"\n \n end\n\n else\n raise\n end\n\n end\n\n else\n raise \"unknown message type\"\n end\n\n end\n\n end",
"def start\n receive(IO.new(3), IO.new(4)) do |f|\n f.when([:call, Array]) do |args|\n method = args[0]\n retype = args[1]\n args = args[2..-1]\n f.send! self.dispatch(method, retype, args)\n exit if Chassis.exit_after_current_dispatch\n f.receive_loop\n end\n \n f.when(:config) do\n f.send! [:result, self.config]\n f.receive_loop\n end\n \n f.when(:api) do\n f.send! [:result, self.api]\n f.receive_loop\n end\n \n f.when(:ping) do\n f.send! :pong\n f.receive_loop\n end\n \n f.when(:quit) do\n exit(0)\n end\n end\n end",
"def perform_feed_job(payload)\n # A lot of refactoring needed\n if payload[:Header][:Type] == Constants::LSPORTS_MSG_TYPE[\"Heartbeat\"]\n Rails.cache.write(key_name, @conn.status, expires_in: 15.seconds)\n Rails.logger.info \"#{key_name} connection status: #{@conn.status}\"\n # Rails.logger.info payload\n elsif payload[:Header][:Type] == Constants::LSPORTS_MSG_TYPE[\"Market Update\"] # 3 Market update\n payload[:Body][:Events].each do |fixture|\n if inplay\n LS::Inplay::MatchMarketsOddsChangeJob.perform_later(fixture)\n else\n LS::Prematch::MatchMarketsOddsChangeJob.perform_later(fixture)\n end\n end\n elsif payload[:Header][:Type] == Constants::LSPORTS_MSG_TYPE[\"Fixture metadata\"]\n payload[:Body][:Events].each do |fixture|\n LS::Inplay::UpdateMatadataJob.perform_later(fixture)\n end\n elsif payload[:Header][:Type] == Constants::LSPORTS_MSG_TYPE[\"Settlements\"]\n LS::FeedResultJob.perform_later(payload, 'listener_settlement')\n else\n if payload[:Header][:Type] == Constants::LSPORTS_MSG_TYPE[\"Livescore\"] # 2 Livescore update\n payload[:Body][:Events].each do |fixture|\n # if OddStoreService.odd_store == :redis\n single_status_update(fixture)\n # else\n # push_to_dynamic_queue(fixture)\n # end\n end\n end\n # Below call not needed for prematch\n if inplay\n LS::AMQP::FeedJob.perform_later(\n inplay_queue, payload[:Header][:ServerTimestamp],\n payload\n )\n end\n end\n end",
"def execute\n previous_time = Time.now\n\n publish_message(message(@channel, @data))\n\n @response_time = (Time.now - previous_time) * 1000 # Miliseconds\n @response_code = 1\n rescue Exception => e\n @response_code = @response_time = nil\n @response_body = e.message\n 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 process_msgs\n end",
"def run\n begin\n loop do\n command = @queue.pop\n start_time = Time.now\n # Commands are defined in command modules\n command['command'] == 'STOP' ? break : self.send(command['method'].to_sym, @agent, @state)\n end_time = Time.now\n diff = end_time - start_time\n @responses << {id: @id, command: command['command'], method: command['method'], step: command['step'], status: @agent.page.code, time: diff}\n break unless ['200', '301', '302'].include? @agent.page.code\n end\n rescue Exception => e\n puts \"Something went wrong! Bot: #{@id}, #{e}\"\n @responses << {id: @id, status: 'dead'}\n end\n end",
"def dispatch!\n \n # negotiates initial configuration\n @meta = self.negotiate!\n \n # dispatches hash set to the server\n self.dispatch_hashing!\n self.dispatch_hashset!\n \n # dispatches orders\n self.dispatch_orders!\n \n # dispatches messages\n self.handle_messages!\n \n end",
"def handler\r\n\t loop do \r\n\t socket = @rqueue.pop\r\n\t req = Request.new socket \r\n\t if req.broadcast == true\r\n\t handle_broadcast req \r\n\t else\r\n\t handle_listen req\r\n\t end\r\n\t \r\n\t end\r\n \tend",
"def handle_ack_msg( their_msg )\r\n begin\r\n if their_msg.startup_ack\r\n super\r\n send_next_case\r\n warn \"Started, shouldn't see this again...\" if self.class.debug\r\n return\r\n end\r\n if their_msg.result\r\n self.class.lookup[:results][their_msg.result]||=0\r\n self.class.lookup[:results][their_msg.result]+=1\r\n if their_msg.result=='crash' and their_msg.crashdetail\r\n crashdetail=their_msg.crashdetail\r\n self.class.lookup[:buckets][DetailParser.hash( crashdetail )]=true\r\n # You might want to clear this when outputting status info.\r\n self.class.queue[:bugs] << DetailParser.long_desc( crashdetail )\r\n # Just initials - NOT EXPLOITABLE -> NE etc\r\n classification=DetailParser.classification( crashdetail).split.map {|e| e[0]}.join\r\n self.class.lookup[:classifications][classification]||=0\r\n self.class.lookup[:classifications][classification]+=1\r\n end\r\n else\r\n # Don't cancel the ack timeout here - this is the first ack\r\n # We wait to get the full result, post delivery.\r\n super\r\n send_next_case\r\n end\r\n rescue\r\n raise RuntimeError, \"#{COMPONENT}: Unknown error. #{$!}\"\r\n end\r\n end",
"def post_init\n @builder, @parser = Hatetepe::Builder.new, Hatetepe::Parser.new\n @builder.on_write << method(:send_data)\n # @builder.on_write {|data| p \"|--> #{data}\" }\n @parser.on_response << method(:receive_response)\n\n @queue = []\n\n @app = proc {|request| send_request(request) }\n\n self.comm_inactivity_timeout = config[:timeout]\n self.pending_connect_timeout = config[:connect_timeout]\n\n start_tls if config[:ssl]\n end",
"def dispatch(msg)\n case msg.command\n when LINK_ESTABLISHING\n ret=on_link_establishing(msg)\n when LINK_ESTABLISHED\n ret=on_link_established(msg)\n when LINK_FAILED\n ret=on_link_failed(msg)\n when LINK_CLOSING\n ret=on_link_closing(msg)\n when LINK_CLOSED\n ret=on_link_closed(msg)\n when RECV_MESSAGE\n ret=on_recv_message(msg)\n when RECV_MESSAGE_BROKEN\n ret=on_recv_message_broken(msg)\n when RECV_MESSAGE_KILL\n ret=on_recv_message_kill(msg)\n when RECV_MESSAGE_PING\n ret=on_recv_message_ping(msg)\n when RECV_MESSAGE_PONG\n ret=on_recv_message_pong(msg)\n when RECV_MESSAGE_ERROR\n ret=on_recv_message_error(msg)\n when RECV_MESSAGE_NOTICE\n ret=on_recv_message_notice(msg)\n when RECV_RPL_INIT\n ret=on_recv_rpl_init(msg)\n when RECV_RPL_TRACELINK\n ret=on_recv_rpl_tracelink(msg)\n when RECV_RPL_TRACECONNECTING\n ret=on_recv_rpl_traceconnecting(msg)\n when RECV_RPL_TRACEHANDSHAKE\n ret=on_recv_rpl_tracehandshake(msg)\n when RECV_RPL_TRACEUNKNOWN\n ret=on_recv_rpl_traceunknown(msg)\n when RECV_RPL_TRACEOPERATOR\n ret=on_recv_rpl_traceoperator(msg)\n when RECV_RPL_TRACEUSER\n ret=on_recv_rpl_traceuser(msg)\n when RECV_RPL_TRACESERVER\n ret=on_recv_rpl_traceserver(msg)\n when RECV_RPL_TRACENEWTYPE\n ret=on_recv_rpl_tracenewtype(msg)\n when RECV_RPL_STATSLINKINF\n ret=on_recv_rpl_statslinkinf(msg)\n when RECV_RPL_STATSCOMMANDS\n ret=on_recv_rpl_statscommands(msg)\n when RECV_RPL_STATSCLINE\n ret=on_recv_rpl_statscline(msg)\n when RECV_RPL_STATSNLINE\n ret=on_recv_rpl_statsnline(msg)\n when RECV_RPL_STATSILINE\n ret=on_recv_rpl_statsiline(msg)\n when RECV_RPL_STATSKLINE\n ret=on_recv_rpl_statskline(msg)\n when RECV_RPL_STATSYLINE\n ret=on_recv_rpl_statsyline(msg)\n when RECV_RPL_ENDOFSTATS\n ret=on_recv_rpl_endofstats(msg)\n when RECV_RPL_UMODEIS\n ret=on_recv_rpl_umodeis(msg)\n when RECV_RPL_STATSLLINE\n ret=on_recv_rpl_statslline(msg)\n when RECV_RPL_STATSUPTIME\n ret=on_recv_rpl_statsuptime(msg)\n when RECV_RPL_STATSOLINE\n ret=on_recv_rpl_statsoline(msg)\n when RECV_RPL_STATSHLINE\n ret=on_recv_rpl_statshline(msg)\n when RECV_RPL_LUSERCLIENT\n ret=on_recv_rpl_luserclient(msg)\n when RECV_RPL_LUSEROP\n ret=on_recv_rpl_luserop(msg)\n when RECV_RPL_LUSERUNKNOWN\n ret=on_recv_rpl_luserunknown(msg)\n when RECV_RPL_LUSERCHANNELS\n ret=on_recv_rpl_luserchannels(msg)\n when RECV_RPL_LUSERME\n ret=on_recv_rpl_luserme(msg)\n when RECV_RPL_ADMINME\n ret=on_recv_rpl_adminme(msg)\n when RECV_RPL_ADMINLOC1\n ret=on_recv_rpl_adminloc1(msg)\n when RECV_RPL_ADMINLOC2\n ret=on_recv_rpl_adminloc2(msg)\n when RECV_RPL_ADMINEMAIL\n ret=on_recv_rpl_adminemail(msg)\n when RECV_RPL_TRACELOG\n ret=on_recv_rpl_tracelog(msg)\n when RECV_RPL_NONE\n ret=on_recv_rpl_none(msg)\n when RECV_RPL_AWAY\n ret=on_recv_rpl_away(msg)\n when RECV_RPL_USERHOST\n ret=on_recv_rpl_userhost(msg)\n when RECV_RPL_ISON\n ret=on_recv_rpl_ison(msg)\n when RECV_RPL_UNAWAY\n ret=on_recv_rpl_unaway(msg)\n when RECV_RPL_NOWAWAY\n ret=on_recv_rpl_nowaway(msg)\n when RECV_RPL_WHOISUSER\n ret=on_recv_rpl_whoisuser(msg)\n when RECV_RPL_WHOISSERVER\n ret=on_recv_rpl_whoisserver(msg)\n when RECV_RPL_WHOISOPERATOR\n ret=on_recv_rpl_whoisoperator(msg)\n when RECV_RPL_WHOWASUSER\n ret=on_recv_rpl_whowasuser(msg)\n when RECV_RPL_ENDOFWHO\n ret=on_recv_rpl_endofwho(msg)\n when RECV_RPL_WHOISIDLE\n ret=on_recv_rpl_whoisidle(msg)\n when RECV_RPL_ENDOFWHOIS\n ret=on_recv_rpl_endofwhois(msg)\n when RECV_RPL_WHOISCHANNELS\n ret=on_recv_rpl_whoischannels(msg)\n when RECV_RPL_LISTSTART\n ret=on_recv_rpl_liststart(msg)\n when RECV_RPL_LIST\n ret=on_recv_rpl_list(msg)\n when RECV_RPL_LISTEND\n ret=on_recv_rpl_listend(msg)\n when RECV_RPL_CHANNELMODEIS\n ret=on_recv_rpl_channelmodeis(msg)\n when RECV_RPL_NOTOPIC\n ret=on_recv_rpl_notopic(msg)\n when RECV_RPL_TOPIC\n ret=on_recv_rpl_topic(msg)\n when RECV_RPL_INVITING\n ret=on_recv_rpl_inviting(msg)\n when RECV_RPL_SUMMONING\n ret=on_recv_rpl_summoning(msg)\n when RECV_RPL_VERSION\n ret=on_recv_rpl_version(msg)\n when RECV_RPL_WHOREPLY\n ret=on_recv_rpl_whoreply(msg)\n when RECV_RPL_NAMREPLY\n ret=on_recv_rpl_namreply(msg)\n when RECV_RPL_LINKS\n ret=on_recv_rpl_links(msg)\n when RECV_RPL_ENDOFLINKS\n ret=on_recv_rpl_endoflinks(msg)\n when RECV_RPL_ENDOFNAME\n ret=on_recv_rpl_endofname(msg)\n when RECV_RPL_BANLIST\n ret=on_recv_rpl_banlist(msg)\n when RECV_RPL_ENDOFBANLIST\n ret=on_recv_rpl_endofbanlist(msg)\n when RECV_RPL_ENDOFWHOWAS\n ret=on_recv_rpl_endofwhowas(msg)\n when RECV_RPL_INFO\n ret=on_recv_rpl_info(msg)\n when RECV_RPL_MOTD\n ret=on_recv_rpl_motd(msg)\n when RECV_RPL_ENDOFINFO\n ret=on_recv_rpl_endofinfo(msg)\n when RECV_RPL_MOTDSTART\n ret=on_recv_rpl_motdstart(msg)\n when RECV_RPL_ENDOFMOTD\n ret=on_recv_rpl_endofmotd(msg)\n when RECV_RPL_YOUREOPER\n ret=on_recv_rpl_youreoper(msg)\n when RECV_RPL_REHASHING\n ret=on_recv_rpl_rehashing(msg)\n when RECV_RPL_TIME\n ret=on_recv_rpl_time(msg)\n when RECV_RPL_USERS\n ret=on_recv_rpl_users(msg)\n when RECV_RPL_ENDOFUSERS\n ret=on_recv_rpl_endofusers(msg)\n when RECV_RPL_NOUSERS\n ret=on_recv_rpl_nousers(msg)\n when RECV_ERR_NOSUCHNICK\n ret=on_recv_err_nosuchnick(msg)\n when RECV_ERR_NOSUCHSERVE\n ret=on_recv_err_nosuchserve(msg)\n when RECV_ERR_NOSUCHCHANNEL\n ret=on_recv_err_nosuchchannel(msg)\n when RECV_ERR_CANNOTSENDTOCHAN\n ret=on_recv_err_cannotsendtochan(msg)\n when RECV_ERR_TOOMANYCHANNELS\n ret=on_recv_err_toomanychannels(msg)\n when RECV_ERR_WASNOSUCHNICK\n ret=on_recv_err_wasnosuchnick(msg)\n when RECV_ERR_TOOMANYTARGETS\n ret=on_recv_err_toomanytargets(msg)\n when RECV_ERR_NOORIGIN\n ret=on_recv_err_noorigin(msg)\n when RECV_ERR_NORECIPIENT\n ret=on_recv_err_norecipient(msg)\n when RECV_ERR_NOTEXTTOSEND\n ret=on_recv_err_notexttosend(msg)\n when RECV_ERR_NOTOPLEVE\n ret=on_recv_err_notopleve(msg)\n when RECV_ERR_WILDTOPLEVEL\n ret=on_recv_err_wildtoplevel(msg)\n when RECV_ERR_UNKNOWNCOMMAND\n ret=on_recv_err_unknowncommand(msg)\n when RECV_ERR_NOMOTD\n ret=on_recv_err_nomotd(msg)\n when RECV_ERR_NOADMININFO\n ret=on_recv_err_noadmininfo(msg)\n when RECV_ERR_FILEERROR\n ret=on_recv_err_fileerror(msg)\n when RECV_ERR_NONICKNAMEGIVEN\n ret=on_recv_err_nonicknamegiven(msg)\n when RECV_ERR_ERRONEUSNICKNAME\n ret=on_recv_err_erroneusnickname(msg)\n when RECV_ERR_NICKNAMEINUSE\n ret=on_recv_err_nicknameinuse(msg)\n when RECV_ERR_NICKCOLLISION\n ret=on_recv_err_nickcollision(msg)\n when RECV_ERR_USERNOTINCHANNEL\n ret=on_recv_err_usernotinchannel(msg)\n when RECV_ERR_NOTONCHANNE\n ret=on_recv_err_notonchanne(msg)\n when RECV_ERR_USERONCHANNEL\n ret=on_recv_err_useronchannel(msg)\n when RECV_ERR_NOLOGIN\n ret=on_recv_err_nologin(msg)\n when RECV_ERR_SUMMONDISABLED\n ret=on_recv_err_summondisabled(msg)\n when RECV_ERR_USERSDISABLED\n ret=on_recv_err_usersdisabled(msg)\n when RECV_ERR_NOTREGISTERED\n ret=on_recv_err_notregistered(msg)\n when RECV_ERR_NEEDMOREPARAM\n ret=on_recv_err_needmoreparam(msg)\n when RECV_ERR_ALREADYREGISTRE\n ret=on_recv_err_alreadyregistre(msg)\n when RECV_ERR_NOPERMFORHOST\n ret=on_recv_err_nopermforhost(msg)\n when RECV_ERR_PASSWDMISMATCH\n ret=on_recv_err_passwdmismatch(msg)\n when RECV_ERR_YOUREBANNEDCREEP\n ret=on_recv_err_yourebannedcreep(msg)\n when RECV_ERR_KEYSET\n ret=on_recv_err_keyset(msg)\n when RECV_ERR_CHANNELISFULL\n ret=on_recv_err_channelisfull(msg)\n when RECV_ERR_UNKNOWNMODE\n ret=on_recv_err_unknownmode(msg)\n when RECV_ERR_INVITEONLYCHAN\n ret=on_recv_err_inviteonlychan(msg)\n when RECV_ERR_BANNEDFROMCHAN\n ret=on_recv_err_bannedfromchan(msg)\n when RECV_ERR_BADCHANNELKEY\n ret=on_recv_err_badchannelkey(msg)\n when RECV_ERR_NOPRIVILEGES\n ret=on_recv_err_noprivileges(msg)\n when RECV_ERR_CHANOPRIVSNEEDED\n ret=on_recv_err_chanoprivsneeded(msg)\n when RECV_ERR_CANTKILLSERVER\n ret=on_recv_err_cantkillserver(msg)\n when RECV_ERR_NOOPERHOST\n ret=on_recv_err_nooperhost(msg)\n when RECV_ERR_UMODEUNKNOWNFLAG\n ret=on_recv_err_umodeunknownflag(msg)\n when RECV_ERR_USERSDONTMATCH\n ret=on_recv_err_usersdontmatch(msg)\n when RECV_CMND_UNKNOWN\n ret=on_recv_cmnd_unknown(msg)\n when RECV_CMND_PASS\n ret=on_recv_cmnd_pass(msg)\n when RECV_CMND_NICK\n ret=on_recv_cmnd_nick(msg)\n when RECV_CMND_USER\n ret=on_recv_cmnd_user(msg)\n when RECV_CMND_SERVER\n ret=on_recv_cmnd_server(msg)\n when RECV_CMND_OPER\n ret=on_recv_cmnd_oper(msg)\n when RECV_CMND_QUIT\n ret=on_recv_cmnd_quit(msg)\n when RECV_CMND_SQUIT\n ret=on_recv_cmnd_squit(msg)\n when RECV_CMND_JOIN\n ret=on_recv_cmnd_join(msg)\n when RECV_CMND_PART\n ret=on_recv_cmnd_part(msg)\n when RECV_CMND_MODE\n ret=on_recv_cmnd_mode(msg)\n when RECV_CMND_TOPIC\n ret=on_recv_cmnd_topic(msg)\n when RECV_CMND_NAMES\n ret=on_recv_cmnd_names(msg)\n when RECV_CMND_LIST\n ret=on_recv_cmnd_list(msg)\n when RECV_CMND_INVITE\n ret=on_recv_cmnd_invite(msg)\n when RECV_CMND_KICK\n ret=on_recv_cmnd_kick(msg)\n when RECV_CMND_VERSION\n ret=on_recv_cmnd_version(msg)\n when RECV_CMND_STATAS\n ret=on_recv_cmnd_statas(msg)\n when RECV_CMND_LINK\n ret=on_recv_cmnd_link(msg)\n when RECV_CMND_TIME\n ret=on_recv_cmnd_time(msg)\n when RECV_CMND_CONNECT\n ret=on_recv_cmnd_connect(msg)\n when RECV_CMND_TRACE\n ret=on_recv_cmnd_trace(msg)\n when RECV_CMND_ADMIN\n ret=on_recv_cmnd_admin(msg)\n when RECV_CMND_INFO\n ret=on_recv_cmnd_info(msg)\n when RECV_CMND_PRIVMSG\n ret=on_recv_cmnd_privmsg(msg)\n when RECV_CMND_NOTICE\n ret=on_recv_cmnd_notice(msg)\n when RECV_CMND_WHO\n ret=on_recv_cmnd_who(msg)\n when RECV_CMND_WHOIS\n ret=on_recv_cmnd_whois(msg)\n when RECV_CMND_WHOWAS\n ret=on_recv_cmnd_whowas(msg)\n when RECV_CMND_KILL\n ret=on_recv_cmnd_kill(msg)\n when RECV_CMND_PING\n ret=on_recv_cmnd_ping(msg)\n when RECV_CMND_PONG\n ret=on_recv_cmnd_pong(msg)\n when RECV_CMND_ERROR\n ret=on_recv_cmnd_error(msg)\n when RECV_CMND_AWAY\n ret=on_recv_cmnd_away(msg)\n when RECV_CMND_REHASH\n ret=on_recv_cmnd_rehash(msg)\n when RECV_CMND_RESTART\n ret=on_recv_cmnd_restart(msg)\n when RECV_CMND_SUMMON\n ret=on_recv_cmnd_summon(msg)\n when RECV_CMND_USERS\n ret=on_recv_cmnd_users(msg)\n when RECV_CMND_WALLOPS\n ret=on_recv_cmnd_wallops(msg)\n when RECV_CMND_USERHOST\n ret=on_recv_cmnd_userhost(msg)\n when RECV_CMND_ISON\n ret=on_recv_cmnd_ison(msg)\n when RECV_CMND_CTCP_QUERY\n ret=on_recv_cmnd_ctcp_query(msg)\n when RECV_CMND_CTCP_QUERY_UNKNOWN\n ret=on_recv_cmnd_ctcp_query_unknown(msg)\n when RECV_CMND_CTCP_QUERY_PING\n ret=on_recv_cmnd_ctcp_query_ping(msg)\n when RECV_CMND_CTCP_QUERY_ECHO\n ret=on_recv_cmnd_ctcp_query_echo(msg)\n when RECV_CMND_CTCP_QUERY_TIME\n ret=on_recv_cmnd_ctcp_query_time(msg)\n when RECV_CMND_CTCP_QUERY_VERSION\n ret=on_recv_cmnd_ctcp_query_version(msg)\n when RECV_CMND_CTCP_QUERY_CLIENTINFO\n ret=on_recv_cmnd_ctcp_query_clientinfo(msg)\n when RECV_CMND_CTCP_QUERY_USERINFO\n ret=on_recv_cmnd_ctcp_query_userinfo(msg)\n when RECV_CMND_CTCP_QUERY_ACTION\n ret=on_recv_cmnd_ctcp_query_action(msg)\n when RECV_CMND_CTCP_QUERY_DCC\n ret=on_recv_cmnd_ctcp_query_dcc(msg)\n when RECV_CMND_CTCP_ANSWER\n ret=on_recv_cmnd_ctcp_answer(msg)\n when RECV_CMND_CTCP_ANSWER_UNKNOWN\n ret=on_recv_cmnd_ctcp_answer_unknown(msg)\n when RECV_CMND_CTCP_ANSWER_PING\n ret=on_recv_cmnd_ctcp_answer_ping(msg)\n when RECV_CMND_CTCP_ANSWER_ECHO\n ret=on_recv_cmnd_ctcp_answer_echo(msg)\n when RECV_CMND_CTCP_ANSWER_TIME\n ret=on_recv_cmnd_ctcp_answer_time(msg)\n when RECV_CMND_CTCP_ANSWER_VERSION\n ret=on_recv_cmnd_ctcp_answer_version(msg)\n when RECV_CMND_CTCP_ANSWER_CLIENTINFO\n ret=on_recv_cmnd_ctcp_answer_clientinfo(msg)\n when RECV_CMND_CTCP_ANSWER_USERINFO\n ret=on_recv_cmnd_ctcp_answer_userinfo(msg)\n when RECV_CMND_CTCP_ANSWER_ACTION\n ret=on_recv_cmnd_ctcp_answer_action(msg)\n when RECV_CMND_CTCP_ANSWER_DCC\n ret=on_recv_cmnd_ctcp_answer_dcc(msg)\n else\n ret=default_action(msg)\n end\n\n return ret\n end",
"def perform\n logger.debug \"Preparing to start stream\"\n @stream_processor = nil\n type = request_method\n http = EventMachine::HttpRequest.new(full_url).send(type, http_options(type))\n authorization_method.add_header_to(http)\n # Handle failures correctly so we can back off\n @current_request = http\n http.errback { fail!(:network)}\n http.callback { http.response_header.status > 299 ? fail!(:http) : perform }\n http.stream { |c| receive_chunk(c) }\n end",
"def main()\n puts(\"\\n\\nStarting up...\")\n\n #-------------------------\n # SET UP INFO\n #-------------------------\n # set up twilio info\n account_sid, auth_token, twilio_number = get_account_info()\n wordHash = HuffmanEncoder.getHash() # list of words to encode with\n\n \n get '/message' do\n\n #----------------------------\n # PREPARE TEXT RESPONSE\n #----------------------------\n puts(\"\\n\\n\\n\\nrecieved\\n\")\n \n # 1) Collect information from user text\n user_number = params['From']\n sms = params['Body'] # store incoming sms text\n declaration, bot_key, bot_case, packageSlot, content_request =\n get_request_info(sms)\n \n # 2) Run Bot\n # Gets bot name, and then runs bot from command line\n bot = %x{ruby BotFinder.rb #{bot_key}}.chomp\n result = %x{ruby bots/#{bot} #{content_request}}.downcase \n \n # 3) prepare result for sms\n encoded = Encoder.encode(result, wordHash) # encode it\n output = SeparateIntoTexts.separate(encoded, 150) # split it\n \n # print to terminal\n print_string(result)\n printf(\"packages size: %d\\npackageSlot: %d\\n\", output.length, packageSlot)\n print_string(output)\n # print packages expected: \n \n #----------------------------\n # SEND TEXT TO USER\n #----------------------------\n size = output.length\n \n if(declaration)\n # Send Declaration Text\n # { + bot_key + request + packageSlot + size \n size = output.length\n sms_message = \"{\" + bot_key + bot_case +\n packageSlot + int_to_key(size) + content_request\n \n send_text(account_sid, auth_token, sms_message,\n user_number, twilio_number)\n else\n # Send Content Texts\n # packageSlot + index + content\n index = 0\n while(index<size)\n sms_message = packageSlot + int_to_key(index) + output[index] \n \n send_text(account_sid, auth_token, sms_message,\n user_number, twilio_number)\n index+=1\n end\n end\n \n end\nend",
"def run\n return if halted?\n\n http = request.em\n http.callback {\n Benchy.logger.info \"#{name}\\t| #{request.method.upcase} #{request.url} - HTTP #{http.response_header.status}\"\n run\n }\n http.errback {\n Benchy.logger.error \"#{name}\\t| Connection error!\"\n halt # TODO - Make this fail the ping and try again, not halt\n }\n end",
"def process_data\n begin\n data = ::ActiveSupport::HashWithIndifferentAccess.new(JSON.parse(received_data))\n packet = ::Syncano::Packets::Base.instantize_packet(data)\n\n if packet.notification?\n notification = ::Syncano::Resources::Notifications::Base.instantize_notification(client, packet)\n\n callbacks_queue.each do |callback_name|\n callbacks[callback_name].call(notification)\n end\n elsif packet.call_response?\n queue_response(packet)\n elsif packet.auth?\n queue_response(packet)\n end\n\n self.received_data = ''\n rescue Exception => e\n p 'EXCEPTION!'\n p e.inspect\n end\n end",
"def run_linear_strategy\n\t\tdebug.print(3, \"Running linear strategy\", File.basename(__FILE__), __LINE__)\n\t\t\n\t\twhile hydra.queued_requests.length > 0\n\t\t\tdebug.print(1, \"Inside requests\", File.basename(__FILE__), __LINE__)\n\n\t\t\treq = hydra.queued_requests.pop\n\t\t\t#######binding.pry\n\n\t\t\tdebug.print(1, \"\\n Popped\", req.url, \"length is\", hydra.queued_requests.length, File.basename(__FILE__), __LINE__) \n\t\t\t\t#puts req, hydra.queued_requests.length\n\t\t\t\t\n\t\t\t\tdelay_request\n\n\t\t\t\tdebug.print(1, \"\\nProcessing, \", req.url, File.basename(__FILE__), __LINE__)\n\t\t\t\treq.run\n\t\t\tend\n\t\tend",
"def dispatch\n @queue.pop.run while @queue.ready?\n end",
"def invoke_command\n params[:sessionid] ||= Xmpp::IdGenerator.generate_id\n invoke_command_on_route do\n define_meta_class_method(:request, &route[:blk])\n define_meta_class_method(:request_handler) do \n run_command(request) \n end\n define_meta_class_method(:request_callback) do |*resp|\n resp = resp.length.eql?(1) ? resp.first : resp \n add_payload_to_container(resp)\n end\n process_request\n end\n end",
"def run\n while running? || !queue.empty?\n payload = queue.pop(false)\n call_dispatchers(payload)\n end\n end",
"def command(cmd, arg = 2)\n return if @sp == nil\n #<SOT><CMD_BYTE><CHECK_SUM><EOT>\n case cmd\n=begin\n Request DCF Time\n <SOH><0x30><Chksum><EOT>\n=end\n when 0 #Poll DCF Time\n exchange(\"\\x01\\x30\\xcf\\x04\", 7)\n puts DCF77.new(@response).to_s\n=begin\n Request Dataset\n \t<SOH><0x31><Chksum><EOT>\n \t\tResponse from weather station: (34/60 Bytes) Mine has additional 0 byte, so 35/61 bytes are received.\n \t\t1. Data available\n \t\t\tBlock no.: 2 bytes Number of the block in the memory\n \t\t\t (no relation to time. Serves to control dataset registered twice).)\n \t\t\tTime: 2 bytes Age of the dataset in minutes up to the current time.\n \t\t\t\t\t\t\t\t age = ( data[2] & 0xff ) + ( data[3] << 8 & 0xff00 );\n \t\t\tData: 30 (9 sensors) or 56 (16 sensors) bytes\n \t\t2. No data available: <DLE>\n=end\n when 1 #Request dataset\n exchange(\"\\x01\\x31\\xce\\x04\", 61)\n #@response.each { |r| print \"%02X \" % r }\n s = Sensors.new(@response)\n if s.data?\n puts s.to_data_row\n puts Sensors.new(@response).to_s\n end\n=begin\n \tSelect Next Dataset\n \t\t<SOH><0x32><Chksum><EOT>\n \t\t\tResponse from weather station: (1 Byte)\n \t\t\t\t1. Next dataset available : <ACK> 0x06\n \t\t\t\t2. No dataset available: <DLE> 0x10\n=end\n when 2 #select next dataset\n exchange(\"\\x01\\x32\\xcd\\x04\",1)\n exit @response[0] == ACK ? 0 : 1\n=begin\n \tSet 8 Sensors\n \t\t<SOH><0x33><Chksum><EOT>\n \t\tResponse from weather station: (1 Byte)\n \t\t<ACK>\n=end\n when 3 #activate 8 sensors\n exchange(\"\\x01\\x33\\xcc\\x04\",1)\n exit @response[0] == ACK ? 0 : 1\n=begin\n set 16 Sensors\n \t<SOH><0x34><Chksum><EOT>\n \tResponse from weather station: (1 Byte)\n \t<ACK>\n=end\n when 4 #activate 16 sensors\n exchange(\"\\x01\\x34\\xcb\\x04\",1)\n exit @response[0] == ACK ? 0 : 1\n=begin\n \tStatus\n \t <SOH><0x35><Chksum><EOT>\n \tResponse from weather station: (21 Byte)\n \tBytes 1 - 18\n \t\t\tS:1-8 Temp/Hum\n \t\t\t9 Rain,\n \t\t\t10 Wind\n \t\t\t11 Indoor Temp/Hum/Pres\n \t\t\t12 S9:Temp/Hum\n \t\t\t13-15 S10-15:Temp/Hum/Pres\n \t\tByte >= 0x10 if sensor present\n \t\tvalue > 0x10 number of error\n \tByte 19 Sample Interval in minutes\n \tByte 20\n \t bit 0 DFC77 time receiver active\n \t\tbit 1 HF if set\n \t\tbit 2 8/16 Sensors\n \t\tbit 3 DFC Synchronized (Not likely in NZ)\n \tByte 21 Version Number\n=end\n when 5 #Request Status\n exchange(\"\\x01\\x35\\xca\\x04\", 21)\n @response.each { |r| print \"%02X \" % r }\n puts\n=begin\n Set Interval time\n \t <SOH><0x36><minutes><Chksum><EOT>\n \t\tminutes range 1..60\n \t Response from weather station: (1 Byte)\n \t<ACK> if in range\n \t<DLE> if out of range\n=end\n when 6 #set interval time\n #<SOT><CMD_BYTE><ARGUMENT><CHECK_SUM><EOT>\n raise Weather_exception, \"Interval Range 2..60\" if arg > 60 || arg < 2\n exchange(\"\\x01\\x36#{arg.chr}#{(0xc9-arg).chr}\\x04\", 1)\n exit @response[0] == ACK ? 0 : 1\n\n when 12 #Loop through 1 and 2\n begin\n exchange(\"\\x01\\x31\\xce\\x04\", 61)\n s = Sensors.new(@response)\n exchange(\"\\x01\\x32\\xcd\\x04\",1)\n if s.data?\n\t puts s.to_data_row\n else\n break\n end\n end while( @response[0] == ACK )\n end\n end",
"def command_queue; end",
"def runOperation(msg, client)\n case msg.getConfig(\"type\")\n when 0; edgebReflex(msg.getMessage(), client)\n when 1; fillBack(msg)\n when 2; edgeuUpdate(msg.getMessage())\n when 3; pingCallBack(msg)\n when 4; tracerouteCallBack(msg)\n when 5; sendMsgCallBack(msg, client)\n else STDERR.puts \"ERROR: INVALID MESSAGE \\\"#{msg}\\\"\"\n end\nend",
"def request_loop\n @request_queue.receive_messages.each do |msg|\n yield(get_request(msg))\n end\n end",
"def work(raw_post)\n puts \"Msg received: \" + raw_post\n ack! # we need to let queue know that message was received\n end",
"def receive_data p_data\n if p_data[:data][:worker_method] == :exit\n exit\n end\n case p_data[:type]\n when :request then process_request(p_data)\n when :response then process_response(p_data)\n when :get_result then return_result_object(p_data)\n end\n end",
"def process\n klass.new(request).process\n end",
"def process\n by_time_batch\n by_waiting_batch\n rescue\n @logger.fatal \"Failed to process: #{$!}\"\n @logger.fatal $!.backtrace.join(\"\\n\")\n end",
"def run!(frequency = 0)\n while @jabber.connected?\n @jabber.received_messages do |message|\n start = Time.now\n \n from = message.from.to_s.split('/').first\n parts = message.body.strip.split(':', 2)\n hash = parts.first\n path_parts = parts.last.split('?', 2)\n request = Request.new(hash, from, path_parts.first, ((path_parts.length == 2) ? path_parts.last : ''))\n # TODO: DRY this portion up.\n if @debug\n # Allow errors to fall through and kill the process.\n controller_response = @controller.route!(request)\n response = {:status => 200, :data => ''}.merge(controller_response)\n respond_to request, :status => response[:status], :data => response[:data]\n puts \"Responded to '#{from}' in #{(Time.now - start).to_s} seconds.\"\n else\n # Capture the errors so that the server keeps on running.\n begin\n controller_response = @controller.route!(request)\n response = {:status => 200, :data => ''}.merge(controller_response)\n respond_to request, :status => response[:status], :data => response[:data]\n rescue\n respond_to request, :status => 500\n puts \"Error responding to #{message.from.to_s.strip}:\"\n puts $!\n else\n puts \"Responded to '#{from}' in #{(Time.now - start).to_s} seconds.\"\n end\n end\n #puts \"\\n\"\n end\n if frequency > 0\n # Keep it from hogging up CPU cycles.\n sleep frequency\n end\n end\n end",
"def run\n AMQP.start(:host => \"localhost\") {\n @mq = MQ.new\n @update_channel = EM::Channel.new\n @deferred_responses = {}\n\n @queue_name = \"cmdr:websocket:#{self.object_id}\"\n @queue = @mq.queue(@queue_name)\n \n # watch for responses from devices\n @queue.subscribe{|json|\n msg = JSON.parse(json)\n puts \"Got response: #{msg}\"\n if @deferred_responses[msg[\"id\"]]\n @deferred_responses.delete(msg[\"id\"]).succeed(msg)\n end\n }\n\n topic = @mq.topic(EVENT_TOPIC)\n @mq.queue(\"cmdr:websocket:#{self.object_id}:response\").bind(topic, :key => \"device.*\").subscribe do |json|\n handle_event json\n end\n\n setup\n\n EM::WebSocket.start({\n :host => \"0.0.0.0\",\n :port => 8000,\n :debug => false\n #:secure => true \n }) do |ws|\n\n ws.onopen { onopen ws }\n \n ws.onmessage {|json| onmessage ws, json}\n \n ws.onclose do\n @update_channel.unsubscribe(@sid) if @sid\n DaemonKit.logger.debug \"Connection on #{ws.signature} closed\"\n end\n\n ws.onerror do\n DaemonKit.logger.debug \"Error on #{ws.signature}\"\n end\n end\n }\n end",
"def process_request!\n job = Thread.current[:redis_blocking].brpop(Scales::Storage::REQUEST_QUEUE, 0).last\n id, response = nil, nil\n \n Thread.current[:post_process_queue] = []\n id, response = process!(job)\n post_process!(job)\n @status.put_response_in_queue!(response)\n Thread.current[:redis_nonblocking].publish(Scales::Storage::RESPONSE_CHANNEL, JSON.generate(response))\n \n [id, response]\n end",
"def requester_run(hb, body)\n @body = body\n rtcsignaloutput = []\n rtcmanagementoutput = []\n\n # Get all RTCSignals for this browser\n BeEF::Core::Models::Rtcsignal.where(:target_hooked_browser_id => hb.id, :has_sent => \"waiting\").each { |h|\n # output << self.requester_parse_db_request(h)\n rtcsignaloutput << h.signal\n h.has_sent = \"sent\"\n h.save\n }\n\n # Get all RTCManagement messages for this browser\n BeEF::Core::Models::Rtcmanage.where(:hooked_browser_id => hb.id, :has_sent => \"waiting\").each {|h|\n rtcmanagementoutput << h.message\n h.has_sent = \"sent\"\n h.save\n }\n\n # Return if we have no new data to add to hook.js\n return if rtcsignaloutput.empty? and rtcmanagementoutput.empty?\n\n config = BeEF::Core::Configuration.instance\n ws = BeEF::Core::Websocket::Websocket.instance\n\n # todo antisnatchor: prevent sending \"content\" multiple times. Better leaving it after the first run, and don't send it again.\n #todo antisnatchor: remove this gsub crap adding some hook packing.\n # The below is how antisnatchor was managing insertion of messages dependent on WebSockets or not\n # Hopefully this still works\n if config.get(\"beef.http.websocket.enable\") && ws.getsocket(hb.session)\n \n rtcsignaloutput.each {|o|\n add_rtcsignal_to_body o\n } unless rtcsignaloutput.empty?\n rtcmanagementoutput.each {|o|\n add_rtcmanagement_to_body o\n } unless rtcmanagementoutput.empty?\n # ws.send(content + @body,hb.session)\n ws.send(@body,hb.session)\n #if we use WebSockets, just reply wih the component contents\n else # if we use XHR-polling, add the component to the main hook file\n rtcsignaloutput.each {|o|\n add_rtcsignal_to_body o\n } unless rtcsignaloutput.empty?\n rtcmanagementoutput.each {|o|\n add_rtcmanagement_to_body o\n } unless rtcmanagementoutput.empty?\n end\n\n end",
"def queue(link)\n\t\t####binding.pry\n\t\treq = request(link)\n\t\t######binding.pry\n\t\treq.on_complete {|res| \n\t\t\t######binding.pry\n\t\t\thandle_response(req, res)\n\t\t}\n\t\t#####binding.pry\n\t\thydra.queue(req)\n\t\t####binding.pry\n\tend",
"def process_response\n job = message.job\n job.data = message.data\n job.message = message.message\n\n if message.ok?\n job.proceed!\n else\n job.error!\n end\n end",
"def process\n return 'OK' if @email.to.first[:token] == 'example'\n return process_image if @email.to.first[:token] == 'flyers'\n\n token = ReplyToken.find(@email.to.first[:token])\n\n case token.reply_type\n when 'participation_request'\n process_participation_request(token)\n when 'conversation'\n process_conversation(token)\n when 'comment'\n process_comment(token)\n when 'community'\n process_community_reply(token)\n end\n\n track_reply(token)\n\n token.use!\n end",
"def rtmstart_handler(hash)\n logger.info 'Processing RTM.start response...'\n handlers = SlackRTMReceiver.event_handlers\n handlers.each do |handler|\n handler.process_event(hash, self) if handler.type == :rtmstart\n end\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 ) # 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 hsdq_callback(message, context); placeholder; end",
"def handle_messages!\n self.logger.debug { \"Starting message handler.\" }\n \n loop do\n message = nil\n\n # reads data\n self.logger.debug { \"Waiting for messages.\" }\n message = self.protocol.wait_interaction!\n \n # if nil data arrived, it means termination\n if message.nil?\n break\n end\n \n self.logger.debug { \"Message of type '#{message.type}' received.\" }\n\n # calls processing method according to incoming message\n case message.type.to_sym\n when :order\n self.handle_order(message)\n end\n \n end\n \n self.logger.debug { \"Message handler terminated.\" }\n end",
"def process_data\n unless @state.include?(:rcpt)\n send_data \"503 Operation sequence error\\r\\n\"\n else\n succeeded = proc {\n send_data \"354 Send it\\r\\n\"\n @state << :data\n @databuffer = []\n }\n failed = proc {\n send_data \"550 Operation failed\\r\\n\"\n }\n\n d = receive_data_command\n\n if d.respond_to?(:callback)\n d.callback(&succeeded)\n d.errback(&failed)\n else\n (d ? succeeded : failed).call\n end\n end\n end",
"def _get_queued_instruction\n\n begin\n\n # pull from the priority queue first\n queue_uri = \"#{@control_queue_uri}_priority_100\"\n response = @sqs.receive_message(queue_url: queue_uri, max_number_of_messages: 1)\n\n\n # otherwise go to the normal queue\n unless response.messages.count > 0\n queue_uri = @control_queue_uri\n response = @sqs.receive_message(queue_url: queue_uri, max_number_of_messages: 1)\n end\n\n control_message = {}\n response.messages.each do |m|\n\n if (m && m.body)\n\n @sqs.delete_message({\n queue_url: queue_uri,\n receipt_handle: m.receipt_handle\n })\n\n # return the first one\n message = JSON.parse(m.body)\n _log \"Got instruction for #{message[\"id\"]}\"\n _log \"#{message}\"\n\n return message\n\n else\n _log_error \"No instructions received!!!\"\n return nil\n end\n end\n rescue JSON::ParserError => e\n _log_error \"Can't parse response\"\n rescue Aws::SQS::Errors::NonExistentQueue\n _log_error \"A queue named '#{queue_name}' does not exist.\"\n end\n\n false\n end",
"def receive_data data\n @buf.extract(data).each do |packet|\n begin\n request = JSON::parse(packet)\n log.debug { request }\n case request['method']\n when \"relay_tx\"\n return handle_relay_tx(request, *request['params'])\n when \"monitor\"\n respond(request, handle_monitor(request, *request['params']))\n else\n if respond_to?(\"handle_#{request['method']}\")\n respond(request, send(\"handle_#{request['method']}\", *request['params']))\n else\n respond(request, { error: \"unknown command: #{request['method']}. send 'help' for help.\" })\n end\n end\n rescue\n respond(request, { error: $!.message })\n end\n end\n rescue Exception\n p $!; puts *$@\n end",
"def setup\n EM.kqueue\n #AMQP.logging = true\n @mq = MQ.new\n @requests = @mq.queue('jesus_nut',:auto_delete => true)\n @setup = true\n @mq.queue(@reply_to).subscribe { |info, response|\n resp = Marshal.load response\n callback = @pending.delete info.message_id\n callback.call resp\n }\n @id = 1\n end",
"def process checkup\n begin\n checkup[:templates].each do |template|\n I2X::Config.log.info(self.class.name) {\"Delivering to #{template} template.\"}\n checkup[:payload].each do |payload|\n I2X::Config.log.debug(self.class.name) {\"Processing #{payload}.\"}\n response = RestClient.post \"#{I2X::Config.host}postman/deliver/#{template}.js\", payload\n case response.code\n when 200\n\n else\n I2X::Config.log.warn(self.class.name) {\"unable to deliver \\\"#{payload}\\\" to \\\"#{template}\\\"\"}\n end\n end\n end\n rescue Exception => e\n I2X::Config.log.error(self.class.name) {\"Processing error: #{e}\"}\n end\n \n end",
"def execute\n\n case @template[:payload][:method]\n when 'get'\n begin\n out = RestClient.get @template[:payload][:uri]\n response = {:status => 200, :message => \"[i2] GET request on #{@template[:payload][:uri]} executed.\", :id => @template[:payload][:uri], :response => out.to_str}\n rescue Exception => e\n response = {:status => 400, :message => \"Unable to perform GET request, #{e}\"}\n Services::Slog.exception e\n end\n when 'post'\n begin\n\n case @template[:payload][:message]\n when 'form'\n out = RestClient.post @template[:payload][:uri], @template[:payload]\n when 'text/plain'\n out = RestClient.post @template[:payload][:uri], @template[:payload][:content], :content_type => 'text/plain'\n when 'application/javascript'\n if @template[:payload][:content].nil?\n out = RestClient.post @template[:payload][:uri], @template[:payload].to_json, :content_type => 'application/javascript'\n else\n out = RestClient.post @template[:payload][:uri], @template[:payload][:content], :content_type => 'application/javascript'\n end\n when \"application/json\"\n if @template[:payload][:content].nil?\n out = RestClient.post @template[:payload][:uri], @template[:payload].to_json, :content_type => 'application/json'\n else\n out = RestClient.post @template[:payload][:uri], @template[:payload][:content], :content_type => 'application/json'\n end\n when 'application/xml'\n if @template[:payload][:content].nil?\n out = RestClient.post @template[:payload][:uri], @template[:payload].to_xml, :content_type => 'application/xml'\n else\n out = RestClient.post @template[:payload][:uri], @template[:payload][:content], :content_type => 'application/xml'\n end\n when 'text/xml'\n if @template[:payload][:content].nil?\n out = RestClient.post @template[:payload][:uri], @template[:payload].to_xml, :content_type => 'text/xml'\n else\n out = RestClient.post @template[:payload][:uri], @template[:payload][:content], :content_type => 'text/xml'\n end\n when 'text/html'\n out = RestClient.post @template[:payload][:uri], @template[:payload][:content], :content_type => 'text/html'\n end\n\n response = {:status => 200, :message => \"[i2] POST request on #{@template[:payload][:uri]} executed.\", :id => @template[:payload][:uri], :response => out.to_str}\n rescue Exception => e\n response = {:status => 400, :message => \"Unable to perform POST request, #{e}\"}\n end\n when 'put'\n begin\n\n rescue Exception => e\n response = {:status => 440, :message => \"Unable to perform PUT request (not implemented), #{e}\"}\n end\n when 'delete'\n begin\n\n rescue Exception => e\n response = {:status => 440, :message => \"Unable to perform DELETE request (not implemented), #{e}\"}\n end\n end\n response\n end",
"def incoming \n response.headers[\"Content-Type\"] = \"text/plain; charset=utf-8\"\n #Read params from the text message\n \n if (params[:uid] && params[:body])\n @userid = params[:uid]\n @body = params[:body] \n \n sms = Sms.new(:raw => @body, :login => @userid)\n \n sms.parse\n \n user = User.find_by_login(sms.login)\n \n if user.nil?\n render :text => \"User #{sms.login} couldn't be found, have you signed up at #{AZIMUTH_DOMAIN}?\" \n else\n hunt = user.hunt\n if hunt.nil?\n render :text => \"User #{sms.login} doesn't appear to have signed up for a hunt. Please sign up for one at #{AZIMUTH_DOMAIN}.\"\n else\n if hunt.aasm_current_state == :hunting\n discovery = Discovery.new(:treasure => user.current_treasure, :key => sms.key, :lat => sms.lat, :lng => sms.lng, :hunt => hunt, :user => user)\n hunt.attempt_open_treasure_chest(discovery, user)\n user.save!\n hunt.save!\n discovery.save!\n \n if discovery.success?\n render :text => \"\" # don't send extra texts since the hunt will do it for us...\n else\n render :text => \"What you texted didn't open the treasure chest :-(. Coords: #{sms.lat} #{sms.lng}. Key: #{sms.key}\"\n end\n else\n render :text => \"The hunt #{hunt.name} is currently in #{hunt.state.humanize} state. Please wait for the hounds to be released to get your first clue.\"\n end\n end\n end\n else\n render :text => \"\"\n end\n \n end",
"def handle_request(client, lines, requests); end",
"def tick # :nodoc: all\n # Handle the tick\n # Do we have any retries due to be sent yet?\n # @mutex.synchronize{\n @parent.single_res_mutex.synchronize {\n time_now = Time.now\n @timeouts.keys.each do |client_query_id|\n msg, client_queue, select_queue, outstanding = @query_list[client_query_id]\n query_timeout, timeouts = @timeouts[client_query_id]\n if query_timeout < Time.now\n # Time the query out\n send_result_and_stop_querying(client_queue, client_query_id, select_queue, nil,\n ResolvTimeout.new('Query timed out'))\n next\n end\n timeouts_done = []\n timeouts.keys.sort.each do |timeout|\n if timeout < time_now\n # Send the next query\n res, retry_count = timeouts[timeout]\n id = [res, msg, client_query_id, retry_count]\n Dnsruby.log.debug(\"Sending msg to #{res.server}\")\n # We should keep a list of the queries which are outstanding\n outstanding.push(id)\n timeouts_done.push(timeout)\n timeouts.delete(timeout)\n\n # Pick a new QID here @TODO@ !!!\n # msg.header.id = rand(65535);\n # print \"New query : #{new_msg}\\n\"\n res.send_async(msg, select_queue, id)\n else\n break\n end\n end\n timeouts_done.each { |t| timeouts.delete(t) }\n end\n }\n end",
"def running_phase\n loop do\n maybe_log(\"Waiting for message\")\n request = ::Ractor.receive\n next unless request.is_a?(Message)\n case request.type\n when :call\n @queue.enq(request)\n register_call(request)\n maybe_log(\"Queued method #{request.data.first} (transaction=#{request.transaction})\")\n when :thread_stopped\n maybe_log(\"Thread unexpectedly stopped: #{request.data}\")\n @thread_count -= 1\n break\n when :stop\n maybe_log(\"Received stop\")\n break\n end\n end\n end",
"def setup\n setup_requeue_queue\n consume_requeue\n setup_retry_queues\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 process(payload)\n @working = true\n begin\n @queues.outgoing.push(discover_artifact_from(payload))\n rescue => ex\n STDERR.puts \"[Error] Exception in thread: #{ex.full_message}\"\n @queues.outgoing.push(ex)\n ensure\n @working = false\n end\n end",
"def process_request(public_request_id) \n\n # parse the URL into verb, resources, options, and body\n @active_requests[public_request_id][:public_request].match /(GET|POST) \\/(\\S*)(.*)^(.*)\\Z/m\n parsed_requests, new_requests, request_resources = [$1, $2, $3, $4], {}, $2\n\n ## handle / (GENERIC) resource requests ##\n if request_resources.empty?\n new_requests = process_generic_request(parsed_requests, public_request_id)\n\n ## handle /TEST_POST/ resource request ##\n elsif request_resources.match /test_post/\n new_requests = process_form_request(parsed_requests, public_request_id)\n \n ## handle ALL OTHER requests ##\n else\n parsed_resources = parsed_requests[1].split(\"/\")\n device_match = ::ArduinoGateway::Model::ModelTemplates::ResourceDevice.find_by_name(parsed_resources[0])\n\n # handle requests for DEVICE-BASED SERVICES\n unless device_match.empty?\n new_requests = process_device_request(parsed_requests, parsed_resources, device_match, public_request_id) \n # handle requests for SERVICES ACCROSS DEVICES\n else \n new_requests = process_service_request(parsed_requests, parsed_resources, device_match, public_request_id)\n end\n\n end # else related to ALL OTHER requests\n\n new_requests.each { | name, request | make_request request }\n @active_requests[public_request_id][:arduino_requests] = new_requests\n end",
"def interpret_task\n\n command = params[:process].to_sym\n respond_to do |format|\n case command\n when :setup\n setup_project() if @project.may_setup?\n @project.setup! # TODO refactor setup_project as a :before callback to event\n\n format.html { redirect_to project_path(@project, :submit_action => 'setup'), notice: 'Request for project set-up has been submitted.' }\n format.json {render :json => {'data' => 'Request for project set-up has been submitted.'}.merge(state_snapshot)}\n when :start, :stop, :abort, :terminate\n submit_process(command) if @project.send(\"may_#{command}?\")\n @project.send(\"#{command}!\") # TODO refactor as a :before callback to events\n format.html { redirect_to project_path(@project, :submit_action => params[:process]), notice: 'Request for project '+params[:process]+' has been submitted.' }\n format.json {render :json => {'data' => 'Request for project '+params[:process]+' has been submitted.'}.merge(state_snapshot)}\n when :download, :export\n\n id_ary = params[:ids].map(&:to_i).reverse\n # save data for selected results\n result_download_data = Hash.new\n result_download_data[:test_ids] = id_ary.join(',')\n result_download_data[:project_id] = @project.id\n result_download_data[:result_type] = params[:process]\n result_download = ProjectResultDownload.new(result_download_data)\n result_download.save!\n\n project_results_download(params[:process], id_ary, result_download.id)\n\n format.json {render :json => {'request_id' => result_download.id, 'status' => 0}}\n else\n format.html { redirect_to project_path(@project), notice: 'Unidentified process command.' }\n format.json {render :json => {'data' => 'Unidentified process command.'}}\n end\n\n end\n end",
"def run(chunk_id, logger)\n @logger = logger\n logger.info \"\\n(#{chunk_id}) Processing backtest with a #{et_name} entry trigger and #{es_name} entry with #{xt_name} trigger and #{xs_name} exit against #{scan_name}\"\n\n @chunk_id = chunk_id\n @etrigger_decl = et_name && $analytics.find_etrigger(et_name)\n @opening_decl = es_name && $analytics.find_opening(es_name)\n @xtrigger_decl = xt_name && $analytics.find_xtrigger(xt_name)\n @closing_decl = xs_name && $analytics.find_closing(xs_name)\n @stop_loss_decl = $analytics.find_stop_loss\n\n @scan = Scan.find_by_name(scan_name)\n\n using_blocks = []\n using_blocks << @entry_trigger = et_name && EntryTrigger.find_by_name(et_name)\n using_blocks << @entry_strategy = es_name && EntryStrategy.find_by_name(es_name)\n using_blocks << @exit_trigger = xt_name && ExitTrigger.find_by_name(xt_name)\n using_blocks << @exit_strategy = xs_name && ExitStrategy.find_by_name(xs_name)\n\n\n raise Exception, \"undefined scan or trigger name: check using statement against analytics names\" if using_blocks.any?(&:nil?)\n\n truncate(self.options[:truncate]) unless self.options[:truncate].nil?\n\n startt = global_startt = Time.now\n\n # FIXME when a backtest specifies a different set of options, e.g. (:price => :close) we should\n # FIXME invalidate any cached posistions (including and exspecially scans_strategies because the positions will have\n # FIXME totally different values\n #\n # Grab tickers from scans and compute the date range from the scan dates or the options\n # passed in to the constructor (they win)\n #\n sdate = self.options[:start_date] ? self.options[:start_date] : scan.start_date\n edate = self.options[:end_date] ? self.options[:end_date] : scan.end_date\n\f\n #--------------------------------------------------------------------------------------------------------------------\n # TRIGGERED POSITION pass. Iterates through a tickers in scan, executing the trigger block for each ticker. Since\n # we're only using an RSI(14) as a triggering signal we execute the block three times varying (in effect) the threshold\n # which, when crossed, tiggers a positioins. The three thresholds used are 20, 25, and 30. The way the thresholds are\n # varied is a hack (FIXME), which should instead involve the use of three seperate trigger strategies instead of the\n # bastardized one we use here.\n #-------------------------------------------------------------------------------------------------------------------\n unless optimize_passes && Position.count(:all, :conditions => { :entry_trigger_id => entry_trigger.id, :scan_id => scan.id }) > 0\n logger.info \"(#{chunk_id}) Beginning trigger positions analysis...\" if log? :basic\n RubyProf.start if self.options[:profile]\n primary_indicator = etrigger_decl.params[:result] && etrigger_decl.params[:result].first\n indicator_id ||= Indicator.lookup(primary_indicator).id\n\n count = 0\n index_count = 0\n ticker_ids = scan.population_ids(options[:repopulate], :logger => logger)\n for ticker_id in ticker_ids\n begin\n ts = Timeseries.new(ticker_id, sdate..edate, resolution, self.options.merge(:logger => logger))\n reset_position_index_hash()\n for pass in self.options[:epass]\n triggered_indexes = ts.instance_exec(etrigger_decl.params, pass, &etrigger_decl.block)\n index_count = triggered_indexes.length\n for index in triggered_indexes\n next if triggered_index_hash.include? index #This index has been triggered on a previous pass\n trigger_date, trigger_price = ts.closing_values_at(index)\n trigger_ival = ts.result_at(index, primary_indicator)\n # the case\n debugger if trigger_date.nil? or trigger_price.nil?\n position = Position.trigger_entry(ts.ticker_id, trigger_date, trigger_price, indicator_id, trigger_ival, pass, :next_pass => entry_strategy.name != 'identity')\n logger.info \"Triggered #{ts.symbol} on #{trigger_date.to_formatted_s(:ymd)} at $#{trigger_price}\" if log? :triggers\n ts.persist_results(entry_trigger, position, *etrigger_decl.params[:result]) if options[:record_indicators]\n entry_trigger.positions << position\n scan.positions << position\n count += 1\n map_position_ts(position, ts)\n triggered_index_hash[index] = true\n ts.clear_results() unless ts.nil?\n end\n end\n rescue TimeseriesException => e\n logger.info \"#{e.to_s} -- SKIPPING Ticker\"\n #rescue Exception => e\n # logger.info \"Unexpected exception #{e.to_s}\"\n rescue ActiveRecord::StatementInvalid\n logger.info(\"Duplicate entry for #{ts.symbol} on #{trigger_date.to_formatted_s(:ymd)} ent_id: #{indicator_id}\")\n end\n symbol = Ticker.find(ticker_id).symbol\n $stderr.print \"\\r#{symbol} \"\n logger.info(\"Processed #{symbol} #{count} of #{ticker_ids.length} #{index_count} positions entered\") if log? :trigger_summary\n end\n\n\n endt = Time.now\n delta = endt - startt\n logger.info \"(#{chunk_id}) #{count} positions triggered -- elapsed time: #{Backtester.format_et(delta)}\" if log? :basic\n\n if self.options[:profile]\n GC.disable\n results = RubyProf.stop\n GC.enable\n\n File.open \"#{RAILS_ROOT}/tmp/trigger-positions.prof\", 'w' do |file|\n RubyProf::CallTreePrinter.new(results).print(file)\n end\n end\n else\n logger.info \"Using pre-generated triggers...\" if log? :basic\n end\n\n #--------------------------------------------------------------------------------------------------------------------\n # OPEN POSITION pass. Iterates through all positions triggered by the previous pass, running a \"confirmation\" strategy\n # whose mission it is to cull out losers that have been triggered and ones not likely to close.\n #-------------------------------------------------------------------------------------------------------------------\n unless optimize_passes && Position.count(:all, :conditions => { :entry_strategy_id => entry_strategy.id, :scan_id => scan.id }) > 0\n logger.info \"(#{chunk_id}) Beginning open positions analysis...\" if log? :basic\n RubyProf.start if self.options[:profile]\n startt = Time.now\n count = 0\n duplicate_entries = 0\n triggers = entry_trigger.positions.find(:all, :conditions => { :scan_id => scan.id }, :order => 'ettime, ticker_id')\n trig_count = triggers.length\n for position in triggers\n if entry_strategy.params[:result] == [:identity]\n result_id ||= Indicator.lookup(:identity).id\n position.entry_date = position.ettime\n position.entry_price = position.etprice\n position.entry_ival = position.etival\n position.eind_id = result_id;\n entry_strategy.positions << position\n count += 1\n else\n begin\n start_date = position.ettime.to_date\n end_date = [Backtester.trading_date_from(start_date, days_to_open), max_date].min\n if ts = timeseries_for(position)\n ts.reset_local_range(start_date, end_date)\n else\n ts = Timeseries.new(position.ticker_id, start_date..end_date, resolution, self.options.merge(:logger => logger))\n end\n\n confirming_index = ts.instance_exec(opening_decl.params, &opening_decl.block)\n ts.persist_results(entry_strategy, position, *entry_strategy.params[:result]) if options[:record_indicators]\n\n unless confirming_index.nil?\n index = confirming_index\n entry_time, entry_price = ts.closing_values_at(index)\n logger.info \"#{ts.symbol} etrigger: #{position.ettime.to_formatted_s(:ymd)} entry_date: #{entry_time.to_formatted_s(:ymd)}\" if log? :entry\n position = position.open(entry_time, entry_price, :parent => entry_strategy)\n logger.info format(\"Position %d of %d (%s) %s\\t%d\\t%3.2f\\t%3.2f\\t%3.2f\",\n count, trig_count, position.ticker.symbol,\n position.ettime.to_formatted_s(:ymd),\n position.entry_delay, position.etprice, position.entry_price,\n position.consumed_margin) if log? :entries\n entry_strategy.positions << position if position.entry_strategy_id != entry_strategy.id\n count += 1\n else # Since an entry has already been created, any entry not confirmed should be destroyed\n position.destroy()\n end\n rescue TimeseriesException => e\n logger.error(e.to_s)\n remove_from_position_map(position)\n position.destroy\n rescue ActiveRecord::StatementInvalid\n duplicate_entries += 1\n position.destroy\n logger.error(\"Duplicate entry for #{position.ticker.symbol} tigger: #{position.ettime.to_formatted_s(:ymd)} entry: #{entry_time.to_formatted_s(:ymd)}\")\n end\n ts.clear_results unless ts.nil?\n end\n end\n endt = Time.now\n delta = endt - startt\n logger.info \"(#{chunk_id}) #{duplicate_entries} duplicate entries merged\" if log? :basic\n logger.info \"(#{chunk_id}) #{count} positions opened of #{trig_count} triggered -- elapsed time: #{Backtester.format_et(delta)}\" if log? :basic\n\n if self.options[:profile]\n GC.disable\n results = RubyProf.stop\n GC.enable\n\n File.open \"#{RAILS_ROOT}/tmp/open-position.prof\", 'w' do |file|\n RubyProf::CallTreePrinter.new(results).print(file)\n end\n end\n else\n logger.info \"Using pre-computed entries...\"\n end\n\n #--------------------------------------------------------------------------------------------------------------------\n # TRIGGERED EXIT pass. Iterates through all positions opened by the previous pass applying an exitting strategy based upon\n # crossing a certain threshold of one or more indicators. This is NOT intended to be an optimizing close, rather it records the\n # the time and values at which it crossed a SELL threshold. This often is a threshold crossing which indicates an over-bought\n # condition. The backtest is configured with a certain number of days for this to occur otherwise the position os\n # forcefully closed (usually at a significant loss). Any positions found with an incomplete set of bars is\n # summarily logged and destroyed.\n #-------------------------------------------------------------------------------------------------------------------\n unless optimize_passes && Position.count(:all, :conditions => { :exit_trigger_id => exit_trigger.id, :scan_id => scan.id }) > 0\n logger.info \"(#{chunk_id}) Beginning exit trigger analysis...\" if log? :basic\n startt = Time.now\n\n RubyProf.start if self.options[:profile]\n\n open_positions = entry_strategy.positions.find(:all, :conditions => { :scan_id => scan.id }, :include => :ticker, :order => 'tickers.symbol, entry_date')\n pos_count = open_positions.length\n\n counter = 1\n null_exits = 0\n for position in open_positions\n @current_position = position\n begin\n max_exit_date = Position.trading_date_from(position.entry_date, days_to_close)\n if max_exit_date > Date.today-1\n ticker_max = DailyBar.maximum(:bartime, :conditions => { :ticker_id => position.ticker_id } )\n max_exit_date = ticker_max.localtime\n end\n if ts = timeseries_for(position)\n ts.reset_local_range(position.entry_date, max_exit_date)\n else\n ts_options = { :logger => logger } # FIXME prefetch bars should be dynamic\n ts = Timeseries.new(position.ticker_id, position.entry_date..max_exit_date, resolution, self.options.merge(ts_options))\n end\n\n exit_time, indicator, ival = ts.instance_exec(xtrigger_decl.params, &xtrigger_decl.block)\n ts.persist_results(exit_trigger, position, *entry_strategy.params[:result]) if options[:record_indicators]\n\n if exit_time.is_a?(Time)\n Position.trigger_exit(position, exit_time, c = ts.value_at(exit_time, :close), indicator, ival, :closed => true)\n logger.info \"#{ts.symbol}\\t#{position.entry_date.to_formatted_s(:ymd)} #{position.xttime.to_formatted_s(:ymd)} #{position.etival} #{position.xtival}\" if log? :exits\n position.update_attribute(:exit_trigger_id, exit_trigger.id)\n elsif exit_time.nil?\n Position.trigger_exit(position, max_exit_date, ts.value_at(max_exit_date, :close), :rvigor, nil, :closed => false)\n elsif exit_time.is_a?(Numeric) # FIXME I'm not sure what in the fuck this is doing here\n exit_date = Backtester.trading_date_from(position.entry_date, -exit_time)\n Position.trigger_exit(position, exit_date, ts.value_at(exit_date, :close), nil, nil, :closed => false)\n null_exit = Position.close(position, exit_date, ts.value_at(exit_date, :close), nil, :indicator => :rsi, :closed => false)\n if null_exit\n logger.info format(\"Position %d of %d (%s) %s\\t%s has NULL close\",\n counter, pos_count, position.ticker.symbol,\n position.entry_date.to_formatted_s(:ymd),\n max_exit_date.to_formatted_s(:ymd))\n null_exits += 1\n end\n end\n rescue TimeseriesException => e\n logger.error(\"#{e.class.to_s}: #{e.to_s}. DELETING POSITION!\")\n remove_from_position_map(position)\n Position.delete position.id\n end\n ts.clear_results() unless ts.nil?\n logger.info format(\"Position %d of %d (%s) %s\\t%d\\t%3.2f\\t%3.2f\\t%3.2f\\t%3.2f\\t%s\",\n counter, pos_count, position.ticker.symbol,\n position.entry_date.to_formatted_s(:ymd),\n position.xtdays_held, position.entry_price, position.xtprice, 0.0,\n position.xtroi, position.indicator.name ) if log? :exits\n counter += 1\n end\n\n endt = Time.now\n delta = endt - startt\n\n logger.info \"(#{chunk_id}) #{null_exits} NULL EXITS found\" if log? :basic\n logger.info \"(#{chunk_id}) Exit trigger analysis elapsed time: #{Backtester.format_et(delta)}\" if log? :basic\n\n if self.options[:profile]\n GC.disable\n results = RubyProf.stop\n GC.enable\n\n File.open \"#{RAILS_ROOT}/tmp/exit-trigger.prof\", 'w' do |file|\n RubyProf::CallTreePrinter.new(results).print(file)\n end\n end\n else\n logger.info \"Using pre-computed exits...\"\n end\n\n #--------------------------------------------------------------------------------------------------------------------\n # CLOSE POSITION pass. Once a position has crossed a exit threshold it is further processed to seek an optimal close,\n # not just the point at which an arbritary threshold was crossed. This is usually done by followin an indicator as it rises and\n # finally peeks or levels off. At this point we close the position on this pass. The theory being that there's still\n # some headroom betwen the triggered exit threshold and the max value an indicator is known to likely reach. Alternatively\n # we could just raise our exit threshold, but we run the risk of never reaching them and winding up with un-closed positions.\n # This pass is a compromise between to two. One we reach an exit threshold it's likely that we are already in a profit\n # position. The purpose of this pass is to follow the curse looking for a local maxima and then closing, thus added\n # to our profit.\n #-------------------------------------------------------------------------------------------------------------------\n unless optimize_passes && exit_strategy.nil? || Position.count(:all, :conditions => { :exit_strategy_id => exit_trigger.id, :scan_id => scan.id }) > 0\n logger.info \"(#{chunk_id}) Beginning close position optimization analysis...\" if log? :basic\n startt = Time.now\n\n RubyProf.start if self.options[:profile]\n\n open_positions = Position.find(:all, :conditions => { :exit_trigger_id => exit_trigger.id, :scan_id => scan.id },\n :include => :ticker, :order => 'tickers.symbol, entry_date')\n pos_count = open_positions.length\n\n counter = 1\n log_counter = 0\n max_limit_counter = 0\n for position in open_positions\n if entry_strategy.params[:result] == [:identity]\n exit_time = position.xttime\n exit_price = position.xtprice\n exit_ival = position.xtival\n position.xind_id = position.xtind_id\n exit_strategy.positions << position\n Position.close(position, exit_time, exit_price, exit_ival, :closed => true)\n count += 1\n else\n begin\n p = position\n max_exit_date = Position.trading_date_from(position.xttime, options[:days_to_optimize])\n if max_exit_date > Date.today\n ticker_max = DailyBar.maximum(:bartime, :conditions => { :ticker_id => position.ticker_id } )\n max_exit_date = ticker_max.localtime\n end\n if ts = timeseries_for(position)\n ts.reset_local_range(position.xttime, max_exit_date)\n else\n ts = Timeseries.new(position.ticker_id, position.xttime..max_exit_date, resolution, self.options.merge(:logger => logger))\n end\n index = ts.instance_exec(position, closing_decl.params, &closing_decl.block)\n ts.persist_results(exit_strategy, position, *entry_strategy.params[:result]) if options[:record_indicators]\n\n unless index.nil?\n closing_time, closing_price = ts.closing_values_at(index)\n max_rsi = ts.result_at(index, :rsi)\n else\n closing_time = position.xttime\n closing_price = position.xtprice\n max_rsi = position.xtival\n max_limit_counter += 1\n end\n indicator = exit_strategy.params[:result]\n Position.close(position, closing_time, closing_price, max_rsi, :indicator => indicator, :closed => true)\n begin\n exit_strategy.positions << position\n rescue Exception # FIXME duplicates should have been filtered out on opening, so we should not have to do this\n remove_from_position_map(position)\n Position.delete position.id\n end\n ts.clear_results() unless ts.nil?\n\n if position.exit_date > position.xttime\n xtival = position.xtival.nil? ? -0.00 : position.xtival.abs > 100.0 ? -0.00 : position.xtival\n logger.info(\"\\t\\t\\t\\t\\t\\tDH\\tXTROI\\tDELTA\\tROI\\tXTIVAL\\tRSI\") if log?(:closures) and log_counter % 50 == 0\n logger.info format(\"Position %d of %d (%s)\\t%s\\t%d\\t%3.2f%%\\t%3.2f\\t%3.2f%%\\t%3.2f\\t%3.2f\\t%s\",\n counter, pos_count, position.ticker.symbol,\n position.xttime.to_formatted_s(:ymd), position.exit_days_held,\n position.xtroi*100, position.exit_delta, position.roi*100,\n xtival , position.exit_ival, position.xtind.name) if log? :closures\n log_counter += 1 if log? :closures\n elsif position.exit_date < position.xttime\n xtival = position.xtival.nil? ? -0.00 : position.xtival.abs > 100.0 ? -0.00 : position.xtival\n logger.info format(\"!!!Position %d of %d (%s)\\t%s %s\\t%3.2f\\t%3.2f\\t%3.2f\\t%3.2f\\t%s\",\n counter, pos_count, position.ticker.symbol,\n position.xttime.to_formatted_s(:ymd), position.exit_date.to_formatted_s(:ymd),\n position.xtprice, position.exit_price,\n xtival , position.exit_ival, position.xtind.name) if log? :closures\n end\n rescue TimeseriesException => e\n logger.error(\"#{e.class.to_s}: #{e.to_s}. DELETING POSITION!\")\n remove_from_position_map(position)\n Position.delete position.id\n end\n counter += 1\n end\n end\n end\n\n endt = Time.now\n delta = endt - startt\n logger.info \"Max Optimize limit reached = #{max_limit_counter}\"\n logger.info \"(#{chunk_id}) Backtest (optimize close analysis) elapsed time: #{Backtester.format_et(delta)}\" if log? :basic\n\n #-----------------------------------------------------------------------------------------------------------------\n # Persist the closed positions to the disk resident Positions table by walking through the positions in the\n # position map and writing out only those which closed\n #-----------------------------------------------------------------------------------------------------------------\n startt = Time.now\n\n columns = Position.columns.map(&:name)\n columns.delete 'id'\n\n #TODO replace this entire block with a single constructed INSERT stmt with conditions on scan_id and exit_date\n #TODO see Position.generate_insert_sql\n\n sql = \"insert into positions select #{columns.join(',')} from #{Position.table_name} where scan_id = #{scan.id} \"+\n \"and exit_date is not null\"\n #Position.connection.execute(sql)\n\n endt = Time.now\n delta = endt - startt\n logger.info \"Backtest (persist positions) elapsed time: #{Backtester.format_et(delta)}\" if log? :basic\n\n\n #--------------------------------------------------------------------------------------------------------------------\n # Stop-loss pass. The nitty gritty of threshold crossing is handeled by tstop(...)\n #-------------------------------------------------------------------------------------------------------------------\n unless stop_loss.nil? || stop_loss.threshold.to_f == 100.0\n logger.info \"Beginning stop loss analysis...\"\n startt = Time.now\n open_positions = exit_strategy.positions.find(:all, :conditions => { :scan_id => scan.id })\n open_positions.each do |p|\n tstop(p, stop_loss.threshold, stop_loss.options)\n end\n endt = Time.now\n delta = endt - startt\n deltam = delta/60.0\n logger.info \"Backtest (stop loss analysys) elapsed time: #{deltam} minutes\" if log? :basic\n end\n #--------------------------------------------------------------------------------------------------------------------\n # Post processing which not only includes make_sheet(...)\n #-------------------------------------------------------------------------------------------------------------------\n if post_process\n logger.info \"(#{chunk_id}) Beginning post processing (make_sheet)...\" if log? :basic\n startt = Time.now\n\n post_process.call(entry_trigger, entry_strategy, exit_trigger, exit_strategy, scan) if post_process\n\n endt = Time.now\n delta = endt - startt\n\n logger.info \"(#{chunk_id}) Post processing (make_sheet) elapsed time: #{Backtester.format_et(delta)}\" if log? :basic\n end\n end",
"def queue(message); end",
"def initialize(exchange_name = nil, routing_key: nil, connection: nil, context: nil, ident: nil, expiration: nil, persistent: true, durable: true, timeout: nil)\n super(connection: connection, context: context, ident: ident)\n\n @routing_key = routing_key\n @timeout = timeout\n\n @rpc_exchange = self.channel.direct(\n exchange_name || EXCHANGE_NAME_DEFAULT,\n durable: durable\n )\n\n @response_queue = self.channel.queue(\n @ident,\n durable: false,\n header: true,\n auto_delete: true\n )\n @expiration = expiration\n @persistent = !!persistent\n\n @callback = { }\n\n @consumer = Skein::Adapter.subscribe(@response_queue, block: false) do |payload, delivery_tag, reply_to|\n self.context.trap do\n if (ENV['SKEIN_DEBUG_JSON'])\n $stdout.puts(payload)\n end\n\n response = JSON.load(payload)\n\n if (callback = @callback.delete(response['id']))\n if (response['error'])\n exception =\n case (response['error'] and response['error']['code'])\n when -32601\n NoMethodError.new(\n \"%s from `%s' RPC call\" % [\n response.dig('error', 'message'),\n response.dig('error', 'data', 'method')\n ]\n )\n when -32602\n ArgumentError.new(\n response.dig('error', 'data', 'message') || 'wrong number of arguments'\n )\n else\n RPCException.new(\n response.dig('error', 'data', 'message') || response.dig('error', 'message')\n )\n end\n\n case (callback)\n when Skein::TimeoutQueue\n callback << exception\n when Proc\n callback.call(exception)\n end\n else\n case (callback)\n when Skein::TimeoutQueue\n callback << response['result']\n when Proc\n callback.call(response['result'])\n end\n end\n end\n\n self.channel.acknowledge(delivery_tag)\n end\n end\n end",
"def run\n @running = true\n while @running do\n begin\n message = Hastur::Message.recv(@data_socket)\n envelope = message.envelope\n uuid = message.envelope.from\n Hastur::Cassandra.insert(@client, message.payload, envelope.type_symbol.to_s, :uuid => uuid)\n envelope.to_ack.send(@ack_socket) if envelope.ack?\n rescue Hastur::ZMQError => e\n @logger.error \"Error reading from ZeroMQ socket.\", { :exception => e, :backtrace => e.backtrace }\n rescue Exception => e\n @logger.error e.to_s, { :message => e.message, :backtrace => e.backtrace }\n end\n end\n end",
"def run\n @running = true\n\n while @running do\n message = Hastur::Message.recv(@data_socket)\n envelope = message.envelope\n uuid = message.envelope.from\n Hastur::Cassandra.insert(@client, message.payload, envelope.type_symbol.to_s, :uuid => uuid)\n envelope.to_ack.send(@ack_socket) if envelope.ack?\n end\n\n rescue Hastur::ZMQError => e\n @logger.error \"Error reading from ZeroMQ socket.\", { :exception => e, :backtrace => e.backtrace }\n rescue Exception => e\n @logger.warn \"unhandled exception! Dropped message: #{message}\"\n Hastur::Util.log_exception e, @logger\n raise e\n end",
"def run\n @output.print \"Run, Forest, run!\"\n \n EM.synchrony do\n print \"Mapper has been started #{Time.now}\"\n AMQP.start do |connection|\n print \"AMQP started #{Time.now}\"\n channel = AMQP::Channel.new connection\n queue = channel.queue(@config[\"broker\"][\"queue-name\"], :auto_delete => true)\n queue.subscribe do |payload|\n print \"Received message #{payload}\"\n connection.close {EM.stop} if payload == \"stop\"\n Fiber.new{start}.resume if payload == \"start\"\n Fiber.new {match}.resume if payload == 'match'\n EM.defer {start_webserver} if payload == 'start_webserver'\n EM.defer {start_search_server} if payload == 'start_solr'\n EM.defer {stop_search_server} if payload == 'stop_solr'\n EM.defer {add_db_to_search_index} if payload == 'index'\n EM.defer {setup_storage} if payload == 'setup_storage'\n end\n end\n end\n end",
"def process\n process_setting_specs\n process_shard_specs\n process_connection_specs\n end",
"def perform(*args)\n puts \"\"\n puts \"* Sending in 5s...\"\n sleep(5)\n puts \"* Inside SendSlackMessageAllJob *\"\n\n puts \"> Finding Survey with id #{args[0][:survey_id]}\"\n survey = Survey.find(args[0][:survey_id])\n puts \"> Finding Question with id #{args[0][:question_id]}\"\n question = Question.find(args[0][:question_id])\n team = User.find(survey.user_id).team\n\n puts \"> Fetching member list from SLACK API (not async)\"\n member_list = HTTParty.get(\"https://slack.com/api/channels.info\",\n query: {\n token: team.bot_access_token,\n channel: survey.channel_id })\n\n # Now handled in Controller\n # member_list[\"channel\"][\"members\"].reject { |x| x == User.find(survey.user_id).uid }.each do |uid|\n # GetSlackUserInfoJob.perform_later(uid: uid, surv_id: args[0][:survey_id], team_id: xxx)\n # end\n\n\n\n sender_fn = \"#{User.find(survey.user_id).first_name.capitalize}\"\n sender_ln = \"#{User.find(survey.user_id).last_name.capitalize}\"\n others = member_list[\"channel\"][\"members\"].count - 1\n\n message_text = \"Hi! #{sender_fn} #{sender_ln} wants a Critiq. #{others.to_words.capitalize} other people have been messaged and everyone's responses will be anonymized. #{sender_fn} asks:\\n\"\n\n puts \"> Beginning to iterate over member list...\"\n member_list[\"channel\"][\"members\"].each do |member_uid|\n # Put this in the above line before '.each' to prevent critiq's from being sent to their creator\n # .reject { |x| x == User.find(survey.user_id).uid }\n\n send_message(member_uid, message_text, team)\n\n if question.question_type == 'radio'\n puts \"> Question is MC\"\n send_message_multiple_choice(member_uid, question, team)\n else\n puts \"> Question is NOT MC\"\n send_message(member_uid, question.name, team)\n end\n\n puts \">> Creating SentQuestion entry for Question: #{args[0][:question_id]}, User: #{member_uid}\"\n SentQuestion.create(question_id: args[0][:question_id], recipent_slack_uid: member_uid)\n\n end\n puts \"> Finished sending all messages <\"\n\n end",
"def process_queue\n puts \"Waiting for new messages\"\n th = Thread.new do\n Thread.current.abort_on_exception = true\n loop do\n # This will sit around and wait forever.\n key, raw_msg = @redis_client.blpop(@redis_in_key, 0)\n json_msg = Crack::JSON.parse(raw_msg)\n # Send back a random quote\n random_quote = @quotes[rand(@quotes.size)]\n out_msg = {:from => json_msg['from'], :body => random_quote}.to_json\n # Pusing onto the \"out\" list queues up something for the listener to process\n @redis_client.lpush(@redis_out_key, out_msg)\n end\n end \n end",
"def process_command\n @fiber.resume get_result\n end",
"def process\n puts 'Bacground processor - %s' % self\n\n read do |func, data|\n Lux::DelayedJob.call func, data\n end\n end",
"def process(source)\n Thread.abort_on_exception = true\n ships_tsw = ThreadSafeWrapper.new(Hash.new)\n safety_message_tsw = ThreadSafeWrapper.new(\"\")\n\n start_threads(ships_tsw, safety_message_tsw)\n\n # listen for AIS messages, constantly\n listener = Thread.new do\n decoder = NMEAPlus::SourceDecoder.new(source)\n decoder.each_complete_message do |message|\n update_ship_information(ships_tsw, safety_message_tsw, message)\n\n yield if block_given?\n sleep(0.001) # give other threads a chance to work\n end # decoding\n puts \"end of decoding, but will keep server running for #{GRACE_PERIOD} more seconds\"\n\n # keep running other threads for a bit, like the http server\n sleep(GRACE_PERIOD)\n stop_threads\n\n end # thread\n\n join_threads\n listener.join\n end",
"def process_job_msg(job_msg)\n msg = job_msg[\"msg\"]\n data = job_msg[\"data\"]\n\n if status == 'pending' && msg == 'begin'\n @status = 'running'\n @start_time = Time.now\n elsif (status == 'running' || status == 'unknown') && (msg == 'success' || msg == 'failure')\n @status = msg\n @result = data\n @duration = Time.now - @start_time\n elsif (status == 'running' || status == 'unknown') && msg == 'exception'\n @status = 'exception'\n @exception = data\n @duration = Time.now - @start_time\n elsif msg == \"info\"\n # Ignore client defined messages\n true\n elsif msg == \"arrhythmia\"\n @status = 'unknown'\n @duration = Time.now - @start_time\n else\n raise \"State machine Error #{job_msg}\"\n end\n end",
"def run\n super\n\n email_address = _get_entity_name\n\n @api_key = _get_task_config(\"hibp_api_key\")\n unless @api_key\n _log_error \"unable to proceed, no API key for HIBP provided\"\n return\n end\n\n _search_pastes_and_create_issues(email_address) if _get_option(\"search_pastes\")\n _search_breaches_and_create_issues(email_address) if _get_option(\"search_breaches\")\n end",
"def execute\n @checkup = {}\n\n case @publisher\n when 'sql'\n begin\n @d = I2X::SQLDetector.new(self)\n rescue Exception => e\n @response = {:status => 400, :error => e}\n I2X::Config.log.error(self.class.name) {\"#{e}\"}\n end\n when 'csv'\n begin\n @d = I2X::CSVDetector.new(self)\n rescue Exception => e\n @response = {:status => 400, :error => e}\n I2X::Config.log.error(self.class.name) {\"#{e}\"}\n end\n when 'xml'\n begin\n @d = I2X::XMLDetector.new(self)\n rescue Exception => e\n @response = {:status => 400, :error => e}\n I2X::Config.log.error(self.class.name) {\"#{e}\"}\n end\n when 'json'\n begin\n @d = I2X::JSONDetector.new(self)\n rescue Exception => e\n @response = {:status => 400, :error => e}\n I2X::Config.log.error(self.class.name) {\"#{e}\"}\n end\n end\n\n\n # Start checkup\n begin\n unless content.nil? then\n @d.content = content\n end\n @checkup = @d.checkup\n rescue Exception => e\n I2X::Config.log.error(self.class.name) {\"Checkup error: #{e}\"}\n end\n\n # Start detection\n begin\n @d.objects.each do |object|\n @d.detect object\n end\n\n @checkup[:templates] = @d.templates.uniq\n rescue Exception => e\n I2X::Config.log.error(self.class.name) {\"Detection error: #{e}\"}\n end\n\n begin\n if @checkup[:status] == 100 then\n process @checkup\n end\n rescue Exception => e\n I2X::Config.log.error(self.class.name) {\"Process error: #{e}\"}\n end\n response = {:status => @checkup[:status], :message => \"[i2x][Checkup][execute] All OK.\"} \n end",
"def call\r\n # TODO: rename to more appropriate one 2007/05/10 by shino\r\n self.modify_message\r\n logger.debug{\"Ap4r::Dispatcher after modification\\n#{@message.to_yaml}\"}\r\n self.invoke\r\n self.validate_response\r\n self.response\r\n end",
"def message(event)\n req = Message.from_wire(event.data)\n\n if req.type == \"rpc\" then\n # Execute the requested method and return the result\n # Do it asynchronously so as not to hold up the EM-loop while the command is running\n @thread_pool.perform do\n json_req = req.json_request\n logger.debug { \"RPC request\\n#{json_req}\" }\n json_response = @handler.new(req).handle(json_req)\n EM.next_tick { ws.send(Response.new(json_response, req.id).to_wire) }\n end\n\n elsif req.type == \"rpc_result\" then\n # Pass the result back to the caller\n res = req.json_response\n logger.debug { \"RPC_RESULT for request id [#{req.id}]\\n#{res}\" }\n @responses[req.id].response = res\n\n elsif req.type == \"connect\" then\n # Agent request to CONNECT to the manager\n # will only be received by the server-end of the channel\n logger.debug { \"CONNECT request #{req.id}\"}\n ret = @handler.new(req).connect(req.json_request, self)\n if ret.kind_of? JsonResponse then\n ws.send(Response.new(ret, req.id).to_wire)\n else\n ws.send(Response.new(JsonResponse.new(\"success\"), req.id).to_wire)\n end\n\n end\n end",
"def process\n data = @result['data']\n @source = 'Trello'\n @from = @result['memberCreator']['fullName']\n @project = data['board']['name']\n\n @board_id = data['board']['id']\n @board_link = \"https://trello.com/board/#{@board_id}\"\n\n card_data = data['card'] || {}\n @card_link = \"https://trello.com/card/#{@board_id}/#{card_data['idShort']}\"\n card_name = card_data['name']\n subject, @content = process_event @result, card_name\n @content += \"<p><a href='#{@board_link}'>Board: #{@board_link}</a>\"\n @subject = \"#@from: #{subject}\"\n self\n end",
"def enqueue_pending_output; end",
"def call_block_for_request(request, parsed_response)\n if parsed_response[\"body\"].nil?\n request.on_complete_block.call(parsed_response) if request.on_complete_block\n else\n case request.token.gsub(/:.*/, \"\")\n when \"subscribe\"\n request.on_datastream_block.call(parsed_response) if request.on_datastream_block\n when \"get\"\n request.on_get_block.call(parsed_response) if request.on_get_block\n end\n end\n end",
"def process_head_message(message)\n report = build_report(message)\n message_type = report[:type]\n case message_type\n when START\n update_chunk(report, message)\n when FINISH\n update_chunk(report, message)\n check_job_status(report)\n when CREATED\n update_chunk(report, message, true)\n when JOBUNPACKING\n job_status(report, message, \"Unpacking\")\n when JOBUNPACKED\n job_status(report, message, \"Processing\")\n when JOBPACKING\n job_status(report, message, \"Packing\")\n when JOBPACKED\n set_job_complete(report, message)\n when SENDSTATISTICS\n statistics_to_vipstats(report, message)\n when BACKGROUNDUPLOAD\n background_upload(report, message)\n when PROCESSDATABASE\n process_search_database(report, message)\n when PROCESSDATAFILE\n process_datafile(report, message)\n else\n message.delete\n end\n end",
"def process_pdu(pdu)\n case pdu\n when Pdu::DeliverSm\n write_pdu(Pdu::DeliverSmResponse.new(pdu.sequence_number))\n logger.debug \"ESM CLASS #{pdu.esm_class}\"\n if pdu.esm_class != 4\n # MO message; invoke MO proc\n @mo_proc.call(pdu.source_addr, pdu.destination_addr, pdu.short_message)\n else\n # Invoke DR proc (let the owner of the block do the mapping from msg_reference to mt_id)\n @dr_proc.call(pdu.msg_reference.to_s, pdu.stat)\n end \n when Pdu::BindTransceiverResponse\n case pdu.command_status\n when Pdu::Base::ESME_ROK\n logger.debug \"Bound OK.\"\n @state = :bound\n when Pdu::Base::ESME_RINVPASWD\n logger.warn \"Invalid password.\"\n EventMachine::stop_event_loop\n when Pdu::Base::ESME_RINVSYSID\n logger.warn \"Invalid system id.\"\n EventMachine::stop_event_loop\n else\n logger.warn \"Unexpected BindTransceiverResponse. Command status: #{pdu.command_status}\"\n EventMachine::stop_event_loop\n end\n when Pdu::SubmitSmResponse\n mt_message_id = @ack_ids[pdu.sequence_number]\n if !mt_message_id\n raise \"Got SubmitSmResponse for unknown sequence_number: #{pdu.sequence_number}\"\n end\n if pdu.command_status != Pdu::Base::ESME_ROK\n logger.error \"Error status in SubmitSmResponse: #{pdu.command_status}\"\n else\n logger.info \"Got OK SubmitSmResponse (#{pdu.message_id} -> #{mt_message_id})\"\n end\n # Now we got the SMSC message id; create pending delivery report\n @pdr_storage[pdu.message_id] = mt_message_id\n when Pdu::SubmitMultiResponse\n mt_message_id = @ack_ids[pdu.sequence_number]\n if !mt_message_id\n raise \"Got SubmitMultiResponse for unknown sequence_number: #{pdu.sequence_number}\"\n end\n if pdu.command_status != Pdu::Base::ESME_ROK\n logger.error \"Error status in SubmitMultiResponse: #{pdu.command_status}\"\n else\n logger.info \"Got OK SubmitMultiResponse (#{pdu.message_id} -> #{mt_message_id})\"\n end\n else\n super\n end \n end",
"def work(raw_post)\n email_params = JSON.parse(raw_post).with_indifferent_access\n send_simple_message(params)\n ack! # we need to let queue know that message was received\n end",
"def process_request(message, request_options = nil)\n # this method could be called by any thread, so we need to serialize the call back\n # onto the reactor thread so that we aren't doing a socket operation from a\n # non-reactor thread. 0mq gets very upset if we try.\n #\n schedule { @handler.process_request(message, request_options) }\n end",
"def dispatching_loop(group, conf, index)\r\n group.add(Thread.current)\r\n mq = ::ReliableMsg::MultiQueue.new(conf[\"targets\"])\r\n logger.info{ \"start dispatcher: targets= #{mq}, index= #{index})\" }\r\n until Thread.current[:dying]\r\n # TODO: change sleep interval depending on last result? 2007/05/09 by shino\r\n sleep @@sleep_inverval\r\n # logger.debug{ \"try dispatch #{mq} #{mq.name}\" }\r\n # TODO: needs timeout?, 2006/10/16 shino\r\n begin\r\n mq.get{|m|\r\n unless m\r\n logger.debug{\"message is nul\"}\r\n break\r\n end\r\n logger.debug{\"dispatcher get message\\n#{m.to_yaml}\"}\r\n response = get_dispather_instance(m.headers[:dispatch_mode], m, conf).call\r\n logger.debug{\"dispatcher get response\\n#{response.to_yaml}\"}\r\n }\r\n rescue Exception => err\r\n logger.warn(\"dispatch err #{err.inspect}\")\r\n logger.warn(err.backtrace.join(\"\\n\"))\r\n end\r\n end\r\n logger.info{\"end dispatcher #{mq} (index #{index})\"}\r\n end",
"def process\n caption = response_text\n channel = channel_by_keyword\n channel_group = channel_group_by_keyword\n\n if channel || channel_group\n tmp = response_text.split\n tmp.shift\n caption = tmp.join(\" \")\n end\n\n delivery_notice = nil\n dn_responding_message_unconfigured = nil\n responding_messages_delivery = responding_messages_delivery_with_no_responses(channel, channel_group)\n\n responding_messages_delivery.each do |dn|\n unless dn.message.check_subscriber_response(response_text)\n dn_responding_message_unconfigured = dn\n next\n end\n delivery_notice = dn\n break\n end\n\n delivery_notice ||= dn_responding_message_unconfigured\n delivery_notice ||= last_sent_relevant_delivery(channel, channel_group)\n\n process_delivery_notice(\n delivery_notice,\n caption: caption,\n channel: channel,\n channel_group: channel_group,\n )\n end",
"def execute\n logger.info('Processing message...')\n\n # Process message\n resp = execute_middleware_chain\n\n # Log processing completion and return result\n logger.info(\"Processing done after #{process_duration}s\") { { duration: process_duration } }\n resp\n rescue StandardError => e\n logger.info(\"Processing failed after #{process_duration}s\") { { duration: process_duration } }\n raise(e)\n end",
"def process_request(env)\n @triggered = []\n @env = @default_options.merge(env)\n perform_receive\n end",
"def process_request(env)\n @triggered = []\n @env = @default_options.merge(env)\n perform_receive\n end",
"def call( env )\n resource_request = RESTRack::ResourceRequest.new( :request => Rack::Request.new(env) )\n unless @request_hook.nil? or (RESTRack::CONFIG.has_key?(:PRE_PROCESSOR_DISABLED) and RESTRack::CONFIG[:PRE_PROCESSOR_DISABLED])\n @request_hook.pre_processor(resource_request)\n end\n response = RESTRack::Response.new(resource_request)\n unless resource_request.requires_async_defer\n unless @request_hook.nil? or (RESTRack::CONFIG.has_key?(:POST_PROCESSOR_DISABLED) and RESTRack::CONFIG[:POST_PROCESSOR_DISABLED])\n @request_hook.post_processor(response)\n end\n env['async.callback'].call response.output\n end\n AsyncResponse\n end",
"def process checkup\n ##\n # => Load seed.\n #\n begin\n rescue Exception => e\n \tServices::Slog.exception e\n end\n \n ## this should be simpler!!!\n begin\n \ti = 0\n \t#AgentMapping.where(:agent_id => id).each do |mapping|\n \t\t#Integration.where(:id => mapping.integration_id).each do |integration|\n self.integrations.each do |integration|\n \t\t\tintegration.templates.each do |t|\n \t\t\t\tServices::Slog.debug({:message => \"Sending #{identifier} for delivery by #{t.identifier}\", :module => \"Agent\", :task => \"process\", :extra => {:agent => identifier, :template => t.identifier, :payload => checkup[:payload].to_s, :destination => \"#{ENV[\"APP_HOST\"]}postman/deliver/#{t.identifier}.js\"}})\n \t\t\t\tcheckup[:payload].each do |payload|\n \t\t\t\t\tresponse = RestClient.post \"#{ENV[\"APP_HOST\"]}postman/deliver/#{t.identifier}.js\", payload\n \t\t\t\t\tcase response.code\n \t\t\t\t\twhen 200\n \t\t\t\t\t\ti = i + 1\n \t\t\t\t\t\t@event = Event.new({:payload => payload, :status => 100, :agent => self})\n \t\t\t\t\t\t@event.save\n \t\t\t\t\telse\n \t\t\t\t\t\tServices::Slog.warn({:message => \"Delivery failed for #{identifier} in #{t.identifier}\", :module => \"Agent\", :task => \"process\", :extra => {:agent => identifier, :template => t.identifier}})\n \t\t\t\t\tend \n \t\t\t\tend\n \t\t\tend\n \t\t#end\n \tend\n \tRestClient.post(\"#{ENV[\"APP_HOST\"]}fluxcapacitor/agents/#{id}/update_meta\", {:events_count => events_count + i, :last_check_at => Time.now}) if i > 1\n rescue Exception => e\n \tServices::Slog.exception e\n end\n \nend",
"def queue_job; end",
"def process_next_server_message\n msg = nil\n begin\n @mutex_srvmsg.synchronize{\n if @srv_msg_queue.size > 0 and !is_msg_handler_suspended?\n msg = @srv_msg_queue.pop \n end\n }\n if msg != nil\n #@log.debug \"[QPROC] Process msg from idle\"\n process_srv_command(msg)\n end \n rescue=> detail\n @log.error \"Parser error(#{$!}) on #{msg}\"\n @log.error detail.backtrace.join(\"\\n\")\n end\n end",
"def run\n if options(:object)\n loop{ options(:object).instance_exec(receive, &@receive_block) }\n elsif @receive_block\n loop{ @receive_block.call(receive) }\n else\n loop{ receive }\n end\n rescue Stop\n nil\n rescue Exception => e\n @exception = e\n @last_message = @message\n ensure\n @state = :finished\n notify_linked_of(@exception) if @exception\n end",
"def output_thread_step\n obj = @send_q.deq\n case obj\n when Message\n# rt_debug \"output: sending message #{obj}\" + (obj.id == :request ? \" (request queue size #{@want_blocks.length})\" : \"\")\n send_bytes obj.to_wire_form\n @time[:send] = Time.now\n when Block\n# rt_debug \"output: sending block #{obj}\"\n send_bytes Message.new(:piece, {:length => obj.length, :index => obj.pindex, :begin => obj.begin}).to_wire_form\n obj.each_chunk(BUFSIZE) { |c| send_bytes c }\n @time[:send] = Time.now\n @ulmeter.add obj.length\n# rt_debug \"sent block #{obj} ul rate now #{(ulrate / 1024.0).round}kb/s\"\n else\n raise \"don't know what to do with #{obj}\"\n end\n end",
"def perform\n\n begin\n\n while true\n set_data_for_current_iteration\n\n get_block_transactions\n\n r = validate_response\n return r unless r.success?\n\n if blocks_trail_count >= MIN_BLOCK_DIFFERENCE\n\n process_transactions\n\n update_last_processed_block_number\n\n verify_token_count if blocks_trail_count == MIN_BLOCK_DIFFERENCE\n\n end\n\n return if blocks_trail_count <= MIN_BLOCK_DIFFERENCE\n return if GlobalConstant::SignalHandling.sigint_received?\n end\n\n rescue StandardError => e\n puts e.inspect\n Rails.logger.error(e)\n return\n end\n\n end",
"def submit\n self.http_get(self.poll_url)#.tap{|t| STDERR.puts \"Trace: #{caller[1]}: returning #{t}\"}\n end",
"def unboundRequest(params)\n broker_url = APP_CONFIG['broker_ip'] + ':' + APP_CONFIG['broker_port'].to_s\n\n resources = []\n\n h1 = Hash.new\n h2 = Hash.new\n\n # puts Time.zone.now\n\n if params[:start_date] != \"\"\n valid_from = params[:start_date] + \":00 \"\n valid_from = Time.zone.parse(valid_from)\n else\n time_now = Time.zone.now.to_s.split(\" \")[1][0...-3]\n time_from = roundTimeUp(time_now)\n valid_from = Time.zone.now.to_s.split(\" \")[0] + \" \" +time_from+ \":00 \"\n valid_from = Time.zone.parse(valid_from)\n end\n\n #For nodes\n if params[:number_of_nodes] != \"\"\n if params[:duration_t1] != \"\"\n if params[:domain1] != \"\"\n h1 = { type: \"Node\", exclusive: true, duration: params[:duration_t1].to_i, valid_from: valid_from, domain: params[:domain1]}\n else\n h1 = { type: \"Node\", exclusive: true, duration: params[:duration_t1].to_i, valid_from: valid_from}\n end\n else\n if params[:domain1] != \"\"\n h1 = { type: \"Node\", exclusive: true, valid_from: valid_from, domain: params[:domain1]}\n else\n h1 = { type: \"Node\", exclusive: true, valid_from: valid_from}\n end\n end \n\n params[:number_of_nodes].to_i.times {resources << h1}\n\n end\n\n #For channels\n if params[:number_of_channels] != \"\"\n if params[:duration_t1] != \"\"\n if params[:domain1] != \"\"\n h1 = { type: \"Channel\", exclusive: true, duration: params[:duration_t1].to_i, valid_from: valid_from, domain: params[:domain1]}\n else\n h1 = { type: \"Channel\", exclusive: true, duration: params[:duration_t1].to_i, valid_from: valid_from}\n end\n else\n if params[:domain1] != \"\"\n h1 = { type: \"Channel\", exclusive: true, valid_from: valid_from, domain: params[:domain1]}\n else\n h1 = { type: \"Channel\", exclusive: true, valid_from: valid_from}\n end\n end \n\n params[:number_of_channels].to_i.times {resources << h1}\n\n end\n\n options = {body: {\n resources: resources\n }.to_json, :headers => { 'Content-Type' => 'application/json' } , :verify => false}\n response = HTTParty.get(broker_url+\"/resources\", options)\n\n puts options\n\n if response.header.code != '200'\n puts \"Something went wrong\"\n puts response\n flash[:danger] = response\n else \n puts response\n response[\"resource_response\"][\"resources\"].each do |element|\n element[\"valid_from\"] = Time.zone.parse(element[\"valid_from\"]).to_s\n element[\"valid_until\"] = Time.zone.parse(element[\"valid_until\"]).to_s\n end\n\n return response\n end\n end",
"def call(env)\n request_id = id_generator.call\n logger.info formatter.message_from_request_body(env, request_id)\n app.call(env).on_complete do |env|\n logger.info formatter.message_from_response_body(env, request_id)\n end\n end",
"def mainloop3(reader,writer)\n h = @handler.new\n state = :init\n abi = 1\n last_soa_name = nil\n\n reader.each_line do |line|\n h.log = []\n h.result = false\n\n # cannot continue anymore\n if state == :fail\n next\n end\n\n input = {}\n line = line.strip\n if (state == :init) \n if line.match \"HELO[ \\t]*([0-9])\"\n abi = $2.to_i\n # synthesize empty init\n h.do_initialize(input)\n\n if h.result == false\n state = :fail\n h.log.each do |l| \n writer.puts \"LOG\\t#{l}\"\n end\n writer.puts \"FAIL\"\n else\n writer.puts \"OK\\tPowerDNS ruby remotebackend version #{Pdns::Remotebackend::VERSION} initialized\"\n state = :main \n end\n else\n writer.puts \"FAIL\"\n state = :fail\n end\n next\n end\n \n # parse input\n query = line.split /[\\t ]+/\n input[\"method\"] = query[0]\n if input[\"method\"] == \"Q\"\n input[\"method\"] = \"lookup\"\n input[\"parameters\"] = {\n \"qname\" => query[1], \"qclass\" => query[2],\n \"qtype\" => query[3], \"domain_id\" => query[4].to_i,\n \"zone_id\" => query[4].to_i, \"remote\" => query[5]\n }\n if abi > 1 \n input[\"parameters\"][\"local\"] = query[6]\n end\n if abi > 2\n input[\"parameters\"][\"edns-subnet\"] = query[7]\n end\n if input[\"parameters\"][\"qtype\"] == \"SOA\"\n last_soa_name = input[\"parameters\"][\"qname\"]\n end\n elsif input[\"method\"] == \"AXFR\"\n input[\"method\"] = \"list\"\n input[\"parameters\"] = { \"zonename\" => last_soa_name, \"domain_id\" => line[1].to_i }\n else\n writer.puts \"FAIL\"\n next\n end\n\n method = \"do_#{input[\"method\"]}\"\n # try to call\n if h.respond_to?(method.to_sym) == true\n h.send(method, input[\"parameters\"])\n else\n writer.puts \"FAIL\"\n next\n end\n\n if (h.result != false) \n h.result.each do |r|\n if r.has_key? :scopemask == false\n r[:scopemask] = 0\n end\n if r.has_key?(:domain_id) == false\n r[:domain_id] = input[\"parameters\"][\"domain_id\"]\n end\n\n # fix content to contain prio if needed\n if [\"MX\", \"SRV\", \"NAPTR\"].include? r[:qtype].upcase\n if r.has_key?(\"prio\")\n r[:content] = \"#{r[:prio].to_i} #{r[:content]}\"\n else\n r[:content] = \"0 #{r[:content]}\"\n end\n end\n if (abi < 3)\n writer.puts \"DATA\\t#{r[:qname]}\\tIN\\t#{r[:qtype]}\\t#{r[:ttl]}\\t#{r[:domain_id]}\\t#{r[:content]}\"\n else\n writer.puts \"DATA\\t#{r[:scopemask]}\\t#{r[:auth]}\\t#{r[:qname]}\\tIN\\t#{r[:qtype]}\\t#{r[:ttl]}\\t#{r[:domain_id]}\\t#{r[:content]}\"\n end\n end\n end\n\n h.log.each do |l|\n writer.puts \"LOG\\t#{l}\"\n end\n writer.puts \"END\"\n end\n end",
"def process!\n end",
"def read\n while msg = consumer.pop\n begin\n data = JSON.parse msg.body\n yield data[0], data[1]\n rescue => error\n Lux::Error.split_backtrace error\n end\n\n msg.finish\n end\n end"
] |
[
"0.59011865",
"0.587079",
"0.58684707",
"0.58466643",
"0.583267",
"0.58268005",
"0.58240277",
"0.57761085",
"0.5758437",
"0.5729472",
"0.5704195",
"0.5645847",
"0.5567061",
"0.55201375",
"0.5518222",
"0.5499532",
"0.549418",
"0.54630053",
"0.54579365",
"0.544479",
"0.54348004",
"0.54061675",
"0.538418",
"0.537292",
"0.5371511",
"0.535222",
"0.5341289",
"0.53306985",
"0.532261",
"0.532152",
"0.5317154",
"0.5311426",
"0.5310387",
"0.5298653",
"0.52968436",
"0.5294032",
"0.5285747",
"0.5283476",
"0.5283193",
"0.5280564",
"0.5267531",
"0.5262151",
"0.5255417",
"0.52550024",
"0.524406",
"0.5239921",
"0.52352804",
"0.5228193",
"0.5224663",
"0.52223146",
"0.52166635",
"0.5213932",
"0.5210895",
"0.5207013",
"0.5204031",
"0.5199186",
"0.51991016",
"0.5198867",
"0.5197997",
"0.51960665",
"0.5194429",
"0.51943624",
"0.5193459",
"0.51917213",
"0.5191385",
"0.51858586",
"0.51790553",
"0.51742274",
"0.5174182",
"0.5173456",
"0.51711965",
"0.51671374",
"0.5163441",
"0.51589173",
"0.51526535",
"0.5152266",
"0.51492673",
"0.51470524",
"0.5146558",
"0.5135342",
"0.5134752",
"0.5130239",
"0.5121647",
"0.5119938",
"0.51175606",
"0.51159424",
"0.51130617",
"0.51130617",
"0.51121515",
"0.51101625",
"0.5109379",
"0.5102785",
"0.510201",
"0.51016176",
"0.50993913",
"0.50955284",
"0.50943714",
"0.5093522",
"0.50852406",
"0.50834435",
"0.5082211"
] |
0.0
|
-1
|
Save for future use context data into the thread_store
|
def set_context(spark)
# store in thread_store for later use
sent_to spark[:sender]
previous_sender spark[:sender]
context_params({ reply_to: spark[:previous_sender], spark_uid: spark[:spark_uid]})
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def store\n Thread.current\n end",
"def save_context(context)\n session[:context] = context\n end",
"def save_context(context)\n message_context_session[:context] = context\n end",
"def context\n Thread.current[NAME] ||= Hash.new\n end",
"def context\n @context ||= {name: name, record: record}\n end",
"def local=(ctx)\n Thread.current[@key] = ctx\n end",
"def save_state\n\t\t@store.transaction do \n\t\t\t@store[:tracks] = @track_list\n\t\t\t@store[:artists] = @artist_list\n\t\t\t@store[:last_played] = @last_played\n\t\tend\n\tend",
"def initialize context\n @context = context\n @store = context.store\n\n @seen = {}\n end",
"def store(io, context = {})\n _store(io, context)\n end",
"def context\n Thread.current[NAME] ||= Array.new\n end",
"def request_data\n Thread.current[THREAD_LOCAL_NAME] ||= {}\n end",
"def context\n Thread.current[:ctx] ||= {}\n Thread.current[:ctx]\n end",
"def storing\n if block_given?\n yield\n end.tap { persist! if persistible? }\n end",
"def store\n @store ||= {}\n end",
"def store\n @store\n end",
"def store\n @store\n end",
"def context\n @context ||= {}\n end",
"def context\n @context ||= {}\n end",
"def context\n unless @instance_context\n @instance_context = TaskContext.new(@version , @params['workspace_sid'], @params['sid'])\n end\n @instance_context\n end",
"def local(thread = Thread.current)\n thread[@key] ||= Datadog::Context.new\n end",
"def root; thread_local_store[:root] end",
"def context\n unless @instance_context\n @instance_context = TaskContext.new(@version, @params['workspace_sid'], @params['sid'], )\n end\n @instance_context\n end",
"def store_in_batch(batch)\n # store the comment\n batch.set(firestore_doc_id, serialized_for_firestore)\n # store comment_thread to update its `updated_at`\n comment_thread.store_in_batch(batch)\n # ping all the users threads so they get an updated unread_count\n comment_thread.users_threads.each do |ut|\n ut.store_in_batch(batch)\n end\n end",
"def thread\n @thread ||= super\n return @thread unless @thread.nil?\n\n @thread = build_thread\n @thread.save if persisted?\n @thread\n end",
"def context &block\n self.worker.context(&block) \n end",
"def store *args, █ put *args, █ end",
"def store; end",
"def store; end",
"def store; end",
"def get_context\n @context_hash ||= {}\n end",
"def current=(context)\n all_contexts[Thread.current.object_id] = context\n end",
"def context\n init\n @context\n end",
"def _sync\n # Reset the stash map to ensure that it's reset before the next\n # transaction is being started.\n @_stash_map = nil\n\n db_obj = {\n 'class_id' => @store.class_map.class_to_id(self.class.to_s),\n 'data' => _serialize\n }\n @store.db.put_object(db_obj, @_id)\n end",
"def store\n self.class.store\n end",
"def context=(ctx)\n @context.local = ctx\n end",
"def store(key, value)\r\n obj = for_context(self) { |c| c.store(key, value); c }\r\n return if obj != self \r\n super(key, value)\r\n end",
"def thread_context\n Thread.current[:runshell_context] ||= Context.new(main_context.to_h)\n end",
"def []=(key,value)\n raise Wfe::Exception.new(\"workflow context hash accessed outside of execution scope\") unless ! @wf.nil?\n @wf.run_time_ctx[key] = value\n @wf.save\n end",
"def stored_data; end",
"def context\n unless @instance_context\n @instance_context = WorkersRealTimeStatisticsContext.new(@version , @params['workspace_sid'])\n end\n @instance_context\n end",
"def context=(value); end",
"def restore_queue_and_setup_persistence\n @store = YAML::Store.new(\"/config/update-handler.store\", true)\n @store.transaction do\n @queue = @store.fetch(\"queue\", [])\n @subject_map = @subject_map.merge(@store.fetch(\"index\", {}))\n @logger.info(\"UPDATE HANDLER\") { \"Restored update queue (length: #{@queue.length})\" }\n end\n\n @persister = Thread.new(abort_on_exception: true) do\n loop do\n sleep 300\n @mutex.synchronize do\n @logger.info(\"UPDATE HANDLER\") { \"Persisting update queue to disk (length: #{@queue.length})\" }\n begin\n @store.transaction do\n @store[\"queue\"] = @queue\n @store[\"index\"] = @subject_map\n end\n rescue StandardError => e\n @logger.error(\"UPDATE HANDLER\") { \"Failed to persist update queue to disk\" }\n @logger.error(\"UPDATE HANDLER\") { e.full_message }\n end\n end\n end\n end\n end",
"def store\n @store ||= storage.new self\n end",
"def store(type, file)\n require_writeable_layers!\n hash = store_immediately!(type, file)\n if layers.delayed.writeable.any?\n Dis::Jobs::Store.perform_later(type, hash)\n end\n hash\n end",
"def usage_tracker_context(data)\n self.usage_tracker_context = data\n end",
"def usage_tracker_context(data)\n self.usage_tracker_context = data\n end",
"def push_context(context_data)\n if context_data.is_a?(Class)\n context << context_data.new\n else\n context << context_data\n end\n end",
"def store\n @store ||= Hash.new\n end",
"def store\r\n return @store\r\n end",
"def save(task)\n @store.transaction do\n @store[task.id] = task\n end\n end",
"def store?; end",
"def store_itself\n\n #ldebug { \"store_itself() for #{@fei.to_debug_s}\" }\n #ldebug { \"store_itself() \\n#{OpenWFE::caller_to_s(0, 6)}\" }\n\n get_expression_pool.update(self)\n end",
"def save\n store = NotFoundCatcher.request_store.store\n store.transaction do\n\n store[self.role] = self\n\n end\n\n\n end",
"def store_merge_state; end",
"def store_merge_state; end",
"def store(*args); end",
"def save\n self.class.store(job_id, data, expire_at)\n self\n end",
"def with_context\n self.context_cache = {}\n yield\n ensure\n self.context_cache = nil\n end",
"def start_thread\n @thread ||= Thread.new do\n loop do\n sleep @timeout\n\n @mutex.lock\n @store.transform_values! do |value|\n sess, used = value\n if used\n [sess, !used]\n else # Not used since we've been here last time → free resources\n sess.close(@context)\n nil\n end\n end\n\n # We can't delete elements from the map in the #transform_values!\n # block, we just assign nil to them. Thus we need to filter\n # the map again here.\n @store.reject! { |_, v| v.nil? }\n\n @mutex.unlock\n end\n end\n end",
"def store\n connection.store\n end",
"def context\n unless @instance_context\n @instance_context = TaskStatisticsContext.new(@version , @params['assistant_sid'], @params['task_sid'])\n end\n @instance_context\n end",
"def current_store_id\n Thread.current[REQUEST_STORE_ID]\n end",
"def context=(ctx)\n @context = ctx\n end",
"def store_data key, value\n init_data\n\n Bot::DB[my_name][key] = value\n end",
"def store_data key, value\n init_data\n\n Bot::DB[my_name][key] = value\n end",
"def store(id, data)\n storage[id] = data\n end",
"def save!(context)\n raise NotImplementedError, \"Subclasses must implement a save!(context) method.\"\n end",
"def context\n unless @instance_context\n @instance_context = WorkersStatisticsContext.new(@version , @params['workspace_sid'])\n end\n @instance_context\n end",
"def store_in_batch(batch)\n batch.set(firestore_doc_id, serialized_for_firestore)\n end",
"def execution_context\n initialize_context!(Object.new)\n end",
"def write\n @id = store.put(self)\n end",
"def run_stored_block\n self.run_in_context @stored_block if @stored_block\n end",
"def save\n MoxiworksPlatform::Task.update(self.to_hash)\n end",
"def clean_thread_context(logger: nil, namespace: nil)\n if store(namespace).present?\n if logger.nil?\n puts \"WARNING: ThreadAccessor variables set outside ThreadAccessor context: #{store(namespace).keys.join(\", \")}\"\n else\n logger.warn(\"ThreadAccessor variables set outside ThreadAccessor context: #{store(namespace).keys.join(\", \")}\")\n end\n end\n\n yield\n ensure\n store(namespace).clear\n end",
"def store(options = {})\n each(&:store)\n self\n end",
"def datastore()\n\n\t\t\t\t\tif not @local_session[:dropbox_context] then\n\t\t\t\t\t\traise \"datastore not initialized, make sure you have retrieved a token \" +\n\t\t\t\t\t\t\t \"(include DropboxStore::TokenFilter and add before_filter :requires_token)\"\n\t\t\t\t\tend\n\n\t\t\t\t\t# has a session?\n\t\t\t\t\tif not DROPBOX_CONTEXTS[@local_session[:dropbox_context] + \"_DATA\"] then\n\t\t\t\t\t\tctx = DROPBOX_CONTEXTS[@local_session[:dropbox_context]]\n\n\t\t\t\t\t\t# generate a code block that is passed to the datastore constructor\n\t\t\t\t\t\tload_tables_proc = Proc.new do |data|\n\n\t\t\t\t\t\t\t@@store_definition_descriptor[:tables].each do |t_class|\n\t\t\t\t\t\t\t\tdata.table t_class\n\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\tDROPBOX_CONTEXTS[@local_session[:dropbox_context] + \"_DATA\"] = DropboxStore::Data.new(\n\t\t\t\t\t\t\t\tctx, \n\t\t\t\t\t\t\t\t@@store_definition_descriptor[:datastore_id],\n\t\t\t\t\t\t\t\t&load_tables_proc\n\t\t\t\t\t\t\t)\n\n\t\t\t\t\tend\n\n\t\t\t\t\treturn DROPBOX_CONTEXTS[@local_session[:dropbox_context] + \"_DATA\"] \n\t\t\t\tend",
"def save(wfid, jid, job, context_buffer)\n raise NotImplementedError\n end",
"def save_session()\n @store\n end",
"def usage_tracker_context=(data)\n unless request.env[key].blank?\n unless Rails.env.test? && !caller.grep(/test\\/functional/).blank?\n UsageTrackerMiddleware.log 'WARNING: overwriting context data!'\n end\n end\n\n request.env[key] = data\n end",
"def usage_tracker_context=(data)\n unless request.env[key].blank?\n unless Rails.env.test? && !caller.grep(/test\\/functional/).blank?\n UsageTracker.log 'WARNING: overwriting context data!'\n end\n end\n\n request.env[key] = data\n end",
"def delayed_store(type, hash)\n file = get(type, hash)\n layers.delayed.writeable.each do |layer|\n layer.store(type, hash, file)\n end\n end",
"def store=(store)\n @store = store\n end",
"def save\n @@data_store.insert(self)\n self\n end",
"def store_in_background(column, worker=::CarrierWave::Workers::StoreAsset)\n super\n (@@_carrierwave_store_in_background ||= {})[:\"#{column}\"] = worker\n end",
"def set(**options)\n options.symbolize_keys!\n keys = options.keys\n\n store = self.store\n\n previous_context = keys.zip(store.values_at(*keys)).to_h\n\n store.merge!(options)\n @after_change_callbacks.each(&:call)\n\n if block_given?\n begin\n yield\n ensure\n store.merge!(previous_context)\n @after_change_callbacks.each(&:call)\n end\n end\n end",
"def store\n @store ||= MotionPrime::Store.shared_store\n end",
"def store\n @@store ||= Store.get_store(0)\n end",
"def add_to_global_context(h)\n @global_context.merge!(h)\n end",
"def context(payload = nil)\n @context.merge! payload if payload\n @context\n end",
"def _prepare_context; end",
"def save_fabrication(type, time)\n return unless Thread.current.key?(type)\n return unless top_level_fabrication?\n\n Thread.current[type] += time\n end",
"def persist_data(db_columns_and_rows, store)\n store.transaction do\n store['db_columns_and_rows'] = db_columns_and_rows\n end\nend",
"def store= store\n super\n\n @attributes .each do |attr| attr.store = store end\n @constants .each do |const| const.store = store end\n @includes .each do |incl| incl.store = store end\n @extends .each do |ext| ext.store = store end\n @method_list.each do |meth| meth.store = store end\n end",
"def context\n @context.to_flat_hash\n end",
"def context(status, header, body, request)\n @context = context_retriever(request)&.call(status, header, body)\n @data[:request_context] = @context[:context_id] \\\n if @context && @context[:context_id]\n @context\n end",
"def []= key, value\n Thread.current[key] = value\n end",
"def save (do_eval = false)\n begin\n if @id.nil?\n @id = Strand.redis.incr SCOPE + ':count'\n self.class.active[@id.to_i] = self\n end\n Strand.redis.sadd SCOPE + ':' + @id.to_s, @members.map(&:typed_id)\n @members.each do |member|\n Strand.redis.hset LOOKUP, member.typed_id, @id.to_s\n end\n evaluate if do_eval\n Strand.redis.hset TOPICS, @id, @topic.code unless @topic.nil?\n Strand.redis.hset STATUS, @id, @good\n rescue Redis::CannotConnectError => e\n Rails.logger.warn 'Failed to save Strand to Redis, no connection.'\n end\n end",
"def persist(data)\n\t\tupdate_design_for self.shared_data_context\n\t\t\n\t\td = CouchRest::Document.new\n\t\td.database = proxy_database\n\n\t\t#copy data in to document\n\t\tdata.each do |key,value|\n\t\t\td[\"#{key}\"] = value\n\t\t\tputs \"added: #{key}\"\n\t\tend\n\t\td[:type] = self.shared_data_context.name\n\t\td[:date] = DateTime.now\n\n\t\tbegin\n\t\t\td.save false\n\t\trescue => e\n\t\t\tputs \"NOT SAVED: #{e.response}\"\n\t\t\t#TODO: properly handle this stuff\n\t\tend#\n\tend",
"def save_tb_data\n @tb_state = TB_DataSave.new\n end",
"def context\n Context.instance\n end"
] |
[
"0.7367369",
"0.65594435",
"0.6550074",
"0.6405408",
"0.5983536",
"0.5953486",
"0.591049",
"0.5887386",
"0.5846141",
"0.58443063",
"0.58374345",
"0.58030486",
"0.5778585",
"0.5688269",
"0.56869334",
"0.56869334",
"0.5669636",
"0.5669636",
"0.56667805",
"0.5641456",
"0.56315404",
"0.55866784",
"0.55731875",
"0.55720687",
"0.5546847",
"0.5527818",
"0.5525924",
"0.5525924",
"0.5525924",
"0.5524885",
"0.55060345",
"0.5497642",
"0.54844946",
"0.54743725",
"0.5449744",
"0.54379416",
"0.5400778",
"0.5400415",
"0.5387627",
"0.53860563",
"0.5371684",
"0.5362516",
"0.53573346",
"0.53245974",
"0.5321813",
"0.5321813",
"0.5320312",
"0.5319454",
"0.530468",
"0.5289853",
"0.5284249",
"0.5284218",
"0.5283228",
"0.5282717",
"0.5282717",
"0.52554107",
"0.5248021",
"0.52434003",
"0.5242149",
"0.52407545",
"0.52315557",
"0.52276725",
"0.5225789",
"0.5198804",
"0.5198804",
"0.5194398",
"0.5182168",
"0.51817334",
"0.5174586",
"0.5168577",
"0.51675594",
"0.51536673",
"0.51486176",
"0.51466936",
"0.514419",
"0.5126552",
"0.51249087",
"0.51229453",
"0.5120359",
"0.5112443",
"0.51093817",
"0.51091886",
"0.5108615",
"0.5107907",
"0.50929695",
"0.5091389",
"0.50850403",
"0.50820917",
"0.5081749",
"0.5081513",
"0.5078498",
"0.5070494",
"0.5070351",
"0.50683665",
"0.5067401",
"0.5066002",
"0.5065094",
"0.5063242",
"0.50546736",
"0.50397694"
] |
0.5379825
|
40
|
Manage pulling: the burst (persistent action) associated with the spark from the matching Redis hash if needed the context data
|
def get_burst(spark, _options={})
# get the context parameters
context_h = spark[:context]
burst_p = -> { cx_data.hget hsdq_key(spark), burst_key(spark) }
if response?(spark) && context_h
# save previous_sender in thread_store for later reply
sent_to context_h[:previous_sender]
# set the proc for multi redis to pull the initial request
burst_context_p = -> { cx_data.hget hsdq_key(spark), "request_#{context_h[:spark_uid]}" }
# exec the redis multi
burst_j, burst_context_j = pull_burst(burst_p, burst_context_p)
else
burst_j, burst_context_j = pull_burst_only burst_p
end
burst = burst_j ? (JSON.parse burst_j, {symbolize_names: true}) : {}
burst_context = burst_context_j ? (JSON.parse burst_context_j, {symbolize_names: true}) : {}
[burst, burst_context]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def fetch(params)\n Resque.logger.info \"Requestable.fetch received #{params.inspect}\"\n past = Time.now\n total = api_count(params)\n remain_requests = (total/250.to_f).ceil\n Resque.logger.info \"pages to request total: #{remain_requests}\"\n batch_num = (remain_requests / BATCH_SIZE.to_f).ceil\n Resque.logger.info \"batch number: #{batch_num}\"\n chap_start = 1\n chap_end = 0\n entity = params.fetch(:entity)\n Resque.logger.info \"entity name: #{entity}\"\n cache = $redis\n pages = []\n batch_num.times do\n entity_url = entity.pluralize\n if remain_requests > BATCH_SIZE\n chap_end += BATCH_SIZE\n remain_requests -= BATCH_SIZE\n else\n chap_end += remain_requests\n end\n hydra = Typhoeus::Hydra.new(max_concurrency: 30)\n\n chap_start.upto(chap_end) do |page|\n pages << page\n # queue up current batch\n request = Typhoeus::Request.new(\n \"https://api.rechargeapps.com/#{entity_url}?#{params[:query]}&limit=250&page=#{page}\",\n # followlocation: true,\n headers: HEADER\n )\n # error logging callbacks\n request.on_complete do |res|\n @used = res.headers['x-recharge-limit'].to_i\n if res.success?\n puts \"#{entity.upcase} request queued\"\n elsif res.timed_out?\n Resque.logger.error \"(HYDRA request) TIMED OUT: #{res.response_headers}\"\n elsif res.code.zero?\n Resque.logger.error \"(HYDRA request) Couldnt get an http response #{res.return_message}\"\n else\n Resque.logger.error(\"(HYDRA request) HTTP request failed: #{res.code}\")\n end\n end\n\n request.on_success do |res|\n # @used = res.headers['x-recharge-limit'].to_i\n # Resque.logger.info res.headers['x-recharge-limit']\n key = \"#{entity}_pull:#{Time.now.strftime(\"%Y%m%d\")}#{page.to_s.rjust(3, '0')}\"\n hash_set(cache, key, res.response_body)\n end\n\n hydra.queue(request)\n chap_start = chap_end\n end\n hydra.run\n batch_throttle(@used)\n end\n Resque.logger.info \"Pages iterated: #{pages.inspect}\"\n Resque.logger.info(\"RUN TIME per #{total} records: #{(Time.now - past)}\")\n end",
"def pull; end",
"def pull_queue_pull\n return nil if self.pull_queue_names.length == 0\n \n puts \"pulling from queues #{self.pull_queue_names.join ', '}\"\n \n elt = nil\n elt = @redis.brpop(self.pull_queue_names, self.queue_wait_seconds) while elt == nil\n \n key = elt[0]\n val = elt[1]\n self.debug_out \"got data from pull queue #{key}\"\n Marshal.load val\n end",
"def populate_from_redis\n response_from_redis_or_service\n end",
"def redis_pool; end",
"def pull\n start = Time.now\n job = job_of(\n clean(\n Typhoeus::Request.get(\n 'https://wts.zold.io/pull',\n headers: headers\n )\n )\n )\n @log.debug(\"PULL job #{job} started in #{Zold::Age.new(start)}\")\n job\n end",
"def pull\n fetch\n merge\n end",
"def perform_feed_job(payload)\n # A lot of refactoring needed\n if payload[:Header][:Type] == Constants::LSPORTS_MSG_TYPE[\"Heartbeat\"]\n Rails.cache.write(key_name, @conn.status, expires_in: 15.seconds)\n Rails.logger.info \"#{key_name} connection status: #{@conn.status}\"\n # Rails.logger.info payload\n elsif payload[:Header][:Type] == Constants::LSPORTS_MSG_TYPE[\"Market Update\"] # 3 Market update\n payload[:Body][:Events].each do |fixture|\n if inplay\n LS::Inplay::MatchMarketsOddsChangeJob.perform_later(fixture)\n else\n LS::Prematch::MatchMarketsOddsChangeJob.perform_later(fixture)\n end\n end\n elsif payload[:Header][:Type] == Constants::LSPORTS_MSG_TYPE[\"Fixture metadata\"]\n payload[:Body][:Events].each do |fixture|\n LS::Inplay::UpdateMatadataJob.perform_later(fixture)\n end\n elsif payload[:Header][:Type] == Constants::LSPORTS_MSG_TYPE[\"Settlements\"]\n LS::FeedResultJob.perform_later(payload, 'listener_settlement')\n else\n if payload[:Header][:Type] == Constants::LSPORTS_MSG_TYPE[\"Livescore\"] # 2 Livescore update\n payload[:Body][:Events].each do |fixture|\n # if OddStoreService.odd_store == :redis\n single_status_update(fixture)\n # else\n # push_to_dynamic_queue(fixture)\n # end\n end\n end\n # Below call not needed for prematch\n if inplay\n LS::AMQP::FeedJob.perform_later(\n inplay_queue, payload[:Header][:ServerTimestamp],\n payload\n )\n end\n end\n end",
"def pull\n begin\n @map = read_data\n rescue LockMethod::Locked\n sleep 0.5\n pull\n end\n end",
"def run\n super\n\n config = _get_task_config \"control/collection_processor\"\n\n @sqs = Aws::SQS::Client.new({\n region: 'us-east-1',\n access_key_id: config[\"aws_access_key\"],\n secret_access_key: config[\"aws_secret_access_key\"]\n })\n\n @control_queue_uri = config[\"control_queue_uri\"]\n @status_queue_uri = config[\"status_queue_uri\"]\n sleep_interval = config[\"sleep\"] || 10\n max_seconds = config[\"max_seconds\"] || 36000\n\n handler = config[\"handler\"]\n\n # connect to the configured amazon queue & Grab one\n _set_status :available, nil\n instruction_data = nil\n iteration = 0\n while true\n\n # loop until we have something\n while !instruction_data\n\n _log \"Attempting to get an instruction from the queue!\"\n instruction_data = _get_queued_instruction # try again\n\n # kick it off if we got one, and break out of this loop\n if instruction_data\n _log \"[+] Executing #{instruction_data[\"id\"]} for #{sleep_interval} seconds! (expire in: ~#{max_seconds - (iteration * sleep_interval) }s)\"\n _set_status :start, \"#{instruction_data[\"id\"]}\"\n _execute_instruction(instruction_data)\n else\n _log \"Nothing to do, waiting!\"\n sleep sleep_interval\n end\n\n end\n\n # hold tight\n sleep sleep_interval\n\n # determine how we're doing\n task_count_left = _tasks_left\n seconds_elapsed = iteration * sleep_interval\n done = (iteration > 10 && task_count_left == 0 ) || (seconds_elapsed > max_seconds)\n\n _log \"Seconds elapsed: #{seconds_elapsed}\" if iteration % 10 == 0\n _log \"Tasks left: #{task_count_left}\" if iteration % 10 == 0\n\n if done\n _log_good \"Done with #{instruction_data[\"id\"]} after #{seconds_elapsed}s\"\n _set_status :end, {\n \"id\" => \"#{instruction_data[\"id\"]}\",\n \"elapsed\" => \"#{seconds_elapsed}\",\n \"entities\" => \"#{Intrigue::Model::Project.first(:name => instruction_data[\"id\"]).entities.count}\"\n }\n\n _log_good \"#{instruction_data[\"id\"]}\"\n _run_handlers instruction_data\n _set_status :sent, \"#{instruction_data[\"id\"]}\"\n\n instruction_data = nil\n iteration = -1\n\n end\n\n iteration +=1\n end\n\n end",
"def call\n @from_redis.scan_each(match: \"*\", count: FeatureFlagger::Storage::Redis::SCAN_EACH_BATCH_SIZE) do |redis_key|\n # filter out resource_keys\n next if redis_key.start_with?(\"#{FeatureFlagger::Storage::Redis::RESOURCE_PREFIX}:\")\n\n migrate_key(redis_key)\n end\n end",
"def refresh\n self.operation = \"#{operation}#refresh\"\n\n return if params_missing?\n\n # Connection settings\n set_connection_data!\n logger.info_ext(operation, \"Connection set successfully\")\n\n # Get all tasks\n tasks, @refresh_state_uuid = {}, SecureRandom.uuid\n @parts_requested_cnt, @parts_received_cnt = Concurrent::AtomicFixnum.new(0), Concurrent::AtomicFixnum.new(0)\n @source_refs_requested, @source_refs_received = [], Concurrent::Array.new\n\n params.to_a.each do |task|\n if task['task_id'].blank? || task['source_ref'].blank?\n logger.warn_ext(operation, \"Missing data for task: #{task}\")\n next\n end\n tasks[task['task_id']] = task['source_ref']\n\n if tasks.length == REFS_PER_REQUEST_LIMIT\n refresh_part(tasks)\n tasks = {}\n end\n end\n\n refresh_part(tasks) unless tasks.empty?\n\n archive_not_received_service_instances unless on_premise?\n rescue => err\n metrics_err_type = on_premise? ? :receptor : :cloud unless endpoint.nil?\n metrics&.record_error(metrics_err_type || :general)\n logger.error_ext(operation, \"Error: #{err.message}\\n#{err.backtrace.join(\"\\n\")}\")\n end",
"def delayed_atomic_pulls\n @delayed_atomic_pulls ||= {}\n end",
"def loadAll()\n # Load the configuration from global.rb\n SHAREDPOOLS.each_key do |k|\n p = Pool.new(k, SHAREDPOOLS[k][:zone],\n SHAREDPOOLS[k][:allocateable_cpus],\n SHAREDPOOLS[k][:allocateable_mem],\n SHAREDPOOLS[k][:service_class])\n\n @poolList.push(p)\n end\n SERVICES.each_key do |k|\n s = Service.new(k, SERVICES[k][:authinfo],\n SERVICES[k][:maxcpus],\n SERVICES[k][:maxmemory],\n SERVICES[k][:priority])\n @svcList.push(s)\n end\n # Load the requests from redis\n @reqList = $eventProcessor.loadRequests()\n # Compute the free/used stats from state of requests\n @reqList.each { |req|\n if req.status == \"ALLOCATED\"\n pmatches = @poolList.select {|p| p.name == req.pool}\n if pmatches == nil || pmatches[0] == nil\n $Logger.error \"Unable to find pool #{req.pool} for ALLOCATED request #{req.reqid}\"\n next\n end\n smatches = @svcList.select {|s| s.name == req.service}\n if smatches == nil || smatches[0] == nil\n $Logger.error \"Unable to find service #{req.service} for ALLOCATED request #{req.reqid}\"\n next\n end\n pool = pmatches[0]\n pool.availvcpus = pool.availvcpus.to_i - req.vcpus.to_i\n pool.availmem = pool.availmem.to_i - req.mem.to_i\n service = smatches[0]\n service.vcpusallocated = service.vcpusallocated.to_i + req.vcpus.to_i\n service.memallocated = service.memallocated.to_i + req.mem.to_i\n end\n }\n end",
"def fetch\n @shard_prefixes.each do |prefix|\n data = {}\n shard_name = prefix\n prefix = \"#{@shard_prefix}#{prefix}\"\n @filenames.map do |filename|\n filename = filename.sub(/\\*/, prefix)\n puts \"Fetching #{filename}...\"\n\n index = @filters.select { |_, value| filename.match value }\n key = index.values[0]\n data[key] = download(@host, \"#{@path_prefix}#{filename}\")\n end\n save Shard.new(shard_name, data)\n end\n binding.pry\n end",
"def perform(metadata)\n scheduled_at = Time.at(metadata[\"scheduled_at\"])\n minutes = scheduled_at.min\n hours = scheduled_at.hour\n\n # 20 requests / minute\n if (minutes % 2 == 0) # Top 0-19; every 2 minutes\n perform_update(1)\n else # Top 20-99; every 2 minutes, full cycle of 6 minutes\n sub_index = (minutes / 2) % 3\n perform_update(2, sub_index)\n end\n\n # 20 requests / minute\n if minutes % 3 == 0 # Top 100-199; every 3 minutes, full cycle of 15 minutes\n sub_index = (minutes / 3) % 5\n perform_update(3, sub_index)\n elsif minutes % 6 == 1 # Top 200-299; every 6 minutes, full cycle of 30 minutes\n sub_index = (minutes / 6) % 5\n perform_update(4, sub_index)\n elsif minutes % 6 == 2 # Top 300-499; every 6 minutes, full cycle of 60 minutes\n sub_index = (minutes / 6) % 10\n perform_update(5, sub_index)\n end\n\n # 25-30 requests / minute\n if minutes % 12 == 0 # Top 500-749; every 12 minutes, full cycle of 1 hour\n sub_index = (minutes / 12) % 5\n perform_update(6, sub_index)\n end\n two_hour_cycle = hours % 2 * 60 + minutes\n if two_hour_cycle % 12 == 1 # Top 750-999; every 12 minutes, full cycle of 2 hours\n sub_index = (two_hour_cycle / 12) % 10\n perform_update(7, sub_index)\n end\n four_hour_cycle = hours % 4 * 60 + minutes\n if four_hour_cycle % 12 == 2 # Top 1000-1499; every 12 minutes, full cycle of 4 hours\n sub_index = (four_hour_cycle / 12) % 20\n perform_update(8, sub_index)\n end\n # 25 requests / 3 minutes with blank periods due to unknown coin limit\n six_hour_cycle = hours % 6 * 60 + minutes\n if six_hour_cycle % 3 == 1 # Top 1500-4499; every 3 minutes, full cycle of 6 hours\n sub_index = (six_hour_cycle / 3) % 120\n perform_update(9, sub_index)\n end\n end",
"def fetch\n\n set_id_to_cache_key_map\n\n cache_keys_to_fetch = []\n @id_to_cache_key_map.each do |_, keys|\n cache_keys_to_fetch.push(keys[:kit])\n end\n\n data_from_cache = Memcache.read_multi(cache_keys_to_fetch)\n\n ids_for_cache_miss = []\n @ids.each do |id|\n ids_for_cache_miss << id if data_from_cache[@id_to_cache_key_map[id][:kit]].nil?\n end\n\n if ids_for_cache_miss.any?\n\n fetch_data_rsp = fetch_from_db(ids_for_cache_miss)\n\n data_to_set = fetch_data_rsp.data || {}\n\n # to ensure we do not always query DB for invalid ids being cached, we would set {} in cache against such ids\n @ids.each do |id|\n data_to_set[id] = {} if data_from_cache[@id_to_cache_key_map[id][:kit]].nil? && data_to_set[id].nil?\n end\n\n set_cache(data_to_set) if fetch_data_rsp.success?\n\n end\n\n @ids.inject({}) do |data, id|\n data[id] = data_from_cache[@id_to_cache_key_map[id][:kit]] || data_to_set[id]\n data\n end\n\n end",
"def perform(*args)\n\n begin\n logger.info \"************ STARTING refresh coins ******************************************\"\n\n # # grab the main assets from kraken\n assets_json = get_coin_data('https://api.kraken.com/0/public/Assets', '')\n assets_keys = assets_json.keys\n\n\n # grab the asset pairs from kraken\n asset_pairs_json = get_coin_data('https://api.kraken.com/0/public/AssetPairs', '')\n asset_pairs_keys = asset_pairs_json.keys\n\n # grab the market cap and full name from a different source\n market_response = RestClient.get 'https://api.coinmarketcap.com/v1/ticker'\n market_json = JSON.parse(market_response)\n\n\n # loop thru the asset pairs that kraken gives us\n asset_pairs_keys.each do |key|\n\n # wrap every coin in a try catch - if it fails go to the next coin\n begin\n\n asset = {\"pair\" => key, \"base\" => asset_pairs_json[key]['base'], \n \"quote\" => asset_pairs_json[key]['quote']}\n\n # we only want pairs with a USD currency\n # using \"quote\" of ZUSD check to say it is a USD pair - is this a valid check??\n # could alse use a string parse of the last 3 chars and\n # see if it matches USD...\n # ALSO ignore the .d pairs - WHAT ARE THESE???\n # they seem to be duplicates of an existing pair without a .d at the end...\n if (asset['pair'].exclude? \".d\") && (asset['quote'] == \"ZUSD\") \n # && (asset['pair'].exclude? \"X\") #this line is for testing to cut down on our results\n\n # add the alternative name of the base using the asset listing we got\n # matching the asset pair to the asset using the asset key which is the name\n assets_keys.each do |key|\n if asset['base'] == key\n asset['altbase'] = assets_json[key]['altname']\n asset['display_decimals'] = assets_json[key]['display_decimals']\n end\n end\n\n # special case for bitcoin - kraken uses xbt, but everywhere else uses btc, \n # so set that here\n if (asset['altbase'] == 'XBT') \n asset['altbase'] = 'BTC'\n end\n\n # look up the assets compliance in the erc20 table\n erc20 = Erc20.where(symbol: asset['altbase']).first\n if (erc20)\n asset['erc20'] = erc20['flag']\n else\n asset['erc20'] = 'no data' \n end\n\n # lookup the full name of the coin using the list from the ticker - \n # matching based on the altBaseName (since kraken uses its own symbols...)\n market_json.each do |market|\n if market['symbol'] == asset['altbase']\n asset['name'] = market['name']\n asset['marketcap'] = market['market_cap_usd']\n end\n end\n\n\n # save the asset to the db model\n asset_db = Asset.new(pair: key, base: asset['base'], quote: asset['quote'], \n altbase: asset['altbase'], name: asset['name'], marketcap: asset['marketcap'],\n display_decimals: asset['display_decimals'],\n erc20: asset['erc20'])\n\n\n # ok now look up each coin individually and grab the data from kraken\n logger.info '--pulling coin data from kraken -- (' + key + ')' \n\n # grab additional data from kraken\n ticker_json = get_coin_data('https://api.kraken.com/0/public/Ticker?pair=' + key, key)\n\n if (ticker_json != nil)\n asset_db['last_traded'] = ticker_json['c'][0]\n end\n \n # grab the asks and bids info for this coin and add to the coin in the db\n depth_json = get_coin_data('https://api.kraken.com/0/public/Depth?pair=' + key, key)\n\n if (depth_json != nil)\n depth_json['asks'].each do |depth|\n asset_db.asks.build(price: depth[0], volume: depth[1], timestamp: depth[2])\n end\n end\n\n if (depth_json != nil)\n depth_json['bids'].each do |depth|\n asset_db.bids.build(price: depth[0], volume: depth[1], timestamp: depth[2])\n end\n end\n\n # begin\n # grab the spread info for this coin and add/replace it in the db\n spread_json = get_coin_data('https://api.kraken.com/0/public/Spread?pair=' + key, key)\n\n if (spread_json != nil)\n spread_json.each do |spread|\n asset_db.spreads.build(time: spread[0], bid: spread[1], ask: spread[2])\n end\n end\n\n # begin\n # grab the trade info for this coin and add/replace it in the db\n trade_json = get_coin_data('https://api.kraken.com/0/public/Trades?pair=' + key, key)\n\n if (trade_json != nil)\n trade_json.each do |trade|\n asset_db.trades.build(price: trade[0], volume: trade[1], time: trade[2], buysell: trade[3], \n marketlimit: trade[4], misc: trade[5])\n end\n end\n\n # wrap the delete and insert in a transaction so that there is no lag in case there is\n # a request to pull the data in the middle of a delete and insert\n # we are replacing the existing asset pair with the newly fetched/created one\n Asset.transaction do\n # first remove the coin (and child data) from the data before we insert our newly aquired coin info\n Asset.where(pair: key).destroy_all\n asset_db.save\n end\n\n end\n\n # if there is any issue when getting a coins data - usually the response errored or is null\n # then just move on to the next coin\n rescue => error\n logger.error 'SINGLE coin refresh error-----------: ' + key\n logger.error error\n next\n end\n end\n\n logger.info \"*********** FINISHED refresh coins ******************************************\"\n\n # if there is an error grabbing the coin list, then just restart the job \n rescue => error\n logger.error \"GENERAL coin list refresh error: -------------\" \n logger.error error\n raise StandardError.new(\"STANDARD ERROR\")\n end\n\n end",
"def index\n @last5ratings = Rating.last5\n @ratings = Rating.includes(:beer, :user).all\n \n TestJob.perform_async\n \n #Rails.cache.write('brewery top 3', Brewery.top(3), expires_in: 15.minutes)\n @top_breweries = brewery.top(3)\n #Rails.cache.write('beers top 3', Beer.top(3), expires_in: 15.minutes)\n @top_beers = beer.top(3)\n #Rails.cache.write('style top 3', Style.top(3), expires_in: 15.minutes)\n @top_styles = style.top(3)\n @most_active = User.most_active(3)\n end",
"def fetch_messages\n if !@worker_pool.worker_available? && @state.run?\n @worker_available.wait\n end\n return unless @worker_pool.worker_available? && @state.run?\n\n begin\n args = [self.signals_redis_key, self.queue_redis_keys.shuffle, 0].flatten\n redis_key, encoded_payload = @client.block_dequeue(*args)\n if redis_key != @signals_redis_key\n @worker_pool.push(QueueItem.new(redis_key, encoded_payload))\n end\n rescue RuntimeError => exception\n log \"Error occurred while dequeueing\", :error\n log \"#{exception.class}: #{exception.message}\", :error\n (exception.backtrace || []).each{ |l| log(l, :error) }\n sleep 1\n end\n end",
"def redis_pool=(_arg0); end",
"def retrieve\n # TODO remove !!self.graph after run once\n if self.new_item? # !!self.graph\n @since_date = 6.months.ago\n end\n @bulk_insert_array = []\n @bulk_update_hash = {}\n puts \" retrieve #{self.id} #{since_date}\"\n since = since_date\n hasta = until_date\n started=Time.now.strftime(\"%Y-%m-%d %H:%M:%S .%L\")\n success = nil\n while (hasta - since_date) >= back_to_date\n since = hasta - back_to_date\n success = do_retrieve(since, hasta)\n # yes just minus 1 second, becomes the end of previous day\n hasta = since - 1\n end\n if !@bulk_update_hash.blank?\n # FbPost.update_bulk! [:replies_to_comment,:post_created_time], @bulk_update_hash\n FbPost.update_bulk! @bulk_update_hash\n @bulk_update_hash = {}\n end\n if !@bulk_insert_array.empty?\n # puts \" retrieve call FbPost.import_bulk!\"\n FbPost.import_bulk! @bulk_insert_array\n @bulk_insert_array = []\n end\n save_posts_details\n self.update_attributes :new_item=>false,:status=>success,:updated_at=>DateTime.now.utc\n begin\n # for today only\n daily_aggregate_data\n rescue Exception=>ex\n logger.error \" retrieve daily_aggregate_data #{ex.message}\"\n end\n begin\n # for past 7 days if no argument \n aggregate_data_daily\n rescue Exception=>ex\n logger.error \" retrieve aggregate_data_daily #{ex.message}\"\n end\n # create additional fb_pages if neccessary\n # aggregate_data 1,'day', true\n # recent_page available after aggregate_data\n save_lifetime_data\n ended=Time.now.strftime(\"%Y-%m-%d %H:%M:%S .%L\")\n puts \" id #{self.id} finished retrieve #{started} - #{ended} \"\n STDOUT.flush\n end",
"def retrieve(key); @amq.queue(key); end",
"def down(start_id = -1, machine_id = nil, options = {})\n options.delete_if { |key, value| value.nil? }\n count = options.delete(:count) || false\n \n # get all logged rows from the Replicas (queue) table\n options[:conditions] = [\"id > ? and for_machine_id <> ?\", start_id, machine_id ]\n\n # allow the model to define a new set of conditions to \n # further filter the returning result data set\n if options[:extra_conditions]\n original_cond, *original_values = options[:conditions]\n new_cond, *new_values = options.delete( :extra_conditions )\n options[:conditions] = [original_cond + new_cond] + original_values + new_values\n end\n\n # limits the batch\n counter, errors = 0, []\n if count\n payload = self.count(options)\n total = payload\n else\n options[:order] = 'id ASC'\n options[:limit] = $SYNC_CONFIG[:batch_limit] if $SYNC_CONFIG[:batch_limit]\n payload = self.find(:all, options)\n total = payload.size\n\n payload.collect! do |row|\n begin\n # search for the original table row to get its data\n model_klass = Object.const_get(row.method_type)\n\n msg = case row.crud\n when METHOD_CREATE\n model_klass.find(row.method_id)\n when METHOD_UPDATE\n model_klass.respond_to?(\"deleted_attribute\") ? model_klass.find_with_deleted(row.method_id) : model_klass.find(row.method_id)\n when METHOD_DESTROY\n model_klass.new\n end\n\n counter += 1\n # assemble the transaction package\n ActsAsReplica::Structs::SyncTransaction.new :counter => counter,\n :method => row.crud, \n :sync_id => row.id,\n :row => msg, \n :destroy_id => row.deleted_id\n rescue => e\n errors << e \n nil\n end\n end\n payload.compact!\n end\n \n # if total > payload.size it means that there are more batches waiting to\n # be sent back. Control over new requests should be done in the controller\n # level\n ActsAsReplica::Structs::SyncPayload.new :payload => payload, \n :version => Replica.version, \n :errors => errors,\n :total => total,\n :last_synced => self.maximum('id')\n end",
"def op_fetch(puid = nil)\n push vm.fetch(puid || pop)\n end",
"def retrieve_job\n json = Server.redis { |c| c.brpop(Server.keys[:perform_list]) }\n Job.new(JSON.parse(json.last))\n rescue => e\n raise ServerError, e.message\n end",
"def receive_data(msg) \n msg.split(\"\\n\").each do |row|\n begin\n msg_split = row.split(\" \")\n command = msg_split[0]\n\n return unless command\n case\n when command.match(/available/i)\n EM.defer { send_data \"#{JSON(@redis.datapoints)}\\n\" }\n when command.match(/values/i)\n EM.defer do\n command, metric, begin_time, end_time = msg_split\n datapoints, interval = [], 0\n\n if metric.match(/^gauge/)\n datapoints = @diskstore.read(metric, begin_time, end_time)\n else\n Batsd::Server.config[:retentions].each_with_index do |retention, index|\n if (index != Batsd::Server.config[:retentions].count - 1) && (Time.now.to_i - (retention[0] * retention[1]) > begin_time.to_i)\n next\n end\n interval = retention[0]\n\n if index.zero?\n datapoints = @redis.values_from_zset(metric, begin_time, end_time)\n break\n else\n datapoints = @diskstore.read(\"#{metric}:#{retention[0]}\", begin_time, end_time)\n break\n end\n end\n end\n send_data \"#{JSON({'interval' => interval, \"#{metric}\" => datapoints})}\\n\"\n end\n when command.match(/ping/i)\n send_data \"PONG\\n\"\n when command.match(/quit|exit/i)\n send_data \"BYE\\n\"\n close_connection\n else\n send_data \"#{JSON({error: \"Unrecognized command #{command}\"})}\\n\"\n end\n rescue Exception => e\n puts e if ENV[\"VERBOSE\"]\n rescue\n puts \"Uncaught Error\"\n end\n end\n end",
"def index\n \n @stocks = Stock.select{ |s| s['user_id']==current_user.id}\n @tickers = Array[]\n @recommendations = Recommendation.all\n @stockprofiles = Stockprofile.all\n\n\n\n @api = StockQuote::Stock.new(api_key: ENV['iexcloud_api_key'])\n @finnhub_api_key = ENV['finnhub_api_key']\n \n @iexcloud_api_key = ENV['iexcloud_api_key']\n @baseurl_iexcloud = \"https://cloud.iexapis.com/stable/stock/\"\n\n @tradier_api_key = ENV['tradier_api_key']\n @baseurl_tradier = ENV['baseurl_tradier'] # /options/expirations\"\n\n get_watchlist_stocks_live_quotes\n\n\n\n #StockquoteDownloadJob.set(wait: 1.minute).perform_later\n #StockquoteDownloadJob.perform_later\n #StockquoteDownloadJob.perform_later(\"refresh_options\")\n #StockquoteDownloadJob.perform_later(\"clear_oldoptions\")\n #StockquoteDownloadJob.perform_later(\"delete_all_options\")\n #StockquoteDownloadJob.perform_later(\"metadata\")\n #StockquoteDownloadJob.perform_later(\"delete_stockprofiles\")\n #StockquoteDownloadJob.perform_later(\"delete_recommendations\")\n end",
"def process_pull\n factory = \"::#{object_type}\".constantize\n syncer = factory.synchronizer\n syncer.pull_object(self.object_remote_id)\n \n self.state = 'done'\n self.save\n end",
"def snapshot_every_n_requests; end",
"def tick\n vals = Libcgroup.usage\n vals = Hash[vals.map { |uuid, hash| [uuid, hash.select { |k, _| @wanted_keys.include? k }] }]\n\n update(vals)\n rescue Exception => e\n Syslog.info(\"Throttler: unhandled exception #{e.message}\\n\" + e.backtrace.join(\"\\n\"))\n end",
"def _refresh_get(ds)\n # SEQUEL5: Remove\n if use_prepared_statements_for?(:refresh)\n _set_prepared_statement_server(model.send(:prepared_refresh)).call(pk_hash)\n else\n super\n end\n end",
"def fetch\n end",
"def load_all_raw_data_into_redis\n\t$all_stock_list.each do |symbol,name|\n\t\tputs \"#{symbol} start\"\n\t\tyahoo_get_raw_data_from_file(symbol)\n\tend\n\nend",
"def determine_loads_state\n\n loads = @marketo.loads(:user => GOODDATA_USER,\n :pass => GOODDATA_PASSWORD,\n :project => GOODDATA_PROJECT,\n :marketo_client => @marketo)\n\n if loads.available?\n\n file = loads.available.first\n load = loads.create :name => file\n\n load.execute\n\n # Data from the job can now be accessed ARRAY load.storage\n # load.storage\n\n # Increment the load by one day if it is time related.\n\n case load.json[:method]\n\n when 'get_changes'\n\n one_day = (24*60*60)\n oca = load.arguments[:oldest_created_at]\n lca = load.arguments[:latest_created_at]\n\n load.arguments[:oldest_created_at] = (Time.parse(oca) + one_day).to_s\n load.arguments[:latest_created_at] = (Time.parse(lca) + one_day).to_s\n\n # If the latest time is later then today kill the load.\n if Time.parse(lca) > Time.now\n\n load.terminate\n\n determine_loads_state\n\n # Otherwise save the load and resume additional loads.\n else\n\n load.save\n\n determine_loads_state\n\n end\n\n when 'get_multiple'\n\n determine_loads_state\n\n else\n raise 'Unable to determine lead type (\"get_multiple\"/\"get_changes\")!'\n\n end\n\n else\n\n load = @queue.pop\n loads.create load\n\n determine_loads_state\n\n end\n\nend",
"def process_retrieval_petition(data)\n\t\tif data.length()>=2\n\t\t\tcommand=data[0]\n\t\t\tkeys=data.drop(1)\n @cache.purge_expired_keys(keys)\n case command\n\t\t\twhen GET_COMMAND\n\t\t\t\treturn @cache.get(keys)\n\t\t\twhen GETS_COMMAND \n\t\t\t\treturn @cache.gets(keys)\n\t\t\telse\n\t\t\t\treturn ERROR_MESSAGE \n\t\t\tend\n\t\telse\n\t\t\treturn CLIENT_ERROR_MESSAGE\n\t\tend\n\tend",
"def pull_data\n @pull_data ||= source_classes\n .map { |source| Thread.future { source.run(pull, page) } }\n .reduce({}) { |result, source_future| result.merge(~source_future) }\n end",
"def pull_burst(burst_p, burst_context_p)\n cx_data.multi do\n burst_p.call\n burst_context_p.call\n end\n end",
"def views\n $redis.get(\"product:#{id}\")\n end",
"def load\n # This could be generallized but for now lets just do this\n return if @cached.queue_name.nil?\n\n # logger.debug(\"CMB: load for #{self.to_param}\")\n time_now = Time.now\n\n # Pull the fields we need from the cached record into an options_hash\n options_hash = {\n :queue_name => @cached.queue_name,\n :h_or_s => @cached.h_or_s,\n :center => @cached.center.center\n }\n\n # :requested_elements is a special case\n requested_elements = Combined::Call.retain_fields.map { |field| field.to_sym }\n requested_elements << :ppg\n requested_elements << :p_s_b\n # logger.debug(\"CMB: requested_elements = #{requested_elements.inspect}\")\n options_hash[:requested_elements] = requested_elements\n\n # Create a Retain::Queue from the options cache.\n retain_queue = Retain::Queue.new(retain_user_connection_parameters, options_hash)\n retain_calls = retain_queue.calls\n\n # We know that the queue is valid or the calls method above\n # would have raised an expcetion. We are going to attach calls\n # to this queue and that does not work with a new record so we\n # go ahead and save it to the database.\n @cached.save if @cached.new_record?\n\n # retain_calls are the calls from retain while db_calls are the\n # calls that the database knows about.\n db_calls = @cached.calls\n\n # If retain says we have no calls, we delete the calls in the\n # database and go home.\n if retain_calls.length == 0\n # logger.debug(\"CMB: Queue is empty\")\n\n # If DB already says there are no calls, then there are no\n # calls to delete and, also, we do not need to touch\n # last_fetched.\n unless db_calls.length == 0\n @cached.calls.clear\n @cached.last_fetched = time_now\n end\n\n # We know that the queue is not dirty, set the updated_at\n # time, and save what has changed.\n @cached.dirty = false\n @cached.updated_at = time_now\n @cached.save\n return\n end\n\n # A new approach: Mark all the db calls as not used. Then walk\n # the retain call list. If the ppg and call_search_result both\n # equal, then we assume its the same call (I can't see how it\n # could not be) and mark it as used. Afterwards, we walk the db\n # call list and delete the unused calls.\n db_calls_hash = { }\n db_calls.each { |db_call|\n db_calls_hash[db_call.ppg] = db_call\n db_call.used = false\n }\n\n no_new = true\n slot = 0\n group_request = nil\n\n retain_calls.each do |retain_call|\n slot += 1\n db_call = db_calls_hash[retain_call.ppg]\n\n # Trust old call as the same\n if db_call && db_call.call_search_result == retain_call.call_search_result\n db_call.used = true\n db_call.slot = slot\n next\n end\n\n # first time through set these up\n if no_new\n no_new = false # at least one new call\n group_request = Combined::Call.retain_fields.map { |field| field.to_sym }\n group_request.freeze\n end\n\n # Make call fetch the fields we need\n retain_call.group_requests = group_request\n retain_call.send(group_request[0])\n\n # create or find the call\n call_options = Cached::Call.options_from_retain(retain_call)\n\n # If we have a call with the same ppg, we reuse it else we\n # find or create a new one. I don't see how the find could\n # not return a new record in the case that db_call was\n # originally null.\n db_call = @cached.calls.find_or_new(call_options) unless db_call\n\n # if an old record, update it with new info (If it is a new\n # record, this work will already been done.)\n unless db_call.new_record?\n db_call.attributes = call_options\n end\n\n db_call.used = true\n db_call.last_fetched = time_now if db_call.changed?\n db_call.slot = slot\n db_call.dirty = false\n\n # Make or find Cached PMR\n db_pmr = Pmr.find_existing_pmr(retain_call).unwrap_to_cached\n\n # I believe now that customer is not required for pmrs, we can \n # delete this code... To Be Done\n #\n # This code is duplicated three times presently. The problem\n # is that we do not want the center or other fields from the\n # call to enter in to the search or values for the customer.\n # So, we do a specific search for the customer by country and\n # customer number.\n #\n # Well, actually that is only half the problem. The bigger\n # problem with the PMR and customer is that we do not want to\n # fetch them from Retain until we need something from them.\n # That is why we construct the database objects in multiple\n # places.\n cust_options = {\n :country => retain_call.country,\n :customer_number => retain_call.customer_number\n }\n db_customer = Cached::Customer.find_or_new(cust_options)\n db_customer.save\n db_pmr.customer = db_customer\n db_pmr.save\n db_call.pmr = db_pmr\n\n # We just do the save which will cause updated_at to be\n # modified. It also causes the PMR and customer to be saved\n # if they are new.\n db_call.updated_at = time_now\n db_call.save\n end\n\n # delete any unused db_calls\n no_deletes = true\n db_calls.each do |db_call|\n unless db_call.used\n db_call.destroy\n no_deletes = false\n end\n end\n\n # mark as last_fetched if anything changed including adding or\n # deleting db calls.\n unless no_deletes && no_new && !@cached.changed?\n @cached.last_fetched = time_now\n end\n\n # Force the reload of the calls if we added or deleted db calls\n unless no_deletes && no_new\n @cached.calls(true)\n end\n @cached.dirty = false\n @cached.updated_at = time_now\n @cached.save\n end",
"def load\n # logger.debug(\"CMB: load for #{self.to_param}\")\n # Pull the fields we need from the cached record into an options_hash\n queue = @cached.queue\n options_hash = {\n :queue_name => queue.queue_name,\n :h_or_s => queue.h_or_s,\n :center => queue.center.center,\n :ppg => @cached.ppg\n }\n # logger.debug(\"CMB: options_hash = #{options_hash.inspect}\")\n\n # :group_request is a special case\n group_request = Combined::Call.retain_fields.map { |field| field.to_sym }\n # logger.debug(\"CMB: group_request = #{group_request.inspect}\")\n options_hash[:group_request] = [ group_request ]\n\n # Create retain object\n call = Retain::Call.new(retain_user_connection_parameters, options_hash)\n\n # Touch to force a fetch from Retain\n begin\n call.send(group_request[0])\n rescue Retain::SdiReaderError => e\n if e.sr == 65 && e.ex == 11\n # This may cause another exception but I don't think it\n # will. If it does, the to_param can be manually coded.\n raise CallNotFound.new(to_param)\n else\n raise e\n end\n end\n\n # Make or find Cached PMR\n @cached.pmr = Pmr.find_existing_pmr(call).unwrap_to_cached\n\n # Make or find customer\n cust_options = {\n :country => call.country,\n :customer_number => call.customer_number\n }\n @cached.pmr.customer = Cached::Customer.find_or_new(cust_options)\n\n # logger.debug(\"CMB: TMP customer_time_zone_adj = #{call.customer_time_zone_adj}\")\n # logger.debug(\"CMB: TMP time_zone_code = #{call.time_zone_code}\")\n\n # Update call record\n #\n # This comment applies to most of the combined models.\n # We gather the options that go into the database record from\n # the call and assign them to the database record. We then ask\n # if anything has changed. If something has changed, when we\n # mark last_fetched with the current time. We then fix the\n # dirty flag as false, force the updated_at to be now, and then\n # do a save.\n # The net result will be that the updated_at timestamp will be\n # the time that we last checked retain. The last_fetched will\n # be the time when Retain last changed.\n #\n options = self.class.cached_class.options_from_retain(call)\n @cached.attributes = options\n if @cached.changed?\n @cached.last_fetched = Time.now\n end\n @cached.dirty = false\n @cached.updated_at = Time.now\n\n @cached.owner_css,\n @cached.owner_message,\n @cached.owner_editable = compute_owner_private\n\n @cached.resolver_css,\n @cached.resolver_message,\n @cached.resolver_editable = compute_resolver_private\n\n @cached.next_queue_css,\n @cached.next_queue_message,\n @cached.next_queue_editable = compute_next_queue_private\n @cached.save\n end",
"def read\n super\n\n self.fetch\n\n self.items\n end",
"def perform\n\n start_time = Time.now\n puts \"Opening Connection: #{start_time}\"\n\n Share.all.each do | share | \n share.load_share_data\n logger.info share.name+' data sucessfully loaded'\n end\n\n end_time = Time.now\n puts \"Opening Connection: #{end_time}\"\n\n end",
"def collector_thread(connection, entity_type)\n refresh_state_uuid = SecureRandom.uuid\n logger.info(\"[START] Collecting #{entity_type} with :refresh_state_uuid => '#{refresh_state_uuid}'\")\n parser = TopologicalInventory::AnsibleTower::Parser.new\n\n total_parts = 0\n cnt = 0\n\n # each on ansible_tower_client's enumeration makes pagination requests by itself\n send(\"get_#{entity_type}\", connection).each do |entity|\n cnt += 1\n\n parser.send(\"parse_#{entity_type.singularize}\", entity)\n\n if cnt >= limits[entity_type]\n total_parts += 1\n refresh_state_part_uuid = SecureRandom.uuid\n save_inventory(parser.collections.values, refresh_state_uuid, refresh_state_part_uuid)\n\n # re-init\n parser = TopologicalInventory::AnsibleTower::Parser.new\n cnt = 0\n end\n end\n\n if parser.collections.values.present?\n total_parts += 1\n refresh_state_part_uuid = SecureRandom.uuid\n save_inventory(parser.collections.values, refresh_state_uuid, refresh_state_part_uuid)\n end\n\n logger.info(\"[END] Collecting #{entity_type} with :refresh_state_uuid => '#{refresh_state_uuid}' - Parts [#{total_parts}]\")\n\n # Sweeping inactive records\n\n logger.info(\"[START] Sweeping inactive records for #{entity_type} with :refresh_state_uuid => '#{refresh_state_uuid}'...\")\n sweep_inventory(refresh_state_uuid, total_parts, parser.collections.inventory_collections_names)\n logger.info(\"[END] Sweeping inactive records for #{entity_type} with :refresh_state_uuid => '#{refresh_state_uuid}'\")\n\n # connection.api.jobs.all\n # connection.api.workflow_jobs.all\n rescue => e\n logger.error(\"Error collecting :#{entity_type}, message => #{e.message}\")\n raise e\n end",
"def fetch_latest_from_queue(user)\n redis_activity = $redis.lrange(redis_key_for_user(user), 0, KEEP_ACTIVITY_ITEMS - 1)\n\n preload_tour_ids = []\n\n redis_activity.map do |activity_json|\n activity_json = JSON.parse(activity_json)\n preload_tour_ids << activity_json['t_id']\n end\n\n preload_tour_ids = preload_tour_ids.compact.map(&:to_i).uniq\n tours = Tour.active.where(id: preload_tour_ids).order('updated_at desc') if preload_tour_ids\n tours\n end",
"def demand_functioning_bikes_from(container)\n while should_collect_functioning_bikes?(container) do\n collected_bike = container.offload_functioning_bike\n load(collected_bike)\n end\n end",
"def pull(pulls)\n prepare_atomic_operation do |ops|\n process_atomic_operations(pulls) do |field, value|\n (send(field) || []).delete(value)\n ops[atomic_attribute_name(field)] = value\n end\n { \"$pull\" => ops }\n end\n end",
"def work(msg)\n parsed_msg = Oj.load(msg)\n channel = Channel.find(parsed_msg.fetch('channel_id'))\n ack! && return if channel.inactive?\n\n API::Products::Puller.new(channel).call\n ack!\n rescue StandardError => exception\n Rails.logger.error(\"[ImportProductError]: #{exception.message}\")\n reject!\n end",
"def process(tag,es)\n log.trace \"process request received \", tag\n\n if !@redis\n connect_redis()\n end\n\n if (@redis.connected?)\n @redis.multi\n es.each do |time, record|\n log.debug \"process redis push:\", tag, time, record, @listname\n @redis.lpush(@listname,redisFormat(tag,time,record))\n end\n \n @redis.exec\n else\n log.warn \"no connection to Redis\"\n router.emit_error_event(tag, time, record, \"No Redis\")\n end\n end",
"def use_replica_if_available(&block)\n ::Gitlab::Database::LoadBalancing::Session.current.use_replicas_for_read_queries(&block)\n end",
"def index\n validate_arguments!\n quota_resp = api.request(\n :expects => [200, 404],\n :method => :post,\n :path => \"/apps/#{app}/actions/get-quota\",\n :headers => {\n \"Accept\" => \"application/vnd.heroku+json; version=3.app-quotas\",\n \"Content-Type\" => \"application/json\"\n }\n )\n\n if quota_resp.status = 200\n quota = quota_resp.body\n now = Time.now.getutc\n quota_message = if quota[\"allow_until\"]\n \"Free quota left:\"\n elsif quota[\"deny_until\"]\n \"Free quota exhausted. Unidle available in:\"\n end\n if quota_message\n quota_timestamp = (quota[\"allow_until\"] ? Time.parse(quota[\"allow_until\"]).getutc : Time.parse(quota[\"deny_until\"]).getutc)\n time_left = time_remaining(Time.now.getutc, quota_timestamp)\n display(\"#{quota_message} #{time_left}\")\n end\n end\n\n processes_resp = api.request(\n :expects => 200,\n :method => :get,\n :path => \"/apps/#{app}/dynos\",\n :headers => {\n \"Accept\" => \"application/vnd.heroku+json; version=3\",\n \"Content-Type\" => \"application/json\"\n }\n )\n processes = processes_resp.body\n\n processes_by_command = Hash.new {|hash,key| hash[key] = []}\n processes.each do |process|\n now = Time.now\n type = process[\"type\"]\n elapsed = now - Time.iso8601(process['updated_at'])\n since = time_ago(now - elapsed)\n size = process[\"size\"] || \"1X\"\n\n if type == \"run\"\n key = \"run: one-off processes\"\n item = \"%s (%s): %s %s: `%s`\" % [ process[\"name\"], size, process[\"state\"], since, process[\"command\"] ]\n else\n key = \"#{type} (#{size}): `#{process[\"command\"]}`\"\n item = \"%s: %s %s\" % [ process['name'], process['state'], since ]\n end\n\n processes_by_command[key] << item\n end\n\n extract_run_id = /\\.(\\d+).*:/\n processes_by_command.keys.each do |key|\n processes_by_command[key] = processes_by_command[key].sort do |x,y|\n x.match(extract_run_id).captures.first.to_i <=> y.match(extract_run_id).captures.first.to_i\n end\n end\n\n processes_by_command.keys.sort.each do |key|\n styled_header(key)\n styled_array(processes_by_command[key], :sort => false)\n end\n end",
"def fetch; end",
"def fetch; end",
"def fetch(name, options = nil)\n options ||= {}\n name = expanded_key(name)\n\n if block_given?\n unless options[:force]\n entry = instrument(:read, name, options) do |payload|\n payload[:super_operation] = :fetch if payload\n read_entry(name, options)\n end\n end\n\n if !entry.nil?\n instrument(:fetch_hit, name, options) { |payload| }\n entry\n else\n result = instrument(:generate, name, options) do |payload|\n yield\n end\n write(name, result, options)\n result\n end\n else\n read(name, options)\n end\n end",
"def workload(pr)\n q = <<-QUERY\n select count(distinct(prh.pull_request_id)) as num_open\n from pull_request_history prh, pull_requests pr, pull_request_history prh3\n where prh.created_at < prh3.created_at\n and prh.action = 'opened'\n and pr.id = prh.pull_request_id\n and prh3.pull_request_id = ?\n and (exists (select * from pull_request_history prh1\n where prh1.action = 'closed'\n and prh1.pull_request_id = prh.pull_request_id\n and prh1.created_at > prh3.created_at)\n or not exists (select * from pull_request_history prh1\n where prh1.action = 'closed'\n and prh1.pull_request_id = prh.pull_request_id)\n )\n and pr.base_repo_id = (select pr3.base_repo_id from pull_requests pr3 where pr3.id = ?)\n QUERY\n db.fetch(q, pr[:id], pr[:id]).first[:num_open]\n end",
"def get_command(command)\n ensure_cache_up_to_date\n namespace = \"bluster:objects:command:#{command}\"\n keys = self.redis.keys(\"#{namespace}:*\")\n data = {}\n keys.each { |key|\n short_key = key.split(\":\")[4]\n data[short_key] = self.redis.get(\"#{namespace}:#{short_key}\")\n }\n data\n end",
"def fetch(facebook)\n setup facebook if facebook.present?\n\n # Make an Invocation per batch and enqueue each in Sidekiq.\n batchify.each do |batch|\n batch.to_invocation.save\n end\n end",
"def fetch\n @github.fetch\n @stackoverflow.fetch\n @acuk.fetch\n @jobs = data.shuffle\n end",
"def con_pull_action(input, args)\n\t\troute = @routing_table.find { |r| r.name == @context_arg }\n\n\t\tid = args[:action].to_i\n\t\taction = route.actions[id]\n\n\t\tif id >= 1\n\t\t\troute.actions.insert(id - 1, action)\n\t\t\troute.actions.delete_at(id + 1)\n\t\tend\n\tend",
"def fetch_top_events(params={}, save_to_db=true)\n params = setup_params(params)\n self.model_class = ::Mixpanel::Event\n \n method_url = get_method_url('events', 'top')\n request_params = self.select_params(params, [:type, :limit, :bucket])\n request_params[:resource] = method_url\n \n data = send_request(request_params)\n \n is_empty = (data.blank? || data['events'].blank?)\n if save_to_db && !is_empty\n target_ids = get_target_ids(params) \n \n self.model_class.transaction do\n data['events'].each do |event|\n target_id = event['event']\n # Format to JSON data.\n json_data = {:events => event}.to_json\n \n self.insert_or_update(params, target_ids, \n target_id, json_data)\n end\n end \n end\n return data\n end",
"def process_payload\n return unless @payload.key?('projectId')\n\n projectId = @payload['projectId']\n queue = \"recap:#{projectId}\"\n recap = {\n 'projectId' => projectId,\n 'invalid' => 0,\n 'error' => 0,\n 'info' => 0,\n 'warning' => 0\n }\n\n recap = JSON.parse(@redis_conn.get(queue)) if @redis_conn.exists?(queue)\n\n # if the payload is valid it defaults to severity error for the stats\n # unless a different type of severity is declared\n if valid?\n recap['valid_error'] += 1 unless @payload.key?('severity')\n recap[@payload['severity']] += 1\n else\n recap['invalid'] += 1\n end\n @redis_conn.set(queue, recap.to_json)\n end",
"def fetch_data\n\n UserKycDetail.find_in_batches(batch_size: 100) do |batched_records|\n batch_ued_ids = []\n user_id_to_ukd_map = {}\n\n batched_records.each do |record|\n user_id_to_ukd_map[record.user_id] = record\n batch_ued_ids << record.user_extended_detail_id\n end\n\n UserExtendedDetail.where(id: batch_ued_ids).each do |user_extended_detail|\n user_kyc_detail = user_id_to_ukd_map[user_extended_detail.user_id]\n\n r = Aws::Kms.new('kyc', 'admin').decrypt(user_extended_detail.kyc_salt)\n unless r.success?\n @failed_kms_decrypt_ued_ids << user_extended_detail.id\n next\n end\n\n kyc_salt_d = r.data[:plaintext]\n\n case_data = generate_case_data(kyc_salt_d, user_extended_detail, user_kyc_detail)\n\n populate_ethereum_addr_case_data_map(case_data)\n end\n\n end\n\n end",
"def retrieve_hook\n json = ActiveHook.redis.with { |c| c.brpop('ah:queue') }\n json.last if json\n end",
"def price_bulk_load\n logger.info 'PRICE BULK LOAD REQUESTED.'\n FeedWorker.perform_async('price_bulk_load')\n head :accepted\n end",
"def lookup(batch)\n req = Vacuum.new key: 'AKIAJA2IADZPBGHJTZRQ',\n secret: '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',\n tag: @tag,\n locale: 'us'\n \n \n params = { 'Operation' => 'ItemLookup',\n 'SearchIndex' => 'Books',\n 'ItemLookup.Shared.IdType' => 'ISBN',\n 'ItemLookup.Shared.Condition' => 'All',\n 'ItemLookup.Shared.MerchantId' => 'All',\n 'ItemLookup.Shared.ResponseGroup' => 'OfferFull'}\n \n batch.each_with_index do |item,index|\n params['ItemLookup.'+(index+1).to_s+'.ItemId'] = item\n end\n req.build params\n \n res = req.get\n items = []\n if res.valid?\n res.to_hash['Items'].each do |item|\n prod = {}\n prod['ASIN'] = item['Item']['ASIN']\n prod['New Price'] = item['Item']['OfferSummary']['LowestNewPrice']['FormattedPrice']\n prod['Used Price'] = item['Item']['OfferSummary']['LowestUsedPrice']['FormattedPrice']\n prod['url'] = \"http://www.amazon.com/dp/\"+prod['ASIN']+'/?tag='+@tag\n items << prod\n end\n end\n #puts res.to_hash.to_json\n items\nend",
"def poll\n\t\tactive_node = Node.find_by_mac_address(params[:nodeid]) || create_node\n\n\t\tif params[:jobid]\n\t\t\t# check status of current job\n\t\t\tjob = Job.find(params[:jobid])\n\n\t\t\tif job.status == \"active\"\n\t\t\t\trender :json => '{ \"status\": \"active\"}'\n\t\t\telse\n\t\t\t\trender\t:json => '{ \"status\": \"halt\"}'\n\t\t\tend\n\t\telse\n\t\t\t# check if there are any ongoing jobs\n\t\t\tjobs = Job.active\n\n\t\t\t# If there are any, choose one randomly\n\t\t\tif jobs.count > 0\n\t\t\t\tjob_idx = rand(jobs.count - 1)\n\n\t\t\t\tjob = jobs[job_idx]\n\n\t\t\t\t# If it's a dictionary job let's find the work\n\t\t\t\tif job[:attack_type] == \"dictionary\"\n\t\t\t\t\t# Not elegant, but can't directly assign job[:work] = ...\n\t\t\t\t\tjob.work = dictionary_content_for_job(job.id, active_node.id)\n\n\t\t\t\t\tif job.work == \"\"\n\t\t\t\t\t\tjob.status = \"completed\"\n\t\t\t\t\t\tjob.save\n\t\t\t\t\t\treturn :json => '{ \"status\": \"halt\"}'\n\t\t\t\t\tend\n\t\t\t\telsif job[:attack_type] == \"bruteforce\"\n\t\t\t\t\tjob.next_index = job.next_index.nil? ? 0 : job.next_index\n\n\t\t\t\t\tbruteforce_status = BruteforceStatus.create({\n\t\t\t\t\t\t:node_id => active_node.id,\n\t\t\t\t\t\t:job_id => job.id,\n\t\t\t\t\t\t:index => job.next_index\n\t\t\t\t\t})\n\t\t\t\t\t## Calculate next index. We're just going to increase by 50 for now\n\t\t\t\t\tjob.next_index = job.next_index + 50\n\t\t\t\t\tjob.save\n\n\t\t\t\t\t# TODO: Mark job complete if next_index > length\n\t\t\t\t\tkeyspace_size = Bruteforce::totalSize(job.charset)\n\t\t\t\t\tif job.next_index > keyspace_size\n\t\t\t\t\t\tjob.status = \"completed\"\n\t\t\t\t\t\tjob.save\n\t\t\t\t\tend\n\n\t\t\t\tend\n\n\t\t\t\trender :json => job, methods: [:work, :response_flag_meta]\n\t\t\telse\n\t\t\t\trender :json => '{ \"job\": \"none\"}'\n\t\t\tend\n\t\tend\n\n\t\t# mark the client as active\n\t\tactive_node.mark_active\n\tend",
"def current_data\n start_ssh do |ssh|\n return ssh.scp.download!(full_filename)\n end\n end",
"def run_washu_upload # CHNAGE _STATUS_FLAG = Y !!!!!!!\n v_base_path = Shared.get_base_path()\n @schedule = Schedule.where(\"name in ('washu_upload')\").first\n @schedulerun = Schedulerun.new\n @schedulerun.schedule_id = @schedule.id\n @schedulerun.comment =\"starting washu_upload\"\n @schedulerun.save\n @schedulerun.start_time = @schedulerun.created_at\n @schedulerun.save\n v_comment = \"\"\n v_comment_warning =\"\"\n v_computer = \"kanga\"\n connection = ActiveRecord::Base.connection();\n # shp, alz, pc, adni, dodadni, lmpd\n v_scan_procedure_exclude = [21,28,31,34,15,19,23,35,44,51,50,49,20,24,26,36,41] # [21,28,31,34,15,19,23,35,44,51,50,49]\n # just get the predicttau\n v_scan_procedures = [58] #[20,24,26,36,41,58] # how to only get adrc impact? \n #not limiting by protocol #scan_procedures_vgroups.scan_procedure_id in (\"+v_scan_procedures.join(\",\")+\")\n # getting adrc impact from t_adrc_impact_20150105 --- change to get from refreshing table?\n v_pet_tracer_array = [7] #1,2] # pib and fdg and thk5117 \n\n v_scan_type_limit = 1 \n v_series_desc_array =['T1 Volumetic','T1 Volumetric','T1+Volumetric','T1_Volumetric','T1','T2','T2 Flair','T2_Flair','T2+Flair','DTI','ASL','resting_fMRI']\n v_series_desc_nii_hash = {'nothing'=>\"Y\"} #{ 'T1 Volumetic'=>\"Y\",'T1 Volumetric'=>\"Y\",'T1+Volumetric'=>\"Y\",'T1_Volumetric'=>\"Y\",'T1'=>\"Y\"}\n # recruit new scans --- change \n v_weeks_back = \"2\" # cwant to give time for quality checks etc. \n # NEED TO LIMIT ADRC BY LP --- NEED TO REFRESH ADRC IMPACT \n # t_adrc_impact_control_20150216 where participant_id is not null and lp_completed_flag ='Y')\n #(participants.wrapnum is not null and participants.wrapnum > '')\n # only want the tau - petid=7 \n sql = \"select distinct vgroups.id, vgroups.participant_id,\n vgroups.transfer_mri, vgroups.transfer_pet\n from enrollments,enrollment_vgroup_memberships, vgroups, scan_procedures_vgroups,participants \n where participants.id = vgroups.participant_id and\n ( \n (vgroups.participant_id*-1) in ( select t_washu_adrc_20150215.participant_id from t_washu_adrc_20150215)\n or vgroups.participant_id in ( select t_washu_predicttau_20150909.participant_id from t_washu_predicttau_20150909)\n )\n and vgroups.id = enrollment_vgroup_memberships.vgroup_id \n and vgroups.id = scan_procedures_vgroups.vgroup_id\n and scan_procedures_vgroups.scan_procedure_id not in (\"+v_scan_procedure_exclude.join(\",\")+\")\n and enrollment_vgroup_memberships.enrollment_id = enrollments.id\n and vgroups.vgroup_date < DATE_SUB(curdate(), INTERVAL \"+v_weeks_back+\" WEEK) \n and enrollments.do_not_share_scans_flag ='N' \n and vgroups.id NOT IN ( select cg_washu_upload.vgroup_id from cg_washu_upload \n where scan_procedure_id = scan_procedures_vgroups.scan_procedure_id )\n and ( ( (vgroups.transfer_mri ='yes' or vgroups.transfer_mri !='yes') and vgroups.transfer_pet ='yes' and vgroups.id \n in ( select appointments.vgroup_id from appointments, petscans where petscans.appointment_id = appointments.id\n and petscans.lookup_pettracer_id in (7) )\n ) \n or \n (vgroups.transfer_mri ='yesSKIP' and enrollments.id in ( select enrollment_id from cg_csf) \n and vgroups.participant_id in (select p.id from participants p where wrapnum is not null and wrapnum > ''))\n or \n (vgroups.transfer_mri ='yesSKIP' and vgroups.participant_id in ( select t_washu_predicttau_20150909.participant_id from t_washu_predicttau_20150909) )\n or \n (vgroups.transfer_mri ='yesSKIP' and vgroups.completedlumbarpuncture = 'yes' \n and vgroups.participant_id in (select p.id from participants p where wrapnum is not null and wrapnum > '')\n and vgroups.id \n in ( select appointments.vgroup_id from appointments, lumbarpunctures where lumbarpunctures.appointment_id = appointments.id \n and lumbarpunctures.lpsuccess = 1) ) )\"\n results = connection.execute(sql)\n results.each do |r|\n enrollments = Enrollment.where(\"id in (select enrollment_id from enrollment_vgroup_memberships where vgroup_id in(?))\",r[0])\n enrollment_enumbers_array = []\n enrollments.each do |e|\n enrollment_enumbers_array.push(e.enumber)\n end\n enrollment_enumbers = enrollment_enumbers_array.join(\",\")\n scan_procedures = ScanProcedure.where(\"id in (select scan_procedure_id from scan_procedures_vgroups where vgroup_id in(?))\",r[0])\n scan_procedure_codename_array = []\n scan_procedures.each do |e|\n scan_procedure_codename_array.push(e.codename)\n end\n scan_procedure_codenames = scan_procedure_codename_array.join(\",\")\n v_mri_status_flag = \"N\"\n v_pet_status_flag =\"N\"\n if (r[2].to_s == \"yes\")\n v_mri_status_flag = \"Y\" \n end\n if (r[3].to_s == \"yes\")\n v_pet_status_flag = \"Y\" \n end\n sql2 = \"insert into cg_washu_upload (vgroup_id,mri_sent_flag,mri_status_flag, pet_sent_flag,pet_status_flag,participant_id,enumbers,codenames) \n values('\"+r[0].to_s+\"','N','\"+v_mri_status_flag+\"', 'N','\"+v_pet_status_flag+\"',\"+r[1].to_s+\",'\"+enrollment_enumbers+\"','\"+scan_procedure_codenames+\"')\"\n results2 = connection.execute(sql2)\n end\n\n sql = \"insert into cg_washu_participants (participant_id)\n select distinct cg_washu_upload.participant_id from cg_washu_upload \n where participant_id NOT IN ( select participant_id from cg_washu_participants)\n and participant_id is not null\"\n\n results = connection.execute(sql)\n\n sql = \"update cg_washu_upload \n set cg_washu_upload.export_id = ( select cg_washu_participants.export_id from cg_washu_participants \n where cg_washu_participants.participant_id = cg_washu_upload.participant_id)\"\n results = connection.execute(sql)\n\n v_folder_array = Array.new\n v_scan_desc_type_array = Array.new\n # check for dir in /tmp\n v_target_dir =\"/tmp/washu_upload\"\n # v_target_dir =\"/Volumes/Macintosh_HD2/washu_upload\"\n if !File.directory?(v_target_dir)\n v_call = \"mkdir \"+v_target_dir\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n end\n #PET\n sql = \"select distinct vgroup_id,export_id,enumbers from cg_washu_upload where pet_sent_flag ='N' and pet_status_flag in ('G') \" # ('Y','R') \"\n results = connection.execute(sql)\n\n v_comment = \" :list of vgroupids\"+v_comment\n results.each do |r|\n\n v_comment = r[0].to_s+\",\"+v_comment\n end\n @schedulerun.comment =v_comment[0..1990]\n @schedulerun.save\n results.each do |r|\n v_vgroup_id = r[0].to_s\n v_export_id = r[1]\n v_comment = \"strt \"+v_vgroup_id+\",\"+v_comment\n @schedulerun.comment =v_comment[0..1990]\n @schedulerun.save\n # update schedulerun comment - prepend \n \n sql_vgroup = \"select round((DATEDIFF(max(v.vgroup_date),p.dob)/365.25),2) from vgroups v, participants p where \n v.participant_id = p.id\n and v.id = \"+v_vgroup_id+\" and v.id in (select evm.vgroup_id from enrollment_vgroup_memberships evm, enrollments e,scan_procedures_vgroups spvg where spvg.vgroup_id = evm.vgroup_id and \n evm.enrollment_id = e.id and e.do_not_share_scans_flag ='N')\"\n results_vgroup = connection.execute(sql_vgroup)\n # mkdir /tmp/washu_upload/[subjectid]_YYYYMMDD_wisc\n v_subject_dir = v_export_id.to_s+\"_\"+(results_vgroup.first)[0].to_s+\"_pet_wisc\"\n v_parent_dir_target =v_target_dir+\"/\"+v_subject_dir\n v_call = \"mkdir \"+v_parent_dir_target\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close \n sql_pet = \"select distinct appointments.appointment_date, petscans.id petscan_id, petfiles.id petfile_id, lookup_pettracers.name, petfiles.path,petscans.lookup_pettracer_id\n from vgroups , appointments, petscans, lookup_pettracers, petfiles \n where vgroups.transfer_pet = 'yes' and vgroups.id = appointments.vgroup_id \n and appointments.id = petscans.appointment_id and petscans.id = petfiles.petscan_id\n and petscans.lookup_pettracer_id = lookup_pettracers.id\n and petscans.lookup_pettracer_id in (\"+v_pet_tracer_array.join(\",\")+\") \n and vgroups.id = \"+v_vgroup_id+\" \n order by appointments.appointment_date \"\n results_pet = connection.execute(sql_pet)\n v_folder_array = [] # how to empty\n v_tracer_array = []\n v_cnt = 1\n results_pet.each do |r_dataset|\n v_subject_id = \"\"\n v_tracer = r_dataset[3].gsub(/ /,\"_\").gsub(/\\[/,\"_\").gsub(/\\]/,\"_\")\n if !v_tracer_array.include?(v_tracer)\n v_tracer_array.push(v_tracer)\n end\n v_petfile_path = r_dataset[4]\n v_petfile_name = (r_dataset[4].split(\"/\")).last\n v_pettracer_id = r_dataset[5]\n #/mounts/data/raw/johnson.pipr.visit1/pet/pipr00001_2ef_c95_de11.v\n v_enumbers_array = r[2].split(\",\")\n v_enumbers_array.each do |e|\n v_subject_id = e\n v_petfile_name = v_petfile_name.gsub(v_subject_id,v_export_id.to_s )\n end\n if 1 == 2 and v_pettracer_id.to_s != \"7\"\n v_petfile_target_name = v_tracer+\"_\"+v_petfile_name\n v_call = \"rsync -av \"+v_petfile_path+\" \"+v_parent_dir_target+\"/\"+v_petfile_target_name \nputs(\"this petid= \"+v_pettracer_id.to_s )\nputs(v_call)\n stdin, stdout, stderr = Open3.popen3(v_call)\n stderr.each {|line|\n puts line\n }\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n end\n # tau \n if v_pettracer_id.to_s == \"7\" # only want tau\n v_processed_path = v_base_path+\"/preprocessed/outside_batches/TauPredict/20150811_TauPredict/\"\n v_enumbers_array.each do |e|\n v_subject_id = e\n v_source_file = v_subject_id+\"_T1_FS.nii\"\n v_export_file_name = v_export_id.to_s+\"_T1_FS_\"+v_tracer+\".nii\"\n v_check_path = v_processed_path+v_subject_id+\"/\"+v_source_file\n # check if exisits\n if(File.file?v_check_path)\n v_call = \"rsync -av \"+v_check_path+\" \"+v_parent_dir_target+\"/\"+v_export_file_name \nputs(v_call)\n stdin, stdout, stderr = Open3.popen3(v_call)\n stderr.each {|line|\n puts line\n }\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n end\n\n \n v_source_file = \"Coreg_\"+v_subject_id+\"HYPR_DVR.nii\"\n v_export_file_name = \"Coreg_\"+v_export_id.to_s+\"HYPR_DVR_\"+v_tracer+\".nii\"\n v_check_path = v_processed_path+v_subject_id+\"/\"+v_source_file\n # check if exisits\n if(File.file?v_check_path)\n v_call = \"rsync -av \"+v_check_path+\" \"+v_parent_dir_target+\"/\"+v_export_file_name \nputs( v_call)\n stdin, stdout, stderr = Open3.popen3(v_call)\n stderr.each {|line|\n puts line\n }\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n end\n end\n end\n\n end\n\n v_call = \"rsync -av \"+v_parent_dir_target+\" panda_user@\"+v_computer+\".dom.wisc.edu:/home/panda_user/upload_washu/\" #+v_subject_dir\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n \n #v_call = \"zip -r \"+v_target_dir+\"/\"+v_subject_dir+\".zip \"+v_parent_dir_target\n #v_call = \"cd \"+v_target_dir+\"; zip -r \"+v_subject_dir+\" \"+v_subject_dir # ??????? PROBLEM HERE????\n #v_call = \"cd \"+v_target_dir+\"; /bin/tar -zcf \"+v_subject_dir+\".tar.gz \"+v_subject_dir+\"/\"\n v_call = 'ssh panda_user@'+v_computer+'.dom.wisc.edu \" tar -C /home/panda_user/upload_washu -zcf /home/panda_user/upload_washu/'+v_subject_dir+'.tar.gz '+v_subject_dir+'/ \" '\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n puts \"bbbbbbb \"+v_call\n\n v_call = ' rm -rf '+v_target_dir+'/'+v_subject_dir\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n # \n v_call = 'ssh panda_user@'+v_computer+'.dom.wisc.edu \" rm -rf /home/panda_user/upload_washu/'+v_subject_dir+' \"'\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n \n \n # did the tar.gz on \"+v_computer+\" to avoid mac acl PaxHeader extra directories\n # not need this? \n # could change sftp to come from ~/upload_washu\n v_call = \"rsync -av panda_user@'+v_computer+'.dom.wisc.edu:/home/panda_user/upload_washu/\"+v_subject_dir+\".tar.gz \"+v_target_dir+'/'+v_subject_dir+\".tar.gz\"\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n\n#### # sftp -- shared helper hasthe username /password and address\n#### v_username = Shared.washu_sftp_username # get from shared helper\n#### v_passwrd = Shared.washu_sftp_password # get from shared helperwhich is not on github\n#### v_ip = Shared.washu_sftp_host_address # get from shared helper\n v_source = v_target_dir+'/'+v_subject_dir+\".tar.gz\"\n v_target = v_subject_dir+\".tar.gz\"\n\n \n\n#### Net::SFTP.start(v_ip, v_username, :password => v_passwrd) do |sftp|\n#### sftp.upload!(v_source, v_target)\n#### end\n# WANT TO CHECK TRANSFERS\n v_call = \" rm -rf \"+v_target_dir+'/'+v_subject_dir+\".tar.gz\"\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close \n \n sql_sent = \"update cg_washu_upload set pet_sent_flag ='Y' where vgroup_id ='\"+r[0].to_s+\"' \"\n results_sent = connection.execute(sql_sent) \n\n end\n\n # get subjectid to upload # USING G AS LIMIT FOR TESTING\n #MRI switching to appointment\n sql = \"select distinct cg_washu_upload.vgroup_id,export_id,appointments.id from cg_washu_upload,appointments \n where appointments.vgroup_id = cg_washu_upload.vgroup_id and\n appointments.appointment_type = 'mri'\n and mri_sent_flag ='N' and mri_status_flag in ('G') \" # ('Y','R') \"\n results = connection.execute(sql)\n\n v_comment = \" :list of vgroupid \"+v_comment\n results.each do |r|\n v_comment = r[0].to_s+\",\"+v_comment\n end\n @schedulerun.comment =v_comment[0..1990]\n @schedulerun.save\n v_past_vgroup_id = \"0\"\n v_cnt = 1\n results.each do |r|\n v_vgroup_id = r[0].to_s\n if v_vgroup_id != v_past_vgroup_id\n v_past_vgroup_id = v_vgroup_id\n v_cnt = 1\n else\n v_cnt = v_cnt + 1\n end\n v_export_id = r[1].to_s\n v_appointment_id = r[2].to_s\n v_comment = \"strt \"+v_vgroup_id+\",\"+v_comment\n @schedulerun.comment =v_comment[0..1990]\n @schedulerun.save\n # update schedulerun comment - prepend \n\n sql_vgroup = \"select round((DATEDIFF(a.appointment_date,p.dob)/365.25),2),\n round((DATEDIFF(v.vgroup_date,p.dob)/365.25),2),\n a.id from appointments a,vgroups v,participants p where v.id = \"+v_vgroup_id+\" \n and v.id = a.vgroup_id and a.id = \"+v_appointment_id+\"\n and v.participant_id = p.id\n and v.id in (select evm.vgroup_id from enrollment_vgroup_memberships evm, enrollments e,scan_procedures_vgroups spvg where spvg.vgroup_id = evm.vgroup_id and \n evm.enrollment_id = e.id and e.do_not_share_scans_flag ='N')\"\nputs \"PPPPP = apptid=\"+v_appointment_id+\" sql=\"+sql_vgroup \n results_vgroup = connection.execute(sql_vgroup)\n # mkdir /tmp/washu_upload/[subjectid]_YYYYMMDD_wisc\n v_subject_dir = v_export_id.to_s+\"_\"+(results_vgroup.first)[1].to_s+\"_\"+(results_vgroup.first)[0].to_s+\"_\"+v_cnt.to_s+\"_mri_wisc\"\n v_parent_dir_target =v_target_dir+\"/\"+v_subject_dir\n v_call = \"mkdir \"+v_parent_dir_target\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close \n sql_dataset = \"select distinct appointments.appointment_date, visits.id visit_id, image_datasets.id image_dataset_id, image_datasets.series_description, image_datasets.path, series_description_types.series_description_type \n from vgroups , appointments, visits, image_datasets, series_description_maps, series_description_types \n where vgroups.transfer_mri = 'yes' and vgroups.id = appointments.vgroup_id \n and appointments.id = visits.appointment_id and visits.id = image_datasets.visit_id\n and (image_datasets.do_not_share_scans_flag is NULL or image_datasets.do_not_share_scans_flag ='N')\n and LOWER(image_datasets.series_description) = LOWER(series_description_maps.series_description)\n and series_description_maps.series_description_type_id = series_description_types.id\n and series_description_types.series_description_type in ('\"+v_series_desc_array.join(\"','\")+\"') \n and image_datasets.series_description != 'DTI whole brain 2mm FATSAT ASSET'\n and vgroups.id = \"+v_vgroup_id+\" and appointments.id = \"+v_appointment_id+\"\n order by appointments.appointment_date \"\n results_dataset = connection.execute(sql_dataset)\n v_folder_array = [] # how to empty\n v_scan_desc_type_array = []\n v_cnt = 1\n results_dataset.each do |r_dataset|\n v_ids_ok_flag = \"Y\"\n v_ids_id = r_dataset[2]\n v_ids_ok_flag = self.check_ids_for_severe_or_incomplete(v_ids_id) # ADD THE DO NOT SHARE\n if v_ids_ok_flag == \"Y\" # no quality check severe or incomplete\n v_series_description_type = r_dataset[5].gsub(\" \",\"_\")\n v_path = r_dataset[4]\n v_dir_array = v_path.split(\"/\")\n v_dir = v_dir_array[(v_dir_array.size - 1)]\n v_dir_target = v_dir+\"_\"+v_series_description_type\n v_path = v_path.gsub(\"/Volumes/team/\",\"\").gsub(\"/Volumes/team-1/\",\"\").gsub(\"/Data/vtrak1/\",\"\") #v_base_path+\"/\"+\n if v_folder_array.include?(v_dir_target)\n v_dir_target = v_dir_target+\"_\"+v_cnt.to_s\n v_cnt = v_cnt +1\n # might get weird if multiple types have dups - only expect T1/Bravo\n end\n v_folder_array.push(v_dir_target)\n v_nii_flag = \"N\"\n #### v_nii_file_name = [subjectid]_[series_description /replace \" \" with -] , _[] , path- split / , last value]\n v_path_dir_array = r_dataset[4].split(\"/\")\n #/mounts/data/raw/wrap140/wrp002_5938_03072008/001\n v_subject_vgroup_array = v_path_dir_array[4].split(\"_\")\n v_subject_id = v_subject_vgroup_array[0]\n v_nii_file_name = v_subject_id+\"_\"+r_dataset[3].gsub(/ /,\"-\")+\"_\"+v_path_dir_array.last+\".nii\"\n v_nii_file_path = v_base_path+\"/preprocessed/visits/\"+v_path_dir_array[4].to_s+\"/\"+v_subject_id+\"/unknown/\"+v_nii_file_name\n\n if(v_series_desc_nii_hash[r_dataset[5]] == \"Y\")\n v_nii_flag = \"Y\"\n v_call = \"rsync -av \"+v_nii_file_path+\" \"+v_parent_dir_target+\"/\"+v_export_id.to_s+\"_\"+r_dataset[3].gsub(/ /,\"-\")+\"_\"+v_path_dir_array.last+\".nii\" \n stdin, stdout, stderr = Open3.popen3(v_call)\n stderr.each {|line|\n puts line\n }\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n end\n if !v_scan_desc_type_array.include?(v_series_description_type)\n v_scan_desc_type_array.push(v_series_description_type)\n end\n # v_call = \"/usr/bin/bunzip2 \"+v_parent_dir_target+\"/\"+v_dir_target+\"/*.bz2\"\n v_call = \"mise \"+v_path+\" \"+v_parent_dir_target+\"/\"+v_dir_target # works where bunzip2 cmd after rsync not work\n#puts \"v_path = \"+v_path\n#puts \"v_parent_dir_target = \"+ v_parent_dir_target\n#puts \"v_dir_target=\"+v_dir_target\nputs \"AAAAAA \"+v_call\n stdin, stdout, stderr = Open3.popen3(v_call)\n stderr.each {|line|\n puts line\n }\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n # temp - replace /Volumes/team/ and /Data/vtrak1/ with /Volumes/team-1 in dev\n # split on / --- get the last dir\n # make new dir name dir_series_description_type \n # check if in v_folder_array , if in v_folder_array , dir_series_description_type => dir_series_description_type_2\n # add dir, dir_series_description_type to v_folder_array\n # cp path ==> /tmp/washu_upload/[subjectid]_yyymmdd_wisc/dir_series_description_type(_2)\n end # skipping if qc severe or incomplete \n end\n\n sql_status = \"select mri_status_flag from cg_washu_upload where vgroup_id ='\"+r[0].to_s+\"' \"\n results_status = connection.execute(sql_status)\n if v_scan_desc_type_array.size < v_scan_type_limit and (results_status.first)[0] != \"R\"\n puts \"bbbbb !R or not enough scan types \"\n sql_dirlist = \"update cg_washu_upload set general_comment =' NOT ALL SCAN TYPES!!!! \"+v_folder_array.join(\", \")+\"' where vgroup_id ='\"+r[0].to_s+\"' \"\n results_dirlist = connection.execute(sql_dirlist)\n # send email \n v_subject = \"washu_upload \"+r[0].to_s+\" is missing some scan types --- set mri_status_flag ='R' to send : scans =\"+v_folder_array.join(\", \")\n v_email = \"noreply_johnson_lab@medicine.wisc.edu\"\n PandaMailer.schedule_notice(v_subject,{:send_to => v_email}).deliver\n\n # mail(\n # :from => \"noreply_johnson_lab@medicine.wisc.edu\"\n # :to => \"noreply_johnson_lab@medicine.wisc.edu\", \n # :subject => v_subject\n # )\n PandaMailer.schedule_notice(v_subject,{:send_to => \"noreply_johnson_lab@medicine.wisc.edu\"}).deliver\n v_comment_warning = v_comment_warning+\" \"+v_scan_desc_type_array.size.to_s+\" scan type \"+r[0].to_s+\" sp\"+r[1].to_s\n v_call = \"rm -rf \"+v_parent_dir_target\n# puts \"BBBBBBBB \"+v_call\n stdin, stdout, stderr = Open3.popen3(v_call)\n stderr.each {|line|\n puts line\n }\n while !stdout.eof?\n puts stdout.read 1024 \n end \n stdin.close\n stdout.close\n stderr.close\n else\n puts \"AAAAAAAAA DCM PATH TMP =\"+v_parent_dir_target+\"/*/*/*.dcm\"\n# /tmp/washu_upload/adrc00045_20130920_wisc/008_DTI/008\n\n sql_dirlist = \"update cg_washu_upload set mri_dir_list =concat('\"+v_folder_array.join(\", \")+\"',mri_dir_list) where vgroup_id ='\"+r[0].to_s+\"' \"\n results_dirlist = connection.execute(sql_dirlist)\n# TURN INTO A LOOP -- need to get rid of dates \n v_dicom_field_array =['0010,0030','0010,0010','0008,0050','0008,1030','0010,0020','0040,0254','0008,0080','0008,1010','0009,1002','0009,1030','0018,1000',\n '0025,101A','0040,0242','0040,0243','0008,0020','0008,0021','0008,0022','0008,0023','0040,0244']\n v_dicom_field_value_hash ={'0010,0030'=>'DOB','0010,0010'=>'Name','0008,0050'=>'Accession Number',\n '0008,1030'=>'Study Description', '0010,0020'=>'Patient ID','0040,0254'=>'Performed Proc Step Desc',\n '0008,0080'=>'Institution Name','0008,1010'=>'Station Name','0009,1002'=>'Private',\n '0009,1030'=>'Private','0018,1000'=>'Device Serial Number','0025,101A'=>'Private',\n '0040,0242'=>'Performed Station Name','0040,0243'=>'Performed Location',\n '0008,0020'=>'Study Date','0008,0021'=>'Series Date','0008,0022'=>'Acquisition Date', \n '0008,0023'=>'Content Date','0040,0244'=>'Performed Procedure Step Start Date'}\n #### v_dicom_field_array.each do |dicom_key|\n Dir.glob(v_parent_dir_target+'/*/*/*.dcm').each {|dcm| puts d = DICOM::DObject.read(dcm); \n v_dicom_field_array.each do |dicom_key|\n if !d[dicom_key].nil? \n d[dicom_key].value = v_dicom_field_value_hash[dicom_key]; d.write(dcm) \n end \n end }\n Dir.glob(v_parent_dir_target+'/*/*/*.0*').each {|dcm| puts d = DICOM::DObject.read(dcm); \n v_dicom_field_array.each do |dicom_key|\n if !d[dicom_key].nil? \n d[dicom_key].value = v_dicom_field_value_hash[dicom_key]; d.write(dcm) \n end \n end }\n Dir.glob(v_parent_dir_target+'/*/*/*.1*').each {|dcm| puts d = DICOM::DObject.read(dcm); \n v_dicom_field_array.each do |dicom_key|\n if !d[dicom_key].nil? \n d[dicom_key].value = v_dicom_field_value_hash[dicom_key]; d.write(dcm) \n end \n end }\n Dir.glob(v_parent_dir_target+'/*/*/*.2*').each {|dcm| puts d = DICOM::DObject.read(dcm); \n v_dicom_field_array.each do |dicom_key|\n if !d[dicom_key].nil? \n d[dicom_key].value = v_dicom_field_value_hash[dicom_key]; d.write(dcm) \n end \n end }\n Dir.glob(v_parent_dir_target+'/*/*/*.3*').each {|dcm| puts d = DICOM::DObject.read(dcm); \n v_dicom_field_array.each do |dicom_key|\n if !d[dicom_key].nil? \n d[dicom_key].value = v_dicom_field_value_hash[dicom_key]; d.write(dcm) \n end \n end }\n Dir.glob(v_parent_dir_target+'/*/*/*.4*').each {|dcm| puts d = DICOM::DObject.read(dcm); \n v_dicom_field_array.each do |dicom_key|\n if !d[dicom_key].nil? \n d[dicom_key].value = v_dicom_field_value_hash[dicom_key]; d.write(dcm) \n end \n end }\n Dir.glob(v_parent_dir_target+'/*/*/*.5*').each {|dcm| puts d = DICOM::DObject.read(dcm); \n v_dicom_field_array.each do |dicom_key|\n if !d[dicom_key].nil? \n d[dicom_key].value = v_dicom_field_value_hash[dicom_key]; d.write(dcm) \n end \n end }\n Dir.glob(v_parent_dir_target+'/*/*/*.6*').each {|dcm| puts d = DICOM::DObject.read(dcm); \n v_dicom_field_array.each do |dicom_key|\n if !d[dicom_key].nil? \n d[dicom_key].value = v_dicom_field_value_hash[dicom_key]; d.write(dcm) \n end \n end }\n \n #### end \n \n# \n# # #puts \"bbbbb dicom clean \"+v_parent_dir_target+\"/*/\"\n# Dir.glob(v_parent_dir_target+'/*/*/*.dcm').each {|dcm| puts d = DICOM::DObject.read(dcm); if !d[\"0010,0030\"].nil? \n# d[\"0010,0030\"].value = \"DOB\"; d.write(dcm) \n# end } \n v_call = \"rsync -av \"+v_parent_dir_target+\" panda_user@\"+v_computer+\".dom.wisc.edu:/home/panda_user/upload_washu/\" #+v_subject_dir\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n \n #v_call = \"zip -r \"+v_target_dir+\"/\"+v_subject_dir+\".zip \"+v_parent_dir_target\n #v_call = \"cd \"+v_target_dir+\"; zip -r \"+v_subject_dir+\" \"+v_subject_dir # ??????? PROBLEM HERE????\n #v_call = \"cd \"+v_target_dir+\"; /bin/tar -zcf \"+v_subject_dir+\".tar.gz \"+v_subject_dir+\"/\"\n v_call = 'ssh panda_user@'+v_computer+'.dom.wisc.edu \" tar -C /home/panda_user/upload_washu -zcf /home/panda_user/upload_washu/'+v_subject_dir+'.tar.gz '+v_subject_dir+'/ \" '\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n puts \"bbbbbbb \"+v_call\n\n v_call = ' rm -rf '+v_target_dir+'/'+v_subject_dir\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n # \n v_call = 'ssh panda_user@'+v_computer+'.dom.wisc.edu \" rm -rf /home/panda_user/upload_washu/'+v_subject_dir+' \"'\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n \n \n # did the tar.gz on \"+v_computer+\" to avoid mac acl PaxHeader extra directories\n # not need this? \n # could change sftp to come from ~/upload_washu\n v_call = \"rsync -av panda_user@\"+v_computer+\".dom.wisc.edu:/home/panda_user/upload_washu/\"+v_subject_dir+\".tar.gz \"+v_target_dir+'/'+v_subject_dir+\".tar.gz\"\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close\n\n#### # sftp -- shared helper hasthe username /password and address\n#### v_username = Shared.washu_sftp_username # get from shared helper\n#### v_passwrd = Shared.washu_sftp_password # get from shared helperwhich is not on github\n#### v_ip = Shared.washu_sftp_host_address # get from shared helper\n v_source = v_target_dir+'/'+v_subject_dir+\".tar.gz\"\n v_target = v_subject_dir+\".tar.gz\"\n\n \n\n#### Net::SFTP.start(v_ip, v_username, :password => v_passwrd) do |sftp|\n#### sftp.upload!(v_source, v_target)\n#### end\n# WANT TO CHECK TRANSFERS\n v_call = \" rm -rf \"+v_target_dir+'/'+v_subject_dir+\".tar.gz\"\n stdin, stdout, stderr = Open3.popen3(v_call)\n while !stdout.eof?\n puts stdout.read 1024 \n end\n stdin.close\n stdout.close\n stderr.close \n \n sql_sent = \"update cg_washu_upload set mri_sent_flag ='Y' where VGROUP_id ='\"+r[0].to_s+\"' \"\n results_sent = connection.execute(sql_sent)\n end\n v_comment = \"end \"+r[0].to_s+\",\"+v_comment\n @schedulerun.comment =v_comment[0..1990]\n @schedulerun.save \n end\n \n @schedulerun.comment =(\"successful finish washu_upload \"+v_comment_warning+\" \"+v_comment[0..1990])\n if !v_comment.include?(\"ERROR\")\n @schedulerun.status_flag =\"Y\"\n end\n @schedulerun.save\n @schedulerun.end_time = @schedulerun.updated_at \n @schedulerun.save \n \n \n end",
"def snapshot_every_n_requests=(_arg0); end",
"def index\n token = params[:token].presence\n user = token && User.find_by_authentication_token(token.to_s)\n\n @serv_offers\n user_id = params[:user_id].presence\n qry_type = params[:qry_type].presence\n qry_level = params[:qry_level].presence\n catalog_id = params[:catalog_id].presence\n serv_id = params[:serv_id].presence\n #个人已存档的需求查询的参数为request\n archived = params[:archived].presence\n extra_parm_s = params[:exploreparams]\n \t#场景一:按职业模糊查询\n \tif user_id.nil? && !extra_parm_s.nil? && 'undefined' != extra_parm_s\n \t\textra_parm_h = JSON.parse extra_parm_s\n\n #@serv_offers = Good.all\n uids = []\n \n if qry_level == Const::SERV_QRY_LEVEL[:myRe]\n uids = myRe(user)\n logger.debug \"1我的推荐用户id#{uids}\"\n elsif qry_level == Const::SERV_QRY_LEVEL[:friendRe]\n uids = friendRe(user) - myRe(user)\n logger.debug \"2我的好友推荐用户id#{uids}\"\n elsif qry_level == Const::SERV_QRY_LEVEL[:villageRe]\n uids = villageRe(user) - friendRe(user) - myRe(user)\n logger.debug \"3社区推荐用户id#{uids}\"\n elsif qry_level == Const::SERV_QRY_LEVEL[:MyResRe]\n uids = MyResRe(user) - villageRe(user) - friendRe(user) - myRe(user)\n logger.debug \"4我的推荐的推荐用户id#{uids}\"\n elsif qry_level == Const::SERV_QRY_LEVEL[:reMyResRe]\n uids = reMyResRe(user) - MyResRe(user) - villageRe(user) - friendRe(user) - myRe(user)\n logger.debug \"5、推荐了我推荐的用户的其它推荐id#{uids}\"\n end\n uids = uids.join(\",\")\n if uids != '' \n @serv_offers = Good.where(\"user_id in (#{uids})\")\n else\n uids = '999999999999999'\n @serv_offers = Good.where(\"user_id in (#{uids})\")\n end\n @serv_offers = @serv_offers.where(\"status = ?\", Const::GOODS_STATUS[:pass])\n @serv_offers = @serv_offers.where(\"serv_catagory =?\", Const::SysMsg::GOODS_TYPE[:offer])\n #查询参数有title且title不为空\n if extra_parm_h.include?(\"title\") && extra_parm_h['title']!=''\n @serv_offers = @serv_offers.where(\"catalog like ?\", \"%#{extra_parm_h['title']}%\").order(\"created_at DESC\").page(params[:page]).per(5) \n else\n @serv_offers = @serv_offers.order(\"created_at DESC\").page(params[:page]).per(5) \n end\n #场景三:某[二级分类]相关服务查询\n elsif user_id.nil? && catalog_id\n logger.debug \"查找分类为#{catalog_id}\"\n @target_user = Good.find(serv_id).user\n #serv_id不为空时是查看服务的相关服务\n #serv_id为空时是查看需求的相关服务\n if serv_id \n @serv_offers = Good.where(\"id != ? and status = ? and goods_catalog_id = ? and serv_catagory = ?\", serv_id, Const::GOODS_STATUS[:pass], catalog_id, Const::SysMsg::GOODS_TYPE[:offer]).order(\"created_at DESC\").page(params[:page]).per(4) \n else\n @serv_offers = Good.where(\"status = ? and goods_catalog_id = ? and serv_catagory = ?\", Const::GOODS_STATUS[:pass], catalog_id, Const::SysMsg::GOODS_TYPE[:offer]).order(\"created_at DESC\").page(params[:page]).per(4) \n end\n \n #场景二:全部查询\n \telsif user_id.nil?\n if (qry_type == Const::SERV_QRY_TYPE[:offer])\n @serv_offers = Good.where(\"serv_catagory =?\", Const::SysMsg::GOODS_TYPE[:offer])\n elsif (qry_type == Const::SERV_QRY_TYPE[:request])\n @serv_offers = Good.where(\"serv_catagory =?\", Const::SysMsg::GOODS_TYPE[:request])\n else\n @serv_offers = Good.order(\"created_at DESC\")\n \t\tend\n @serv_offers =@serv_offers.where(\"status =?\", Const::GOODS_STATUS[:pass]).order(\"created_at DESC\").page(params[:page]).per(5)\n \n #场景四:个人查询\n else\n if(qry_type == Const::SERV_QRY_TYPE[:offer])#我的->服務\n @serv_offers = Good.where(\" serv_catagory =? and user_id = ? and status != ? \", Const::SysMsg::GOODS_TYPE[:offer], user_id, Const::GOODS_STATUS[:destroy]).order(\"created_at DESC\").page(params[:page]).per(5)\n @size = 0 #Good.where(\" serv_catagory =? and user_id = ?\", Const::SysMsg::GOODS_TYPE[:offer], user_id).size;\n elsif(qry_type == Const::SERV_QRY_TYPE[:request])#我的->需求\n if(archived)\n @favorites = Favorite.where(\"user_id = ? and obj_type = ?\", user.id, Const::SysMsg::GOODS_TYPE[:request]).order(\"created_at DESC\").page(params[:page]).per(5)\n @requests = []\n logger.debug \"收藏的需求#{@favorites.to_json}\"\n @favorites.each do |favorite|\n offer = Good.find(favorite.obj_id)\n s = offer.attributes.clone\n s[\"isFavorited\"] = true\n s[\"favorite_id\"] = favorite.id.to_s\n r = Report.where(\"user_id = ? and obj_id = ? and obj_type = ?\", user.id, offer.id, \"good\").first\n if r.blank?\n s[\"isReported\"] = false\n else\n s[\"isReported\"] = true\n s[\"report_id\"] = r[\"id\"].to_s\n end\n s[\"user\"]=user\n @requests.push(s)\n end\n respond_to do |format|\n format.json {\n render json: {page: @favorites.current_page, total_pages: @favorites.total_pages, feeds: @requests.to_json}\n }\n end\n return\n else\n @serv_offers = Good.where(\"serv_catagory =? and user_id = ? and status != ? and not exists (select obj_id from favorites f where f.obj_id = goods.id) \", Const::SysMsg::GOODS_TYPE[:request], user_id, Const::GOODS_STATUS[:destroy]).order(\"created_at DESC\").page(params[:page]).per(5) \n @size = 0 #Good.where(\" serv_catagory =? and user_id = ? and status != ? \", Const::SysMsg::GOODS_TYPE[:request], user_id, Const::GOODS_STATUS[:destroy]).size;\n end \n else\n @serv_offers = Good.where(\"user_id = ? and status != ? \", user_id, Const::GOODS_STATUS[:destroy]).order(\"created_at DESC\").page(params[:page]).per(5)\n end\n end\n\n @offers = []\n if @serv_offers.nil?\n respond_to do |format|\n format.json {\n render json: {page: 0, total_pages: 0, feeds: @offers.to_json, count: @size ? @size : 0}\n }\n end\n else\n @serv_offers.each do |offer|\n s = offer.attributes.clone\n begin\n u = User.find(offer.user_id)\n u.authentication_token = \"***\"\n s[\"user\"]=u\n rescue ActiveRecord::RecordNotFound => e\n\n end\n\n #是否推荐(好评)\n c = Comment.where(\"user_id = ? and obj_id= ? and status = ?\", user.id, u.id, \"good\").first\n if c.blank?\n s[\"isRecommanded\"] = false\n else\n s[\"isRecommanded\"] = true\n s[\"comment_id\"] = c[\"id\"].to_s\n s[\"comment_content\"] = c[\"content\"]\n end\n c2 = Comment.where(\"user_id != ? and obj_id = ? and status = ?\", user.id, u.id, \"good\").first\n if c2.blank?\n else\n s[\"recommand_user\"] = User.find(c2.user_id)\n end\n #是否收藏\n f = Favorite.where(\"user_id = ? and obj_id = ?\", user.id, offer.id).first\n if f.blank?\n s[\"isFavorited\"] = false\n else\n s[\"isFavorited\"] = true\n s[\"favorite_id\"] = f[\"id\"].to_s\n end\n\n #是否举报\n r = Report.where(\"user_id = ? and obj_id = ? and obj_type = ?\", user.id, offer.id, \"good\").first\n if r.blank?\n s[\"isReported\"] = false\n else\n s[\"isReported\"] = true\n s[\"report_id\"] = r[\"id\"].to_s\n end\n\n s[\"created_at\"] = s[\"created_at\"].strftime('%Y-%m-%d %H:%M:%S')\n s[\"updated_at\"] = s[\"updated_at\"].strftime('%Y-%m-%d %H:%M:%S')\n @offers.push(s)\n end\n\n respond_to do |format|\n format.json {\n render json: {page: @serv_offers.current_page, total_pages: @serv_offers.total_pages, feeds: @offers.to_json, count: @size ? @size : 0}\n }\n end\n end\n\n end",
"def index\n @stocks = Stock.all.where(user_id: current_user.id)\n @stock_lists = StockList.all.where(user_id: current_user.id)\n\n #GetPricesJob.perform_now\n\n end",
"def query\n resp = {:records => []}\n status_key = STATUS[rand(STATUS.length)]\n ss = Spooge.find_on_redis(:status,status_key)\n resp[:record_count] = ss.length\n ss.each do |s|\n resp[:records] << s\n end \n render :json => resp\n end",
"def fetch_from_redis(object, feed_type, score=nil)\n score = self.timestamp if score.nil?\n (ActivityFeed.redis_instance.zrevrangebyscore object.redis_feed_key(feed_type), score, score).first\n end",
"def mget\n begin \n params.reject! {|key, value| ['controller', 'action', 'format'].include?(key)}\n @connections = []\n params.each do |key, value|\n @connections << {key: value, value: to_obj($redis.get(value)), ttl: $redis.ttl(value)}\n end \n rescue => e\n @connections = {status: 500, message: e.message }\n end \n\n respond_to do |format|\n format.json { render json: @connections }\n end\n end",
"def get\n self.class.cast_from_redis redis.get(self.key), @options\n end",
"def runjob\n #last_valuation = current_valuation\n #current_valuation = rand(100)\n\n #APIKEY = 'qFuWyb9A1pIkykQ'\n #@SERVERURL = 'http://nightwing.recsports.vt.edu:3001/api?api_key=' + APIKEY\n\n #data = HTTParty.get @SERVERURL\n\n #@STATURL = 'http://nightwing.recsports.vt.edu:3001/api/stats?key=123456'\n @STATURL = 'http://run.recsports.vt.edu/api/stats?key=qFuWyb9A1pIkykQ'\n @stats = HTTParty.get(@STATURL)\n @statshash = JSON.parse(@stats.body)\n\n #@statshash = Oj.dump(@stats.body)\n\n #puts @statshash\n #total_registrations = @statshash['stats']['total_registrations']\n\n total_registrations = @statshash['stats']['checked_in']\n\n #walkup = @statshash['stats']['walkup']\n #checked_in = @statshash['stats']['checked_in']\n #checked_in_first_day = @statshash['stats']['checked_in_first_day']\n #checked_in_percent = checked_in.fdiv(@total_registrations)*100\n #checked_in_percent = checked_in_percent.round\n\n puts total_registrations\n\n last_valuation = total_registrations\n #puts walkup\n #puts checked_in\n #puts checked_in_percent\n\n #json = Oj.load(@statshash)\n #@statshash = JSON.parse(@stats.stats)\n\n\n Dashing.send_event('totalregisters', { current:total_registrations}) #, last: last_valuation\n #Dashing.send_event('walk', { current: walkup, last: walkup })\n #Dashing.send_event('checkedin', { value: checked_in })\n #Dashing.send_event('checkedinfirstday', { current: checked_in_first_day, last: checked_in_first_day })\n\n\nend",
"def create_heartbeat\n heartbeat = Thread.new do\n begin\n hb = {:data => {:hb => true}, :user_id => nil}\n ActiveRecord::Base.connection_pool.with_connection do |connection|\n conn = connection.instance_variable_get(:@connection)\n loop do\n opened_boards = $redis.lrange(\"opened_board_ids\", 0, -1)\n puts 'Currently HeartBeating towards channels: #{opened_boards}'\n puts opened_boards\n opened_boards.each do |board_id|\n conn.async_exec \"NOTIFY boards_#{board_id}, '#{hb.to_json}'\"\n end\n sleep 20.seconds\n end\n end\n ensure\n end\n end\nend",
"def start\n\n @settings['accounts'].each do |account,keys|\n\n puts \"Account: #{account}\"\n @aws_access_key_id = keys['access_key_id']\n @aws_secret_access_key = keys['secret_access_key']\n\n # Find all servers with tags matching the supplied Hash\n find_instances(@tags).each do |server|\n\n # Begin snapshotting each volume attached to the server\n #\n server.block_device_mapping.each do |block_device|\n\n log \"\\e[0;32m Searching for matching snapshots \\e[0m(#{server.id}:#{block_device})..\"\n snapshots = volume_snapshots(block_device['volumeId'])\n\n # Create each type of backup we'll be using\n #\n %w(hourly daily weekly monthly).each do |snapshot_type|\n\n # Build snapshot history for the working volume and return all snapshots\n # matching our particular snapshot type\n history = snapshots.select do |snapshot|\n snapshot.tags['snapshot_type'] == snapshot_type &&\n snapshot.tags['volume_id'] == block_device['volumeId'] &&\n snapshot.tags['protected'] == 'false'\n end\n\n history.sort_by! { |snapshot| snapshot.created_at }\n\n unless too_soon?(history,snapshot_type) || instance_variable_get(\"@#{snapshot_type}_snapshots\") == 0\n\n # Check against threshold limits for backup history and delete as needed\n #\n while history.size >= instance_variable_get(\"@#{snapshot_type}_snapshots\")\n delete_snapshot(history.first.id)\n history.delete(history.first)\n end\n\n log \"Creating #{snapshot_type} for #{block_device['volumeId']}..\"\n create_snapshot({\n 'volume_id' => block_device['volumeId'],\n 'snapshot_type' => snapshot_type,\n 'description' => \"Snapshot::#{snapshot_type.capitalize}> Server: #{server.id}\",\n 'tags' => {\n 'snapshot_time' => \"#{Time.now}\",\n 'snapshot_type' => snapshot_type,\n 'instance_id' => server.id,\n 'volume_id' => block_device['volumeId'],\n 'deviceName' => block_device['deviceName'],\n 'protected' => 'false'\n }\n })\n end\n end\n end\n end\n end\n\n end",
"def getIngest_queue( flush)\n params = Hash.new\n params['flush'] = flush\n return doCurl(\"get\",\"/ingest_queue\",params)\n end",
"def refresh\n ::Chef_Delivery::ClientHelper.enter_client_mode_as_delivery\n @job = @rest.get_rest(@job_uri)\n ::Chef_Delivery::ClientHelper.leave_client_mode_as_delivery\n\n @id ||= job['id']\n @status = job['status']\n @created_at = DateTime.parse(job['created_at'])\n @updated_at = DateTime.parse(job['updated_at'])\n @results = job['nodes']\n end",
"def main()\n\t@home_directory=\"/home/ubuntu\"\n\t@curl_path =\"/usr/bin\"\n\t@curl_command = \"curl\"\n\t@dummy_directory=\"/opt/cloudfoundry/dummy\"\n\t@project = \"redis\"\n\t@zip_path = \"/opt/cloudfoundry/gitzip/#{@project}\"\n\t@project_directory = \"/opt/cloudfoundry/project\"\n\t@git_url =\"https://github.com/pivotal-cf/cf-redis-example-app/archive/master.zip\"\n\tget_api_url()\n\tget_access_token()\n\tprint \"Enter the Organization name:\".yellow\n\t@organization_name = gets.chomp\n\tprint \"Enter the Space name:\".yellow\n\t@space_name = gets.chomp\n\tendpoint = Endpoint.new(@curl_command,@curl_path,@api_url,@access_token)\n\tendpoint.main(@organization_name,@space_name)\n\tspace_hash = endpoint.space_hash # since it is needed in service class for checking the service in market place for a particular space.\n\tcf_login()\n\tprint \"Enter the application name:\".yellow\n\t@application_name = gets.chomp\n\tapplication = Application.new(@curl_command,@curl_path,@application_name,@access_token,@api_url,@zip_path,@project_directory,@git_url)\n\tapplication.delete_orphan_route()\n\tapplication.check_for_app(@application_name)\n\tservice = Service.new(@curl_command,@curl_path,@organization_name,@space_name,@api_url,@access_token,space_hash)\n\tservice.main()\n\t@service_instance_name = service.service_instance\n\tbind = Bind.new\n\tbind.binding_service_to_app(@application_name,@service_instance_name)\n\tstart_obj = Start.new\n\tstart_obj.start(@application_name)\n\tcheck = Check.new(@api_url,@curl_command,@curl_path,@dummy_directory,@application_name)\n\tcheck.push_data()\n\tcheck.get_data()\nend",
"def pull_on_operand_branch *args\n self.on_operand_branch :pull, *args\n end",
"def unboundRequest(params)\n broker_url = APP_CONFIG['broker_ip'] + ':' + APP_CONFIG['broker_port'].to_s\n\n resources = []\n\n h1 = Hash.new\n h2 = Hash.new\n\n # puts Time.zone.now\n\n if params[:start_date] != \"\"\n valid_from = params[:start_date] + \":00 \"\n valid_from = Time.zone.parse(valid_from)\n else\n time_now = Time.zone.now.to_s.split(\" \")[1][0...-3]\n time_from = roundTimeUp(time_now)\n valid_from = Time.zone.now.to_s.split(\" \")[0] + \" \" +time_from+ \":00 \"\n valid_from = Time.zone.parse(valid_from)\n end\n\n #For nodes\n if params[:number_of_nodes] != \"\"\n if params[:duration_t1] != \"\"\n if params[:domain1] != \"\"\n h1 = { type: \"Node\", exclusive: true, duration: params[:duration_t1].to_i, valid_from: valid_from, domain: params[:domain1]}\n else\n h1 = { type: \"Node\", exclusive: true, duration: params[:duration_t1].to_i, valid_from: valid_from}\n end\n else\n if params[:domain1] != \"\"\n h1 = { type: \"Node\", exclusive: true, valid_from: valid_from, domain: params[:domain1]}\n else\n h1 = { type: \"Node\", exclusive: true, valid_from: valid_from}\n end\n end \n\n params[:number_of_nodes].to_i.times {resources << h1}\n\n end\n\n #For channels\n if params[:number_of_channels] != \"\"\n if params[:duration_t1] != \"\"\n if params[:domain1] != \"\"\n h1 = { type: \"Channel\", exclusive: true, duration: params[:duration_t1].to_i, valid_from: valid_from, domain: params[:domain1]}\n else\n h1 = { type: \"Channel\", exclusive: true, duration: params[:duration_t1].to_i, valid_from: valid_from}\n end\n else\n if params[:domain1] != \"\"\n h1 = { type: \"Channel\", exclusive: true, valid_from: valid_from, domain: params[:domain1]}\n else\n h1 = { type: \"Channel\", exclusive: true, valid_from: valid_from}\n end\n end \n\n params[:number_of_channels].to_i.times {resources << h1}\n\n end\n\n options = {body: {\n resources: resources\n }.to_json, :headers => { 'Content-Type' => 'application/json' } , :verify => false}\n response = HTTParty.get(broker_url+\"/resources\", options)\n\n puts options\n\n if response.header.code != '200'\n puts \"Something went wrong\"\n puts response\n flash[:danger] = response\n else \n puts response\n response[\"resource_response\"][\"resources\"].each do |element|\n element[\"valid_from\"] = Time.zone.parse(element[\"valid_from\"]).to_s\n element[\"valid_until\"] = Time.zone.parse(element[\"valid_until\"]).to_s\n end\n\n return response\n end\n end",
"def despacharFtp(sku,cant,to,oc)\n price = Product.where(sku: sku).first.price\n transfered = 0\n #do while products have to be dispatched\n while transfered < cant do\n resp = Fetcher.Bodegas(\"GET\"+DESPACHO+sku.to_s,\"stock?almacenId=\"+DESPACHO+\"&sku=\"+sku.to_s)\n puts resp\n count = 0\n for prod in resp do\n if count == 89 && transfered < cant then\n sleep(60)\n count = 0\n end\n if transfered < cant then\n id_aux = prod['_id']\n dispatchStockFTP(id_aux,oc,to,price)\n count+=1\n transfered+=1\n else\n return 0\n end\n end\n end\n #restar stock\n a = Product.where(sku:sku.to_i).first\n a.stock -= cant\n a.save\n end",
"def redis_on_base\n on_base\n end",
"def index\n #@future_tickers = FutureTicker.all\n @future_tickers = $influxdb.query(\"select * from ticker where contract_type='#{params[:contract_type]}' and symbol='#{params[:symbol]}'\").first[\"values\"]\n end",
"def command_queue; end",
"def read(uid)\n if instance = klass.where(id: uid).take\n [\n instance.payload,\n instance.meta\n ]\n else\n nil\n end\n end",
"def initialize\n @db_size = 10 # Number of puns to parse\n @db = Redis.new\n end",
"def get_solrcloud_instances_by_action(node, action)\n if !node['workorder']['payLoad'].has_key?(\"SolrClouds\")\n puts \"***FAULT:FATAL=SolrClouds payload not found, you must pull the design.\"\n e = Exception.new(\"no backtrace\")\n e.set_backtrace(\"\")\n raise e \n end\n solr_clouds = node['workorder']['payLoad']['SolrClouds']\n Chef::Log.info(\"Total solrcloud instances in the payload : #{solr_clouds.size()}\")\n solr_clouds_actioned = solr_clouds.select { |solr_cloud| solr_cloud['rfcAction'] != nil && solr_cloud['rfcAction'].eql?(action) }\n Chef::Log.info(\"Total solrcloud instances with action #{action} in the deployment : #{solr_clouds_actioned.size()}\")\n return solr_clouds_actioned\n end",
"def run_jobs\n begin\n while self.pending_ops.where(state: :init).count > 0\n op = self.pending_ops.where(state: :init).first\n\n # store the op._id to load it later after a reload\n # this is required to prevent a reload from replacing it with another one based on position\n op_id = op._id\n\n # try to do an update on the pending_op state and continue ONLY if successful\n op_index = self.pending_ops.index(op)\n retval = CloudUser.where({ \"_id\" => self._id, \"pending_ops.#{op_index}._id\" => op._id, \"pending_ops.#{op_index}.state\" => \"init\" }).update({\"$set\" => { \"pending_ops.#{op_index}.state\" => \"queued\" }})\n unless retval[\"updatedExisting\"]\n self.reload\n next\n end\n\n case op.op_type\n when :add_ssh_key\n Application.accessible(self).each{ |app| app.add_ssh_keys(self._id, [UserSshKey.new.to_obj(op.arguments)], nil) }\n when :delete_ssh_key\n Application.accessible(self).each{ |app| app.remove_ssh_keys(self._id, [UserSshKey.new.to_obj(op.arguments)], nil) }\n end\n\n # reloading the op reloads the cloud_user and then incorrectly reloads (potentially)\n # the op based on its position within the pending_ops list\n # hence, reloading the cloud_user, and then fetching the op using the op_id stored earlier\n self.reload\n op = self.pending_ops.find_by(_id: op_id)\n\n op.close_op\n op.delete if op.completed?\n end\n true\n rescue Exception => ex\n Rails.logger.error ex\n Rails.logger.error ex.backtrace\n false\n end\n end",
"def fetch_data\n _mem = mem\n _loadavg = loadavg\n {\n :server => \"#{@config[\"server\"]}\",\n :key => \"#{@config[\"key\"]}\",\n :data => {\n :mem => _mem.to_json,\n :loadavg => _loadavg.to_json\n }}.to_json\nend",
"def load_bills()\n params = {'history.active' => true}\n params['order'] = 'last_action_at'\n @bills = process('bills', 'bills', params)\n end",
"def fetch!\n cm = @api.api('apps/v1').resource('deployments', namespace: @ns).get(@deployment)\n volume = cm.spec.template.spec.volumes.map(&:to_h).find { |h| h[:name] == @volume }\n items = volume.dig(:configMap, :items) || []\n @_current = items.find { |item| item[:key] == @key }\n end",
"def run_jobs(result_io=nil)\n result_io = ResultIO.new if result_io.nil?\n self.reload\n begin\n while self.pending_op_groups.count > 0\n op_group = self.pending_op_groups.first\n self.user_agent = op_group.user_agent\n if op_group.pending_ops.count == 0\n case op_group.op_type\n when :change_members\n added = Array(op_group.args['added']).select{ |id| (role = role_for(id)) and Ability.has_permission?(id, :ssh_to_gears, Application, role, self) } \n removed = Array(op_group.args['removed']).dup\n Array(op_group.args['changed']).each do |(id, from, to)|\n was = Ability.has_permission?(id, :ssh_to_gears, Application, from || default_role, self) \n is = Ability.has_permission?(id, :ssh_to_gears, Application, to || default_role, self) \n next if is == was\n (is ? added : removed) << id\n end\n ops = calculate_update_existing_configuration_ops({\n # FIXME this is an unbounded operation, all keys for all users added and removed to each gear. need to optimize\n 'add_keys_attrs' => CloudUser.members_of(added).map{ |u| get_updated_ssh_keys(u._id, u.ssh_keys) }.flatten(1),\n 'remove_keys_attrs' => CloudUser.members_of(removed).map{ |u| get_updated_ssh_keys(u._id, u.ssh_keys) }.flatten(1),\n })\n op_group.pending_ops.push(*ops)\n when :update_configuration\n ops = calculate_update_existing_configuration_ops(op_group.args)\n op_group.pending_ops.push(*ops)\n when :add_features\n #need rollback\n features = self.requires + op_group.args[\"features\"]\n group_overrides = (self.group_overrides || []) + (op_group.args[\"group_overrides\"] || [])\n ops, add_gear_count, rm_gear_count = update_requirements(features, group_overrides, op_group.args[\"init_git_url\"], op_group.args[\"user_env_vars\"])\n try_reserve_gears(add_gear_count, rm_gear_count, op_group, ops)\n when :remove_features\n #need rollback\n features = []\n features = self.requires - op_group.args[\"features\"] unless op_group.args[\"remove_all_features\"]\n group_overrides = (self.group_overrides || []) + (op_group.args[\"group_overrides\"] || [])\n ops, add_gear_count, rm_gear_count = update_requirements(features, group_overrides)\n try_reserve_gears(add_gear_count, rm_gear_count, op_group, ops)\n when :update_component_limits\n updated_overrides = (self.group_overrides || []).deep_dup\n found = updated_overrides.find {|go| go[\"components\"].include? op_group.args[\"comp_spec\"] }\n group_override = found || {\"components\" => [op_group.args[\"comp_spec\"]]}\n group_override[\"min_gears\"] = op_group.args[\"min\"] unless op_group.args[\"min\"].nil?\n group_override[\"max_gears\"] = op_group.args[\"max\"] unless op_group.args[\"max\"].nil?\n group_override[\"additional_filesystem_gb\"] = op_group.args[\"additional_filesystem_gb\"] unless op_group.args[\"additional_filesystem_gb\"].nil?\n updated_overrides.push(group_override) unless found\n features = self.requires\n ops, add_gear_count, rm_gear_count = update_requirements(features, updated_overrides)\n try_reserve_gears(add_gear_count, rm_gear_count, op_group, ops)\n when :delete_app\n self.pending_op_groups.clear\n self.delete\n when :remove_gear\n ops = calculate_remove_gear_ops(op_group.args)\n try_reserve_gears(0, 1, op_group, ops)\n when :scale_by\n #need rollback\n ops, add_gear_count, rm_gear_count = calculate_scale_by(op_group.args[\"group_instance_id\"], op_group.args[\"scale_by\"])\n try_reserve_gears(add_gear_count, rm_gear_count, op_group, ops)\n when :replace_all_ssh_keys\n ops = calculate_replace_all_ssh_keys_ops(op_group.args)\n op_group.pending_ops.push(*ops)\n when :add_alias\n self.group_instances.each do |group_instance|\n if group_instance.gears.where(app_dns: true).count > 0\n gear = group_instance.gears.find_by(app_dns: true)\n op_group.pending_ops.push PendingAppOp.new(op_type: :add_alias, args: {\"group_instance_id\" => group_instance.id.to_s, \"gear_id\" => gear.id.to_s, \"fqdn\" => op_group.args[\"fqdn\"]} )\n break\n end\n end\n when :remove_alias\n self.group_instances.each do |group_instance|\n if group_instance.gears.where(app_dns: true).count > 0\n gear = group_instance.gears.find_by(app_dns: true)\n op_group.pending_ops.push PendingAppOp.new(op_type: :remove_alias, args: {\"group_instance_id\" => group_instance.id.to_s, \"gear_id\" => gear.id.to_s, \"fqdn\" => op_group.args[\"fqdn\"]} )\n break\n end\n end\n when :add_ssl_cert\n self.group_instances.each do |group_instance|\n if group_instance.gears.where(app_dns: true).count > 0\n gear = group_instance.gears.find_by(app_dns: true)\n op_group.pending_ops.push PendingAppOp.new(op_type: :add_ssl_cert, args: {\"group_instance_id\" => group_instance.id.to_s, \"gear_id\" => gear.id.to_s,\n \"fqdn\" => op_group.args[\"fqdn\"], \"ssl_certificate\" => op_group.args[\"ssl_certificate\"], \"private_key\" => op_group.args[\"private_key\"], \"pass_phrase\" => op_group.args[\"pass_phrase\"] } )\n break\n end\n end\n when :remove_ssl_cert\n self.group_instances.each do |group_instance|\n if group_instance.gears.where(app_dns: true).count > 0\n gear = group_instance.gears.find_by(app_dns: true)\n op_group.pending_ops.push PendingAppOp.new(op_type: :remove_ssl_cert, args: {\"group_instance_id\" => group_instance.id.to_s, \"gear_id\" => gear.id.to_s, \"fqdn\" => op_group.args[\"fqdn\"]} )\n break\n end\n end\n when :patch_user_env_vars\n op_group.pending_ops.push(PendingAppOp.new(op_type: op_group.op_type, args: op_group.args.dup))\n when :add_broker_auth_key, :remove_broker_auth_key\n ops = []\n args = op_group.args.dup\n self.group_instances.each do |group_instance|\n args[\"group_instance_id\"] = group_instance._id.to_s\n group_instance.gears.each do |gear|\n args[\"gear_id\"] = gear._id.to_s\n ops.push(PendingAppOp.new(op_type: op_group.op_type, args: args.dup))\n end\n end\n op_group.pending_ops.push(*ops)\n when :start_app, :stop_app, :restart_app, :reload_app_config, :tidy_app\n ops = calculate_ctl_app_component_ops(op_group.op_type)\n op_group.pending_ops.push(*ops)\n when :start_feature, :stop_feature, :restart_feature, :reload_feature_config\n ops = calculate_ctl_feature_component_ops(op_group.op_type, op_group.args['feature'])\n op_group.pending_ops.push(*ops)\n when :start_component, :stop_component, :restart_component, :reload_component_config\n ops = calculate_ctl_component_ops(op_group.op_type, op_group.args['comp_spec'])\n op_group.pending_ops.push(*ops)\n when :execute_connections\n op_group.pending_ops.push PendingAppOp.new(op_type: :execute_connections)\n end\n end\n\n if op_group.op_type != :delete_app\n op_group.execute(result_io)\n unreserve_gears(op_group.num_gears_removed)\n op_group.delete\n self.reload\n end\n\n end\n true\n rescue Exception => e_orig\n Rails.logger.error e_orig.message\n Rails.logger.debug e_orig.backtrace.inspect\n\n #rollback\n begin\n op_group.execute_rollback(result_io)\n op_group.delete\n num_gears_recovered = op_group.num_gears_added - op_group.num_gears_created + op_group.num_gears_rolled_back + op_group.num_gears_destroyed\n unreserve_gears(num_gears_recovered)\n rescue Exception => e_rollback\n Rails.logger.error \"Error during rollback\"\n Rails.logger.error e_rollback.message\n Rails.logger.error e_rollback.backtrace.inspect\n end\n raise e_orig\n end\n end",
"def read_hash_for_id(id)\n Sidekiq.redis do |conn|\n conn.hgetall id\n end\n end",
"def reload\n reset\n fetch\n end",
"def reload\n reset\n fetch\n end",
"def execute_restore_stripe(options={})\n new_vol_name = \"#{options[:lineage]}-#{ENV['EC2_INSTANCE_ID']}\"\n json_result = self.find_latest_ebs_backup(options[:lineage], options[:from_master], options[:timestamp])\n\n if json_result.nil? \n STDERR.puts \"No existing snapshot found for the specified nickname lineage. Aborting...\"\n exit(-1)\n end\n STDERR.puts \"Restoring.. #{json_result.inspect}\"\n options[:new_size_gb] = (options[:new_volume_size_in_gb] / json_result.size.to_f).ceil if options[:new_volume_size_in_gb]\n\n @disk.sync\n @disk.umount\n @disk.disable_volume\n\n self.execute_terminate_volumes if options[:force]\n\n json_result.each do |snapshot|\n \n# create volume from snap\n create_result = ( options[:new_size_gb] ? create_volume_from_snap_size_gb(snapshot[\"aws_id\"],new_vol_name,options[:new_size_gb] ) : create_volume_from_snap(snapshot[\"aws_id\"], new_vol_name ) )\n raise \"FATAL: error occured in create_volume_from_snap(#{snapshot['aws_id']}, #{new_vol_name})\" if create_result.nil?\n\n# attach volume to instance\n retry_seconds = 0\n while retry_seconds < 200\n begin \n attach_result = attach_volume(create_result['aws_id'], snapshot['device'])\n raise \"FATAL: error occured in attach_volume(#{create_result['aws_id']}, #{snapshot['device']}\" if attach_result.nil?\n break if attach_result\n rescue => e\n puts \"CAUGHT EXCEPTION in execute_restore_stripe. Device attachment. #{e}, Retrying #{retry_seconds} of 200 seconds\"\n retry_seconds += 30\n sleep 30 \n end\n end\n raise \"FATAL: error occured in attach_volume(#{create_result['aws_id']}, #{snapshot['device']}\" if attach_result.nil?\n end\n\n# wait for devices to attach, after completing ALL the api calls\n json_result.each { |s| wait_for_attachment(s['device']) }\n @disk.enable_volume\n raise \"FATAL: mount failed!\" unless @disk.mount\n @disk.write_fstab\n# TODO - grow the filesystem if a new size was given\n end",
"def reducer\n begin\n obj_tempQuery=ReducerQuerySetting.new()\n @@reducer_array = []\n @@error_selection_reducer = []\n @@error_selection_reducer = []\n @@error_updation_reducer = []\n # Create analytics table array\n table_detail=['reduce_campaigns_summaries','reduce_adv_carriers','reduce_adv_devicesproperties','reduce_adclients_summaries','reduce_pub_channels','reduce_pub_carriers','reduce_pub_urls','reduce_advertiser_summaries','reduce_publisher_summaries']\n for tblname in table_detail\n @@max_id=300000 if tblname=='reduce_pub_urls'\n @@max_id=GetMaxId::MAXID if tblname!='reduce_pub_urls'\n # Here we are going to establish a connection for transaction table to check the availablitiy of rows for the even hour table. \n @dbconn_selection = DBI.connect(\"DBI:MYSQL:#{@@analytics_read_db}:#{@@analytics_read_ip}\", AnalyticsDBReadServer::USERNAME, AnalyticsDBReadServer::PASSWORD)\n begin\n tx_illegal = \"false\"\n get_lock= acquire_lock(@dbconn_selection ,ACQUIRE_LOCK,REPORTS_SUMMARIZER)\n if(get_lock == 1)\n #Check if any records is available from shard database, check any records having the status as Table is locked for reading' or Transaction completed or Transaction completed for zero records. \n select_all=\"select * from reducer_transaction where tablename='#{tblname}' and (status='Transaction completed' or status = 'Table is locked for reading') order by id desc limit 1\"\n select_status_transaction =@dbconn_selection.select_all(select_all)\n curr_date=((Time.now)-86400).strftime(\"%Y-%m-%d\")\n created_at=Time.now.strftime(\"%Y-%m-%d %H:%M:%S\") \n if select_status_transaction.length == 0 # If no records are there for the whole day.\n select_max_id=\"select min(id) as min_id,max(id) as max_id from #{tblname} where delivery_date<='#{curr_date}'\"\n max_id_selection =@dbconn_selection.select_all(select_max_id)\n if max_id_selection.length == 0\n start_id=0\n end_id=0\n elsif (max_id_selection.length > 0) \n start_id=max_id_selection[0]['min_id'].to_i\n end_id=max_id_selection[0]['max_id'].to_i\n if ((end_id-start_id).to_i>@@max_id.to_i)\n end_id=start_id.to_i+@@max_id.to_i\n end\n end\n elsif(select_status_transaction.length > 0) \n check_updated_time=(Time.now-3600).strftime(\"%Y-%m-%d %H:%M:%S\") \n select_max_id=\"select id as max_id from #{tblname} where last_updated <='#{check_updated_time}' and delivery_date<='#{curr_date}' order by id desc limit 1\"\n max_id_selection =@dbconn_selection.select_all(select_max_id)\n start_id=select_status_transaction[0]['end_id'].to_i+1\n end_id=(max_id_selection==nil || max_id_selection[0]==nil) ? 0 : max_id_selection[0]['max_id'].to_i\n if ((end_id-start_id).to_i>@@max_id.to_i)\n end_id=start_id.to_i+@@max_id.to_i\n end\n end # end of select_status_transaction.length == 0\n else\n tx_illegal = \"true\"\n end # end of @get_lock_stat[0] == 1\n if (tx_illegal == \"true\" or (start_id==0 && end_id==0) or start_id>end_id)\n acquire_lock(@dbconn_selection ,RELEASE_LOCK,REPORTS_SUMMARIZER)\n else \n insert_transaction_query = \"insert into reducer_transaction(tablename,start_id, end_id, status,created_at) values('#{tblname}', '#{start_id}', '#{end_id}', 'Table is locked for reading','#{created_at}')\"\n #puts insert_transaction_query\n insert_status = @dbconn_selection.do(insert_transaction_query)\n acquire_lock(@dbconn_selection ,RELEASE_LOCK,REPORTS_SUMMARIZER)\n time_taken=Time.now# Fetch the current time 'seconds' \n select_records = \"false\"\n #Establish a connection to analytics databse to insert the reduced data.\n @dbconn_transaction = DBI.connect(\"DBI:MYSQL:#{@@analytics_write_db}:#{@@analytics_write_ip}\", AnalyticsDBWriteServer::USERNAME, AnalyticsDBWriteServer::PASSWORD)\n @dbconn_transaction.do(\"SET AUTOCOMMIT=0\")\n @dbconn_transaction.do(\"BEGIN\")\n begin\n select_stat=obj_tempQuery.selectReducerQuery(start_id,end_id,tblname)\n select_query = @dbconn_selection.select_all(select_stat)\n @dbconn_selection.disconnect if @dbconn_selection != nil \n select_records = \"true\"\n rescue Exception =>e \n puts \"Error in ClassName: AnalyticsDataReducer MethodName: reducer while selcting records ErrInfo:#{e.to_s}\" \n puts @@error_selection_reducer << \"<p style='color:#FF0000'> ERROR :: REDUCER method during Selection...<br />Project: ANALYTICS_REDUCER<br />Job: AnalyticsDataReducer<br />Table: #{tblname}<br />Start_id: #{start_id}<br />End_id: #{end_id}<br />Failure_Time:#{Time.now}<br />Exception is : #{e.to_s}<br /></p>\"\n end\n insert_records = \"true\"\n begin\n if ((select_query.length > 0) and (select_records == \"true\"))\n @mail_status_insert = \"true\"\n count=0\n global_count=0\n flag=nil\n requests=0\n url=''\n fill_rate=0\n pub_id=0\n client_id=0\n delivery_hour=0\n delivery_date=''\n url_flag=true\n for row in select_query # Insert the selected rows one by one into the REDUCER table resides in master database. \n break if insert_records == \"false\"\n begin\n insert_query=\"insert into campaigns_summaries(metrics,ad_client_type,impressions,clicks,amount_spent,gross_profit,zestadz_revenue,handset,handset_model,unique_visitors,advertiser_id,campaign_id,ad_id,continent_code,country_code,delivery_hour,delivery_date) VALUES ('#{row['metrics']}','#{row['ad_client_type']}',#{row['impression']},#{row['click']},#{row['amt_spent']},#{row['grs_profit']},#{row['zest_revenue']},\\\"#{row['handset']}\\\",\\\"#{row['handset_model']}\\\",'#{row['uniq_visitors']}',#{row['advertiser_id']},#{row['campaign_id']},#{row['ad_id']},\\\"#{row['continent_code']}\\\",\\\"#{row['country_code']}\\\",#{row['delivery_hour']},'#{row['delivery_date']}')\" if tblname.to_s=='reduce_campaigns_summaries'\n insert_query=\"insert into adv_carriers(owner,requests,advertiser_id,campaign_id,ad_id,delivery_hour,delivery_date) VALUES (\\\"#{(row['owner']!=nil && row['owner']!='') ? row['owner'].to_s.gsub(/([,])/,'') : row['owner']}\\\",#{row['request']},#{row['advertiser_id']},#{row['campaign_id']},#{row['ad_id']},#{row['delivery_hour']},'#{row['delivery_date']}')\" if tblname.to_s=='reduce_adv_carriers'\n insert_query=\"insert into adv_devicesproperties(user_agent,requests,handset,handset_model,advertiser_id,campaign_id,ad_id,delivery_hour,delivery_date) VALUES(\\\"#{row['user_agent']}\\\",#{row['request']},\\\"#{row['handset']}\\\",\\\"#{row['handset_model']}\\\",#{row['advertiser_id']},#{row['campaign_id']},#{row['ad_id']},#{row['delivery_hour']},'#{row['delivery_date']}')\" if tblname.to_s=='reduce_adv_devicesproperties'\n insert_query=\"insert into adclients_summaries(ad_client_type,ad_type,impressions,clicks,fill_rate,requests_unique_visitors,revenue,adclient_name,handset,handset_model,user_agent,pub_id,client_id,continent_code,country_code,delivery_hour,delivery_date) VALUES ('#{row['ad_client_type']}','#{row['ad_type']}',#{row['impression']},#{row['click']},#{row['fl_rate']},#{row['sum_visitor']},#{row['sum_revenue']},\\\"#{row['adclient_name']}\\\",\\\"#{row['handset']}\\\",\\\"#{row['handset_model']}\\\",\\\"#{row['user_agent']}\\\",#{row['pub_id']},#{row['client_id']},\\\"#{row['continent_code']}\\\",\\\"#{row['country_code']}\\\",#{row['delivery_hour']},'#{row['delivery_date']}')\" if tblname.to_s=='reduce_adclients_summaries'\n insert_query=\"insert into pub_channels(channel,requests,fill_rate,pub_id,client_id,ad_client_type,delivery_hour,delivery_date) VALUES(\\\"#{row['channel']}\\\",#{row['request']},#{row['fl_rate']},#{row['pub_id']},#{row['client_id']},'#{row['ad_client_type']}',#{row['delivery_hour']},'#{row['delivery_date']}')\" if tblname.to_s=='reduce_pub_channels'\n insert_query=\"insert into pub_carriers(owner,requests,fill_rate,pub_id,client_id,ad_client_type,delivery_hour,delivery_date) VALUES(\\\"#{(row['owner']!=nil && row['owner']!='') ? row['owner'].to_s.gsub(/([,])/,'') : row['owner']}\\\",#{row['request']},#{row['fl_rate']},#{row['pub_id']},#{row['client_id']},'#{row['ad_client_type']}',#{row['delivery_hour']},'#{row['delivery_date']}')\" if tblname.to_s=='reduce_pub_carriers'\n if tblname.to_s=='reduce_pub_urls'\n global_count+=1\n if flag!=nil and flag!=row['client_id'].to_i\n if count>5\n insert_query=\"insert into pub_urls(url,requests,fill_rate,pub_id,client_id,delivery_hour,delivery_date) VALUES (\\\"#{url}\\\",#{requests},#{fill_rate},#{pub_id},#{client_id},#{delivery_hour},'#{delivery_date}')\"\n insert_stat = @dbconn_transaction.do(insert_query)\n end\n count=0\n requests=0\n fill_rate=0\n url=''\n pub_id=0\n client_id=0\n delivery_hour=0\n delivery_date='' \n end\n flag=row['client_id'].to_i\n count+=1\n if (count.to_i<=5)\n insert_query=\"insert into pub_urls(url,requests,fill_rate,pub_id,client_id,delivery_hour,delivery_date) VALUES (\\\"#{row['url']}\\\",#{row['request']},#{row['fl_rate']},#{row['pub_id']},#{row['client_id']},#{row['delivery_hour']},'#{row['delivery_date']}')\"\n url_flag=true\n else\n url_flag=false\n requests+=row['request'].to_i\n fill_rate+=row['fl_rate'].to_i\n url='Others'\n pub_id=row['pub_id']\n client_id=row['client_id']\n delivery_hour=row['delivery_hour']\n delivery_date=row['delivery_date']\n if(select_query.length.to_i==global_count.to_i)\n url_flag=true\n insert_query=\"insert into pub_urls(url,requests,fill_rate,pub_id,client_id,delivery_hour,delivery_date) VALUES (\\\"#{url}\\\",#{requests},#{fill_rate},#{pub_id},#{client_id},#{delivery_hour},'#{delivery_date}')\"\n end\n end\n end\n insert_query=\"insert into advertiser_summaries(metrics,ad_client_type,impressions,clicks,amount_spent,gross_profit,zestadz_revenue,unique_visitors,advertiser_id,campaign_id,ad_id,delivery_hour,delivery_date) VALUES ('#{row['metrics']}','#{row['ad_client_type']}',#{row['impression']},#{row['click']},#{row['amt_spent']},#{row['grs_profit']},#{row['zest_revenue']},'#{row['uniq_visitors']}',#{row['advertiser_id']},#{row['campaign_id']},#{row['ad_id']},#{row['delivery_hour']},'#{row['delivery_date']}')\" if tblname.to_s=='reduce_advertiser_summaries'\n insert_query=\"insert into publisher_summaries(ad_client_type,ad_type,impressions,clicks,fill_rate,requests_unique_visitors,revenue,pub_id,client_id,delivery_hour,delivery_date) VALUES ('#{row['ad_client_type']}','#{row['ad_type']}',#{row['impression']},#{row['click']},#{row['fl_rate']},#{row['sum_visitor']},#{row['sum_revenue']},#{row['pub_id']},#{row['client_id']},#{row['delivery_hour']},'#{row['delivery_date']}')\" if tblname.to_s=='reduce_publisher_summaries'\n insert_stat = @dbconn_transaction.do(insert_query) if url_flag==true\n rescue Exception =>e \n insert_records = \"false\"\n puts \"Error in ClassName: AnalyticsDataReducer MethodName: reducer while inserting records ErrInfo:#{e.to_s}\" \n if @mail_status_insert == \"true\" \n @@error_selection_reducer << \"<p style='color:#FF0000'> ERROR :: REDUCER method during Insertion...<br />Project: ANALYTICS_REDUCER <br />Job: AnalyticsDataReducer <br />Table: #{tblname}<br />Start_id: #{start_id}<br />End_id: #{end_id}<br />Failure_Time:#{Time.now}<br />Exception is : #{e.to_s}<br /></p>\"\n @mail_status_insert = \"false\"\n end # end of @mail_status_insert == \"true\"\n end\n end # end of row in select_query\n end # end of (select_query.length > 0) and (select_records == \"true\")\n rescue Exception => e\n puts \"Error in ClassName: AnalyticsDataReducer MethodName: reducer while checking length ErrInfo:#{e.to_s}\" \n select_records = \"false\"\n insert_records = \"false\"\n end # end of begin\n fetch_new_time=(Time.now) # Fetch the current time again\n new_time_taken = fetch_new_time-time_taken # Calculating the difference between two 'seconds'\n if insert_records == \"true\" # if records are there in ads deliveries table and it has been inserted into REDUCER\n status_val =\"Transaction completed\" # set the transaction status as \"Transaction completed\"\n end # end of insert_records == \"true\"\n # Update the transaction status based on records are there in ads deliveries table are not\n @dbconn_selection = DBI.connect(\"DBI:MYSQL:#{@@analytics_read_db}:#{@@analytics_read_ip}\", AnalyticsDBReadServer::USERNAME, AnalyticsDBReadServer::PASSWORD)\n if (insert_records == \"true\")\n begin\n update_transaction_status = \"update reducer_transaction set status = '#{status_val}', time_taken = #{new_time_taken.to_i} where tablename = '#{tblname}' and start_id='#{start_id}' and end_id='#{end_id}' and status = 'Table is locked for reading' and created_at = '#{created_at}'\"\n update_status = @dbconn_selection.prepare(update_transaction_status)\n update_status.execute\n insert_records = \"true\"\n # Store the updated records ip address, database name, table name, start datetime, end datetime and status in @@reducer_array\n @@reducer_array<< \"<p style='color:#0000FF'>Project: ANALYTICS_REDUCER...<br />Job: AnalyticsDataReducer<br />Table: #{tblname}<br />Start_id: #{start_id}<br />End_id: #{end_id}<br />Status: #{status_val}<br /></p>\"\n rescue Exception => e\n puts \"Error in ClassName: AnalyticsDataReducer MethodName: reducer while updating ErrInfo:#{e.to_s}\" \n @@error_updation_reducer << \"<p style='color:#FF0000'> ERROR :: REDUCER method during Updation...<br />Project: ANALYTICS_REDUCER<br />Job: AnalyticsDataReducer<br />Table: #{tblname}<br />Start_id: #{start_id}<br />End_id: #{end_id}<br />Failure_Time:#{Time.now}<br />Exception is : #{e.to_s}<br /></p>\"\n insert_records = \"false\"\n end\n end #end of (zero_record == \"true\") or (records == \"true\")\n if (insert_records == \"false\")\n @dbconn_transaction.do(\"ROLLBACK\")\n elsif (insert_records == \"true\")\n @dbconn_transaction.do(\"COMMIT\") \n end # end of (records == \"false\")\n @dbconn_transaction.disconnect if @dbconn_transaction != nil\n end # end of tx_illegal == \"true\" or start_date > end_date or start_date > curr_datetime \n rescue Exception =>e \n @dbconn_transaction.disconnect if @dbconn_transaction != nil\n puts \"Error in ClassName: AnalyticsDataReducer MethodName: reducer while iterating ErrInfo:#{e.to_s}\" \n select_records = \"false\"\n acquire_lock(@dbconn_selection ,RELEASE_LOCK,REPORTS_SUMMARIZER)\n end # end of begin\n @dbconn_selection.disconnect if @dbconn_selection != nil\n end # end of tblname in table_detail\n rescue Exception =>e \n puts \"Error in ClassName: AnalyticsDataReducer MethodName: reducer ErrInfo:#{e.to_s}\" \n end # end of begin \n end"
] |
[
"0.56816435",
"0.5641253",
"0.5445054",
"0.53529847",
"0.5347884",
"0.5346648",
"0.52747536",
"0.52167577",
"0.5178319",
"0.51277167",
"0.50772816",
"0.496733",
"0.4929243",
"0.49261323",
"0.49189678",
"0.49168858",
"0.4915393",
"0.49079368",
"0.48955694",
"0.4876947",
"0.4864297",
"0.48586056",
"0.48460793",
"0.48012537",
"0.47800323",
"0.47702256",
"0.4760749",
"0.47469807",
"0.47414696",
"0.4731109",
"0.47274625",
"0.47226587",
"0.47216094",
"0.4715054",
"0.4713052",
"0.4712571",
"0.47079825",
"0.47078463",
"0.46979722",
"0.46835485",
"0.46751502",
"0.46684116",
"0.46480957",
"0.46459377",
"0.46326554",
"0.46157593",
"0.46083593",
"0.4607757",
"0.4603177",
"0.4601457",
"0.4598419",
"0.45912775",
"0.45912775",
"0.45905694",
"0.45869136",
"0.45849848",
"0.45813364",
"0.4579161",
"0.45763597",
"0.45747456",
"0.45703655",
"0.45665923",
"0.45637167",
"0.45617166",
"0.45546857",
"0.45460597",
"0.45400938",
"0.4539788",
"0.4539667",
"0.4537923",
"0.45341918",
"0.4531468",
"0.45312536",
"0.452792",
"0.45162907",
"0.45156908",
"0.45152816",
"0.45151648",
"0.4510241",
"0.4506014",
"0.4499508",
"0.44993323",
"0.44931313",
"0.44913304",
"0.44871673",
"0.44840956",
"0.4483325",
"0.44825062",
"0.44803208",
"0.44777578",
"0.44763386",
"0.44725558",
"0.4470067",
"0.44686052",
"0.4454935",
"0.44547832",
"0.44528574",
"0.44528574",
"0.4452651",
"0.44477558"
] |
0.5368666
|
3
|
Execute a multi transaction to get the burst and the context from Redis in a single call
|
def pull_burst(burst_p, burst_context_p)
cx_data.multi do
burst_p.call
burst_context_p.call
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def enqueue\n redis.multi do\n enqueue_non_atomically\n end\n end",
"def transaction(&block); end",
"def runMbxTransaction(hpk, op = '')\n limit = Rails.configuration.x.relay.mailbox_retry\n count, complete, res = 0, false, nil\n while count < limit and not complete\n rds.watch(\"mbx_#{hpk}\") do\n rds.multi\n yield\n res = rds.exec\n complete = ! res.nil?\n unless complete\n count += 1\n sleep 0.1 + rand() * 0.1 # let other mbx writes complete\n logger.warn \"#{INFO_NEG} mailbox #{dumpHex hpk}, retry #{op}/#{count}\"\n end\n end\n end\n if count >= limit and not complete\n raise TransactionError.new(self,hpk),\n \"#{op} in mailbox #{dumpHex hpk} transaction failure\"\n end\n return complete ? res : nil\n end",
"def execute\n Trade.transaction do\n execute_without_transaction!\n end\n end",
"def perform\n # Since `is_txn_confirmations_gte_10` is the only field that may change, we can limit our query\n # to use that as a starting block\n earliest_unconfirmed_block_number = StakedCofiTransaction\n .where(is_txn_confirmations_gte_10: false)\n .order(txn_block_number: :asc)\n .select(:txn_block_number)\n .first\n &.txn_block_number\n latest_block_number = StakedCofiTransaction\n .order(txn_block_number: :desc)\n .select(:txn_block_number)\n .first\n &.txn_block_number\n start_block = earliest_unconfirmed_block_number || latest_block_number || 0\n\n transaction_items = fetch_token_transactions(start_block: start_block)\n puts \"Found #{transaction_items.length} transactions\"\n\n ActiveRecord::Base.transaction do\n transaction_items.each do |transaction_item|\n transaction = StakedCofiTransaction.find_by(txn_hash: transaction_item['hash'])\n # Check if we even need to update at all\n if transaction && transaction.is_txn_confirmations_gte_10\n puts \"Already saved transaction #{transaction_item['hash']}\"\n next\n end\n\n transaction ||= StakedCofiTransaction.new(\n txn_block_number: transaction_item['blockNumber'],\n txn_timestamp: DateTime.strptime(transaction_item['timeStamp'], '%s'),\n txn_hash: transaction_item['hash'],\n txn_block_hash: transaction_item['blockHash'],\n txn_from: transaction_item['from'],\n txn_to: transaction_item['to'],\n txn_value: transaction_item['value'],\n txn_token_decimal: transaction_item['tokenDecimal'].to_i,\n )\n transaction.is_txn_confirmations_gte_10 = (transaction_item['confirmations'].to_i >= 10)\n\n if transaction.changed?\n transaction.save!\n puts \"Created/Updated transaction #{transaction_item['hash']}\"\n end\n end\n end\n\n associate_transactions_service = AssociateUnassignedStakedCofiTransactionsService.call\n puts \"Associated #{associate_transactions_service.staked_cofi_transactions_updated.length} unassigned staked COFI transactions\"\n end",
"def transaction(options = {}, &block)\n @klass.connection.run_queries_on_shard(@shard) do\n @klass = @klass.connection.transaction(options, &block)\n end\n end",
"def transaction(&block)\n block.call\n end",
"def transaction\n @pool.hold do |conn|\n @transactions ||= []\n if @transactions.include? Thread.current\n return yield(conn)\n end\n conn.execute(SQL_BEGIN)\n begin\n @transactions << Thread.current\n result = yield(conn)\n conn.execute(SQL_COMMIT)\n result\n rescue => e\n conn.execute(SQL_ROLLBACK)\n raise e unless Error::Rollback === e\n ensure\n @transactions.delete(Thread.current)\n end\n end\n end",
"def transaction(&block)\n yield\n end",
"def transaction(&block)\n yield\n end",
"def transaction(&block)\n db\n persister\n\n result = nil\n start_time = Time.now\n begin\n db.transaction(:rollback => :reraise, :isolation => :repeatable,\n :retry_on => @retry_on_error, :num_retries => 3) do\n result = yield block\n end\n total = Time.now.to_ms - start_time.to_ms\n debug \"Transaction committed (#{total} ms)\"\n result\n rescue StandardError => e\n total = Time.now.to_ms - start_time.to_ms\n warn \"Transaction failed (#{total} ms)\"\n raise e\n ensure\n GC.start\n end\n end",
"def transaction(&block)\n @@semaphore.synchronize{\n block.call\n }\n end",
"def transaction\n use do |connection|\n connection.transaction do |conn|\n begin\n yield conn\n rescue Rollback\n return\n end\n end\n end\n end",
"def transaction\n raise Mysql::Error, 'Not Connected' if @my.nil?\n\n if block_given?\n begin\n @my.query('START TRANSACTION WITH CONSISTENT SNAPSHOT')\n yield # Start executing the query black.\n @my.query('COMMIT')\n rescue Mysql::Error => e\n @my.query('ROLLBACK')\n raise e\n end\n end\n end",
"def each(&block) \n reset\n \n while transaction = next_transaction\n yield transaction\n end\n end",
"def transaction(&blk)\n tap(&blk)\n end",
"def transactions(options = {}, &block)\n blocks(options) do |block, block_num|\n if block.nil?\n warn \"Batch missing block_num: #{block_num}, retrying ...\"\n \n block = block_api.get_block(block_num: block_num) do |result|\n result.block\n end\n end\n \n block.transactions.each_with_index do |transaction, index|\n trx_id = block.transaction_ids[index]\n \n yield transaction, trx_id, block_num\n end\n end\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 transaction\n raise Mysql2::Error, 2002 if @my.nil?\n\n if block_given?\n begin\n @my.query('START TRANSACTION WITH CONSISTENT SNAPSHOT')\n yield # Start executing the query black.\n @my.query('COMMIT')\n rescue Mysql2::Error => e\n @my.query('ROLLBACK')\n raise e\n end\n end\n end",
"def run_transaction(conn, op)\n retries = 0\n max_retries = 3\n while true\n retries += 1\n if retries == max_retries\n err = \"Transaction did not succeed after #{retries} retries\"\n raise err\n end\n\n begin\n op.call(conn)\n\n # If we reach this point, we were able to commit, so we break\n # from the retry loop.\n break\n\n rescue PG::TRSerializationFailure\n # This is a retry error, so we roll back the current\n # transaction and sleep for a bit before retrying. The\n # sleep time increases for each failed transaction.\n # conn.rollback\n puts \"EXECUTE SERIALIZATION_FAILURE BRANCH\"\n sleep_secs = (2**retries).floor\n puts \"Sleeping for #{sleep_secs} seconds\"\n sleep(sleep_secs)\n next\n end\n end\nend",
"def save\n # Update the updated_at timestamp.\n # If we had servers in multiple time zones, we'd want\n # to use utc in the next line. This might be important\n # if we go cloud in multiple availability zones, this\n # way time is consistent across zones.\n # self.updated_at = Time.now.utc\n self.updated_at = Time.now\n\n # Flag that will determine if this is the first time we save.\n first_save = false\n # if this is our first time saving this transaction\n if(@state == :new)\n @state = :started\n first_save = true\n # if new, grab a numeric id and assign it to this object\n if(@numeric_id == nil)\n @numeric_id = Store.db.incr(\"#{Transaction.db_global_prefix}:numeric_id_count\")\n end\n end\n\n # Now lets convert the transaction object to a json. Note:\n # We have to retrieve this here, incase we ever need values here\n # from the Store. If we do it inside the multi or pipelined\n # we won't have those values availble when building the json\n # and all we'll have is a Redis::Future object. By doing\n # the following to_json call here, we would've retrieved the data\n # needed before the save, properly.\n json = self.to_json\n # do a pipeline command, executing all commands in an atomic fashion.\n # inform the pipelined save if this is the first time we're saving the\n # transaction, so that proper jobs may be enqueued.\n pipelined_save(json, first_save)\n # puts caller\n if Config.display_hints\n debug \"#{\"Hint\".green}: View the transaction data in Redis using: GET #{db_id}\\n\"+\n \"#{\"Hint\".green}: View the last #{LAST_TRANSACTIONS_TO_KEEP_IN_CACHE} transactions using: \"+\n \"LRANGE #{db_list} 0 -1\\n\"+\n \"#{\"Hint\".green}: View the items in pending queue using: LRANGE #{queue_pending} 0 -1\\n\"+\n \"#{\"Hint\".green}: View the last item in the pending queue using: LINDEX #{queue_pending} 0\"\n end\n return true\n end",
"def transaction\n @pool.hold do |conn|\n @transactions ||= []\n if @transactions.include? Thread.current\n return yield(conn)\n end\n log_info(SQL_BEGIN)\n conn.execute(SQL_BEGIN)\n begin\n @transactions << Thread.current\n yield(conn)\n rescue Exception => e\n log_info(SQL_ROLLBACK)\n conn.execute(SQL_ROLLBACK)\n raise e unless Error::Rollback === e\n ensure\n unless e\n log_info(SQL_COMMIT)\n conn.execute(SQL_COMMIT)\n end\n @transactions.delete(Thread.current)\n end\n end\n end",
"def run_01props_put_for_txn_batch\n do_run_00warmup(20, 0.5, 10)\n do_run_01props_put(\n :count => [8],\n :index => [true],\n :type => [\"integer\"],\n :txn => [true, false],\n :batch => [true, false],\n :repeat => [1,4,8,32],\n :thread_count => 10\n )\nend",
"def transaction\n start_transaction!\n\n result = yield\n\n query 'COMMIT'\n\n result\n rescue\n query 'ROLLBACK'\n raise\n\n ensure\n end_transaction!\n end",
"def transaction\n start_transaction\n\n yield\n ensure\n end_transaction if transaction_started?\n end",
"def begin\n db.transaction do\n yield\n end\n end",
"def transaction\n transaction_not_started = true\n while transaction_not_started do\n begin\n @lock.synchronize do\n @cache.begin_transaction\n # If we get to this point, the transaction was successfully\n # started. We can exit the loop.\n transaction_not_started = false\n end\n rescue TransactionInOtherThread\n # sleep up to 50ms\n sleep(rand(50) / 1000.0)\n end\n end\n\n begin\n yield if block_given?\n rescue => e\n @lock.synchronize { @cache.abort_transaction }\n raise e\n end\n @lock.synchronize { @cache.end_transaction }\n end",
"def transaction( &block )\n connect do | conn |\n conn.transaction do | conn |\n yield SqlRunner.new(SingleConnectionPool.new( conn ))\n end\n end\n end",
"def use_transactions; end",
"def use_transactions; end",
"def get_burst(spark, _options={})\n # get the context parameters\n context_h = spark[:context]\n\n burst_p = -> { cx_data.hget hsdq_key(spark), burst_key(spark) }\n if response?(spark) && context_h\n # save previous_sender in thread_store for later reply\n sent_to context_h[:previous_sender]\n # set the proc for multi redis to pull the initial request\n burst_context_p = -> { cx_data.hget hsdq_key(spark), \"request_#{context_h[:spark_uid]}\" }\n # exec the redis multi\n burst_j, burst_context_j = pull_burst(burst_p, burst_context_p)\n else\n burst_j, burst_context_j = pull_burst_only burst_p\n end\n\n burst = burst_j ? (JSON.parse burst_j, {symbolize_names: true}) : {}\n burst_context = burst_context_j ? (JSON.parse burst_context_j, {symbolize_names: true}) : {}\n\n [burst, burst_context]\n end",
"def transaction(options = {}, &block)\n run_on_shard { @klass = klass.transaction(options, &block) }\n end",
"def transactions\n read_all_transactions\n transaction_cache\n end",
"def batch_transactions(options = {})\n response = JSON.parse(@client.get(\"items/#{send(:id)}/batch_transactions\", options).body)\n batch_transactions = response.key?('batch_transactions') ? response['batch_transactions'] : []\n batch_transactions.map { |attributes| Promisepay::BatchTransaction.new(@client, attributes) }\n end",
"def transaction\n raise ArgumentError, 'No block was given' unless block_given?\n\n with_client do |client|\n begin\n client.query('BEGIN')\n yield client\n client.query('COMMIT')\n rescue StandardError => e\n client.query('ROLLBACK')\n raise e\n end\n end\n end",
"def transaction(start_db_transaction=true)\n yield\n end",
"def transaction(&block)\n @cache.transaction do\n yield(@cache)\n end\n end",
"def batch\n mon_synchronize do\n begin\n original, @client = @client, SSDB::Batch.new\n yield(self)\n @client.values = original.perform(@client)\n ensure\n @client = original\n end\n end\n end",
"def batch\n mon_synchronize do\n begin\n original, @client = @client, SSDB::Batch.new\n yield(self)\n @client.values = original.perform(@client)\n ensure\n @client = original\n end\n end\n end",
"def transaction; end",
"def transaction; end",
"def transaction; end",
"def multi_exec\n self.multi.errback do |r|\n # This usually happens in the case of a programming error.\n # Sometimes it is called when the connection breaks.\n self.close_connection\n end\n error = nil\n begin\n yield redis_multi = Multi.new(self)\n rescue Exception => e\n error = e\n end\n redis_exec = self.exec\n if error\n EM.next_tick do\n close_connection\n redis_exec.fail error \n end\n end\n redis_exec.callback do |results|\n # Normalized results include syntax errors and original references.\n # Command callbacks are meant to run before exec callbacks.\n if results == nil\n redis_exec.succeed nil\n else\n normalized_results = []\n redis_multi.each do |command|\n if Exception === command\n normalized_results << command\n else\n result = results.shift\n normalized_results << result\n if Exception === result\n command.fail result\n else\n command.succeed result\n end\n end\n end\n redis_exec.succeed normalized_results\n end\n end\n end",
"def perform_atomic_update(&block)\n Edition.connection.execute \"set transaction isolation level serializable\"\n Edition.connection.transaction do\n yield\n end\n end",
"def transaction\n start\n yield self\n rescue Object => ex\n rollback\n debug \"#{ex.class}: #{ex.message}\"\n ex.backtrace.each { |line| debug line }\n else\n commit\n end",
"def _call_in_transaction\n aliquot_updater = UpdateAliquotsHandler.new(db, bus, log, metadata, s2_resource, settings)\n\n begin \n s2_resource[:plates].each do |plate|\n aliquot_updater.send(:update_aliquots, plate) if plate[:plate].size == SupportedPlateSize\n end\n\n db.transaction(:savepoint => true) do\n begin\n date = s2_resource[:plates].first[:date]\n add_asset_links(s2_resource[:transfer_map], date)\n set_transfer_requests(s2_resource[:transfer_map], date)\n rescue PlateNotFoundInSequencescape => e\n log.info(\"The asset_link and the transfer request has not been set: #{e.message}\")\n end\n end\n rescue Sequel::Rollback, PlateNotFoundInSequencescape, UnknownSample => e\n metadata.reject(:requeue => true)\n log.info(\"Error updating plate aliquots in Sequencescape: #{e}\")\n raise Sequel::Rollback\n else\n metadata.ack\n log.info(\"Plate transfer message processed and acknowledged\")\n end\n end",
"def transaction(&block)\n yield\n commit\n end",
"def run_in_transaction isolation\n if isolation\n Base.transaction isolation: isolation do\n yield\n end\n else\n yield\n end\n end",
"def run_in_transaction isolation\n if isolation\n Base.transaction isolation: isolation do\n yield\n end\n else\n yield\n end\n end",
"def transaction\n begin\n if block_given?\n begin_db_transaction\n result = yield\n commit_db_transaction\n result\n end\n rescue Exception => database_transaction_rollback\n rollback_db_transaction\n raise\n end\n end",
"def transaction(opts={:auto_enable => false})\n @transaction_level||=0\n @transaction_level+=1\n session do\n raise_if_transaction_running\n @transaction ||= true\n raise Error.cannot_obtain_transaction_lock if not lock_transaction\n begin\n yield\n # get_transaction in case cfgsave or cfgenable was run in transaction block\n # if there is no transaction we do not need to run it\n # if there is transaction but opend by someone else then t\n cfg_save if @transaction_level==1 && get_transaction\n rescue => e\n abort_transaction\n raise e\n end \n end\n ensure\n @transaction_level-=1\n @transaction = nil if @transaction_level==0\n end",
"def transaction(&block)\n raise InvalidDbError if @stale\n\n return transaction_in_staging(true, &block) if self.staging?\n\n begin\n transaction_in_staging(false, &block)\n ensure\n self.unstage\n end\n end",
"def execute(async)\n f = Fiber.current\n begin\n conn = acquire(f)\n conn.acquired_for_connection_pool += 1\n yield conn\n ensure\n conn.acquired_for_connection_pool -= 1\n conn.run_postponed_queries if conn.acquired_for_connection_pool == 0\n release(f) if !async && conn.acquired_for_connection_pool == 0\n end\n end",
"def begin_db_transaction() end",
"def begin_db_transaction() end",
"def checked_transaction(opts=OPTS)\n use_transaction?(opts) ? db.transaction({:server=>this_server}.merge!(opts)){yield} : yield\n end",
"def checked_transaction(opts=OPTS)\n use_transaction?(opts) ? db.transaction({:server=>this_server}.merge!(opts)){yield} : yield\n end",
"def within_transaction; end",
"def within_transaction; end",
"def transaction(mode = :deferred, &block)\n @db.transaction(mode, &block)\n end",
"def begin_db_transaction\n @transaction = @connection.transaction('READ COMMITTED')\n end",
"def flush\n return nil if @queries.empty?\n \n @args[:db].transaction do\n @queries.shift(1000).each do |str|\n STDOUT.print \"Executing via buffer: #{str}\\n\" if @debug\n @args[:db].q(str)\n end\n end\n \n return nil\n end",
"def perform( &block )\r\n @transaction_strategy.perform( &block )\r\n end",
"def with_transaction\n ActiveRecord::Base.transaction { yield }\n end",
"def transaction(key, settings = {}, &block)\n t = init_transaction(key, settings)\n block.call\n t.finish\n rescue\n t.rollback\n raise\n ensure\n t.clean_publisher\n end",
"def pipelined_save(json, first_save=false)\n if Config.display_hints\n debug \"Store Pipeline: Attempting to save transaction in Store under key \\\"#{db_id}\\\"\"\n debug \"Store Pipeline: Attempting to save into recent transactions list \\\"#{db_list}\\\"\"\n debug \"Store Pipeline: Attempting to save into \\\"#{queue_pending}\\\" queue\"\n end\n\n # This is where we do an atomic save on the database. We grab a\n # connection from the pool, and use it. If a connection is unavailable\n # the code (Fiber) will be on hold, and will magically resume properly\n # thanks to our use of EM-Synchrony.\n Store.db.pipelined do |db_connection|\n # don't worry about an error here, if the db isn't available\n # it'll raise an exception that will be caught by the system\n\n # Update the transaction object in the database by storing the JSON\n # in the key under this ID in the database store.\n db_connection.set(db_id, json)\n\n # If TTL is not nil, update the Time to Live everytime a transaction\n # is saved/updated\n if(EXPIRATION > 0)\n db_connection.expire(db_id, EXPIRATION)\n end\n\n # if this is the first time this transaction is saved:\n if first_save\n # Add it to a list of the last couple of items\n db_connection.lpush(db_list, db_cache_info)\n # trim the items to the maximum allowed, determined by this constant:\n db_connection.ltrim(db_list, 0, LAST_TRANSACTIONS_TO_KEEP_IN_CACHE)\n\n # Add it to our GMQ pending queue, to be grabbed by our workers\n # Enqueue a email notification job\n db_connection.rpush(queue_pending, job_notification_data)\n # Enqueue a rapsheet validation job\n # db_connection.rpush(queue_pending, job_rapsheet_validation_data)\n\n # We can't use any method that uses Store.db here\n # because that would cause us to checkout a db connection from the\n # pool for each of those commands; the pipelined commands need to\n # run on the same connection as the commands in the pipeline,\n # so we will not use the Store.add_pending method. For any\n # of our own method that requires access to the db, we will\n # recycle the current db_connection. In this case, the add_pending\n # LibraryHelper method supports receiving an existing db connection\n # which makes it safe for the underlying classes to perform\n # database requests, appending them to this pipeline block.\n add_pending(db_connection)\n end # end of first_save for new transactions\n end\n debug \"Saved!\".bold.green\n end",
"def processTransaction\t\t\n\t\t# retrieve the requests with data in form\n\t\ttransaction_request = @request[:transaction] \t\t\n\t\t# store transaction num, we'll use it later to see if there was a transaction or not\n\t\ttransaction_num = transaction_request[:transactionNum]\n\t\t# fetch the operations\n\t\toperations = transaction_request[:operations]\n\t\t\n\t\t# response list\n\t\tres_list = Array.new\t\t\t\n\t\t# transaction progress\n\t\t@model.transaction do \t\t\t\t\t\t\t\t\t\n\t\t\tbegin\t\t\t\t\n\t\t\t\toperations.each do |op|\t \n\t\t\t\t\t# parase advanced criterias, if any\n\t\t\t\t\tadvanced_criteria = parse_advanced_criterias(op)\n\t\t\t\t\t \n\t\t\t\t\treq = DSRequest.new(op, @model) \t\t\t\t\t\n\t\t\t\t\tunless advanced_criteria == nil\n\t\t\t\t\t\treq.advancedCriteria = advanced_criteria\n\t\t\t\t\tend \n\t\t\t\t\t# execute the request and get the response\n\t\t\t\t\tres = req.execute\t\t\t\t\t\t\t \n\t\t\t\t\tif res == nil\n\t\t\t\t\t\tres = DSResponse.new\n\t\t\t\t\t\tres.status = -1\n\t\t\t\t\tend\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t# store the response for later\n\t\t\t\t\tres_list << res\t \t\t\t\t\t\n\t\t\t\tend\t\t\t\n\t\t\trescue ActiveRecord::RecordInvalid\n\t\t\t\t# if it occurs exception\n\t\t\t\traise ActiveRecord::Rollback\n\t\t\tend\n\t\tend\n\t\t\n\t\t# if we have only one object, send directly the DSResponse\n\t\tif transaction_num == -1\n\t\t\tresponse = DSResponse.new\n\t\t\tresponse.data = res_list[0].data\n\t\t\tresponse.startRow = res_list[0].startRow\n\t\t\tresponse.endRow = res_list[0].endRow\n\t\t\tresponse.totalRow = res_list[0].totalRow\n\t\t\tresponse.status = res_list[0].status\n\t\t\t\n\t\t\treturn response\n\t\tend\n\t\t\n\t\t# iterate over the responses and create a instance of an anonymous class which mimics the required json\n\t\tresponses = Array.new\n\t\t\n\t\tres_list.each do | response |\t\t\t\n\t\t\tres = DSResponse.new\n\t\t\tres.data = response.data\t\t\t\n\t\t\tres.startRow = response.startRow\n\t\t\tres.endRow = response.endRow\n\t\t\tres.totalRow = response.totalRow\n\t\t\tres.status = response.status\t\t\t\n\t\t\tresponses << res\n\t\tend \n\t\treturn responses\n\tend",
"def transaction(&block)\n self['AutoCommit'] = false\n self.do_transaction(&block)\n self['AutoCommit'] = true\n end",
"def call\n %i[ethaud btcaud].map do |currency|\n Thread.new do\n send(currency)\n end\n end.map(&:value).reduce(&:merge)\n end",
"def transaction\n @database.transaction { yield self }\n end",
"def scaffold_transaction(&block)\n transaction(&block)\n end",
"def perform(*args)\n\n begin\n logger.info \"************ STARTING refresh coins ******************************************\"\n\n # # grab the main assets from kraken\n assets_json = get_coin_data('https://api.kraken.com/0/public/Assets', '')\n assets_keys = assets_json.keys\n\n\n # grab the asset pairs from kraken\n asset_pairs_json = get_coin_data('https://api.kraken.com/0/public/AssetPairs', '')\n asset_pairs_keys = asset_pairs_json.keys\n\n # grab the market cap and full name from a different source\n market_response = RestClient.get 'https://api.coinmarketcap.com/v1/ticker'\n market_json = JSON.parse(market_response)\n\n\n # loop thru the asset pairs that kraken gives us\n asset_pairs_keys.each do |key|\n\n # wrap every coin in a try catch - if it fails go to the next coin\n begin\n\n asset = {\"pair\" => key, \"base\" => asset_pairs_json[key]['base'], \n \"quote\" => asset_pairs_json[key]['quote']}\n\n # we only want pairs with a USD currency\n # using \"quote\" of ZUSD check to say it is a USD pair - is this a valid check??\n # could alse use a string parse of the last 3 chars and\n # see if it matches USD...\n # ALSO ignore the .d pairs - WHAT ARE THESE???\n # they seem to be duplicates of an existing pair without a .d at the end...\n if (asset['pair'].exclude? \".d\") && (asset['quote'] == \"ZUSD\") \n # && (asset['pair'].exclude? \"X\") #this line is for testing to cut down on our results\n\n # add the alternative name of the base using the asset listing we got\n # matching the asset pair to the asset using the asset key which is the name\n assets_keys.each do |key|\n if asset['base'] == key\n asset['altbase'] = assets_json[key]['altname']\n asset['display_decimals'] = assets_json[key]['display_decimals']\n end\n end\n\n # special case for bitcoin - kraken uses xbt, but everywhere else uses btc, \n # so set that here\n if (asset['altbase'] == 'XBT') \n asset['altbase'] = 'BTC'\n end\n\n # look up the assets compliance in the erc20 table\n erc20 = Erc20.where(symbol: asset['altbase']).first\n if (erc20)\n asset['erc20'] = erc20['flag']\n else\n asset['erc20'] = 'no data' \n end\n\n # lookup the full name of the coin using the list from the ticker - \n # matching based on the altBaseName (since kraken uses its own symbols...)\n market_json.each do |market|\n if market['symbol'] == asset['altbase']\n asset['name'] = market['name']\n asset['marketcap'] = market['market_cap_usd']\n end\n end\n\n\n # save the asset to the db model\n asset_db = Asset.new(pair: key, base: asset['base'], quote: asset['quote'], \n altbase: asset['altbase'], name: asset['name'], marketcap: asset['marketcap'],\n display_decimals: asset['display_decimals'],\n erc20: asset['erc20'])\n\n\n # ok now look up each coin individually and grab the data from kraken\n logger.info '--pulling coin data from kraken -- (' + key + ')' \n\n # grab additional data from kraken\n ticker_json = get_coin_data('https://api.kraken.com/0/public/Ticker?pair=' + key, key)\n\n if (ticker_json != nil)\n asset_db['last_traded'] = ticker_json['c'][0]\n end\n \n # grab the asks and bids info for this coin and add to the coin in the db\n depth_json = get_coin_data('https://api.kraken.com/0/public/Depth?pair=' + key, key)\n\n if (depth_json != nil)\n depth_json['asks'].each do |depth|\n asset_db.asks.build(price: depth[0], volume: depth[1], timestamp: depth[2])\n end\n end\n\n if (depth_json != nil)\n depth_json['bids'].each do |depth|\n asset_db.bids.build(price: depth[0], volume: depth[1], timestamp: depth[2])\n end\n end\n\n # begin\n # grab the spread info for this coin and add/replace it in the db\n spread_json = get_coin_data('https://api.kraken.com/0/public/Spread?pair=' + key, key)\n\n if (spread_json != nil)\n spread_json.each do |spread|\n asset_db.spreads.build(time: spread[0], bid: spread[1], ask: spread[2])\n end\n end\n\n # begin\n # grab the trade info for this coin and add/replace it in the db\n trade_json = get_coin_data('https://api.kraken.com/0/public/Trades?pair=' + key, key)\n\n if (trade_json != nil)\n trade_json.each do |trade|\n asset_db.trades.build(price: trade[0], volume: trade[1], time: trade[2], buysell: trade[3], \n marketlimit: trade[4], misc: trade[5])\n end\n end\n\n # wrap the delete and insert in a transaction so that there is no lag in case there is\n # a request to pull the data in the middle of a delete and insert\n # we are replacing the existing asset pair with the newly fetched/created one\n Asset.transaction do\n # first remove the coin (and child data) from the data before we insert our newly aquired coin info\n Asset.where(pair: key).destroy_all\n asset_db.save\n end\n\n end\n\n # if there is any issue when getting a coins data - usually the response errored or is null\n # then just move on to the next coin\n rescue => error\n logger.error 'SINGLE coin refresh error-----------: ' + key\n logger.error error\n next\n end\n end\n\n logger.info \"*********** FINISHED refresh coins ******************************************\"\n\n # if there is an error grabbing the coin list, then just restart the job \n rescue => error\n logger.error \"GENERAL coin list refresh error: -------------\" \n logger.error error\n raise StandardError.new(\"STANDARD ERROR\")\n end\n\n end",
"def in_transaction(opts = {})\n yield\n end",
"def transaction(&block)\n ActiveRecord::Base.transaction(&block)\n end",
"def call\n db.transaction do\n _call_in_transaction\n end\n end",
"def call\n validate_params params\n token = JWT.encode(payload.to_hash, secret, algorithm)\n access_token = Entity::AccessToken.new(token: token)\n refresh_token = Entity::RefreshToken.new(token: refresh_token)\n \n #yield tokens_repo.transaction do\n # tokens_repo.save access_token\n # tokens_repo.save refresh_toke\n #end\n \n yield tokens_repo.single_transaction access_token\n yield tokens_repo.single_transaction refresh_token\n \n\n #result = tokens_repo.transaction do\n # tokens_repo.save access_token\n # tokens_repo.save refresh_token\n #end\n #return result unless result.success?\n\n #tokens_repo.save Entity::AccessToken.new(\n # token: token\n #)\n #tokens_repo.save Entity::RefreshToken.new(\n # token: refresh_token\n #)\n return access_token, refresh_token\n end",
"def within_transaction\n if use_transactions && !empty?\n first.within_transaction do\n yield\n success?\n end\n else\n yield\n end\n end",
"def transaction(&block)\n @in_transaction += 1\n begin\n yield self\n self.commit if @in_transaction > 0\n rescue => e\n self.rollback\n raise e\n ensure\n @in_transaction -= 1 unless @in_transaction == 0\n end\n end",
"def do\n execute flush\n end",
"def transaction(opts={}, &blk)\n Toshi.db.transaction(opts, &blk)\n end",
"def smart_transaction\n result = nil\n ensure_in_transaction do\n begin\n handle = connection.lo_open(oid)\n result = yield handle\n connection.lo_close(handle)\n end\n end\n result\n end",
"def flush\n\n # Flushing is usually very fast, but always fix it so that the\n # entire thing is based on a constant start time\n # Saves on time syscalls too\n flush_start = Time.now.to_i\n \n @retentions.each_with_index do |retention, index|\n @current_slots[index] += 1 \n @current_slots[index] = 0 if @current_slots[index] == @slots[index] \n \n ts = (flush_start - flush_start % retention.to_i)\n counters = @counters[index][@current_slots[index]].dup\n @counters[index][@current_slots[index]] = {}\n\n if index.zero?\n counters.each_slice(50) do |keys|\n threadpool.queue ts, keys do |timestamp, keys|\n keys.each do |key, value|\n redis.client.zadd key, timestamp, \"#{timestamp}<X>#{value}\"\n end\n end\n end\n else\n counters.each_slice(100) do |keys|\n threadpool.queue ts, keys, retention do |timestamp, keys, retention|\n keys.each do |key, value|\n key = \"#{key}:#{retention}\"\n if value\n value = \"#{ts} #{value}\"\n decode_key = \"v#{DATASTORE_VERSION} #{key}\"\n diskstore.append_value_to_file(diskstore.build_filename(key), value, 0, decode_key)\n end\n end\n end\n end\n end\n\n # If this is the last retention we're handling, flush the\n # counters list to redis and reset it\n if retention == @retentions.last\n redis.add_datapoint counters.keys\n end\n\n end\n\n end",
"def batch arg = nil\n if arg\n # Backward compatibility\n return scoped.batch(arg)\n else\n raise ArgumentError, \"Block not given\" unless block_given?\n end\n b = BatchAction.send(:new, self, @mutation)\n yield b\n results = Array.new(b.actions.length).to_java\n process = lambda do\n results.each_with_index do |r, idx|\n action = b.actions[idx]\n type = action[:type]\n case type\n when :get\n action[:result] = (r.nil? || r.empty?) ? nil : Row.send(:new, self, r)\n when :append\n action[:result] = r && Row.send(:new, self, r).to_h\n when :increment\n action[:result] = r &&\n Row.send(:new, self, r).to_h.tap { |h|\n h.each do |k, v|\n h[k] = Util.from_bytes :fixnum, v unless v.is_a?(Fixnum)\n end\n }\n else\n case r\n when java.lang.Exception\n action[:result] = false\n action[:exception] = r\n when nil\n action[:result] = false\n else\n action[:result] = true\n end\n end\n end\n b.actions\n end\n\n begin\n htable.batch b.actions.map { |a| a[:action] }, results\n process.call\n rescue Exception => e\n raise HBase::BatchException.new(e, process.call)\n end\n end",
"def perform_top_level\n @propagate_exceptions = true\n rv = true\n\n begin\n xact = self\n database.batch do\n xact.instance_eval(&xact.block)\n end\n\n commit\n @database.notify\n rescue Exception => e\n raise e if (not e.kind_of? TransactionRollback) && @propagate_exceptions\n rv = false\n end\n\n rv\n end",
"def call(*, &block)\n lock_instance.execute(&block)\n end",
"def start_transaction!\n fail DbMod::Exceptions::AlreadyInTransaction if @in_transaction\n @in_transaction = true\n\n query 'BEGIN'\n end",
"def fetch(params)\n Resque.logger.info \"Requestable.fetch received #{params.inspect}\"\n past = Time.now\n total = api_count(params)\n remain_requests = (total/250.to_f).ceil\n Resque.logger.info \"pages to request total: #{remain_requests}\"\n batch_num = (remain_requests / BATCH_SIZE.to_f).ceil\n Resque.logger.info \"batch number: #{batch_num}\"\n chap_start = 1\n chap_end = 0\n entity = params.fetch(:entity)\n Resque.logger.info \"entity name: #{entity}\"\n cache = $redis\n pages = []\n batch_num.times do\n entity_url = entity.pluralize\n if remain_requests > BATCH_SIZE\n chap_end += BATCH_SIZE\n remain_requests -= BATCH_SIZE\n else\n chap_end += remain_requests\n end\n hydra = Typhoeus::Hydra.new(max_concurrency: 30)\n\n chap_start.upto(chap_end) do |page|\n pages << page\n # queue up current batch\n request = Typhoeus::Request.new(\n \"https://api.rechargeapps.com/#{entity_url}?#{params[:query]}&limit=250&page=#{page}\",\n # followlocation: true,\n headers: HEADER\n )\n # error logging callbacks\n request.on_complete do |res|\n @used = res.headers['x-recharge-limit'].to_i\n if res.success?\n puts \"#{entity.upcase} request queued\"\n elsif res.timed_out?\n Resque.logger.error \"(HYDRA request) TIMED OUT: #{res.response_headers}\"\n elsif res.code.zero?\n Resque.logger.error \"(HYDRA request) Couldnt get an http response #{res.return_message}\"\n else\n Resque.logger.error(\"(HYDRA request) HTTP request failed: #{res.code}\")\n end\n end\n\n request.on_success do |res|\n # @used = res.headers['x-recharge-limit'].to_i\n # Resque.logger.info res.headers['x-recharge-limit']\n key = \"#{entity}_pull:#{Time.now.strftime(\"%Y%m%d\")}#{page.to_s.rjust(3, '0')}\"\n hash_set(cache, key, res.response_body)\n end\n\n hydra.queue(request)\n chap_start = chap_end\n end\n hydra.run\n batch_throttle(@used)\n end\n Resque.logger.info \"Pages iterated: #{pages.inspect}\"\n Resque.logger.info(\"RUN TIME per #{total} records: #{(Time.now - past)}\")\n end",
"def push_transactions\n AirdropMint.push_transactions_for_pending_rewards(user)\n end",
"def deadlock_scenario(low, high, slice)\n t1 = n_threads(2) do\n (low..high).each_slice(slice) do |commits|\n ActiveRecord::Base.transaction do\n # debug helper\n # puts \"Enqueue: [#{commits.join(', ')}] #{Thread.current}\"\n commits.each do |x|\n Delayed::Job.enqueue_once SomeJob.new(x)\n Thread.pass\n sleep 0.005\n Delayed::Job.enqueue AnotherJob.new(x)\n end\n # debug helper\n # puts \" [#{commits.join(', ')}] -- DONE #{Thread.current}\"\n end\n end\n end\n\n t2 = n_threads(2) do\n high.downto(low).each_slice(slice) do |commits|\n\n ActiveRecord::Base.transaction do\n # puts \"Enqueue: [#{commits.join(', ')}] #{Thread.current}\"\n commits.each do |x|\n Delayed::Job.enqueue_once SomeJob.new(x)\n sleep 0.005\n Thread.pass\n Delayed::Job.enqueue AnotherJob.new(x)\n end\n # puts \" [#{commits.join(', ')}] -- DONE #{Thread.current}\"\n end\n end # high -> low\n end\n\n t3 = n_threads(1) do\n (low..high).each do |x|\n Delayed::Job.enqueue_once SomeJob.new(x)\n sleep 0.02\n end\n end\n t1 + t2 + t3\n end",
"def redis_pool; end",
"def begin_transaction\n return System.begin_transaction\n end",
"def snapshot_every_n_requests; end",
"def begin\n self.transaction_count += 1\n end",
"def queue(&callback)\n callback.call(cassandra_proxy)\n end",
"def run_bulk; end",
"def within_transaction\n if use_transaction\n first.within_transaction do\n yield\n success?\n end\n else\n yield\n end\n end",
"def restart_transaction\n ActiveRecord::Base.connection.execute(\"COMMIT\")\n ActiveRecord::Base.connection.execute(\"BEGIN\")\n end",
"def getTransactions\n\t\t\n\tend",
"def execute\n puts \"*********************\"\n Tenant.all.each do |tenant|\n puts tenant.subdomain\n begin\n if PackageConfig::PAY_AS_YOU_GO.eql? tenant.plan_bid.to_s\n tenant_minutes = (tenant.call_minutes.to_i - tenant.credit_minutes.to_i)\n\n ClientMailer.delay.call_transaction_mailer(tenant,\"execute - tenant minutes - #{tenant_minutes}\")\n\n if tenant.tenant_notification.nil?\n tenant_notification = TenantNotification.new\n tenant_notification.tenant_id = tenant.id\n tenant_notification.pay_as_you_go = 0\n tenant_notification.save\n ClientMailer.delay.call_transaction_mailer(tenant,\"execute - tenant notification created - pay as you go\")\n else\n tenant_notification = tenant.tenant_notification\n tenant_notification.pay_as_you_go = 0\n tenant_notification.save\n ClientMailer.delay.call_transaction_mailer(tenant,\"execute - tenant notification updated - pay as you go\")\n end\n\n ClientMailer.delay.call_transaction_mailer(tenant,\"execute - not overage_transaction\")\n\n if tenant_minutes > 100\n overage_transaction(tenant, \"call minutes\", :call_minutes, 0)\n ClientMailer.delay.call_transaction_mailer(tenant,\"execute - overage_transaction\")\n end\n\n tenant_minutes = (tenant.call_minutes.to_i - tenant.credit_minutes.to_i)\n if (tenant_minutes >= 90 or tenant_minutes >= 350) && !tenant_notification.pay_as_you_go.present?\n ClientMailer.delay.minutes_running_low(tenant)\n ClientMailer.delay.call_transaction_mailer(tenant,\"execute - minutes running low - pay as you go\")\n end\n end\n\n if PackageConfig::MINUTE_200.eql? tenant.plan_bid.to_s\n if tenant.tenant_notification.nil?\n tenant_notification = TenantNotification.new\n tenant_notification.tenant_id = tenant.id\n tenant_notification.minutes200 = 0\n tenant_notification.save\n ClientMailer.delay.call_transaction_mailer(tenant,\"execute - tenant notification created - 200 minutes\")\n else\n tenant_notification = tenant.tenant_notification\n tenant_notification.minutes200 = 0\n tenant_notification.save\n ClientMailer.delay.call_transaction_mailer(tenant,\"execute - tenant notification updated - 200 minutes\")\n end\n\n tenant_minutes = (tenant.call_minutes.to_i - tenant.credit_minutes.to_i)\n if tenant_minutes >= 350 && !tenant_notification.minutes200.present?\n ClientMailer.delay.minutes_running_low(tenant)\n ClientMailer.delay.call_transaction_mailer(tenant,\"execute - minutes running low - 200 minutes\")\n end\n end\n\n #if tenant.menu_minutes > 100\n # overage_menu_minutes(tenant)\n # ClientMailer.delay.call_transaction_mailer(tenant,\"execute - overage_transaction - menu minutes\")\n #end\n #if tenant.mail_minutes > 100\n # overage_mail_minutes(tenant)\n # ClientMailer.delay.call_transaction_mailer(tenant,\"execute - overage_transaction - mail minutes\")\n #end\n rescue => e\n puts \"ERROR: #{e}\"\n end\n\n end\n end",
"def bulk_tokenized_charge_transactions(bulk_id)\n base_url = flutterwave_object.base_url \n response = get_request(\"#{base_url}/bulk-tokenized-charges/#{bulk_id}/transactions\")\n return response\n end",
"def startRun\n db_cached_connect\n\n @dbh.do(\"BEGIN TRANSACTION;\")\n @dbh.do(\"SELECT startRun();\")\n end"
] |
[
"0.6150511",
"0.60140514",
"0.6000278",
"0.59217525",
"0.58475876",
"0.57977444",
"0.57458943",
"0.5729778",
"0.57279706",
"0.57279706",
"0.57230306",
"0.57178307",
"0.5714453",
"0.57112795",
"0.5677369",
"0.5656723",
"0.56521195",
"0.56381905",
"0.5634469",
"0.56168234",
"0.56113464",
"0.5606301",
"0.5599775",
"0.55640393",
"0.5548187",
"0.5547823",
"0.5531106",
"0.55308217",
"0.55219513",
"0.55219513",
"0.54906034",
"0.54728127",
"0.5467707",
"0.54413646",
"0.54372233",
"0.5429642",
"0.5426217",
"0.5357354",
"0.5357354",
"0.5347621",
"0.5347621",
"0.5347621",
"0.5342618",
"0.53289247",
"0.53180426",
"0.53135675",
"0.5308408",
"0.53007793",
"0.53007793",
"0.5296696",
"0.529476",
"0.523736",
"0.52189636",
"0.52116114",
"0.52116114",
"0.5207123",
"0.5207123",
"0.52059895",
"0.52059895",
"0.5186856",
"0.5171769",
"0.516983",
"0.51695716",
"0.51659226",
"0.51624894",
"0.5156309",
"0.5150867",
"0.51424384",
"0.5134469",
"0.51270956",
"0.51122516",
"0.5107417",
"0.51055557",
"0.5096763",
"0.50962627",
"0.5085377",
"0.5082601",
"0.5037639",
"0.5037002",
"0.502997",
"0.502679",
"0.502518",
"0.5024539",
"0.49992427",
"0.4987743",
"0.49859598",
"0.49844462",
"0.49804065",
"0.49681515",
"0.49420953",
"0.49402192",
"0.49380505",
"0.49291006",
"0.4927668",
"0.49246255",
"0.49240112",
"0.49151567",
"0.4913547",
"0.4903576",
"0.48974302",
"0.48949632"
] |
0.0
|
-1
|
If there is no context this method is used instead of pull_burst
|
def pull_burst_only(burst_p)
[burst_p.call, nil]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def pull_burst(burst_p, burst_context_p)\n cx_data.multi do\n burst_p.call\n burst_context_p.call\n end\n end",
"def get_burst(spark, _options={})\n # get the context parameters\n context_h = spark[:context]\n\n burst_p = -> { cx_data.hget hsdq_key(spark), burst_key(spark) }\n if response?(spark) && context_h\n # save previous_sender in thread_store for later reply\n sent_to context_h[:previous_sender]\n # set the proc for multi redis to pull the initial request\n burst_context_p = -> { cx_data.hget hsdq_key(spark), \"request_#{context_h[:spark_uid]}\" }\n # exec the redis multi\n burst_j, burst_context_j = pull_burst(burst_p, burst_context_p)\n else\n burst_j, burst_context_j = pull_burst_only burst_p\n end\n\n burst = burst_j ? (JSON.parse burst_j, {symbolize_names: true}) : {}\n burst_context = burst_context_j ? (JSON.parse burst_context_j, {symbolize_names: true}) : {}\n\n [burst, burst_context]\n end",
"def pull; end",
"def floodfill_tree bn_id, &blk\n info \"Fill #{bn_id}\"\n return bn_id if node_visited?(bn_id)\n _q.push(bn_id)\n\n index = 0\n while _q.length > 0 do\n #bn = blk.call(bn_id)\n bns = Http.get_bns _q\n bns.each do |bn|\n bn_data = get_node_data_from_xml_doc(bn)\n set_node(bn_data)\n children = get_children_from_xml_doc(bn).map do |child_bn| \n get_node_data_from_xml_doc(child_bn)\n end\n children.each do |child|\n #floodfill_tree child[:id], &blk\n _q.push(child[:id])\n add_child bn_data[:id], child[:id]\n end\n ancestors = get_ancestors_from_xml_doc(bn)\n ancestors.each do |parent|\n parent_data = get_node_data_from_xml_doc parent\n #floodfill_tree parent_data[:id], &blk\n _q.push(parent_data[:id])\n add_ancestor bn_data[:id], parent_data[:id]\n # First 2 levels of ancestors are virtual nodes\n # Add them with this request\n current_parent_bn_id = parent_data[:id]\n grandparent = get_ancestors_from_xml_doc(parent)\n while grandparent.length > 0\n # MAybe Bug\n grandparent_data = get_node_data_from_xml_doc parent\n set_node grandparent_data\n add_ancestor current_parent_bn_id, grandparent_data[:id]\n current_parent_bn_id = grandparent_data[:id]\n grandparent = get_ancestors_from_xml_doc(grandparent)\n end\n end\n # a node is visited when all neighbours are visited\n visit_node bn_data[:id]\n end\n info \"To process #{_q.inspect}\"\n _q.reject!{|e| node_visited?(e)}\n info \"To process #{_q.length} node(s)\"\n index += 1\n save if (index%100 == 0)\n end\n save\n end",
"def pop\n context.pop\n end",
"def round_down()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::RoundDown::RoundDownRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def pull\n source = source_tree_path + \"/\"\n command = make_command(source, \".\")\n if blank_source_tree_path?\n execution_context = prepare_execution_context(command, false, output: nil, errors: BLANK_SOURCE_TREE_ERROR)\n yield(execution_context) if block_given?\n return execution_context\n end\n\n @tempdir = Dir.mktmpdir(\"gorgon\")\n Dir.chdir(@tempdir)\n\n execution_context = execute_command(command)\n begin\n yield(execution_context) if block_given?\n ensure\n cleanup\n end\n\n execution_context\n end",
"def pop\n context.pop if context.size > 1\n end",
"def set_brave_burst\n @brave_burst = BraveBurst.friendly.find(params[:id])\n end",
"def ring; end",
"def ring; end",
"def round_up()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::RoundUp::RoundUpRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def pull_on_operand_branch *args\n self.on_operand_branch :pull, *args\n end",
"def pop_context\n context.pop\n end",
"def yield_disc()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::YieldDisc::YieldDiscRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def pop! &use\n ( use || proc {|obj|} ).call @blocks[ @pop_at & (@depth-1) ]\n @pop_at += 1\n end",
"def pull\n fetch\n merge\n end",
"def round()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Round::RoundRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def retrogress_bbtree\n if @tags_list[-1].definition[:self_closable]\n # It is possible that the next (self_closable) tag is on the next line\n # Remove newline of current tag and parent tag as they are (probably) not intented as an actual newline here but as tag separator\n @tags_list[-1][:nodes][0][:text]&.chomp!\n @tags_list[-2][:nodes][0][:text].chomp! unless (@tags_list.length < 2) || @tags_list[-2][:nodes][0][:text].nil?\n end\n\n @tags_list.pop # remove latest tag in tags_list since it's closed now...\n # The parsed data manifests in @bbtree.current_node.children << TagNode.new(element) which I think is more confusing than needed\n\n @current_node = if within_open_tag?\n @tags_list[-1]\n else\n # we're still at the root of the BBTree or have returned back to the root via encountering closing tags...\n TagNode.new(nodes: nodes)\n end\n end",
"def tbill_yield()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::TbillYield::TbillYieldRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def context\n nil\n end",
"def _run\n super.tap { reenqueue }\n end",
"def pull from, to, dryrun=true, push=false\n build from, to, dryrun, push\n end",
"def update!(**args)\n @starburst = args[:starburst] if args.key?(:starburst)\n end",
"def drain\n raise NotImplementedError\n end",
"def pop(&block)\n if self.empty?\n result = super(&block)\n else\n result = super(&block)\n \n if @scheduler.nil?\n self.pop(&block)\n else\n @scheduler.call(Proc::new { self.pop(&block) })\n end\n end\n \n return result\n end",
"def make_recursive_call\n offset = 0\n p_args = set_pagination(offset, page_size, args)\n api_caller.verbosity(conn, method, *p_args)\n\n return if api_caller.opts[:noop]\n\n ret = api_caller.respond(conn.public_send(method, *p_args))\n\n return ret unless ret.more_items?\n\n loop do\n offset += page_size\n p_args = set_pagination(offset, page_size, p_args)\n api_caller.verbosity(conn, method, *p_args)\n resp = api_caller.respond(conn.public_send(method, *p_args))\n raise StopIteration unless resp.ok?\n\n ret.response.items += resp.response.items\n return finalize_response(ret) unless resp.more_items?\n end\n end",
"def run_context\n nil\n end",
"def receive_tipped_bins\n search_bins_tipped_hierarchy\n end",
"def pullBittrex(timeToPull, pairsToPull)\n supportedIntervals = [60, 300, 1800, 3600, 86400]\n \n # Request to get all Bittrex tickers\n allBittrexTickers = http_With_Timeout(\"https://bittrex.com/api/v1.1/public/getmarketsummaries\")\n unless allBittrexTickers then return end\n \n if allBittrexTickers[\"success\"]\n allBittrexTickers[\"result\"].each do |ticker|\n \n # Check to see if pair is in whitelist\n if pairsToPull.include?(ticker[\"MarketName\"].sub('-','_'))\n timeToPull.each do |intervalArray|\n \n # Attempt to set pullInterval to largest factor of intervalArray[0] that is present in supportedIntervals\n pullInterval = getCompatibleInterval(intervalArray[0], supportedIntervals)\n unless supportedIntervals.include?(pullInterval) then next end\n \n # Go to next if not able to support that interval.\n unless supportedIntervals.include?(pullInterval) then next end\n \n # Convert time interval to Bittrex-compatible time period in words.\n intervalWords = convert_Intervals_to_Bittrex_Words(pullInterval)\n \n # Request candlestick data at five minute intervals.\n candlestickData = http_With_Timeout(\"https://bittrex.com/Api/v2.0/pub/market/GetTicks?marketName=#{ticker[\"MarketName\"]}&tickInterval=#{intervalWords}\")\n unless candlestickData then return end\n \n if candlestickData[\"success\"]\n candlestickData = candlestickData[\"result\"]\n \n # Remove all entries at the front of candlestickData that are too old.\n candlestickData = cleanup_Old_Candlesticks_Front(\"T\", intervalArray[1], candlestickData)\n\n # Merge candlesticks if pulling an interval that isn't natively supported.\n unless supportedIntervals.include?(intervalArray[0]) then candlestickData = merge_Candlesticks(candlestickData, intervalArray[0], \"H\", \"L\", \"C\", \"T\") end\n \n # Store/update candlestick data\n candlestickData.each do |candlestick|\n addCandlestick(\"Bittrex\", ticker[\"MarketName\"].sub('-','_'), Time.at(time_To_Seconds(candlestick[\"T\"])), candlestick[\"O\"], candlestick[\"H\"], candlestick[\"L\"], candlestick[\"C\"], intervalArray[0])\n end\n \n end\n end\n end\n \n end\n end\n puts \"Finished retrieval and storage of Bittrex data.\"\n end",
"def pull_node(xn)\n # nothing to do with node\n end",
"def __bb_context; end",
"def myPullRequests\n @pullRequests = PullRequest.where(user_id: current_user.id)\n respond_with(@pullRequests)\n end",
"def read\n if !@derived_queue.empty?\n p1 = @derived_queue.shift\n return p1\n else\n\n # This is a blocking call to wait for an actual packet to come over the wire\n packet = super()\n\n agg_pkt_map.select do |agg_packet, simple_packet|\n agg_pkt = System.telemetry.packet(target, agg_packet)\n if(agg_pkt.identify?(packet.buffer)) \n process(packet: packet, target: target, agg_packet: agg_packet, simple_packet: simple_packet)\n end\n end\n \n return packet\n end \n end",
"def pull\n start = Time.now\n job = job_of(\n clean(\n Typhoeus::Request.get(\n 'https://wts.zold.io/pull',\n headers: headers\n )\n )\n )\n @log.debug(\"PULL job #{job} started in #{Zold::Age.new(start)}\")\n job\n end",
"def run(context, options = {})\n #@block.call(options)\n\n if @options[:defaults]\n options = @options[:defaults].merge(options)\n end\n\n context.instance_exec(options, &@block)\n end",
"def parse_yield(context, single, tk, method)\n return if method.block_params\n\n get_tkread\n method.block_params = parse_method_or_yield_parameters\n end",
"def snat_pool\n super\n end",
"def reset_radius_statistics\n super\n end",
"def run(id = nil, incremental_report = true)\n data = []\n if id\n pull_request = @client.pull_request(@repo, id)\n record = process_pull_request(pull_request)\n incremental_report ? report_one(record) : data.push(record)\n else\n pull_requests = @client.pull_requests(@repo)\n while pull_requests\n pull_requests.each do |pull_request|\n record = process_pull_request(pull_request)\n incremental_report ? report_one(record) : data.push(record)\n end\n next_rel = @client.last_response.rels[:next]\n pull_requests = next_rel ? next_rel.get.data : nil\n end\n end\n report(data) unless incremental_report\n end",
"def method_missing(name, *args, &block)\n super unless respond_to? name\n @builder = Builder.new(builder.tree) do\n __send__(name, *args, &block)\n end\n end",
"def call\n cube = []\n\n deck = Deck.find(context.deck_id)\n\n deck.card_decks.each do |card_deck|\n (1..card_deck.occurences_in_main_deck).each do\n cube.push(card_deck.card_id)\n end\n end\n\n tirages = []\n # reste = []\n\n while cube.length > 14\n tirage = cube.sample(15)\n tirage.each do |card_id|\n cube.delete_at(cube.find_index(card_id))\n end\n tirages.push(tirage)\n end\n context.tirages = tirages\n # reste = cube\n end",
"def pop()\n stack.stack.pop if !empty?\n end",
"def push(info={})\n context.push(info)\n yield if block_given?\n ensure\n pop if block_given?\n end",
"def nesting() end",
"def call(context: nil)\n synchronize do\n be_prepared!\n if context\n be_unstarted!\n @context = context.for(self)\n end\n if @parallel\n acts = @actions.dup\n @actions = []\n acts.each do |action|\n Thread.new { action.call(context: @context) }\n end\n else\n action = pop\n action.call(context: context) if action\n end\n end\n end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def cb_rpts_build_tree\n TreeBuilderChargebackReports.new(\"cb_reports_tree\", @sb)\n end",
"def pull_expression\n strategy.pull_condition\n end",
"def get_rear()\n \n end",
"def context\n {}\n end",
"def context\n {}\n end",
"def patch!\n # rubocop:disable Metrics/BlockLength\n ::SuckerPunch::Job::ClassMethods.class_eval do\n alias_method :__run_perform_without_datadog, :__run_perform\n def __run_perform(*args)\n Datadog::Tracing.send(:tracer).provider.context = Datadog::Tracing::Context.new\n\n __with_instrumentation(Ext::SPAN_PERFORM) do |span|\n span.resource = \"PROCESS #{self}\"\n\n span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_PERFORM)\n\n # Set analytics sample rate\n if Datadog::Tracing::Contrib::Analytics.enabled?(datadog_configuration[:analytics_enabled])\n Datadog::Tracing::Contrib::Analytics.set_sample_rate(\n span,\n datadog_configuration[:analytics_sample_rate]\n )\n end\n\n # Measure service stats\n Datadog::Tracing::Contrib::Analytics.set_measured(span)\n\n __run_perform_without_datadog(*args)\n end\n rescue => e\n ::SuckerPunch.__exception_handler.call(e, self, args)\n end\n ruby2_keywords :__run_perform if respond_to?(:ruby2_keywords, true)\n\n alias_method :__perform_async, :perform_async\n def perform_async(*args)\n __with_instrumentation(Ext::SPAN_PERFORM_ASYNC) do |span|\n span.resource = \"ENQUEUE #{self}\"\n\n span.set_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_PERFORM_ASYNC)\n\n # Measure service stats\n Datadog::Tracing::Contrib::Analytics.set_measured(span)\n\n __perform_async(*args)\n end\n end\n ruby2_keywords :perform_async if respond_to?(:ruby2_keywords, true)\n\n alias_method :__perform_in, :perform_in\n def perform_in(interval, *args)\n __with_instrumentation(Ext::SPAN_PERFORM_IN) do |span|\n span.resource = \"ENQUEUE #{self}\"\n\n span.set_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_PERFORM_IN)\n\n span.set_tag(Ext::TAG_PERFORM_IN, interval)\n\n # Measure service stats\n Datadog::Tracing::Contrib::Analytics.set_measured(span)\n\n __perform_in(interval, *args)\n end\n end\n ruby2_keywords :perform_in if respond_to?(:ruby2_keywords, true)\n\n private\n\n def datadog_configuration\n Datadog.configuration.tracing[:sucker_punch]\n end\n\n def __with_instrumentation(name)\n Datadog::Tracing.trace(name, service: datadog_configuration[:service_name]) do |span|\n span.span_type = Datadog::Tracing::Metadata::Ext::AppTypes::TYPE_WORKER\n span.set_tag(Datadog::Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)\n span.set_tag(Ext::TAG_QUEUE, to_s)\n yield span\n end\n end\n end\n # rubocop:enable Metrics/BlockLength\n end",
"def push! &put\n ( put || proc {|obj|} ).call @blocks[ @push_at & (@depth-1) ]\n @push_at += 1\n end",
"def climb(position, radius)\n max_rad, max_pos, max_ele, inc, my_ele = highest_neighbor(position, radius)\n if inc < 0 || max_rad < radius\n puts \"We have reached the peak (#{my_ele}) at #{position}\".green\n peak_id = store_peak(position, my_ele)\n [position, my_ele, peak_id]\n else\n puts \"Elevation #{max_ele}, position #{max_pos}\".yellow\n sleep 0.01\n if inc > 0\n puts \"Climbing more\".light_black\n climb(max_pos, 1)\n else\n new_radius = radius + 1\n puts \"On a flat, increasing radius to #{new_radius}\"\n climb(max_pos, new_radius)\n end\n end\nend",
"def pull(receiver, *functions)\n PullChain.new(receiver, *functions).call\n end",
"def reset_diameter_statistics\n super\n end",
"def drush\n ret = @uri.drush params[:command]\n render plain: ret[:message], status: ret[:status]\n end",
"def update!(**args)\n @frame_starburst_data = args[:frame_starburst_data] if args.key?(:frame_starburst_data)\n end",
"def callback_traces\n return if @trace_buffer.empty?\n\n begin\n traces = @trace_buffer.pop()\n @trace_task.call(traces, @transport)\n rescue StandardError => e\n # ensures that the thread will not die because of an exception.\n # TODO[manu]: findout the reason and reschedule the send if it's not\n # a fatal exception\n Datadog::Tracer.log.error(\"Error during traces flush: dropped #{items.length} items. Cause: #{e}\")\n end\n end",
"def fillarc(*)\n super\n end",
"def each(&block)\n\t\t@stack.drop(1).each(&block)\n\t\treturn self\n\tend",
"def within_context(context)\n block_given? ? @bridge.within_context(context, &Proc.new) : @bridge.within_context(context)\n end",
"def break\n build_deeper_query(nil)\n end",
"def pull(stream)\n stream.is_a?(Proc) && !cons?(stream) ? pull(stream.call) : stream\n end",
"def gadget; end",
"def gadget; end",
"def pull_from_ids(topic_neo_id, depth=20)\n #Rails.cache.fetch(\"neo4j-#{topic_neo_id}-pulling-#{depth}\", :expires_in => 1.day) do\n query = \"\n START n=node(#{topic_neo_id})\n MATCH n-[:pull*1..#{depth}]->x\n RETURN distinct x.uuid\n \"\n ids = Neo4j.neo.execute_query(query)\n pull_from = []\n if ids\n ids['data'].each do |id|\n pull_from << Moped::BSON::ObjectId(id[0])\n end\n end\n pull_from\n #end\n end",
"def call(*, &blk)\n socket.print \"#{format(self.class.const_get(:TEMPLATE), combined_options)}\\r\\n\"\n\n pull_socket(&blk)\n\n return result_accumulator unless block_given?\n end",
"def retrieve\n # TODO remove !!self.graph after run once\n if self.new_item? # !!self.graph\n @since_date = 6.months.ago\n end\n @bulk_insert_array = []\n @bulk_update_hash = {}\n puts \" retrieve #{self.id} #{since_date}\"\n since = since_date\n hasta = until_date\n started=Time.now.strftime(\"%Y-%m-%d %H:%M:%S .%L\")\n success = nil\n while (hasta - since_date) >= back_to_date\n since = hasta - back_to_date\n success = do_retrieve(since, hasta)\n # yes just minus 1 second, becomes the end of previous day\n hasta = since - 1\n end\n if !@bulk_update_hash.blank?\n # FbPost.update_bulk! [:replies_to_comment,:post_created_time], @bulk_update_hash\n FbPost.update_bulk! @bulk_update_hash\n @bulk_update_hash = {}\n end\n if !@bulk_insert_array.empty?\n # puts \" retrieve call FbPost.import_bulk!\"\n FbPost.import_bulk! @bulk_insert_array\n @bulk_insert_array = []\n end\n save_posts_details\n self.update_attributes :new_item=>false,:status=>success,:updated_at=>DateTime.now.utc\n begin\n # for today only\n daily_aggregate_data\n rescue Exception=>ex\n logger.error \" retrieve daily_aggregate_data #{ex.message}\"\n end\n begin\n # for past 7 days if no argument \n aggregate_data_daily\n rescue Exception=>ex\n logger.error \" retrieve aggregate_data_daily #{ex.message}\"\n end\n # create additional fb_pages if neccessary\n # aggregate_data 1,'day', true\n # recent_page available after aggregate_data\n save_lifetime_data\n ended=Time.now.strftime(\"%Y-%m-%d %H:%M:%S .%L\")\n puts \" id #{self.id} finished retrieve #{started} - #{ended} \"\n STDOUT.flush\n end",
"def _perform(environment)\n node = dup\n node.perform!(environment)\n node\n end",
"def _perform(environment)\n node = dup\n node.perform!(environment)\n node\n end",
"def dsum()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Dsum::DsumRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def inject(carrier, context, setter = nil)\n span_context = Trace.current_span(context).context\n return unless span_context.valid?\n\n sampling_state = if XRay.debug?(context)\n 'd'\n elsif span_context.trace_flags.sampled?\n '1'\n else\n '0'\n end\n\n ot_trace_id = span_context.hex_trace_id\n xray_trace_id = \"1-#{ot_trace_id[0..6]}-#{ot_trace_id[7..ot_trace_id.length]}\"\n parent_id = span_context.hex_span_id\n\n xray_value = \"Root=#{xray_trace_id};Parent=#{parent_id};Sampled=#{sampling_state}\"\n\n setter ||= @default_setter\n setter.set(carrier, XRAY_CONTEXT_KEY, xray_value)\n carrier\n end",
"def pulled_from_ids(topic_neo_id, depth=20)\n #Rails.cache.fetch(\"neo4j-#{topic_neo_id}-pushing-#{depth}\", :expires_in => 1.day) do\n query = \"\n START n=node(#{topic_neo_id})\n MATCH n<-[:pull*1..#{depth}]-x\n RETURN distinct x.uuid\n \"\n ids = Neo4j.neo.execute_query(query)\n pull_from = []\n if ids\n ids['data'].each do |id|\n pull_from << Moped::BSON::ObjectId(id[0])\n end\n end\n pull_from\n #end\n end",
"def pop_tree\n @tree_stack.pop\n end",
"def call(*args, &block)\n call_with_tracing(args[0]) { super }\n end",
"def disc()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Disc::DiscRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def dig\n @stack.push(@stack.slice!(-3))\n end"
] |
[
"0.6811905",
"0.557157",
"0.51338893",
"0.47984928",
"0.46801764",
"0.4668408",
"0.46215606",
"0.46159634",
"0.4613274",
"0.46123788",
"0.46123788",
"0.45138147",
"0.44802356",
"0.4468857",
"0.44554564",
"0.4449934",
"0.44464165",
"0.4433477",
"0.44118798",
"0.43884322",
"0.436004",
"0.43348527",
"0.42747328",
"0.42654112",
"0.42612427",
"0.4257187",
"0.42471182",
"0.42470345",
"0.42450082",
"0.42237785",
"0.4220176",
"0.41953063",
"0.41630864",
"0.41609353",
"0.4153536",
"0.41445288",
"0.4137265",
"0.41371307",
"0.41290247",
"0.4125814",
"0.41240653",
"0.41191748",
"0.41098356",
"0.410889",
"0.41020465",
"0.40830266",
"0.4081378",
"0.4081378",
"0.4081378",
"0.4081378",
"0.4081378",
"0.4081378",
"0.4081378",
"0.4081378",
"0.4081378",
"0.4081378",
"0.4081378",
"0.4081378",
"0.4081378",
"0.4081378",
"0.4081378",
"0.4081378",
"0.4081378",
"0.4081378",
"0.4081378",
"0.4081378",
"0.4081378",
"0.4081378",
"0.40778935",
"0.40772936",
"0.40751192",
"0.40744293",
"0.40744293",
"0.40679005",
"0.40672097",
"0.40643275",
"0.40632623",
"0.4060676",
"0.4059005",
"0.4058493",
"0.40565547",
"0.4048529",
"0.4048375",
"0.4042211",
"0.4042036",
"0.40402922",
"0.4037248",
"0.4037248",
"0.40365458",
"0.40350005",
"0.4031344",
"0.40182528",
"0.40182528",
"0.40165633",
"0.40105945",
"0.40096748",
"0.4001489",
"0.3997086",
"0.3994596",
"0.39938742"
] |
0.62543994
|
1
|
Spark validation, call valid_type?. If invalid: an error is sent back to the sender false is returned to the processing to stop the action.
|
def valid_spark?(spark, options)
begin
raise ArgumentError.new("Illegal type #{spark[:type]}") unless valid_type? spark[:type]
'request' == spark[:type] ? check_whitelist(spark, options) : true
rescue => e
reject_spark spark, e
false
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def validate\n self.send(\"validate_#{type}\".to_sym)\n end",
"def validate!\n # pass\n end",
"def validated?; end",
"def validate_type(type, context:); end",
"def valid?(_) true end",
"def valid?(_) true end",
"def validate\n end",
"def validate!(t)\n # None.\n end",
"def validate\n \n \n end",
"def validation; end",
"def validation; end",
"def validate!; end",
"def validate!; end",
"def validate!; end",
"def validated; end",
"def validate; end",
"def validate; end",
"def validate; end",
"def validate; end",
"def validate\n\n end",
"def validate!\n validator.validate(data: data, schema: schema, logger: validation_logger)\n end",
"def validate(data_value, data_type=nil)\n #TODO: port from python runtime\n end",
"def validate(data_value, data_type=nil)\n #TODO: port from python runtime\n end",
"def validate\n end",
"def validate\n end",
"def validate\n end",
"def validate\r\n validate! rescue false\r\n end",
"def validate\r\n\r\n end",
"def execute(params = {})\n ok, values = @signature.apply(params)\n if ok\n # validation is ok, merge params and continue\n [:success, @method.bind(controller.instance).call(params.merge!(values))]\n else\n # validation is ko\n [:\"validation-ko\", values]\n end\n rescue ::Waw::Validation::KO => ex\n [:\"validation-ko\", ex.failed]\n rescue ::Waw::Validation::Error => ex\n [:\"validation-error\", ex.failed]\n end",
"def validate!\n validate_redis\n validate_workers\n validate_options\n end",
"def validate\n raise \"Can only validate request messages\" unless type == :request\n\n raise(NotTargettedAtUs, \"Received message is not targetted to us\") unless PluginManager[\"security_plugin\"].validate_filter?(payload[:filter])\n end",
"def validate_type\n if params&.data&.type == params[:controller]\n return true\n end\n head 409 and return\n end",
"def validate\n end",
"def validate\n end",
"def validate\n end",
"def validate\n valid?\n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def validate(obj, type); end",
"def validate!\n true\n end",
"def perform\n\n r = validate\n return r unless r.success?\n\n process_hook\n\n end",
"def valid?\n !type.nil?\n end",
"def valid?\n !type.nil?\n end",
"def valid?; end",
"def valid?; end",
"def valid?; end",
"def valid?; end",
"def valid?; end",
"def validate_block\n shrine_class.opts[:validate]\n end",
"def perform_validation\n raise NotImplementedError\n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def validate\n # add errors if not validate\n end",
"def validate\n true\n end",
"def validate!\n unless resource_type === 'user_moves'\n fail PayloadValidationError, 'Invalid resource type at \"data.type\", expected \"user_moves\"'\n end\n\n unless raw_given_position.is_a?(Array) && raw_given_position.length == 2\n fail PayloadValidationError, 'Invalid resource type at \"data.attributes.position\", expected Array([x, y])'\n end\n end",
"def validate!\n\t\t\t\treturn true\n\t\t\tend",
"def validate()\n name = @name.to_sym\n unless support.has_key?(name)\n @errors << Sparkql::ParserError.new(:token => @name, \n :message => \"Unsupported function call '#{@name}' for expression\",\n :status => :fatal )\n return\n end\n\n required_args = support[name][:args]\n total_args = required_args + Array(support[name][:opt_args]).collect {|args| args[:type]}\n\n if @args.size < required_args.size || @args.size > total_args.size\n @errors << Sparkql::ParserError.new(:token => @name, \n :message => \"Function call '#{@name}' requires #{required_args.size} arguments\",\n :status => :fatal )\n return\n end\n\n count = 0\n @args.each do |arg|\n type = arg[:type] == :function ? arg[:return_type] : arg[:type]\n unless Array(total_args[count]).include?(type)\n @errors << Sparkql::ParserError.new(:token => @name, \n :message => \"Function call '#{@name}' has an invalid argument at #{arg[:value]}\",\n :status => :fatal )\n end\n count +=1\n end\n\n if name == :cast\n type = @args.last[:value]\n if !VALID_CAST_TYPES.include?(type.to_sym)\n @errors << Sparkql::ParserError.new(:token => @name,\n :message => \"Function call '#{@name}' requires a castable type.\",\n :status => :fatal )\n return\n end\n end\n\n if name == :substring && !@args[2].nil?\n substring_index_error?(@args[2][:value])\n end\n end",
"def validate\n raise NoMethodError, \"must define method 'validate'\"\n end",
"def valid?\n \n \n \n \n \n \n \n allowed_values = [\"STRING\", \"BOOLEAN\", \"DECIMAL\", \"INTEGER\", \"DATE_TIME\", \"REFERENCE\", \"COMPLEX\"]\n if @type && !allowed_values.include?(@type)\n return false\n end\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n allowed_values = [\"readWrite\", \"readOnly\", \"immutable\", \"writeOnly\"]\n if @mutability && !allowed_values.include?(@mutability)\n return false\n end\n \n \n \n \n \n allowed_values = [\"ALWAYS\", \"NEVER\", \"DEFAULT\", \"REQUEST\"]\n if @returned && !allowed_values.include?(@returned)\n return false\n end\n \n \n \n \n \n allowed_values = [\"NONE\", \"SERVER\", \"GLOBAL\"]\n if @uniqueness && !allowed_values.include?(@uniqueness)\n return false\n end\n \n \n \n \n \n \n \n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def do_validation \n return true if self.ok\n set_ok\n self.ok\n end",
"def check\n if valid?\n report_template(:ok)\n else\n report_template(:fail, VALIDATOR_MISSING)\n end\n end",
"def validate(&block)\n shrine_class.opts[:validate] = block\n end",
"def is_valid; end",
"def validate\r\n @invalid=false\r\n end",
"def validate(options); end",
"def run_validations!\n super\n include_typecasting_errors\n errors.empty?\n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def validate!\n @ddl.validate_rpc_request(@action, @data)\n end",
"def validate\n @invalid=false\n end",
"def validate\n errors.clear\n instance_exec(&validate_block) if validate_block && get\n end",
"def validator; end",
"def valid?\n validate\n end",
"def run_validation(vmode)\n validate(vmode)\n self\n end",
"def validation\n :wf_point?\n end",
"def validate_and_sanitize\n r = validate\n return r unless r.success?\n\n r = validate_gateway_type\n return r unless r.success?\n\n success\n end",
"def validate\n @condition = nil\n @error = \"No validation implemented for #{self.class}#validate\"\n end",
"def validate\n fail 'sub class to implement'\n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def validate\n super\n raise ValidationError, \"Status must be specified\" if status.nil?\n raise ValidationError, \"Status must be a RSAML::Protocol::Status instance\" unless status.is_a?(Status)\n end",
"def valid; end",
"def perform\n validate_data_from_requests\n end",
"def valid?\n return validate\n end",
"def validate\n execute(:validate).to_boolean\n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def is_valid?\n end",
"def valid?\n workflow_type_validator = EnumAttributeValidator.new('String', [\"active_archive\", \"offline_archive\", \"data_exchange\", \"data_migration\", \"maintenance\", \"data_enrichment\"])\n return false unless workflow_type_validator.valid?(@workflow_type)\n workflow_action_validator = EnumAttributeValidator.new('String', [\"copy\", \"move\", \"erase\", \"scan\", \"rehydratation\", \"format\", \"check_consistency\", \"duplication\", \"cache_cleaning\", \"ejection\", \"get_index\", \"full_backup\", \"incremental_backup\"])\n return false unless workflow_action_validator.valid?(@workflow_action)\n source_type_validator = EnumAttributeValidator.new('String', [\"container\", \"primary_nas\", \"secondary_nas\", \"primary_cloud\", \"secondary_cloud\", \"secondary_tape\"])\n return false unless source_type_validator.valid?(@source_type)\n destination_type_validator = EnumAttributeValidator.new('String', [\"container\", \"primary_nas\", \"secondary_nas\", \"primary_cloud\", \"secondary_cloud\", \"secondary_tape\"])\n return false unless destination_type_validator.valid?(@destination_type)\n status_validator = EnumAttributeValidator.new('String', [\"not_activated\", \"done\", \"in_progress\", \"error\", \"paused\", \"stopped_by_system\", \"in_queue\", \"finished_with_warnings\", \"calculating\", \"stopped_by_user\"])\n return false unless status_validator.valid?(@status)\n true\n end",
"def validate(instance)\n if !applicable_type || instance.is_a?(applicable_type)\n validate_instance(instance)\n end\n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n allowed_values = [\"DOCUMENT\", \"FAX\", \"RECORDING\"]\n if @system_type && !allowed_values.include?(@system_type)\n return false\n end\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n allowed_values = [\"SINGLE_PUT\", \"MULTIPART_POST\"]\n if @upload_method && !allowed_values.include?(@upload_method)\n return false\n end\n \n \n \n \n \n \n \n \n \n \n \n \n \n allowed_values = [\"NONE\", \"LIMITED\", \"PUBLIC\"]\n if @sharing_status && !allowed_values.include?(@sharing_status)\n return false\n end\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def valid?\n end",
"def valid?\n end",
"def valid?\n end",
"def valid?\n end",
"def valid?\n return false if @name.nil?\n return false if @value.nil?\n return false if @timestamp.nil?\n return false if @source_id.nil?\n return false if @source_label.nil?\n return false if @source.nil?\n source_validator = EnumAttributeValidator.new('String', [\"IMPORT\", \"API\", \"FORM\", \"ANALYTICS\", \"MIGRATION\", \"SALESFORCE\", \"INTEGRATION\", \"CONTACTS_WEB\", \"WAL_INCREMENTAL\", \"TASK\", \"EMAIL\", \"WORKFLOWS\", \"CALCULATED\", \"SOCIAL\", \"BATCH_UPDATE\", \"SIGNALS\", \"BIDEN\", \"DEFAULT\", \"COMPANIES\", \"DEALS\", \"ASSISTS\", \"PRESENTATIONS\", \"TALLY\", \"SIDEKICK\", \"CRM_UI\", \"MERGE_CONTACTS\", \"PORTAL_USER_ASSOCIATOR\", \"INTEGRATIONS_PLATFORM\", \"BCC_TO_CRM\", \"FORWARD_TO_CRM\", \"ENGAGEMENTS\", \"SALES\", \"HEISENBERG\", \"LEADIN\", \"GMAIL_INTEGRATION\", \"ACADEMY\", \"SALES_MESSAGES\", \"AVATARS_SERVICE\", \"MERGE_COMPANIES\", \"SEQUENCES\", \"COMPANY_FAMILIES\", \"MOBILE_IOS\", \"MOBILE_ANDROID\", \"CONTACTS\", \"ASSOCIATIONS\", \"EXTENSION\", \"SUCCESS\", \"BOT\", \"INTEGRATIONS_SYNC\", \"AUTOMATION_PLATFORM\", \"CONVERSATIONS\", \"EMAIL_INTEGRATION\", \"CONTENT_MEMBERSHIP\", \"QUOTES\", \"BET_ASSIGNMENT\", \"QUOTAS\", \"BET_CRM_CONNECTOR\", \"MEETINGS\", \"MERGE_OBJECTS\", \"RECYCLING_BIN\", \"ADS\", \"AI_GROUP\", \"COMMUNICATOR\", \"SETTINGS\", \"PROPERTY_SETTINGS\", \"PIPELINE_SETTINGS\", \"COMPANY_INSIGHTS\", \"BEHAVIORAL_EVENTS\", \"PAYMENTS\", \"GOALS\", \"PORTAL_OBJECT_SYNC\", \"APPROVALS\", \"FILE_MANAGER\", \"MARKETPLACE\", \"INTERNAL_PROCESSING\", \"FORECASTING\", \"SLACK_INTEGRATION\", \"CRM_UI_BULK_ACTION\", \"WORKFLOW_CONTACT_DELETE_ACTION\"])\n return false unless source_validator.valid?(@source)\n return false if @selected_by_user.nil?\n return false if @selected_by_user_timestamp.nil?\n return false if @source_vid.nil?\n return false if @source_metadata.nil?\n return false if @request_id.nil?\n true\n end",
"def validate\n unless @id.is_a? Integer then\n raise RuntimeError.new( 'flow validation failed: id must be an Integer' )\n end\n unless TrueClass === @obsolete || FalseClass === @obsolete then\n puts \"obsolete: #{ @obsolete.class }\"\n raise RuntimeError.new( 'flow validation failed: obsolete must be true or false ')\n end\n unless @target_task_id.is_a? Integer then\n raise RuntimeError.new( 'flow validation failed: target_task_id must be an Integer' )\n end\n unless @source_task_id.is_a? Integer then\n raise RuntimeError.new( 'flow validation failed: target_task_id must be an Integer' )\n end\n unless @status_id.is_a? Integer then\n raise RuntimeError.new( 'flow validation failed: status_id must be an Integer' )\n end\n end",
"def valid?\n return false if @type.nil?\n type_validator = EnumAttributeValidator.new('String', [\"alert\", \"notification\"])\n return false unless type_validator.valid?(@type)\n priority_validator = EnumAttributeValidator.new('String', [\"P1\", \"P2\", \"P3\", \"P4\", \"P5\"])\n return false unless priority_validator.valid?(@priority)\n return true\n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def validate(*args, &block)\n end",
"def valid?(*args)\n super(:create)\n end",
"def validate(&block)\n if block\n @validate = block\n else\n @validate\n end\n end",
"def validate_params\n validate_size\n validate_mine_density\n validate_first_click\n type_specific_checks\n end"
] |
[
"0.6746783",
"0.6337037",
"0.62817955",
"0.62786585",
"0.6133059",
"0.6133059",
"0.6084968",
"0.6062485",
"0.60308945",
"0.60270345",
"0.60270345",
"0.59943277",
"0.59943277",
"0.59943277",
"0.59571874",
"0.5942148",
"0.5942148",
"0.5942148",
"0.5942148",
"0.594166",
"0.59253347",
"0.59019387",
"0.59019387",
"0.5898607",
"0.5898607",
"0.5898607",
"0.5883427",
"0.5876242",
"0.58642906",
"0.5858965",
"0.58379215",
"0.5827998",
"0.5819663",
"0.5819663",
"0.5819663",
"0.5819435",
"0.5808785",
"0.57972884",
"0.579147",
"0.57871395",
"0.5786138",
"0.5786138",
"0.57752275",
"0.57752275",
"0.57752275",
"0.57752275",
"0.57752275",
"0.57572716",
"0.57561874",
"0.57489073",
"0.57425207",
"0.57388115",
"0.573094",
"0.5720669",
"0.571825",
"0.5702106",
"0.57011104",
"0.56983715",
"0.5697841",
"0.5692078",
"0.56895244",
"0.5673458",
"0.56661",
"0.56658274",
"0.5661252",
"0.56608176",
"0.5654573",
"0.5653568",
"0.56373084",
"0.563642",
"0.56304306",
"0.5628466",
"0.56279635",
"0.5616894",
"0.56119406",
"0.5601024",
"0.5598776",
"0.5598776",
"0.5589285",
"0.5576975",
"0.557237",
"0.5567076",
"0.556654",
"0.5555894",
"0.55522466",
"0.55492353",
"0.5532315",
"0.5532283",
"0.55304515",
"0.55304515",
"0.55304515",
"0.55304515",
"0.5530424",
"0.54941505",
"0.5492614",
"0.5471169",
"0.5465491",
"0.5463939",
"0.54563016",
"0.5443019"
] |
0.62345374
|
4
|
Call whitelisted? to verify the the topic and task are legit.
|
def check_whitelist(spark, options)
begin
whitelisted?(spark, options) ? true : (raise ArgumentError.new("Illegal argument in topic or task"))
rescue => e
reject_spark spark, e
false
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def whitelisted?(spark, options)\n valid_topic?(spark, options) && valid_task?(spark, options)\n end",
"def whitelisted?(request)\n false\n end",
"def can_be_blacklisted?\n !self.blacklisted?\n end",
"def task_available\n return unless task\n\n validate_task_has_no_pending\n validate_task_has_no_approved\n end",
"def blacklisted?(request)\n false\n end",
"def drop_topic_allowed?(dd)\n dd.deadline_type_id == DeadlineHelper::DEADLINE_TYPE_DROP_TOPIC\n end",
"def white_listed\n @white_listed ||= []\n end",
"def validate_tasks\n validated = false\n if tasks_completed?\n validated = tasks_completed!\n end\n\n validated\n end",
"def valid?\n @hydra.queue(request('verify'))\n end",
"def verify( *suspect_words )\n\t\tsuspect_words.flatten.sort == @banned_words\n\tend",
"def check_permission\n # Check if user is signed in\n signed_in_user\n \n if (params[:topic_id]).nil?\n topic = Post.find(params[:id]).topic\n else\n topic = Topic.find(params[:topic_id])\n end\n\n # Admins have unlimited power\n if !current_user_is_admin?\n # Moderators have unlimited power in their boards\n if !current_user_is_moderator?(topic.board)\n\n # Check that user has the required rank to post in the board\n if !topic.board.required_rank.nil?\n req_rank = Rank.find(topic.board.required_rank)\n unless current_user.rank >= req_rank\n flash[:alert] = \"You do not have the required rank for that board.\" \n redirect_to topic\n return\n end\n end\n\n # Check if the board is unlocked\n if topic.board.locked?\n flash[:alert] = \"That board is currently locked.\"\n redirect_to topic\n return\n end\n\n # Check if the topic is unlocked\n if topic.locked?\n flash[:alert] = \"That topic is currently locked.\" \n redirect_to topic\n return\n end\n end\n end\n end",
"def can_recover?\n self.lapsed? and not self.blacklisted\n end",
"def whitelist_users?\n self.whitelist_users.any?\n end",
"def sanity_check_registered_vps\n registered_vps = []\n under_quarantine = []\n ProbeController.issue_to_controller do |controller|\n registered_vps = controller.hosts.clone\n under_quarantine = controller.under_quarantine.clone\n end\n\n if registered_vps.empty?\n Emailer.isolation_warning(\"No VPs are registered with the controller!\").deliver\n elsif Set.new(under_quarantine) == Set.new(registered_vps)\n Emailer.isolation_warning(\"All VPs are quarentined!\").deliver\n end\n\n registered_vps\n end",
"def check_use\r\n if !(params[:id]).nil?\r\n if !((Team.find_by_id(TodoList.find_by_id(params[:id]).team_id).users).include?(current_user))\r\n redirect_to frontend_root_path,\r\n notice: \"You cannot see Todo List\"\r\n end\r\n end\r\n end",
"def is_blacklisted?\n errors.add(:url, \"is blacklisted\") if BlacklistUrl.is_listed?(self.url)\n end",
"def verify( *suspect_words )\n suspect_words.flatten.sort == @banned_words\n end",
"def watches?(task_list)\n watched_task_lists.include?(task_list)\n end",
"def verify( *suspect_words )\n suspect_words.flatten.sort == @banned_words\n end",
"def has_topics?\n !self.topics.empty?\n end",
"def list_checker(checklist)\n\t\tif checklist.include?(\"bananas\") #using include? inbuilt method to get true/false for the existence of banana string within the array\n\t\t\tp \"You don't need to pick up bananas today\"\n\t\telse \n\t\t\tp \"You need to pick up bananas\"\n\t\t\tend\nend",
"def whitelisted?\n\n # Initialise method variables\n result = false\n\n # Setup the options to call the verify endpoint to see if this installation\n # has been whitelisted or not\n options = build_options\n\n # Set the data in the options\n options[:body] = {\n \"subscription_id\": new_resource.subscription_id,\n \"automate_licence\": new_resource.license,\n }\n\n @headers = {\n \"x-functions-key\": new_resource.apikey\n }\n options[:headers] = @headers\n\n # Configure the url that needs to be accessed\n url = format('%s/verify', new_resource.url)\n\n # Make the call\n response = make_request('post', url, [200, 401, 404], options)\n\n if response[:status_code] == 401\n log 'Unauthorised access to central functions' do\n level :warn\n end\n end\n\n # Use the status code to determine if the workspace id and key have been returned\n result = response[:data] if response[:status_code] == 200\n\n result\n\n end",
"def validate_create(topic)\n true\n end",
"def can_create_forem_topics? forum\n true\n end",
"def blacklisted?\n self.friendship_status == BLACKLISTED\n end",
"def has_topic\n !@topic.nil?\n end",
"def has_topic\n !@topic.nil?\n end",
"def allot_topic_to_user_if_possible(assignment_id, signed_up_user_entry,topic,current_max_slots)\n high_prio_topics = is_other_topic_of_higher_priority(assignment_id,signed_up_user_entry.creator_id,signed_up_user_entry.preference_priority_number,current_max_slots)\n if(high_prio_topics == false)\n current_max_slots[topic.id] = current_max_slots[topic.id] -1\n signed_up_user_entry.update_attribute('is_waitlisted',0)\n participant = Participant.find_by_user_id_and_parent_id(Team.find(signed_up_user_entry.creator_id).users[0].id, assignment_id)\n participant.update_topic_id(topic.id)\n delete_other_bids(assignment_id, signed_up_user_entry.creator_id)\n return true\n end\n return false\nend",
"def has_topic?\n ! (topic.nil? || topic_name.nil?)\n end",
"def validate_whitelisting_process\n return error_with_data(\n 'uaj_2',\n \"Client Whitelisting information is inactivated. Please contact Ost team.\",\n \"Client Whitelisting information is inactivated. Please contact Ost team.\",\n GlobalConstant::ErrorAction.default,\n {}\n ) if get_client_whitelist_detail_obj.nil?\n\n # Check if client whitelisting is running or not\n unless get_client_whitelist_detail_obj.no_suspension_type?\n error_msg = \"Whitelisting or unWhitelisting is not happening at the moment. \"\n error_msg += \"Whitelister eth balance is low.\" if get_client_whitelist_detail_obj.low_balance_suspension_type?\n\n return error_with_data(\n 'uaj_3',\n \"#{error_msg} Please try after sometime.\",\n \"#{error_msg} Please try after sometime.\",\n GlobalConstant::ErrorAction.default,\n {}\n )\n end\n\n # todo: This validation has also been done before enqueue.\n KycWhitelistLog.where(client_id: @client_id, ethereum_address: @ethereum_address).all.each do |kwl|\n\n if (GlobalConstant::KycWhitelistLog.kyc_whitelist_confirmation_pending_statuses.include?(kwl.status))\n return error_with_data(\n 'uaj_1',\n \"Waiting for KYC Whitelist Confirmation. Please try after sometime!\",\n \"Waiting for KYC Whitelist Confirmation. Please try after sometime!\",\n GlobalConstant::ErrorAction.default,\n {}\n )\n end\n\n end\n\n success\n end",
"def tasks_are_active_and_permitted\n self.tasks.all.each do | task |\n errors.add( :base, \"Task '#{ task.augmented_title }' is no longer active and cannot be included\" ) unless task.active\n\n if ( self.user.try( :restricted? ) )\n errors.add( :base, \"Inclusion of task '#{ task.augmented_title }' is no longer permitted\" ) unless self.user.task_ids.include?( task.id )\n end\n end\n end",
"def herbalizable?(param)\n whitelisted?(param) && !blacklisted?(param)\n end",
"def check!\n if @activity.valid?\n @activity.schedule_for_review!\n # Idnet::Core::Activity::SpamCheckServiceConnection.new(@activity).spam?.tap do |spam_check_result|\n # case spam_check_result\n # when true\n # @activity.schedule_for_review!\n # when false\n # @activity.mark_as_not_spam!\n # end\n # end\n end\n end",
"def tasks?\n tasks.summary.items?\n end",
"def can_modify_scrap_topic?\n return (admin? or @scrap_topic.scraps.length == 0 or (logged_in? and @scrap_topic.user_id == current_user.id))\n end",
"def in_whitelist?(chan)\n return @whiteList.include?(chan.downcase) if whitelist?\n true\n end",
"def can_moderate_topics?\n can?(:move_topics) || \n can?(:lock_topics) ||\n can?(:merge_topics) ||\n can?(:split_topics) ||\n can?(:sticky_topics)\n end",
"def can_use?(token:, count:)\n check_token_count(token, count)\n\n publish(:fail, @errors) if @errors.any?\n\n @errors.empty?\n end",
"def valid_task?(spark, _options)\n return true if spark[:task].nil? || hsdq_authorized_tasks.empty?\n hsdq_authorized_tasks.include?(spark[:task].to_sym)\n end",
"def permission_for_task?( task )\n tasklist.present? && tasklist.split(',').map{ |v| Integer(v) }.include?( task )\n end",
"def valid_test_taking()\n if current_user.tenant.pricing_plan.plan_group == \"assessment_only_plan\" then\n if current_user.tenant.remaining_learner_credit > 0 then\n return true\n else\n return false\n end\n else\n return true\n end\n end",
"def check_mixed_resources\n end",
"def can_read_forem_topic? topic\n true\n end",
"def is_denied?\n (self.denied_feeds.count > 0)\n end",
"def already_thanked?(topic)\n notification = Notification.thanked_by(self.id, topic.id)\n !notification.empty?\n end",
"def whitelisted?(request)\n whitelisters.any? { |name, whitelister| whitelister.matched?(request) }\n end",
"def feedback_can_be_given?\n !has_feedback? && !feedback_skipped?\n end",
"def owned_topic\n unless current_user.id == @topic.user_id\n flash[:alert] = \"Opps! You don't have permission to do that.\"\n end\n end",
"def allowed?(request)\n whitelisted?(request) && !blacklisted?(request) && meets_quota?\n end",
"def test_reject_community\n assert !public_trap_passes?(\"test\")\n assert !public_trap_passes?([\"foo\", \"bar\"])\n assert !public_trap_passes?([])\n end",
"def is_banned?\n self.publishing_state == PublishingState::BANNED\n end",
"def wants_to_subscribe?\n source_is_ffcrm? && has_list?\n end",
"def white_list_check_expire(name_of_list)\n list_check_expire(\"#{WHITE_LIST_NAMED}:#{name_of_list}\")\n end",
"def allowed?\n true\n end",
"def allowed?\n true\n end",
"def checks; end",
"def show\n authorize @publishers_test\n end",
"def verify_org_task_unique\n true\n end",
"def test_accept_community\n assert public_trap_passes? \"public\"\n assert public_trap_passes? [\"test\", \"public\"]\n assert public_trap_passes? nil\n end",
"def authorized_to_modify_task?\n current_user.site_admin? || can_view_all_manuscript_managers_for_journal? || can_view_manuscript_manager_for_paper? ||\n allowed_manuscript_information_task? || metadata_task_collaborator? || allowed_reviewer_task? || task_participant?\n end",
"def excluding_topics_list\n names_string(self.excludes_topics)\n end",
"def blocked?(subscriber)\n false\n end",
"def validate_maillist\n listname = params[:maillist]\n\n valid = maillist_is_valid? listname\n is_member = valid && maillist_members(params[:maillist]).include?(@current_user.pseudonym.unique_id.split('@')[0])\n\n if !valid\n payload = { valid_maillist: false, reason: \"#{params[:maillist]} is not a valid SFU Maillist\" }\n elsif !is_member\n payload = { valid_maillist: false, reason: \"You are not a member of #{params[:maillist]}. You must be a member of a list to add it to your Space.\" }\n else\n payload = { valid_maillist: true }\n end\n\n render json: payload, status: :ok\n end",
"def check!\n true\n end",
"def accept_checklist(filename)\n return $marathon_trace_func.acceptChecklist(filename)\nend",
"def claimed_chore?\n tasks.where(completion_status: \"pending\").count > 0\n end",
"def is_whitelisted?(address)\n !!(self.class.safetynet_options[:whitelist].match(address))\n end",
"def allowed?; true end",
"def check_config\n %w(token).each do |param|\n (usage and return false) if Weechat.get_plugin_config(param).to_s.empty?\n end\n true\nend",
"def check_status(payload)\n # get login of user who set status\n sender = payload.sender.login\n commit = payload.commit.sha\n\n # determine if user who set status is in whitelist\n if WHITELIST.include? sender\n puts \"Status set by trusted user \\\\o/\"\n else\n puts \"WARNING! Status set by untrusted user #{sender}\"\n puts \"Status changed for commit #{commit}\"\n end\nend",
"def can_publish?\n !user.discourse_username.empty?\n end",
"def check\n \n end",
"def check\n \n end",
"def tasks_have_failed?\n return true if @tasks_have_failed\n failed = select do |task|\n task.failed?\n end\n if failed.any?\n debug \"Found failed tasks: #{failed.map { |t| t.name }.join ', '}\"\n @tasks_have_failed = true\n end\n failed.any?\n end",
"def check_tweet_for_user\n if @tweet.user_id != current_user.id\n flash[:notice] = \"Not allowed!\"\n redirect_to tweets_url\n return\n end\n end",
"def check_authorization\n @can_edit = can_blank_timetable?('edit')\n @can_show = can_blank_timetable?('show')\n end",
"def accept_checklist(filename)\n return $marathon_trace_func.acceptChecklist(filename)\nend",
"def allowed?\n true\n end",
"def enabled_checks; end",
"def test_waistlisted_nonmember\n\t\tnon_member = enrollments(:non_member_two)\n\t\texpected = 1\n\t\tassert_equal expected, non_member.waitlist_status, \"Supposedly waitlisted non member is not waitlisted\"\n\tend",
"def allow_free_trial\n result = Spreedly.post(\"/subscribers/#{id}/allow_free_trial.xml\")\n\n case result.code.to_s\n when /2../\n else\n raise \"Could not allow subscriber to another trial: result code #{result.code}.\"\n end\n end",
"def agent_should_start?\n !blacklisted_constants? &&\n !blacklisted_executables? &&\n !in_blacklisted_rake_task?\n end",
"def check(params)\n false\n end",
"def wish_list?\n !leveled? && !sharded?\n end",
"def allowed?\n allowed\n end",
"def can_accept_showing?\n profile.valid? && valid_bank_token? && !blocked?\n end",
"def allowed?(*_)\n true\n end",
"def allow?(item)\n @whitelist.include?(item) || !@blacklist.include?(item)\n end",
"def allowed?\n stream.config.allowed?(validate_to || stream.domain, stream.user.jid)\n end",
"def check_default_check_list\n if too_big_for_check_list? && !prefers_check_lists && check_list\n delay(:priority => USER_INTEGRITY_PRIORITY).remove_default_check_list\n end\n if too_big_for_check_list?\n self.prefers_check_lists = false\n end\n if prefers_check_lists && check_list.blank?\n self.create_check_list(:place => self)\n save(:validate => false)\n unless check_list.valid?\n Rails.logger.info \"[INFO] Failed to create a default check list on \" + \n \"creation of #{self}: \" + \n check_list.errors.full_messages.join(', ')\n end\n end\n true\n end",
"def run?(blacklist, whitelist)\n ((@address.scheme == 'http') || (@address.scheme == 'https')) && (!match?(blacklist) || match?(whitelist))\n end",
"def can_accept?(task)\n # logger.info(\n # puts \"can_accept : task = #{task.inspect}, name = #{self.name}\"\n return false if task.nil?\n return false if (self.name.eql?('localhost'))\n # status may change, so need to check\n # look at state and status \n node_state = NodeState.where(id: self.state_id).first\n #TODO handle different node types ?\n can_run = false\n # puts \"NODE state name = #{node_state.name}\"\n case node_state.name\n # HACK HACK HACK\n when 'idle', 'ready', 'pipeline_task'\n # when 'idle', 'ready', 'pipeline_task', 'updating'\n can_run = true\n end\n if ( can_run ) \n # NOTE: you could look at node_type and get number of cpus and memory to calculate max num jobs ...\n # 12/6/2012 - temporarily limited the max number of jobs to 4 to control process\n # collisions. \n if ((task.is_exclusive? && self.num_jobs > 1) || (self.num_jobs > 4) )\n can_run = false \n end\n end\n # puts \"Can_run? self.num_jobs=#{self.num_jobs} #{can_run}\"\n if ( can_run ) \n reqs = task.requirements\n # logger.warn(\"can_accept : requirements = #{reqs.inspect}\")\n can_run = true \n if ( !reqs.nil? )\n reqs.each do |req|\n # logger.warn(\"can_accept : req = #{req.inspect}\")\n if (!req.node_meets(self))\n can_run = false \n # logger.warn(\"can_accept : failed at req = #{req.inspect}\")\n\t # puts \"can_accept : failed at req = #{req.inspect}\"\n break\n end\n end\n end\n end\n # TODO: max num_jobs ?\n # TODO: look at load average\n # TODO: look at memory / swap etc\n # TODO: look at node and job \"type\" ? \n # TODO: idl ?\n # logger.warn(\"can_accept : result = #{can_run.inspect}\")\n return can_run\n end",
"def authorized?(task_context)\n # If there is no rule, action is unauthorized\n return false if @allow_if.empty?\n\n # else, check all rules and return false if any of them did not return true\n # do not check all rules if unnecessary\n @allow_if.each do |rule|\n return false if rule.call(task_context) != true\n end\n\n true\n end",
"def slotAvailable?(topic_id)\n SignUpTopic.slotAvailable?(topic_id)\n end",
"def slotAvailable?(topic_id)\n SignUpTopic.slotAvailable?(topic_id)\n end",
"def slotAvailable?(topic_id)\n SignUpTopic.slotAvailable?(topic_id)\n end",
"def verify_unpublished_access\n unless resource.published || (!resource.published && logged_in? && current_user.send(pluralized_name).exists?(resource.id))\n render json: ErrorSerializer.serialize(resource_name => \"is invalid\"), status: 422 and return false\n end\n true\n end",
"def check_listing\n unless @listing.context == :listing\n warn block: @listing, message: <<~LOG.strip\n #{LAYOUT_DESCRIPTION} but the first block was a #{@listing.context}.\n LOG\n return false\n end\n\n validate_listing_langauge\n end",
"def check_approved\n redirect_to animals_path, notice: \"Your account is not yet approved, you can't list an animal.\" if !current_user&.approved?\n end",
"def whitelist\n config[\"whitelist\"]\n end"
] |
[
"0.65914893",
"0.6058476",
"0.60472053",
"0.6020961",
"0.5945337",
"0.58393544",
"0.5823831",
"0.57127124",
"0.5674508",
"0.56393725",
"0.56154907",
"0.56102693",
"0.5594485",
"0.5544983",
"0.5516038",
"0.55117995",
"0.5505832",
"0.54988116",
"0.5498231",
"0.5495662",
"0.54859865",
"0.54798007",
"0.54511315",
"0.5444669",
"0.5442904",
"0.54395926",
"0.54395926",
"0.54353654",
"0.5432029",
"0.5426397",
"0.5415285",
"0.5409158",
"0.54049027",
"0.5393567",
"0.5391627",
"0.53855926",
"0.5380362",
"0.53664",
"0.5359185",
"0.53511375",
"0.5336635",
"0.53362346",
"0.53331316",
"0.53229487",
"0.53182316",
"0.52895314",
"0.52727324",
"0.5269279",
"0.52643025",
"0.52583396",
"0.5246845",
"0.5239797",
"0.5228102",
"0.5221318",
"0.5221318",
"0.522079",
"0.5219505",
"0.5209448",
"0.52074564",
"0.520483",
"0.5202234",
"0.52003664",
"0.5196095",
"0.51909363",
"0.51813555",
"0.517703",
"0.5174645",
"0.51705015",
"0.51681495",
"0.5166833",
"0.51639396",
"0.5163406",
"0.5163406",
"0.51594067",
"0.5157522",
"0.5154063",
"0.51529163",
"0.5152427",
"0.5135765",
"0.5132774",
"0.5129881",
"0.5129206",
"0.51264435",
"0.5124088",
"0.51194566",
"0.5117644",
"0.5117076",
"0.511703",
"0.5114611",
"0.511095",
"0.5109943",
"0.5106973",
"0.510334",
"0.51024425",
"0.51024425",
"0.51024425",
"0.50978625",
"0.50919586",
"0.5091208",
"0.50843936"
] |
0.6660271
|
0
|
validate the topic and the task
|
def whitelisted?(spark, options)
valid_topic?(spark, options) && valid_task?(spark, options)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def validate_create(topic)\n true\n end",
"def validate_topic\n errors.add(:topic_id, 'Topic not presence') if Topic.find_by_id( self[:topic_id] ) == nil\n end",
"def validate_topic_input(forum, subject, message)\n raise Impostor::TopicError.new(\"forum not set\") unless forum\n raise Impostor::TopicError.new(\"subject not set\") unless subject\n raise Impostor::TopicError.new(\"message not set\") unless message\n true\n end",
"def task_available\n return unless task\n\n validate_task_has_no_pending\n validate_task_has_no_approved\n end",
"def validate_tasks\n validated = false\n if tasks_completed?\n validated = tasks_completed!\n end\n\n validated\n end",
"def validate\n unless TrueClass === @obsolete or FalseClass === @obsolete then\n raise RuntimeError.new( 'task validation failed: obsolete must be true or false ')\n end\n unless @id.is_a? Integer then\n raise RuntimeError.new( 'task validation failed: id must be an Integer' )\n end\n unless @role_id.is_a? Integer or @role_id.nil? then\n raise RuntimeError.new( 'task validation failed: role_id must be nil or an Integer' )\n end\n unless @label.is_a? String then\n raise RuntimeError.new( 'task validation failed: label must be a String' )\n end\n unless @inflows.is_a? Array then\n raise RuntimeError.new( 'task validation failed: incoming flows must be an Array' )\n else\n @inflows.each do |f|\n unless f.is_a? WorkFlowFlow\n raise RuntimeError.new( 'task validation failed: an incoming flow is not a WorkFlowFlow' )\n end\n end\n end\n unless @outflows.is_a? Array then\n raise RuntimeError.new( 'task validation failed: outgoing flows must be an Array' )\n else\n @outflows.each do |f|\n unless f.is_a? WorkFlowFlow\n raise RuntimeError.new( 'task validation failed: an outgoing flow is not a WorkFlowFlow' )\n end\n end\n end\n end",
"def valid?\n run_validations!\n true\n rescue InvalidTaskError => e\n false\n end",
"def are_task_basic_fields_valid?(node)\n err = []\n\n err << \"Task status provided '#{node['task_status']}' is not supported\" if\n !valid_task_status?(node['task_status'])\n err << \"Task name is not provided\" if node['deployment_graph_task_name'].blank?\n\n err.any? ? fail_validation(node, err) : true\n end",
"def are_task_basic_fields_valid?(node)\n err = []\n\n err << \"Task status provided '#{node['task_status']}' is not supported\" if\n !valid_task_status?(node['task_status'])\n err << \"Task name is not provided\" if node['deployment_graph_task_name'].blank?\n\n err.any? ? fail_validation(node, err) : true\n end",
"def validate_for_transcription!\n if transcript_id\n raise \"This source has already been submitted for transcription.\"\n elsif self.platform\n raise \"Not a valid platform: #{self.platform}\" unless VALID_PLATFORMS.includes?(self.platform)\n raise \"This is an invalid platform source. Please specify a video_id\" unless video_id\n elsif self.url\n # TODO: validate url format\n # raise \"Not a valid url: #{self.url}\" unless # check here\n else\n raise \"This is an invalid source. Please specify a platform or url.\"\n end\n return true\n end",
"def validate_check_scheduling(check)\n must_be_boolean_if_set(check[:publish]) ||\n invalid(check, \"check publish must be boolean\")\n unless check[:publish] == false\n if check[:cron]\n validate_check_cron(check)\n else\n (must_be_an_integer(check[:interval]) && check[:interval] > 0) ||\n invalid(check, \"check interval must be an integer greater than 0\")\n end\n end\n must_be_boolean_if_set(check[:standalone]) ||\n invalid(check, \"check standalone must be boolean\")\n unless check[:standalone]\n if is_an_array?(check[:subscribers])\n items_must_be_strings(check[:subscribers]) ||\n invalid(check, \"check subscribers must each be a string\")\n else\n invalid(check, \"check subscribers must be an array\")\n end\n end\n end",
"def validate_task(task, instance, options)\n if instance.try(:ext_management_system)&.zone&.maintenance?\n task.error(\"#{instance.ext_management_system.name} is paused\")\n return false\n end\n\n return true unless options[:task] == \"retire_now\" && instance.retired?\n task.error(\"#{instance.name} is already retired\")\n false\n end",
"def validate_format(task_name, reference_key, klass)\n (tasks[task_name][reference_key].nil? || tasks[task_name][reference_key].is_a?(klass))\n end",
"def define_task_validate(*args)\n desc 'Validate the git urls and branches, refs, or tags'\n task :validate do\n gitvalididation = Ra10ke::Validate::Validation.new(get_puppetfile.puppetfile_path)\n exit_code = 0\n if gitvalididation.bad_mods?\n exit_code = 1\n message = BAD_EMOJI + ' Not all modules in the Puppetfile are valid. '.red + BAD_EMOJI\n else\n message = GOOD_EMOJI + ' Puppetfile looks good. '.green + GOOD_EMOJI\n end\n tp gitvalididation.sorted_mods, :name, { url: { width: 50 } }, :ref, :status\n abort(message) if exit_code.positive?\n puts message\n end\n end",
"def validate_post_input(forum, topic, message)\n raise Impostor::PostError.new(\"forum not set\") unless forum\n raise Impostor::PostError.new(\"topic not set\") unless topic\n raise Impostor::PostError.new(\"message not set\") unless message\n true\n end",
"def validate\n return unless events\n\n events.each_key do |event_name|\n publish_operation_name = publish_operation_name_for(event_name)\n\n logger.debug \"#{self}#validate find publish operation for: #{publish_operation_name}\"\n publish_operation = find_publish_operation_for(publish_operation_name)\n\n if publish_operation\n logger.debug \"#{self}#validate found publish operation for: #{publish_operation_name}\"\n else\n logger.error \"\\n *******\\n #{self}#validate unable to find publish operation for: #{publish_operation_name}\\n *******\"\n end\n end\n end",
"def verify_org_task_unique\n true\n end",
"def check_error\n if @errors.empty?\n false\n else\n @log.error(@taskname) { \"--- Configuration for #{@taskname} ---\" }\n @doc.each do |doc|\n @log.error(@taskname) { \"#{doc}\" }\n end\n @log.error(@taskname) { \"--- Errors found for #{@taskname} ---\" }\n @errors.each do |error|\n @log.error(@taskname) { \" #{error}\" }\n end\n @log.fatal(@taskname) { 'terminated' }; exit\n end\n end",
"def check_emission_validity # :nodoc:\n if (error = super)\n refine_emit_exception(error)\n else\n task.check_emission_validity(self)\n end\n end",
"def validate\n unless @id.is_a? Integer then\n raise RuntimeError.new( 'flow validation failed: id must be an Integer' )\n end\n unless TrueClass === @obsolete || FalseClass === @obsolete then\n puts \"obsolete: #{ @obsolete.class }\"\n raise RuntimeError.new( 'flow validation failed: obsolete must be true or false ')\n end\n unless @target_task_id.is_a? Integer then\n raise RuntimeError.new( 'flow validation failed: target_task_id must be an Integer' )\n end\n unless @source_task_id.is_a? Integer then\n raise RuntimeError.new( 'flow validation failed: target_task_id must be an Integer' )\n end\n unless @status_id.is_a? Integer then\n raise RuntimeError.new( 'flow validation failed: status_id must be an Integer' )\n end\n end",
"def validate!\n validate_redis\n validate_workers\n validate_options\n end",
"def validate!\n # pass\n end",
"def validate_check(check)\n validate_check_name(check)\n validate_check_execution(check)\n validate_check_source(check) if check[:source]\n validate_check_scheduling(check)\n validate_check_proxy_requests(check) if check[:proxy_requests]\n validate_check_handling(check)\n validate_check_ttl(check) if check[:ttl]\n validate_check_aggregate(check)\n validate_check_flap_detection(check)\n validate_check_hooks(check) if check[:hooks]\n validate_check_truncate_output(check)\n validate_check_subdue(check) if check[:subdue]\n end",
"def has_topic?\n ! (topic.nil? || topic_name.nil?)\n end",
"def test_presence\n task = Task.new\n assert !task.valid?\n assert_equal @@error[:blank], task.errors.on(:date)\n assert_equal @@error[:blank], task.errors.on(:job_id)\n assert_equal @@error[:blank], task.errors.on(:minutes)\n end",
"def test_import_with_validations_that_fail\n columns = [ 'title' ]\n values = [['LDAP'],['Rails Recipes']] # missing author names, these should fail\n\n # these should fail, so we should end up with the same count for Topics\n expected_count = Topic.count\n result = Topic.import( columns, values, :validate=>true )\n invalid_topics = result.failed_instances\n \n assert_equal expected_count, Topic.count\n assert_equal values.size, invalid_topics.size\n invalid_topics.each{ |e| assert_kind_of Topic, e }\n end",
"def validate!(t)\n # None.\n end",
"def validate_presence_of_reference_tasks(task_name, reference_key, klass)\n task_names = (tasks[task_name][reference_key] || klass.new)\n task_names = task_names.keys if klass.eql?(Hash)\n task_names.all? { |t_name| tasks[t_name].is_a?(Hash) }\n end",
"def _validate_task(object, task) #:nodoc:\n klass = object.is_a?(Class) ? object : object.class\n raise \"Expected Thor class, got #{klass}\" unless klass <= Thor::Base\n\n task ||= klass.default_task if klass <= Thor\n task = klass.all_tasks[task.to_s] || Thor::Task::Dynamic.new(task) if task && !task.is_a?(Thor::Task)\n task\n end",
"def has_topic\n !@topic.nil?\n end",
"def has_topic\n !@topic.nil?\n end",
"def test_should_be_invalid\n task = Task.create\n assert !task.valid?, \"Task shouldn't be created\"\n end",
"def create_if_necessary!\n if topic.blank?\n @topic = pubsub.create_topic(topic_name).tap do |topic|\n raise error, \"Unable to create topic #{topic_name}\" if topic.nil?\n end\n end\n\n @subscription = @topic.find_subscription(subscription_name) || @topic.create_subscription(subscription_name)\n @subscription.tap do |subscription|\n raise Error, \"Unable to create subscription #{subscription_name}\" if subscription.nil?\n\n # Default subscription expiry is 31 days. We want none of that.\n subscription.expires_in = nil unless pubsub.project_id == EMULATOR.fetch(:project_id)\n end\n end",
"def validate\n \n \n end",
"def validate_todo_data(todo_data)\n ##----------------\n ## Required values\n ##----------------\n required = %i{ todo_base\n source\n workspace\n compressed_destination\n glacier_description\n glacier_vault\n application\n method\n }\n missing = required.select { |key| todo_data[key].to_s.strip.empty? }.map(&:inspect)\n raise \"Required todo values missing: #{missing.join(', ')}\" unless missing.empty?\n\n ##------------------------------------\n ## Verify compressed archived checking\n ##------------------------------------\n verify = todo_data[:verify_compressed_archive].to_s.strip.downcase\n return if ['', 'false'].include?(verify) # No verification to do; end validation\n # We have a non-false verify value; unless it's 'true', it's not a valid value.\n raise \":verify_compressed_archive must be '', 'true'. or 'false'; got: '#{verify}'\" unless verify == 'true'\n\n # ':verify_compressed_archive' is true; make sure :verification_destination\n # is defined.\n if todo_data[:verification_destination].to_s.strip.empty?\n raise \"':verification_destination' must be supplied if ':verify_compressed_archive' is 'true'\"\n end\n\n end",
"def define\n task :validate\n\n namespace :scm do\n task :push => :validate do\n status \"Pushing commits ...\"\n\n unless push!\n error \"Could not push commits\"\n end\n end\n end\n end",
"def validate_config\n # if @cfg.keys != [:user]\n unless @cfg.has_key?( :user )\n raise TaskConfigError.new \"Top level keys needs to contain 'user'\"\n end\n if (@cfg[:user].keys <=> [:collections, :works]) < 1\n raise TaskConfigError.new \"user can only contain collections and works\"\n end\n end",
"def validate\n raise ValidationError, \"Subject is required\" if subject.nil?\n end",
"def valid_for_publish\n\t\tvalid = true\n \tif structural_set.nil?\n \t\terrors << \"Structural Set> Error: No set selected\"\n\t\t\tvalid = false\n \tend\n\t\tvalid\n \tend",
"def drop_topic_allowed?(dd)\n dd.deadline_type_id == DeadlineHelper::DEADLINE_TYPE_DROP_TOPIC\n end",
"def validate!\n raise Errors::Worker, 'Queue threads must be an Integer.' unless @queue_threads.is_a?(Integer)\n raise Errors::Worker, 'Retry threads must be an Integer.' unless @retry_threads.is_a?(Integer)\n end",
"def validate_task(task, instance, options)\n return true unless options[:task] == \"retire_now\" && instance.retired?\n task.error(\"#{instance.name} is already retired\")\n false\n end",
"def validate_new_topic_result(page)\n raise Impostor::MissingTemplateMethodError.new(\"validate_new_topic_result must be implemented\")\n end",
"def create\n topic = SignUpTopic.find_by_topic_name_and_assignment_id(params[:topic][:topic_name], params[:id])\n\n #if the topic already exists then update\n if topic != nil\n topic.topic_identifier = params[:topic][:topic_identifier]\n\n #While saving the max choosers you should be careful; if there are users who have signed up for this particular\n #topic and are on waitlist, then they have to be converted to confirmed topic based on the availability. But if\n #there are choosers already and if there is an attempt to decrease the max choosers, as of now I am not allowing\n #it.\n if SignedUpUser.find_by_topic_id(topic.id).nil? || topic.max_choosers == params[:topic][:max_choosers]\n topic.max_choosers = params[:topic][:max_choosers]\n else\n if topic.max_choosers.to_i < params[:topic][:max_choosers].to_i\n topic.update_waitlisted_users(params[:topic][:max_choosers])\n topic.max_choosers = params[:topic][:max_choosers]\n else\n flash[:error] = 'Value of maximum choosers can only be increased! No change has been made to max choosers.'\n end\n end\n\n topic.category = params[:topic][:category]\n #topic.assignment_id = params[:id] \n topic.save\n redirect_to_sign_up(params[:id])\n else\n @sign_up_topic = SignUpTopic.new\n @sign_up_topic.topic_identifier = params[:topic][:topic_identifier]\n @sign_up_topic.topic_name = params[:topic][:topic_name]\n @sign_up_topic.max_choosers = params[:topic][:max_choosers]\n @sign_up_topic.category = params[:topic][:category]\n @sign_up_topic.assignment_id = params[:id]\n\n @assignment = Assignment.find(params[:id])\n\n if @assignment.staggered_deadline?\n topic_set = Array.new\n topic = @sign_up_topic.id\n\n end\n\n if @sign_up_topic.save\n #NotificationLimit.create(:topic_id => @sign_up_topic.id)\n flash[:notice] = 'Topic was successfully created.'\n redirect_to_sign_up(params[:id])\n else\n render :action => 'new', :id => params[:id]\n end\n end\n end",
"def valid_task?(spark, _options)\n return true if spark[:task].nil? || hsdq_authorized_tasks.empty?\n hsdq_authorized_tasks.include?(spark[:task].to_sym)\n end",
"def validate(filters = %w(ldm, pdm, metric_filter, invalid_objects))\n response = GoodData.post \"#{GoodData.project.md['validate-project']}\", 'validateProject' => filters\n polling_link = response['asyncTask']['link']['poll']\n polling_result = GoodData.get(polling_link)\n while polling_result['wTaskStatus'] && polling_result['wTaskStatus']['status'] == 'RUNNING'\n sleep(3)\n polling_result = GoodData.get(polling_link)\n end\n polling_result\n end",
"def validate\r\n\r\n end",
"def create\n # Read form\n @topic = Topic.new(params[:topic])\n @instance = @topic.course_instance\n @course = @instance.course\n @is_teacher = @course.has_teacher?(current_user)\n\n # Check writing permissions\n #authorize_level @course.feedback_write_permission or return\n authorize! :create, @topic\n\n @topic.moderation_status = (@course.moderate && !@is_teacher && @topic.visibility == 'public') ? 'pending' : 'published'\n @topic.action_status = 'unanswered'\n @topic.nick = 'Anonymous' if @topic.nick.blank?\n\n # User\n if logged_in? && !@topic.anonymous\n #@topic.anonymous = (@topic.nick != current_user.name)\n @topic.user = current_user\n @topic.nick = current_user.name\n end\n\n # Save topic\n unless @topic.save\n flash[:error] = 'Failed to send feedback'\n render :action => \"new\"\n return\n end\n\n if @topic.moderation_status == 'pending'\n flash[:success] = t(:added_to_queue)\n else\n flash[:success] = t(:topic_opened)\n end\n\n # Email notification\n @instance.notify_subscribers_later\n\n redirect_to topic_index_path(@course.code, @instance.path)\n end",
"def validate_settings\n end",
"def check_validity!\n # nothing\n end",
"def validate\n end",
"def event_and_parent_validation\n if parent_id.nil? ^ trigger.nil?\n errors.add(:trigger, ' may be not set unless the Parent Task is specified.') if parent_id.nil?\n errors.add(:parent_id, ' requires a trigger event.') if trigger.nil?\n end\n end",
"def create\n @topic = current_user.topics.new(topic_params)\n if @topic.save\n redirect_to @topic, notice: params[:is_draft]? 'Topic successfully save as draft.': 'Topic successfully published.'\n else\n render 'new'\n end\n end",
"def validate_question params\n\n end",
"def kafka_validator(hash_to_validate)\n kafka_deploy = hash_to_validate[:kafka_deploy]\n if kafka_deploy.nil? or kafka_deploy.empty?\n @log.error \"'kafka_deploy' is required parameter, valid values: hash|disabled\"\n @errors_count += 1\n elsif kafka_deploy == 'disabled'\n @log.debug 'Kafka deployment is disabled' if @debug\n elsif ! kafka_deploy.is_a? Hash\n @log.error \"unrecognized value set for 'kafka_deploy' : #{kafka_deploy}\"\n @errors_count += 1\n end\n\n if hash_to_validate[:install_mode] == 'local'\n if kafka_deploy != 'disabled'\n # kafka_nodes = kafka_deploy[:kafka_nodes]\n # if kafka_nodes.nil? or kafka_nodes.empty?\n # puts '[Error]: '.red + \"'kafka_nodes' should contain list of fqdn(s) on which to install kafka package\"\n # @errors_count += 1\n # elsif ! kafka_nodes.is_a? Array\n # puts '[Error]: '.red + \"Excepting list (array) of nodes for 'kafka_nodes'\"\n # @errors_count += 1\n # end\n kafka_brokers = kafka_deploy[:brokers]\n if kafka_brokers.nil? or kafka_brokers.empty?\n @log.error \"Property 'brokers' of 'kafka_deploy' should contain list of fqdn(s) which act as kafka broker nodes\"\n @errors_count += 1\n elsif ! kafka_brokers.is_a? Array\n @log.error \"Excepting list (array) of fqdn(s) for 'kafka_brokers'\"\n @errors_count += 1\n end\n end\n else # Cloud deploy\n if kafka_deploy != 'disabled'\n collocate = kafka_deploy[:collocate]\n if collocate.nil?\n @log.debug 'Defaulting collocate for kafka'\n hash_to_validate[:kafka_deploy][:collocate] = false \n elsif ! (collocate.is_a? TrueClass or collocate.is_a? FalseClass)\n @log.error \"Invalid value found for 'collocate', valid values are yes|no\"\n @errors_count += 1\n end\n if ! collocate\n number_of_instances = kafka_deploy[:number_of_instances]\n if number_of_instances.nil?\n @log.error \"'number_of_instances' is a required key for kafka_deploy if collocate is disabled\"\n @errors_count += 1\n elsif ! number_of_instances.is_a? Numeric\n @log.error \"expecting numeric value for 'number_of_instances' in kafka_deploy hash\"\n @errors_count += 1\n end\n end\n kafka_brokers_count = kafka_deploy[:number_of_brokers]\n if kafka_brokers_count.nil?\n @log.debug \"'number_of_brokers' is not provided for kafka_deploy defaulting to 1\" if @debug\n hash_to_validate[:kafka_deploy][:number_of_brokers] = 1\n elsif ! kafka_brokers_count.is_a? Numeric\n @log.error \"Expecting numeric value for 'number_of_brokers' in kafka_deploy hash\"\n @errors_count += 1\n end\n end\n end\n end",
"def confirmTopic(creator_id, topic_id, assignment_id, user_id)\n #check whether user has signed up already\n user_signup = otherConfirmedTopicforUser(assignment_id, creator_id)\n\n sign_up = SignedUpUser.new\n sign_up.topic_id = topic_id\n sign_up.creator_id = creator_id\n\n result = false\n if user_signup.size == 0\n\n # Using a DB transaction to ensure atomic inserts\n ActiveRecord::Base.transaction do\n #check whether slots exist (params[:id] = topic_id) or has the user selected another topic\n if slotAvailable?(topic_id)\n sign_up.is_waitlisted = false\n\n #Update topic_id in participant table with the topic_id\n participant = AssignmentParticipant.find_by_user_id_and_parent_id(user_id, assignment_id)\n\n participant.update_topic_id(topic_id)\n else\n sign_up.is_waitlisted = true\n end\n if sign_up.save\n result = true\n end\n end\n else\n #If all the topics choosen by the user are waitlisted,\n for user_signup_topic in user_signup\n if user_signup_topic.is_waitlisted == false\n #TODO flash[:error] = \"You have already signed up for a topic.\"\n return false\n end\n end\n\n # Using a DB transaction to ensure atomic inserts\n ActiveRecord::Base.transaction do\n #check whether user is clicking on a topic which is not going to place him in the waitlist\n if !slotAvailable?(topic_id)\n sign_up.is_waitlisted = true\n if sign_up.save\n result = true\n end\n else\n #if slot exist, then confirm the topic for the user and delete all the waitlist for this user\n SignUpTopic.cancel_all_waitlists(creator_id, assignment_id)\n sign_up.is_waitlisted = false\n sign_up.save\n\n participant = Participant.find_by_user_id_and_parent_id(user_id, assignment_id)\n participant.update_topic_id(topic_id)\n result = true\n end\n end\n end\n\n result\n end",
"def validate_tasks(options)\n tasks = []\n\n instances = base_class.where(:id => options[:ids]).order(\"lower(name)\").to_a\n return instances, tasks unless options[:invoke_by] == :task # jobs will be used instead of tasks for feedback\n\n instances.each do |instance|\n # create a task for each instance\n task = MiqTask.create(:name => \"#{instance.name}: '#{options[:task]}'\", :userid => options[:userid])\n tasks.push(task)\n\n validate_task(task, instance, options)\n end\n return instances, tasks\n end",
"def validate\n validate_action\n validate_deliver_at\n validate_event_id\n\n super\n end",
"def validate; end",
"def validate; end",
"def validate; end",
"def validate; end",
"def validate_consumers!\n return if !options[:topics]\n\n options[:topics].each do |topic, consumer|\n begin\n consumer.constantize\n rescue\n puts \"Couldn't constantize '#{consumer}'! Please check the configuration you've provided.\"\n exit 1\n end\n end\n end",
"def create\n @topic = Topic.new(topic_params)\n if @topic.save\n @topics = Topic.all\n @topic = Topic.new\n @flag = true\n else\n @flag = false\n end\n redirect_to topics_path\n end",
"def validate\r\n @invalid=false\r\n end",
"def can_accept?(task)\n # logger.info(\n # puts \"can_accept : task = #{task.inspect}, name = #{self.name}\"\n return false if task.nil?\n return false if (self.name.eql?('localhost'))\n # status may change, so need to check\n # look at state and status \n node_state = NodeState.where(id: self.state_id).first\n #TODO handle different node types ?\n can_run = false\n # puts \"NODE state name = #{node_state.name}\"\n case node_state.name\n # HACK HACK HACK\n when 'idle', 'ready', 'pipeline_task'\n # when 'idle', 'ready', 'pipeline_task', 'updating'\n can_run = true\n end\n if ( can_run ) \n # NOTE: you could look at node_type and get number of cpus and memory to calculate max num jobs ...\n # 12/6/2012 - temporarily limited the max number of jobs to 4 to control process\n # collisions. \n if ((task.is_exclusive? && self.num_jobs > 1) || (self.num_jobs > 4) )\n can_run = false \n end\n end\n # puts \"Can_run? self.num_jobs=#{self.num_jobs} #{can_run}\"\n if ( can_run ) \n reqs = task.requirements\n # logger.warn(\"can_accept : requirements = #{reqs.inspect}\")\n can_run = true \n if ( !reqs.nil? )\n reqs.each do |req|\n # logger.warn(\"can_accept : req = #{req.inspect}\")\n if (!req.node_meets(self))\n can_run = false \n # logger.warn(\"can_accept : failed at req = #{req.inspect}\")\n\t # puts \"can_accept : failed at req = #{req.inspect}\"\n break\n end\n end\n end\n end\n # TODO: max num_jobs ?\n # TODO: look at load average\n # TODO: look at memory / swap etc\n # TODO: look at node and job \"type\" ? \n # TODO: idl ?\n # logger.warn(\"can_accept : result = #{can_run.inspect}\")\n return can_run\n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def do_activity(task)\n if task.input.nil?\n @results = { :reason => \"Didn't receive any input!\", :detail => \"\" }.to_yaml\n return false\n end\n\n subscription_data = YAML.load(task.input)\n\n # get the SNS topic by using the ARN retrieved from the previous activity,\n # so we can check to see if the user has confirmed the subscription.\n topic = AWS::SNS::Topic.new(subscription_data[:topic_arn])\n\n if topic.nil?\n @results = {\n :reason => \"Couldn't get SWF topic ARN\",\n :detail => \"Topic ARN: #{topic.arn}\" }.to_yaml\n return false\n end\n\n # loop until we get some indication that a subscription was confirmed.\n subscription_confirmed = false\n while(!subscription_confirmed)\n topic.subscriptions.each do | sub |\n if subscription_data[sub.protocol.to_sym][:endpoint] == sub.endpoint\n # this is one of the endpoints we're interested in. Is it subscribed?\n if sub.arn != 'PendingConfirmation'\n subscription_data[sub.protocol.to_sym][:subscription_arn] = sub.arn\n puts \"Topic subscription confirmed for (#{sub.protocol}: #{sub.endpoint})\"\n @results = subscription_data.to_yaml\n return true\n else\n puts \"Topic subscription still pending for (#{sub.protocol}: #{sub.endpoint})\"\n end\n end\n end\n\n # send a heartbeat notification to SWF to keep the activity alive...\n task.record_heartbeat!(\n { :details => \"#{topic.num_subscriptions_confirmed} confirmed, #{topic.num_subscriptions_pending} pending\" })\n # sleep a bit.\n sleep(4.0)\n end\n\n # if nothing is confirmed, assume that the user did not authenticate.\n if (subscription_confirmed == false)\n @results = {\n :reason => \"No subscriptions could be confirmed\",\n :detail => \"#{topic.num_subscriptions_confirmed} confirmed, #{topic.num_subscriptions_pending} pending\" }.to_yaml\n return false\n end\n end",
"def task_check_error\n # nochannel job failure should not result in any state changes\n return if is_nochannel?\n\n policies = Push::Policy.policies_for_errata(errata, {:mandatory => true}).select(&:push_applicable?)\n push_jobs = policies.map(&:push_job_since_last_push_ready).compact\n\n # nochannel jobs never count toward whether advisory push is considered\n # to have failed\n push_jobs.reject!(&:is_nochannel?)\n\n failed_jobs = push_jobs.select(&:failed?)\n active_jobs = push_jobs.select(&:in_progress?)\n\n # Move the status of errata to PUSH_READY if:\n # - no more active push jobs are running\n # - and there is at least one failed push job.\n if active_jobs.empty? && failed_jobs.any?\n comment = \"Mandatory push job(s) have failed: #{failed_jobs.map(&:id).join(', ')}\"\n error comment\n move_advisory_to_push_ready(comment)\n end\n end",
"def validate_tasks(options)\n tasks = []\n\n instances = base_class.where(:id => options[:ids]).order(Arel.sql(\"lower(name)\")).to_a\n return instances, tasks unless options[:invoke_by] == :task # jobs will be used instead of tasks for feedback\n\n instances.each do |instance|\n # create a task for each instance\n task = MiqTask.create(:name => \"#{instance.name}: '#{options[:task]}'\", :userid => options[:userid])\n tasks.push(task)\n\n validate_task(task, instance, options)\n end\n return instances, tasks\n end",
"def validate!; end",
"def validate!; end",
"def validate!; end",
"def valid?\n @hydra.queue(request('verify'))\n end",
"def check\n \n end",
"def check\n \n end",
"def validate\n valid?\n end",
"def valid?(_) true end",
"def valid?(_) true end",
"def validate!\n ensure_valid_tick\n end",
"def delete\n @topic = SignUpTopic.find(params[:id])\n\n if !@topic.nil?\n @topic.destroy\n else\n flash[:error] = \"Topic could not be deleted\"\n end\n\n #if this assignment has staggered deadlines then destroy the dependencies as well \n if Assignment.find(params[:assignment_id])['staggered_deadline'] == true\n dependencies = TopicDependency.find_all_by_topic_id(params[:id])\n if !dependencies.nil?\n dependencies.each {|dependency| dependency.destroy}\n end\n end\n redirect_to_sign_up(params[:assignment_id])\n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def validate\r\n validate! rescue false\r\n end",
"def check\n if valid?\n report_template(:ok)\n else\n report_template(:fail, VALIDATOR_MISSING)\n end\n end",
"def validate\n check_keys qs_plugin, \"QSPlugIn\", %w[author categories description extendedDescription helpPage hidden icon infoFile relatedBundles secret]\n %w[QSActionsTemplate QSDefaultsTemplate QSPresetAdditionsTemplate QSRegistrationTemplate QSRequirementsTemplate].each do |k|\n report_error \"Unknown key: #{k.inspect}\" if @info[k]\n end\n if reg = self['QSRegistration']\n %w[QSPreferencePanesTemplate].each do |k|\n report_error \"Unknown key: QSRegistration/#{k.inspect}\" if @info[k]\n end\n end\n if @info['QSRegistryTables']\n report_error \"Check QSRegistryTables shouldn't be QSRegistration/QSRegistryHeaders instead\"\n end\n end",
"def do_activity(task)\n puts \"\"\n puts \"Please enter either an email address or SMS message (mobile phone) number to\"\n puts \"receive SNS notifications. You can also enter both to use both address types.\"\n puts \"\"\n puts \"If you enter a phone number, it must be able to receive SMS messages, and must\"\n puts \"be 11 digits (such as 12345678901 to represent the number 1-234-567-8901).\"\n\n input_confirmed = false\n while !input_confirmed\n puts \"\"\n print \"Email: \"\n email = $stdin.gets.strip\n\n print \"Phone: \"\n phone = $stdin.gets.strip\n\n puts \"\"\n if (email == '') && (phone == '')\n print \"You provided no subscription information. Quit? (y/n)\"\n confirmation = $stdin.gets.strip.downcase\n if confirmation == 'y'\n return false\n end\n else\n puts \"You entered:\"\n puts \" email: #{email}\"\n puts \" phone: #{phone}\"\n print \"\\nIs this correct? (y/n): \"\n confirmation = $stdin.gets.strip.downcase\n if confirmation == 'y'\n input_confirmed = true\n end\n end\n end\n\n # make sure that @results is a single string. YAML makes this easy.\n @results = { :email => email, :sms => phone }.to_yaml\n\n return true\n end",
"def validate\n show\n return\n\n # Check the variables:\n steps = []\n variables = all_variable.sort_by{|var| var.ordinal}\n variables.each_with_index do |variable, i|\n raise \"Variable #{i} should have ordinal #{variable.ordinal}\" unless variable.ordinal == i\n raise \"Variable #{i} has missing object_type\" unless variable.object_type\n variable.all_play do |play|\n raise \"Variable for #{object_type.name} includes role played by #{play.object_type.name}\" unless play.object_type == object_type\n end\n steps += variable.all_step\n end\n steps.uniq!\n\n # Check the steps:\n steps.each do |step|\n raise \"Step has missing fact type\" unless step.fact_type\n raise \"Step has missing input node\" unless step.input_play\n raise \"Step has missing output node\" unless step.output_play\n if (role = input_play).role.fact_type != fact_type or\n (role = output_play).role.fact_type != fact_type\n raise \"Step has role #{role.describe} which doesn't belong to the fact type '#{fact_type.default_reading}' it traverses\"\n end\n end\n\n # REVISIT: Do a connectivity check\n end",
"def validate_tutorial\n if self.tutorial\n return true\n end\n if self.rut.nil? || birth_date.nil? || city_id.nil? || phone.nil? || preuniversity.nil? || level_id.nil? || nem.nil?\n return false\n else\n self.tutorial = true\n self.save\n end\n end",
"def validate\n plugin.check_keys info, \"QSActions/#{id}\", UNCHECKED_KEYS + KNOWN_KEYS + EXTRA_KEYS\n end",
"def start_new_topic\n @topic = Topic.new\n @post = Post.new\n\n if params[:submit_button] \n begin\n if params[:is_anonymous] == 'on' then\n anon_value = true\n else\n anon_value = false\n end\n @topic.name = params[:name]\n @topic.is_anonymous = anon_value\n @topic.user_id = logged_in_user.id\n \n if not @topic.valid?\n raise_after_msg 'error', :title=>@topic.errors.on('name')\n end\n \n\n @post.user_id = @topic.user_id\n @post.is_first_post = true\n @post.is_anonymous = anon_value\n @post.body = params[:body]\n\n if not @post.valid?\n flash[:title] = @topic.name\n raise_after_msg 'error', :title=>@post.errors.on('body')\n end\n\n @owner.topics << @topic\n @topic.posts << @post\n Syndicate::story_for(logged_in_user,'newtopic',:type=>\"newtopic\",:context=>@owner,:locals=>{:topic_id=>@topic.id})\n fb_redirect_to :controller => 'discussion', :action => 'topics', :cn => params[:cn], :cid => params[:cid]\n return\n rescue Exception=>e\n p e.message\n p flash.inspect\n fb_redirect_to :controller => 'discussion', :action => 'start_new_topic', :cn => params[:cn], :cid => params[:cid]\n return\n end\n else\n @topic.name = flash[:title]\n @post.body = flash[:body]\n end\n end",
"def valid?; end",
"def valid?; end",
"def valid?; end",
"def valid?; end",
"def valid?; end",
"def topic_params\n params.require(:topic).permit(:name, :description, :group_id, :user_id)\n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def check_permission\n # Check if user is signed in\n signed_in_user\n \n if (params[:topic_id]).nil?\n topic = Post.find(params[:id]).topic\n else\n topic = Topic.find(params[:topic_id])\n end\n\n # Admins have unlimited power\n if !current_user_is_admin?\n # Moderators have unlimited power in their boards\n if !current_user_is_moderator?(topic.board)\n\n # Check that user has the required rank to post in the board\n if !topic.board.required_rank.nil?\n req_rank = Rank.find(topic.board.required_rank)\n unless current_user.rank >= req_rank\n flash[:alert] = \"You do not have the required rank for that board.\" \n redirect_to topic\n return\n end\n end\n\n # Check if the board is unlocked\n if topic.board.locked?\n flash[:alert] = \"That board is currently locked.\"\n redirect_to topic\n return\n end\n\n # Check if the topic is unlocked\n if topic.locked?\n flash[:alert] = \"That topic is currently locked.\" \n redirect_to topic\n return\n end\n end\n end\n end",
"def validate\n end",
"def validate\n end",
"def validate\n end"
] |
[
"0.7291646",
"0.72716177",
"0.67401636",
"0.64412546",
"0.64292365",
"0.63417315",
"0.62256604",
"0.61765784",
"0.61765784",
"0.60115564",
"0.59328145",
"0.5918468",
"0.58776146",
"0.58436525",
"0.58224374",
"0.58051574",
"0.5758825",
"0.5730315",
"0.57258123",
"0.57218087",
"0.57103026",
"0.56817967",
"0.56710374",
"0.5665525",
"0.5661312",
"0.5601196",
"0.5588819",
"0.5579805",
"0.5569581",
"0.5547027",
"0.5547027",
"0.55236816",
"0.5519926",
"0.5519723",
"0.5504186",
"0.5503676",
"0.5500801",
"0.54872584",
"0.54802823",
"0.54746217",
"0.54687464",
"0.5456319",
"0.5434299",
"0.54250586",
"0.54217553",
"0.5399524",
"0.53889203",
"0.5380843",
"0.538022",
"0.53736377",
"0.5373328",
"0.53685355",
"0.5342255",
"0.532857",
"0.5326644",
"0.5319197",
"0.53104246",
"0.52866656",
"0.52694476",
"0.52694476",
"0.52694476",
"0.52694476",
"0.52641994",
"0.52608454",
"0.52607185",
"0.5260186",
"0.52541465",
"0.5253044",
"0.52518517",
"0.5251634",
"0.52512676",
"0.52512676",
"0.52512676",
"0.524606",
"0.5233928",
"0.5233928",
"0.5233471",
"0.5227791",
"0.5227791",
"0.52272093",
"0.5221821",
"0.5217878",
"0.5198402",
"0.5198339",
"0.51964647",
"0.519574",
"0.51951015",
"0.5194704",
"0.51927227",
"0.5191861",
"0.5190777",
"0.5190777",
"0.5190777",
"0.5190777",
"0.5190777",
"0.51881254",
"0.51880306",
"0.5183836",
"0.5175695",
"0.5175695",
"0.5175695"
] |
0.0
|
-1
|
Send the ack back to the sender in case of a request
|
def send_ack(spark)
return unless ['request', :request].include? spark[:type]
ack_msg = spark.merge sent_to: spark[:sender], sender: channel
hsdq_send_ack ack_msg
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def send_ack\n sock.put('+')\n vprint_status('Sending ack...')\n end",
"def ack\n unless acked?\n @acked = true\n @connection.future(:ack, delivery_info.delivery_tag).value\n end\n end",
"def ack\n @mq.callback do\n @mq.send Protocol::Basic::Ack.new({ :delivery_tag => @header_obj.properties[:delivery_tag] })\n end\n end",
"def ack(msg_info)\n end",
"def ack!\n @manager.ack(self)\n self\n end",
"def ack msgid\n send_frame \"ACK\", 'message-id'=> msgid\n end",
"def ack(opts={})\n\t\t\t# Set delivery tag\n\t\t\tdelivery_tag = opts.delete(:delivery_tag)\n\t\t\tdelivery_tag ||= self.delivery_tag\n\t\t\traise Bunny::AcknowledgementError, \"No delivery tag received\" unless delivery_tag\n\t\t\t\n client.send_frame(\n Qrack::Protocol09::Basic::Ack.new({:delivery_tag => delivery_tag, :multiple => false}.merge(opts))\n )\n\n\t\t\t# reset delivery tag\n\t\t\tself.delivery_tag = nil if self.delivery_tag == delivery_tag\n end",
"def acknowledge\n # do nothing\n end",
"def req_ack(clk_e,req,ack,port)\n rst_req_ack(clk_e,nil,req,ack,port)\n end",
"def acknowledge()\n\t\tend",
"def acked?; all_status?(:ack); end",
"def ack(opts = {})\n # Set delivery tag\n if delivery_tag.nil? and opts[:delivery_tag].nil?\n raise Bunny::AcknowledgementError, \"No delivery tag received\"\n else\n self.delivery_tag = opts[:delivery_tag] if delivery_tag.nil?\n end\n\n opts = {:delivery_tag => delivery_tag, :multiple => false}.merge(opts)\n\n client.send_frame(Qrack::Protocol::Basic::Ack.new(opts))\n\n # reset delivery tag\n self.delivery_tag = nil\n end",
"def ack_frame *args\n create_ack_or_nack 'ACK', args\n end",
"def nack\n @action = :nack\n end",
"def ack(subscription_headers, message)\n #p [:ack, message.headers[\"message-id\"]]\n if message.headers[\"message-id\"].to_s.strip != \"\" && subscription_headers[\"ack\"].to_s == \"client\"\n SMQueue.dbg { [:smqueue, :ack, :message, message].inspect }\n connection.ack message.headers[\"message-id\"], { }\n else\n SMQueue.dbg { [:smqueue, :ack, :not_acknowledging, message].inspect }\n end\n if ENV['PAUSE_SMQUEUE']\n $stderr.print \"press enter to continue> \"\n $stderr.flush\n $stdin.gets\n end\n end",
"def rst_req_ack(clk_e,rst,req,ack,port)\n if clk_e then\n # Ensures clk_e is an event.\n clk_e = clk_e.posedge unless clk_e.is_a?(Event)\n par(clk_e) do\n # Handle the reset.\n hif(rst) { port.reset } if rst\n ack <= 0\n # Control the start of the task.\n hif(req) { port.run }\n # Control the end of the task: set ack to 1.\n port.finish { ack <= 1 }\n end\n else\n par do\n # Handle the reset\n hif(rst) { port.reset } if rst\n # Control the start of the task.\n hif(req) { port.run }\n ack <= 0\n # Control the end of the task: set ack to 1.\n port.finish { ack <= 1 }\n end\n end\n end",
"def hsdq_ack(message, context); placeholder; end",
"def ack(msg)\n return unless msg.sub\n msg.sub.synchronize do\n ack_proto = STAN::Protocol::Ack.new({\n subject: msg.proto.subject,\n sequence: msg.proto.sequence\n }).to_proto\n nats.publish(msg.sub.ack_inbox, ack_proto)\n end\n end",
"def hsdq_send_ack(message)\n hsdq_send(message.merge(type: :ack))\n end",
"def acknowledge\n api_call(\"acknowledge\")\n self\n end",
"def emitack(event, object, ack)\n @ws.send(get_emit_ack_object(event, object, increment_cnt).to_json)\n @acks[@cnt] = [event, ack]\n end",
"def ack?\n Capp::TCP_ACK == flags & Capp::TCP_ACK\n end",
"def confirm_ack(conn, seq)\r\n return unless @queue[conn.user.id]\r\n @queue[conn.user.id].delete_if {|x| x[:seq] == seq}\r\n conn.empty_response\r\n end",
"def on_verack\n log.debug { \">> verack\" }\n complete_handshake if outgoing?\n end",
"def work(raw_post)\n puts \"Msg received: \" + raw_post\n ack! # we need to let queue know that message was received\n end",
"def ack(multiple = false)\n @channel.acknowledge(@method.delivery_tag, multiple)\n end",
"def ack=(ack)\n raise 'Invalid ack flag. true or false expected' unless\n [true, false].include? ack\n @message[:ack] = ack\n end",
"def acknowledge(authcode = nil)\n true\n end",
"def process_ack(data, reply, subject)\n # FIXME: This should handle errors asynchronously in case there are any\n\n # Process ack\n pub_ack = STAN::Protocol::PubAck.decode(data)\n unless pub_ack.error.empty?\n raise Error.new(pub_ack.error)\n end\n\n # Unblock publishing queue\n @pending_pub_acks.pop if @pending_pub_acks.size > 0\n\n synchronize do\n # yield the ack response back to original publisher caller\n if cb = @pub_ack_map[pub_ack.guid]\n cb.call(pub_ack)\n end\n end\n end",
"def ack_message( tag, success, try_again=true )\n\t\treturn unless self.acknowledge\n\n\t\tchannel = self.consumer.channel\n\n\t\tif success\n\t\t\tself.log.debug \"ACKing message %s\" % [ tag ]\n\t\t\tchannel.acknowledge( tag )\n\t\telse\n\t\t\tself.log.debug \"NACKing message %s %s retry\" % [ tag, try_again ? 'with' : 'without' ]\n\t\t\tchannel.reject( tag, try_again )\n\t\tend\n\n\t\treturn success\n\tend",
"def ack_block(cid)\n ws = @ws\n lambda do |error, data|\n ws.send(get_ack_object(error, data, cid))\n end\n end",
"def handle_ack_msg( their_msg )\r\n begin\r\n if their_msg.startup_ack\r\n super\r\n send_next_case\r\n warn \"Started, shouldn't see this again...\" if self.class.debug\r\n return\r\n end\r\n if their_msg.result\r\n self.class.lookup[:results][their_msg.result]||=0\r\n self.class.lookup[:results][their_msg.result]+=1\r\n if their_msg.result=='crash' and their_msg.crashdetail\r\n crashdetail=their_msg.crashdetail\r\n self.class.lookup[:buckets][DetailParser.hash( crashdetail )]=true\r\n # You might want to clear this when outputting status info.\r\n self.class.queue[:bugs] << DetailParser.long_desc( crashdetail )\r\n # Just initials - NOT EXPLOITABLE -> NE etc\r\n classification=DetailParser.classification( crashdetail).split.map {|e| e[0]}.join\r\n self.class.lookup[:classifications][classification]||=0\r\n self.class.lookup[:classifications][classification]+=1\r\n end\r\n else\r\n # Don't cancel the ack timeout here - this is the first ack\r\n # We wait to get the full result, post delivery.\r\n super\r\n send_next_case\r\n end\r\n rescue\r\n raise RuntimeError, \"#{COMPONENT}: Unknown error. #{$!}\"\r\n end\r\n end",
"def acknowledge_response(response)\n id = response['message-response-id']\n http.delete(api_base_uri.path + \"/messages/#{id}\")\n end",
"def done!(delivery_info)\n channel.ack(delivery_info.delivery_tag) if manual_ack?\n end",
"def ack_message(adapter, queue_url, msg)\n adapter.sqs_client.delete_message(\n queue_url: queue_url, receipt_handle: msg.receipt_handle\n )\n end",
"def ack_receipt\n Net::HTTP.get(URI(params[:response_url]))\n end",
"def nack_message(adapter, queue_url, msg)\n adapter.sqs_client.change_message_visibility(\n queue_url: queue_url,\n receipt_handle: msg.receipt_handle,\n visibility_timeout: NACK_VISIBILITY_TIMEOUT\n )\n rescue StandardError => e\n Mimi::Messaging.logger&.error(\n \"#{self.class}: failed to NACK message from: #{queue_url},\" \\\n \" error: (#{e.class}) #{e}\"\n )\n # NOTE: error is recovered and the message is neither ACKed or NACKed\n end",
"def ack_mine(response)\n email = fetch_user(response.user)\n return response.reply(t('identify.missing')) unless email\n incidents = fetch_my_incidents(email)\n return response.reply(t('incident.none_mine')) unless incidents.count > 0\n completed = []\n incidents.each do |incident|\n result = acknowledge_incident(incident.id)\n completed.push(incident.id) if result == \"#{incident.id}: Incident acknowledged\"\n response.reply(t('all.acknowledged', list: completed.join(', ')))\n end\n end",
"def acknowledge( message )\n @queue.acknowledge( message )\n end",
"def handle_heartbeat_ack(_payload)\n @heartbeat_acked = true\n end",
"def acknowledge(delivery_tag)\n @channel.acknowledge(delivery_tag)\n\n self\n end",
"def resend_pending_message_ack_queue\n connection.__pending_message_ack_queue__.delete_if do |protocol_message|\n if protocol_message.ack_required?\n connection.__outgoing_message_queue__ << protocol_message\n connection.__outgoing_protocol_msgbus__.publish :protocol_message\n true\n end\n end\n end",
"def ack_required?\n self.class.ack_required?(action)\n end",
"def acknowledge\n verify? params, KEY\n end",
"def acknowledge\n verify? params, KEY\n end",
"def acknowledge\n attrs = {\n :acknowledged => true,\n :acknowledged_at => Time.now()\n }\n self.update_attributes(attrs)\n end",
"def executeack(key, object, ack)\n function = @events_ack[key] if @events_ack.key?(key)\n function.call(key, object, ack) if function\n end",
"def acknowledge(delivery_tag)\n @channel.acknowledge(delivery_tag)\n\n self\n end",
"def onack(key, function)\n @events_ack[key] = function\n end",
"def acknowledge(enquiry)\n @enquiry = enquiry\n\n mail :to => enquiry.email, :subject => \"B&B availability request for Bull Farm Oast\"\n end",
"def nacknowledge_frame sequence_number\n @stats[:naks_sent] += 1\n\n # Already acked?\n return if @buffer[sequence_number] == \"\"\n\n @buffer[sequence_number] = nil\n\n # If GO_BACK_N algorithm, then we expect to receive all of the\n # frames again\n expected_frame = (@next_frame % @options[:window_size]) + (@options[:window_size] * (@window % 2))\n\n if @options[:implementation] == :go_back\n next_frame = ((@window * @options[:window_size]) + (sequence_number % @options[:window_size]))\n @next_frame = [next_frame, @next_frame].min\n @current_frame = @next_frame\n\n # Undo work done\n \n max_frame = @options[:window_size] * ((@window % 2) + 1)\n (expected_frame+1..max_frame).each do |i|\n @buffer[i] = nil\n end\n end\n\n if drop_ack?\n @stats[:naks_dropped] += 1\n puts \"Dropped NAK\"\n return\n end\n\n puts \"NAK #{sequence_number}\"\n @socket.puts \"NAK #{sequence_number} #{@number}\"\n\n # we received a response, so good\n reset_timeout\n end",
"def replyWithAck?(pduPacket)\n\n Utils_visiona.verifyInput(CFDP::PDUPacket, pduPacket.class)\n return unless isclass2?\n\n status = (@finishType.nil? ? 1 : 2)\n sourceID = MYID\n destinationID = DESTINATIONID\n direction = 0\n\n # This is a received PDU.\n case pduPacket.pduPayload\n when CFDP::PDUEOF\n \n # I only receive EOF packets in DOWNLINK events\n return unless @type.eql?(\"DOWNLINK\")\n direction = 1\n sourceID = destinationID\n destinationID = MYID\n when CFDP::PDUFinished\n\n # I only receive FINISHED packets in UPLINK events\n return unless @type.eql?(\"UPLINK\")\n # use default values from function start\n else\n return\n end\n\n ackPdu = CFDP.generatePDU(\"ACK\", directiveCode:pduPacket.pduPayload.class.class_variable_get(:@@fdCode),\n directiveSubtypeCode:0, conditionCode:pduPacket.pduPayload.conditionCode, transactionStatus:status,\n direction:direction, transmissionMode:0, sourceID:sourceID, destinationID:destinationID,\n sequenceNumber:pduPacket.pduHeader.sequenceNumber)\n\n writeLog(\"Generated ACK PDU: #{ackPdu.pack.to_s}\")\n CFDP::CFDPEngine.instance.insertIntoBuffer(ackPdu)\n end",
"def enable_xack\n getok('XACK ON')\n @xack = true\n end",
"def ack(device_uuid, ack_keys)\n validate_device!(device_uuid)\n raise ArgumentError, \"ack_keys must not be nil and an array\" unless ack_keys && ack_keys.is_a?(Array)\n return true if ack_keys.empty?\n\n payload = {\n :ack_keys => ack_keys.map(&:to_s)\n }\n status, _, _ = @client.post('/sync/ack', payload, build_headers(device_uuid))\n status == 202\n end",
"def acknowledge( message )\n open_msg = @open_messages.delete( message.key )\n raise Qup::Error, \"Message #{message.key} is not currently being consumed\" unless open_msg\n @client.close( @name )\n end",
"def on_message_ack(&handler)\n @on_message_ack_handler = handler\n end",
"def acknowledge_alert(alert_id, by = nil, comment = nil)\n sub_url = \"/ack/#{alert_id}\"\n query = generate_query_params 'ackBy' => by, 'ackNotes' => comment\n sub_url += query\n http_put(sub_url, {})\n\n true\n end",
"def publishack(channel, data, ack)\n @ws.send(get_publish_object(channel, data, increment_cnt).to_json)\n @acks[@cnt] = [channel, ack]\n end",
"def receive_acknowledgement sequence_number\n @stats[:acks_received] += 1\n\n frame_acknowledged = sequence_number-1\n if frame_acknowledged == -1\n frame_acknowledged = (@options[:window_size] * 2) - 1\n end\n puts \"Frame #{frame_acknowledged} ACK'd\"\n\n perform_acknowledgement frame_acknowledged\n end",
"def nack_frame *args\n create_ack_or_nack 'NACK', args\n end",
"def acknowledge\n @mutex.synchronize do\n return if @requeued || @acked\n\n Sidekiq.redis do |redis|\n redis.lrem(@queue.inproc, -1, @job)\n end\n\n @acked = true\n end\n end",
"def test_client_ack_with_symbol_12\n if @conn.protocol != Stomp::SPL_12\n assert true\n return\n end\n sid = @conn.uuid()\n queue = make_destination()\n @conn.subscribe queue, :ack => :client, :id => sid\n @conn.publish queue, \"test_stomp#test_client_ack_with_symbol_11\"\n msg = @conn.receive\n assert_nothing_raised {\n # The ACK frame MUST include an id header matching the ack header \n # of the MESSAGE being acknowledged.\n @conn.ack msg.headers['ack']\n }\n checkEmsg(@conn)\n end",
"def acknowledge(authcode = nil)\n payload = raw\n\n uri = URI.parse(<%= class_name %>.notification_confirmation_url)\n\n request = Net::HTTP::Post.new(uri.path)\n\n request['Content-Length'] = \"#{payload.size}\"\n request['User-Agent'] = \"Active Merchant -- http://activemerchant.org/\"\n request['Content-Type'] = \"application/x-www-form-urlencoded\"\n\n http = Net::HTTP.new(uri.host, uri.port)\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE unless @ssl_strict\n http.use_ssl = true\n\n response = http.request(request, payload)\n\n # Replace with the appropriate codes\n raise StandardError.new(\"Faulty <%= class_name %> result: #{response.body}\") unless [\"AUTHORISED\", \"DECLINED\"].include?(response.body)\n response.body == \"AUTHORISED\"\n end",
"def acknowledge(authcode = nil)\n verified?\n end",
"def acknowledge(authcode = nil)\n string = [params['_raw_action'],\n params['_raw_orderSumAmount'],\n params['_raw_orderSumCurrencyPaycash'],\n params['_raw_orderSumBankPaycash'],\n params['_raw_shopId'],\n params['_raw_invoiceId'],\n params['_raw_customerNumber'],\n authcode\n ].join(';')\n\n digest = Digest::MD5.hexdigest(string)\n res = params['_raw_md5'] == digest.upcase\n if res\n @response_code = '0'\n else\n @response_code = '1'\n end\n end",
"def haseventack(key)\n @events_ack[key]\n end",
"def test_client_ack_with_symbol_10\n if @conn.protocol != Stomp::SPL_10\n assert true\n return\n end\n queue = make_destination()\n @conn.subscribe queue, :ack => :client\n @conn.publish queue, \"test_stomp#test_client_ack_with_symbol_10\"\n msg = @conn.receive\n assert_nothing_raised {\n # ACK has one required header, message-id, which must contain a value \n # matching the message-id for the MESSAGE being acknowledged.\n @conn.ack msg.headers['message-id']\n }\n checkEmsg(@conn)\n end",
"def ACK08=(arg)",
"def send_pending; end",
"def ACK07=(arg)",
"def ACK10=(arg)",
"def execute\n return unless active\n process_outbound_ack\n deactivate(@flag)\n end",
"def mark_processed(stream, group, message_id)\n stream = stream_name(stream)\n group = \"#{stream}-#{group}\"\n\n count = connection.xack(stream, group, message_id)\n return if count == 1\n\n raise \"Message could not be ACKed in Redis: #{stream} #{group} \"\\\n \"#{message_id}. Return value: #{count}\"\n end",
"def ACK05=(arg)",
"def ACK01=(arg)",
"def test_client_ack_with_symbol_11\n if @conn.protocol != Stomp::SPL_11\n assert true\n return\n end\n sid = @conn.uuid()\n queue = make_destination()\n @conn.subscribe queue, :ack => :client, :id => sid\n @conn.publish queue, \"test_stomp#test_client_ack_with_symbol_11\"\n msg = @conn.receive\n assert_nothing_raised {\n # ACK has two REQUIRED headers: message-id, which MUST contain a value \n # matching the message-id for the MESSAGE being acknowledged and \n # subscription, which MUST be set to match the value of the subscription's \n # id header.\n @conn.ack msg.headers['message-id'], :subscription => msg.headers['subscription']\n }\n checkEmsg(@conn)\n end",
"def acknowledge( events = [], message = \"#{@parent.whoami} is working on this.\" )\n request = { 'method' => 'event.acknowledge', 'params' => { 'eventids' => events, 'message' => message } }\n call_api(request)\n end",
"def send_topic_acknowledge(msg, headers, timeout=60)\n #m=StompMessage::Message.new('stomp_BILLING', msg)\n open_connection\n s=rand*30 # scott - used to be 1000 but seem to create connections on activemq\n # open new topic to listen to reply...\n # was this but jms seems to blow up receipt_topic=\"/topic/receipt/client#{s.to_i}\"\n receipt_topic=\"/topic/rcpt_client#{s.to_i}\"\n receipt_flag = false\n # internal_conn = Stomp::Connection.open '', '', self.host, self.port, false \n self.conn.subscribe( receipt_topic, { :ack =>\"client\" }) {|msg|\n begin\n Timeout::timeout(timeout) {\n self.conn.acknowledge(msg,msg.headers)\n \t msg2= msg.body\n \t yield msg2\n }\n rescue Exception => e\n puts \"exception #{e.message}\"\n # raise \"timeout\" \n ensure\n receipt_flag=true\n self.conn.unsubscribe receipt_topic \n end \n }\n \n \n more_headers= {'persistent'=>'false', 'reply-to' => \"#{receipt_topic}\" }\n more_headers.merge headers\n self.conn.send(self.topic, msg.to_xml, more_headers ) \n Thread.new { sleep(timeout+1)\n puts \"calling unsubscribe on #{receipt_topic}\" if !receipt_flag\n self.conn.unsubscribe receipt_topic if !receipt_flag\n } \n end",
"def acknowledge\n payload = @raw\n noti_confirm = Alipay.notification_confirmation_url\n noti_confirm += (\"partner=\" + Alipay::ACCOUNT.to_s + \"¬ify_id=\" + notify_id)\n PAYMENT_LOG.info \"===============acknowledge init by jumaimai ============\"\n PAYMENT_LOG.info noti_confirm \n uri = URI.parse(noti_confirm)\n result = Net::HTTP.get(uri)\n PAYMENT_LOG.info \"---------acknowledge result #{result} ----------------\"\n result == \"true\"\n end",
"def acknowledge(info, &callback)\n EM.defer {\n @sqs.delete_message(\n queue_url: @settings[:consuming_sqs_queue_url],\n receipt_handle: info.receipt_handle,\n )\n statsd_incr(\"sqs.#{@settings[:consuming_sqs_queue_url]}.message.deleted\")\n callback.call(info) if callback\n }\n end",
"def basic_nack(delivery_tag, multiple: false, requeue: false)\n write_bytes FrameBytes.basic_nack(@id, delivery_tag, multiple, requeue)\n nil\n end",
"def send_email_if_needed\n \tif self.is_response\n \t\tlogger.info \"Send Email\"\n \t\tMessageMailer.reply_email( self ).deliver\n \tend\n end",
"def acknowledge_message(poller, msg)\n poller.delete_message(msg)\n end",
"def ACK04=(arg)",
"def notify_acknowledgement\n # message = sender_activity.decorate.activity_message\n # logger.info \"Preparing to send acknowledgment push notification of #{ message } to sender: #{ sender.id }\"\n #\n # sender.devices.each do |device|\n # device.notify message\n # end\n end",
"def accept\n @proxy_deposit_request.transfer!(params[:reset])\n if params[:sticky]\n current_user.can_receive_deposits_from << @proxy_deposit_request.sending_user\n end\n redirect_to :back, notice: \"Transfer complete\"\n end",
"def jms_send_ack(session,producer,tmp_text,ttimeout=75, rawflag=false)\n # scott new comment msg=session.create_text_message\n jms_temp_result =''\n @my_jms_guard.synchronize {\n # jms_next_transaction_id\n jms_tmp_header={}\n jms_temp_result=''\n begin \n count =0;\n Timeout::timeout(ttimeout) {\n tmp_msg_recv_flag=false\n jms_send_message(session,producer,jms_tmp_header,tmp_text) { |t2msg|\n #puts \"message recieved: #{t2msg.inspect}\" \n temp_m=StompMessage::Message.load_xml(t2msg.get_text())\n jms_temp_result = temp_m.body \n jms_temp_result = temp_m if rawflag\n tmp_msg_recv_flag=true\n }\n # sleep(0.05)\n while true \n # putc '.'\n count +=1\n break if tmp_msg_recv_flag\n sleeptime=count*0.01\n count= 5 if count > 100 #don't let count get too big\n sleep(sleeptime) \n # puts \"----sleeptime is: #{sleeptime} count: #{count}\" \n end\n }\n\n rescue Timeout::Error\n jms_temp_result=\"timeout waiting for response\"\n end\n }\n return jms_temp_result\n end",
"def xack(key, group, *ids)\n args = [:xack, key, group].concat(ids.flatten)\n send_command(args)\n end",
"def markmsgdelivered(msgid)\n req(\"markmsgdelivered\", \"\", \"\", msgid, \"\")\n end",
"def acknowledge(authcode = nil)\n return false if security_key.blank?\n if ins_message?\n Digest::MD5.hexdigest(\"#{ transaction_id }#{ params['vendor_id'] }#{ invoice_id }#{ secret }\").upcase == security_key.upcase\n elsif passback?\n order_number = params['demo'] == 'Y' ? 1 : params['order_number']\n Digest::MD5.hexdigest(\"#{ secret }#{ params['sid'] }#{ order_number }#{ gross }\").upcase == params['key'].upcase\n else\n false\n end\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 ack?\n filename.downcase.start_with?(\"ack\")\n end",
"def ACK03=(arg)",
"def redo!\n send_request\n end",
"def acknowledge\n if params['paymentState'] == 'SUCCESS'\n p = params.clone\n p['secret'] = @options[:secret]\n md5digest = Digest::MD5.hexdigest(p['responseFingerprintOrder'].split(',').map { |key| p[key] }.join)\n\n md5digest == params['responseFingerprint']\n else\n true\n end\n end",
"def setup_shared_queue\n @amq.queue(@shared_queue).subscribe(:ack => true) do |info, msg|\n begin\n info.ack\n receive_request(@serializer.load(msg))\n rescue Exception => e\n RightLinkLog.error(\"RECV #{e.message}\")\n @callbacks[:exception].call(e, msg, self) rescue nil if @callbacks && @callbacks[:exception]\n end\n end\n true\n end",
"def trigger_requeue!\n false\n end",
"def ACK06=(arg)",
"def acknowledge subscription, *ack_ids\n subscriber.acknowledge subscription: subscription_path(subscription), ack_ids: ack_ids\n end",
"def call\n transaction do\n discard_drafts\n end\n\n broadcast(:ok)\n end"
] |
[
"0.79083085",
"0.7592287",
"0.7546514",
"0.75286406",
"0.73193854",
"0.71973634",
"0.7018864",
"0.6948857",
"0.6925333",
"0.689984",
"0.68785095",
"0.6801428",
"0.6800155",
"0.67787606",
"0.6675017",
"0.6660697",
"0.66142124",
"0.6610668",
"0.65270597",
"0.6474745",
"0.639441",
"0.6374825",
"0.634706",
"0.6330397",
"0.63196397",
"0.630711",
"0.62518954",
"0.62408423",
"0.62321204",
"0.6221334",
"0.62197703",
"0.62017536",
"0.61992955",
"0.6195838",
"0.61445194",
"0.6078037",
"0.6072773",
"0.60472685",
"0.59801424",
"0.59155834",
"0.5895672",
"0.58778536",
"0.5859076",
"0.5850116",
"0.5850116",
"0.5787243",
"0.5785975",
"0.5784212",
"0.57373595",
"0.56903416",
"0.56862706",
"0.56628335",
"0.56368494",
"0.563508",
"0.562741",
"0.5621902",
"0.5605573",
"0.5600405",
"0.55892164",
"0.55785763",
"0.5567007",
"0.55477816",
"0.5525267",
"0.5501065",
"0.5500853",
"0.5480524",
"0.54740417",
"0.5443213",
"0.5414742",
"0.54026043",
"0.53993964",
"0.5392795",
"0.53836554",
"0.5383366",
"0.5380355",
"0.53751475",
"0.533677",
"0.5319685",
"0.5314643",
"0.52985394",
"0.5278439",
"0.52719104",
"0.525858",
"0.52551377",
"0.52442104",
"0.52333164",
"0.5231732",
"0.5231397",
"0.52218914",
"0.52029085",
"0.51995665",
"0.5195725",
"0.51916355",
"0.5185677",
"0.516733",
"0.5162683",
"0.5162369",
"0.51617175",
"0.51612455",
"0.5158604"
] |
0.65629834
|
18
|
Hash of the internal authorized message types
|
def hsdq_authorized_types
[:request, :ack, :feedback, :callback, :error]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def hash\n [domain, message, stack, type].hash\n end",
"def hash\r\n\t\treturn @name.hash() + @type.hash()\r\n\tend",
"def message_types\n @message_types ||= {}\n end",
"def hash\n @type.hash\n end",
"def hash\n [type, page_access_token, app_id, app_secret, account_sid, auth_token, phone_number_sid, token, channel_access_token, encoding_aes_key, from_address, certificate, password, auto_update_badge, server_key, sender_id, consumer_key, consumer_secret, access_token_key, access_token_secret].hash\n end",
"def hash\n type.hash ^ (id.hash >> 1)\n end",
"def hash\n @hash[:perm_type].hash ^\n @hash[:perms].hash ^\n @hash[:inheritance].hash ^\n @hash[:target].hash\n end",
"def hash\n [@bit, @type].hash\n end",
"def hash\n [accept_tos, verify_sms, kyc_check, documentary_verification, selfie_check, watchlist_screening, risk_check].hash\n end",
"def get_message_types; end",
"def get_message_types; end",
"def hash\n\t\t(language + type + klass + thing).hash\n\tend",
"def hash # :nodoc:\n name.hash ^ type.hash ^ requirement.hash\n end",
"def hash\n [type, id, timestamp, local_timestamp, local_timezone, caller_id, service_url, channel_id, from, conversation, recipient, text_format, attachment_layout, members_added, members_removed, reactions_added, reactions_removed, topic_name, history_disclosed, locale, text, speak, input_hint, summary, suggested_actions, attachments, entities, channel_data, action, reply_to_id, label, value_type, value, name, relates_to, code, expiration, importance, delivery_mode, listen_for, text_highlights, semantic_action].hash\n end",
"def hash\n [auth_provider_x509_cert_url, auth_uri, automute, client_email, client_id, client_x509_cert_url, errors, host_filters, is_cspm_enabled, private_key, private_key_id, project_id, token_uri, type].hash\n end",
"def hash\n [class_id, object_type, msg_type, path, stream].hash\n end",
"def auth_types_collection\n @auth_types_h ||= Rails.cache.fetch \"auth_types_h\", :expires_in => 24.hours do\n # Uses the Hash object to cast a mapped array as a hash\n Hash[auth_types.map {|x| [x[\"code\"], x[\"web_text\"]]}]\n end\n end",
"def hash\n [ data, type ].hash\n end",
"def hash\n [domain, register_server, transport_protocol, proxy_server, register_server2, transport_protocol2, proxy_server2, register_server3, transport_protocol3, proxy_server3, registration_expire_time, user_name, password, authorization_name, user_email, voice_mail].hash\n end",
"def hash\n [deleted, edited_by_user, email_communication_sequence_email_uuid, email_communication_sequence_uuid, email_container_cjson, email_container_cjson_last_modified_dts, email_template_vm_path, filter_profile_equation_json, individually_render, library_item_oid, magic_link, merchant_id, pending_review, preview_text, rejected, requires_review, screenshot_large_full_url, screenshot_large_viewport_url, screenshot_small_full_url, screenshot_small_viewport_url, smart_sending, storefront_oid, subject, suspended_for_spam, transactional_email, version].hash\n end",
"def hash\n [id, alternate_id, type, first_name, surname, date_of_brith, date_of_birth, shipping_address, mailing_address, home_phone, mobile_phone, email_address, mailing_address_active, accounts, classifications, member_photo, gender, receive_email, receive_sms, password].hash\n end",
"def attr_hash\n Digest::MD5.hexdigest(\"#{@name}:#{@ruby_type}\")\n end",
"def hash\n [id, sender, receiver, text, status, contact_id, session_id, message_time, avatar, deleted, charset, charset_label, first_name, last_name, country, phone, price, parts_count, from_email, from_number].hash\n end",
"def hash\n [system_cache_clear, system_exit, system_alert, system_account_state_changed, message_deleted, message_incoming, message_incoming_deleted, message_state_changed, message_bulk_end, message_wipe_end, message_sent, message_session_deleted, message_cache_clear, message_incoming_cache_clear, message_schedule_added, message_schedule_state_changed, message_schedule_deleted, message_schedule_cache_clear, message_template_cache_clear, call_finished, chat_created, chat_marked_as_read, chat_muted, chat_unmuted, chat_pinned, chat_unpinned, chat_deleted, chat_closed, chat_reopened, chat_cache_clear, contact_added, contact_deleted, contact_state_changed, list_added, list_deleted, list_state_changed, contact_wipe_end, contact_import_end, contact_cache_clear, list_cache_clear, custom_fields_cache_clear].hash\n end",
"def hash\n [_name, _type, _klass].hash\n end",
"def hash\n raw = [name, type, values.join('/')].join(' ')\n Digest::MD5.hexdigest(raw)\n end",
"def hash\n [check_id, exceptions, key, links, port, proof, protocol, since, status].hash\n end",
"def message_hash msg\n {\n message: msg,\n type: self.class.name,\n id: self.id\n }\n end",
"def hash\n [bitmask, self.class].hash\n end",
"def message_types\n {\n create: [:light_cyan, :cyan],\n store: [:light_cyan, :cyan],\n update: [:light_cyan, :cyan],\n reset: [:light_cyan, :cyan],\n\n event: [:light_magenta, :magenta],\n\n timer: [:light_blue, :blue],\n\n info: [:white, :light_grey],\n test: [:white, :light_grey],\n debug: [:white, :light_grey],\n\n input: [:light_yellow, :yellow],\n output: [:light_green, :green],\n\n error: [:light_red, :red],\n\n config: [:light_blue, :blue],\n dsl: [:light_blue, :blue],\n editor: [:light_blue, :blue],\n drb: [:light_blue, :blue],\n }\n end",
"def auth_types\n @auth_types ||= [\"CB\"]\n end",
"def hash\n [account_management_granular, admin_only, admin_only_metadata, allow_auto_tagging, allow_envelope_transfer_to, allow_envelope_transfer_to_metadata, allow_eseal_recipients, allow_eseal_recipients_metadata, allow_power_forms_admin_to_access_all_power_form_envelope, allow_power_forms_admin_to_access_all_power_form_envelope_metadata, allow_recipient_language_selection, allow_recipient_language_selection_metadata, allow_send_on_behalf_of, allow_send_on_behalf_of_metadata, allow_supplemental_documents, allow_supplemental_documents_metadata, anchor_tag_versioned_placement_enabled, api_account_wide_access, api_account_wide_access_metadata, api_can_export_ac, api_can_export_ac_metadata, bulk_send, bulk_send_metadata, can_charge_account, can_charge_account_metadata, can_edit_shared_addressbook, can_edit_shared_addressbook_metadata, can_lock_envelopes, can_lock_envelopes_metadata, can_manage_account, can_manage_account_metadata, can_manage_distributor, can_manage_distributor_metadata, can_manage_templates, can_manage_templates_metadata, can_send_api_requests, can_send_api_requests_metadata, can_send_envelope, can_send_envelope_metadata, can_sign_envelope, can_sign_envelope_metadata, can_use_scratchpad, can_use_scratchpad_metadata, can_use_smart_contracts, can_use_smart_contracts_metadata, disable_document_upload, disable_document_upload_metadata, disable_other_actions, disable_other_actions_metadata, enable_ds_pro, enable_ds_pro_metadata, enable_sequential_signing_api, enable_sequential_signing_api_metadata, enable_sequential_signing_ui, enable_sequential_signing_ui_metadata, enable_signer_attachments, enable_signer_attachments_metadata, enable_sign_on_paper_override, enable_sign_on_paper_override_metadata, enable_transaction_point, enable_transaction_point_metadata, enable_vaulting, enable_vaulting_metadata, express_send_only, locale, locale_metadata, locale_policy, manage_clickwraps_mode, manage_clickwraps_mode_metadata, modified_by, modified_by_metadata, modified_date, modified_date_metadata, modified_page, modified_page_metadata, new_send_ui, new_send_ui_metadata, power_form_mode, power_form_mode_metadata, recipient_viewed_notification, recipient_viewed_notification_metadata, seal_identifiers, self_signed_recipient_email_document, self_signed_recipient_email_document_metadata, sender_email_notifications, signer_email_notifications, supplemental_document_include_in_download, supplemental_documents_must_accept, supplemental_documents_must_accept_metadata, supplemental_documents_must_read, supplemental_documents_must_read_metadata, supplemental_documents_must_view, supplemental_documents_must_view_metadata, template_active_creation, template_active_creation_metadata, template_apply_notify, template_apply_notify_metadata, template_auto_matching, template_auto_matching_metadata, template_matching_sensitivity, template_matching_sensitivity_metadata, template_page_level_matching, template_page_level_matching_metadata, timezone_dst, timezone_dst_metadata, timezone_mask, timezone_mask_metadata, timezone_offset, timezone_offset_metadata, timezone_sending_pref, timezone_sending_pref_metadata, timezone_signing_pref, timezone_signing_pref_metadata, transaction_point_site_name_url, transaction_point_site_name_url_metadata, transaction_point_user_name, transaction_point_user_name_metadata, vaulting_mode, vaulting_mode_metadata].hash\n end",
"def hash\n [authentication_type, community_name, database, domain, enumerate_sids, notes_id_password, ntlm_hash, oracle_listener_password, password, pem_key, permission_elevation, permission_elevation_password, permission_elevation_username, privacy_password, privacy_type, private_key_password, realm, service, sid, use_windows_authentication, username].hash\n end",
"def hash\n [message_id, from, date, chat, forward_from, forward_from_chat, forward_from_message_id, forward_date, reply_to_message, edit_date, text, entities, caption_entities, audio, document, game, photo, sticker, video, voice, video_note, caption, contact, location, venue, new_chat_members, left_chat_member, new_chat_title, new_chat_photo, delete_chat_photo, group_chat_created, supergroup_chat_created, channel_chat_created, migrate_to_chat_id, migrate_from_chat_id, pinned_message, invoice, successful_payment, forward_signature, author_signature, connected_website].hash\n end",
"def hash\n [bitmask, self.class].hash\n end",
"def hash\n [author, created, icon, id, integration_id, is_favorite, is_read_only, is_shared, modified, popularity, tags, title, type, url].hash\n end",
"def hash\n [id, type, name, is_active, external_url, external_authorization_type, external_user_name, external_password, external_bearer_token, external_headers].hash\n end",
"def to_hash_keys\n ([:_type] + _struct.keys.map(&:to_sym)).uniq\n end",
"def hash\n [author, created_at, dashboard_id, dashboard_type, global_time, global_time_selectable_enabled, public_url, selectable_template_vars, share_list, share_type, token].hash\n end",
"def message_hash parrent, msg\n {\n message: msg,\n type: parrent.class.name,\n id: parrent.id\n }\n end",
"def hash\n [application, authorized_entity, platform, attest_status, app_signer, connection_type, connect_date, rel].hash\n end",
"def hash\n [audit, username, ereq_id, level, comp, error_code, s2comp, req_id, ent_id, security, subcomp].hash\n end",
"def hash\n [admin, created_at, customer_id, description, event_type, ip, metadata, service_id, user_id, token_id].hash\n end",
"def hash\n [attachments, billing, body, body_html, body_rtf, body_type, categories, companies, item_id, message_class, mileage, recipients, sensitivity, subject, subject_prefix, properties, discriminator, electronic_addresses, events, name_info, other_fields, personal_info, photo, physical_addresses, professional_info, telephones].hash\n end",
"def hash\n [id, next_send, rrule, session, last_sent, contact_name, parameters, type, summary, text_parameters, first_occurrence, last_occurrence, recipients_count, timezone, completed, avatar, created_at].hash\n end",
"def hash\n { hash: @hash, hashType: @hash_type }\n end",
"def hash\n [id, to, from, description, metadata, merge_variables, send_date, mail_type, memo, check_number, message, amount, bank_account, check_bottom_template_id, attachment_template_id, check_bottom_template_version_id, attachment_template_version_id, url, carrier, thumbnails, expected_delivery_date, tracking_events, object, date_created, date_modified, deleted, use_type].hash\n end",
"def hash\n [color, cards, address_placement, custom_envelope, double_sided, extra_service, mail_type, return_envelope, bleed, file_original_url].hash\n end",
"def hash\n [canceled, created, display_timezone, message, modified, monitor_identifier, mute_first_recovery_notification, notify_end_states, notify_end_types, schedule, scope, status].hash\n end",
"def types\n @@types ||= Hash.new\n end",
"def hash\n [inbox_id, count, delay_timeout, timeout, unread_only, count_type, matches, sort_direction, since, before].hash\n end",
"def hash\n [class_id, object_type, description, name, type, system].hash\n end",
"def user_hash(message)\n return Digest::MD5.hexdigest(message.user).to_i(16) + Digest::MD5.hexdigest(message.host).to_i(16)\nend",
"def auth_types_array\n @auth_types_array ||= Rails.cache.fetch \"auth_types_array\", :expires_in => 24.hours do\n auth_types.collect {|x| x[\"code\"] }\n end\n end",
"def hash\n name.hash ^ provider.hash\n end",
"def hash\n [class_id, object_type, action, cache_state, cached_time, last_access_time, md5sum, original_sha512sum, path, registered_workflows, used_count, file, network_element].hash\n end",
"def key_types; end",
"def key_types; end",
"def hash\n [account_id, cms_user_id, company, created_at, dept, email, first_name, group_ids, host_key, id, im_group_ids, jid, job_title, language, last_client_version, last_login_time, last_name, location, personal_meeting_url, phone_country, phone_number, pic_url, pmi, role_name, status, timezone, type, use_pmi, vanity_url, verified].hash\n end",
"def hash\n [description, routing_number, account_number, account_type, signatory, metadata, id, signature_url, bank_name, verified, date_created, date_modified, deleted, object].hash\n end",
"def platform_authorized_key(type)\n \"#{type.graphql_name}.authorized\"\n end",
"def hash\n [avatar, banner, created_at, description, handle, hidden_modules, link_count, modified_at, name, summary, user_count, visible_modules].hash\n end",
"def type\n self.class.type_enum_map.key(@cred_struct[:type])\n end",
"def hash\n [self.class, to_s].hash\n end",
"def hash(message)\n return Digest::SHA1.hexdigest(message)\n end",
"def hash\n [class_id, object_type, account_moid, create_time, domain_group_moid, mod_time, moid, owners, shared_scope, tags, version_context, ancestors, parent, permission_resources, display_names].hash\n end",
"def get_hash(type)\n allowed_tables = A_HASHES\n allowed_tran = %w(month day)\n allowed_spec = %w(time)\n\n if allowed_tables.include? type\n rows = get_list(type)\n if rows == 'ERROR' # Dirty fix for 'multiple responses' error\n return 'ERROR'\n end\n\n r = {}\n\n rows.each {|v|\n r[v.id] = v.name\n }\n\n r\n elsif allowed_tran.include? type\n a = ::I18n.t(\"g_#{type}s\").clone # Because Translation is given by reference. REFERENCE.\n\n i = 0\n a.map! {|v| [i += 1, v]}\n\n a.to_h\n\n elsif allowed_spec.include? type\n get_special_list type\n\n else\n # TODO: Log error\n end\n end",
"def create_tps_hash(data, hash_type)\n return \"SECRET KEY NOT PROVIDED\" if !defined? @SECRET_KEY\n case hash_type \n when 'HMAC_SHA256'\n OpenSSL::HMAC.hexdigest('sha256', @SECRET_KEY, data)\n when 'SHA512'\n Digest::SHA512.hexdigest(@SECRET_KEY + data)\n when 'SHA256'\n Digest::SHA256.hexdigest(@SECRET_KEY + data)\n when 'MD5'\n Digest::MD5.hexdigest(@SECRET_KEY + data)\n else\n OpenSSL::HMAC.hexdigest('sha512', @SECRET_KEY, data)\n end\n end",
"def hash\n [bin_commercial, bin_corporate, bin_country_issued, bin_credit, bin_currency, bin_debit, bin_description, bin_eu, card_id, card_status, default, expmonth, expyear, label, label2, last4digits, scheme, token].hash\n end",
"def calculate_authorization_response_types\n []\n end",
"def hash\n [self.class, to_s].hash\n end",
"def hash\n [edge, interim_client, role].hash\n end",
"def hash\n bytes.hash\n end",
"def type\n case purpose\n when PURPOSE_TYPE[:legacy]\n 'pubkeyhash'\n when PURPOSE_TYPE[:nested_witness]\n 'p2wpkh-p2sh'\n when PURPOSE_TYPE[:native_segwit]\n 'p2wpkh'\n else\n 'unknown'\n end\n end",
"def types\n @data.keys & TYPES\n end",
"def hash\n guid.hash\n end",
"def to_hash\n {\n type: self.class.name,\n secret: secret,\n salt: salt,\n iterations: iterations,\n hash_function: hash_function.class.name\n }\n end",
"def all_types\n @mutex.synchronize do\n @types.keys.find_all{ |t_| !t_.is_a?(AnonymousType) }\n end\n end",
"def message_fingerprint\n return @message_fingerprint\n end",
"def platform_types\n @platform_types.to_hash\n end",
"def keys\n messages.keys\n end",
"def keys\n messages.keys\n end",
"def hash\n [expires_in, data, access_token, refresh_token, scope, token_type].hash\n end",
"def hash\r\n return to_s.hash\r\n end",
"def stat_hash(*type)\n\n if type === []\n type = @type \n end \n\n return type.map {|t| @raw[t]}\n\n end",
"def hash\n [author_email, author_name, author_time, branch, commit_time, committer_email, committer_name, default_branch, message, repository_url, sha, tag].hash\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\n [apm_scanned_bytes, events_scanned_bytes, hour, logs_scanned_bytes, org_name, public_id, rum_scanned_bytes, total_scanned_bytes].hash\n end",
"def hash\n\t\treturn [ self.class, self.dn ].hash\n\tend",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end"
] |
[
"0.66591483",
"0.6562162",
"0.6497484",
"0.63952833",
"0.62717116",
"0.6239237",
"0.6233638",
"0.62060845",
"0.6127952",
"0.608272",
"0.608272",
"0.6050678",
"0.59844804",
"0.59699756",
"0.5959553",
"0.59431374",
"0.59243554",
"0.5869893",
"0.5847079",
"0.5821665",
"0.58146155",
"0.5807263",
"0.58041793",
"0.57977796",
"0.57868385",
"0.5772712",
"0.5761176",
"0.5756454",
"0.5688334",
"0.5688203",
"0.568751",
"0.56826",
"0.56727165",
"0.5661862",
"0.56543255",
"0.56384706",
"0.5634892",
"0.5633176",
"0.5615614",
"0.5604119",
"0.55961967",
"0.5576505",
"0.55761266",
"0.5566106",
"0.55537564",
"0.5552205",
"0.5547885",
"0.55411273",
"0.552698",
"0.5526591",
"0.5519684",
"0.55105394",
"0.5501939",
"0.5457377",
"0.5452137",
"0.54474705",
"0.5447079",
"0.5447079",
"0.544638",
"0.54446137",
"0.5441891",
"0.543477",
"0.5431667",
"0.54298824",
"0.54277855",
"0.54164666",
"0.54085135",
"0.53853244",
"0.5384429",
"0.5382036",
"0.5378035",
"0.53756005",
"0.53746533",
"0.53725666",
"0.536763",
"0.5355543",
"0.53549635",
"0.5340143",
"0.5333209",
"0.5327315",
"0.53265035",
"0.53265035",
"0.5316776",
"0.530162",
"0.53014106",
"0.52893084",
"0.5286506",
"0.5286506",
"0.5286506",
"0.5286506",
"0.5286506",
"0.5286506",
"0.5286506",
"0.52844924",
"0.52842855",
"0.5283214",
"0.5283214",
"0.5283214",
"0.5283214",
"0.5283214",
"0.5283214"
] |
0.0
|
-1
|
Cached value of the tasks authorized to be processed
|
def hsdq_authorized_tasks(*tasks)
if tasks.any?
@hsdq_authorized_tasks = [tasks].flatten
else
@hsdq_authorized_tasks ||= [hsdq_opts[:tasks]].flatten
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def active_permitted_tasks\n ( self.restricted? ) ? self.tasks.active : Task.active\n end",
"def all_permitted_tasks\n ( self.restricted? ) ? self.tasks.scoped : Task.scoped\n end",
"def update_task_completion_status_cache!(tasks = nil)\n self.task_completion_status_cache ||= {}\n tasks ||= offering.tasks.find(:all, :conditions => \"context = 'applicant' AND completion_criteria != ''\")\n tasks = [tasks] unless tasks.is_a?(Array)\n for task in tasks\n tcs = task_completion_statuses.find_or_create_by_task_id(task.id)\n tcs.result = self.instance_eval(task.completion_criteria.to_s)\n tcs.complete = tcs.result == true\n tcs.save\n self.task_completion_status_cache[task.id] = tcs.attributes\n end\n task_completion_status_cache\n end",
"def index\n @tasks = policy_scope(Task)\n record.user == current_user\n end",
"def current_context_task_names()\n @cached_tasks.fetch(@active_context.get_task_cache_id(),[]).dup\n end",
"def all_tasks\n @task = Task.get_all_tasks_user_can_see(current_user)\n end",
"def tasks\n @tasks ||= {}\n end",
"def task_processing_results\n return @task_processing_results\n end",
"def task_processing_results\n return @task_processing_results\n end",
"def retrieve\n if not @perm_values then\n if not File.readable?(\"#{@perm_target}/tasks\") then\n raise Puppet::Error, \"You do not appear to have a cgroup mounted at '#{@perm_target}'\"\n end\n\n @perm_values = Hash.new\n\n @perm_values[:task_uid] = File.stat(\"#{@perm_target}/tasks\").uid\n @perm_values[:task_gid] = File.stat(\"#{@perm_target}/tasks\").gid\n\n admin_uid = []\n admin_gid = []\n Dir.glob(\"#{@perm_target}/*\").each do |file|\n next if not File.file?(file)\n next if file == \"#{@perm_target}/tasks\"\n\n admin_uid << File.stat(file).uid\n admin_gid << File.stat(file).gid\n end\n\n # Setting these to blank in the case of a mixed permissions set\n admin_uid.uniq.size == 1 ? @perm_values[:admin_uid] = admin_uid.first : @perm_values[:admin_uid] = \"!!MISMATCH!!\"\n admin_gid.uniq.size == 1 ? @perm_values[:admin_gid] = admin_gid.first : @perm_values[:admin_gid] = \"!!MISMATCH!!\"\n end\n\n @perm_values\n \n end",
"def tasks\n return @tasks.values\n end",
"def tasks_are_active_and_permitted\n self.tasks.all.each do | task |\n errors.add( :base, \"Task '#{ task.augmented_title }' is no longer active and cannot be included\" ) unless task.active\n\n if ( self.user.try( :restricted? ) )\n errors.add( :base, \"Inclusion of task '#{ task.augmented_title }' is no longer permitted\" ) unless self.user.task_ids.include?( task.id )\n end\n end\n end",
"def task_list_items\n result[:task_list_items] ||= []\n end",
"def set_task\n @task = Task.find(params[:id])\n \n if @task.user_id != @user.id\n render json: { message: \"Not authorized.\" }, status: :unauthorized\n end\n end",
"def invoked_tasks\n @invoked_tasks\n end",
"def set_task\n @task = Task.includes(:project).find(params[:id])\n if @task.project.user != current_user\n render plain: '', status: :forbidden\n end\n end",
"def my_task\n @my_id = current_user.id # may be redundant4 but will head towards service objects\n @tasks = Task.where(user_id: @my_id)\n end",
"def tasks\n @tasks ||= Evoke.tasks\n end",
"def index\n authenticate_user!\n @tasks = current_user.tasks\n end",
"def show\n authorize! :read, @task\n end",
"def task\n @keys[:task]\n end",
"def registered_tasks\n @task_register_lock.synchronize do\n @registered_tasks.values\n end\n end",
"def registered_tasks\n @task_register_lock.synchronize do\n @registered_tasks.values\n end\n end",
"def tasks\n Task.undone_for_user(goddamn_tfpid)\n end",
"def task_processingresult\n return @task_processingresult\n end",
"def cultivation_tasks\n Cultivation::Task.in(user_ids: id)\n end",
"def set_task\n @task = Task.where(authorization_id: Authorization.current_id).find(params[:id])\n end",
"def tasks\n @tasks ||= Task.find(self.task_ids)\n end",
"def actionable_tasks\n\t\tnext_tasks.select{ |t| !t.deferred? }\n\tend",
"def tasks\n return @tasks\n end",
"def tasks\n return @tasks\n end",
"def tasks\n return @tasks\n end",
"def tasks=(value)\n @tasks = value\n end",
"def tasks=(value)\n @tasks = value\n end",
"def tasks=(value)\n @tasks = value\n end",
"def index # all available task\n @task_check = Task.all\n # need to list only Tasks that is not owned by current_user\n if user_signed_in?\n @my_id = current_user.id\n # All Available task not current_user & checks for accepted_by_user_id == 0\n # query worked only after setting accepted_by_user_id to = 0 from nil\n # Set default field of accepted_by_user_id to 0 within task.rb via after_initialize\n # @tasks = Task.where(\"user_id != ? AND task_status = ? AND accepted_by_user_id = ?\", @my_id, \"Available\", 0)\n @tasks = Task.where(\"user_id != ? AND task_status = ? AND accepted_by_user_id = ?\", @my_id, \"Available\", 0)\n @tasks2 = @tasks\n else\n # All Available task including my tasks : user_signed_in?(false) => index display\n @tasks = Task.where(task_status: \"Available\")\n @tasks2 = @tasks\n end\n end",
"def my_accepted_task\n @my_id = current_user.id # redundant 3\n @tasks = Task.where(accepted_by_user_id: @my_id)\n # We may wish to only list task we are working on and with status processing, and nothing more\n #@tasks = Task.where(\"user_id != ? AND task_status = ? AND accepted_by_user_id = ?\", @my_id, \"available\", 0)\n @other_user_task_status_options = {finished: \"Finished\", processing: \"Processing\", error_in_tag: \"Errors in TAG\", Return_Tag: \"Please_Remove_Me\"}\n end",
"def total_tasks\n return @total_tasks\n end",
"def total_tasks\n return @total_tasks\n end",
"def index\n @tasks = @current_user.tasks\n end",
"def index\n set_tasks\n if @role === 'admin'\n @tasks = Task.all\n end\n if @role === 'merchant'\n @tasks = Task.where(merchant: spree_current_user.merchant_id)\n end\n end",
"def successful_tasks\n @successful_tasks ||= @tasks_results.select(&:success?)\n end",
"def task\n return @task\n end",
"def set_task\n @task = Task.find_by!(uuid: params[:id])\n\n # rubocop:disable Style/GuardClause\n if @task.user_id != @current_user.id\n render status: :forbidden, json: { error: 'You are not allowed to make this action.' }\n false\n end\n # rubocop:enable Style/GuardClause\n end",
"def task_completion_status(task_id, force_update = false)\n save if task_completion_status_cache.nil? || force_update\n task_completion_status_cache[task_id]\n end",
"def tasks\n @db[:tasks].keys.compact.uniq || []\n end",
"def list_user_tasks\n\t\t@tasks = current_user.get_developer_tasks\n\tend",
"def sync_tasks\n\n #TODO make this line optional\n @account_info = @authenticator.get_account\n\n #Add any tasks that needed to be added\n new_tasks = @tasks.keys.select{|task| task.brand_new?}\n @authenticator.add_tasks(new_tasks.collect {|task| task.json_parsed}) unless @new_tasks.new_tasks.empty?\n\n #Record that the tasks have already been added\n new_tasks.each {|task| task.no_longer_new}\n\n #Delete any tasks that were marked as deleted locally but not yet removed from @tasks\n deleted_tasks = @tasks.keys.select{|task| task.deleted?}\n @authenticator.delete_tasks(deleted_tasks.collect {|task| task.id}) unless deleted_tasks.empty?\n \n if lastedit_task > @last_task_sync\n #Get (recently edited) tasks\n tasks = @authenticator.get_tasks {:after => lastedit_task}\n \n locally_edited = []\n\n #TODO we may need to put this in a loop and load tasks page by page\n tasks.each do |task|\n if not @tasks[task.id]\n #If for some reason the task doesn't exist yet locally, add it\n @tasks[task.id] = task\n else\n #Compare modification times, update local copy when necessary, and resolve editing conflicts\n #Do NOT use task.last_mod, because that will just refer to the time that the get_tasks function was called!\n #Instead, we care about the time that the last edits were actually saved on the Toodledo server\n if task.modified > @tasks[task.id].last_mod\n #The server-stored task was modified more recently than the local task\n #TODO make sure all other locations are properly mutating the task, rather than creating parallel/outdated instances\n #If we simply overwrote the task instead of updating task.json_parsed, any past references to the task would point to an invalid/outdated\n @tasks[task.id].json_parsed = task.json_parsed\n @tasks[task.id].edit_saved\n else\n #The local task was modified more recently than the server-stored task\n #Realistically, the two timestamps cannot be the same, but if they are, we will assume the local copy is more accurate\n locally_edited.push(@tasks[task.id])\n end\n end\n end\n end\n\n if lastdelete_task > @last_task_sync\n #Query the deleted tasks (on the Toodledo server) and delete them here locally\n @user.get_deleted_tasks.collect{|task| task.id}.each do |id| \n #The delete boolean will be set just in case there are other references to the task, in which case it would not be garbage-collected\n @tasks[id].delete!\n @tasks[id].edit_saved #Make sure it won't be edited-saved in the future\n @tasks.delete(id)\n end\n end\n\n locally_edited = locally_edited.select{|task| not task.deleted?}\n @user.edit_tasks(locally_edited.collect{|task| task.json_parsed}) unless locally_edited.empty?\n \n #After this, the modified timestamp on the server will be the current time, which is later than the task.last_mod for any task stored locally\n \n #TODO check if there were repeating tasks that needed to be rescheduled\n \n #Remove any deleted tasks from @tasks. There may still be references elsewhere to them (depending on the application), so they may not necessarily be garbage-collected\n @tasks = @tasks.select{|task| not task.deleted?}\n\n @last_task_sync = Time.now\n end",
"def update_internal_task_lists\n\n # Security - discard tasks the user should not be able to see.\n\n if ( @current_user.restricted? )\n @tasks.select do | task |\n task.is_permitted_for?( @current_user )\n end\n end\n\n # Now the fiddly bit! Sort the task objects by augmented title, then\n # retrospectively rebuild the task ID arrays using the reordered list.\n\n Task.sort_by_augmented_title( @tasks )\n\n @task_ids = []\n @active_task_ids = []\n @inactive_task_ids = []\n\n @tasks.each do | task |\n @task_ids << task.id\n @active_task_ids << task.id if ( task.active )\n @inactive_task_ids << task.id unless ( task.active )\n end\n end",
"def tasks\n task_list.tasks\n end",
"def tasks\n if @tasks.nil?\n @tasks = tasks_by_filters\n @tasks = filter_by_tags(@tasks)\n @tasks += unread_tasks if session[:show_all_unread].to_i > 0\n @tasks = sort_tasks(@tasks)\n end\n\n return @tasks\n end",
"def status_cache_key\n [\n ip,\n ip_port,\n outlet,\n secondary_outlet,\n # Include username/password so that if one of the shared schedule is right and\n # the other is wrong we still do multiple queries: one gets an error and the other\n # doesn't.\n username,\n password,\n ]\n end",
"def get_taskarray\n @task_array\n end",
"def get_dashboard user_id\n task = self.tasks.my_uncompleted(user_id).sorted.first\n if task.nil?\n if self.start_on > Date.today || self.expires_on < Date.today\n -1\n else\n -2 # -2 : no task currently - create one!\n end\n else\n task.percent_complete\n end\n end",
"def task_assignments\n @task_assignments ||= Harvest::API::TaskAssignments.new(credentials)\n end",
"def get_user_tasks\n render json: get_current_user.tasks\n end",
"def own_tasks\n uri = self.uri\n query = Ruta::Sparql.select.where(\n [:task, RDF.type, Ruta::Class.task],\n [:task, Ruta::Property.has_creator, uri]\n )\n tasks = []\n query.each_solution { |sol| tasks.push(sol.task.as(Task)) }\n tasks\n end",
"def index\n active_task\n completed_task\n end",
"def task_params\n if user_signed_in?\n current_id = current_user.id\n else\n current_id = 1\n end\n params.fetch(:task, {}).permit(\n :name, :is_done\n ).merge(\n user_id: current_id\n )\n end",
"def set_task\n\t\t\t@task = Task.find(params[:id])\n\t\t\tnot_your_task if @task.user != current_user\n\t\tend",
"def index\n @tasks = Task.where(user_id: current_user.id)\n end",
"def rebuild_task_cache\n user = User.find_by_id(session[:id])\n user.kunis.all.each do |kuni|\n kuni.tasks.all.each do |task|\n puts task.s_count\n task.s_count = task.solutions.count\n task.save\n end\n end\n end",
"def task_lists\n\t\t@task_lists ||= fetch_latest_task_lists\n\tend",
"def total_tasks=(value)\n @total_tasks = value\n end",
"def total_tasks=(value)\n @total_tasks = value\n end",
"def index\n\n @tasks = Card.where(authorization_id: Authorization.current_id).find(params[:card_id]).tasks\n end",
"def value\n # double-checked locking is safe because we only update once\n return @value if @fulfilled\n\n @mutex.synchronize do\n unless @fulfilled\n begin\n @value = @task.call\n rescue\n @value = @default\n ensure\n @fulfilled = true\n end\n end\n return @value\n end\n end",
"def authorized_to_modify_task?\n current_user.site_admin? || can_view_all_manuscript_managers_for_journal? || can_view_manuscript_manager_for_paper? ||\n allowed_manuscript_information_task? || metadata_task_collaborator? || allowed_reviewer_task? || task_participant?\n end",
"def tasks_data_today \n tasks_of_today = self.tasks_due_today\n tasks = []\n tasks_of_today.each do |task|\n task = {\n task_name: task.name, \n completion_value: task.completions.last.completion_value,\n completion_max: task.completion_max,\n completion_unit: task.completion_unit\n }\n tasks << task \n end\n tasks \n end",
"def tasks\n @tasks ||= Harvest::API::Tasks.new(credentials)\n end",
"def value\n mutex.lock\n execute_task_once\n apply_deref_options(@value)\n ensure\n mutex.unlock\n end",
"def task(task_name, session, lock_mode, admin_auth=false, &block)\n begin\n # lock\n if lock_mode == :wt\n @lock.write_lock\n else\n @lock.read_lock\n end\n\n begin\n rc = authenticate(session, admin_auth, &block)\n log_msg = rc\n rescue => e\n rc = [false, e.message]\n log_msg = [false, e]\n end\n\n ensure\n # unlock\n if lock_mode == :wt\n @lock.write_unlock\n else\n @lock.read_unlock\n end\n end\n\n log_result(task_name, get_user_from_session(session), log_msg)\n return rc\n end",
"def get_user_tasks\n puts \"CURRENT USER: #{get_current_user}\"\n if get_current_user\n # if params[:category_ids].empty?\n tasks = get_current_user.tasks.order(created_at: :desc)\n tasks_categories = TaskSerializer.new(tasks)\n\n puts \"CATEGORRRIES\", tasks_categories\n\n render json: TaskSerializer.new(tasks).to_serialized_json\n else \n render json: {\n error: \"Login to see tasks\"\n }\n # render json: get_current_user.tasks.order(created_at: :desc)\n end \n end",
"def new_tasks_pending tasks\n tasks ||= []\n self.task_ids += tasks\n\n # Salva a instancia apos adicionar as novas task's\n self.save\n end",
"def claimed_chore?\n tasks.where(completion_status: \"pending\").count > 0\n end",
"def active_tasks\n @tasks.select { | task | task.active }\n end",
"def index\n\t if current_user.has_role? :admin\n\t\t @tasks = Task.all\n\t elsif current_user.has_role? :ing\n\t\t @user = User.find(current_user)\n\t\t @tasks = @user.tasks\n\t end\n end",
"def total_tasks_count\n return @total_tasks_count\n end",
"def total_tasks\n tasks.count\n end",
"def show\n # Restrict access\n check_if_admin unless @task.user_id == @person.id || @task.state == 'open'\n end",
"def task_get(task_name)\n tasks.fetch prepare_key(task_name), nil\n end",
"def client_tasks\n self.all(:conditions => {:client_task => true})\n end",
"def get_running_task(t_info) \n if t_info.key?(\"time_entries\")\n t_info[\"time_entries\"].each do |i|\n return i if i.key?(\"stop\") == false\n end\n return \"This User has no Running Tasks\"\n else\n return \"This User has no Tasks!\"\n end\n end",
"def get_available_tasks\n tasks_to_return = []\n @tasks_names.each{ |t_name|\n tasks_to_return.push(@tasks[t_name])\n } \n return tasks_to_return\n end",
"def show\n Observer.find_or_create_by(session_id: session[:session_id])\n .update(task_id: @task.id, updated_at: DateTime.now)\n @my_tasks = current_user.tasks.where.not(id: current_user.current_task.id)\n end",
"def final_completed_tasks\n self.tasks.order(\"created_at DESC\").group_by {|t| t.id }.map { |k, v| v.first }\n end",
"def set_and_log_tasks_already_ran(evaluated_tasks)\n return [] if evaluated_tasks.empty?\n\n already_ran = []\n\n evaluated_tasks.each do |evaluated_task|\n successful_attempt = find_successful_attempt_for_task(evaluated_task)\n already_ran << tasks_updater.set_and_log_task_as_already_ran(evaluated_task, successful_attempt) if successful_attempt\n end\n\n already_ran\n end",
"def check\n @trainer = Trainer.find(params[:id])\n temp = session[@trainer.id.to_s + \"_trainer\"]\n temp[:user_ans] = params[:user_ans].to_f.round(1)\n @generated_task = temp\n end",
"def complete_task(task)\n self.task_completion_status_cache ||= {}\n task = OfferingAdminPhaseTask.find(task) unless task.is_a?(OfferingAdminPhaseTask)\n tcs = task_completion_statuses.find_or_create_by_task_id(task.id)\n tcs.result = true\n tcs.complete = true\n tcs.save\n self.task_completion_status_cache[task.id] = tcs.attributes\n tcs\n end",
"def tasks\n if @tasks.nil?\n @tasks ||= (filtering_by_tags? ? tasks_by_tags : tasks_by_filters)\n @tasks = filter_by_properties(@tasks)\n @tasks = sort_tasks(@tasks)\n end\n\n return @tasks\n end",
"def task_available\n return unless task\n\n validate_task_has_no_pending\n validate_task_has_no_approved\n end",
"def tasks_for(list)\n\t\t@tasks[list] ||= fetch_latest_tasks_for(list)\n\tend",
"def index\n @user = current_user\n if @user.project_manager\n @tasks = Task.where(pm_id: @user.id)\n else\n @tasks = Task.where(collaborator_id: @user.id)\n end\n\n end",
"def task=(value)\n @task = value\n end",
"def permission_for_task?( task )\n tasklist.present? && tasklist.split(',').map{ |v| Integer(v) }.include?( task )\n end",
"def task_revoke(tasks_revoke, data_inject = nil)\n tasks_revoke = [tasks_revoke].flatten.uniq\n task_object = tasks_context.find { |t| t.is_a?(tasks_revoke.first) }\n return nil unless task_object and task_object.active\n\n unless task_object.revokable?(tasks_revoke[1..-1])\n raise \"Task unrevoke: #{task_object} #{tasks_revoke.collect { |t| t.name }.inspect}\"\n end\n \n primary_task = nil\n OrderTask.transaction do\n tasks_context.each do |task|\n next unless !task.new_record? and task.active and tasks_revoke.include?(task.class)\n\n task.active = nil\n\n if task.is_a?(tasks_revoke.first)\n primary_task = task \n if data_inject\n raise \"Task data must be hash instead #{task.data.inspect}\" unless !task.data or task.data.is_a?(Hash)\n raise \"Passed data must be hash instead #{data_inject}\" unless data_inject.is_a?(Hash)\n task.data = task.data.merge(data_inject)\n end\n end\n task.save!\n tasks_active.target.delete(task)\n end\n end\n return primary_task\n end",
"def active_tasks\n request.method = :get\n request.uri = '_active_tasks'\n Couchdbtools.execute(request)\n end",
"def set_task\n @task = current_user.tasks.find(params[:email])\n end",
"def get_assignable_users\n @assignable_users = TaskType.get_users(@task_type) \n end",
"def done\n done_ids = @tasks.keys.find_all do |id|\n @tasks[id].done?\n end\n done_tasks = done_ids.inject({}) do |map, id|\n map[id] = @tasks[id]\n map\n end\n done_ids.each do |id|\n @tasks.delete(id)\n end\n return done_tasks\n end"
] |
[
"0.66707957",
"0.63352734",
"0.625641",
"0.61616063",
"0.60851854",
"0.60552716",
"0.60341424",
"0.589842",
"0.589842",
"0.5854229",
"0.585054",
"0.5847502",
"0.58469665",
"0.58457255",
"0.5844895",
"0.5820754",
"0.5817586",
"0.5772821",
"0.5747787",
"0.5742558",
"0.57385063",
"0.5736906",
"0.57363737",
"0.56907994",
"0.567916",
"0.5644986",
"0.5643388",
"0.5627137",
"0.5625038",
"0.5623101",
"0.5623101",
"0.5623101",
"0.56005657",
"0.56005657",
"0.56005657",
"0.55900246",
"0.5585188",
"0.55769324",
"0.55769324",
"0.55637527",
"0.55590945",
"0.55559045",
"0.5551988",
"0.55506253",
"0.5545215",
"0.55435836",
"0.55200356",
"0.54962647",
"0.54808706",
"0.54701394",
"0.5465622",
"0.54642075",
"0.5463167",
"0.54528284",
"0.5450565",
"0.54399043",
"0.5429308",
"0.54251295",
"0.5417827",
"0.5405257",
"0.5404714",
"0.53959227",
"0.5387696",
"0.5380252",
"0.5380252",
"0.5380124",
"0.5376078",
"0.5365468",
"0.5363307",
"0.5361821",
"0.53607714",
"0.5357947",
"0.5352984",
"0.5349822",
"0.53475976",
"0.53425205",
"0.5332476",
"0.5331526",
"0.53296864",
"0.5322572",
"0.5318769",
"0.5312716",
"0.53110397",
"0.5305471",
"0.5292117",
"0.5283555",
"0.52820504",
"0.52808785",
"0.5277223",
"0.527704",
"0.52740055",
"0.52707",
"0.52691644",
"0.526139",
"0.5258924",
"0.5251727",
"0.52510154",
"0.52476025",
"0.5244026",
"0.5233523"
] |
0.56039107
|
32
|
Cached value of the topics authorized to be processed
|
def hsdq_authorized_topics(*topics)
if topics.any?
@hsdq_authorized_topics = [topics].flatten
else
@hsdq_authorized_topics ||= [hsdq_opts[:topics]].flatten
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def my_topic\n @published_topics = current_user.topics.published\n @unpublished_topics = current_user.topics.unpublished\n end",
"def index\n @published_topics = current_user.topics.published\n @unpublished_topics = current_user.topics.unpublished\n end",
"def topics_with_cache\n if new_record?\n @associated_topics_cache || []\n else\n self.topics_without_cache\n end\n end",
"def topics\n _topics\n end",
"def index\n @topics = current_user.topics\n end",
"def save_topics\n self.topics = @associated_topics_cache if @associated_topics_cache\n end",
"def get_topics_values\n @chapter = Chapter.find(params[:id]) unless params[:id].blank?\n if current_user.is?(\"EA\") or current_user.is?(\"IA\")\n list = @chapter.topics.map {|u| Hash[value: (u.id.to_s+'|'+get_params(u.params.to_s)), name: u.name]}\n else\n topic_ids = ContentUserLayout.get_unlocked_topics(@chapter,current_user)\n if !topic_ids.nil?\n list = @chapter.topics.where(:id=>topic_ids).map {|u| Hash[value: (u.id.to_s+'|'+get_params(u.params.to_s)), name: u.name]}\n else\n list = @chapter.topics.map {|u| Hash[value: (u.id.to_s+'|'+get_params(u.params.to_s)), name: u.name]}\n end\n end\n render json: list\n end",
"def find_user_data\n if @guardian.current_user && @all_topics.present?\n topic_lookup = TopicUser.lookup_for(@guardian.current_user, @all_topics)\n @all_topics.each { |ft| ft.user_data = topic_lookup[ft.id] }\n end\n end",
"def get_topics\n @chapter = Chapter.find(params[:id]) unless params[:id].blank?\n if current_user.is?(\"EA\") or current_user.is?(\"IA\")\n list = @chapter.topics.map {|u| Hash[value: u.id, name: u.name]}\n else\n topic_ids = ContentUserLayout.get_unlocked_topics(@chapter,current_user)\n if !topic_ids.nil?\n list = @chapter.topics.where(:id=>topic_ids).map {|u| Hash[value: u.id, name: u.name]}\n else\n list = @chapter.topics.map {|u| Hash[value: u.id, name: u.name]}\n end\n end\n render json: list\n end",
"def get_topics\n @topics = Topic.all\n end",
"def get_topics\n @topics = Topic.all\n end",
"def topic_ids\n new_record? ? (@associated_topics_cache ? @associated_topics_cache.compact.map(&:id) : []) : self.topics.map(&:id)\n end",
"def index\n\n\t @resource = User.find_by_authentication_token(params[:auth_token])\n\t # byebug\n\t return invalid_user unless @resource\n\t @subtopics = Subtopic.all\n\t # @user = current_user\n\tend",
"def get(*topics)\n # FIXME: implement this\n end",
"def topics_count\n object.topics.count\n end",
"def coarse_topics\n _coarse_topics\n end",
"def all\n data = service.list_topics.to_h[:topics] || []\n load(data)\n end",
"def topics\n respond_to?(:topic) ? topic : []\n end",
"def topics\n begin\n case params[:filter].to_i\n when 0: #everyone. unfiltered.\n @topics = @owner.topics.unfiltered\n when 1: #my topics\n @topics = @owner.topics.by_userlist(logged_in_user.id)\n when 2: #my friend's topics\n @topics = @owner.topics.by_userlist(logged_in_user.friends)\n when 3: #topics by classmates\n #@topics = @owner.topics.by_userlist(@logged_in_user.classmates)\n @topics = @owner.topics.unfiltered\n else\n params[:filter] = 0\n @topics = @owner.topics.unfiltered\n end\n case params[:sorter].to_i\n when 0: #latest replies\n @topics.sort! { |x,y| y.latest_post.created_on <=> x.latest_post.created_on}\n when 1: #newest posts\n @topics.sort! { |x,y| y.created_on <=> x.created_on }\n when 2: #most people\n @topics.sort! { |x,y| y.people_count <=> x.people_count }\n when 3: #most posts\n @topics.sort! { |x,y| y.posts.count <=> x.posts.count }\n else\n params[:sorter] = 0\n @topics.sort! { |x,y| y.latest_post.created_on <=> x.latest_post.created_on}\n end\n rescue Exception => e #render_return\n puts e.inspect\n end\n end",
"def topics_for_course\n redirect_guest\n @course = Course.find(params[:id])\n @topics = @course.topics\n end",
"def topic_search\n @topic_search ||= begin\n vals = []\n vals.concat(subject_topics) if subject_topics\n vals.empty? ? nil : vals\n end\n end",
"def pending\n @topics = if current_course_user&.student?\n unread_topics_for_student\n else\n all_topics.pending_staff_reply\n end\n\n render_topics_list_data\n end",
"def has_topics?\n !self.topics.empty?\n end",
"def index\n @topics = @ip.topics\n end",
"def index\n @user_topics = UserTopic.all\n end",
"def index\n @topics = Topic.published\n end",
"def all\n data = service.list_topics.body[\"topics\"] || []\n load(data)\n end",
"def topics\n optional! :order, type: String, default: \"recent\", values: %w[recent likes replies]\n optional! :offset, type: Integer, default: 0\n optional! :limit, type: Integer, default: 20, values: 1..150\n\n @topics = @user.topics.fields_for_list\n @topics =\n if params[:order] == \"likes\"\n @topics.high_likes\n elsif params[:order] == \"replies\"\n @topics.high_replies\n else\n @topics.recent\n end\n @topics = @topics.includes(:user).offset(params[:offset]).limit(params[:limit])\n end",
"def topics\n topics = [\"News\", \"A.I.\", \"V.R.\", \"RMIT\", \"Game\", \"Rails\", \"Go\", \"Web\", \"M.L\", \"Joke\", \"React\", \"Vue\", \"Node\", \"iOS\", \"AWS\"]\n end",
"def update_topics_kases_count\n self.topics.each do |topic|\n ua = {}\n ua.merge!(:kases_count => topic.kases.count(\"kases.id\", self.class.find_options_for_visible({:distinct => true}))) if topic.class.columns.to_a.map {|a| a.name.to_sym}.include?(:kases_count)\n ua.merge!(:people_count => topic.people.count) if topic.class.columns.to_a.map {|a| a.name.to_sym}.include?(:people_count)\n unless ua.empty?\n topic.class.transaction do \n topic.lock!\n topic.update_attributes(ua)\n end\n end\n end\n end",
"def define_topics\n @topics = {\n 'uk' => 'UK',\n 'world' => 'World',\n 'education' => 'Education',\n 'politics' => 'Politics',\n 'health' => 'Health',\n 'science_and_environment' => 'Science and Environment',\n 'business' => 'Business',\n 'technology' => 'Technology',\n 'entertainment_and_arts' => 'Entertainment and Arts'\n }\n end",
"def unread_topics user\r\n topics.find_all{|topic| topic.unread_comment?(user) }\r\n end",
"def topic\n load\n @topic\n end",
"def owned_topic\n unless current_user.id == @topic.user_id\n flash[:alert] = \"Opps! You don't have permission to do that.\"\n end\n end",
"def load\n unless @id.nil?\n typed_member_ids = Strand.redis.smembers(SCOPE + ':' + @id.to_s).map { |x| x.split(':') }.group_by(&:first).map { |c, xs| [c, xs.map(&:last)] }\n typed_member_ids.each do |typed_ids|\n @members += typed_ids.first.constantize.find_by_sql(\n [\n 'SELECT x.*, l.topic_id FROM ' + typed_ids.first.tableize + ' x LEFT OUTER JOIN links l ON l.target_id = x.id AND target_type = ? WHERE x.id IN (?)',\n typed_ids.first.classify,\n typed_ids.last\n ]\n )\n end\n topic_ids = @members.map(&:topic_id).compact.uniq\n topics = Hash[Topic.find(topic_ids).collect { |t| [t.id, t] }]\n @members.each { |m| m.association(:topic).target = topics[m.topic_id] unless m.topic_id.nil? }\n topic_code = Strand.redis.hget TOPICS, @id\n unless topic_code.nil?\n @topic = Topic.find_by_code topic_code\n end\n @good = Strand.redis.hget STATUS, @id\n end\n self\n end",
"def topics=(value)\n @topics = value.is_a?(Array) ? value : [value]\n end",
"def remember_topic(topic)\n @monitor.synchronize {\n @topic_map[topic.name] = topic\n }\n end",
"def topics\n @topics ||= [cloudenvoy_options_hash[:topic], cloudenvoy_options_hash[:topics]].flatten.compact.map do |t|\n t.is_a?(String) ? { name: t } : t\n end\n end",
"def muted_topics\n @muted_topics ||= (self[:muted_topics].blank? ? [] : YAML.load(self[:muted_topics]))\n end",
"def topic\n return @topic\n end",
"def find_topic\n @topic = current_user.topics.find(params[:topic_id])\n end",
"def find_topic\n @topic = current_user.topics.find(params[:topic_id])\n end",
"def show\n\t resource = User.find_by_authentication_token(params[:auth_token])\n\t return invalid_user unless resource\n\n\t @topic = Topic.where(:id => \"#{params[:topic_id]}\").first\n\t return invalid_topic unless @topic.present?\n\n\t unless resource.has_admin_previlages?\n\t\t\tlog_topic_activity resource , @topic.name, \"#{resource.first_name} clicked this topic, #{@topic.name}\" \n\t\tend\n\n\t\t@questions = @topic.questions.page(params[:page]).per_page(10)\n\n\t end",
"def get_topics_cohort\n # If affect is all, that means all matching tickets should be bulk updated\n if params[:affect].present? && params[:affect] == \"all\"\n if params[:status].present?\n @topics = Topic.where(current_status: params[:status]).all\n elsif params[:q].present?\n @topics = Topic.admin_search(params[:q])\n end\n\n # Select topics from params\n else\n @topics = Topic.where(id: params[:topic_ids]).all\n end\n \n end",
"def list_topics\n outputter.print_topics(guides.keys)\n 0\n end",
"def reload_topic!\n clear_topic_cache\n end",
"def index\n respond_with current_user.topics.all.to_json(:include => [:posts, :owner])\n end",
"def index\n @topics = Topic.includes(:user).includes(:responses).subscribed_by(@user).order('id DESC').page(params[:page])\n end",
"def topics\n\t\t\t# Magically make arrays from string Wooooo!\n\t\t\tuid = params[\"uid\"].split(\",\")\n\t\t\ttid = params[\"tid\"].split(\",\")\n\n\t\t\t#request post from usrs AND specific topics ahhhhhhh!\n\t\t\tposts = Post.where('user_id IN (?) OR topic_id IN (?) OR raw LIKE (?)', uid, tid, '%@everyone%' )\n\t\t\t \t\t\t\t\t\t\t\t\t.order(created_at: :desc)\n\t\t\t \t.limit(params[\"total\"])\n\t\t\t\t\t\t\t\t\t\t\t\t.offset(params[\"start\"])\n\n\t\t\t# that cleaned that up\n\t\t\trender_json_dump(serialize_data(posts, PostSerializer))\n\t\t\t#K shows over\n\t\tend",
"def index\n @feeds = current_user.subscriptions.ordered_by_title\n @entries = current_user.entries.for_user(current_user.id, @@per_page).paginate(page: params[:page], per_page: @@per_page).set_read_attribute\n @unread_entries_count = current_user.reads.where(read: false).count \n end",
"def subject_topics\n @subject_topics ||= term_values([:subject, :topic])\n end",
"def header\n @topics ||= begin\n objects = Registry.all(:class, :module)\n\n objects.delete_if do |controller_object|\n controller_object.children.all? { |method_object| cancan_ability_filter(method_object, cancan_ability(options.verifier.roles)) }\n end\n\n {}.tap do |topics|\n index_objects(objects).each do |object|\n object.tags('topic').each { |topic| (topics[topic.text] ||= []) << object }\n end\n end\n end\n\n @role = options.verifier.roles.first =~ /user/ ? \"client\" : options.verifier.roles.first\n\n erb(:header)\nend",
"def topics\n client = Comments.discourse\n @topics = client.latest_topics\n respond_to do |fmt|\n fmt.js { }\n end\n end",
"def update_scrap_topic\n # Not allowed for now\n render_401 and return\n end",
"def get_suggested_topics(assignment_id)\n team_id = TeamsUser.team_id(assignment_id, session[:user].id)\n teams_users = TeamsUser.where(team_id: team_id)\n teams_users_array = Array.new\n teams_users.each do |teams_user|\n teams_users_array << teams_user.user_id\n end\n @suggested_topics = SignUpTopic.where(assignment_id: assignment_id, private_to: teams_users_array)\n end",
"def show\n @stickied_topics = Topic.where(forum_id: @forum.id, stickied: true).order('last_post_at DESC')\n @topics = Topic.where(forum_id: @forum.id, stickied: false).order('last_post_at DESC')\n if @forum.id == Forum.city_hall_forum_id\n current_user.update_attributes(city_hall_notice: false) if current_user.city_hall_notice\n end\n end",
"def topic=(value)\n @topic = value\n end",
"def topic\n return @topic\n end",
"def topic\n return @topic\n end",
"def index\n @topics = Topic.all\n @new_topics = Topic.all.order(created_at: :desc).first(5)\n \n count = Hash.new\n \n Topic.ids.each do |id|\n count[id] = Topic.find(id).comments.count\n end\n \n comment = Hash[ count.sort_by{ |_, v| -v } ]\n \n @many_comments_topics = Topic.find(comment.keys)\n end",
"def view\n get_topic(@current_id, :resolve => false)\n get_complete_topic(@current_id, :resolve => false)\n get_related_for_current\n end",
"def can_read_forem_topic? topic\n true\n end",
"def set_topics \n # Below - All city topics for filter panel obj pass. \n @ossembly = @city.topics\n # Below - Lets Talk topic and all corresponding subtopics.\n @lets_talk = @city.topics.find_by_name(\"Let's Talk\")\n @general_talk = @city.subtopics.find_by_name(\"General Talk\")\n @help_out = @city.subtopics.find_by_name(\"Help Me Out\")\n @sports = @city.subtopics.find_by_name(\"Sports\")\n @business_buzz = @city.subtopics.find_by_name(\"Business Buzz\")\n @grinds_gears = @city.subtopics.find_by_name(\"Grinds My Gears\")\n # Below - Good Vibes topic and all corresponding subtopics.\n @good_vibes = @city.topics.find_by_name(\"Good Vibes\")\n @general_good = @city.subtopics.find_by_name(\"General Good\")\n @good_news = @city.subtopics.find_by_name(\"Good News\")\n @furry_friends = @city.subtopics.find_by_name(\"Furry Friends\")\n @city_snaps = @city.subtopics.find_by_name(\"City Snaps\")\n @local_historian = @city.subtopics.find_by_name(\"Local Historian\")\n # Below - City Affairs topic and all corresponding subtopics.\n @city_affairs = @city.topics.find_by_name(\"City Affairs\")\n @general_affairs = @city.subtopics.find_by_name(\"General Affairs\")\n @ballots = @city.subtopics.find_by_name(\"Ballots\")\n @schools = @city.subtopics.find_by_name(\"Schools\")\n @city_improvements = @city.subtopics.find_by_name(\"City Improvements\")\n @events = @city.subtopics.find_by_name(\"Events\")\n end",
"def set_topics\n if @topics == [] || @topics == nil\n @topics = []\n @topics.push(@database_name)\n end\n @topics.uniq!\n @topics.each {|topic| @dataset.topics << topic}\n end",
"def topics\n @topics ||= import.map { |topic| Topic.parse(topic) }\n end",
"def show\n\t\treferenced = @topic.tweets.count(:distinct)\n\t\tusers = @topic.tweets.user.count(:distinct)\n\t\trender json: show_json(@topic, referenced, users)\n\tend",
"def update\n # Making sure only signed in users can access\n # if user_signed_in?\n topic = Topic.find(params[:id])\n topic.update(topic_params)\n if topic.valid?\n render json: topic\n else\n render json: topic.errors\n end\n # else\n # render status: 403, plain: 'Please Sign In to Access'\n # end\n end",
"def own_topic?(topic)\n topic.read_attribute(:user_id) == self.id\n end",
"def topic_names\n if topic.blank?\n {}\n else\n @topic_names ||= topic.sub_topics.collect { |t| t.name }.join(' ')\n end\n end",
"def update_forum_counter_cache\n @forum_conditions = ['topics_count = ?', Topic.count(:id, :conditions => \"forum_id = #{forum_id}\")]\n account_for_forum_change\n Forum.update_all @forum_conditions, ['id = ?', forum_id]\n @old_forum_id = nil\n set_section_topic_count\n end",
"def index\n\n\t\t@topics = Topic.all\n\n\t\treturn @topics\n\n\tend",
"def answered_topics_by_user\n user_answers = Answer.where(uuid: params[:uuid])\n topic_ids = user_answers.map{ |a| a.statement.topic.id }\n render json: topic_ids.uniq, status:200\n end",
"def including_topics_list\n names_string(self.includes_topics)\n end",
"def get_user_count(id, topic_name)\n timenow = DateTime.now\n if topic_name != \"Main\"\n return Active.where(:channel_id => id, :topic_name => topic_name).where(\"updated > ?\", timenow-5.seconds).size\n else\n return Active.where(:channel_id => id).where(\"updated > ?\", timenow-5.seconds).size\n end\n end",
"def edit\n @post = Post.find(params[:id])\n @topics = @topic.category.topics.sorted\n @post_count = Post.count\n end",
"def toggle_privacy\n\n #handle array of topics\n # @topics = Topic.where(id: params[:topic_ids])\n @topics.update_all(private: params[:private], forum_id: params[:forum_id])\n @topics.each{|topic| topic.update_pg_search_document}\n bulk_post_attributes = []\n\n @topics.each do |topic|\n if topic.forum_id == 1\n bulk_post_attributes << {body: I18n.t(:converted_to_ticket), kind: 'note', user_id: current_user.id, topic_id: topic.id}\n flash[:notice] = I18n.t(:converted_to_ticket)\n else\n bulk_post_attributes << {body: I18n.t(:converted_to_topic, forum_name: topic.forum.name), kind: 'note', user_id: current_user.id, topic_id: topic.id}\n flash[:notice] = I18n.t(:converted_to_topic, forum_name: topic.forum.name)\n end\n\n # Calls to GA\n tracker(\"Agent: #{current_user.name}\", \"Moved to #{topic.forum.name}\", @topic.to_param, 0)\n end\n\n # Bulk insert notes\n Post.bulk_insert values: bulk_post_attributes\n\n @topic = @topics.last\n @posts = @topic.posts.chronologic\n\n fetch_counts\n get_all_teams\n get_tickets_by_status\n\n\n # respond_to do |format|\n # format.js {\n if params[:topic_ids].count > 1\n render 'index'\n else\n render 'update_ticket', id: @topic.id\n end\n # }\n # end\n\n end",
"def on_get(path)\n topics = I3.server.remote_account_as(Account).viewable_topics\n articles = Article.find_recent(MAX_ARTICLES, topics).collect do |article|\n item = I3::SharedObject.new\n if article.comments.count > 0\n item.modified_at = article.comments.last.posted_at\n item.last_contributor = article.comments.last.author.full_name\n else\n item.modified_at = article.posted_at\n item.last_contributor = article.author.full_name\n end #if\n item.author = article.author.full_name\n item.subject = article.subject\n item.uri = '/bboard/data/messages/%s/%s/%s' % [\n article.topic.permalink,\n article.posted_at.strftime(\"%Y/%m/%d\"),\n article.permalink\n ]\n item.comment_count = article.comments.count\n item\n end #collect\n I3.server.send_object(articles)\n end",
"def all_topics\n topics = Feed.find(params[:feed_id]).topics\n render :json => topics\n end",
"def index\n @topics = Topic.all\n end",
"def index\n @topics = Topic.all\n end",
"def index\n @topics = Topic.all\n end",
"def topic=(value)\n @topic = value\n end",
"def topic=(value)\n @topic = value\n end",
"def index\n @tasks = policy_scope(Task)\n record.user == current_user\n end",
"def top_topics\n topics_with_views = Hash.new\n topics.each do |topic|\n topics_with_views[topic] = getViews(topic)\n end\n topics_with_views = topics_with_views.sort_by { |k, v| v }.reverse\n return topics_with_views\n end",
"def authorizations\n @@authorized_actions ||= {}\n @@authorized_actions\n end",
"def all_following_topics\n topics = User.find(params[:user_id]).following_topics\n render :json => topics\n end",
"def authorized(m)\n m.user == current_user\n end",
"def find_share\n @share = @topic.shares.find(params[:id])\n authorize @share\n end",
"def update!(**args)\n @topics = args[:topics] unless args[:topics].nil?\n @next_page_token = args[:next_page_token] unless args[:next_page_token].nil?\n end",
"def show\n # Making sure only signed in users can access\n # if user_signed_in?\n topic = Topic.find(params[:id])\n render json: topic\n # else\n # render status: 403, plain: 'Please Sign In to Access'\n # end\n end",
"def user_topic_share_count(user_id, topic_neo_id)\n #Rails.cache.fetch(\"neo4j-#{user_id}-#{topic_id}-share_count\", :expires_in => 1.day) do\n count = 0\n query = \"\n START n=node(#{topic_neo_id})\n MATCH n-[:pull*0..20]->x<-[r:talking]-y\n WHERE y.uuid = '#{user_id}'\n RETURN r.shares\n \"\n data = Neo4j.neo.execute_query(query)\n ids = []\n if data && data['data']\n data['data'].each do |d|\n ids += d[0]\n end\n count = ids.uniq.length\n end\n count\n #end\n end",
"def index\n @topics = Admin::Topic.order(date: :desc).paginate(page: params[:page], per_page: 20)\n end",
"def index\n @class_topics = ClassTopic.all\n end",
"def messages_for(topic)\n @delivery_lock.synchronize do\n # Return a clone so that the list of messages can be traversed\n # without worrying about a concurrent modification\n @messages[topic].clone\n end\n end",
"def show\n\n\t @resource = User.find_by_authentication_token(params[:auth_token])\n\t return invalid_user unless @resource\n\t @subtopic = Subtopic.find(params[:id])\n\n\t return cannot_find_subtopic unless @subtopic\n\t \n\t # end\n\tend",
"def get_most_recently_visited_topics(org_unit_id) # GET\n query_string = \"/d2l/api/le/#{$le_ver}/#{org_unit_id}/content/recent\"\n _get(query_string)\n # Returns: a JSON array of Topic ToC entries.\nend",
"def index\n @topics = Topic.all\n end",
"def profile_viewed!\n $redis.incr \"#{key}:views\"\n end",
"def authorize subscriber, node\n true\n end"
] |
[
"0.6574096",
"0.6515707",
"0.6410573",
"0.63099027",
"0.62513775",
"0.61848086",
"0.6099768",
"0.58392316",
"0.5755114",
"0.5746827",
"0.5746827",
"0.5649583",
"0.557454",
"0.5556482",
"0.5526483",
"0.551546",
"0.55131006",
"0.55011934",
"0.54585177",
"0.5427703",
"0.5410237",
"0.54036653",
"0.5397976",
"0.5387917",
"0.5379741",
"0.53617847",
"0.5312569",
"0.530785",
"0.5250371",
"0.5231411",
"0.5220973",
"0.5208064",
"0.51781344",
"0.5158685",
"0.5147588",
"0.51417",
"0.5119485",
"0.5098118",
"0.5092692",
"0.50901955",
"0.5084566",
"0.5084566",
"0.50797045",
"0.50671",
"0.5062855",
"0.5061727",
"0.50353724",
"0.50241435",
"0.5020448",
"0.50108653",
"0.5010747",
"0.5010044",
"0.50066346",
"0.4999429",
"0.49940783",
"0.49940246",
"0.49925497",
"0.49862146",
"0.49862146",
"0.49802256",
"0.4946355",
"0.49367264",
"0.49288356",
"0.49257323",
"0.49198282",
"0.49097985",
"0.490561",
"0.4901009",
"0.48988572",
"0.48955595",
"0.48925352",
"0.48767674",
"0.4874145",
"0.4870657",
"0.48617932",
"0.48604897",
"0.4859136",
"0.48583528",
"0.48530397",
"0.48530397",
"0.48530397",
"0.4847776",
"0.4847776",
"0.4846399",
"0.4838961",
"0.48345444",
"0.48293856",
"0.4827823",
"0.48264703",
"0.48220095",
"0.48152286",
"0.481369",
"0.48102328",
"0.48100203",
"0.48034725",
"0.48023227",
"0.4800451",
"0.4799927",
"0.4799751",
"0.47907376"
] |
0.57883227
|
8
|
test the task against the list of authorised tasks
|
def valid_task?(spark, _options)
return true if spark[:task].nil? || hsdq_authorized_tasks.empty?
hsdq_authorized_tasks.include?(spark[:task].to_sym)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def permission_for_task?( task )\n tasklist.present? && tasklist.split(',').map{ |v| Integer(v) }.include?( task )\n end",
"def tasks_are_active_and_permitted\n self.tasks.all.each do | task |\n errors.add( :base, \"Task '#{ task.augmented_title }' is no longer active and cannot be included\" ) unless task.active\n\n if ( self.user.try( :restricted? ) )\n errors.add( :base, \"Inclusion of task '#{ task.augmented_title }' is no longer permitted\" ) unless self.user.task_ids.include?( task.id )\n end\n end\n end",
"def similar_task(user, taskname)\n can_create_task = true\n user.assignments.each do |assignment_instance|\n if assignment_instance.taskname.downcase == taskname.downcase\n # binding.pry \n can_create_task = false \n end \n end\n can_create_task\n end",
"def edit\n get_current_user\n if @user.tasks.include?(task) #If the task they want to edit belongs to them\n task\n else #If the task they want to edit does NOT belong to them\n flash.alert = \"You can only edit your own tasks.\"\n redirect_to root_path\n end\n end",
"def index\n @tasks = policy_scope(Task)\n record.user == current_user\n end",
"def authorized_to_modify_task?\n current_user.site_admin? || can_view_all_manuscript_managers_for_journal? || can_view_manuscript_manager_for_paper? ||\n allowed_manuscript_information_task? || metadata_task_collaborator? || allowed_reviewer_task? || task_participant?\n end",
"def set_task\n @task = Task.find(params[:id])\n \n if @task.user_id != @user.id\n render json: { message: \"Not authorized.\" }, status: :unauthorized\n end\n end",
"def set_task\n @task = Task.find_by!(uuid: params[:id])\n\n # rubocop:disable Style/GuardClause\n if @task.user_id != @current_user.id\n render status: :forbidden, json: { error: 'You are not allowed to make this action.' }\n false\n end\n # rubocop:enable Style/GuardClause\n end",
"def show\n # Restrict access\n check_if_admin unless @task.user_id == @person.id || @task.state == 'open'\n end",
"def active_permitted_tasks\n ( self.restricted? ) ? self.tasks.active : Task.active\n end",
"def hsdq_authorized_tasks(*tasks)\n if tasks.any?\n @hsdq_authorized_tasks = [tasks].flatten\n else\n @hsdq_authorized_tasks ||= [hsdq_opts[:tasks]].flatten\n end\n end",
"def set_task\n @task = Task.includes(:project).find(params[:id])\n if @task.project.user != current_user\n render plain: '', status: :forbidden\n end\n end",
"def task_available\n return unless task\n\n validate_task_has_no_pending\n validate_task_has_no_approved\n end",
"def show\n authorize! :read, @task\n end",
"def set_task\n @task = Task.find(params[:id])\n if @task.list.user_id != @user.id\n redirect_to tasks_path\n end\n end",
"def can_authorize?(user, a)\n user != self and may_authorize and\n (abilities | ADMIN_TASKS).include?(a)\n end",
"def my_task_accepted_by_another_user_id # accepted_by_id, != nil\n @my_id = current_user.id\n @tasks = Task.where(user_id: @my_id, accepted_by_id: any?) # if !empty? doens't work != nil may\n end",
"def current_user_authorized?(options)\n\n c_user = current_user\n\n if !c_user\n flash[:info] = \"You must be a member\"\n redirect_to root_url\n return false\n end\n\n case options[:task]\n when :edit_profile, :delete_user\n\n return true if c_user.admin\n\n id = options[:user_id]\n if id.to_i != c_user.id\n flash[:info] = \"Not authorized\"\n else\n return true\n end\n when :admin_task\n if c_user.admin\n return true\n else\n flash[:info] = \"That action require admin privileges\"\n end\n when :member_task\n return true #checked current_user above\n end\n redirect_to root_url\n false\n end",
"def current_user_is_task_user_id\n # set status options, removing processing & completed, may add for stripe integration test\n @my_task_status_options = {available: \"Available\", unlist: \"Unlisted\"} # this transfers over to _form via edit call\n if current_user.id != @task.user_id\n redirect_to tasks_path\n end\n end",
"def verify_org_task_unique\n true\n end",
"def all_permitted_tasks\n ( self.restricted? ) ? self.tasks.scoped : Task.scoped\n end",
"def temp_work_complete?\n user.id == @task_work_offer.task.user.id\n end",
"def task_exists?( task )\n task_arns = ecs_client.list_tasks(cluster: name).task_arns\n task_arns.include?( task )\n end",
"def index\n\n if params[:user_id] && User.find(params[:user_id]) == current_user\n @tasks = @user.tasks\n elsif\n redirect_to missions_path\n flash[:notice] = \"Can't Do that\"\n else\n @tasks = Tasks.all\n end\n end",
"def is_permitted_for?( user )\n return true if user.privileged?\n\n # User is restricted. User can only see this object if it\n # has at least one task associated with it and at least one\n # of those associated tasks appears in the user's permitted\n # task list, so check the intersection of the two arrays.\n\n return ( self.tasks & user.tasks ).length > 0\n end",
"def set_task\n\t\t\t@task = Task.find(params[:id])\n\t\t\tnot_your_task if @task.user != current_user\n\t\tend",
"def authorized?(task_context)\n # If there is no rule, action is unauthorized\n return false if @allow_if.empty?\n\n # else, check all rules and return false if any of them did not return true\n # do not check all rules if unnecessary\n @allow_if.each do |rule|\n return false if rule.call(task_context) != true\n end\n\n true\n end",
"def index\n set_tasks\n if @role === 'admin'\n @tasks = Task.all\n end\n if @role === 'merchant'\n @tasks = Task.where(merchant: spree_current_user.merchant_id)\n end\n end",
"def validate_tasks\n validated = false\n if tasks_completed?\n validated = tasks_completed!\n end\n\n validated\n end",
"def claimed_chore?\n tasks.where(completion_status: \"pending\").count > 0\n end",
"def potential_task_assignees(task)\n if task.assigned_to.is_a?(Organization)\n task.assigned_to.users.active\n elsif task.parent&.assigned_to.is_a?(Organization)\n task.parent.assigned_to.users.active.reject { |check_user| check_user == task.assigned_to }\n else\n []\n end\n end",
"def my_accepted_task\n @my_id = current_user.id # redundant 3\n @tasks = Task.where(accepted_by_user_id: @my_id)\n # We may wish to only list task we are working on and with status processing, and nothing more\n #@tasks = Task.where(\"user_id != ? AND task_status = ? AND accepted_by_user_id = ?\", @my_id, \"available\", 0)\n @other_user_task_status_options = {finished: \"Finished\", processing: \"Processing\", error_in_tag: \"Errors in TAG\", Return_Tag: \"Please_Remove_Me\"}\n end",
"def task_for_project_leaders\n return @_action_name == \"index\" || @_action_name == \"edit\" || @_action_name == \"new\" || @_action_name == \"create\"\n end",
"def index\n authenticate_user!\n @tasks = current_user.tasks\n end",
"def check_use\r\n if !(params[:id]).nil?\r\n if !((Team.find_by_id(TodoList.find_by_id(params[:id]).team_id).users).include?(current_user))\r\n redirect_to frontend_root_path,\r\n notice: \"You cannot see Todo List\"\r\n end\r\n end\r\n end",
"def company_task_consistent\n return if self.project.nil?\n return if self.project.client.company.tasks.include?(self.task)\n errors.add(:task, \"must belong to the stated company\")\n end",
"def task_in_todo (nb)\n t = get_todo (nb)\n if t\n task_in t.chomp\n else\n puts \"No task specified\"\n end\n end",
"def set_task\n @task = current_user.tasks.find(params[:email])\n end",
"def all_tasks\n @task = Task.get_all_tasks_user_can_see(current_user)\n end",
"def show\n @task = Task.find(params[:id])\n restrict_access(\"tasks\") if @task.firm_id != @firm.id \n end",
"def index # all available task\n @task_check = Task.all\n # need to list only Tasks that is not owned by current_user\n if user_signed_in?\n @my_id = current_user.id\n # All Available task not current_user & checks for accepted_by_user_id == 0\n # query worked only after setting accepted_by_user_id to = 0 from nil\n # Set default field of accepted_by_user_id to 0 within task.rb via after_initialize\n # @tasks = Task.where(\"user_id != ? AND task_status = ? AND accepted_by_user_id = ?\", @my_id, \"Available\", 0)\n @tasks = Task.where(\"user_id != ? AND task_status = ? AND accepted_by_user_id = ?\", @my_id, \"Available\", 0)\n @tasks2 = @tasks\n else\n # All Available task including my tasks : user_signed_in?(false) => index display\n @tasks = Task.where(task_status: \"Available\")\n @tasks2 = @tasks\n end\n end",
"def list_tasks\n # ASK REPO for the tasks\n tasks = @task_repository.all\n # ASK VIEW to display them\n @tasks_view.display(tasks)\n end",
"def show\n @personal_task = PersonalTask.find(params[:id])\n if @personal_task.userid != session[:userid]\n flash[:error] = \"You don't have access to that task\"\n redirect_to personal_tasks_path\n end\n end",
"def tasks?\n tasks.summary.items?\n end",
"def index\n @tasks = (current_user.admin? ? Task.all : current_user.tasks)\n @error = nil\n if params[:name].present?\n resp = Task.where(\"name ilike '%#{params[:name]}%'\")\n if resp.present? \n if !current_user.admin?\n resp = resp.where(:user_id => current_user.id)\n end\n @tasks = resp \n end\n if resp.blank?\n @error = \"No Task Present with \\'#{params[:name]}\\' name\"\n end\n end \n end",
"def my_task\n @my_id = current_user.id # may be redundant4 but will head towards service objects\n @tasks = Task.where(user_id: @my_id)\n end",
"def index\n @user = current_user\n if @user.project_manager\n @tasks = Task.where(pm_id: @user.id)\n else\n @tasks = Task.where(collaborator_id: @user.id)\n end\n\n end",
"def action_allowed?\n return true if ['Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator'].include? current_role_name\n @teams = TeamsUser.where(user_id: current_user.try(:id))\n @teams.each do |team|\n return true if Team.where(id: team.team_id).first.parent_id == sample_submission_params[:id].to_i\n end\n false\n end",
"def show\n @accounts = Account.accessible_by(current_ability)\n @opportunities = Opportunity.accessible_by(current_ability)\n authorize! :show, @task\n end",
"def completed_by_user?(user)\n @tasks_completed = CompletedTask.all\n @tasks_completed.each do |completed|\n if (user.id == completed.user_id && self.id == completed.task_id)\n return true\n end\n end\n end",
"def owns?(task_list)\n task_list.owner == self\n end",
"def can_be_assigned?(_user)\n false # any user can complete operation\n end",
"def index\n\t if current_user.has_role? :admin\n\t\t @tasks = Task.all\n\t elsif current_user.has_role? :ing\n\t\t @user = User.find(current_user)\n\t\t @tasks = @user.tasks\n\t end\n end",
"def list_user_tasks\n\t\t@tasks = current_user.get_developer_tasks\n\tend",
"def update\n @task = Task.find(params[:id])\n if (@task.taskable_type == \"User\" && @task.taskable == @current_user) ||\n (@task.taskable_type == \"Event\" && @task.taskable == Event.find(params[:event_id]))\n @task.update(task_params)\n render json: @task\n else\n render json: { error: \"No such task for user\" }, status: :unauthorized\n end\n end",
"def authorize\n unless User.find_by(id: session[:user_id])\n redirect_to tasks_index_path, notice: \"Please log in\"\n end\n end",
"def successful_tasks\n @successful_tasks ||= @tasks_results.select(&:success?)\n end",
"def acceptable_by?(user)\n return false unless user.has_role?(:admin, user.unit)\n resource.pending?\n end",
"def actionable_tasks\n\t\tnext_tasks.select{ |t| !t.deferred? }\n\tend",
"def show\n unless current_user.present? && @task.category.user == current_user\n flash[:danger] = \"Unauthorized Access.\"\n redirect_to dashboard_path\n end\n end",
"def set_task\n @task = Task.where(authorization_id: Authorization.current_id).find(params[:id])\n end",
"def index\n @tasks =\n if @is_admin\n if id = params[:filter_by_user_id]\n Task.where(user_id: id)\n elsif state = params[:filter_by_state]\n Task.where(state: state)\n else\n Task.all\n end\n else\n Task.where(user_id: @person.id) + Task.where(state: 'open', user_id: nil)\n end\n end",
"def set_task\n @task = current_user.tasks.find(params[:id])\n end",
"def set_task\n @task = current_user.tasks.find(params[:id])\n end",
"def show\n @user = User.find(params[:id])\n\n @tasks = Task.where(assignee: current_user).page(params[:page])\n @q = @tasks.ransack(params[:q])\n @tasks = @q.result.page(params[:page])\n\n # @tasks_authored = Task.where(author: current_user).page(params[:page])\n # @q_authored = @tasks_authored.ransack(params[:q])\n # @tasks_authored = @q_authored.result.page(params[:page])\n end",
"def show\n @notes = @task.task_notes\n @tasks = @task.sub_tasks\n if current_user.allowed_to?(:manage_roles) and @task.user\n session[:employee_id] = @task.user.id\n User.current = @task.user\n end\n end",
"def tasks_by_section_for_my_tasks(project,\n only_uncompleted: true,\n extra_fields: [])\n raw_tasks = projects.tasks_from_project(project,\n only_uncompleted: only_uncompleted,\n extra_fields: extra_fields + ['assignee_section.name'])\n active_tasks = projects.active_tasks(raw_tasks)\n by_my_tasks_section(active_tasks, project.gid)\n end",
"def run_set(set)\n set_tasks = @tasks[set]\n\n return true if set_tasks.empty?\n\n @playbook.in_context(set) do\n Log.info(\"About to run task set %s with %d task(s)\" % [set, set_tasks.size])\n\n # would typically use map here but you cant break out of a map and keep the thus far built up array\n # so it's either this or a inject loop\n passed = set_tasks.take_while do |task|\n @playbook.in_context(\"%s.%s\" % [set, task[:type]]) { run_task(task, set, set == \"tasks\") }\n end\n\n set_success = passed.size == set_tasks.size\n\n Log.info(\"Done running task set %s with %d task(s): success: %s\" % [set, set_tasks.size, set_success])\n\n set_success\n end\n end",
"def show\n @tasks = Task.from_user(@current_user).by_status(:confirmed).ordered\n @new_tasks = Task.from_user(@current_user).by_status(:pending).ordered\n @completed_tasks = Task.from_user(@current_user).by_status(:complete).ordered\n end",
"def own_tasks\n uri = self.uri\n query = Ruta::Sparql.select.where(\n [:task, RDF.type, Ruta::Class.task],\n [:task, Ruta::Property.has_creator, uri]\n )\n tasks = []\n query.each_solution { |sol| tasks.push(sol.task.as(Task)) }\n tasks\n end",
"def tasks\n Task.undone_for_user(goddamn_tfpid)\n end",
"def show\n @task = current_user.tasks.find params[:id] \n\n end",
"def index\n @tasks = Task.not_related.root.where(assigned_to: @user).or(Task.root.where(for_individual: @user) )\n end",
"def test_authorize\n object_person = people(:valid_person) # person_id 1\n subject_person_1aa = people(:person1) # person_id 1aa\n subject_person_2aa = people(:person3) # person_id 2aa\n \n assert Rule.authorize?(subject_person_1aa, object_person.id, \"view\", \"email\")\n assert !Rule.authorize?(subject_person_2aa, object_person.id, \"view\",\"email\")\n\n end",
"def auth_required\n unless Facts.config.user\n Facts.ui.puts \"Authorization required for this task, use `facts config`\"\n exit(0)\n end\n end",
"def check_authorization\n @can_edit = can_blank_timetable?('edit')\n @can_show = can_blank_timetable?('show')\n end",
"def update\n @task = Task.find(params[:task_id])\n @subtask = Subtask.find(params[:id])\n if (@task.taskable_type == \"User\" && @task.taskable == @current_user) ||\n (@task.taskable_type == \"Event\" && @task.taskable == Event.find(params[:event_id])) &&\n (@subtask.task == @task)\n @subtask.update(subtask_params)\n render json: @subtask\n else\n render json: { error: \"No such task for user\" }, status: :unauthorized\n end\n end",
"def approved?\n self.status == Task::Status::FINISHED\n end",
"def action_allowed?\n if %w[edit update list_submissions].include? params[:action]\n current_user_has_admin_privileges? || current_user_teaching_staff_of_assignment?(params[:id])\n else\n current_user_has_ta_privileges?\n end\n end",
"def reviewer_tasks\n tasks.find(:all, :conditions => { :context => 'reviewers', :show_for_context_object_tasks => true })\n end",
"def task(task_name, session, lock_mode, admin_auth=false, &block)\n begin\n # lock\n if lock_mode == :wt\n @lock.write_lock\n else\n @lock.read_lock\n end\n\n begin\n rc = authenticate(session, admin_auth, &block)\n log_msg = rc\n rescue => e\n rc = [false, e.message]\n log_msg = [false, e]\n end\n\n ensure\n # unlock\n if lock_mode == :wt\n @lock.write_unlock\n else\n @lock.read_unlock\n end\n end\n\n log_result(task_name, get_user_from_session(session), log_msg)\n return rc\n end",
"def set_task\n @user = User.find(params[:user_id])\n @task = @user.tasks.find(params[:id])\n\n end",
"def check_owner\n if current_user != Checklist.find(params[:format]).user\n flash[:notice] = \"Trying to be cheeky are we? You cannot modify a task that's not yours!\"\n redirect_to '/'\n end\n end",
"def in_progress? current_user_id\n todo_completes.active.map(&:submitter_id).include?(current_user_id) ? true : false\n end",
"def can_organize?\n can = false\n group_by = session[:group_by]\n if group_by.to_i > 2 and @tasks\n gb = group_by.to_i\n affected_projects = @tasks.flatten.collect(&:project).uniq\n can = case gb\n when 3 then current_user.can_all?(affected_projects, 'reassign')\n when 4 then current_user.can_all?(affected_projects, 'reassign')\n when 5 then current_user.can_all?(affected_projects, 'reassign')\n when 6 then current_user.can_all?(affected_projects, 'prioritize')\n when 7 then current_user.can_all?(affected_projects, 'close')\n when 8 then current_user.can_all?(affected_projects, 'prioritize')\n when 9 then current_user.can_all?(affected_projects, 'prioritize')\n when 10 then current_user.can_all?(affected_projects, 'reassign')\n end\n elsif Property.find_by_group_by(current_user.company, group_by)\n can = true\n end \n\n return can\n end",
"def set_task\n @task = current_user.tasks.find(params[:id])\n end",
"def set_task\n @task = current_user.tasks.find(params[:id])\n end",
"def set_task\n @task = current_user.tasks.find(params[:id])\n end",
"def set_task\n @task = current_user.tasks.find(params[:id])\n end",
"def set_task\n @task = current_user.tasks.find(params[:id])\n end",
"def index\n authorize Task\n # TODO: should be showing students prompts through assessments...\n # TODO: change route, go through assessments?\n # enrollment = Enrollment.where(student_id: current_user.id)[0]\n # if enrollment then section = enrollment.section_id\n # assessments = Assessment.where(section_id: section)\n # end\n\n @tasks = policy_scope Task.all\n @tasks_grid = initialize_grid @tasks\n end",
"def invoked_tasks\n @invoked_tasks\n end",
"def check\n @trainer = Trainer.find(params[:id])\n temp = session[@trainer.id.to_s + \"_trainer\"]\n temp[:user_ans] = params[:user_ans].to_f.round(1)\n @generated_task = temp\n end",
"def index\n\n @tasks = Card.where(authorization_id: Authorization.current_id).find(params[:card_id]).tasks\n end",
"def index\n @tasks = @current_user.tasks\n end",
"def check(id_string)\n set_done(id_string, true)\n #checking all other tasks with same name/description as the newly checked task which id is id_string\n id = id_string.to_i\n @tasks.each { |project_name, project_tasks|\n project_tasks.each { |task|\n if task.id == id\n @tasks.each do |project_name, project_tasks|\n project_tasks.each do |t|\n if t.description == task.description\n set_done(t.id.to_s, true)\n end\n end\n end\n end\n }\n }\n end",
"def ignore_task?(task)\n return true if metadata[\"run_#{task}\"] == false\n\n !clade? && @@INCLADE_TASKS.include?(task) && metadata[\"run_#{task}\"] != true\n end",
"def run_successfully?(tasks)\n [*tasks].all? do |task|\n Rake::Task.task_defined?(task) && Rake::Task[task].invoke\n end\nend",
"def has_task?(task)\n self.project_tasks.each do |project_task|\n return true if project_task.task == task\n end\n false\n end",
"def task_present?(task_name)\n tasks.key? prepare_key(task_name)\n end"
] |
[
"0.73010886",
"0.69179",
"0.6898325",
"0.67475116",
"0.66654694",
"0.6574193",
"0.6573384",
"0.6528925",
"0.6467978",
"0.6461469",
"0.64126956",
"0.636431",
"0.6359416",
"0.6341048",
"0.6274866",
"0.6228298",
"0.62179524",
"0.616861",
"0.61562407",
"0.61488205",
"0.6135555",
"0.61302614",
"0.6003204",
"0.6000575",
"0.5999614",
"0.5991732",
"0.5991396",
"0.59754205",
"0.59744805",
"0.59639925",
"0.5961776",
"0.5959012",
"0.59411836",
"0.5938502",
"0.59378135",
"0.59350014",
"0.593342",
"0.58797735",
"0.5859851",
"0.58556455",
"0.5810746",
"0.5775982",
"0.57722974",
"0.5741931",
"0.5721352",
"0.5720046",
"0.56862277",
"0.56836146",
"0.5682943",
"0.5679019",
"0.56764895",
"0.5631521",
"0.5630709",
"0.5630505",
"0.5621089",
"0.56083286",
"0.56078845",
"0.56035537",
"0.5597811",
"0.55895334",
"0.5582412",
"0.5559437",
"0.5558408",
"0.5558408",
"0.5551232",
"0.55381095",
"0.5534611",
"0.5530645",
"0.55207723",
"0.55199647",
"0.55156994",
"0.551233",
"0.5479442",
"0.54794055",
"0.54779816",
"0.54775655",
"0.54756904",
"0.547309",
"0.5470761",
"0.5469162",
"0.5455119",
"0.54531455",
"0.54514056",
"0.5447841",
"0.5446671",
"0.5442573",
"0.5442573",
"0.5442573",
"0.5442573",
"0.5442573",
"0.5436435",
"0.54358166",
"0.5433419",
"0.5429422",
"0.54272515",
"0.5426262",
"0.54253757",
"0.5424905",
"0.541656",
"0.5413662"
] |
0.5986161
|
27
|
updating the locationerror and itemerror after deleting records from the upload screen
|
def update_errormaintenance
case self.upload_filename
when 'Location.csv'
location_error = Locationerror.destroy_all(uploadfile_id: self.id)
when 'Item.csv'
item_error = Itemerror.destroy_all(uploadfile_id: self.id)
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def reprocess\n ids = params[:id]\n errorExists = false\n ids.each do |id|\n itemerror = Itemerror.find(id.to_i)\n error = is_row_valid itemerror \n if error.blank?\n \n itemHash = {:client_id => itemerror.attribute1, \n :item_number => itemerror.attribute2, \n :velocity => itemerror.attribute3,\n :daily_avg_sales =>itemerror.attribute4, \n :weekly_avg_sales => itemerror.attribute5,\n :monthly_avg_sales => itemerror.attribute6,\n :daily_forecast => itemerror.attribute7,\n :case_quantity => itemerror.attribute8,\n :case_split_allowed => itemerror.attribute9,\n :attribute1 => itemerror.attribute10,\n :short_description => itemerror.attribute11,\n :long_description => itemerror.attribute12, \n :item_category1 => itemerror.attribute13,\n :item_category2 => itemerror.attribute14,\n :item_category3 => itemerror.attribute15,\n :unit_length => itemerror.attribute16,\n :unit_breadth => itemerror.attribute17,\n :unit_height => itemerror.attribute18,\n :unit_volume => itemerror.attribute19,\n :unit_weight => itemerror.attribute20,\n :case_length => itemerror.attribute21,\n :case_breadth => itemerror.attribute22,\n :case_height => itemerror.attribute23,\n :case_volume => itemerror.attribute24,\n :case_weight => itemerror.attribute25,\n :stocking_UOM => itemerror.attribute26\n }\n \n \n existitem = Itemmaster.where(\"client_id = ? and item_number = ? \" , itemerror.attribute1 , itemerror.attribute2).first\n \n if existitem.nil?\n items= Itemmaster.new(itemHash) \n items.save \n \n else\n existitem.update_attributes(itemHash) \n end\n \n Itemerror.destroy(id.to_i)\n upload_file = Uploadfile.find(itemerror.uploadfile_id)\n upload_file.no_of_error_records -= 1\n upload_file.no_of_processed_records += 1\n upload_file.save \n \n else\n\n itemerror.update_attributes({\n \n :error_description => error\n \n })\n \n errorExists = true \n end\n \n return (errorExists ? \"Error Exists in processing\" : \"Processed Successfully\") \n end \n \n end",
"def update_location_error(params)\n location_error(:edit_location, params)\n end",
"def delete\n ret_val = error_if_exists('delete')\n super if ret_val\n return ret_val\n end",
"def cleanup_failed(msg)\n\t\tself.order_status_code_id = 3\n self.new_notes=\"Order failed!<br/>#{msg}\"\n self.save\n\tend",
"def cleanup_successful\n\t\tself.order_status_code_id = 5\n self.new_notes=\"Order completed.\"\n self.product_cost = self.line_items_total\n self.account.clear_personal_information\n self.save\n\tend",
"def last_record object, count\n if count < 2\n return [:error, \"Failed to delete #{Store.class_name(object).downcase} - you must have at least one.\"]\n else\n object.destroy\n return [:success, \"#{Store.class_name(object).capitalize} was successfully deleted.\"]\n end\n end",
"def delete_fs_item\n d \"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\"\n d \"Delete a file or folder\"\n d \"vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv\"\n \n err_str = ''\n begin # a one time loop to allow break\n \n generic_ty = Integer(params[:sel_kind]) rescue generic_ty = FSTYPE_INVALID\n elem_id = Integer(params[:sel_id]) rescue elem_id = -1\n if ( elem_id <= 0 )\n err_str = 'Invalid index'\n break\n end\n \n if ( generic_ty == FSTYPE_FILE )\n to_upd = Dfile.find_by_id( elem_id )\n if ( to_upd )\n kindname = to_upd.fileType()\n parent_id = to_upd.directory_id\n our_name = to_upd.name\n if to_upd.destroy\n reponse = { action_id: params[:action_id],\n new_id: elem_id,\n new_name: our_name,\n parent_id: parent_id,\n kind_name: kindname\n }\n render :json => reponse, :layout => false, :status => 200 and return\n else\n err_str = 'Failed to delete file'\n break\n end\n else\n err_str = 'File does not exist'\n break\n end\n elsif ( generic_ty == FSTYPE_DIR )\n to_upd = Directory.find_by_id( elem_id )\n if ( to_upd )\n parent_id = to_upd.parent_id\n our_name = to_upd.name\n if to_upd.destroy\n reponse = { action_id: params[:action_id],\n new_id: elem_id,\n new_name: our_name,\n parent_id: parent_id,\n kind_name: 'directory'\n }\n render :json => reponse, :layout => false, :status => 200 and return\n else\n err_str = 'Failed to delete directory'\n break\n end\n else\n err_str = 'Directory does not exist'\n break\n end\n else\n err_str = 'Invalid entry type'\n break\n end\n \n end until true # a one time loop to allow break\n render json: err_str, status: :unprocessable_entity and return\n end",
"def upload_failed\n update_attributes(:status => STATUS[:failed])\n end",
"def destroy\n tmp_element_error = @@model.new\n tmp = @@model.find(params[:id])\n if tmp\n unless tmp.destroy\n tmp.errors.full_messages.each do |tmp_error| \n tmp_element_error.errors.add(:base, tmp_error)\n end\n end\n end\n if tmp_element_error.errors.empty? \n flash[:notice] = @@msg_delete.trn\n else\n flash[:errors_destroy] = tmp_element_error\n end\n redirect_to :action => \"list\"\n end",
"def update_items\n @goods_receive_note = GoodsReceiveNote.find(params[:id])\n params[:item] ||= []\n if params[:commit] == \"Update Items\"\n errors = @goods_receive_note.update_items(params[:item])\n if errors.empty?\n flash[:notice] = \"Goods Receive Note Item was successfully update\"\n else\n flash[:error] = errors\n end\n elsif params[:commit] == \"Remove Items\"\n @goods_receive_note.remove_item(params[:item])\n flash[:notice] = \"Goods Receive Note Item was successfully removed\"\n end\n redirect_to @goods_receive_note\n end",
"def handle_error(line_item)\n order.errors[:base] << line_item.errors.full_messages\n end",
"def destroy\n #@items_location = ItemsLocation.find(params[:id])\n #@items_location.destroy\n\n respond_to do |format|\n format.html { redirect_to items_locations_url }\n format.json { head :no_content }\n end\n end",
"def edit\n if params[:submit_failed]\n add_image_upload_errors\n end\n end",
"def uploading_error\n errors[:base] << I18n.t('simple_attachments.uploading_error')\n end",
"def error_status\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end",
"def notify_error\n self.errors_count ||= 0\n self.errors_count += 1\n if self.errors_count > ERRORS_MAX\n destroy\n else\n save\n end\n end",
"def deleted(item)\n end",
"def destroy\n\n tmp_element_error = EsSetup.new\n for id in params[:cid]\n tmp = EsSetup.find(id)\n unless tmp.destroy\n tmp.errors.full_messages.each do |tmp_error| \n tmp_element_error.errors.add(:base, \"Paramétrage\".trn + \" #{tmp.path} #{tmp.name} : #{tmp_error}.\")\n end\n end\n end\n \n if tmp_element_error.errors.empty? \n flash[:notice] = 'Paramétrage(s) correctement supprimée(s).'.trn\n else\n flash[:errors_destroy] = tmp_element_error\n end\n redirect_to :action => \"list\"\n end",
"def correctly_update_status\n\t\terrors.add(:base, 'La transaccion no fue exitosa') if self.invalid_status\n\tend",
"def handle_delete\n params.record.destroy do |result|\n alert 'unable to delete record' unless result\n end\n end",
"def manage_item_photos(item)\n original_count = item.item_photos.to_a.size\n # Delete photos\n deleted_item_photos = params[:deleted_item_photos].to_a\n deleted_item_photos.each{|p| logger.info \" - item_photo: #{p}\" }\n item.item_photos.to_a.delete_if{|item_photo| deleted_item_photos.include?(item_photo.image_url) }\n item.save if deleted_item_photos.present?\n end",
"def clear_errors!\n update_attributes last_error: nil\n end",
"def render_update_error\n render_error @resource\n end",
"def delete_invalid_eobs(check, client_id, facility_id)\r\n insurance_eobs_count = InsurancePaymentEob.count(:conditions => [ \"check_information_id = ?\", check.id ] )\r\n if insurance_eobs_count != 0\r\n deleted_eobs = InsurancePaymentEob.destroy_all(:check_information_id => check.id, :patient_account_number => nil)\r\n entity = 'insurance_payment_eobs'\r\n else\r\n deleted_eobs = PatientPayEob.destroy_all(:check_information_id => check.id, :account_number => nil)\r\n entity = 'patient_pay_eobs'\r\n end\r\n if deleted_eobs.length > 0\r\n deleted_entity_records = []\r\n deleted_eobs.each do |deleted_eob|\r\n parameters = { :entity => entity, :entity_id => deleted_eob.id,\r\n :client_id => client_id, :facility_id => facility_id }\r\n deleted_entity_records << DeletedEntity.create_records(parameters)\r\n end\r\n if deleted_entity_records.present?\r\n DeletedEntity.import(deleted_entity_records)\r\n end\r\n end\r\n end",
"def clean_up_paperclip_errors\n errors.delete(:file) if errors[:file] == errors[:file_file_size]\n end",
"def published_error(previous_entry)\n previous_entry.error = true\n previous_entry.complete = false\n previous_entry.current_status = 'Update Rejected'\n previous_entry.error_message = 'Cannot update this item, it has already been published.'\n previous_entry.save\n end",
"def update\n @item = @collection.items.get(params[:id])\n @collection.schema.each do |field|\n if params[:item][field.to_s].blank? && !field.is_file\n @item[field.name]=nil\n elsif field.is_file\n #do nothing\n unless params[:item][field.to_s].nil?\n new_file = @file_collection.items.new()\n new_file.file =params[:item][field.to_s]\n new_file.save\n @item[field.name]='{\"project\":{\"id\": \"'+@project.id+'\"}, \"collection\":{\"id\": \"'+@file_collection.id+'\"},\"item\":{\"id\": \"'+new_file.id.to_s+'\", \"display\": \"'+new_file.original_filename+'\"}}'\n end\n else\n @item[field.name] = params[:item][field.to_s]\n end\n end\n if @item.save\n update_associated_fields(@item, @collection, @project)\n respond_to do |format|\n format.html do\n flash[:notice] = \"Item Updated Successfully!\"\n end\n #format.json { render json: @item.to_json, status: :updated}\n format.js { render :js => '$(\"#message\").html(\"<h2>Item updated. Close window and refresh your page.</h2>\").attr(\"class\",\"message notice\"); $(\"html, body\").animate({scrollTop: \"0px\"})' }\n end\n else\n respond_to do |format|\n format.html do\n flash[:error] = [\"Item failed to save! Errors:\", @item.errors.full_messages].flatten.join(' ')\n end\n format.json { render json: @item.to_json, status: :error}\n format.js { render :js => '$(\"#message\").html(\"<h2>Item failed update.</h2>\").attr(\"class\",\"message error\").scrollTop(0); $(\"html, body\").animate({scrollTop: \"0px\"})' }\n end\n end\n redirect_to :back\n end",
"def errors; end",
"def errors; end",
"def errors; end",
"def errors; end",
"def errors; end",
"def errors; end",
"def errors; end",
"def errors; end",
"def errors; end",
"def destroy\n @field = Field.find(params[:id])\n begin\n @field.destroy \n rescue ActiveRecord::DeleteRestrictionError => e\n @field.errors.add(:base, e)\n end \n respond_to do |format|\n\n if e.nil?\n \n format.html { redirect_to(\"/fieldview\", :notice => 'field was successfully deleted.') }\n format.xml { head :ok }\n else \n format.html { render :action => \"edit\" }\n end\n \n \n end\n end",
"def destroy\n begin\n @place.destroy\n respond_to do |format|\n format.html { redirect_to admin_places_url, notice: t('messages.deleted', model:Place.model_name.human) }\n format.json { head :no_content }\n end\n rescue ActiveRecord::InvalidForeignKey => e\n flash[:error] = t 'errors.messages.delete_fail.being_used', model:@place.name\n flash[:error_details] = e\n redirect_to [:admin, @place]\n rescue ActiveRecord::StatementInvalid => e\n flash[:error] = t 'errors.messages.ops'\n flash[:error_details] = e\n redirect_to [:admin, @place]\n end\n end",
"def deleteMetadata\n begin\n # Gets parameters\n typename = params[:metadata_type].to_s.strip.downcase\n puts \"t: \" + typename\n \n if typename == \"\"\n render :text => \"Type of metadata not given\", :status => 404\n return\n end\n\n \n # Metadatatypes that can't be deleted\n #if typename == \"name\" or typename == \"path\" or typename == \"description\" or typename == \"filetype\" or\n # typename == \"created_at\" or typename == \"updated_at\" or typename == \"privatefile\" or\n # typename == \"size\" or typename == \"filedate\" or typename == \"uploaded\" or typename == \"upload_requested\" or\n # typename == \"thumbnail_name\" or typename == \"version\" or typename == \"blob_hash\"\n # render :text => \"Can't delete this metadata\", :status => 404\n # return\n #end\n \n # Search for the user\n @user = User.find_by_username(params[:username].to_s.strip)\n if not @user\n # If the user was not found\n render :text => \"User not found\", :status => 404\n return\n end\n \n # Search for the device\n findDeviceOfURI\n if @device != nil\n getPathAndFilename\n @devfile = @device.devfiles.find(:first, :conditions => ['name = ? and path = ?', @filename, @path])\n if @devfile == nil\n render :text => \"File was not found.\", :status => 404\n return\n end\n else\n # If the device was not found\n render :text => \"Device was not found.\", :status => 404\n return\n end \n\n # Search for the metadatatype\n type = MetadataType.find_by_name(typename) \n if type == nil\n render :text => \"Metadatatype not found\", :status => 404\n return \n end\n \n # If trying to delete metadata of multi metadatatype\n if @@multi_metadata_types_for_context.include?(typename)\n if not params[:metadata_value]\n render :text => \"Value of multi metadata not given\", :status => 409\n return\n end\n\n md_value = params[:metadata_value].to_s.strip.downcase\n \n # Try to find certain metadata of multi values type\n metadata = Metadata.find_by_metadata_type_id_and_devfile_id_and_value(type.id, @devfile.id, md_value)\n else\n # Search for the \"normal\" metadata \n metadata = Metadata.find(:first, :conditions => ['metadata_type_id = ? and devfile_id = ?', type.id, @devfile.id])\n end\n \n if metadata \n metadata.destroy\n render :text => \"Metadata deleted\", :status => 200\n return\n else\n render :text => \"Can't find metadata\", :status => 404\n return\n end \n \n rescue => e\n puts \"Error in deleting metadata\".background(:red)\n puts e\n end\n end",
"def create\n# @deal_location = DealLocation.new(params[:deal_location])\n#\n# respond_to do |format|\n# if @deal_location.save\n# format.html { redirect_to @deal_location, notice: 'Deal location was successfully created.' }\n# format.json { render json: @deal_location, status: :created, location: @deal_location }\n# else\n# format.html { render action: \"new\" }\n# format.json { render json: @deal_location.errors, status: :unprocessable_entity }\n# end\n# end\n# \n DealLocation.transaction do\n begin \n @prev_location = DealLocation.where( :deal_id => params[:deal_location][:deal_id] )\n @prev_location.delete_all( :deal_id => params[:deal_location][:deal_id] )\n rescue ActiveRecord::Rollback\n logger.info \"[DEAL_LOCATIONS CREATE]An error has occured.\"\n redirect_to :deal_locations\n end\n end\n \n # make sure if there is anything to insert\n if params[:deal_location][:empty] != 'empty'\n # insert gracefully\n DealLocation.transaction do\n # delete previous records\n begin\n # todo: rollback on error\n params[:deal_location][:name].each do |t|\n\n new_location = ActiveSupport::JSON.decode(t)\n deal = DealLocation.new\n\n logger.info new_location\n deal.location_name = new_location[\"location_name\"] || nil\n deal.longitude = new_location[\"longitude\"] || nil\n deal.latitude = new_location[\"latitude\"] || nil\n deal.deal_id = new_location[\"deal_id\"] || nil\n if deal.save\n logger.info \"Successfully inserted\"\n else\n raise ActiveRecord::Rollback\n end\n\n end\n\n\n rescue ActiveRecord::Rollback\n logger.info \"An error has occured.\"\n redirect_to :deal_locations\n end\n end\n end\n \n redirect_to :deals\n \n end",
"def destroy\n if(current_user!=nil && current_user.rol==\"admin\"||(current_user.rol==\"regular\" && current_user.id==@location.user_id))\n @user=@location.user\n if(@location.delivers.size>0)\n \n flash[:alert]=\"No se puede eliminar hay pedidos a esta direccion!\"\n else\n@location.destroy\nflash[:alert]=\"Eliminado correctamente\"\n end\n if(current_user.rol==\"admin\")\n redirect_to '/locations/index/'+@user.id.to_s\n else\n redirect_to locations_url\n end\n else\n redirect_to root_path\n end\n end",
"def check_before_destroy\n unless is_comment? || sir_item.sir_entries.last.id == id\n errors.add( :base, I18n.t( 'sir_items.msg.bad_del_req' ))\n# raise ActiveRecord::Rollback\n throw( :abort )\n end\n end",
"def destroy\n @item_location.destroy\n respond_to do |format|\n format.html { redirect_to item_locations_url, notice: 'Item location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @import_error.destroy\n respond_to do |format|\n format.html { redirect_to import_errors_url, notice: \"Import error was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @common_error.destroy\n respond_to do |format|\n format.html { redirect_to common_errors_url, notice: 'Entrada catalogo borrada.' }\n format.json { head :no_content }\n end\n end",
"def update\n if @item.update(item_params)\n render status: 201, :json => @item, :include =>[{:location =>{:except=>[:id, :created_at, :updated_at]}}, {:food =>{:except =>[:id, :created_at, :updated_at]}}], :except => [:created_at, :updated_at, :food_id, :location_id]\n else\n render status: 404, json: { message: @item.errors}.to_json\n end\n\n \n end",
"def restore\n @item = @collection.items.get(params[:item_id])\n old_item = @item.versions.first(:deleted_at => params[:deleted_at])\n att = old_item.attributes\n att.delete(:deleted_at)\n att.delete(:original_uid)\n att.delete(:id)\n if @item.update(att)\n flash[:notice] = \"Item Restored Successfully!\"\n redirect_to project_collection_item_path(@project, @collection, @item)\n else\n flash[:error] = \"Item failed to restore!\"\n render :show\n end\n end",
"def clear_errors!\n @errors = []\n end",
"def destroy\n @item_location.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_item_locations_url, notice: 'Item location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n if @observation_field.observation_field_values.count > 0\n msg = t(:you_cant_delete_observation_fields_that_people_are_using)\n respond_to do |format|\n format.html do\n flash[:error] = msg\n redirect_to(observation_fields_url)\n end\n format.json { render :json => {:error => msg}, :status => :unprocessable_entity }\n end\n else\n @observation_field.destroy\n respond_to do |format|\n format.html { redirect_to(observation_fields_url) }\n format.json { head :ok }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n @item.document1.destroy if params[:remove_document1] == \"1\"\n @item.document2.destroy if params[:remove_document2] == \"1\"\n @item.document3.destroy if params[:remove_document3] == \"1\"\n @item.document4.destroy if params[:remove_document4] == \"1\"\n @item.document5.destroy if params[:remove_document5] == \"1\"\n format.html {redirect_to item_path, notice: 'Item was successfully updated.'}\n format.json {render :show, status: :ok, location: @item}\n else\n format.html {render :edit}\n format.json {render json: @item.errors, status: :unprocessable_entity}\n end\n end\n end",
"def check_detalles\n detalles.reload if errors.size > 0\n end",
"def update_errors\n @errors = []\n @errors << 'One of the cards needs attention' unless cards.all?(&:valid?)\n if email\n @errors << 'Email is not in correct format' unless email_well_formed?\n else\n @errors << 'Email is a required field'\n end\n @errors << 'Wallet token is a required field' unless wallet_token\n @errors\n end",
"def delete\n msg = FileOperations.id_exist?(self) ? FileOperations.delete(self) : 'Product\n Not Found'\n puts msg\n end",
"def confirm_delete\n @quality_rating_field = QualityRatingField.find(params[:id])\n\t @extraction_form = ExtractionForm.find(params[:extraction_form_id])\n\t @project = Project.find(@extraction_form.project_id)\n\t @has_study_data = QualityRatingField.has_study_data(@extraction_form.id)\t\t\n end",
"def clear\n @errors = {}\n end",
"def errors=(_); end",
"def destroy\n\tif params[:quotation_header_id].present?\n\t\n @quotation_header_id = params[:quotation_header_id]\n if params[:quotation_detail_large_classification_id].present?\n @quotation_detail_large_classification_id = params[:quotation_detail_large_classification_id]\n \n #add180803\n #確定済みのものは、変更できないようにする\n quotation_header = QuotationHeader.find(params[:quotation_header_id])\n if quotation_header.present?\n if quotation_header.fixed_flag == 1\n @status = \"fixed\"\n else\n @status = \"not_fixed\"\n end\n end\n #\n end\n\tend\n \n \n if @status != \"fixed\"\n @quotation_detail_middle_classification.destroy\n \n #respond_to do |format|\n #del180803\n #確定済みデータに警告を出すため、ここでリダイレクトさせない→させる\n\t # format.html {redirect_to quotation_detail_middle_classifications_path( :quotation_header_id => params[:quotation_header_id],\n # :quotation_detail_large_classification_id => params[:quotation_detail_large_classification_id], \n\t # :quotation_header_name => params[:quotation_header_name],\n # :working_large_item_name => params[:working_large_item_name], :working_large_specification => params[:working_large_specification]\n # )}\n\t \n\t #品目データの金額を更新\n save_price_to_large_classifications\n\t \n #end\n end\n end",
"def clear\n @errors = {}\n end",
"def destroy\n begin\n @sicoss_location.destroy\n flash[:success] = \"successfully destroyed.\"\n rescue ActiveRecord::DeleteRestrictionError => e\n @sicoss_location.errors.add(:base, e)\n flash[:error] = \"#{e}\"\n redirect_to sicoss_location_url\n else\n redirect_to sicoss_locations_url\n end\n end",
"def before_confirm\n if !@order.all_photos_valid?\n if @order.line_items.count > 0\n flash.now[:error]=\"Please Review Your Order\"\n flash.now[:payment]='A photo in your order was deleted while you were checking out. )'+\\\n ' The item has been removed and your order re-calculated.)'+\\\n ' You can now place your order. '\n respond_with(@order) { |format| format.html { render :edit } } and return\n else\n flash[:error]=\"Please Select More Photos\"\n flash[:payment]='The photo in your order was deleted while you were checking out. )'+\\\n ' The line item has been removed and your cart is now empty'\n redirect_to cart_url\n end\n end\n end",
"def flash_csv_upload_file_validation_errors(errors)\n unless errors[:bad_cell].empty?\n flash_message :error, I18n.t('csv.bad_cell', bad_cells: errors[:bad_cell].map { |c| \"'#{c}'\" }.join(', '))\n end\n unless errors[:dup_groups].empty?\n flash_message :error, I18n.t('csv.duplicate_group_name', group_names: errors[:dup_groups].join(', '))\n end\n unless errors[:dup_members].empty?\n flash_message :error, I18n.t('csv.duplicate_membership_name', member_names: errors[:dup_members].join(', '))\n end\n unless errors[:inconsistent_group_memberships].empty?\n flash_message :error, I18n.t('csv.bad_membership_warning',\n group_names: errors[:inconsistent_group_memberships].join(', '))\n end\n unless errors[:bad_students].empty?\n flash_message :error, I18n.t('csv.bad_students', student_names: errors[:bad_students].join(', '))\n end\n unless errors[:membership_exists].empty?\n flash_message :error, I18n.t('csv.memberships_exist', student_names: errors[:membership_exists].join(', '))\n end\n end",
"def remove_have\n if params[:id].present? and params[:remove_have].present?\n if params[:from_haves_tab] == 'true'\n @user = current_user\n # @have_items = @user.items\n item = Item.find_by_id_and_user_id(params[:id],current_user.id)\n if item.present?\n # item.destroy\n item.update_attribute(\"status\",\"DELETED\")\n end\n flash[:info] = \"Item has been removed from your Haves Board .\"\n redirect_to haves_user_path(@user, :delete => item.id)\n # elsif params[:from_my_offers_tab] == 'true'\n # @user = current_user\n # @have_items = @user.have_items\n # item = Item.find_by_id_and_user_id(params[:id],current_user.id)\n # item.destroy\n # params[:id] = params[:original_id]\n # @item = Item.find_by_id(params[:id])\n # @offer_ids = @item.current_offers.pluck(:offer_id)\n # @useritems = @user.items\n # @useritem_ids = @useritems.pluck(:id)\n # elsif params[:from_items_index] == 'true'\n # # item = Item.find_by_id(params[:id])\n # # item.destroy\n # respond_to do |format|\n # format.js\n # format.html { redirect_to items_path}\n # end\n end\n end\n end",
"def update\n @locations = []\n @errors = []\n @hide_map = true\n if params.has_key? :id\n location = Location.find(params[:id])\n @locations = [ location ]\n location_params = params.clone\n [:created_at, :id, :updated_at, :category, :subcategories, :markerVisible, :action, :controller, :location].each do |param|\n location_params.delete param\n end\n location.update_attributes location_params\n @errors = location.errors\n elsif params.has_key? :locations\n params[:locations][:location].each do |data|\n l = Location.find data[0]\n if not l.update_attributes data[1]\n pp l.errors\n @errors.push l.errors\n end\n @locations.push l\n end\n end\n\n respond_to do |format|\n if @errors.empty?\n format.html { redirect_to :locations, :notice => 'Locations successfully updated.'}\n format.json { head :no_content }\n else\n format.html { render :action =>\"edit\" }\n format.json { render :json => @errors, :status => :unprocessable_entity }\n end\n end\n end",
"def destroy_right\n\n tmp_element_error = DirAccess.new\n tmp = DirAccess.find_by_id(params[:id])\n @dir = tmp.dir_manager\n if tmp\n unless tmp.destroy\n tmp.errors.full_messages.each do |tmp_error| \n tmp_element_error.errors.add(:base, tmp_error)\n end\n end\n end\n if tmp_element_error.errors.empty? \n flash[:notice] = \"Ce droit répertoire a correctement été supprimé.\".trn\n else\n flash[:errors_destroy] = tmp_element_error\n end\n redirect_to :action => \"right_dir\", :id => @dir.id\n end",
"def destroy\n @locations = Location.paginate(:page => params[:page], :per_page => 30).order('updated_at DESC')\n @location = Location.find(params[:id])\n begin\n @location.destroy\n rescue ActiveRecord::DeleteRestrictionError => e\n @error = e.message\n end\n end",
"def undelete\n ActiveRecord::Base.transaction do\n @unit.exhume!\n end\n rescue => e\n flash['error'] = \"#{e}\"\n else\n RefreshOpensearchJob.perform_later\n toast!(title: \"Unit undeleted\",\n message: \"The unit \\\"#{@unit.title}\\\" has been undeleted.\")\n ensure\n redirect_to @unit\n end",
"def upload_error\n vg = Video.find_by_id(params[:video_id]).video_graph rescue nil\n if vg\n vg.set_status(VideoGraph::UPLOADING_ERROR)\n detailed_error_msg = \"Error: #{params[:error_message]} ; File Size: #{params[:file_size]} ; Percent Uploaded: #{params[:percent_uploaded]} ; Average Speed: #{params[:average_speed]} ; Moving Average Speed: #{params[:moving_average]}\"\n vg.error_message = detailed_error_msg\n vg.save\n # save the error for QA tracking and analytics\n vg.video_errors.create(:user_id => vg.user_id, :error_status => vg.status, :error_message => detailed_error_msg)\n \n Airbrake.notify(:error_class => \"Logged Error\", :error_message => \"UPLOAD ERROR: User #{vg.user_id} just had an uploading error... #{detailed_error_msg}\") if Rails.env.production?\n end\n render :nothing => true, :status => :accepted\n end",
"def update_error_message(message:)\n # refresh the resource to avoid stale object error\n @resource = query_service.find_by(id: id)\n primary_file.error_message = [message]\n updated_change_set = ChangeSet.for(resource)\n change_set_persister.buffer_into_index do |buffered_persister|\n buffered_persister.save(change_set: updated_change_set)\n end\n end",
"def delete_loc_time\n delete_loc = user_choice_of_object_in_class(LocationTime)\n try_to_update_database{\n if LocationTime.delete_record(delete_loc.location_id, delete_loc.timeslot_id)\n puts \"Deleted.\"\n else\n puts \"Not deleted. This object id exists in another table.\"\n end\n }\n loc_time_menu\n end",
"def destroy\n @line_item = Spree::LineItem.find_by_id(params[:id])\n @order = Spree::Order.find_by_number(params[:order_id])\n # code to find the order_total\n if @order.market_place.present?\n case @order.market_place.code\n when \"qoo10\"\n order_total = @order.market_place_details.present? ? @order.market_place_details[\"total\"] : @order.total\n when \"lazada\" , \"zalora\"\n order_total = @order.total\n end\n end\n if @line_item.present?\n increased_qty = @line_item.quantity\n @variant = @line_item.variant\n @product = @variant.product if @variant.present?\n @line_item.destroy\n @sellers_market_places_product = Spree::SellersMarketPlacesProduct.where(\"seller_id=? AND market_place_id=? AND product_id=?\", @order.seller_id, @order.market_place_id, @product.id).try(:first)\n if @sellers_market_places_product.present?\n @stock_product = Spree::StockProduct.where(\"sellers_market_places_product_id=? AND variant_id=?\", @sellers_market_places_product.id, @variant.id).try(:first)\n if @stock_product.present?\n @stock_product.update_attributes(:count_on_hand=>@stock_product.count_on_hand + increased_qty.to_i)\n @variant.update_attributes(:fba_quantity=>@variant.fba_quantity + increased_qty.to_i) if !@variant.quantity_inflations.present?\n msg = 'Line Items Controller destroy'\n @variant.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n end\n end\n end\n # code to update order total after creating line item for order\n @order.update_column(:total, order_total)\n @order.reload\n respond_to do |format|\n format.html { redirect_to modify_order_admin_order_path(@order), notice: 'Product is successfully deleted' }\n end\n end",
"def destroy\n listing = UserListing.find(params[:id])\n #change value of 'is_deleted' to true so that it no longer displays\n listing.is_deleted = true\n\n if listing.save(:validate => false)\n if(listing.type == \"Offer\")\n flash[:notice] = 'Offer Deleted' \n else\n flash[:notice] = 'Need Deleted' \n end\n\n respond_to do |format|\n format.html {redirect_to current_user}\n format.js \n end\n else\n\n\n\n if listing.errors.any?\n listing.errors.full_messages.each do |msg|\n flash[:error] = msg\n end\n end\n\n redirect_to current_user\n end\n end",
"def reset_errors!\n @errors = []\n end",
"def reset_errors!\n @errors = []\n end",
"def test_cleanup_failed\n setup_new_order()\n @o.order_line_items << @li\n @o.order_status_code = order_status_codes(:cart)\n @o.notes = \"test test\"\n assert @o.save\n \n notes_before = @o.notes.dup\n\n @o.cleanup_failed(\"A message!\")\n \n # Status code should be updated.\n assert_equal @o.order_status_code, order_status_codes(:on_hold_payment_failed)\n # A new note should be added.\n notes_after = @o.notes\n assert_not_equal notes_before, notes_after\n end",
"def destroy\n #adicionando itens baixados da cautela na reserva \n if params[:baixar]=='false' \n @reservaarmamento=Reservaarmamento.where(id: @cautelaarmamento.reservaarmamento_id,\n reserva_id: @cautelaarmamento.cautela.reserva_id)\n qtd_reserva=0\n @reservaarmamento.each do |reservaarmamento| \n qtd_reserva = reservaarmamento.qtd_armamento\n end\n qtd_armamento_baixado =@cautelaarmamento.qtd_armamento\n qtd_realocar= qtd_reserva + qtd_armamento_baixado \n @reservaarmamento.update(qtd_armamento: qtd_realocar)\n mensagem='O Item foi excluído com Scuesso!'\n end \n \n @cautelaarmamento.destroy\n respond_to do |format|\n format.html { redirect_to \"/cautelaarmamentos?cautela_id=\"+@cautelaarmamento.cautela_id.to_s+\"&reserva_id=\"+@cautelaarmamento.cautela.reserva_id.to_s, notice: mensagem}\n format.json { head :no_content }\n end\n end",
"def delete_file\n unless $list_Item.curselection.empty?\n idx = $list_Item.curselection\n idx = idx[0]\n $bucket_item = $bucket_items[idx]\n ok_delete = Tk.messageBox('type' => 'okcancel',\n 'icon' => 'warning',\n 'title' => 'Delete Bucket',\n 'message' => 'Delete item?')\n if ok_delete == 'ok'\n begin\n $s3.bucket($bucket).objects(prefix: $bucket_item).batch_delete!\n $item_text.delete('1.0','end')\n $save_file_button.state = 'disabled'\n $delete_file_button.state = 'disabled'\n $item_public_read.state = 'disabled'\n $item_public_write.state = 'disabled'\n rescue => e\n Tk.messageBox('type' => 'ok',\n 'icon' => 'error',\n 'title' => 'Delete File',\n 'message' => \"Cannot Delete File #{e}\")\n end\n end\n end\n end",
"def destroy\n @line_item.destroy\n respond_to do |format|\n format.html { redirect_to location_cart_path(@location = params[:location_id], @cart = session[:cart_id]), notice: 'Medicina elimnada de tu carrito' }\n format.json { head :no_content }\n end\n end",
"def clear_import_errors!\n update!(import_errors: nil)\n end",
"def delete_item\n\nend",
"def destroy\n @lint_item.destroy\n respond_to do |format|\n format.html { redirect_to lint_items_url }\n format.json { head :no_content }\n end\n=begin\n @lint_item = LintItem.find(params[:id])\n @lint_item.destroy\n respond_to do |format|\n if @lint_item.cart.lint_items.empty?\n format.html { redirect_to store_url, notice: 'Your cart is empty' }\n else \n format.html { redirect_to @lint_item.cart, notice: 'Product was successfully Removed.'}\n end\n format.json { head :no_content }\n end\n=end\n end",
"def destroy\n item = @item.name\n @item.deleted = true\n @item.deleted_at = Time.now\n @item.save\n\n respond_to do |format|\n format.html { redirect_to items_url, notice: \"#{item} was successfully deleted.\" }\n format.json { head :no_content }\n end\n end",
"def clear_temp_os_places_error\n self.os_places_error = transient_registration.temp_os_places_error\n\n transient_registration.update_attributes(temp_os_places_error: nil)\n end",
"def destroy\n @item.destroy\n flash[:success] = \"項目已刪除!\"\n redirect_to session[:last_page]\n end",
"def validate(item)\n __setobj__(item)\n super\n\n item.errors.messages.merge!(errors.messages)\n end",
"def destroy\n super\n rescue => e\n errors.add(:base, e.message)\n false\n end",
"def destroy\n @item_storage.destroy\n respond_to do |format|\n format.html { redirect_to item_storages_url, notice: '入库记录已删除。' }\n format.json { head :no_content }\n end\n end",
"def destroy\n begin\n @item.destroy\n flash[:notice] = \"Item #{@item.name} deleted\"\n end\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @location = Location.find(params[:id])\r\n RemovedLocation.create(server_id: Integer(params[:id]))\r\n directory = Rails.root.join('app','assets','locations');\r\n\r\n path = File.join(directory, @location.image)\r\n File.delete(path)\r\n @location.destroy\r\n mv = MapsVersion.first\r\n mv.version = mv.version+1\r\n mv.save\r\n respond_to do |format|\r\n format.html { redirect_to locations_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n tmp_element_error = PostitTask.new\n tmp = PostitTask.find(params[:id])\n if tmp\n name = tmp.name\n unless tmp.destroy\n tmp.errors.full_messages.each do |tmp_error| \n tmp_element_error.errors.add(:base, tmp_error)\n end\n end\n end\n if tmp_element_error.errors.empty? \n flash[:notice] = 'Cette tâche a correctement été supprimée.'.trn\n else\n flash[:errors_destroy] = tmp_element_error\n end\n redirect_to :action => \"list\"\n end",
"def destroy\n @storeloc = Storeloc.find(params[:id])\n @storeloc.itemlocs.each do |loc|\n loc.destroy\n end\n\n @storeloc.destroy\n\n respond_to do |format|\n format.html { redirect_to(storelocs_url) }\n format.xml { head :ok }\n end\n end",
"def upload_done(ids)\n # Forces a check that the supplied info is correct\n self.previous_uploads = ids.map { |id| NfsStore::Upload.find(id) }\n self.previous_upload_stored_file_ids = previous_uploads.map(&:nfs_store_stored_file_id)\n\n # Get any uploads that already have an upload_set, since it is invalid to reset it\n raise FsException::Action, \"Upload set files don't match\" if previous_uploads.map(&:upload_set).uniq.length != 1\n\n return unless parent_item&.can_edit?\n\n extra_options_config.calc_save_trigger_if self, alt_on: :upload\n end",
"def cleanup\n deleted = Taxon.cleanup_morphotaxa\n flash[:alert] = \"#{view_context.pluralize(deleted, 'morpho-taxon')} deleted\"\n redirect_to taxa_path\n end",
"def destroy\n begin\n @size.destroy\n respond_to do |format|\n format.html { redirect_to admin_sizes_url, notice: t('messages.deleted', model:Size.model_name.human) }\n format.json { head :no_content }\n end\n rescue ActiveRecord::InvalidForeignKey => e\n flash[:error] = t 'errors.messages.delete_fail.being_used', model:@size.name\n flash[:error_details] = e\n redirect_to [:admin, @size]\n rescue ActiveRecord::StatementInvalid => e\n flash[:error] = t 'errors.messages.ops'\n flash[:error_details] = e\n redirect_to [:admin, @size]\n end\n end",
"def update_errors\n @errors = []\n @errors << 'Expiration date is a required field' unless expiration_date\n @errors << 'Expiration Date is not a valid date' unless expiration_date.is_a? Date\n @errors << 'Card type is a required field' unless card_type\n @errors << 'Card type is not supported' unless check_card_type\n @errors << 'Card number is not valid' unless card_number_valid?\n @errors\n end",
"def storage_failure; end",
"def handle_file_deletions(model)\n record = instance_variable_get(\"@#{model}\")\n if params[\"#{model}_delete\"]\n params[\"#{model}_delete\"].keys.each do |column|\n if record.respond_to?(column) and record.send(column) and File.exists?(record.send(column))\n File.delete(record.send(column))\n #record.update_attribute(column, nil)\n end\n end\n end\n end",
"def handle_file_deletions(model)\n record = instance_variable_get(\"@#{model}\")\n if params[\"#{model}_delete\"]\n params[\"#{model}_delete\"].keys.each do |column|\n if record.respond_to?(column) and record.send(column) and File.exists?(record.send(column))\n File.delete(record.send(column))\n #record.update_attribute(column, nil)\n end\n end\n end\n end",
"def remove_item\n if !@question.many_answers && @item.ok && @question.items.count > 1\n # No more good answer\n # We put one in random to true\n @item.destroy\n @item2 = @question.items.last\n @item2.ok = true\n @item2.save\n flash[:info] = \"Vous avez supprimé une réponse correcte : une autre a été mise correcte à la place par défaut.\"\n else\n @item.destroy\n end\n redirect_to question_manage_items_path(params[:question_id])\n end",
"def destroy\n @crop = Crop.find(params[:id])\n begin\n @crop.destroy \n rescue ActiveRecord::DeleteRestrictionError => e\n @crop.errors.add(:base, e)\n end \n respond_to do |format|\n\n if e.nil?\n \n format.html { redirect_to(\"/cropview\", :notice => 'crop was successfully deleted.') }\n format.xml { head :ok }\n else \n format.html { render :action => \"edit\" }\n end\n \n \n end\n end"
] |
[
"0.63751537",
"0.58743423",
"0.5806554",
"0.57207894",
"0.569172",
"0.5683614",
"0.5657516",
"0.5617872",
"0.5604993",
"0.55403167",
"0.55263066",
"0.5513364",
"0.5510752",
"0.55032307",
"0.5493465",
"0.54803884",
"0.5459021",
"0.54234034",
"0.54214585",
"0.54098827",
"0.53987074",
"0.5397834",
"0.53864706",
"0.5362147",
"0.5354595",
"0.5350199",
"0.53429365",
"0.5341507",
"0.5341507",
"0.5341507",
"0.5341507",
"0.5341507",
"0.5341507",
"0.5341507",
"0.5341507",
"0.5341507",
"0.53339285",
"0.532258",
"0.53186715",
"0.53184456",
"0.5314147",
"0.5309427",
"0.5302353",
"0.5296856",
"0.52874446",
"0.5284025",
"0.5279897",
"0.52762544",
"0.5265376",
"0.5256556",
"0.52512264",
"0.5242384",
"0.52342236",
"0.5221097",
"0.5211929",
"0.52074486",
"0.5207125",
"0.52044475",
"0.5198635",
"0.51938707",
"0.51913166",
"0.51899844",
"0.51786894",
"0.5177174",
"0.5161536",
"0.51600343",
"0.5156342",
"0.51526344",
"0.5149363",
"0.5148988",
"0.514001",
"0.51398814",
"0.51384753",
"0.51384753",
"0.51349014",
"0.5133529",
"0.5130156",
"0.5125471",
"0.5121421",
"0.5119137",
"0.5113046",
"0.5103223",
"0.5102263",
"0.5101068",
"0.5093683",
"0.5090426",
"0.5087211",
"0.508492",
"0.50845",
"0.508107",
"0.5079339",
"0.50747585",
"0.50722224",
"0.5071312",
"0.5064367",
"0.50640297",
"0.5063725",
"0.5063725",
"0.5062957",
"0.5062231"
] |
0.72084194
|
0
|
Update the status of the uploaded file
|
def update_status
case
#If the file is in processing dont change the status
when (self.attribute1 == "Processing" or self.attribute1 == "Uploaded")
self.attribute1 = self.attribute1
#When the file has all processed record
when (self.no_of_processed_records !=0 and self.no_of_error_records == 0)
self.attribute1 = "Processed"
#When the file has only error records no processed record
when (self.no_of_processed_records ==0 and self.no_of_error_records !=0)
self.attribute1 = "Error"
#When there are processed records and error records both in the file
when (self.no_of_processed_records!=0 and self.no_of_error_records !=0)
self.attribute1 = "Processed with Error"
#When all the records are processed and no error and no deleted records
when (self.no_of_records == self.no_of_processed_records and self.no_of_error_records == 0 and self.no_of_deleted_records == 0)
self.attribute1 = "Processed Successfully"
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update_status(status)\n @status = status\n @last_status_change = Time.now\n update_statusfile\n end",
"def update(uploaded_file)\n _set(uploaded_file)\n end",
"def run_upload!\n \tself.status = 'En Proceso'\n \tsave\n end",
"def update_file(params)\n self.processed = false\n self.attributes = params\n set_upload_attributes\n save!\n Avatar.delay.finalize_and_cleanup(id)\n end",
"def upload_failed\n update_attributes(:status => STATUS[:failed])\n end",
"def update\n upload = params.require(:file)\n handler = setup_handler(upload)\n\n if handler.valid?\n handler.call\n render json: {}, status: 202\n else\n render json: { errors: handler.errors }, status: 422\n end\n end",
"def update\n @file_version = FileVersion.find(params[:id])\n params[:versioned_file_id] = @file_version.versioned_file_id\n if update_versioned_files? \n if @file_version.update(:isActive => true)\n head :no_content\n else\n render json: @file_version.errors, status: :unprocessable_entity\n end \n else \n render json: @file_version.errors, status: :unprocessable_entity\n end\n end",
"def update_status(p_audio_file_container)\n\n # Retrieve path-related attributes for the current audio file\n folder = p_audio_file_container[:folder]\n filename = p_audio_file_container[:filename]\n relative_path = \"#{folder}\\\\#{filename}\" # TODO: Eventually path mechanics, combine\n current_audio_file = p_audio_file_container[:file]\n\n # Refresh UI with current status\n @view.update_notification({\n :type => :info,\n :text => tr(\"Processing \\\"#{relative_path}\\\" . . .\")\n })\n\n # Return to be processed audio-file\n current_audio_file\n end",
"def update!(**args)\n @status_content = args[:status_content] if args.key?(:status_content)\n @status_file_name = args[:status_file_name] if args.key?(:status_file_name)\n end",
"def update!(**args)\n @filename = args[:filename] if args.key?(:filename)\n @size = args[:size] if args.key?(:size)\n @upload_status = args[:upload_status] if args.key?(:upload_status)\n end",
"def update\n @upload_file = UploadFile.find(params[:id])\n\t\tauthorize! :create, @upload_file\n\n\t\tif params[:upload]\n\t\t\tname = UploadFile.save(params[:upload])\n\t\t\t@upload_file.filename = name\n\t\tend\n\t\t\n respond_to do |format|\n if @upload_file.update_attributes(params[:upload_file])\n\t format.html { redirect_to(upload_files_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n end\n end\n end",
"def update_upload_attributes\n if document.present? && document_changed?\n self.content_type = document.file.content_type\n self.file_size = document.file.size\n self.file_name = File.basename(document.url)\n end\n end",
"def update\n @uploaded_file = UploadedFile.find(params[:id])\n\n respond_to do |format|\n if @uploaded_file.update_attributes(params[:uploaded_file])\n format.html { redirect_to @uploaded_file, notice: 'Uploaded file was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @uploaded_file.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_status\n\t\tasset.update_attributes(:status => STATUS[\"Assigned\"])\n\tend",
"def update_status\n\t\tasset.update_attributes(:status => STATUS[\"Assigned\"])\n\tend",
"def update\n respond_to do |format|\n if @uploaded_file.update(uploaded_file_params)\n format.html { redirect_to @uploaded_file, notice: 'Uploaded file was successfully updated.' }\n format.json { render :show, status: :ok, location: @uploaded_file }\n else\n format.html { render :edit }\n format.json { render json: @uploaded_file.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n success =\n if wants_to_revert?\n update_version\n elsif wants_to_upload_new_version?\n update_file\n elsif params.key? :generic_file\n update_metadata\n elsif params.key? :visibility\n update_visibility\n end\n if success\n redirect_to sufia.generic_file_path(@generic_file), notice:\n 'File was successfully updated.'\n else\n flash[:error] ||= 'Update was unsuccessful.'\n set_variables_for_edit_form\n render action: 'edit'\n end\n end",
"def update\n version_event = false\n\n if params.has_key?(:revision) and params[:revision] != @generic_file.content.latest_version.versionID\n revision = @generic_file.content.get_version(params[:revision])\n @generic_file.add_file_datastream(revision.content, :dsid => 'content')\n version_event = true\n begin\n Resque.enqueue(ContentRestoredVersionEventJob, @generic_file.pid, current_user.user_key, params[:revision])\n rescue Redis::CannotConnectError\n logger.error \"Redis is down!\"\n end\n end\n\n if params.has_key?(:filedata)\n return unless virus_check(params[:filedata]) == 0\n add_posted_blob_to_asset(@generic_file, params[:filedata])\n version_event = true\n begin\n Resque.enqueue(ContentNewVersionEventJob, @generic_file.pid, current_user.user_key)\n rescue Redis::CannotConnectError\n logger.error \"Redis is down!\"\n end\n end\n @generic_file.update_attributes(params[:generic_file].reject { |k,v| %w{ Filedata Filename revision part_of date_modified date_uploaded format }.include? k})\n @generic_file.set_visibility(params)\n @generic_file.date_modified = Time.now.ctime\n @generic_file.save\n # do not trigger an update event if a version event has already been triggered\n begin\n Resque.enqueue(ContentUpdateEventJob, @generic_file.pid, current_user.user_key) unless version_event\n rescue Redis::CannotConnectError\n logger.error \"Redis is down!\"\n end\n record_version_committer(@generic_file, current_user)\n redirect_to sufia.edit_generic_file_path(:tab => params[:redirect_tab]), :notice => render_to_string(:partial=>'generic_files/asset_updated_flash', :locals => { :generic_file => @generic_file })\n\n end",
"def file_update(project, old_file, new_fie)\n file = ActionDispatch::Http::UploadedFile.new(\n tempfile: upload(new_fie),\n filename: new_fie,\n original_filename: old_file\n )\n post :file_update, user_id: project.user.username,\n id: project.name,\n branch: 'master',\n destination: new_fie,\n message: 'update image',\n file: file\n end",
"def update_job_status(status)\n @csv_report_job.status = status\n @csv_report_job.save!\n end",
"def update\n @upload_file = UploadFile.find(params[:id])\n\n respond_to do |format|\n if @upload_file.update_attributes(params[:upload_file])\n format.html { redirect_to(@upload_file, :notice => 'Upload file was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @upload_file.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @upload_file = UploadFile.find(params[:id])\n\n respond_to do |format|\n if @upload_file.update_attributes(params[:upload_file])\n format.html { redirect_to(@upload_file, :notice => 'Upload file was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @upload_file.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @upload_file.update(upload_file_params)\n format.html { redirect_to @upload_file, notice: 'Upload file was successfully updated.' }\n format.json { render :show, status: :ok, location: @upload_file }\n else\n format.html { render :edit }\n format.json { render json: @upload_file.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @upload_file.update(upload_file_params)\n format.html { redirect_to @upload_file, notice: 'Upload file was successfully updated.' }\n format.json { render :show, status: :ok, location: @upload_file }\n else\n format.html { render :edit }\n format.json { render json: @upload_file.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @file_upload = FileUpload.find(params[:id])\n\n respond_to do |format|\n if @file_upload.update_attributes(params[:file_upload])\n format.html { redirect_to(@file_upload, :notice => 'FileUpload was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @file_upload.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n RawFile.transaction do\n @raw_file = RawFile.find_by_user(params[:id],current_user.id)\n\n @raw_file.uploaded_file = params[:raw_file][:file]\n\n respond_to do |format|\n if @raw_file.save\n format.html { redirect_to @raw_file, :notice => 'Raw file was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render \"edit\", :locals => { :raw_file => @raw_file } }\n format.json { render :json => @raw_file.errors, :status => :unprocessable_entity }\n end\n end\n end\n end",
"def update(uploaded_file)\n super\n record.save(raise_on_failure: true)\n end",
"def update\n @up_file = UpFile.find(params[:id])\n\n respond_to do |format|\n if @up_file.update_attributes(params[:up_file])\n format.html { redirect_to @up_file, notice: 'Up file was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @up_file.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\nrespond_to do |format|\nif @upload.update(upload_params)\nformat.html { redirect_to @upload, notice: 'Upload was successfully updated.' }\nformat.json { head :no_content }\nelse\nformat.html { render action: 'edit' }\nformat.json { render json: @upload.errors, status: :unprocessable_entity }\nend\nend\nend",
"def fix\n path = Rails.root.join(\"public/system/files/#{self.id}/original/#{self.file_file_name}\")\n Formatador.display_line(\"Uploading file at: [green]#{path}[/]\")\n if File.exists?(path)\n self.attached_file.store!(File.open(path))\n self.update_attribute(:attached_file, self.file_file_name)\n Formatador.display_line(\"[yellow]Done![/]\")\n else\n Formatador.display_line(\"[red]ERROR: [/]File does not exist!\")\n end\n end",
"def update\n respond_to do |format|\n if @file_upload.update(file_upload_params)\n format.html { redirect_to @file_upload, notice: 'File upload was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @file_upload.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @upload.update(params[:upload])\n format.html { redirect_to @upload, :notice => 'Upload was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @upload.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update(uploaded_file)\n super\n record.save_changes(validate: false)\n end",
"def update\n respond_to do |format|\n if @upload.update(upload_params)\n format.html { redirect_to @upload, notice: 'Upload was successfully updated.' }\n format.json { render :show, status: :ok, location: @upload }\n else\n format.html { render :edit }\n format.json { render json: @upload.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @upload.update(upload_params)\n format.html { redirect_to @upload, notice: 'Upload was successfully updated.' }\n format.json { render :show, status: :ok, location: @upload }\n else\n format.html { render :edit }\n format.json { render json: @upload.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n\n if @file_upload.update(file_upload_params)\n format.html { redirect_to user_file_upload_path, notice: 'File was successfully updated.' }\n format.json { render :show, status: :ok, location: @file_upload }\n @md5 = Digest::MD5.file(@file_upload.attachment.path).hexdigest \n @file_upload[:hash_val]=@md5\n @file_upload.save\n else\n format.html { render :edit }\n format.json { render json: @file_upload.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_status\n save_csv\n end",
"def update\n @uploaded_file = @page.uploaded_files.find(params[:id])\n return error_status(true, :cannot_edit_uploaded_file) unless (@uploaded_file.can_be_edited_by(@logged_user))\n \n @uploaded_file.updated_by = @logged_user\n\n respond_to do |format|\n if @uploaded_file.update_attributes(params[:uploaded_file])\n flash[:notice] = 'uploaded_file was successfully updated.'\n format.html { redirect_to(@uploaded_file) }\n format.js { render :action => 'update', :content_type => 'text/html' }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.js { render :action => 'update', :content_type => 'text/html' }\n format.xml { render :xml => @uploaded_file.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @upload = Upload.find(params[:id])\n\n respond_to do |format|\n if @upload.update_attributes(params[:upload])\n format.html { redirect_to user_uploads_path(current_user.id), notice: 'Upload was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @upload.errors, status: :unprocessable_entity }\n end\n end\n end",
"def status_update(_event)\n @submitted = false\n @filed = false\n end",
"def update\n @upload = Upload.find(params[:id])\n\n respond_to do |format|\n if @upload.update_attributes(params[:upload])\n format.html { redirect_to(@upload, :notice => 'Upload was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @upload.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @upload = Upload.find(params[:id])\n\n respond_to do |format|\n if @upload.update_attributes(params[:upload])\n format.html { redirect_to(@upload, :notice => 'Upload was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @upload.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @upload = Upload.find(params[:id])\n\n respond_to do |format|\n if @upload.update_attributes(params[:upload])\n format.html { redirect_to(@upload, :notice => 'Upload was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @upload.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @upload = Upload.find(params[:id])\n\n respond_to do |format|\n if @upload.update_attributes(params[:upload])\n flash[:notice] = 'Upload was successfully updated.'\n format.html { redirect_to(@upload) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @upload.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @upload = Upload.find(params[:id])\n\n respond_to do |format|\n if @upload.update_attributes(params[:upload])\n format.html { redirect_to @upload, notice: 'Upload was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @upload.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @upload = Upload.find(params[:id])\n\n respond_to do |format|\n if @upload.update_attributes(params[:upload])\n format.html { redirect_to @upload, notice: 'Upload was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @upload.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @upload = Upload.find(params[:id])\n\n respond_to do |format|\n if @upload.update_attributes(params[:upload])\n format.html { redirect_to @upload, notice: 'Upload was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @upload.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_status\n response = @api.get(@cloud.url(:status, @process_id), no_callbacks: true, token: @cloud.access_token.token)\n @progress = response['ProgressPercents'].to_i\n @progress\n end",
"def save_file_entry\n @user.search_files.create!(file_path: uploaded_file_path.result, file_name: @file.original_filename, status: 'initialized')\n end",
"def process_upload\n return if @upload_processed\n @file.file.process!\n @upload_processed = true\n end",
"def upload\r\n \r\n end",
"def post_save\n if self.upload_status_changed?\n if upload_status == \"Waiting to Upload\"\n self.upload_to_dropbox!\n elsif upload_status == \"Uploading\"\n self.extract_metadata!\n elsif upload_status == \"Complete\"\n self.delete_from_server!\n end\n end\n end",
"def upload\n response = success_update_response\n unless @item.update_attributes(avatar: params[:file])\n response = fail_update_response @item\n end\n render json: response\n end",
"def update\n respond_to do |format|\n if @upload.update(upload_params)\n format.html { redirect_to new_upload_path, notice: 'Upload was successfully updated.' }\n else\n format.html { render action: 'edit' }\n end\n end\n end",
"def update\n # Save file\n if params[:upload]\n file_path = DataFile.store(params[:upload])\n unless file_path\n @apk.errors.add :file, 'upload failed, please try again'\n render :action => \"new\"\n return\n end\n @apk.file_path = file_path\n end\n\n respond_to do |format|\n if @apk.update_attributes(params[:apk])\n format.html { redirect_to(@apk, :notice => 'Apk was successfully updated.') }\n else\n format.html { render :action => \"edit\" }\n end\n end\n end",
"def update_status\n if logged_in?\n\t find_record(params[:post_id])\n\t @read_progress.update(completed: param[:completed])\n end\n end",
"def update_status status\n @job.set({\n custom_status: status,\n pinged_at: Time.now\n })\n end",
"def upload_file\n #TODO\n end",
"def perform\n check_file # checks if the file uploaded is valid\n save_file_entry # Uploads the file to the server and saves a entry to database\n end",
"def swap(uploaded_file)\n update(uploaded_file)\n uploaded_file\n end",
"def update\n cf = CoreFile.find(params[:id])\n cf.update(core_file_params)\n\n redirect_to cf\n end",
"def update_progress(file, percent_done)\n file_info = filesizes[file]\n\n current_bytes = (percent_done * file_info[:size]) / 100\n since_last = current_bytes - file_info[:transferred]\n filesizes[file][:transferred] = current_bytes\n\n increment_transferred(since_last)\n update_percent(transferred)\n end",
"def update\n respond_to do |format|\n if @event_import_file.update_attributes(event_import_file_params)\n if @event_import_file.mode == 'import'\n Resque.enqueue(EventImportFileQueue, @event_import_file.id)\n end\n format.html { redirect_to @event_import_file, notice: t('controller.successfully_updated', model: t('activerecord.models.event_import_file')) }\n format.json { head :no_content }\n else\n prepare_options\n format.html { render action: \"edit\" }\n format.json { render json: @event_import_file.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @file_info.update(file_info_params)\n format.html { redirect_to @file_info, notice: 'File info was successfully updated.' }\n format.json { render :show, status: :ok, location: @file_info }\n else\n format.html { render :edit }\n format.json { render json: @file_info.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_from_filename filename\n self.original_filename = filename\n self.valid?\n end",
"def update_file_info\n if self.path\n size = File.exists?(self.path) ? File.size(self.path) : nil\n end\n if size\n (value, units) = bits_to_human_readable(size)\n self.size = value unless value.nil? or value.empty?\n self.size_units = units unless units.nil? or units.empty?\n self.save if self.descMetadata.changed?\n end\n end",
"def update\n upload = params.require(:file)\n handler = create_handler(params[:id], upload)\n\n if handler.valid?\n render json: attachment_json(handler.call)\n else\n render json: errors_json(handler), status: :unprocessable_entity\n end\n end",
"def changed?(uploaded_file)\n record.reload\n super\n end",
"def update\n @current_user.avatar = params[:file]\n @current_user.save!\n json_response({ message: Message.media_created })\n end",
"def si_update_attachment\n if !$attachment.nil?\n $attachment.destroy\n $attachment = Attachment.new\n end\n $attachment_changed = true\n $attachment.avatar = params[:file]\n $attachment.id = 1\n $attachment.save!\n if $attachment.save\n render json: { \"image\" => $attachment.avatar }\n else\n render json: { \"image\" => \"\" }\n end\n end",
"def update\n @sys_image = resource_find(params[:id])\n uploaded_io = params[:file]\n if (params[:sys_image_id] != -1)\n @sys_image.sys_image_id = params[:sys_image_id]\n end\n\n unless uploaded_io.nil?\n _size = File.size(uploaded_io) \n params[:sys_image].merge!({:size => _size}) \n end\n\n if @sys_image.update_attributes(params[:sys_image])\n unless uploaded_io.nil?\n write_resource(@sys_image, uploaded_io.read, \"ndz\")\n end \n\n #flash[\"success\"] = 'Sys image was successfully updated.'\n flash[\"success\"] = t(\"amazing.sys_image.updated\")\n redirect_to(@sys_image) \n else\n render :action => \"edit\"\n end\n end",
"def update\n pp params\n respond_to do |format|\n if @upload.update(upload_params)\n format.html { redirect_to @upload, notice: 'Upload was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @upload.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n \n @song = Song.find(params[:id])\n thread = Thread.new{@song.update_attributes(params[:song]) && @song.song_upload.update_attributes(:file => params[:file])} \n respond_to do |format|\n if thread\n format.html { redirect_to @song, notice: 'Song was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @song.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @upload_file_to_server.update(upload_file_to_server_params)\n format.html { redirect_to @upload_file_to_server, notice: 'Upload file to server was successfully updated.' }\n format.json { render :show, status: :ok, location: @upload_file_to_server }\n else\n format.html { render :edit }\n format.json { render json: @upload_file_to_server.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_photo(album_id, photo_id, file, filename)\n \n end",
"def update_remote\n last_commit = @connection.last_commit(self.id)\n files = Repository.diff(last_commit)\n \n if files.length > 0\n puts \"#{files.length} changes since last delivery\"\n pbar = ProgressBar.new(\"Uploading\", files.length)\n files.each do |file|\n @connection.send(Gift::Connection.file_method(file.last.action), file.last)\n pbar.inc\n end\n pbar.finish\n \n last_commit = Gift::Repository.last_commit_hash unless last_commit && last_commit != \"\"\n self.save_state(last_commit)\n else\n puts \"Everything up to date!\"\n end\n \n @connection.close\n end",
"def update\n description = file_params[:description] || @file.description\n\n raise ApiError, \"Can't rename a file.\" unless @file.rename(file_params[:name], description)\n\n render json: @file, adapter: :json\n end",
"def update\n respond_to do |format|\n if @user_file.update(user_file_params)\n format.html { redirect_to @user_file, notice: \"User file was successfully updated.\" }\n format.json { render :show, status: :ok, location: @user_file }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @user_file.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_api_status()\n api_status = generate_api_status()\n if !api_status.nil? and !api_status.empty?\n HelperFunctions.write_file(HEALTH_FILE, api_status)\n end\n end",
"def update!(**args)\n @events = args[:events] if args.key?(:events)\n @file_path = args[:file_path] if args.key?(:file_path)\n @status = args[:status] if args.key?(:status)\n end",
"def update\n respond_to do |format|\n if @grid_fs_file.update(grid_fs_file_params)\n format.html { redirect_to @grid_fs_file, notice: 'Grid fs file was successfully updated.' }\n format.json { render :show, status: :ok, location: @grid_fs_file }\n else\n format.html { render :edit }\n format.json { render json: @grid_fs_file.errors, status: :unprocessable_entity }\n end\n end\n end",
"def upload\n end",
"def upload\n end",
"def update\n respond_to do |format|\n if @image_file.update(image_file_params)\n format.html { redirect_to @image_file, notice: 'Image file was successfully updated.' }\n format.json { render :show, status: :ok, location: @image_file }\n else\n format.html { render :edit }\n format.json { render json: @image_file.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n delete_file\n upload_file\n respond_to do |format|\n if @policy.update(:filename => @policy_io.original_filename)\n format.html { redirect_to @policy, notice: 'Policy was successfully updated.' }\n # format.json { render :show, status: :ok, location: @policy }\n else\n format.html { render :edit }\n # format.json { render json: @policy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user_file = UserFile.find(params[:id])\n authorize! :update, @user_file\n respond_to do |format|\n if @user_file.update_attributes(params[:user_file])\n format.html { redirect_to @user_file, :notice => 'User file was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @user_file.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def uploaded_file=(file); write_attribute(:uploaded_file, file); end",
"def update\n params[:account][:label_ids] ||= []\n process_file_uploads(@account)\n respond_to do |format|\n if @account.update_attributes(account_params)\n format.html { redirect_to(@account,\n notice: \"Account was successfully updated. #{undo_link}\") }\n format.xml { head :ok }\n else\n handle_error(format, @account, 'edit')\n end\n end\n end",
"def update\n if @complaintfile.update(complaintfile_params)\n render json: @complaintfile, status: :ok\n else\n render json: @complaintfile.errors, status: :unprocessable_entity\n end\n\n #respond_to do |format|\n # if @complaintfile.update(complaintfile_params)\n # format.html { redirect_to @complaintfile, notice: 'Complaintfile was successfully updated.' }\n # format.json { render :show, status: :ok, location: @complaintfile }\n # else\n # format.html { render :edit }\n # format.json { render json: @complaintfile.errors, status: :unprocessable_entity }\n # end\n #end\n end",
"def update\n feedback_file = record\n\n # Render error if the filename is used by another\n # Feedback File for that submission\n existing_file = feedback_file.submission.feedback_files.find_by(filename: params[:filename])\n if !existing_file.nil? && existing_file.id != params[:id].to_i\n render 'shared/http_status', locals: { code: '409', message:\n 'A Feedback File with that filename already exists' }, status: :conflict\n return\n end\n\n # Update filename if provided\n feedback_file.filename = params[:filename] unless params[:filename].nil?\n\n if params[:file_content].respond_to? :read # binary data\n content = params[:file_content].read\n else\n content = params[:file_content]\n end\n\n if feedback_file.save && feedback_file.update_file_content(content)\n # Everything went fine; report success\n render 'shared/http_status', locals: { code: '200', message:\n HttpStatusHelper::ERROR_CODE['message']['200'] }, status: :ok\n else\n # Some other error occurred\n render 'shared/http_status', locals: { code: '500', message:\n HttpStatusHelper::ERROR_CODE['message']['500'] }, status: :internal_server_error\n end\n rescue ActiveRecord::RecordNotFound => e\n # Could not find submission or feedback file\n render 'shared/http_status', locals: { code: '404', message:\n e }, status: :not_found\n end",
"def update_status(msg)\n status_file_path = File.join(RAILS_ROOT, \"files\", \"activity_results\", \"status_#{id.to_s}.log\")\n File.open(status_file_path, 'w') {|f| f << msg }\n end",
"def update\n @file_info = FileInfo.find(params[:id])\n\n respond_to do |format|\n if @file_info.update_attributes(params[:file_info])\n format.html { redirect_to @file_info, notice: 'File info was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @file_info.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @indexed_file = IndexedFile.find(params[:id])\n\n respond_to do |format|\n if @indexed_file.update_attributes(params[:indexed_file])\n format.html { redirect_to @indexed_file, notice: 'Indexed file was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @indexed_file.errors, status: :unprocessable_entity }\n end\n end\n end",
"def file(_event)\n setTimeout 0 do\n @submitted = true\n @filed = true\n end\n end",
"def update\n @userfile = Userfile.find(params[:id])\n\n respond_to do |format|\n if @userfile.update_attributes(params[:userfile])\n format.html { redirect_to @userfile, notice: 'Userfile was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @userfile.errors, status: :unprocessable_entity }\n end\n end\n end",
"def of_update_attachment\n if !$attachment.nil?\n $attachment.destroy\n $attachment = Attachment.new\n end\n $attachment_changed = true\n $attachment.avatar = params[:file]\n $attachment.id = 1\n $attachment.save!\n if $attachment.save\n render json: { \"image\" => $attachment.avatar }\n else\n render json: { \"image\" => \"\" }\n end\n end",
"def set_file_from_raw_data\n self.status = 'archived'\n self.file = ActionDispatch::Http::UploadedFile.new(filename: filename, tempfile: tempfile_for_filedata)\n end",
"def update\n file = params[:file_name]\n @processor = Import::VehicleImporter.new(current_account, current_user)\n @processor.process(file)\n end",
"def update\n @file_version = FileVersion.find(params[:id])\n\n respond_to do |format|\n if @file_version.update_attributes(params[:file_version])\n format.html { redirect_to @file_version, notice: 'File version was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @file_version.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @inventory_file.update(inventory_file_params)\n flash[:notice] = t('controller.successfully_updated', model: t('activerecord.models.inventory_file'))\n format.html { redirect_to(@inventory_file) }\n format.json { head :no_content }\n else\n prepare_options\n format.html { render action: \"edit\" }\n format.json { render json: @inventory_file.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.7392309",
"0.7360412",
"0.7196221",
"0.711043",
"0.69734913",
"0.6907724",
"0.6903304",
"0.6836086",
"0.67979157",
"0.677148",
"0.6767429",
"0.67000014",
"0.6678934",
"0.6672454",
"0.6672454",
"0.66581047",
"0.66365635",
"0.65847164",
"0.65715075",
"0.6557642",
"0.6553165",
"0.6553165",
"0.65490013",
"0.65490013",
"0.65461576",
"0.65307057",
"0.65142107",
"0.6484227",
"0.6467243",
"0.6452785",
"0.6439024",
"0.64190775",
"0.6378808",
"0.63596195",
"0.63596195",
"0.63260496",
"0.6318529",
"0.6313743",
"0.63115954",
"0.6309842",
"0.63060313",
"0.63060313",
"0.63060313",
"0.62990147",
"0.6295442",
"0.6295442",
"0.6295442",
"0.6290883",
"0.62584794",
"0.62393826",
"0.62244654",
"0.6220993",
"0.6220702",
"0.6202528",
"0.61948025",
"0.6193969",
"0.6185577",
"0.61845195",
"0.61719084",
"0.61627996",
"0.61489916",
"0.6148919",
"0.61461735",
"0.6143817",
"0.6139571",
"0.6136023",
"0.6133541",
"0.6117983",
"0.61127067",
"0.61079943",
"0.6105675",
"0.6104944",
"0.6097979",
"0.60893977",
"0.60870135",
"0.6084734",
"0.6082725",
"0.60809386",
"0.608023",
"0.60751665",
"0.6064324",
"0.6062663",
"0.6062663",
"0.60600936",
"0.60580945",
"0.6057015",
"0.605556",
"0.60338706",
"0.60336",
"0.6030488",
"0.6026633",
"0.60224396",
"0.602179",
"0.6018905",
"0.60116625",
"0.6011443",
"0.5996292",
"0.5992188",
"0.5984256",
"0.59825766"
] |
0.6479603
|
28
|
refactor to put in the reader and initialize method
|
def title
if @title == nil
"Movie not found!"
else
@title
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def initializing_reader(key); end",
"def initialize(reader)\n @reader = reader\n end",
"def reader=(_arg0); end",
"def reader; end",
"def initialize(structured_reader,&block)\n @reader = structured_reader\n instance_eval( &block ) if block\n end",
"def initialize\n super()\n init_data()\n end",
"def initializing_reader(key)\n return self[key] if key?(key)\n self[key] = DocumentMapper::Base.new\n end",
"def initializing_reader(key)\n ck = convert_key(key)\n regular_writer(ck, self.class.new) unless key?(ck)\n regular_reader(ck)\n end",
"def initialize\n \n end",
"def initialize options\n self.class.constants.each do |x|\n klass = eval x.to_s\n @reader = klass.new options\n break if @reader\n end\n raise 'Unknown format' unless @reader\n end",
"def initialize(iRawReader, iHeader)\n @RawReader, @Header = iRawReader, iHeader\n super()\n end",
"def initialize() end",
"def initialize_data\n end",
"def initializing_reader(key)\n self[key] = self.class.new unless key?(key)\n self[key]\n end",
"def initialize(line_reader, cleanse_header: true, **args)\n @tabular = IOStreams::Tabular.new(**args)\n @line_reader = line_reader\n @cleanse_header = cleanse_header\n end",
"def initialize(line)\n cols = line.chomp.split \"\\t\"\n name = [ cols[0], cols[2,4] ]\n @readName = name.flatten.join(':') + '#' + cols[6] + '/' + cols[ 7 ] \n @seq = cols[ 8 ]\n @qvList = cols[ 9 ].each_byte.map {|i| i - 64 }\n @chrom = cols[ 10 ]\n @offset = cols[ 12 ].to_i\n @strand = cols[ 13 ]\n @filter = cols[ 21 ]\n end",
"def initialize\n load_data\n end",
"def initialize\n\t\t\n\tend",
"def custom_reader(key); end",
"def init; end",
"def init; end",
"def init; end",
"def init; end",
"def initialize options\n if options.has_key? :path\n @reader = Polecat::IndexReader.new(options[:path])\n elsif options.has_key? :reader \n @reader = options[:reader]\n raise ArgumentError, 'no reader' unless @reader.kind_of?(Polecat::IndexReader)\n end\n\n if options.has_key? :default_field\n @default_field = options[:default_field]\n end\n end",
"def initialize\n\t \t# loading or not loading should be the key here.\n end",
"def initialize(str,file = true)\n if file\n @data = CSV.read(str)\n else\n @data = CSV.parse(str) \n end\n parse\n end",
"def initialize \n #local variable csv will be created. It will = instance of CSV reader, drawn from \"./zipcode-db.cvs\"\n csv = CSVReader.new(\"./free-zipcode-database.csv\")\n #areas will have default value of an empty array\n @areas = []\n #I will run csv.read, which will return a hash based on a file of information.\n csv.read do |item|\n #the hash I get from csv.read will be formatted according to the Area class, and then put into the @areas array.\n @areas << Area.new(item)\n end\n end",
"def initialize\n end",
"def init_data\n end",
"def initialize(raw_data)\n @raw_data = raw_data\n end",
"def initialize(row)\n @row_hash = row\n\n @id = row[:id]\n @service = row[:service_name]\n @section = row[:section_name]\n @graph = row[:graph_name]\n @number = row[:number].to_i # NOT NULL DEFAULT 0\n @description = row[:description] || ''\n @sort = row[:sort].to_i # NOT NULL DEFAULT 0\n\n @meta = row[:meta]\n @parsed_meta = JSON.parse(@meta || '{}', :symbolize_names => true)\n\n @created_at_time = Time.at(row[:created_at].to_i)\n @updated_at_time = Time.at(row[:updated_at].to_i)\n end",
"def init\n raise NotImplementedError\n end",
"def initialize(reader, writer=\"#{reader}=\", default=nil, attributes={}, init=true, dup=nil)\n self.reader = reader\n self.writer = writer\n @default = default\n @attributes = attributes\n @init = init\n @dup = dup.nil? ? Config.duplicable_value?(default) : dup\n end",
"def initialize(data)\n\n end",
"def initialize(*) end",
"def initialize(*) end",
"def initialize(*) end",
"def initialize(*) end",
"def initialize(*) end",
"def initialize(attrs = {})\n @attributes = attrs\n\n # Set values where we have defined a reader, probably\n @attributes.each do |key, val|\n if respond_to?(key.to_sym)\n instance_variable_set(\"@#{key}\", val)\n end\n end\n end",
"def initialize data\n self.data = data\n parse_data\n end",
"def initialize\n\n\tend",
"def initialize\n\n\tend",
"def pre_initialize; end",
"def initialize(data)\n super\n end",
"def initialize(data)\n super\n end",
"def initialize\r\n\r\n end",
"def initialize() # no file name if want to build model manually\n @reRefs = Hash.new(*[]) # references to the entity, hash keyed by entity\n @enums={}; @records = {}\n @ver = nil\n end",
"def init\n end",
"def init\n end",
"def init\n end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize(data)\n super\n pre_parse!\n end",
"def initialize\n super\n end",
"def initialize\n super\n end",
"def read(*args)\n #This is a stub, used for indexing\n end",
"def initialize()\n end",
"def initialize(*args, &block)\n @csv = CSVReader.new(*args)\n @config = self.class.config.dup\n @config.attributes = args.last\n @report = Report.new\n Configurator.new(@config).instance_exec(&block) if block\n end",
"def init\n\n end",
"def pre_initialize\n end",
"def reader_proc(&block)\n #defined by default_for_proc_type in initialize!\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def create_reader(klass, member); end",
"def initialize(row)\n @row = row\n end",
"def initialize(data)\n @index = data['index']\n @codec_name = data['codec_name']\n @codec_type = data['codec_type']\n @tags = (data['tags']) ? data['tags'] : []\n end",
"def initialize(input_file)\n\t\tsuper(input_file)\n\t\t\n\tend",
"def initialize\n init\n end",
"def init_source(mode, source)\n raise \"Unimplemented method #init_source in data reader #{self.class.name}\"\n end",
"def initialize\n \n end",
"def initialize(data)\n self.data = (self.respond_to? :prepare_data)? prepare_data(data): data\n self\n end",
"def initialize(raw_data)\n # FIXME: check if the data is invalid\n @raw_data = raw_data['results'].first rescue nil\n end",
"def initialize()\n\t\tend",
"def initialize(rowdata)\n @rowdata = rowdata\n end",
"def initialize()\n @name = '';\n @headers = Array.new;\n @params = Hash.new;\n\t\t@rows = Array.new;\n end",
"def initialize(rows)\n @rows = rows\n end",
"def init_with(coder_) # :nodoc:\n format_ = Format.get(coder_['format'], true)\n value_ = coder_['value']\n if value_\n value_ = format_.parse(value_, coder_['parse_params'])\n initialize(value_.values_array, format_, value_.unparse_params)\n else\n initialize(coder_['fields'], format_, coder_['unparse_params'])\n end\n end",
"def at_init\n\n\t\tend",
"def init\n if @read_session\n @session_id = self[:session_id]\n @author_id = self[:author_id]\n @visits = self[:visits]\n @updated_at = self[:updated_at]\n @created_at = self[:created_at]\n @id = self[:id]\n else\n self[:session_id] = SessionCredential.generate_id\n self[:author_id] = SessionCredential.generate_id\n @session_id = self[:session_id]\n @author_id = self[:author_id]\n @visits = self[:visits]\n @updated_at = self[:updated_at]\n @created_at = self[:created_at]\n @id = self[:id]\n end\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end",
"def initialize()\n super\n end"
] |
[
"0.7154368",
"0.70898867",
"0.70443493",
"0.6979475",
"0.65022844",
"0.64680356",
"0.6453356",
"0.64045167",
"0.6398014",
"0.63712186",
"0.6330945",
"0.6329816",
"0.63130033",
"0.6281689",
"0.6254085",
"0.6230478",
"0.6194092",
"0.6176675",
"0.61694026",
"0.6157127",
"0.6157127",
"0.6157127",
"0.6157127",
"0.6130522",
"0.6093107",
"0.60904413",
"0.606452",
"0.60609555",
"0.6056495",
"0.60259265",
"0.6008404",
"0.5999402",
"0.5997737",
"0.5986309",
"0.59813607",
"0.59813607",
"0.59813607",
"0.59813607",
"0.59813607",
"0.59805155",
"0.5975503",
"0.5969924",
"0.5969924",
"0.59658116",
"0.59633607",
"0.59633607",
"0.5960074",
"0.5945264",
"0.59438443",
"0.59438443",
"0.59438443",
"0.5936987",
"0.5936987",
"0.5936987",
"0.5936987",
"0.5936987",
"0.5936987",
"0.5936987",
"0.5936987",
"0.5936987",
"0.5936987",
"0.5936987",
"0.5935848",
"0.59255666",
"0.59255666",
"0.59193623",
"0.5910688",
"0.59063137",
"0.59058344",
"0.5899413",
"0.58988696",
"0.58956736",
"0.58956736",
"0.58956736",
"0.58956736",
"0.58956736",
"0.58956736",
"0.58812547",
"0.58801764",
"0.5873794",
"0.5869148",
"0.58495915",
"0.5846327",
"0.58384746",
"0.5833699",
"0.58299625",
"0.5822156",
"0.58194894",
"0.58152163",
"0.58139545",
"0.58138907",
"0.5805475",
"0.5805343",
"0.5801176",
"0.5801176",
"0.5801176",
"0.5801176",
"0.5801176",
"0.5801176",
"0.5801176",
"0.5801176"
] |
0.0
|
-1
|
This concern requires the following methods to be implemented: current_user, target_branch, repository, commit_message Before calling `run_actions`, you should ensure the repository exists, by calling `repository.create_if_not_exists`.
|
def run_actions(actions, skip_system_notes: false)
raise NoActions if actions.empty?
sha = repository.multi_action(current_user,
branch_name: target_branch,
message: commit_message,
actions: actions.map(&:gitaly_action))
::DesignManagement::Version
.create_for_designs(actions, sha, current_user)
.tap { |version| post_process(version, skip_system_notes) }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def push\n ensure_git_and_cucumber_available\n ensure_repository\n\n puts \"Not implemented yet... pull request for push please!\"\n end",
"def create_managed_repository\n OpenProject::Revisions::Git::GitoliteWrapper.update(:add_repository, self)\n rescue => e\n Rails.logger.error(\"Error while adding repository #{repository_identifier}: #{e.message}\")\n raise OpenProject::Scm::Exceptions::RepositoryBuildError.new(\n I18n.t('repositories.gitolite.cannot_add_repository')\n )\n end",
"def commit\n @repo.commit\n end",
"def setup\n info \"Setting up repository for #{name} in #{location}\"\n Repository.new(self).setup\n end",
"def create(project_name, repo_name, description) ; end",
"def repository; end",
"def create(repository, resource)\n raise NotImplementedError\n end",
"def repo; end",
"def repo; end",
"def repo; end",
"def repo; end",
"def handle_repo_push_request\n return unless @repository\n\n branch_name = payload[\"ref\"].sub(%r{\\Arefs/heads/}, '')\n branch = @repository.branches.where(name: branch_name).first\n if branch.present? && branch.convergence? && @repository.run_ci?\n sha = payload[\"after\"]\n branch.kickoff_new_build_unless_currently_busy(sha)\n end\n end",
"def repository\n raise NotImplementedError\n end",
"def create_local_commit author: nil, branch:, file_name:, file_content:, message:, push: false\n on_branch(branch) do\n if (folder_name = File.dirname file_name) != '.'\n Dir.mkdir folder_name\n end\n File.write file_name, file_content\n run \"git add '#{file_name}'\"\n run \"git commit -m '#{message}' #{\"--author='#{author}'\" if author}\"\n run 'git push' if push\n end\nend",
"def perform\n start = Time.zone.now\n invite_status.creating_repo!\n broadcast_message(CREATE_REPO)\n verify_organization_has_private_repos_available!\n\n if group_assignment.organization.feature_enabled?(:template_repos) && group_assignment.use_template_repos?\n github_repository = create_github_repository_from_template!\n else\n github_repository = create_github_repository!\n end\n\n if group_assignment.use_template_repos?\n GitHubClassroom.statsd.increment(\"group_exercise_repo.create.repo.with_templates.success\")\n end\n\n group_assignment_repo = group_assignment.group_assignment_repos.build(\n github_repo_id: github_repository.id,\n github_global_relay_id: github_repository.node_id,\n group: group\n )\n\n add_team_to_github_repository!(github_repository.id)\n\n push_starter_code!(group_assignment_repo.github_repo_id) if group_assignment.use_importer?\n\n begin\n group_assignment_repo.save!\n rescue ActiveRecord::RecordInvalid => error\n Rails.logger.warn(error.message)\n raise Result::Error.new DEFAULT_ERROR_MESSAGE, error.message\n end\n\n GitHubClassroom.statsd.increment(\"group_exercise_repo.create.success\")\n\n if group_assignment.use_importer?\n invite_status.importing_starter_code!\n broadcast_message(\n IMPORT_STARTER_CODE,\n group_assignment_repo&.github_repository&.html_url\n )\n GitHubClassroom.statsd.increment(\"group_exercise_repo.import.started\")\n else\n invite_status.completed!\n broadcast_message(CREATE_COMPLETE)\n end\n\n report_time(start, group_assignment)\n GitHubClassroom.statsd.increment(\"exercise_repo.create.success\")\n\n Result.success(group_assignment_repo)\n rescue Result::Error => error\n delete_github_repository(group_assignment_repo&.github_repo_id)\n GitHubClassroom.statsd.increment(\"exercise_repo.create.fail\")\n Result.failed(error.message)\n end",
"def run\n repo_name = extract_full_repo_name(_get_entity_name)\n\n _set_entity_detail('owner', repo_name.split('/').first)\n _set_entity_detail('repository_name', repo_name.split('/')[1])\n _set_entity_detail('repository_uri', \"https://github.com/#{repo_name}\")\n _set_entity_detail('repository_public', repo_public?(repo_name))\n end",
"def perform_commit\n raise NotImplementedError\n end",
"def init_repo\n @logger.info \"repository url: #{@repository[:url]}\"\n\n if FileTest.exist?(@repository[:path])\n @logger.info \"repository path exists: #{@repository[:path]}\"\n @rgit = Git.open(@repository[:path], :log => @logger)\n @logger.info @rgit.fetch\n else\n @logger.info \"repository path doesn't exist: #{@repository[:path]}\"\n # Create LogDevice to log to websocket message\n @rgit = Git.clone(@repository[:url], @repository[:name],\n :path => @work_dir,\n :log => @logger)\n end\n end",
"def create\n display 'Create a new Unfuddle repository'\n \n repo = Unfuddle::Resources::Repository.create(\n :repository => {\n :title => ask('Name', :required => true),\n :abbreviation => ask('Slug', :required => true),\n :system => 'git',\n :projects => {\n :project => {\n :id => 24468 \n }\n }\n }\n )\n end",
"def github_push(payload)\n\n pushType = payload[\"repository\"][\"full_name\"].split(\"/\")[1].split(\"-\")[0]\n if pushType == \"assignment\"\n TestGraderWorker.perform_async(payload)\n end\n\n org = payload[\"repository\"][\"organization\"]\n repo = payload[\"repository\"][\"name\"]\n repo_array = repo.split(\"-\")\n\n project_name = repo_array[0]\n type = repo_array[1]\n user = repo_array[2]\n\n expected_repo = \"#{org}/#{project_name}-expected\" \n student_repo = \"#{org}/#{project_name}-#{user}\"\n grade_repo = \"#{org}/#{project_name}-grade\"\n #results_repo = \"#{org}/#{project_name}-results-#{type}\"\n\n organization = Organization.new.github_client\n case type\n when \"grader\"\n if not organization.repository?(expected_repo)\n organization.create_repository(\n \"#{project_name}-expected\", organization: org, auto_init: true)\n end\n when \"expected\"\n when \"grade\"\n #when \"results\"\n # if not organization.repository?(grade_repo)\n # organization.create_repository(\n # \"#{project_name}-grade\", organization: org, auto_init: true)\n # end\n else\n if not organization.repository?(grade_repo)\n organization.create_repository(\n \"#{project_name}-grade\", organization: org, auto_init: true)\n end\n end\n\tend",
"def push_to_repo\n return if @remote_type == :none\n\n if @remote_type == :bitbucket\n puts 'Cannot automatically create BitBucket repository.'\n puts 'Please, open it manually at https://bitbucket.org/repo/create'\n `#{ENV['BROWSER']} https://bitbucket.org/repo/create`\n return\n end\n\n return unless %i[github].include?(@remote_type)\n\n gh_options = [\n @name,\n ]\n gh_options << '--team algolia' if @is_algolia\n\n if @is_private\n gh_options << '--private'\n else\n gh_options << '--public'\n end\n\n command = \"gh repo create #{gh_options.join(' ')}\"\n\n if command_success?(command)\n puts '✔ Creating GitHub repository'\n else\n puts '✘ Failed to create GitHub repository'\n exit 1\n end\n\n if command_success?('git push origin main')\n puts '✔ Pushed to repository'\n else\n puts '✘ Failed to push to repository'\n exit 1\n end\n end",
"def create_repository\n case scm\n when GIT_SCM\n self.class.delay.create_git_repository(full_path)\n when SVN_SCM\n self.class.delay.create_svn_repository(full_path)\n else\n raise UnsupportedSCMError\n end\n end",
"def test_help_message\n Repository.create()\n #Repository.help()\n end",
"def create_branch\n ErrorEmittingExecutor.execute(\"git checkout -B #{BRANCH_NAME}\")\n\n # Ensure local branch matches any existing upstream branch; will reset to HEAD by default\n ErrorEmittingExecutor.execute('git reset --hard', exit_on_error: true)\nend",
"def do_checkout path, shell\n raise RepoError,\n \"The 'do_checkout' method must be implemented by child classes\"\n end",
"def check!\n # does not inherit any dependencies (super.check will inherit)\n Dependencies.new(configuration) do |d|\n d.remote.directory(configuration[:deploy_to]).or(\"`#{configuration[:deploy_to]}' does not exist.\")\n d.remote.writable(configuration[:deploy_to], :via => :sudo).or(\"You do not have permissions to write to `#{configuration[:deploy_to]}'.\")\n d.remote.command(\"svn\")\n d.remote.match(\"cd #{repository_dir}; svn info|grep URL\", configuration[:repository])\n end\n end",
"def make_copy_of_repository\n false # true #false\nend",
"def execute\n get_repo(repo_name).repo.fetch\n end",
"def git_add_commit_push(host, branch, message, git_repo_path)\n git_add_everything(host, git_repo_path)\n git_commit_push(host, branch, message, git_repo_path)\nend",
"def initialize_repo\n puts \"starting to initialize repo: '#{self.ident}' finished successfully.\"\n self.update_repo\n end",
"def create\n @repository = current_user.repositories.new(params[:repository])\n\n respond_to do |format|\n if @repository.save\n format.html { redirect_to @repository, notice: 'Repository was successfully created.' }\n format.json { render json: @repository, status: :created, location: @repository }\n else\n format.html { render action: \"new\" }\n format.json { render json: @repository.errors, status: :unprocessable_entity }\n end\n end\n end",
"def execute\n if (!self.pull_request_id)\n current = GitHub::PullRequest.current\n self.pull_request_id = current.number if current\n end\n self.pull_request_id ||= cli.prompt(\"Pull Request ID: \")\n GitHub.connect do\n unless deployable? || @force\n CLI.say 'Pull request status checks have not passed. Cannot be marked deployable.'\n exit!\n end\n\n merge_result = merge\n add_deployable_label if config.deployable_label && merge_result\n end\n end",
"def setup_repo\n status(2) {\n setup_path\n if @type == 'full'\n Repository::Git.clone(@repo, @type)\n end\n Repository::Git.pull(@repo, @type)\n }\n end",
"def create\n\t\n\t##first check that user doesn't already have a pull request open for this repo line\n\t\t@idea = Idea.find(params[:idea_id])\n\t\t@toRepo = Repository.where(user_id: @idea.user_id).where(idea_id: params[:idea_id]).first\n\t\t@repo = Repository.where(user_id: current_user.id).where(idea_id: params[:idea_id]).first\n\t\t\n\n\t\t@pull_request = PullRequest.where(to_repo_id: @toRepo.id).where(repository_id: @repo.id).where(status: \"SUBMITTED\").first\n\t\tif( !@pull_request && current_user != @idea.user)\n\t @pullRequest = PullRequest.new()\n\n\t\t\t@pullRequest.repository_id = @repo.id\n\t\t\t@pullRequest.to_repo_id = @toRepo.id\n\t\t\t\n\t\t\t@pullRequest.message = params[:name]\n\t\t\t@pullRequest.save\n\t\t\t\n\t\t\tDir.chdir(@repo.path)\n\t\t\t@git = Git.init()\n\t\t\t@git.pull(@toRepo.path, \"master\") # fetch and a merge\n\t\tend\n\t\t\n\t\tif @pull_request\n\t\t\trespond_to do |format|\n\t\t\t\tformat.html # new.html.erb\n\t\t\t\tformat.json { render json: @pullRequest }\n\t\t\tend\n\t\telse\n\t\t\trender json: {error: \"Looks like something went wrong with creating a repo. Perhaps you already have one.\"}\n\t\tend\n end",
"def create_pr\n ErrorEmittingExecutor.execute(\"hub pull-request -f -m '#{COMMIT_DESCRIPTION}'\")\nend",
"def create\n # Create an empty repo in memory\n repo = Repo.new\n \n # Var. 1) Github Repo posted to \"/addrepo?url=\"\n if params[:url]\n url = params[:url]\n # Strip url of leading or trailing whitespace\n # Gsub part of url that is not nescessary\n ident = url.gsub(\"https://github.com/\", \"\").strip\n \n # Split repo ident\n repo.owner = ident.split(\"/\")[0]\n repo.name = ident.split(\"/\")[1]\n repo.ident = ident\n end\n \n # Var. 2) Github Repo is being added by posting to \"/repo\" through form\n if params[:repo]\n # Remove leading and trialing whitespace\n repo.owner = params[:repo][:owner].strip\n repo.name = params[:repo][:name].strip\n repo.ident = repo.owner + \"/\" + repo.name\n end\n \n respond_to do |format|\n if Repo.find_by_ident(repo.ident).nil?\n # Repo is not yet listed\n if repo.save # Check if validations pass\n # Validations passed\n if Repo.init_repo(repo.id)\n # Repo could be found on Github\n format.html { redirect_to repo, notice: \"Success! You added '#{repo.owner}/#{repo.name}' successfully. Thanks for helping to improve this site! You might tag this repo!!!\" }\n else\n # Repo could not be found on Github and was deleted\n format.html { redirect_to root_url, notice: \"Sorry. I could not find '#{repo.owner}/#{repo.name} on github. Spelled everything correctly?\"}\n end\n # Repo validation fails while performing initialization\n format.html { redirect_to root_url, notice: \"Repo validation failed. Please mail our team with details how you managed to get this error.\"}\n else\n # Validation failed\n format.html { redirect_to root_url, notice: \"Sorry, I could not recognize a repo owner and name in there. My bad.\" }\n end\n \n else\n # Repo already listed \n repo = Repo.find_by_ident(repo.ident) \n format.html { redirect_to repo, notice: \"Double success! '#{repo.owner}/#{repo.name}' is listed already. Checkout the tags below and refine them to do some good for your fellow human programmers. Thanks!\"}\n end\n end\n end",
"def git\n\tend",
"def create_repo\n # update gitolite-admin/conf/gitolite.conf file ...\n # but only if there is NOT already an entry for this repo \n # ... to avoid duplicating the entry\n conf_entry = File.read(@@gitolite_conf_file_path).slice(@gitolite_conf_entry)\n if (conf_entry == nil)\n File.open(@@gitolite_conf_file_path, \"a\") { |f| f.write @gitolite_conf_entry}\n # push updates to gitolite-admin repo to create new project repo\n git_push @@gitolite_admin_path, \"Added repo #{@project_label} with users: #{@users}\"\n return true\n else\n LOGGER.error \"Existing gitolite config file entry found for project #{@project_label}, skipping repo creation\"\n return false\n end\n \n end",
"def create_repo\n Rugged::Repository.init_at(repo_path, :bare).tap do |repo|\n repo.remotes.create('origin', \"git@github.com:#{project.gh_path}\")\n repo.remotes.add_fetch_refspec('origin', GITHUB_PULLS_REFSPEC)\n end\n end",
"def git_commit_and_push(cookbook_path, github_url)\n if File.exists?(File.join(cookbook_path, \".git\"))\n shell_out(\"git remote rm origin\", :cwd => cookbook_path)\n else\n shell_out!(\"git init\", :cwd => cookbook_path)\n end\n shell_out!(\"echo - $(date): Uploaded with knife github plugin. >> CHANGELOG.md \", :cwd => cookbook_path)\n shell_out!(\"git add .\", :cwd => cookbook_path)\n shell_out!(\"git commit -m 'creating initial cookbook structure from the knife-github plugin' \", :cwd => cookbook_path)\n shell_out!(\"git remote add origin #{github_url} \", :cwd => cookbook_path)\n shell_out!(\"git push -u origin master\", :cwd => cookbook_path)\n end",
"def initialize(user = nil, api_token = nil, repo_name = \"cookie_monster\") \n if user.nil?\n puts \"No user provided, getting from git config\"\n user = `git config --get github.user`.chomp\n end\n\n if api_token.nil?\n puts \"No API token provided, getting from git config\"\n api_token = `git config --get github.token`.chomp\n end\n\n\n @user = user.chomp # chomp in case user passes in bad data\n @api_token = api_token.chomp # chomp in case user passes in bad data\n @repo_name = repo_name\n\n # Authenticated client\n #@client = Octopussy::Client.new({:login => @user, :token => @api_token})\n\n # Location of local git repository. Necessary for pushing to Github.\n # Put it in .cloud_path so it doesn't conflict with anything\n @git_dir_path = File.expand_path(\"~/.cloud_path/\" + @repo_name)\n\n create_repo\n create_git_dir\n \n # For whatever reason, Repository.find raises Octopi::NotFound when\n # we've just created the repository in this run of the script.\n # Possibly a caching error.\n begin\n repo = Repository.find(:user => @user, :repo => @repo_name)\n rescue Octopi::NotFound\n puts \"Repository not found. Probably just created repository, please\"\n puts \"run this script again.\"\n exit 0\n end\n end",
"def check\n super\n info \"Working in branch '#{Hg.current_branch}'\"\n uncommitted = Hg.uncommitted_files\n fail \"Uncommitted files violate the First Principle Of Release!\\n#{uncommitted.join(\"\\n\")}\" unless uncommitted.empty?\n fail \"You are releasing from a local branch that does not track a remote!\" if Hg.remote.empty?\n end",
"def perform\n # labels option cannot be null due to https://github.com/octokit/octokit.rb/pull/538\n result = GitHub.create_issue(repo_name, title, body, labels: [])\n # capture the information\n self.number = result.number\n self.data = result\n rescue => e\n raise CannotCreate, e.message\n end",
"def run\n super\n\n repo_uri = _get_entity_name\n custom_keywords = _get_option('custom_keywords').delete(' ').split(',')\n custom_config = create_gitleaks_custom_config(custom_keywords) unless custom_keywords.empty?\n\n if _get_option('use_authentication')\n case _get_entity_type_string\n when 'GithubRepository'\n access_token = initialize_gh_client&.access_token\n when 'GitlabProject'\n access_token = retrieve_gitlab_token(parse_gitlab_uri(repo_uri).host)\n end\n end\n\n\n issues = run_gitleaks(repo_uri, access_token, custom_config)\n return if issues.nil?\n\n # create issues\n _log_good \"Found #{issues.size} suspicious commits.\"\n issues.each { |i| create_suspicious_commit_issue(i, i['commit_uri']) }\n end",
"def init(path = Dir.pwd, options = {})\n exit_status = FalkorLib::Git.init(path, options)\n unless command?('git-flow')\n # Check (mainly for Linux) if the command is not available under `/usr/lib/git-core`\n git_lib = '/usr/lib/git-core/'\n error \"you shall install git-flow: see https://github.com/nvie/gitflow/wiki/Installation\" unless File.exist?(File.join(git_lib, 'git-flow'))\n end\n remotes = FalkorLib::Git.remotes(path)\n git_root_dir = FalkorLib::Git.rootdir( path )\n Dir.chdir( git_root_dir ) do\n unless FalkorLib::Git.commits?( git_root_dir)\n warn \"Not yet any commit detected in this repository.\"\n readme = 'README.md'\n unless File.exist?( readme )\n answer = ask(cyan(\"=> initialize a commit with an [empty] #{readme} file (Y|n)?\"), 'Yes')\n exit 0 if answer =~ /n.*/i\n FileUtils.touch(readme)\n end\n FalkorLib::Git.add(readme, \"Initiate the repository with a '#{readme}' file\")\n end\n branches = FalkorLib::Git.list_branch(path)\n gitflow_branches = FalkorLib.config.gitflow[:branches].clone\n # correct eventually the considered branch from the options\n gitflow_branches.each do |t, _b|\n gitflow_branches[t] = options[t.to_sym] if options[t.to_sym]\n confs = FalkorLib::Git.config('gitflow*', path, :hash => true)\n gitflow_branches[t] = confs[\"gitflow.branch.#{t}\"] unless confs.empty?\n end\n if options[:interactive]\n gitflow_branches[:master] = ask(\"=> branch name for production releases\", gitflow_branches[:master])\n gitflow_branches[:develop] = ask(\"=> branch name for development commits\", gitflow_branches[:develop])\n end\n ap gitflow_branches if options[:debug]\n if remotes.include?( 'origin' )\n info \"=> configure remote (tracked) branches\"\n exit_status = FalkorLib::Git.fetch(path)\n gitflow_branches.each do |_type, branch|\n if branches.include? \"remotes/origin/#{branch}\"\n exit_status = FalkorLib::Git.grab(branch, path)\n else\n unless branches.include? branch\n info \"=> creating the branch '#{branch}'\"\n FalkorLib::Git.create_branch( branch, path )\n end\n exit_status = FalkorLib::Git.publish(branch, path )\n end\n end\n else\n gitflow_branches.each do |_type, branch|\n unless branches.include? branch\n info \" => creating the branch '#{branch}'\"\n exit_status = FalkorLib::Git.create_branch( branch, path )\n end\n end\n end\n #info \"initialize git flow configs\"\n gitflow_branches.each do |t, branch|\n exit_status = execute \"git config gitflow.branch.#{t} #{branch}\"\n end\n FalkorLib.config.gitflow[:prefix].each do |t, prefix|\n exit_status = execute \"git config gitflow.prefix.#{t} #{prefix}\"\n end\n devel_branch = gitflow_branches[:develop]\n #info \"checkout to the main development branch '#{devel_branch}'\"\n exit_status = run %(\n git checkout #{devel_branch}\n )\n # git config branch.$(git rev-parse --abbrev-ref HEAD).mergeoptions --no-edit for the develop branch\n exit_status = execute \"git config branch.#{devel_branch}.mergeoptions --no-edit\"\n if branches.include?('master') && !gitflow_branches.values.include?( 'master' )\n warn \"Your git-flow confuguration does not hold the 'master' branch any more\"\n warn \"You probably want to get rid of it asap by running 'git branch -d master'\"\n end\n if devel_branch != 'master' &&\n remotes.include?( 'origin' ) &&\n branches.include?( 'remotes/origin/master')\n warn \"You might want to change the remote default branch to point to '#{devel_branch}\"\n puts \"=> On github: Settings > Default Branch > #{devel_branch}\"\n puts \"=> On the remote bare Git repository: 'git symbolic-ref HEAD refs/head/#{devel_branch}'\"\n end\n end\n exit_status\n end",
"def new?\n not defined?@repository\n end",
"def process_repositories(user) \n can :read, ExampleRepository do |repository|\n can? :read, repository.course_offering\n end\n\n can :manage, ExampleRepository do |repository|\n can? :manage, repository.course_offering.role_for_user(user).can_manage_assignments?\n end\n\n\n # Users can, of course, always read assignment repositories that\n # contain their own work. So can people enrolled in the same course\n # offering who have permission to view other students' submissions.\n can [:read, :update], AssignmentRepository do |repository|\n if repository.user == user\n true\n else\n co = repository.assignment_offering.course_offering\n role = co.role_for_user(user)\n role.can_view_other_submissions?\n end\n end\n\n\n # Users can manage the assignment reference repositories for assignments\n # that they can manage.\n # TODO probably make it so that only the creator can manage but other\n # instructors can edit\n can :read, AssignmentReferenceRepository do |repository|\n repository.assignment.assignment_offerings.any? do |ao|\n role = ao.course_offering.role_for_user(user)\n role.can_view_other_submissions?\n end\n end\n\n can :manage, AssignmentReferenceRepository do |repository|\n can? :manage, repository.assignment\n end\n\n\n can [:read, :update], ScratchpadRepository do |repository|\n user == repository.user\n end\n end",
"def perform\n git.if_clean do\n check_out_branch\n merge_pull_request\n comment_about_merge\n end\n rescue => e\n case e\n when GitHub::PullRequest::NotFound\n cli.say \"Unable to find pull request #{pull_request_id}. Please retry with a valid ID.\"\n when Git::MergeFailed\n cli.say \"Merge failed. Please identify the source of this merge conflict resolve this conflict in your pull request's branch. NOTE: Merge conflicts resolved in the #{branch_type} branch are NOT used when deploying.\"\n when Git::CheckoutFailed\n cli.say \"Checkout of #{branch_to_merge_into} failed. Please contact Infrastructure to determine the cause.\"\n when GitHub::PullRequest::CommentFailed\n cli.say \"Unable to write comment. Please navigate to #{pull_request.url} and add the comment, '#{comment_body}'\"\n else\n cli.say \"An unknown error occurred: #{e.inspect}\"\n end\n raise\n end",
"def ensure_cloned(repository_url)\n repository_url && :not_implemented\n end",
"def git_check\n # May throw InvalidRepositoryException\n # - because of invalid path\n # - or broken git repository\n @repo = GitLib::Repo.new(path)\n end",
"def commit_required?; end",
"def commit\n read_repo\n if @branches.count < 1\n render :template => 'repositories/commit'\n return\n end\n\n params[:action] = \"commit\"\n\n blank_hash = \"4b825dc642cb6eb9a060e54bf8d69288fbee4904\"\n @commit = @repository.get_commit(@branch)\n @parent = @commit.parent\n @parent = @repository.get_commit(blank_hash) if @parent == nil\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @repository }\n end\n end",
"def repository_created(identifier, vendor, url)\n project = Project.find_by_identifier(identifier)\n # Do not create the repository if the project has already one\n return 0 unless project && project.repository.nil?\n logger.debug \"Repository for #{project.name} was created\"\n repository = Repository.factory(vendor, :project => project, :url => url)\n repository.save\n repository.id || 0\n end",
"def execute\n imported =\n # It's possible a repository has already been imported when running\n # this code, e.g. because we had to retry this job after\n # `import_wiki?` raised a rate limit error. In this case we'll skip\n # re-importing the main repository.\n if project.empty_repo?\n import_repository\n else\n true\n end\n\n update_clone_time if imported\n\n imported = import_wiki_repository if import_wiki? && imported\n\n imported\n end",
"def test_no_gitgo_no_remote_gitgo\n assert !sh(b, 'git branch -a').include?('gitgo')\n \n sh(b, 'git branch gitgo')\n sh(b, 'git checkout gitgo')\n method_root.prepare(b, \"shasum\") {|io| io << \"content\" }\n sh(b, 'git add shasum')\n sh(b, 'git commit -m \"added document\"')\n \n sh(b, 'git checkout master')\n sh(b, 'git push origin gitgo')\n \n assert sh(b, 'git branch').include?('gitgo') \n assert sh(a, 'git branch').include?('gitgo')\n \n sh(a, 'git checkout gitgo')\n assert_equal \"content\", File.read(method_root.path(a, \"shasum\"))\n end",
"def create\n @repository = @project.repositories.new(params[:repository])\n @repository.path = '/home/git/repositories'\n @repository.repo_name = @repository.name.downcase.gsub(\" \",\"_\")\n respond_to do |format|\n if @repository.save\n flash[:notice] = 'Repository was successfully created.'\n format.html { redirect_to([@project,@repository]) }\n else\n format.html { render :action => \"new\" }\n end\n end\n end",
"def commit\n system(\"cd #{repo_path};git commit -m 'to the cloud'\")\n end",
"def repository!\n Repository.find_or_create_by!(url: repository_url) do |repo|\n repo.organization_id = org_id\n repo.name = repository_name\n end\n end",
"def create\n final_params = repository_params\n languages = Language.where(name: repository_params[:languages])\n final_params[:languages] = languages\n \n @repository = Repository.new(final_params)\n @uri = URI(@repository.repo_location)\n @repository.secret_path = SecureRandom.hex.to_s + @uri.path.split(\"/\").last.to_s\n @secret_path_to_clone_to = @repository.secret_path\n \n respond_to do |format|\n if @repository.save\n Git.clone(@uri, @secret_path_to_clone_to, :path => Rails.root.join(\"storage\", \"repositories\"))\n format.html { redirect_to @repository, notice: 'Repository was successfully created.' }\n format.json { render :show, status: :created, location: @repository }\n else\n format.html { render :new }\n format.json { render json: @repository.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_issues(repositories, sender_username)\n repositories.each do |repo|\n begin\n @client.create_issue(repo, \"#{sender_username} added new app!\", \"Added GitHub App\")\n rescue\n puts \"Issues is disabled for this repository\"\n end\n end\nend",
"def create_project(project)\n \n update_project(project)\n \n # TODO: Need to handle this exception...\n if (File.directory? project.svn_dir) then\n raise StandardError, \"A project called #{project.display_name} already exists in the #{project.client.display_name} repository. Please delete it or choose an alternate project name and run this script again.\"\n end\n \n # create a new subversion repository\n say(\"Creating a new subversion repository...\")\n `svnadmin create #{project.svn_dir}`\n \n # import into svn\n say(\"Importing temporary project into the new subversion repository...\")\n `svn import #{project.template}/svn file:///#{project.svn_dir} --message \"initial import\"`\n \n # this should fix the 'can't open activity db error'\n `sudo chmod 770 #{project.svn_dir}`\n activites_file = File.join(project.svn_dir,\"/dav/activities\")\n if File.exists?(activites_file)\n `sudo chmod 755 #{activites_file}`\n `sudo chown www-data:www-data #{activites_file}`\n end\n \n # install default post commit hook\n hook_file = File.join(project.svn_dir,\"hooks\",\"post-commit\")\n Template.new(File.join(Config.subtrac_path, \"svn\", \"post-commit.erb\")).write(hook_file)\n `sudo chmod +x #{hook_file}`\n\n end",
"def push\n unless system(\"cd #{repo_path};git push origin #{branch}\")\n raise GitCloud::GitException.new(\"Push\")\n end\n end",
"def git_commit_push(host, branch, message, git_repo_path)\n git_on(host, \"commit -m \\\"#{message}\\\"\", git_repo_path)\n git_push(host, branch, git_repo_path)\nend",
"def git_push_origin\n ErrorEmittingExecutor.execute(\"git push origin -u #{BRANCH_NAME}\")\nend",
"def can_access_git?\n true\n end",
"def notify_prepare_commit\n raise NotImplementedError\n end",
"def perform(args = {})\n if repo_mirror_exists?\n update_mirror\n else\n clone_repo\n end\n end",
"def setup\n @commit_data = {\n :id => \"a-real-deal-id-#{get_iterator}\",\n :commit_message => 'Creating Git Resource',\n :author_name => 'Collin',\n :author_email => 'collin@quickleft.com',\n :attributes => \"{ \\\"title\\\" : \\\"test #{get_iterator}\\\" }\",\n :rendered => \"<h1>Test #{get_iterator}</h1>\"\n }\n @commit_sha = Regulate::Git::Interface.save(@commit_data)\n end",
"def perform\n @project.repo &:fetch\n end",
"def send_to_github\n ExceptionHub.current_octokit.create_issue(\"#{ExceptionHub.repo_owner}/#{ExceptionHub.repo_name}\", self.title, self.description, :open_timeout => 5)\n end",
"def checkout\n raise NotImplementedError\n end",
"def commit(msg = nil)\n require_dep! 'awesome_spawn'\n require_cmd! git_cmd\n\n in_repo { AwesomeSpawn.run \"#{git_cmd} add #{pkg_files.join(' ')}\" }\n super(msg.nil? ? \"updated to #{version}\" : msg)\n self\n end",
"def repo_init\n git :init\n end",
"def add_git_facts\n # see if we're in a git repo. first, we need a directory that exists\n dir = @path.expand_path.ascend.find {|p| p.directory? }\n \n Dir.chdir(dir) do\n root_result = Cmds.new \"git rev-parse --show-toplevel\"\n \n unless root_result.ok?\n @result.in_git_repo = false\n @result.is_git_root = false\n return\n end\n \n @result.in_git_repo = true\n \n git = @result.git = Result.new\n git.root = Pathname.new root_result.out.chomp\n @result.is_git_root = @path == git.root\n \n user = git.user = Result.new\n \n ['name', 'email'].each {|key|\n user[key] = begin\n Cmds.chomp! \"git config user.#{ key }\"\n rescue\n end\n }\n \n git.origin = begin\n Cmds.chomp! \"git remote get-url origin\"\n rescue\n end\n \n match = GITHUB_SSH_URL_RE.match(git.origin) ||\n GITHUB_HTTPS_URL_RE.match(git.origin)\n \n git.is_github = !! match\n \n return unless match\n \n git.owner = match['owner']\n git.name = match['name']\n git.full_name = \"#{ git.owner }/#{ git.name }\"\n \n if true == @args['github_api']\n github = git.github = Result.new\n github.api_url = \"https://api.github.com/repos/#{ git.owner }/#{ git.name }\"\n \n response = Net::HTTP.get_response URI(github.api_url)\n \n if response.is_a? Net::HTTPSuccess\n # parse response body and add everything to github result\n parsed = JSON.parse response.body\n parsed.each {|k, v| github[k] = v}\n else\n # assume it's private if we failed to find it\n github.private = true\n end\n \n end\n end\n end",
"def run(*arguments)\n no_complete = @options.fetch(:no_complete, false)\n no_delete = @options.fetch(:no_delete, false)\n no_merge = @options.fetch(:no_merge, false)\n pull_request = @options.fetch(:pull_request, false) || PivotalIntegration::Util::Git.finish_mode == :pull_request\n\n if pull_request\n root_branch = PivotalIntegration::Util::Git.get_config('root-branch', :branch)\n root_branch = nil if root_branch == 'master'\n\n PivotalIntegration::Util::Git.push PivotalIntegration::Util::Git.branch_name\n PivotalIntegration::Util::Git.create_pull_request(@configuration.story, root_branch)\n PivotalIntegration::Util::Story.mark(@configuration.story, :finished)\n return\n end\n\n unless no_merge\n PivotalIntegration::Util::Git.trivial_merge?\n PivotalIntegration::Util::Git.merge(@configuration.story, no_complete, no_delete)\n end\n\n PivotalIntegration::Util::Git.push PivotalIntegration::Util::Git.branch_name\n end",
"def perform(repo)\n repo.update_catalog_metadata\n repo.add_preservation_and_mets_xml\n repo.delete_clone\n repo.create_iiif_manifest if Settings.bulk_import.create_iiif_manifest\n repo.publish if repo.published\n end",
"def commit!() raise NotImplementedError end",
"def create!(**options)\n options[:validate] = true if options[:validate].nil?\n return false if options[:validate] && !git_condition_valid?\n\n git.push(github_token_url, topic_branch)\n pr_number = github.create_pull_request(**generate_create_pr_options(**options))\n github.add_labels(pr_number, *options[:labels]) unless options[:labels].nil?\n unless options[:project_column_name].nil?\n github.add_to_project(pr_number, **generate_add_to_project_options(**options))\n end\n true\n end",
"def create\n @commit = Commit.new\n\n #walker = Rugged::Walker.new(@repo)\n #\n #walker.sorting(Rugged::SORT_TOPO | Rugged::SORT_REVERSE) # optional\n #\n #walker.push('HEAD')\n #walker.each { |c| \n # @commit = Commit.new(sha: c.oid, description:c.message,\n # author: c.author[:name], commit_date: c.author[:time])\n # @commit.save\n #}\n #walker.reset\n\n respond_to do |format|\n format.html { redirect_to @commit, notice: 'Commit was successfully created.' }\n format.json { render :show, status: :created, location: @commit }\n end\n end",
"def repo=(_arg0); end",
"def repo=(_arg0); end",
"def repo=(_arg0); end",
"def repo=(_arg0); end",
"def git_init\n require 'git'\n begin\n g = Git.open(@destination_root)\n logger.exists '.git'\n rescue ArgumentError\n g = Git.init(@destination_root)\n g.add(@destination_root)\n g.commit(\"beginning of #{@name} project\")\n logger.create '.git'\n end\n end",
"def git_init\n require 'git'\n begin\n g = Git.open(@destination_root)\n logger.exists '.git'\n rescue ArgumentError\n g = Git.init(@destination_root)\n g.add(@destination_root)\n g.commit(\"beginning of #{@name} project\")\n logger.create '.git'\n end\n end",
"def initialize_client_clone_and_push(type, module_name, branch, repo_url, local_repo_dir, version=nil)\n # moved this part from 'check_local_dir_exists_with_content' to this method since this only deletes .git folder\n # which can cause us problems if import fails\n if File.directory?(\"#{local_repo_dir}/.git\")\n response = unlink_local_clone?(type,module_name,version)\n unless response.ok?\n # in case delete went wrong, we raise usage error\n raise DtkError.new(\"Directory (#{local_repo_dir} is set as a git repo; to continue it must be a non git repo; this can be handled by shell command 'rm -rf #{local_repo_dir}/.git'\")\n end\n # we return to normal flow, since .git dir is removed\n end\n\n Response.wrap_helper_actions() do\n ret = Hash.new\n repo_dir = local_repo_dir(type,module_name)\n\n repo = create(repo_dir,branch,:init => true, :no_initial_commit => true)\n repo.add_remote(remote(),repo_url)\n remote_branch = local_branch = branch\n\n repo.pull_remote_to_local(remote_branch,local_branch,remote())\n repo.stage_changes()\n repo.commit(\"Adding files during initialization\")\n repo.push_with_remote(remote(), remote_branch)\n\n commit_sha = repo.head_commit_sha()\n {\"repo_obj\" => repo,\"commit_sha\" => commit_sha}\n end\n end",
"def check\n super\n uncommitted = Git.uncommitted_files\n fail \"Uncommitted files violate the First Principle Of Release!\\n#{uncommitted.join(\"\\n\")}\" unless uncommitted.empty?\n # fail \"You are releasing from a local branch that does not track a remote!\" unless Git.remote\n end",
"def commit_blob_change_to_repo_for_user(repo, user, branch, old_oid, files, message)\n return false unless repo.ready_for_writes?\n\n ref = repo.heads.find_or_build(branch)\n\n # use the branch's target_oid, or fall back on the supplied old_oid.\n # both can be nil for an absolutely new file in a new repo.\n parent_oid = ref.target_oid || old_oid\n\n author_email = params[:author_email]\n commit = repo.create_commit(parent_oid,\n message: message,\n author: current_comment.user,\n files: files,\n author_email: author_email,\n committer: user\n )\n\n return false unless commit\n\n if author_email\n if user.primary_user_email.email != author_email\n GitHub.dogstats.increment(\"commit.custom_commit_email\", tags: [\"email:custom\"])\n else\n GitHub.dogstats.increment(\"commit.custom_commit_email\", tags: [\"email:primary\"])\n end\n end\n\n before_oid = ref.target_oid\n ref.update(commit, user, reflog_data: request_reflog_data(\"blob edit\"))\n PullRequest.after_repository_push(\n repo,\n ref.qualified_name,\n user,\n before: before_oid,\n after: commit.oid\n )\n ref.enqueue_push_job(before_oid, commit.oid, user)\n ref.enqueue_token_scan_job(before_oid, commit.oid)\n ref.name\n rescue Git::Ref::HookFailed => e\n @hook_out = e.message\n false\n rescue Git::Ref::ProtectedBranchUpdateError => e\n @hook_out = \"#{ref.name} branch is protected\"\n false\n rescue Git::Ref::ComparisonMismatch, GitRPC::Failure\n false\n rescue Git::Ref::InvalidName, Git::Ref::UpdateFailed\n false\n rescue GitHub::DGit::UnroutedError, GitHub::DGit::InsufficientQuorumError, GitHub::DGit::ThreepcFailedToLock\n false\n end",
"def create_github_repository!\n repository_name = generate_github_repository_name\n organization.github_organization.create_repository(\n repository_name,\n private: group_assignment.private?,\n description: \"#{repository_name} created by GitHub Classroom\"\n )\n rescue GitHub::Error => error\n raise Result::Error.new REPOSITORY_CREATION_FAILED, error.message\n end",
"def build_actions(actions, guardian, args)\n raise NotImplementedError\n end",
"def check\n super\n uncommitted = Git.uncommitted_files\n fail \"Uncommitted files violate the First Principle Of Release!\\n#{uncommitted.join(\"\\n\")}\" unless uncommitted.empty?\n fail \"You are releasing from a local branch that does not track a remote!\" unless Git.remote\n end",
"def execute\n if (!self.pull_request_id)\n current = GitHub::PullRequest.current\n self.pull_request_id = current.number if current\n end\n self.pull_request_id ||= cli.prompt(\"Pull Request ID: \")\n GitHub.connect do\n if config.deployable_label\n with_labelling do\n merge\n end\n else\n merge\n end\n end\n end",
"def configure_repository\n UnixUser.match_ownership(@user.homedir, @path)\n\n # application developer cannot change git hooks\n hooks = File.join(@path, 'hooks')\n FileUtils.chown_R(0, 0, hooks)\n\n render_file = lambda { |f, m, t|\n File.open(f, 'w', m) { |f| f.write(ERB.new(t).result(binding)) }\n }\n\n render_file.call(File.join(@path, 'description'), 0644, GIT_DESCRIPTION)\n render_file.call(File.join(@user.homedir, '.gitconfig'), 0644, GIT_CONFIG)\n\n render_file.call(File.join(hooks, 'pre-receive'), 0755, PRE_RECEIVE)\n render_file.call(File.join(hooks, 'post-receive'), 0755, POST_RECEIVE)\n end",
"def create\n url = repo_params[:html_url]\n params = Repo.get_repo(url, current_user)\n if params == nil\n redirect_to :back, notice: 'Error with API access token.'\n return\n end\n if params == -1\n redirect_to :back, alert: 'Repo already exists' and return\n end\n\n params[:user_id] = current_user.id\n @repo = Repo.new(params)\n\n respond_to do |format|\n if @repo.save\n format.html { redirect_to @repo, notice: 'Repo was successfully created.' }\n format.json { render :show, status: :created, location: @repo }\n else\n format.html { render :new }\n format.json { render json: @repo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def init_repo\n return if check_deploy_dir\n FileUtils.mkdir_p @deploy_dir\n FileUtils.cd @deploy_dir do\n if Dir[@deploy_dir+'/*'].empty?\n\n # initialize the repository and add the remote.\n #\n `git init`\n `git remote add #{@remote} #{@repo}`\n\n # Attempt to pull from the remote.\n #\n if git_pull\n `git branch -m #{@branch}`\n\n # If no branch exists on remote, create one locally.\n else\n `echo \"initialize deploy repo\" > _`\n `git add .`\n `git commit -m \\\"initial commit\\\"`\n `git branch -m #{@branch}`\n `git rm _`\n `git add -u`\n `git commit -m 'cleanup'`\n end\n end\n end\n end",
"def update\n Repository.new(self).add_git_remote\n Hook.new(self).setup\n end",
"def git_clone_main\n raise \"oops, not done\"\nend",
"def set_build_status!(repo: nil, sha: nil, state: nil, target_url: nil, description: nil, context: nil)\n state = state.to_s\n\n # Available states https://developer.github.com/v3/repos/statuses/\n available_states = [\"error\", \"failure\", \"pending\", \"success\"]\n raise \"Invalid state '#{state}'\" unless available_states.include?(state)\n\n # We auto receive the SLUG, so that the user of this class can pass a full URL also\n repo = repo.split(\"/\")[-2..-1].join(\"/\")\n\n # TODO: this will use the user's session, so their face probably appears there\n # As Josh already predicted, we're gonna need a fastlane.ci account also\n # that we use for all non-user actions.\n # This includes scheduled things, commit status reporting and probably more in the future\n\n if description.nil?\n description = \"All green\" if state == \"success\"\n description = \"Still running\" if state == \"pending\"\n\n # TODO: what's the difference?\n description = \"Something went wrong\" if state == \"failure\"\n description = \"Something went wrong\" if state == \"error\"\n end\n\n # TODO: Enable once the GitHub token is fixed\n #\n # Full docs for `create_status` over here\n # https://octokit.github.io/octokit.rb/Octokit/Client/Statuses.html\n\n task = TaskQueue::Task.new(work_block: proc {\n logger.debug(\"Setting status #{state} on #{target_url}\")\n client.create_status(repo, sha, state, {\n target_url: target_url,\n description: description,\n context: context || \"fastlane.ci\"\n })\n })\n\n @task_queue.add_task_async(task: task)\n rescue StandardError => ex\n # TODO: how do we handle GitHub errors\n # In this case `create_status` will cause an exception\n # if the user doesn't have write permission for the repo\n raise ex\n end",
"def push(repository)\n # add all files to the repository\n repository.add(all: true)\n\n # commit, but be aware: current version could be identical to previous version resulting in an error\n begin\n repository.commit('Application deployment via Nucleus')\n rescue Git::GitExecuteError => e\n # usually indicates that no files could be committed, repository is up to date\n log.debug(\"Git commit failed: #{e}\")\n end\n\n # repack to enhance compression\n repository.repack\n\n # force push, so that the push is executed even when all files remain unchanged\n repository.push('origin', @repo_branch, force: true)\n end",
"def check_if_push_allowed\n if @source.is_a?(CDNSource)\n raise Informative, 'Cannot push to a CDN source, as it is read-only.'\n end\n\n remotes, = Executable.capture_command('git', %w(remote --verbose), :capture => :merge, :chdir => repo_dir)\n master_repo_urls = [\n 'git@github.com:CocoaPods/Specs.git',\n 'https://github.com/CocoaPods/Specs.git',\n ]\n is_master_repo = master_repo_urls.any? do |url|\n remotes.include?(url)\n end\n\n if is_master_repo\n raise Informative, 'To push to the CocoaPods master repo use ' \\\n \"the `pod trunk push` command.\\n\\nIf you are using a fork of \" \\\n 'the master repo for private purposes we recommend to migrate ' \\\n 'to a clean private repo. To disable this check remove the ' \\\n 'remote pointing to the CocoaPods master repo.'\n end\n end",
"def execute\n raise NotImplementedError, 'Generic command has no actions'\n end"
] |
[
"0.63340926",
"0.6236264",
"0.6153249",
"0.6011007",
"0.59975284",
"0.5940933",
"0.5936595",
"0.5833702",
"0.5833702",
"0.5833702",
"0.5833702",
"0.57903993",
"0.5786597",
"0.5775998",
"0.575702",
"0.5753893",
"0.5709424",
"0.5704756",
"0.5695411",
"0.5693894",
"0.56690115",
"0.5667299",
"0.56566226",
"0.56557673",
"0.56476676",
"0.56439245",
"0.5633307",
"0.562603",
"0.5617555",
"0.5614651",
"0.56085604",
"0.5588027",
"0.55792314",
"0.5571581",
"0.55337054",
"0.5517209",
"0.55114216",
"0.5497281",
"0.5491059",
"0.54835564",
"0.54626787",
"0.54611826",
"0.5434783",
"0.5432986",
"0.54272664",
"0.54241455",
"0.539913",
"0.5396262",
"0.53921",
"0.5389236",
"0.5386412",
"0.53861225",
"0.5369762",
"0.53695405",
"0.5354136",
"0.5351561",
"0.5346179",
"0.5340367",
"0.5334472",
"0.5330067",
"0.53274184",
"0.5324599",
"0.5323228",
"0.5320127",
"0.5317581",
"0.53162843",
"0.5310783",
"0.5307018",
"0.53035",
"0.530054",
"0.52946496",
"0.52885586",
"0.5284799",
"0.52793354",
"0.5275247",
"0.52741706",
"0.5273484",
"0.5268355",
"0.52668905",
"0.52588606",
"0.52588606",
"0.52588606",
"0.52588606",
"0.52586764",
"0.52586764",
"0.5251274",
"0.52473664",
"0.52469075",
"0.5242765",
"0.5238517",
"0.52353144",
"0.5234058",
"0.5233442",
"0.52163404",
"0.52128583",
"0.5212019",
"0.52118015",
"0.52091503",
"0.5206884",
"0.5198153",
"0.51967025"
] |
0.0
|
-1
|
Setting.plugin_redmine_html_macro['htmlmacro_url'] ? Setting.plugin_redmine_html_macro['htmlmacro_url'] : Setting.plugin_redmine_html_macro['markdownit_url'] ? Setting.plugin_redmine_html_macro['markdownit_url'] :
|
def view_layouts_base_body_bottom(context={})
html = ""
html << stylesheet_link_tag('htmlmacro.css', :plugin => 'redmine_html_macro')
html << javascript_include_tag('markdown-it.min.js', :plugin => 'redmine_html_macro')
# html << stylesheet_link_tag('/redmine/plugin_assets/redmine_html_macro/stylesheets/htmlmacro.css')
# html << javascript_include_tag('/redmine/plugin_assets/redmine_html_macro/javascripts/markdown-it.min.js')
html << stylesheet_link_tag(Setting.plugin_redmine_html_macro['css_url'])
html << javascript_include_tag(Setting.plugin_redmine_html_macro['js_url'])
# html
# html << javascript_tag("mermaid.initialize({startOnLoad:true});var mermaidInitialized = 1;")
return html
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def markdown_extra?\n true\n end",
"def getDefaultConfig\n return \"\n{\n \\# Directory where MediaWiki is installed\n :MediawikiDir => '#{@MediawikiDir}'\n}\n\"\n end",
"def main_url\n homepage || linkedin || twitter_url || github_url || nil\n end",
"def use_markdown=(value)\n @use_markdown = value\n if value && !markdown_processor\n %W{rdiscount kramdown maruku bluecloth}.each do |lib|\n begin\n require lib\n break\n rescue LoadError\n end\n end\n end\n value\n end",
"def markdown?\n defined?(RDiscount) or defined?(BlueCloth)\n end",
"def markdown?\n defined?(RDiscount) or defined?(BlueCloth)\n end",
"def custom_slug_or_title\n (Refinery::Pages.use_custom_slugs && custom_slug.presence) ||\n menu_title.presence || title.presence\n end",
"def is_default?\n if self.project and self.project.download_url == self.download.url\n return true\n else\n return false\n end \n end",
"def markdown?\n @use_markdown && markdown_processor\n end",
"def more_like_this_config \n blacklight_config.more_like_this || {}\n end",
"def html?\n @html == true\n end",
"def config_or_default(config,key,default)\n (config && config[key] ? config[key] : default)\n end",
"def settings_link(link)\n \"settings-link\" if link.blank? || link == '#'\n end",
"def url\n SETTINGS[:url] || raise(\"Must provide URL - please edit file\")\nend",
"def url\n SETTINGS[:url] || raise(\"Must provide URL - please edit file\")\nend",
"def url\n SETTINGS[:url] || raise(\"Must provide URL - please edit file\")\nend",
"def github\n conf['dashboard']['github']\n end",
"def slack_enabled?\n return settings.slack_enabled && settings.slack_key\nend",
"def website?; website.to_s != \"\" end",
"def logo_url\n logo? ? logo.url : profile_img\n end",
"def gitlab\n conf['dashboard']['gitlab']\n end",
"def project?; @is_project || false; end",
"def url_or_git\n @url || @git || @svn\n end",
"def use_github?\n !journal_biohackrxiv?\n end",
"def development?; self == \"development\"; end",
"def hello_world(lang)\n lang == \"es\" ? result = \"Hola Mundo\" : lang == \"de\" ? result = \"Hallo Welt\" : result = \"Hello World\"\n p result\nend",
"def url(arg = nil)\n if arg.nil? && @url.nil?\n \"#{node['jenkins']['mirror']}/plugins/#{name}/#{version}/#{name}.hpi\"\n else\n set_or_return(:url, arg, :kind_of => String)\n end\nend",
"def display_edit_link(blog)\n# is_blog_admin? ? \"|<a href='/manage/blogs/#{blog.id}/edit'>编辑</a>\" : ''\n end",
"def check_shortcode\n self.shortcode ||= new_shortcode\n end",
"def html_view?\n !!self.__options[:html_view]\n end",
"def for_article_or_lesson?\n return '' unless content\n return 'article' if content.article_content?\n return 'lesson' if content.lesson_content?\n return ''\n end",
"def current_plugin?\n if Origen.application_loaded?\n Origen.app.plugins.current == self\n else\n puts <<-END\ncurrent_plugin? cannot be used at this point in your code since the app is not loaded yet.\n\nIf you are calling this from config/application.rb then you can only use current_plugin? within a block:\n\n# Not OK\nif current_plugin?\n config.output_directory = \"#{Origen.root}/output/dir1\"\nelse\n config.output_directory = \"#{Origen.root}/output/dir2\"\nend\n\n# OK\nconfig.output_directory do\n if current_plugin?\n \"#{Origen.root}/output/dir1\"\n else\n \"#{Origen.root}/output/dir2\"\n end\nend\n\nEND\n exit 1\n end\n end",
"def has_github?\n !github_url.blank?\n end",
"def build_config?\n show?\n end",
"def frontmatter_defaults; end",
"def use_technology_preview=(_arg0); end",
"def default_if_not_specified(opt,default_opt)\n opt ? opt : default_opt\nend",
"def teamSwitchEnabled \n \"teamSwitchEnabled\" \n end",
"def site_bar_switch_link\n link_to_if(admin?, t('.switch_to_your_website', site_bar_translate_locale_args),\n (if session.keys.map(&:to_sym).include?(:website_return_to) and session[:website_return_to].present?\n session[:website_return_to]\n else\n root_path(:locale => (::Refinery::I18n.default_frontend_locale if ::Refinery.i18n_enabled?))\n end), {:'data-pjax-disable' => 'true'}) do\n link_to t('.switch_to_your_website_editor', site_bar_translate_locale_args),\n (if session.keys.map(&:to_sym).include?(:refinery_return_to) and session[:refinery_return_to].present?\n session[:refinery_return_to]\n else\n admin_root_path\n end rescue admin_root_path), {:'data-pjax-disable' => 'true'}\n end\n end",
"def to_html\n production? ? to_production_html : to_development_html\n end",
"def plugin?(ref)\n\t\t\t\t\t\n\t\t\t\tend",
"def use_technology_preview; end",
"def scm_string?; SCM_FALSE; end",
"def set_mst_url(mst, rmt_id)\n url=\"http://#{$settings['redmine_host']}:#{$settings['redmine_port']}/issues/#{rmt_id}\"\n mst.HyperlinkAddress = url\n return url\nend",
"def deprecated?\n self[:slug].nil?\n end",
"def html?; end",
"def html?; end",
"def html?; end",
"def use_rendering_options?\n end",
"def pull_request?\n !!issue.pull_request.html_url\n end",
"def pull_request?\n !!issue.pull_request.html_url\n end",
"def contributed\n\t\tif @contributed.nil? then false else @contributed end\n\tend",
"def test_or_live\n test? ? 'test' : 'live'\n end",
"def custom?\n @custom\n end",
"def oembed_html\n oembed && oembed[:html]\n end",
"def wordpress_url(path=nil)\n return (path) ? \"#{WORDPRESS_URL}/#{path}\" : WORDPRESS_URL\n end",
"def has_theme?(theme_tag) has_tag(:theme, theme_tag) end",
"def get_var(var)\n @local_config.get_value(var) ? @local_config.get_value(var) : @global_config.get_value(var)\nend",
"def post_tweet_hook\n exec main_config['post_tweet_hook'] if main_config['post_tweet_hook']\nend",
"def hide_edit_links?\n !@hide_edit_links.nil? && @hide_edit_links == true \n end",
"def embedded_in?; false; end",
"def add_image_link?(options)\n !options.key?(:link) || options[:link]\n end",
"def view_with_check_option_support\n nil\n end",
"def support_multiple_source?; end",
"def automatic_url\n\t\t\t\t\treturn !self.nature.blank? && !config(:natures, self.nature.to_sym, :url).blank?\n\t\t\t\tend",
"def hide_edit_links?\n\tnot @hide_edit_links.nil?\nend",
"def has_wiki?\n !!wiki_pages\n end",
"def default_meta_image?\n default_meta_image ? true : false\n end",
"def build_framework?; build.include? 'framework'; end",
"def emojiable?(doc)\n (doc.is_a?(Jekyll::Page) || doc.write?) &&\n doc.output_ext == \".html\" || (doc.permalink&.end_with?(\"/\"))\n end",
"def html?\n HTML_EXTENSIONS.include?(output_ext)\n end",
"def html?\n HTML_EXTENSIONS.include?(output_ext)\n end",
"def wordify_boolean(bool)\n# bool ? t(:\"shared.boolean.yes\") : t(:\"shared.boolean.no\")\n bool ? \"Ja\" : \"Nein\"\n end",
"def specialist_setting\n\tend",
"def default_content; end",
"def with_html?\n TRUE_WORDS.include? params[:with_html]\n end",
"def youtube?; youtube.to_s != \"\" end",
"def set_defaults\n self.featured ||= 1\n end",
"def embedded?; false; end",
"def default_layout\n 'default' if html?\n end",
"def has_website?\n !url.blank?\n end",
"def static(true_or_false)\n if (true_or_false != 'true' && true_or_false != 'false')\n puts \"JJTreeTask Error: static must be string value ('true' or 'false')\"\n return\n end\n @static = true_or_false\n end",
"def ext_setting_link(extension, ctx)\n extension.setting_link ? ctx.instance_eval(&extension.setting_link) : '#'\n end",
"def baseSeeAlsoUrl\n if $cnf['environment'] == 'testb'\n case\n when $cnf['datacenter'] == 'US'\n 'https://ds6-testb-www.adminsys.mrll.com/bidder/forum/see_also_prompt.do?projectId='\n end\n\n elsif $cnf['environment'] == 'stage'\n case\n when $cnf['datacenter'] == 'US'\n 'https://ds6-stage-maw.datasite.com/bidder/forum/see_also_prompt.do?projectId='\n when ($cnf['datacenter'] == 'EU') && ($cnf['teridion'] == 't-off')\n 'https://ds6-eumastage-maw.datasite.com/bidder/forum/see_also_prompt.do?projectId='\n when $cnf['teridion'] == 't-on'\n 'https://eu1w-stage.datasite.com/bidder/forum/see_also_prompt.do?projectId='\n end\n elsif $cnf['environment'] == 'stage2'\n case\n when $cnf['datacenter'] == 'US'\n 'https://ds6-stage2-maw.merrillcorp.com/bidder/forum/see_also_prompt.do?projectId='\n end\n\n elsif $cnf['environment'] == 'prod'\n case\n when $cnf['datacenter'] == 'US'\n 'https://us1.merrillcorp.com/bidder/forum/see_also_prompt.do?projectId='\n when ($cnf['datacenter'] == 'EU') && ($cnf['teridion'] == 't-off')\n 'https://eu1.merrillcorp.com/bidder/forum/see_also_prompt.do?projectId='\n when $cnf['teridion'] == 't-on'\n 'https://eu1w.merrillcorp.com/bidder/forum/see_also_prompt.do?projectId='\n end\n end\nend",
"def news_and_media\n # blank\n end",
"def github\n @github ||= (\n require 'detroit'\n require 'detroit-github'\n Detroit::GitHub.new(\n :folder => 'website'\n #:sitemap => {\n # 'index.html' => 'index.html',\n # 'doc.json' => 'doc.json',\n # 'assets' => 'assets'\n #}\n )\n ) \nend",
"def build_your_team?\n return \"DONE\" if (set_budget? == \"DONE\") && (user.team.has_leadplace_agent?) \n return \"INPROC\" if (set_budget? == \"DONE\") && (!user.team.has_leadplace_agent?)\n return nil\n end",
"def site_editor?\n admin? || maintainer? || replies_count >= 100\n end",
"def display_social_bookmarks?; true end",
"def from_yammer?\n self.external_source == \"yammer\"\n end",
"def get_theme val\n case action_name\n when 'index'\n val == 1 ? 'b' : 'd'\n when 'sent'\n val == 2 ? 'b' : 'd'\n when 'seller'\n val == 1 ? 'b' : 'd'\n when 'unposted'\n val == 2 ? 'b' : 'd'\n when 'sold'\n val == 3 ? 'b' : 'd'\n when 'received'\n val == 2 ? 'b' : 'd'\n when 'new'\n val == 3 ? 'b' : 'd'\n when 'contact'\n val == 2 ? 'b' : 'd'\n when 'password'\n val == 3 ? 'b' : 'd'\n end\n end",
"def appTag \n #this tag :htmlfp is set in application.rb javascript_expansions field \n if @title.eql?(\"HTML5 for Publishers\") \n :html5fp\n elsif @title.eql?(\"Finger Paint\")\n :fingerpaint\n elsif @title.eql?(\"CSSGameEngine\") \n :cssgameengine\n elsif @title.eql?(\"GMP\") \n :gmp\n elsif @title.eql?(\"JawsJS\") \n :jaws\n elsif @title.eql?(\"EntityJS\") \n :entityjs\n elsif @title.eql?(\"ImpactJS\") \n :impactjs\n else #the :defaults are already being set\n \"\" \n end\n end",
"def use_rendering_options=(setting)\n end",
"def __(value=\"THE __ TEXT (you fill it in)\", value19=:mu)\n if RUBY_VERSION < \"1.9\"\n value\n else\n (value19 == :mu) ? value : value19\n end\nend",
"def close_browser_redmine?\n ENV['CLOSE_BROWSER']\n end",
"def config_set?(config)\n instance_variable_get(\"@#{config}\").to_s != ''\n end",
"def embed_code_css\n if video? || image? || interactive_map?\n responsive_embed_code_css\n elsif audio?\n audio_embed_code_css\n end\n end",
"def help_link(wiki_entry_name=nil)\n wiki_url = \"https://github.com/indykish/identityprov/wiki\"\n if wiki_entry_name\n wiki_url += \"/#{wiki_entry_name}\"\n link_text = \"Help for #{wiki_entry_name.underscore_humanize}\" \n else\n link_text =\"Help\" \n end\n link_to_ link_text, wiki_url, { :target => '_blank'}\n end",
"def style_howto\n\t%Q|/<a href=\"http://docs.tdiary.org/en/?#{@conf.style}Style\">How to write</a>|\nend",
"def site_title\n self.title ? self.title : self.discussion\n end"
] |
[
"0.57778347",
"0.56799877",
"0.54663444",
"0.5212251",
"0.5204728",
"0.5204728",
"0.5201314",
"0.5139513",
"0.5133032",
"0.5120223",
"0.5117432",
"0.510278",
"0.5102328",
"0.5087032",
"0.5087032",
"0.5087032",
"0.5082156",
"0.5059761",
"0.50050765",
"0.5004875",
"0.50010616",
"0.49836418",
"0.49770123",
"0.49749568",
"0.4971487",
"0.4937716",
"0.49297252",
"0.49023417",
"0.48984292",
"0.48830482",
"0.48815835",
"0.4879949",
"0.487711",
"0.4851489",
"0.48498803",
"0.4846033",
"0.48397964",
"0.48384127",
"0.48350453",
"0.48297912",
"0.48293087",
"0.4825497",
"0.48181078",
"0.48173055",
"0.48156595",
"0.48156157",
"0.48156157",
"0.48156157",
"0.48068306",
"0.47837874",
"0.47837874",
"0.47820407",
"0.47767484",
"0.4768774",
"0.4765586",
"0.47557542",
"0.4744822",
"0.47285032",
"0.4725403",
"0.47242978",
"0.47218224",
"0.47216904",
"0.4721456",
"0.47203428",
"0.47190428",
"0.47109696",
"0.47069338",
"0.47069162",
"0.46993232",
"0.46849823",
"0.46777162",
"0.46777162",
"0.46768725",
"0.46699598",
"0.4667881",
"0.46659738",
"0.46582955",
"0.46568158",
"0.4654421",
"0.4652334",
"0.46497834",
"0.46490645",
"0.46438298",
"0.46403262",
"0.4638003",
"0.46361175",
"0.46356854",
"0.46349445",
"0.46298814",
"0.46275568",
"0.46232465",
"0.46189204",
"0.46168247",
"0.4615109",
"0.4613819",
"0.4612124",
"0.4612084",
"0.46093407",
"0.4606014",
"0.46031"
] |
0.47161523
|
65
|
broke it down like this so that can access and compare the attributes
|
def control
{ :masterid => '1234FAKE',
:ca_co_status => 'control',
:biomom => 1,
:biodad => nil,
:date => nil,
:mother_full_name => 'Jill Johnson',
:mother_maiden_name => 'Jackson',
:father_full_name => 'Jack Johnson',
:child_full_name => 'Michael Johnson',
:child_dobm => 1,
:child_dobd => 6,
:child_doby => 2009,
:child_gender => 'M',
:birthplace_country => 'United States',
:birthplace_state => 'CA',
:birthplace_city => 'Oakland',
:mother_hispanicity => 2,
:mother_hispanicity_mex => 2,
:mother_race => 1,
:mother_race_other => nil,
:father_hispanicity => 2,
:father_hispanicity_mex => 2,
:father_race => 1,
:father_race_other => nil }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def attr_reader(*args)\n super\n comparison_attrs.concat(args)\n end",
"def attr; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attr_info; end",
"def is_attribute?; end",
"def attr(name); end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def attribute(name); end",
"def assert_known_attributes(klass, attribute_hash); end",
"def comparable_attributes\n#\t\tHashWithIndifferentAccess[attributes.select {|k,v| \n#\t\t\t!Abstract.incomparable_attribute_names.include?(k)}]\n\t\tHashWithIndifferentAccess[attributes.select {|k,v| db_fields.include?(k)}]\n\tend",
"def attributes=(_arg0); end",
"def attr_equal?(o)\n self == o and\n self.instance_variables_compare(o).empty? and\n self.attributes == o.attributes\n end",
"def class_attributes; end",
"def attributes\n end",
"def check_attrs(attr_list)\r\n attrs = []\r\n attr_list.each do |attr_sym|\r\n attr = assigns(attr_sym.to_sym)\r\n assert_not_nil attr, \"Attribute @#{attr_sym} should not be nil\"\r\n assert !attr.new_record?, \"Should have saved the @#{attr_sym} obj\" if attr.class == ActiveRecord\r\n attrs << attr\r\n end\r\n attrs.length > 1 ? attrs : attrs[0]\r\n end",
"def check_attrs(attr_list)\r\n attrs = []\r\n attr_list.each do |attr_sym|\r\n attr = assigns(attr_sym.to_sym)\r\n assert_not_nil attr, \"Attribute @#{attr_sym} should not be nil\"\r\n assert !attr.new_record?, \"Should have saved the @#{attr_sym} obj\" if attr.class == ActiveRecord\r\n attrs << attr\r\n end\r\n attrs.length > 1 ? attrs : attrs[0]\r\n end",
"def get_attribute(name); end",
"def get_attribute(name); end",
"def set_attributes_to_reader\n if !@attributes.empty?\n @attributes.each { |ele|\n self.class.__send__(:attr_reader, ele.downcase)\n }\n end\n\nend",
"def testable_response_attributes(response)\n testable_response(response)['data']['attributes']\n end",
"def attribute_method?(attr)\n super || attributes.keys.include?(attr)\n end",
"def defensive\n return (@attributes & 0x10 == 0x10)\n end",
"def instance_attributes; end",
"def is_attrtable?(); @type == GRT_ATTRTABLE; end",
"def test_combined_attributes\n output = tested 'attributes rms.jpg --img class=\"arg classes\"'\n attrs = output.at_css('img')['class'].split\n\n assert_includes attrs, 'arg'\n assert_includes attrs, 'classes'\n assert_includes attrs, 'img'\n end",
"def _read_attribute(key); end",
"def attributes\n # ...\n # debugger\n # f = method_missing(name)\n @attributes ||= {}\n # attributes = Hash.new {|h,k| h[k] = []}\n # @attributes = @colm.map {|colm| attributes[colm]}\n # unless instance_variables(false).include?(f)\n # # print f\n # end\n\n # @attribute ={}\n end",
"def is_propattr?(); @type == GRT_PROPATTR; end",
"def result_attrs\n main_result[\"@attr\"] rescue {}\n end",
"def _isValidAttr(attr,attrname,attrtype,mappings)\n #printValid self, attrname, attr\n # a) \n if isBasicType(attr)\n if not self.expectedValues.nil? and self.expectedValues.include?(attrname) \n if not self.expectedValues[attrname].include?(attr)\n log.debug('%s %s %s bad value not in self.expectedValues[attrname]:'%[attrname,attrtype, attr ])\n return false\n end\n end \n log.debug('%s %s %s ok'%[attrname, attrtype, attr.inspect ])\n return true\n end\n # b)\n if isStructType(attr)\n ### do i need to load it first ? becaus it should be memcopied with the super()..\n if not attr.isValid(mappings)\n log.debug('%s %s %s isValid FALSE'%[attrname,attrtype,attr.inspect ])\n return false\n end\n log.debug('%s %s %s isValid true'%[attrname,attrtype,attr.inspect ])\n return true\n end\n # c)\n if isBasicTypeArrayType(attr)\n #log.info('%s is arraytype %s we decided it was valid',attrname,attr.inspect)#\n return true\n end\n if isArrayType(attr)\n log.debug('%s is arraytype %s recurse validate'%[attrname,attr.inspect] )#\n attrLen = attr.size\n if attrLen == 0\n return true\n end\n elType = attr[0].type\n (0..attrLen).each do |i|\n if not self._isValidAttr(attr[i], \"%s[%d]\"%[attrname,i], elType, mappings )\n return false\n end\n end\n return true\n end\n # d)\n if isCStringPointer( attr)\n myaddress = getaddress(attr)\n if not self.expectedValues.nil? and self.expectedValues.include?(attrname) # TODO\n # test if NULL is an option\n if myaddress.nil? # address is null\n if not ( (self.expectedValues[attrname].include? nil ) or\n (self.expectedValues[attrname].include? 0) )\n log.debug('%s %s %s isNULL and that is NOT EXPECTED'%[attrname, attrtype, attr.inspect ])\n return false\n end\n log.debug('%s %s %s isNULL and that is OK'%[attrname, attrtype, attr.inspect ])\n return true\n end\n end\n if (not myaddress.nil?) and ( is_valid_address_value( myaddress, mappings) == false) \n log.debug('%s %s %s 0x%x INVALID'%[attrname,attrtype, attr.inspect ,myaddress])\n return false\n end\n log.debug('%s %s %s is at 0x%x OK'%[attrname,attrtype,attr.inspect,myaddress ])\n return true\n end\n # e) \n if isPointerType(attr)\n if not self.expectedValues.nil? and self.expectedValues.include?(attrname)\n # test if NULL is an option\n if attr.nil?\n if not ( (self.expectedValues[attrname].include? nil ) or\n (self.expectedValues[attrname].include? 0) )\n log.debug('%s %s %s isNULL and that is NOT EXPECTED'%[attrname,attrtype,attr.inspect ])\n return false\n end\n log.debug('%s %s %s isNULL and that is OK'%[attrname,attrtype,attr.inspect ])\n return true\n end\n end\n # all case, \n _attrType=nil\n if not attrtype.kind_of? NiceFFI::TypedPointer\n log.debug(\"I can't know the size of the basic type behind the %s pointer, it's not a pointer to known registered struct type\"%attrname)\n _attrType=nil\n else\n # test valid address mapping\n _attrType = attrtype.type\n end\n #log.debug(\" ihave decided on pointed attrType to be %s\"%(_attrType))\n if (not getaddress(attr).nil?) and ( is_valid_address( attr, mappings, _attrType) == false) \n log.debug('%s %s %s 0x%x INVALID'%[attrname,attrtype, attr.inspect ,getaddress(attr)])\n return false\n end\n # null is accepted by default \n log.debug('%s %s 0x%x OK'%[attrname,attr.inspect ,getaddress(attr)])\n return true\n end\n # ?\n if isUnionType(attr)\n #log.warning('Union are not validated , yet ')\n return true\n end\n log.error('What type are You ?: %s/%s'%[attrname,attrtype])\n return true\n end",
"def attr_list\n\t\ta_list \n\tend",
"def multi_element_attr_check( elements )\n wanted = Array.new\n found = Array.new\n elements.each do |element|\n print \".\"\n e = $driver.find_element(element[0].to_sym, element[1])\n wanted << [ element[1], element[2], element[3] ]\n found << [ element[1], element[2], e.attribute(element[2]) ]\n end\n\n found.should == wanted\n end",
"def attr_set?(cards, attr)\n array = []\n cards.each do |card|\n # evalutes the string 'attr' and returns the value\n array << card.send(attr)\n end\n\n # only return true if it's all the same or totally different\n return true if array.uniq.count == 1\n return true if array.uniq.count == 3\n return false\n end",
"def same_attributes?(spec)\n @@attributes.all? {|name, default| self.send(name) == spec.send(name) }\n end",
"def observe\n return (@attributes & 0x20 == 0x20)\n end",
"def filter_attributes_match?(hash_one, hash_two)\n hash_one.all? do |key, value_one|\n value_two = hash_two[key]\n case\n when value_one == value_two\n true\n when value_one.is_a?(Hash) && value_two.is_a?(Hash)\n filter_attributes_match?(value_one, value_two)\n when hash_one[key].to_s == hash_two[key].to_s\n true\n when value_one.is_a?(String) && value_one.start_with?(\"eval:\")\n eval_attribute_value(value_one, value_two)\n else\n false\n end\n end\n end",
"def attributes\n _fast_attributes\n\n rescue NameError\n\n method = \"def _fast_attributes\\n\"\n method << \" @_attributes ||=\\n\"\n method << \" begin\\n\"\n method << \" h = {}\\n\"\n\n self.class.attributes.each do |name|\n method << \" h[:\\\"#{name}\\\"] = send(:\\\"#{name}\\\") if include_#{name}?\\n\"\n end\n\n method << \" h\\n\"\n method << \" end\\n\"\n method << \"end\"\n\n self.class.class_eval method\n\n _fast_attributes\n end",
"def attributes\n end",
"def method_missing(name, *args, &block)\n unless self.attributes.include?(name.to_s)\n super(name, *args, &block)\n else\n self.attributes[name.to_s]\n end\n end",
"def method_missing(name, *args, &block)\n unless self.attributes.include?(name.to_s)\n super(name, *args, &block)\n else\n self.attributes[name.to_s]\n end\n end",
"def has_attributes?; end",
"def attributes_exist?\n\tend",
"def get_attributes\n\t\t\t@@attributes\n\t\tend",
"def has_attributes?(dictname)\n self.attribute_dictionary(dictname) != nil\nend",
"def find_attributes(node, &block); end",
"def attribute_name; end",
"def attribute_name; end",
"def attribute_name; end",
"def attribute_name; end",
"def attribute_name; end",
"def attribute_name; end",
"def attribute_name; end",
"def attrs\n @attrs\n end",
"def check_attribute_ancestors(ast_class_name, attributes, attribute)\n\t# Get all attributes with same name in the list\n\tduplicates = attributes.select{|x| x.name == attribute.name}\n\tif duplicates.length > 0\n\t\tduplicate = duplicates[0]\n\t\tline_number = attribute.name_line\n\t\tmessage = \"class #{ast_class_name} redefines attribute #{duplicate.name}\"\n\t\ttype_error(line_number, message)\t\n\tend\nend",
"def check_attribute_ancestors(ast_class_name, attributes, attribute)\n\t# Get all attributes with same name in the list\n\tduplicates = attributes.select{|x| x.name == attribute.name}\n\tif duplicates.length > 0\n\t\tduplicate = duplicates[0]\n\t\tline_number = attribute.name_line\n\t\tmessage = \"class #{ast_class_name} redefines attribute #{duplicate.name}\"\n\t\ttype_error(line_number, message)\t\n\tend\nend",
"def has_attributes?(dictname)\n self.attribute_dictionary(dictname) != nil || self.definition.attribute_dictionary(dictname) != nil\nend",
"def attributes; Common.attributes(@handle); end",
"def compare_attributes(data_criteria, criteria)\n return false unless data_criteria['dataElementAttributes']&.any?\n\n data_criteria['dataElementAttributes'].map { |dc| dc.except('_id') }.include? criteria['dataElementAttributes'][attribute_index].except('_id')\n end",
"def assert_attributes obj, attr_hash\n default_attr_hash = {}\n if obj.respond_to? :default_attr_hash\n default_attr_hash = obj.default_attr_hash\n end\n default_attr_hash.merge(attr_hash).each_pair do |key, value|\n assert_equal value, obj.__send__(key), \"Attribute #{key} of #{obj}\"\n end\n end",
"def attribs\n\t\t@attributes\n\tend",
"def is_attribute?(line)\n (line =~ /(\\s+)attr_(writer|reader|accessor)\\s+:[a-zA-Z_0-9]+/) == 0\n end",
"def attributes_for( an_instance )\n attrs = self.class.attributes[an_instance.class.name] \n raise \"Unable to get attributes for #{an_instance}\" unless attrs\n attrs\n end",
"def attributes_get\n h = {}\n self.class.attributes.each do |a|\n h[a] = attribute_get(a)\n end\n h\n end",
"def attributes_get\n h = {}\n self.class.attributes.each do |a|\n h[a] = attribute_get(a)\n end\n h\n end",
"def has_attributes?(names)\n parts = composite_parts\n names.all?{|k| parts.key?(k)}\n end",
"def method_missing(name, *args, &block)\n return attributes[name.to_sym] if attributes.include?(name.to_sym)\n return super\n end",
"def inspect() \n print @obj_name\n print \" which is \"\n print @obj_attr\n print \" & \"\n puts @obj_secondattr\n end",
"def attrs\n @attrs\n end",
"def test_attributes\n\n output_message(@test_root_name)\n\n test_instance = nil\n\n # setup\n VCR.use_cassette(\"#{@test_root_name}/setup\") do\n test_instance = TestModel.create!(id: 'instance_1', name: 'test_1a', desc: 'desc_1a')\n assert test_instance != false\n end\n\n # test\n VCR.use_cassette(\"#{@test_root_name}/synopsis\") do\n\n test_props = TestModel.properties\n assert test_props.length == 2\n assert test_props.include? :Name\n assert test_props.include? :DESC\n\n test_attrs = TestModel.attrs\n assert test_attrs.length == 2\n assert test_attrs.include? 'name'\n assert test_attrs.include? 'desc'\n\n test_attrs = test_instance.attrs\n assert test_attrs.length == 2\n assert test_attrs.include? 'name'\n assert test_attrs.include? 'desc'\n\n test_attributes = test_instance.attributes\n assert test_attributes.length == 2\n assert test_attributes.include? :name\n assert test_attributes.include? :desc\n assert test_attributes[:name] == 'test_1a'\n assert test_attributes[:desc] == 'desc_1a'\n\n test_qmap = TestModel.qmap\n assert test_qmap.length == test_props.length + test_attrs.length\n\n test_attrs.each { |a| assert test_qmap.include? a }\n\n test_props.each do |p|\n assert test_qmap.include? p.to_s\n assert test_qmap.include? p.to_orchio_rails_attr\n end\n\n test_qmap.each do |k,v|\n assert test_attrs.include? k.to_orchio_rails_attr\n assert test_props.include? v.to_sym\n end\n\n assert test_instance.read_attribute_for_serialization(:name) == 'test_1a'\n assert test_instance.read_attribute_for_validation(:desc) == 'desc_1a'\n\n assert test_instance.read_attribute_for_serialization(:bogus).nil?\n assert test_instance.read_attribute_for_validation(:bogus).nil?\n end\n\n # cleanup\n VCR.use_cassette(\"#{@test_root_name}/cleanup\") do\n status = TestModel.destroy!('instance_1')\n assert status == true\n end\n end",
"def reflection_or_attribute_name; end",
"def test_serizalied_attribute_names_are_returned_by_the_class\n assert Sprocket.serialized_attribute_names.sort == ['in_motion', 'size'].sort\n end",
"def load_attributes!\n fetch_data unless data_fetched?\n # master & value attributes\n raw_attributes = Ken::Util.convert_hash(@data[\"/type/reflect/any_master\"])\n raw_attributes.merge!(Ken::Util.convert_hash(@data[\"/type/reflect/any_value\"])) \n @attributes = {}\n raw_attributes.each_pair do |a, d|\n properties.select { |p| p.id == a}.each do |p|\n @attributes[p.id] = Ken::Attribute.create(d, p)\n end\n end\n # reverse properties\n raw_attributes = Ken::Util.convert_hash(@data[\"/type/reflect/any_reverse\"])\n raw_attributes.each_pair do |a, d|\n properties.select { |p| p.master_property == a}.each do |p|\n @attributes[p.id] = Ken::Attribute.create(d, p)\n end\n end\n @attributes_loaded = true\n end",
"def getValidAndInvalidAttributes\n @valid_attributes = []\n\n @valid_attributes_from_db.each_with_index do |attr_from_db, i| \n if @excel_attributes.include? attr_from_db[:name]\n @valid_attributes << attr_from_db\n end\n end\n\n x_attr = []\n @valid_attributes.each {|x| x_attr << x[:name]}\n @invalid_attributes = @excel_attributes - x_attr\n end",
"def attrs\n self.class.attrs\n end",
"def html_attributes(attr); end",
"def setup_object_attributes; end",
"def match_attributes(attrs)\n attrs = Saxxy::Helpers.stringify_keys(attrs)\n attributes.reduce(true) do |b, (k, v)|\n value = attrs[k]\n b && ((!value.nil? && match(v, value)) || (v.nil? && value.nil?))\n end\n end",
"def changed_attributes\r\n attributes = HashWithIndifferentAccess.new\r\n \r\n if self.edited\r\n %w{rate name}.each do |attr|\r\n if self.different?(attr)\r\n attributes[attr] = self.send(attr)\r\n end\r\n end\r\n end\r\n attributes\r\n end",
"def allowed_attributes=(_arg0); end",
"def allowed_attributes=(_arg0); end",
"def attributes(*args)\n args.each do |attr|\n attribute(attr)\n end\n end",
"def verify_attributes(hash, expected)\n return [] unless expected.attributes\n expected.attributes.map{ |a| verify_attribute_value(hash[a.name.to_s], a) }\n end",
"def attributes\n self.attribute_keys.inject({}) do |hash, key|\n hash[key] = self.__send__(key) if self.__send__(key)\n hash\n end\n end",
"def test_serizalied_attribute_names_are_returned_by_an_instance\n assert Sprocket.new.serialized_attribute_names.sort == ['in_motion', 'size'].sort\n end",
"def other_attrs\n @other_attrs ||= {}\n end"
] |
[
"0.648961",
"0.64631283",
"0.64562124",
"0.64562124",
"0.64562124",
"0.64562124",
"0.64562124",
"0.64562124",
"0.64562124",
"0.64562124",
"0.64562124",
"0.64562124",
"0.64562124",
"0.6366363",
"0.6329011",
"0.6291048",
"0.6253686",
"0.6253686",
"0.6253686",
"0.6253686",
"0.6253686",
"0.6253686",
"0.6253686",
"0.61258864",
"0.6109015",
"0.6106396",
"0.60803825",
"0.6067094",
"0.6065756",
"0.6053847",
"0.60375595",
"0.60375595",
"0.5999054",
"0.5999054",
"0.5992147",
"0.598734",
"0.5962866",
"0.5947619",
"0.58952934",
"0.5880157",
"0.5876056",
"0.5873515",
"0.5832767",
"0.58177984",
"0.5789111",
"0.57878554",
"0.5787066",
"0.5786237",
"0.5779862",
"0.57634145",
"0.5758376",
"0.5758041",
"0.5753113",
"0.5750555",
"0.574895",
"0.574895",
"0.5734278",
"0.57179725",
"0.57163227",
"0.57121754",
"0.5707474",
"0.57055223",
"0.57055223",
"0.57055223",
"0.57055223",
"0.57055223",
"0.57055223",
"0.57055223",
"0.5698125",
"0.5695764",
"0.5695764",
"0.5695326",
"0.5689517",
"0.5681122",
"0.5680526",
"0.5678535",
"0.5664761",
"0.5660984",
"0.56540805",
"0.56540805",
"0.5647096",
"0.56412476",
"0.5639253",
"0.5631449",
"0.5629532",
"0.56269765",
"0.5625872",
"0.5624855",
"0.5622599",
"0.56212384",
"0.56194437",
"0.56130797",
"0.5609778",
"0.5609528",
"0.56023455",
"0.56023455",
"0.5602113",
"0.5599587",
"0.55943984",
"0.5574824",
"0.5573502"
] |
0.0
|
-1
|
shouldn't be called test_... as makes it a test method!
|
def csv_test_file_name
"live_birth_data_update_test_file.csv"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def testing\n # ...\n end",
"def test_method\n end",
"def tests; end",
"def tests; end",
"def self_test; end",
"def self_test; end",
"def test \n end",
"def test\n\n end",
"def test_case; end",
"def test\n end",
"def test\n end",
"def test\n end",
"def __dummy_test__\n end",
"def spec; end",
"def spec; end",
"def stest_method_1(test); end",
"def my_tests\n end",
"def test_nothing\n end",
"def before_test(test); end",
"def before_test(test); end",
"def test_cases; end",
"def running_test_case; end",
"def should; super end",
"def test; end",
"def test_nothing\n end",
"def test_truth\n end",
"def test_setup\r\n \r\n end",
"def private; end",
"def test_nothing; end",
"def test_entry\n raise \"Implement this method in your test class\"\n end",
"def tests=(_arg0); end",
"def tests=(_arg0); end",
"def graffiti_test\n end",
"def default_test\r\n end",
"def test_entry\n raise 'Implement the method \"test_entry\" in your test class'\n end",
"def love_test\nend",
"def test_0_dummy\n\t\tend",
"def default_test; end",
"def default_test\n end",
"def test_step; end",
"def ptest_method_1(test); end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def test_a\n end",
"def assertions; end",
"def assertions; end",
"def test_entry_attrs\n raise \"Implement this method in your test class\"\n end",
"def test_Method_InstanceMethods_to_proc\n\t\tpass\n\tend",
"def test_nothing\n return true\n end",
"def test_connection\n end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def expected_method; end",
"def default_test\n end",
"def test_get_content_for\n end",
"def example_passed(_)\n end",
"def test_playlist\n end",
"def after_test(_test); end",
"def after_test(_test); end",
"def after_test(_test); end",
"def _test_message ; process_test_case(\"message\") ; end",
"def test_order; end",
"def test_hero_is_invincible\n end",
"def test_entry_attrs\n raise 'Implement the method \"test_entry_attrs\" in your test class'\n end",
"def test_marked\n end",
"def test_acknowledgement \n end",
"def __\n raise \"__ should be replaced with a value or expression to make the test pass.\"\nend",
"def test_hack\n assert(true)\n end",
"def test_defaults\n end",
"def run_test\n # Add your code here...\n end",
"def run_test\n # Add your code here...\n end",
"def before_assert\n end",
"def test; true; end",
"def test_created(test)\n\n end",
"def running_test_step; end",
"def scope_test\n end",
"def test_it_has_a_mod\n# skip\n# student = Student.new(\"Phil\", has_laptop = true, has_cookies = true)\n assert_equal 1, @student.mod\n end",
"def failures; end",
"def failures; end",
"def failures; end",
"def test_empty\n # Empty.\n end",
"def setup\n \n end"
] |
[
"0.7896266",
"0.77121276",
"0.7646567",
"0.7646567",
"0.754109",
"0.754109",
"0.7492185",
"0.7461208",
"0.74444",
"0.74434185",
"0.74434185",
"0.74434185",
"0.7419577",
"0.72673863",
"0.72673863",
"0.7238924",
"0.722074",
"0.71210295",
"0.7105422",
"0.7105422",
"0.70630527",
"0.70560586",
"0.6981814",
"0.6954427",
"0.6952073",
"0.69350165",
"0.69291335",
"0.69223565",
"0.69130856",
"0.6909286",
"0.6867319",
"0.6867319",
"0.68654287",
"0.6846875",
"0.67989254",
"0.6758598",
"0.6757854",
"0.6712928",
"0.6670465",
"0.66649795",
"0.66628003",
"0.6652402",
"0.6652402",
"0.6652402",
"0.6652402",
"0.6652402",
"0.6652402",
"0.6652402",
"0.6652402",
"0.6652402",
"0.6652402",
"0.6652402",
"0.6652402",
"0.6652402",
"0.6652402",
"0.6652402",
"0.6652402",
"0.6652402",
"0.6652402",
"0.6652402",
"0.66280055",
"0.66272295",
"0.66272295",
"0.66127086",
"0.66054547",
"0.6600327",
"0.65953654",
"0.6582324",
"0.6582324",
"0.6582324",
"0.6582324",
"0.65775377",
"0.65500474",
"0.6515594",
"0.6493272",
"0.6493119",
"0.64906746",
"0.64906746",
"0.64906746",
"0.6483866",
"0.6479768",
"0.64628464",
"0.64610755",
"0.6456852",
"0.6442215",
"0.6436223",
"0.6420055",
"0.64074713",
"0.63792616",
"0.63792616",
"0.63750815",
"0.63673294",
"0.6363646",
"0.6350955",
"0.63501036",
"0.6346242",
"0.63418317",
"0.63418317",
"0.63418317",
"0.6333489",
"0.6313604"
] |
0.0
|
-1
|
def logger= Wrap SizedQueuepush with a timer metric.
|
def push(*args)
@metric_queue_write.time do
super(*args)
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def push_time_updates\n @log.debug(\"Pushing timelogs.\")\n @ob.static(:Timelog, :push_time_updates, {:oata => self})\n end",
"def queue_time\n NotImplementedError\n end",
"def send_timer_message(topic, tag, body, timer, key = '')\n @producer.send_timer_message(topic, tag, body, timer.to_i * 1000, key)\n end",
"def mlog(*t)\n mess=\"#{Time.now.strftime('%H:%M:%S')} | AMQP #{t.join(' ')}\" \n puts mess\nend",
"def initialize\n @logger = VWO::Logger.get_instance\n @queue = []\n end",
"def info_handle\n @queue << \"i h\"\n end",
"def puts(msg, tok=@default_token)\n q = nil\n @hash_lock.synchronize do\n #Messages are grouped by their token since 1 http request\n #to logplex must only contain log messages belonging to a single token.\n q = @hash[tok] ||= LogMsgQueue.new(@batch_size)\n end\n q.enqueue({:t => Time.now.utc, :token => tok, :msg => msg})\n # Flush all of the queues if any queue is full.\n flush if q.full?\n end",
"def enqueue_to_in(queue, interval, klass, *args); end",
"def log(tag, *messages)\n messages.each do |message|\n QUEUE << [tag, message]\n end\n end",
"def add(args)\n args.each do |key, value|\n if value.respond_to?(:each)\n metric = value\n metric[:name] = key.to_s\n type = metric.delete(:type) || metric.delete('type') || 'gauge'\n else\n metric = {:name => key.to_s, :value => value}\n type = :gauge\n end\n type = (\"#{type}s\").to_sym\n unless skip_measurement_times\n metric[:measure_time] ||= epoch_time\n end\n @queued[type] ||= []\n @queued[type] << metric\n end\n queued\n end",
"def push (target, method_name, *args)\n\n #fei = args.find { |e| e.respond_to?(:fei) }\n #fei = fei.fei.to_s if fei\n #p [ :push, method_name, args.find { |e| e.is_a?(Symbol) }, fei ]\n\n if @stopped\n\n target.send(method_name, *args)\n #\n # degraded mode : as if there were no workqueue\n else\n\n @queue.push [ target, method_name, args ]\n #\n # work will be done later (millisec order)\n # by the work thread\n end\n end",
"def slowlog(subcommand, length = T.unsafe(nil)); end",
"def timer=(_arg0); end",
"def timer=(_arg0); end",
"def timer=(_arg0); end",
"def timer=(_arg0); end",
"def info_stack\n @queue << \"i s\"\n end",
"def push(x)\n @queue << x\n end",
"def metrics_line(name, value, timestamp)\n \"put #{name} #{timestamp} #{value}\"\n end",
"def push(event:)\n super\n\n @queue << event\n end",
"def timer; end",
"def timer; end",
"def timer; end",
"def timer; end",
"def track!(metric_name,call_time,options = {})\n meta = ScoutRails::MetricMeta.new(metric_name)\n meta.scope = options[:scope] if options.has_key?(:scope)\n stat = metric_hash[meta] || ScoutRails::MetricStats.new\n stat.update!(call_time,options[:exclusive_time] || call_time)\n metric_hash[meta] = stat\n end",
"def push(x)\n @size += 1\n @queue_in.push(x)\n end",
"def queue(_); end",
"def queue(_); end",
"def queue; end",
"def queue; end",
"def build_timing; end",
"def info\n @queue << \"info\"\n end",
"def delayed_push(timestamp, item)\n # This line could raise `LockingError` and it should be handled in the\n # `enqueue_at_with_queue` method\n #\n # We can't handle exception here, because of jobs, which raise an error on locking\n # will run after hooks, but its unexpected behavior.\n Resque::Job.new(item[:queue], 'class' => item[:class], 'args' => item[:args])\n .uniqueness\n .try_lock_queueing(timestamp.to_i - Time.now.to_i)\n super\n end",
"def <<(event)\n name, value, time = event.get(\"message\").split(\" \")\n event.set(name, value.to_f)\n\n if time != \"N\"\n event.timestamp = LogStash::Timestamp.at(time.to_i)\n end\n\n @queue << event\n end",
"def logWatch(name, data={}, &blk); return MootLogs.logWatch(name, data, &blk); end",
"def record(*args)\n raise 'Not enough arguments' if args.empty?\n raise 'Too many arguments' if args.size > 2\n\n queue << ['record', *args]\n end",
"def with_timer(name)\n start = Time.now\n yield\n duration = Time.now - start\n # report in ms\n add_field(name, duration * 1000)\n self\n end",
"def around_perform_job_stats_duration(*args)\n start = Time.now\n success = true\n yield\n rescue Exception\n success = false\n raise\n ensure\n duration = Time.now - start\n\n Resque.redis.lpush(jobs_duration_key(success), duration)\n Resque.redis.ltrim(jobs_duration_key(success), 0, durations_recorded)\n end",
"def delayed_push(timestamp, item)\n redis.zadd(:delayed_queue, timestamp.to_i, encode_with_nonce(item))\n end",
"def log_msg(message: , time: Time.now)\n return \"[#{time}, #{message}]\"\nend",
"def queue(message); end",
"def dump(m, time, args)\n return if stats_mode?\n\n start = Time.now\n synchronize do\n append_message(m, time, args)\n end\n ensure @dump_time += (Time.now - start)\n end",
"def push(count)\n service = time_entry.service || session.chosen_service\n (count.to_i * service.duration.to_i).minutes\n end",
"def requeue_throttled\n Sidekiq.redis { |conn| conn.lpush(QueueName.expand(queue_name), job) }\n end",
"def processed!\n Resque::Stat << \"processed\"\n Resque::Stat << \"processed:#{self}\"\n Resque::Stat << \"processed_#{job['queue']}\"\n end",
"def logging\n @@logging ||= lambda { |msg| puts(\"#{Time.now} :minion: #{msg}\") }\n end",
"def log_prefix\n \"Maxretry handler [queue=#{@worker_queue_name}]\"\n end",
"def log_writer; end",
"def save(request)\n result = nil\n benchmark :info, \"Queued #{indirection.name} for #{request.key}\" do\n result = client.publish_message(queue, request.instance.render(:pson))\n end\n result\n rescue => detail\n raise Puppet::Error, \"Could not write #{request.key} to queue: #{detail}\\nInstance::#{request.instance}\\n client : #{client}\"\n end",
"def flush_queue()\n until @log_entries_queue.empty?\n self.send(@log_entries_queue.pop())\n sleep(SLEEP_TIME)\n end\n end",
"def record(metric_name)\n item = ScoutRails::StackItem.new(metric_name)\n stack << item\n item\n end",
"def push_queue_push val\n return nil if self.push_queue_names.length == 0\n key = self.push_queue_names[rand(self.push_queue_names.length - 1)]\n self.debug_out \"pushing data onto push queue #{key}\"\n @redis.lpush key, Marshal.dump(val)\n key\n end",
"def processed!\n Resque::Stat << \"processed\"\n Resque::Stat << \"processed:#{self}\"\n Resque::Stat << \"processed_#{job.queue}\"\n end",
"def add_latency_metric!\n latency = request.annotations[:queue_latency] || 0\n meta = MetricMeta.new(\"Latency\", meta_options)\n stat = MetricStats.new\n stat.update!(latency)\n @metrics[meta] = stat\n end",
"def metric(data={})\n if @@metrics_buffer.empty?\n @@metrics_buffer = [data]\n else\n @@metrics_buffer << data\n end\n end",
"def log_request\n result = super\n push_outstanding_request\n result\n end",
"def info_display\n @queue << \"i d\"\n end",
"def insert(timer)\n @timers.add(timer)\n end",
"def push(x)\n @size += 1\n @queue_in.push(x)\n end",
"def timberline_push(content, metadata = {})\n if @timberline_queue.nil?\n raise \"You must specify a queue name using .timberline_queue first\"\n end\n @timberline_queue.push(content, metadata)\n end",
"def new_tagged_logger; end",
"def test_container_work_queue\n c = Container.new __method__\n delays = [0.1, 0.03, 0.02]\n a = []\n delays.each { |d| c.schedule(d) { a << [d, Time.now] } }\n start = Time.now\n c.run\n delays.sort.each do |d|\n x = a.shift\n assert_equal d, x[0]\n end\n assert_equalish delays.reduce(:+), Time.now-start\n end",
"def on_backends_sidekiq_base_worker_perform(event)\n count = event[:consumer].send(:params_batch).size\n topic = event[:consumer].topic.name\n time = event[:time]\n info \"Sidekiq processing of topic #{topic} with #{count} messages took #{time} ms\"\n end",
"def current_timer=(_arg0); end",
"def with_timer(name, &block)\n start = Time.now\n block.call\n duration = Time.now - start\n # report in ms\n self.add_field(name, duration * 1000)\n self\n end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def timer_notification(ms_time)\n return self\n end",
"def log(message)\n if message.is_a? String\n message_key = \"#{TransactionLogger.log_prefix}info\"\n message = { message_key => message }\n @log_queue.push message\n else\n @log_queue.push message\n end\n end",
"def signal_queue=(_arg0); end",
"def queue_job; end",
"def signal_queue; end",
"def queue(&b)\n @queue << b\n end",
"def register_timer(name)\n register_metric( Drone::Metrics::Timer.new(name) )\n end",
"def dj_log(message)\n Delayed::Worker.logger.debug(message)\nend",
"def queue_time_ms\n # Controller logic\n if converter_results[:queue_time] && converter_results[:queue_time].any?\n converter_results[:queue_time].values.first.total_call_time*1000 # ms\n # Job logic\n elsif converter_results[:job]\n stat = converter_results[:job].metric_set.metrics[ScoutApm::MetricMeta.new(\"Latency/all\", :scope => transaction_name)]\n stat ? stat.total_call_time*1000 : nil\n else\n nil\n end\n end",
"def format(tag, time, record)\n @log.trace \"Buffering #{tag}\"\n [tag, record].to_msgpack\n end",
"def get_log\n SimpleWorker.service.log(task_id)\n end",
"def enqueue_in(interval, klass, *args); end",
"def log(msg)\n puts(\"#{Time.now}> #{msg}\")\n end",
"def record_time(metric, labels = {})\n result = nil\n time = Benchmark.realtime { result = yield }\n metric&.observe(time, labels)\n result\n end",
"def patch!\n # rubocop:disable Metrics/BlockLength\n ::SuckerPunch::Job::ClassMethods.class_eval do\n alias_method :__run_perform_without_datadog, :__run_perform\n def __run_perform(*args)\n Datadog::Tracing.send(:tracer).provider.context = Datadog::Tracing::Context.new\n\n __with_instrumentation(Ext::SPAN_PERFORM) do |span|\n span.resource = \"PROCESS #{self}\"\n\n span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_PERFORM)\n\n # Set analytics sample rate\n if Datadog::Tracing::Contrib::Analytics.enabled?(datadog_configuration[:analytics_enabled])\n Datadog::Tracing::Contrib::Analytics.set_sample_rate(\n span,\n datadog_configuration[:analytics_sample_rate]\n )\n end\n\n # Measure service stats\n Datadog::Tracing::Contrib::Analytics.set_measured(span)\n\n __run_perform_without_datadog(*args)\n end\n rescue => e\n ::SuckerPunch.__exception_handler.call(e, self, args)\n end\n ruby2_keywords :__run_perform if respond_to?(:ruby2_keywords, true)\n\n alias_method :__perform_async, :perform_async\n def perform_async(*args)\n __with_instrumentation(Ext::SPAN_PERFORM_ASYNC) do |span|\n span.resource = \"ENQUEUE #{self}\"\n\n span.set_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_PERFORM_ASYNC)\n\n # Measure service stats\n Datadog::Tracing::Contrib::Analytics.set_measured(span)\n\n __perform_async(*args)\n end\n end\n ruby2_keywords :perform_async if respond_to?(:ruby2_keywords, true)\n\n alias_method :__perform_in, :perform_in\n def perform_in(interval, *args)\n __with_instrumentation(Ext::SPAN_PERFORM_IN) do |span|\n span.resource = \"ENQUEUE #{self}\"\n\n span.set_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_PERFORM_IN)\n\n span.set_tag(Ext::TAG_PERFORM_IN, interval)\n\n # Measure service stats\n Datadog::Tracing::Contrib::Analytics.set_measured(span)\n\n __perform_in(interval, *args)\n end\n end\n ruby2_keywords :perform_in if respond_to?(:ruby2_keywords, true)\n\n private\n\n def datadog_configuration\n Datadog.configuration.tracing[:sucker_punch]\n end\n\n def __with_instrumentation(name)\n Datadog::Tracing.trace(name, service: datadog_configuration[:service_name]) do |span|\n span.span_type = Datadog::Tracing::Metadata::Ext::AppTypes::TYPE_WORKER\n span.set_tag(Datadog::Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)\n span.set_tag(Ext::TAG_QUEUE, to_s)\n yield span\n end\n end\n end\n # rubocop:enable Metrics/BlockLength\n end",
"def call(log, logger)\n self.hash = {}\n self.log = log\n self.logger = logger\n\n metric; time; value; format_dimensions\n\n # gauge, counter, or cumulative_counter\n data = {}\n if log.duration\n data[:gauge] = [hash]\n else\n data[:counter] = [hash]\n end\n data.to_json\n end",
"def doge_control\r\n @next_queue_time = get_queue_time\r\n end",
"def dispatch(payload)\n queue.push(payload)\n end",
"def enqueue(metric)\n if @queue.length < @max_queue_size\n @queue << metric\n ensure_worker_running\n\n true\n else\n logger.warn(\n 'Queue is full, dropping events. The :max_queue_size ' \\\n 'configuration parameter can be increased to prevent this from ' \\\n 'happening.'\n )\n false\n end\n end",
"def _statsd_timing(metric,time)\n statsd.timing(metric,time) if statsd\n end",
"def _publish\n puts(\"pushing message: #{self.to_json} to queue #{@queue}\")\n AMQPCli.instance.push(self.to_json, @queue)\n end",
"def record_measure(label)\n $logger.debug(\n tms = Benchmark.measure(label) do\n yield\n end.format(\"%n: %10.6rreal %10.6u user %10.6y sys\")\n )\nend",
"def add_request(timestamp)\n # add to total requests\n @total_requests += 1\n @logger.debug(\"Pushing timestamp: #{Time.at(timestamp).to_s}\")\n @queue.push(timestamp)\n end",
"def log\n return if @logger.nil?\n\n @logger.debug(\"Counter\") { \"attempt #{self}\" }\n end",
"def info_arguments\n @queue << \"i a\"\n end",
"def current_timer; end",
"def log\n end"
] |
[
"0.60173494",
"0.5971506",
"0.5854686",
"0.58236337",
"0.5822852",
"0.5727988",
"0.57177424",
"0.56765884",
"0.56610304",
"0.56102896",
"0.5589174",
"0.55890787",
"0.5575735",
"0.5575735",
"0.5575735",
"0.5575735",
"0.55646974",
"0.5550715",
"0.5498783",
"0.5464265",
"0.5456947",
"0.5456947",
"0.5456947",
"0.5456947",
"0.54452616",
"0.5443838",
"0.54418427",
"0.54418427",
"0.54409593",
"0.54409593",
"0.54400355",
"0.543433",
"0.5431518",
"0.54296046",
"0.5409264",
"0.54089844",
"0.54086685",
"0.5402519",
"0.538896",
"0.53801847",
"0.5379343",
"0.53767484",
"0.5356217",
"0.5348047",
"0.5338772",
"0.5333014",
"0.5328339",
"0.5328246",
"0.53242594",
"0.5312133",
"0.53112775",
"0.5310798",
"0.5310707",
"0.5309707",
"0.5297301",
"0.5296756",
"0.52886325",
"0.52862513",
"0.5272386",
"0.52679366",
"0.5265236",
"0.52643704",
"0.5263177",
"0.526286",
"0.52465284",
"0.52436936",
"0.52436936",
"0.52436936",
"0.52436936",
"0.52436936",
"0.52436936",
"0.52436936",
"0.52436936",
"0.5241697",
"0.5233094",
"0.5230583",
"0.52266496",
"0.52236503",
"0.52235234",
"0.5220026",
"0.5215739",
"0.52140784",
"0.5213955",
"0.5211433",
"0.52097636",
"0.5208119",
"0.52003026",
"0.51989794",
"0.5194266",
"0.5192563",
"0.51902467",
"0.5185609",
"0.51850706",
"0.51823753",
"0.51821893",
"0.51780236",
"0.51778996",
"0.51773417",
"0.51736075",
"0.5172888"
] |
0.73045415
|
0
|
GET /ingredients GET /ingredients.json
|
def index
@ingredients = Ingredient.all
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def list_ingredients\n rid = params[:id]\n items = Aws.get_ingredients_from_db(rid)\n render :json => items\n end",
"def ingredients_by_recipe\n recipe = Recipe.find(params[:id])\n render json: recipe.ingredients\n end",
"def ingredient_data\n respond_to do |format|\n format.json { render json: helpers.get_ingredient(params[:ingredient_type], params[:ingredient_id]) }\n end\n end",
"def show\n @ingredients_name = IngredientsName.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ingredients_name }\n end\n end",
"def index \n ingredients = Ingredient.all\n #render will return the object back in json format so that it can be used by the frontend\n render json: ingredients\n end",
"def show\n params.require(%i[id])\n render json: Ingredient.find_by!(id: params[:id])\n end",
"def index\n recipe_items = current_user.recipes.includes(recipe_items: :ingredient).find(params[:recipe_id]).recipe_items\n render json: { recipe_items: recipe_items}.to_json(include: :ingredient), status: :ok\n end",
"def show\n @recipe_ingredient = RecipeIngredient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe_ingredient }\n end\n end",
"def index \n recipeIngredients = RecipeIngredient.all\n #render will return the object back in json format so that it can be used by the frontend\n render json: recipeIngredients\n end",
"def show\n # accept the params\n # go to the db and get the correct recipe for that param\n p params[:id]\n @recipe = Recipe.find_by(id: params[:id])\n @ingredients = @recipe.ingredients.split(\", \").map {|ingredient| ingredient.capitalize}\n # send this to the view\n # show that data to the user\n render 'show.json.jb'\n end",
"def show\n @recipe_ingredient = Recipe_ingredient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe_ingredient }\n end\n end",
"def show\n @recipe = Recipe.find(params[:id])\n @recipeIngredients = RecipeIngredient.where(:recipeId => params[:id])\n @ingredients = Ingredient.where(:id => @recipeIngredients.select(:ingredientId))\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe }\n end\n end",
"def show\n if ingredient\n render json: ingredient\n else \n render json: {message: 'Ingredient not found'}\n end\n end",
"def show\n @ingredients = Ingredient.all\n end",
"def by_ingredient\n # If ingredient exists, find recipes that use it\n if Ingredient.exists?(params[:id])\n ingredient = Ingredient.find(params[:id])\n recipes = Recipe.recipes_of_ingredient(params[:id])\n else\n recipes = Recipe.all\n end\n\n # Render json\n render json: {recipes: recipes}, status: 200 \n end",
"def getRecipeByIngredientsList\n begin\n ingredientsList = params[:ingredients].split(\",\")\n\n @recipe = []\n ingredientsList.each do |ingredient|\n @recipe.push(Recipe.where('ingredients ILIKE ?', '%'+ingredient+'%').all)\n end\n \n if !@recipe.empty?\n render json: { status: 'SUCCESS', message: 'Loaded recipe!', data: @recipe }, status: :ok\n else\n render json: { status: 'SUCCESS', message: 'No recipe found', data: {} }, status: :not_found\n end\n rescue\n render json: { status: 'ERROR', message: 'Error loading recipe', data: {} }, status: :not_found\n end\n end",
"def index\n @ingredientes = Ingrediente.all\n end",
"def index\n @ingredientes = Ingrediente.all\n end",
"def show\n @ingredient = Ingredient.find_by_url_slug(params[:id])\n @ingredient = Ingredient.find(params[:id]) if @ingredient.nil?\n @recipes = @ingredient.recipes.order('created_at DESC')\n logger.debug @recipes.inspect\n respond_to do |format|\n format.html {render :layout => 'wall'}\n format.json { render json: @ingredient }\n end\n end",
"def ingredients(url)\n recipe_html_string = open(url).read\n\n recipe = Hangry.parse(recipe_html_string)\n ingredients = recipe.ingredients.map{\n |ingredient|\n Ingreedy.parse(ingredient)\n }\n end",
"def show\n if recipeIngredient\n render json: recipeIngredient\n else \n render json: {message: 'Recipe Ingredient not found'}\n end\n end",
"def recipes # /v1/user/:id/recipes (GET)\n recipes = ::Recipe.all\n render json: recipes, :each_serializer => RecipeSmallSerializer, root: false, status: 200\n end",
"def create\n ingredient = Ingredient.create(ingredient_params)\n render json: ingredient\n end",
"def index\n @page_title = \"All Ingredeients\"\n @ingredients = Ingredient.all\n end",
"def new\n @ingredient = Ingredient.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ingredient }\n end\n end",
"def ingredients\n recipe_ingredients.map do |r|\n r.ingredient\n end\n end",
"def index\n @ingredients_nutrients = IngredientsNutrient.all\n end",
"def show\n\t\t@recipe = Recipe.find(params[:id])\n\t\tif @recipe \n\t\t\trender json: @recipe.to_json(:include => [:inventories])\n\t\telse\n\t\t\trender status: 400, nothing: true\n\t\tend\n\tend",
"def index\n @recipes = Recipe.all\n render json: @recipes\n end",
"def index\n @recipeingredients = Recipeingredient.all\n end",
"def show\n response = Aws.list_recipe(params[:id])\n render :json => response\n end",
"def visualize_ingredients(opts = {})\n data, _status_code, _headers = visualize_ingredients_with_http_info(opts)\n data\n end",
"def index\n recipes = Recipe.all\n render status: :ok, json: recipes\n end",
"def index\n @ingredients = Ingredient.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @ingredients }\n end\n end",
"def index\n @ingredient_recipes = IngredientRecipe.all\n end",
"def ingredients\n recipeingredient.map {|ri| ri.ingredient}\n end",
"def visualize_ingredients_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: IngredientsApi.visualize_ingredients ...'\n end\n allowable_values = [\"application/x-www-form-urlencoded\", \"application/json\", \"multipart/form-data\"]\n if @api_client.config.client_side_validation && opts[:'content_type'] && !allowable_values.include?(opts[:'content_type'])\n fail ArgumentError, \"invalid value for \\\"content_type\\\", must be one of #{allowable_values}\"\n end\n allowable_values = [\"en\", \"de\"]\n if @api_client.config.client_side_validation && opts[:'language'] && !allowable_values.include?(opts[:'language'])\n fail ArgumentError, \"invalid value for \\\"language\\\", must be one of #{allowable_values}\"\n end\n allowable_values = [\"application/json\", \"text/html\", \"media/*\"]\n if @api_client.config.client_side_validation && opts[:'accept'] && !allowable_values.include?(opts[:'accept'])\n fail ArgumentError, \"invalid value for \\\"accept\\\", must be one of #{allowable_values}\"\n end\n # resource path\n local_var_path = '/recipes/visualizeIngredients'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'language'] = opts[:'language'] if !opts[:'language'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['text/html'])\n # HTTP header 'Content-Type'\n content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])\n if !content_type.nil?\n header_params['Content-Type'] = content_type\n end\n header_params[:'Content-Type'] = opts[:'content_type'] if !opts[:'content_type'].nil?\n header_params[:'Accept'] = opts[:'accept'] if !opts[:'accept'].nil?\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'String'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['apiKeyScheme']\n\n new_options = opts.merge(\n :operation => :\"IngredientsApi.visualize_ingredients\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: IngredientsApi#visualize_ingredients\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n @recipe_ingredients = RecipeIngredient.all\n end",
"def add_ingredients\n rid = params['id']\n name = params['name']\n quant = params['quantity']\n meas = params['measurement']\n\n ingredients = {\n 'name' => name,\n 'quantity' => quant,\n 'measurement' => meas,\n }\n\n if Aws.save_ingredient_to_db(rid, ingredients)\n msg = {:notice => \"Ingredient created!\"}\n render :json => msg\n else\n msg = {:notice => \"Error while creating ingredient!\"}\n render :json => msg\n end\n end",
"def index\n @recipes = Recipe.all\n respond_to do |format|\n format.html {}\n format.json { render json: @recipes }\n end\n end",
"def new\n @ingredients_name = IngredientsName.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ingredients_name }\n end\n end",
"def index\n info = Aws.get_recipes_from_db\n render :json => info\n end",
"def show\n @recipe = current_user.recipes.find(params[:id])\n @instructions = @recipe.instructions\n @ingredients = @recipe.ingredients\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe }\n end\n end",
"def index\n @recipes = Recipe.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recipes }\n end\n end",
"def index\n @ingredients = Ingredient.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @ingredients.to_xml }\n end\n end",
"def list\n \n recipes = Recipe.all\n render :json => recipes.to_json\n\n end",
"def show\r\n\r\n url = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/#{params[:id]}/information\")\r\n\r\n http = Net::HTTP.new(url.host, url.port)\r\n http.use_ssl = true\r\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\r\n\r\n request = Net::HTTP::Get.new(url)\r\n request[\"x-rapidapi-key\"] = ENV[\"SPOONACULAR_API_KEY\"] # hidden API key\r\n request[\"x-rapidapi-host\"] = 'spoonacular-recipe-food-nutrition-v1.p.rapidapi.com'\r\n\r\n response = http.request(request)\r\n @recipe = JSON.parse response.read_body # gets the recipe\r\n\r\n p url_ingredients = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/#{params[:id]}/ingredientWidget.json\")\r\n\r\n http_ingredients = Net::HTTP.new(url_ingredients.host, url_ingredients.port)\r\n http_ingredients.use_ssl = true\r\n http_ingredients.verify_mode = OpenSSL::SSL::VERIFY_NONE\r\n\r\n request_ingredients = Net::HTTP::Get.new(url_ingredients)\r\n request_ingredients[\"x-rapidapi-key\"] = ENV[\"SPOONACULAR_API_KEY\"]\r\n request[\"x-rapidapi-host\"] = 'spoonacular-recipe-food-nutrition-v1.p.rapidapi.com'\r\n\r\n response_ingredients = http.request(request_ingredients)\r\n # puts response_ingredients.read_body\r\n @ingredients = JSON.parse # data is a string (which looks like a hash -> convert to hash) response_ingredients.read_body\r\n p \"RECIPES\"\r\n # p @recipe\r\n p \"INGREDIENTS\"\r\n p @ingredients\r\n\r\n end",
"def index\n render json: Recipe.all\n end",
"def new\n @recipeingredient = Recipe_ingredient.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recipe_ingredient }\n end\n end",
"def show\n\n recipe = Recipe.find(params[:id])\n render :json => recipe.to_json\n\n end",
"def index\n recipes = current_user.recipes\n render json: { recipes: recipes}.to_json, status: :ok\n end",
"def show\n @ingredient = Ingredient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ingredient }\n end\n end",
"def show\n @ingredient = Ingredient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ingredient }\n end\n end",
"def new\n @recipe_ingredient = RecipeIngredient.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recipe_ingredient }\n end\n end",
"def show\n recipe = Recipe.find(params[:id])\n # recipes = Recipe.find_by(params[:id])\n # render json: recipe\n render json: recipe\n end",
"def items\n \tbegin\n \t@categories = Category.all.includes(items: [:dimensions])\n \t@ingredients = Ingredient.actives\n \trender 'api/v1/home/items', status: :ok\n \trescue Exception => e\n \t\terror_handling_bad_request(e)\n \tend\n\n\tend",
"def index\n @recipes = Recipe.search(params[:search])\n @ingredients = Ingredient.all\n end",
"def show\n \n rec_id = params[:id].to_i\n recipe = Recipe.find(rec_id)\n # find user name for recipe\n \n username = recipe.user.username;\n\n # get all ingredients from step ingredients ?\n ingredients = []\n\n recipe_steps = recipe.recipe_steps\n # one to one step ingredients to ingredients when coming from recipe-steps\n \n # recipe ingredients\n \n \n \n step_ingredients = recipe_steps.map{ |rs| \n { \n step_num: rs.step_num,\n step_image: rs.image,\n instruction: rs.instruction,\n step_ingredients: rs.step_ingredients.map{ |si| \n {amount: si.amount, ingredient: {name: si.ingredient.name} }\n } \n \n }\n \n }\n\n \n step_ingredients.each do |si|\n # byebug \n ings = si[:step_ingredients]\n ings.each do |ing|\n if ing[:amount] \n ing_total = ing[:amount] + \" \" + ing[:ingredient][:name] \n if !ingredients.include?(ing_total)\n ingredients.push(ing_total) \n end\n else\n ing_total = ing[:ingredient][:name] \n if !ingredients.include?(ing_total)\n ingredients.push(ing_total) \n end\n end\n end\n end\n \n # fix time to string\n \n render json: {username: username, recipe: recipe, ingredients: ingredients, recipe_steps: step_ingredients }, status: :accepted\n end",
"def index\n\t\t@recipes = Recipe.where(user_id: session[:user_id])\n\t\tif @recipes\n\t\t\trender json: @recipes.to_json(:include => [:inventories])\n\t\telse\n\t\t\tflash[:error] = \"You haven't saved any recipes yet! Search now :)\"\n\t\t\trender status: 400, nothing: true\n\t\tend\n\tend",
"def show\n @recipe = Recipe.find(params[:id])\n @nutrition_info = NutritionInfo.where( \"recipe_id = ?\", @recipe.id ).first\n @inventory_items = []\n @recipe.inventory_items.each do |inventory_item|\n @inventory_items << inventory_item\n end\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe }\n end\n end",
"def ingredient_params\n ActiveModelSerializers::Deserialization.jsonapi_parse!(params, only: [:name, :location, :category])\n end",
"def ingredients\n # self.recipe_ingredients\n recipe_ingredients.map do |r_i|\n r_i.ingredient\n end\n end",
"def index\n @ingredient_lists = IngredientList.all\n end",
"def show\n @ingredient = Ingredient.find(params[:id])\n\n respond_to do |format|\n format.xml { render :xml => @ingredient }\n end\n end",
"def show\n render json: @recipe\n end",
"def index\n @ingredients = Ingredient.paginate(page: params[:page], per_page: 5)\n end",
"def index\n @allergens_ingredients = AllergensIngredient.all\n end",
"def index\n per_page = params[:per_page]&.to_i || DEFAULT_PER_PAGE\n page = params[:page]&.to_i || DEFAULT_PAGE\n query = params[:query] || \"\"\n\n queries = query.split(\",\").map { |q| \"%#{q.downcase.strip}%\" }\n recipe_ids = []\n \n if queries.present?\n queries.each do |q|\n tmp_recipe_ids = Ingredient.where('UNACCENT(LOWER(name)) ILIKE UNACCENT(?)', q)\n .pluck(:recipe_id)\n .uniq\n\n excluded_ids = []\n excluded_ids = recipe_ids - tmp_recipe_ids | tmp_recipe_ids - recipe_ids unless recipe_ids.empty?\n \n recipe_ids = (recipe_ids + tmp_recipe_ids) - excluded_ids\n end\n end\n \n recipes = Recipe.where(id: recipe_ids).order('rate DESC NULLS LAST').order(id: :asc)\n .page(page)\n .per(per_page)\n \n render json: {\n meta: {\n total_recipes: recipes.total_count,\n total_pages: recipes.total_pages,\n per_page: per_page,\n query: query,\n page: page\n }, \n recipes: recipes.map { |recipe| ::RecipeJson.new(recipe: recipe).to_h }\n }\n end",
"def get_recipe_titles(user_ingredients)\n \n search_params = 'http://www.recipepuppy.com/api/?i=' + user_ingredients.join(\",\")\n \n\n recipes = []\n search_string = RestClient.get(search_params)\n search_hash = JSON.parse(search_string)\n relevant_recipes = search_hash[\"results\"]\n relevant_recipes.collect do |recipe|\n recipes << recipe[\"title\"].strip\n end\n \n recipes\nend",
"def set_ingredients_nutrient\n @ingredients_nutrient = IngredientsNutrient.find(params[:id])\n end",
"def ingredients\n self.dessert_ingredients.map {|di| di.ingredient}\n end",
"def create\n recipeIngredient = rRcipeIngredient.create(recipeIngredient_params)\n render json: recipeIngredient\n end",
"def get_recipe(id)\n recipe = Recipe.find(id)\n url = \"https://api2.bigoven.com/recipe/steps/#{recipe.id}?&api_key=#{ENV['API_KEY']}\"\n uri = URI(url)\n response = Net::HTTP.get(uri)\n # puts response\n\n JSON.parse(response)[\"Ingredients\"].each do |ingredient|\n # recipe.ingredients.create!(\n if (!Ingredient.exists?(ingredient[\"IngredientID\"])) \n Ingredient.create!(\n id: ingredient[\"IngredientID\"],\n name: ingredient[\"Name\"],\n html_name: ingredient[\"HTMLName\"]\n )\n end\n end\n\n if (recipe.recipe_ingredients.count > 0)\n recipe.recipe_ingredients.destroy_all\n recipe.save\n recipe.reload\n end\n\n JSON.parse(response)[\"Ingredients\"].each do |ingredient|\n \n # if (!recipe.recipe_ingredients.find_by(ingredient_id: ingredient[\"IngredientID\"]))\n recipe.recipe_ingredients.create!(\n ingredient_id: ingredient[\"IngredientID\"],\n quantity: ingredient[\"Quantity\"],\n display_quantity: ingredient[\"DisplayQuantity\"],\n unit: ingredient[\"Unit\"],\n metric_quantity: ingredient[\"MetricQuantity\"],\n metric_display_quantity: ingredient[\"MetricDisplayQuantity\"],\n metric_unit: ingredient[\"MetricUnit\"],\n preparation_notes: ingredient[\"PreparationNotes\"]\n )\n # end\n end\n \n recipe.steps = ''\n steps = JSON.parse(response)[\"Steps\"]\n steps.each do |step|\n step != steps.last ? recipe.steps += step[\"Text\"] + '$' : recipe.steps += step[\"Text\"]\n # recipe.steps += step[\"Text\"] + ','\n end\n \n recipe.save\n end",
"def show \n\n # @recipe.ingredients.build\n @new_ingredient = Ingredient.new\n @new_ingredient.recipe = @recipe\n\n # @flag = @recipe.flags.create\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe }\n end\n end",
"def index\n @dis_ingredients = DisIngredient.all\n end",
"def create\n\t\t\t\trecipe = Recipe.new(recipe_params)\n\t\t\t\tingredients = params[:ingredients]\n\t\t\t\ttags = params[:tags]\n\t\t\t\t\n\t\t\t\tif recipe.save\n\t\t\t\t\tif !ingredients.blank?\n\t\t\t\t\t\tredirect_to api_v1_recipe_ingredients_url(recipe_id: recipe.id, ingredients: ingredients, tags: tags)\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\trender json: {status: 'ERROR', message: 'Recipe not saved', data: recipe.errors}, status: :unprocessable_entity\n\t\t\t\tend\n\t\t\tend",
"def show\n respond_to do |format|\n format.html {}\n format.json { render json: @recipe }\n end\n end",
"def recipes\n @ingredient = Ingredient.find(params[:id])\n \n respond_to do |format|\n format.html do\n @recipes = @ingredient.recipes.paginate(:page => params[:page], :order => 'name', :per_page => 5)\n end # recipes.html.haml\n format.xml do\n @recipes = @ingredient.recipes\n render :xml => @recipes\n end\n end\n end",
"def index\n @recipe_ingredients_units = RecipeIngredientsUnit.all\n end",
"def index\n ingredients = BeverageIngredient.where(beverage_id: params[:id])\n empty_ingredients = []\n hash = {}\n\n ingredient_needed = ingredients.map do |i|\n hash.store(i.ingredient_id.to_s, i.units)\n {\n id: i.ingredient_id.to_s,\n units: i.units\n }\n end\n\n ingredients_id = ingredient_needed.pluck(:id)\n\n ingredients_present = Ingredient.where(id: ingredients_id).as_json.map do |i|\n { name: i['name'], id: i['id'], units: i['units'] }\n end\n error_msg = []\n ingredients_present.each do |ing|\n id = ing[:id]\n current_units = ing[:units] - hash[id]\n if current_units >= 0\n hash[id] = current_units\n elsif current_units == 0\n empty_ingredient.push({ id: id, name: ing[:name] })\n else\n error_msg = error_msg.push(\"Unable to Dispense, Insufficient Ingredients: #{ing[:name]} is less than required units. Please Refill!\")\n end\n end\n\n raise ActionController::BadRequest, error_msg if error_msg.present?\n\n update_ingredients(hash)\n\n output_json = { status: DISPENSED }\n output_json[:empty_ingredients] = empty_ingredients if empty_ingredients.present?\n render json: output_json\n end",
"def enter_ingredients\n puts \"\\nPlease input your ingredients below. Separate each ingredient with a comma.\\n\"\n\n ingredients = gets.strip\n recipes = EverythingButTheKitchenSink::SpoonacularApi.get_recipes(ingredients)\n EverythingButTheKitchenSink::TransformData.get_id_and_title(recipes)\n end",
"def index\n @cooking_ingredients = CookingIngredient.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @cooking_ingredients }\n end\n end",
"def index\n @post_ingredients = @post.post_ingredients\n end",
"def ingredient(name)\n content = content_by_name(name)\n return nil if content.blank?\n content.ingredient\n end",
"def ingredient(name)\n content = content_by_name(name)\n return nil if content.blank?\n content.ingredient\n end",
"def autocomplete_ingredient_search_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: IngredientsApi.autocomplete_ingredient_search ...'\n end\n if @api_client.config.client_side_validation && !opts[:'number'].nil? && opts[:'number'] > 100\n fail ArgumentError, 'invalid value for \"opts[:\"number\"]\" when calling IngredientsApi.autocomplete_ingredient_search, must be smaller than or equal to 100.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'number'].nil? && opts[:'number'] < 1\n fail ArgumentError, 'invalid value for \"opts[:\"number\"]\" when calling IngredientsApi.autocomplete_ingredient_search, must be greater than or equal to 1.'\n end\n\n allowable_values = [\"en\", \"de\"]\n if @api_client.config.client_side_validation && opts[:'language'] && !allowable_values.include?(opts[:'language'])\n fail ArgumentError, \"invalid value for \\\"language\\\", must be one of #{allowable_values}\"\n end\n # resource path\n local_var_path = '/food/ingredients/autocomplete'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'query'] = opts[:'query'] if !opts[:'query'].nil?\n query_params[:'number'] = opts[:'number'] if !opts[:'number'].nil?\n query_params[:'metaInformation'] = opts[:'meta_information'] if !opts[:'meta_information'].nil?\n query_params[:'intolerances'] = opts[:'intolerances'] if !opts[:'intolerances'].nil?\n query_params[:'language'] = opts[:'language'] if !opts[:'language'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'Array<AutocompleteIngredientSearch200ResponseInner>'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['apiKeyScheme']\n\n new_options = opts.merge(\n :operation => :\"IngredientsApi.autocomplete_ingredient_search\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: IngredientsApi#autocomplete_ingredient_search\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def show\n @recipe = Recipe.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe }\n end\n end",
"def get_ingredients_names\n self.ingredients.map{|ingredient| ingredient.name}\n end",
"def update\n ingredient.update(ingredient_params)\n render json: ingredient\n end",
"def show\n @data = @recipe.read(params[:id])\n render json: @data\n end",
"def index\n @ingredients = Ingredient.order(sort_type + \" \" + sort_direction)\n @activeSort = sort_type\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ingredients }\n end\n end",
"def ingredient_search_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: IngredientsApi.ingredient_search ...'\n end\n if @api_client.config.client_side_validation && !opts[:'offset'].nil? && opts[:'offset'] > 900\n fail ArgumentError, 'invalid value for \"opts[:\"offset\"]\" when calling IngredientsApi.ingredient_search, must be smaller than or equal to 900.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'offset'].nil? && opts[:'offset'] < 0\n fail ArgumentError, 'invalid value for \"opts[:\"offset\"]\" when calling IngredientsApi.ingredient_search, must be greater than or equal to 0.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'number'].nil? && opts[:'number'] > 100\n fail ArgumentError, 'invalid value for \"opts[:\"number\"]\" when calling IngredientsApi.ingredient_search, must be smaller than or equal to 100.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'number'].nil? && opts[:'number'] < 1\n fail ArgumentError, 'invalid value for \"opts[:\"number\"]\" when calling IngredientsApi.ingredient_search, must be greater than or equal to 1.'\n end\n\n allowable_values = [\"en\", \"de\"]\n if @api_client.config.client_side_validation && opts[:'language'] && !allowable_values.include?(opts[:'language'])\n fail ArgumentError, \"invalid value for \\\"language\\\", must be one of #{allowable_values}\"\n end\n # resource path\n local_var_path = '/food/ingredients/search'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'query'] = opts[:'query'] if !opts[:'query'].nil?\n query_params[:'addChildren'] = opts[:'add_children'] if !opts[:'add_children'].nil?\n query_params[:'minProteinPercent'] = opts[:'min_protein_percent'] if !opts[:'min_protein_percent'].nil?\n query_params[:'maxProteinPercent'] = opts[:'max_protein_percent'] if !opts[:'max_protein_percent'].nil?\n query_params[:'minFatPercent'] = opts[:'min_fat_percent'] if !opts[:'min_fat_percent'].nil?\n query_params[:'maxFatPercent'] = opts[:'max_fat_percent'] if !opts[:'max_fat_percent'].nil?\n query_params[:'minCarbsPercent'] = opts[:'min_carbs_percent'] if !opts[:'min_carbs_percent'].nil?\n query_params[:'maxCarbsPercent'] = opts[:'max_carbs_percent'] if !opts[:'max_carbs_percent'].nil?\n query_params[:'metaInformation'] = opts[:'meta_information'] if !opts[:'meta_information'].nil?\n query_params[:'intolerances'] = opts[:'intolerances'] if !opts[:'intolerances'].nil?\n query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?\n query_params[:'sortDirection'] = opts[:'sort_direction'] if !opts[:'sort_direction'].nil?\n query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?\n query_params[:'number'] = opts[:'number'] if !opts[:'number'].nil?\n query_params[:'language'] = opts[:'language'] if !opts[:'language'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'IngredientSearch200Response'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['apiKeyScheme']\n\n new_options = opts.merge(\n :operation => :\"IngredientsApi.ingredient_search\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: IngredientsApi#ingredient_search\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def show\n @food_recipe = FoodRecipe.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @food_recipe }\n end\n end",
"def index\n @ingredients = Ingredient.paginate(page: params[:page],per_page:3)\n end",
"def ingredient\n return nil if essence.nil?\n essence.ingredient\n end",
"def ingredients\n recipe_ingredients.map {|recipe_ingredient| recipe_ingredient.ing}\n end",
"def recipe_ingredients(recipe_id)\n recipe_status_helper(recipe_id)\n @recipe_ingredient_arr = recipe_ingredient.split(\", \")\n puts \" \"\n p user.recipes.where(id: recipe_id)[0].ingredient\n prompt.select(\"Options\") do |menu|\n puts \" \"\n menu.choice \"Choose New Protein\", -> {choose_protein}\n menu.choice \"Update Recipe Rating\", -> {update_recipe_rating(recipe_id)}\n menu.choice \"Add Ingredient\", -> {ingredient_add_helper(recipe_id)}\n menu.choice \"Remove Ingredient\", -> {ingredient_remove_helper(recipe_id)}\n menu.choice \"Exit\", -> {exit_helper}\n end\n end",
"def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end",
"def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end"
] |
[
"0.82749915",
"0.7904606",
"0.738146",
"0.7342815",
"0.73110056",
"0.7248971",
"0.71387273",
"0.71288425",
"0.7097881",
"0.7073",
"0.70626014",
"0.7022474",
"0.69816965",
"0.6942283",
"0.69415855",
"0.6918985",
"0.68556786",
"0.68556786",
"0.68036395",
"0.6783335",
"0.67776346",
"0.67708075",
"0.66968864",
"0.6688179",
"0.6674736",
"0.6647643",
"0.6639557",
"0.6624424",
"0.6606948",
"0.66036123",
"0.66004467",
"0.6569925",
"0.6565459",
"0.6557448",
"0.65545887",
"0.6550004",
"0.6548285",
"0.65252477",
"0.650632",
"0.6502084",
"0.6500273",
"0.64755785",
"0.6458162",
"0.6456038",
"0.6450124",
"0.6425364",
"0.64210826",
"0.64151466",
"0.6405696",
"0.6398421",
"0.63798225",
"0.6349813",
"0.6349813",
"0.631552",
"0.62992805",
"0.6298536",
"0.6297503",
"0.6296491",
"0.6290424",
"0.62858635",
"0.6278444",
"0.62373585",
"0.6233175",
"0.62180245",
"0.6215055",
"0.6189826",
"0.6189525",
"0.6167378",
"0.6141881",
"0.61361265",
"0.6132324",
"0.61302674",
"0.6128841",
"0.6125336",
"0.61241233",
"0.6118582",
"0.6108676",
"0.61053526",
"0.6090396",
"0.6085369",
"0.6055861",
"0.60514665",
"0.60404503",
"0.60379285",
"0.60379285",
"0.60359114",
"0.60190964",
"0.59976506",
"0.59818095",
"0.59810024",
"0.59805673",
"0.59752864",
"0.5973094",
"0.59680885",
"0.5963388",
"0.5956346",
"0.5946223",
"0.59454286",
"0.59454286"
] |
0.6984497
|
13
|
GET /ingredients/1 GET /ingredients/1.json
|
def show
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def list_ingredients\n rid = params[:id]\n items = Aws.get_ingredients_from_db(rid)\n render :json => items\n end",
"def ingredients_by_recipe\n recipe = Recipe.find(params[:id])\n render json: recipe.ingredients\n end",
"def show\n params.require(%i[id])\n render json: Ingredient.find_by!(id: params[:id])\n end",
"def show\n @ingredients_name = IngredientsName.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ingredients_name }\n end\n end",
"def show\n @recipe_ingredient = RecipeIngredient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe_ingredient }\n end\n end",
"def show\n @recipe_ingredient = Recipe_ingredient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe_ingredient }\n end\n end",
"def show\n # accept the params\n # go to the db and get the correct recipe for that param\n p params[:id]\n @recipe = Recipe.find_by(id: params[:id])\n @ingredients = @recipe.ingredients.split(\", \").map {|ingredient| ingredient.capitalize}\n # send this to the view\n # show that data to the user\n render 'show.json.jb'\n end",
"def show\n @recipe = Recipe.find(params[:id])\n @recipeIngredients = RecipeIngredient.where(:recipeId => params[:id])\n @ingredients = Ingredient.where(:id => @recipeIngredients.select(:ingredientId))\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe }\n end\n end",
"def ingredient_data\n respond_to do |format|\n format.json { render json: helpers.get_ingredient(params[:ingredient_type], params[:ingredient_id]) }\n end\n end",
"def by_ingredient\n # If ingredient exists, find recipes that use it\n if Ingredient.exists?(params[:id])\n ingredient = Ingredient.find(params[:id])\n recipes = Recipe.recipes_of_ingredient(params[:id])\n else\n recipes = Recipe.all\n end\n\n # Render json\n render json: {recipes: recipes}, status: 200 \n end",
"def index \n ingredients = Ingredient.all\n #render will return the object back in json format so that it can be used by the frontend\n render json: ingredients\n end",
"def show\n if ingredient\n render json: ingredient\n else \n render json: {message: 'Ingredient not found'}\n end\n end",
"def show\n @ingredient = Ingredient.find_by_url_slug(params[:id])\n @ingredient = Ingredient.find(params[:id]) if @ingredient.nil?\n @recipes = @ingredient.recipes.order('created_at DESC')\n logger.debug @recipes.inspect\n respond_to do |format|\n format.html {render :layout => 'wall'}\n format.json { render json: @ingredient }\n end\n end",
"def index\n recipe_items = current_user.recipes.includes(recipe_items: :ingredient).find(params[:recipe_id]).recipe_items\n render json: { recipe_items: recipe_items}.to_json(include: :ingredient), status: :ok\n end",
"def index \n recipeIngredients = RecipeIngredient.all\n #render will return the object back in json format so that it can be used by the frontend\n render json: recipeIngredients\n end",
"def show\n if recipeIngredient\n render json: recipeIngredient\n else \n render json: {message: 'Recipe Ingredient not found'}\n end\n end",
"def index\n @ingredients = Ingredient.all\n end",
"def index\n @ingredients = Ingredient.all\n end",
"def new\n @ingredient = Ingredient.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ingredient }\n end\n end",
"def show\n @ingredients = Ingredient.all\n end",
"def show\n recipe = Recipe.find(params[:id])\n # recipes = Recipe.find_by(params[:id])\n # render json: recipe\n render json: recipe\n end",
"def show\n response = Aws.list_recipe(params[:id])\n render :json => response\n end",
"def show\n\t\t@recipe = Recipe.find(params[:id])\n\t\tif @recipe \n\t\t\trender json: @recipe.to_json(:include => [:inventories])\n\t\telse\n\t\t\trender status: 400, nothing: true\n\t\tend\n\tend",
"def show\n\n recipe = Recipe.find(params[:id])\n render :json => recipe.to_json\n\n end",
"def index\n @ingredientes = Ingrediente.all\n end",
"def index\n @ingredientes = Ingrediente.all\n end",
"def recipes # /v1/user/:id/recipes (GET)\n recipes = ::Recipe.all\n render json: recipes, :each_serializer => RecipeSmallSerializer, root: false, status: 200\n end",
"def show\r\n\r\n url = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/#{params[:id]}/information\")\r\n\r\n http = Net::HTTP.new(url.host, url.port)\r\n http.use_ssl = true\r\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\r\n\r\n request = Net::HTTP::Get.new(url)\r\n request[\"x-rapidapi-key\"] = ENV[\"SPOONACULAR_API_KEY\"] # hidden API key\r\n request[\"x-rapidapi-host\"] = 'spoonacular-recipe-food-nutrition-v1.p.rapidapi.com'\r\n\r\n response = http.request(request)\r\n @recipe = JSON.parse response.read_body # gets the recipe\r\n\r\n p url_ingredients = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/#{params[:id]}/ingredientWidget.json\")\r\n\r\n http_ingredients = Net::HTTP.new(url_ingredients.host, url_ingredients.port)\r\n http_ingredients.use_ssl = true\r\n http_ingredients.verify_mode = OpenSSL::SSL::VERIFY_NONE\r\n\r\n request_ingredients = Net::HTTP::Get.new(url_ingredients)\r\n request_ingredients[\"x-rapidapi-key\"] = ENV[\"SPOONACULAR_API_KEY\"]\r\n request[\"x-rapidapi-host\"] = 'spoonacular-recipe-food-nutrition-v1.p.rapidapi.com'\r\n\r\n response_ingredients = http.request(request_ingredients)\r\n # puts response_ingredients.read_body\r\n @ingredients = JSON.parse # data is a string (which looks like a hash -> convert to hash) response_ingredients.read_body\r\n p \"RECIPES\"\r\n # p @recipe\r\n p \"INGREDIENTS\"\r\n p @ingredients\r\n\r\n end",
"def create\n ingredient = Ingredient.create(ingredient_params)\n render json: ingredient\n end",
"def new\n @ingredients_name = IngredientsName.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ingredients_name }\n end\n end",
"def show\n @ingredient = Ingredient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ingredient }\n end\n end",
"def show\n @ingredient = Ingredient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ingredient }\n end\n end",
"def new\n @recipeingredient = Recipe_ingredient.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recipe_ingredient }\n end\n end",
"def index\n recipes = Recipe.all\n render status: :ok, json: recipes\n end",
"def index\n @page_title = \"All Ingredeients\"\n @ingredients = Ingredient.all\n end",
"def index\n @recipeingredients = Recipeingredient.all\n end",
"def show\n @recipe = current_user.recipes.find(params[:id])\n @instructions = @recipe.instructions\n @ingredients = @recipe.ingredients\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe }\n end\n end",
"def index\n @recipes = Recipe.all\n render json: @recipes\n end",
"def new\n @recipe_ingredient = RecipeIngredient.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recipe_ingredient }\n end\n end",
"def index\n @ingredients_nutrients = IngredientsNutrient.all\n end",
"def index\n @ingredient_recipes = IngredientRecipe.all\n end",
"def getRecipeByIngredientsList\n begin\n ingredientsList = params[:ingredients].split(\",\")\n\n @recipe = []\n ingredientsList.each do |ingredient|\n @recipe.push(Recipe.where('ingredients ILIKE ?', '%'+ingredient+'%').all)\n end\n \n if !@recipe.empty?\n render json: { status: 'SUCCESS', message: 'Loaded recipe!', data: @recipe }, status: :ok\n else\n render json: { status: 'SUCCESS', message: 'No recipe found', data: {} }, status: :not_found\n end\n rescue\n render json: { status: 'ERROR', message: 'Error loading recipe', data: {} }, status: :not_found\n end\n end",
"def index\n @recipes = Recipe.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recipes }\n end\n end",
"def index\n @recipes = Recipe.all\n respond_to do |format|\n format.html {}\n format.json { render json: @recipes }\n end\n end",
"def index\n @recipe_ingredients = RecipeIngredient.all\n end",
"def index\n @ingredients = Ingredient.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @ingredients }\n end\n end",
"def show\n @ingredient = Ingredient.find(params[:id])\n\n respond_to do |format|\n format.xml { render :xml => @ingredient }\n end\n end",
"def show\n @recipe = Recipe.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe }\n end\n end",
"def index\n info = Aws.get_recipes_from_db\n render :json => info\n end",
"def show\n @recipe = Recipe.find(params[:id])\n @nutrition_info = NutritionInfo.where( \"recipe_id = ?\", @recipe.id ).first\n @inventory_items = []\n @recipe.inventory_items.each do |inventory_item|\n @inventory_items << inventory_item\n end\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe }\n end\n end",
"def show\n @data = @recipe.read(params[:id])\n render json: @data\n end",
"def index\n @ingredients = Ingredient.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @ingredients.to_xml }\n end\n end",
"def show \n\n # @recipe.ingredients.build\n @new_ingredient = Ingredient.new\n @new_ingredient.recipe = @recipe\n\n # @flag = @recipe.flags.create\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe }\n end\n end",
"def show\n render json: @recipe\n end",
"def show\n respond_to do |format|\n format.html {}\n format.json { render json: @recipe }\n end\n end",
"def index\n render json: Recipe.all\n end",
"def show\n @food_recipe = FoodRecipe.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @food_recipe }\n end\n end",
"def add_ingredients\n rid = params['id']\n name = params['name']\n quant = params['quantity']\n meas = params['measurement']\n\n ingredients = {\n 'name' => name,\n 'quantity' => quant,\n 'measurement' => meas,\n }\n\n if Aws.save_ingredient_to_db(rid, ingredients)\n msg = {:notice => \"Ingredient created!\"}\n render :json => msg\n else\n msg = {:notice => \"Error while creating ingredient!\"}\n render :json => msg\n end\n end",
"def show\n \n rec_id = params[:id].to_i\n recipe = Recipe.find(rec_id)\n # find user name for recipe\n \n username = recipe.user.username;\n\n # get all ingredients from step ingredients ?\n ingredients = []\n\n recipe_steps = recipe.recipe_steps\n # one to one step ingredients to ingredients when coming from recipe-steps\n \n # recipe ingredients\n \n \n \n step_ingredients = recipe_steps.map{ |rs| \n { \n step_num: rs.step_num,\n step_image: rs.image,\n instruction: rs.instruction,\n step_ingredients: rs.step_ingredients.map{ |si| \n {amount: si.amount, ingredient: {name: si.ingredient.name} }\n } \n \n }\n \n }\n\n \n step_ingredients.each do |si|\n # byebug \n ings = si[:step_ingredients]\n ings.each do |ing|\n if ing[:amount] \n ing_total = ing[:amount] + \" \" + ing[:ingredient][:name] \n if !ingredients.include?(ing_total)\n ingredients.push(ing_total) \n end\n else\n ing_total = ing[:ingredient][:name] \n if !ingredients.include?(ing_total)\n ingredients.push(ing_total) \n end\n end\n end\n end\n \n # fix time to string\n \n render json: {username: username, recipe: recipe, ingredients: ingredients, recipe_steps: step_ingredients }, status: :accepted\n end",
"def show\n respond_with Recipe.find(params[\"id\"])\n end",
"def show\n @meal = Meal.find(params[:meal_id]) if params[:meal_id]\n @recipe = @meal.recipes.find(params[:id]) if @meal\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe }\n end\n end",
"def show(id) \n response = request(:get, \"/recipes/#{id}.json\")\n response.first[1]\n end",
"def index\n recipes = current_user.recipes\n render json: { recipes: recipes}.to_json, status: :ok\n end",
"def get_recipe(id)\n recipe = Recipe.find(id)\n url = \"https://api2.bigoven.com/recipe/steps/#{recipe.id}?&api_key=#{ENV['API_KEY']}\"\n uri = URI(url)\n response = Net::HTTP.get(uri)\n # puts response\n\n JSON.parse(response)[\"Ingredients\"].each do |ingredient|\n # recipe.ingredients.create!(\n if (!Ingredient.exists?(ingredient[\"IngredientID\"])) \n Ingredient.create!(\n id: ingredient[\"IngredientID\"],\n name: ingredient[\"Name\"],\n html_name: ingredient[\"HTMLName\"]\n )\n end\n end\n\n if (recipe.recipe_ingredients.count > 0)\n recipe.recipe_ingredients.destroy_all\n recipe.save\n recipe.reload\n end\n\n JSON.parse(response)[\"Ingredients\"].each do |ingredient|\n \n # if (!recipe.recipe_ingredients.find_by(ingredient_id: ingredient[\"IngredientID\"]))\n recipe.recipe_ingredients.create!(\n ingredient_id: ingredient[\"IngredientID\"],\n quantity: ingredient[\"Quantity\"],\n display_quantity: ingredient[\"DisplayQuantity\"],\n unit: ingredient[\"Unit\"],\n metric_quantity: ingredient[\"MetricQuantity\"],\n metric_display_quantity: ingredient[\"MetricDisplayQuantity\"],\n metric_unit: ingredient[\"MetricUnit\"],\n preparation_notes: ingredient[\"PreparationNotes\"]\n )\n # end\n end\n \n recipe.steps = ''\n steps = JSON.parse(response)[\"Steps\"]\n steps.each do |step|\n step != steps.last ? recipe.steps += step[\"Text\"] + '$' : recipe.steps += step[\"Text\"]\n # recipe.steps += step[\"Text\"] + ','\n end\n \n recipe.save\n end",
"def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end",
"def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end",
"def current_ingredient\n ingredient = Ingredient.find(params[:id])\n end",
"def ingredients(url)\n recipe_html_string = open(url).read\n\n recipe = Hangry.parse(recipe_html_string)\n ingredients = recipe.ingredients.map{\n |ingredient|\n Ingreedy.parse(ingredient)\n }\n end",
"def random\n offset = rand(@ingredients.count)\n render json: @ingredients.offset(offset).first.as_json\n end",
"def set_ingredients_nutrient\n @ingredients_nutrient = IngredientsNutrient.find(params[:id])\n end",
"def ingredients\n recipe_ingredients.map do |r|\n r.ingredient\n end\n end",
"def create\n recipeIngredient = rRcipeIngredient.create(recipeIngredient_params)\n render json: recipeIngredient\n end",
"def ingredient(name)\n content = content_by_name(name)\n return nil if content.blank?\n content.ingredient\n end",
"def ingredient(name)\n content = content_by_name(name)\n return nil if content.blank?\n content.ingredient\n end",
"def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end",
"def index\n @recipes = Recipe.search(params[:search])\n @ingredients = Ingredient.all\n end",
"def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end",
"def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end",
"def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end",
"def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end",
"def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end",
"def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end",
"def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end",
"def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end",
"def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end",
"def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end",
"def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end",
"def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end",
"def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end",
"def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end",
"def update\n ingredient.update(ingredient_params)\n render json: ingredient\n end",
"def list\n \n recipes = Recipe.all\n render :json => recipes.to_json\n\n end",
"def recipes\n @ingredient = Ingredient.find(params[:id])\n \n respond_to do |format|\n format.html do\n @recipes = @ingredient.recipes.paginate(:page => params[:page], :order => 'name', :per_page => 5)\n end # recipes.html.haml\n format.xml do\n @recipes = @ingredient.recipes\n render :xml => @recipes\n end\n end\n end",
"def show\n @recipe = Recipe.find(params[:id])\n @ingredients = @recipe.ingredients\n @instructions_domain = @recipe.instruction_url_split\n @nutrition_info = @recipe.nutrition_informations\n @health_labels = @recipe.health_labels\n end",
"def index\n\t\t@recipes = Recipe.where(user_id: session[:user_id])\n\t\tif @recipes\n\t\t\trender json: @recipes.to_json(:include => [:inventories])\n\t\telse\n\t\t\tflash[:error] = \"You haven't saved any recipes yet! Search now :)\"\n\t\t\trender status: 400, nothing: true\n\t\tend\n\tend",
"def show\n if recipe\n render json: recipe\n else \n render json: {message: 'Recipe not found'}\n end\n end",
"def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n params[:recipe][:ingredients].each do |ingredient_id|\n next if ingredient_id.to_i == 0\n ingredient = Ingredient.find(ingredient_id.to_i)\n @recipe.ingredients << ingredient\n end\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def visualize_ingredients_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: IngredientsApi.visualize_ingredients ...'\n end\n allowable_values = [\"application/x-www-form-urlencoded\", \"application/json\", \"multipart/form-data\"]\n if @api_client.config.client_side_validation && opts[:'content_type'] && !allowable_values.include?(opts[:'content_type'])\n fail ArgumentError, \"invalid value for \\\"content_type\\\", must be one of #{allowable_values}\"\n end\n allowable_values = [\"en\", \"de\"]\n if @api_client.config.client_side_validation && opts[:'language'] && !allowable_values.include?(opts[:'language'])\n fail ArgumentError, \"invalid value for \\\"language\\\", must be one of #{allowable_values}\"\n end\n allowable_values = [\"application/json\", \"text/html\", \"media/*\"]\n if @api_client.config.client_side_validation && opts[:'accept'] && !allowable_values.include?(opts[:'accept'])\n fail ArgumentError, \"invalid value for \\\"accept\\\", must be one of #{allowable_values}\"\n end\n # resource path\n local_var_path = '/recipes/visualizeIngredients'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'language'] = opts[:'language'] if !opts[:'language'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['text/html'])\n # HTTP header 'Content-Type'\n content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])\n if !content_type.nil?\n header_params['Content-Type'] = content_type\n end\n header_params[:'Content-Type'] = opts[:'content_type'] if !opts[:'content_type'].nil?\n header_params[:'Accept'] = opts[:'accept'] if !opts[:'accept'].nil?\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'String'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['apiKeyScheme']\n\n new_options = opts.merge(\n :operation => :\"IngredientsApi.visualize_ingredients\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: IngredientsApi#visualize_ingredients\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def show\n @cooking_ingredient = CookingIngredient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @cooking_ingredient }\n end\n end",
"def index\n ingredients = BeverageIngredient.where(beverage_id: params[:id])\n empty_ingredients = []\n hash = {}\n\n ingredient_needed = ingredients.map do |i|\n hash.store(i.ingredient_id.to_s, i.units)\n {\n id: i.ingredient_id.to_s,\n units: i.units\n }\n end\n\n ingredients_id = ingredient_needed.pluck(:id)\n\n ingredients_present = Ingredient.where(id: ingredients_id).as_json.map do |i|\n { name: i['name'], id: i['id'], units: i['units'] }\n end\n error_msg = []\n ingredients_present.each do |ing|\n id = ing[:id]\n current_units = ing[:units] - hash[id]\n if current_units >= 0\n hash[id] = current_units\n elsif current_units == 0\n empty_ingredient.push({ id: id, name: ing[:name] })\n else\n error_msg = error_msg.push(\"Unable to Dispense, Insufficient Ingredients: #{ing[:name]} is less than required units. Please Refill!\")\n end\n end\n\n raise ActionController::BadRequest, error_msg if error_msg.present?\n\n update_ingredients(hash)\n\n output_json = { status: DISPENSED }\n output_json[:empty_ingredients] = empty_ingredients if empty_ingredients.present?\n render json: output_json\n end",
"def show\n @ingredient_assignment = IngredientAssignment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ingredient_assignment }\n end\n end"
] |
[
"0.79940003",
"0.788936",
"0.7566463",
"0.7531003",
"0.74188334",
"0.73733646",
"0.7350761",
"0.7282355",
"0.7211195",
"0.71441513",
"0.7120503",
"0.7106303",
"0.70800036",
"0.7016235",
"0.6978926",
"0.6972189",
"0.6941257",
"0.6941257",
"0.6913198",
"0.6897089",
"0.68653595",
"0.6825604",
"0.68165773",
"0.6808061",
"0.67634284",
"0.67634284",
"0.67231",
"0.6697679",
"0.6687151",
"0.6684178",
"0.66745114",
"0.66745114",
"0.6667514",
"0.6644589",
"0.6632663",
"0.6622128",
"0.6617606",
"0.6612754",
"0.65811473",
"0.65726286",
"0.65572447",
"0.6554956",
"0.6542591",
"0.65390116",
"0.6532843",
"0.65252656",
"0.6520685",
"0.64811873",
"0.6474707",
"0.64741135",
"0.64188695",
"0.6416789",
"0.63997656",
"0.6397338",
"0.63885057",
"0.63879067",
"0.6386611",
"0.6381963",
"0.63534826",
"0.634433",
"0.63392496",
"0.6334398",
"0.63298154",
"0.63235325",
"0.6259873",
"0.6259873",
"0.62574893",
"0.6255571",
"0.6241383",
"0.62412256",
"0.6235935",
"0.62338316",
"0.62201536",
"0.62201536",
"0.621403",
"0.61887264",
"0.61753917",
"0.61753917",
"0.61753917",
"0.61753917",
"0.61753917",
"0.61753917",
"0.61753917",
"0.61753917",
"0.61753917",
"0.61753917",
"0.61753917",
"0.61753917",
"0.61753917",
"0.61753917",
"0.61738926",
"0.6170218",
"0.6164866",
"0.6152535",
"0.6144601",
"0.6143342",
"0.61427873",
"0.6140627",
"0.613433",
"0.6120427",
"0.6118931"
] |
0.0
|
-1
|
POST /ingredients POST /ingredients.json
|
def create
@ingredient = Ingredient.new(ingredient_params)
@ingredient.recipe = Recipe.find(ingredient_params[:recipe])
@ingredient.recipe.ingredients << @ingredient
save_relations
respond_to do |format|
if @ingredient.save
format.html { redirect_to @ingredient.recipe, notice: 'Ingredient was successfully added.' }
format.json { render :show, status: :created, location: @ingredient }
else
format.html { render :new }
format.json { render json: @ingredient.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n ingredient = Ingredient.create(ingredient_params)\n render json: ingredient\n end",
"def add_ingredients\n rid = params['id']\n name = params['name']\n quant = params['quantity']\n meas = params['measurement']\n\n ingredients = {\n 'name' => name,\n 'quantity' => quant,\n 'measurement' => meas,\n }\n\n if Aws.save_ingredient_to_db(rid, ingredients)\n msg = {:notice => \"Ingredient created!\"}\n render :json => msg\n else\n msg = {:notice => \"Error while creating ingredient!\"}\n render :json => msg\n end\n end",
"def create\n\t\t\t\trecipe = Recipe.new(recipe_params)\n\t\t\t\tingredients = params[:ingredients]\n\t\t\t\ttags = params[:tags]\n\t\t\t\t\n\t\t\t\tif recipe.save\n\t\t\t\t\tif !ingredients.blank?\n\t\t\t\t\t\tredirect_to api_v1_recipe_ingredients_url(recipe_id: recipe.id, ingredients: ingredients, tags: tags)\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\trender json: {status: 'ERROR', message: 'Recipe not saved', data: recipe.errors}, status: :unprocessable_entity\n\t\t\t\tend\n\t\t\tend",
"def create\n @recipe = Recipe.new(recipe_params)\n if params['ingredients']\n params['ingredients'].each do |ingredient_name|\n @recipe.ingredients << Ingredient.find_by(name: ingredient_name)\n end\n end\n\n @recipe.save \n redirect_to recipes_path\n end",
"def create\n recipeIngredient = rRcipeIngredient.create(recipeIngredient_params)\n render json: recipeIngredient\n end",
"def create\n @ingredient = Ingredient.new(params[:ingredient])\n\n respond_to do |format|\n if @ingredient.save\n format.html { redirect_to @ingredient, notice: 'Ingredient was successfully created.' }\n format.json { render json: @ingredient, status: :created, location: @ingredient }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ingredient = Ingredient.new(ingredient_params)\n\n respond_to do |format|\n if @ingredient.save\n format.html { redirect_to edit_receipe_url(@receipe), notice: 'Ingredient was successfully created.' }\n format.json { render :show, status: :created, location: @ingredient }\n else\n format.html { render :new }\n format.json { render json: @ingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @recipe = Recipe.new(recipe_params)\n # if params[:add_ingredient]\n # @recipe.ingredients.build\n # end\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render :show, status: :created, location: @recipe }\n else\n format.html { render :new }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n post_params = {\n name: params[:name].downcase,\n units: params[:units] || 0\n }\n render json: Ingredient.create!(post_params), status: :created\n end",
"def ingredient_params\n params.require(:ingredient).permit(:name, :recipe_ids => [])\n end",
"def create\n @ingredient = @bar.ingredients.new(ingredient_params)\n\n respond_to do |format|\n if @ingredient.save\n format.html { render :show, notice: 'Ingredient was successfully created.' }\n format.json { render :show, status: :created, location: @ingredient }\n else\n format.html { render :new }\n format.json { render json: @ingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n puts recipe_params[:ingredients], recipe_params[:recipe], recipe_params[:user_id]\n recipe = Recipe.create(recipe_params[:recipe])\n if(recipe.valid?)\n Ingredient.create_and_assign(recipe_params[:ingredients], recipe.id)\n newUR = UserRecipe.create(recipe_id: recipe.id, user_id: recipe_params[:user_id])\n render json: UserRecipeSerializer.new(newUR).to_serialized_json\n else\n render json: recipe.errors.full_messages\n end\n end",
"def create\n unless logged_in?\n render :file => 'public/401', :status => :unauthorized, :layout => false and return\n end\n\n @ingredient = Ingredient.new(ingredient_params)\n\n respond_to do |format|\n if @ingredient.save\n format.html { redirect_to Item.find(@recipe.item_id), notice: 'Ingredient was successfully added to the recipe.' }\n format.json { render :show, status: :created, location: @ingredient }\n else\n flash.now[:error] = 'Unable to save ingredient'\n format.html { redirect_to new_recipe_ingredient_path }\n format.json { render json: @ingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def ingredients_by_recipe\n recipe = Recipe.find(params[:id])\n render json: recipe.ingredients\n end",
"def create\n @recipe_ingredient = RecipeIngredient.new(params[:recipe_ingredient])\n\n respond_to do |format|\n if @recipe_ingredient.save\n format.html { redirect_to @recipe_ingredient, notice: 'Recipe ingredient was successfully created.' }\n format.json { render json: @recipe_ingredient, status: :created, location: @recipe_ingredient }\n else\n format.html { render action: \"new\" }\n format.json { render json: @recipe_ingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post_ingredient = @post.post_ingredients.build(post_ingredient_params)\n\n respond_to do |format|\n if @post_ingredient.save\n format.html { redirect_to post_post_ingredients_path(@post), notice: \"Post ingredient was successfully created.\" }\n format.json { render :show, status: :created, location: @post_ingredient }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @post_ingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def list_ingredients\n rid = params[:id]\n items = Aws.get_ingredients_from_db(rid)\n render :json => items\n end",
"def create\n @ingredient_recipe = IngredientRecipe.new(ingredient_recipe_params)\n\n respond_to do |format|\n if @ingredient_recipe.save\n format.html { redirect_to @ingredient_recipe, notice: 'Ingredient recipe was successfully created.' }\n format.json { render :show, status: :created, location: @ingredient_recipe }\n else\n format.html { render :new }\n format.json { render json: @ingredient_recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @recipe_ingredient = RecipeIngredient.new(recipe_ingredient_params)\n\n respond_to do |format|\n if @recipe_ingredient.save\n format.html { redirect_to @recipe_ingredient, notice: 'Recipe ingredient was successfully created.' }\n format.json { render :show, status: :created, location: @recipe_ingredient }\n else\n format.html { render :new }\n format.json { render json: @recipe_ingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ingredient = Ingredient.new(ingredient_params)\n\n respond_to do |format|\n if @ingredient.save\n format.html { redirect_to recipes_path, notice: 'Ingredient was successfully created.' }\n else\n format.html { render :new }\n end\n end\n end",
"def create\n @beverage = Beverage.new(params[:beverage])\n params[:ingredient].each{|ingr|\n @beverage.ingredients << Ingredient.find_by_name(ingr)\n } unless params[:ingredient].blank?\n\n\n respond_to do |format|\n if @beverage.save\n format.html { redirect_to @beverage, notice: 'Beverage was successfully created.' }\n format.json { render json: @beverage, status: :created, location: @beverage }\n else\n format.html { render action: \"new\" }\n format.json { render json: @beverage.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @recipe_ingredient = Recipe_ingredient.new(params[:recipe_ingredient])\n\n respond_to do |format|\n if @recipe_ingredient.save\n format.html { redirect_to @recipe_ingredient, notice: 'Recipe_ingredient was successfully created.' }\n format.json { render json: @recipe_ingredient, status: :created, location: @recipe_ingredient }\n else\n format.html { render action: \"new\" }\n format.json { render json: @recipe_ingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ingredient = Ingredient.new(params[:ingredient])\n @food = Food.find_by_name(params[:food][:name])\n @ingredient.food_id = @food.id if @food\n respond_to do |format|\n if @recipe.ingredients << @ingredient\n flash[:notice] = 'Ingredient was successfully added.'\n format.html { redirect_to recipe_url(@recipe) }\n format.js\n format.xml { head :created, :location => ingredient_url(@ingredient) }\n else\n format.html { render :action => \"new\" }\n format.js\n format.xml { render :xml => @ingredient.errors.to_xml }\n end\n end\n end",
"def create\n @recipeingredient = Recipeingredient.new(recipeingredient_params)\n\n respond_to do |format|\n if @recipeingredient.save\n format.html { redirect_to @recipeingredient, notice: 'Recipeingredient was successfully created.' }\n format.json { render :show, status: :created, location: @recipeingredient }\n else\n format.html { render :new }\n format.json { render json: @recipeingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n user = current_user\n if params[:id]\n @recipe = Recipe.new(name: params[:name],\n description: params[:description],\n ingredients: params[:indredients],\n instructions: params[:instructions],\n servings: params[:servings],\n original_id: params[:id])\n else\n @recipe = Recipe.new(recipe_params)\n end\n user.recipes << @recipe\n if user.save\n render json: @recipe, status: :created\n else\n render json: {message: \"something went wrong\"}\n end\n end",
"def create\n\n @ingredient = Ingredient.find_by_name(params[\"ingredient\"][\"name\"]) || Ingredient.new(params[\"ingredient\"])\n respond_to do |format|\n if @ingredient.save and Amount.create(params[\"amount\"].merge(:ingredient_id => @ingredient.id, :recipe_id => @recipe.id))\n flash[:notice] = 'Ingredient was successfully created.'\n format.html {render :partial => 'list_ingredients', :object => @ingredient}\n format.xml { render :xml => @ingredient, :status => :created, :location => @ingredient }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ingredient.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def ingredient_params\n params.require(:ingredient).permit(:name, :description, :tags)\n end",
"def create\n @bruschettum = Bruschettum.new(params[:bruschettum])\n params[:ingredient].each{|ingr|\n @bruschettum.ingredients << Ingredient.find_by_name(ingr)\n }\n\n\n respond_to do |format|\n if @bruschettum.save\n format.html { redirect_to @bruschettum, notice: 'Bruschetta è stata creata con successo.' }\n format.json { render json: @bruschettum, status: :created, location: @bruschettum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bruschettum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def ingredient_params\n params.require(:ingredient).permit(:name, :amount, :recipe_id)\n end",
"def create\n @recipe = Recipe.new(recipe_params)\n params[:recipe][:ingredients].each do |ingredient_id|\n next if ingredient_id.to_i == 0\n ingredient = Ingredient.find(ingredient_id.to_i)\n @recipe.ingredients << ingredient\n end\n params[:recipe][:gadgets].each do |gadget_id|\n next if gadget_id.to_i == 0\n gadget = Gadget.find(gadget_id.to_i)\n @recipe.gadgets << gadget\n end\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render action: 'show', status: :created, location: @recipe }\n else\n format.html { render action: 'new' }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @meal = Meal.find(params[:meal_id]) if params[:meal_id]\n @recipe = @meal ? @meal.recipes.create(params[:recipe]) : Recipe.new(params[:recipe])\n\n #@recipe.ingredients = params[:ingredients].map {|i| \n #Ingredient.new(:item => Food.find(i.delete(:item_id)), :quantity => i[:quantity]) unless i[:item_id].blank? \n #}.compact if params[:ingredients]\n\n @recipe.tags = params[:tags].split(/,/).map { |t|\n Tag.find_or_create_by_name(t.strip.downcase)\n }.compact if params[:tags]\n\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to @recipe}\n format.json { render json: @recipe, status: :created, location: @recipe }\n else\n format.html { render action: \"new\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @dis_ingredient = DisIngredient.new(dis_ingredient_params)\n\n respond_to do |format|\n if @dis_ingredient.save\n format.html { redirect_to @dis_ingredient, notice: 'Dis ingredient was successfully created.' }\n format.json { render :show, status: :created, location: @dis_ingredient }\n else\n format.html { render :new }\n format.json { render json: @dis_ingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @ingredient = Ingredient.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ingredient }\n end\n end",
"def create\n @recipe = current_user.recipes.new(recipe_params)\n\n respond_to do |format|\n if @recipe.save\n if params[:lista].present?\n params[:lista].each do |(c,ingrediente)|\n Ingredient.create(name: ingrediente, recipe_id:@recipe.id) if ingrediente != \"\"\n end\n end\n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render :show, status: :created, location: @recipe }\n format.js {flash.now[:notice] = 'La receta se ha creado de forma exitosa.'} #ajax\n else\n format.html { render :new }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n format.js {flash.now[:alert] = 'Error al crear la receta.'} #ajax\n end\n end\n end",
"def ingredient_params\n params.require(:ingredient).permit(:name)\n end",
"def ingredient_params\n params.require(:ingredient).permit(:name)\n end",
"def create\n @ingredients_name = IngredientsName.new(params[:ingredients_name])\n\n respond_to do |format|\n if @ingredients_name.save\n format.html { redirect_to @ingredients_name, notice: 'Ingredients name was successfully created.' }\n format.json { render json: @ingredients_name, status: :created, location: @ingredients_name }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ingredients_name.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @ingredients_name = IngredientsName.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ingredients_name }\n end\n end",
"def create\n @recipe = Recipe.new(recipe_params)\n\n respond_to do |format|\n if @recipe.save\n count = 1\n complete_directions = \"\"\n params[\"directions\"].each do |direction|\n complete_directions += direction + \"\\n\"\n count += 1\n end\n @recipe.directions = complete_directions\n params[\"ingredients\"].each_with_index do |ingredient, index|\n found = false\n Ingredient.all.each do |db_ingredient|\n if db_ingredient.name == ingredient\n @ingredient = db_ingredient\n Recipeingredient.create({:ingredient_id => @ingredient.id, :recipe_id => @recipe.id, :amount => params[\"amounts\"][index]})\n found = true\n end\n end\n if found == false\n @ingredient = Ingredient.create({:name => ingredient})\n Recipeingredient.create({:ingredient_id => @ingredient.id, :recipe_id => @recipe.id, :amount => params[\"amounts\"][index]})\n end\n end\n Userrecipe.create({:contribution_id => @recipe.id, :user_id => current_user.id})\n if params[\"tags\"] != nil\n params[\"tags\"].each do |tag|\n @tag = Tag.find_by_name(tag)\n Recipetag.create({:recipe_id => @recipe.id,:tag_id => @tag.id})\n end\n end\n @recipe.serves = params[\"serves\"]\n @recipe.save\n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render :show, status: :created, location: @recipe }\n else\n format.html { render :new }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def ingredient_params\n params.require(:ingredient).permit(:weight, :recipe, :description)\n end",
"def ing_params\n params.require(:ingredient).permit(:name)\n end",
"def update\n @recipe.ingredients.clear\n params['ingredients'].each do |ingredient_name|\n @recipe.ingredients << Ingredient.find_by(name: ingredient_name)\n end\n\n @recipe.update(recipe_params)\n redirect_to @recipe\n end",
"def recipe_params\n params.require(:recipe).permit(:name,:description, ingredient_ids: [])\n end",
"def ingredient_params\n params.require(:ingredient).permit(:name)\n end",
"def ingredient_params\n params.require(:ingredient).permit(:item_id, :qty, :recipe_id).merge({recipe_id: @recipe.id})\n end",
"def create\n @ingredient = Ingredient.new(params[:ingredient])\n\n respond_to do |format|\n if @ingredient.save\n format.html { redirect_to(@ingredient, :notice => 'Ingredient was successfully created.') }\n format.xml { render :xml => @ingredient, :status => :created, :location => @ingredient }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ingredient.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @ingredients_nutrient = IngredientsNutrient.new(ingredients_nutrient_params)\n\n respond_to do |format|\n if @ingredients_nutrient.save\n format.html { redirect_to @ingredients_nutrient, notice: 'Ingredients nutrient was successfully created.' }\n format.json { render action: 'show', status: :created, location: @ingredients_nutrient }\n else\n format.html { render action: 'new' }\n format.json { render json: @ingredients_nutrient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n recipe = Recipe.create(recipe_params)\n render json: recipe\n end",
"def create\n @ingredient = Ingredient.new(ingredient_params)\n\n respond_to do |format|\n if @ingredient.save\n format.html { redirect_to @ingredient, :flash =>{success:\"l'ingredient #{@ingredient.name} a été rajouté dans notre site...\"} }\n format.json { render :show, status: :created, location: @ingredient }\n else\n format.html { render :new }\n format.json { render json: @ingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def ingredient_params\n params.require(:ingredient).permit(:ingredientnom)\n end",
"def ingredient_params\n params[:ingredient][:ingredient_list] ||= [] \n params.require(:ingredient).permit(:name, ingredient_list: [])\n end",
"def ingredient_data\n respond_to do |format|\n format.json { render json: helpers.get_ingredient(params[:ingredient_type], params[:ingredient_id]) }\n end\n end",
"def recipeingredient_params\n params.require(:recipeingredient).permit(:recipe, :ingredient)\n end",
"def create\n @recipe_ingredients_unit = RecipeIngredientsUnit.new(recipe_ingredients_unit_params)\n\n respond_to do |format|\n if @recipe_ingredients_unit.save\n format.html { redirect_to recipe_ingredients_units_path, notice: 'Recipe ingredients unit was successfully created.' }\n format.json { render :show, status: :created, location: @recipe_ingredients_unit }\n else\n format.html { render :new }\n format.json { render json: @recipe_ingredients_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @recipeingredient = Recipe_ingredient.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recipe_ingredient }\n end\n end",
"def ingredient_recipe_params\n params.require(:ingredient_recipe).permit(:ingredient_id, :recipe_id)\n end",
"def create_ingredient(recipe_id, ingredients)\n\t\t\t\tdestroy_ingredients = RecipeIngredient.where(recipe_id: recipe_id)\n\t\t\t\tif !destroy_ingredients.blank? \n\t\t\t\t\tdestroy_ingredients.delete_all \n\t\t\t\tend\n\t\t\t\tingredients.each do |recipe_ingredient|\n\t\t\t\t\tingredient = RecipeIngredient.new\n\t\t\t\t\tingredient.recipe_id = recipe_id\n\t\t\t\t\tingredient.ingredient = recipe_ingredient\n\t\t\t\t\tingredient.save!\n\t\t\t\tend\n\t\t\tend",
"def update\n ingredient.update(ingredient_params)\n render json: ingredient\n end",
"def create\n @ingredient_list = IngredientList.new(ingredient_list_params)\n\n respond_to do |format|\n if @ingredient_list.save\n format.html { redirect_to @ingredient_list, notice: 'Ingredient list was successfully created.' }\n format.json { render :show, status: :created, location: @ingredient_list }\n else\n format.html { render :new }\n format.json { render json: @ingredient_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @recipe = Recipe.find(current_recipe)\n @recipe_ingredient = current_recipe.recipe_ingredients.build(ri_params)\n @obj = @recipe_ingredient\n if @recipe_ingredient.save\n #flash.alert = \"Ingredient added\"\n respond_to do |f|\n f.html {redirect_to current_recipe}\n f.js {@recipe_ingredient}\n end\n else\n #flash.now.alert = \"Error\"\n respond_to do |f|\n f.html{render 'shared/form'}\n f.js {@recipe_ingredient}\n end\n end\n end",
"def create\n @allergens_ingredient = AllergensIngredient.new(allergens_ingredient_params)\n\n respond_to do |format|\n if @allergens_ingredient.save\n format.html { redirect_to @allergens_ingredient, notice: 'Allergens ingredient was successfully created.' }\n format.json { render :show, status: :created, location: @allergens_ingredient }\n else\n format.html { render :new }\n format.json { render json: @allergens_ingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_ingredients(recipe, count: 2)\n (1..count).map do |i|\n create :ingredient, recipe_id: recipe.id\n end\n end",
"def ingredient_params\n params\n .require(:ingredient)\n .permit(:quantity, :product_id)\n .merge({receipe_id: @receipe.id})\n end",
"def new\n @recipe_ingredient = RecipeIngredient.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recipe_ingredient }\n end\n end",
"def create\n @platillo = Platillo.new(platillo_params)\n @ingredients = platillo_params[:ingredients_attributes]\n debug @ingredients\n\n @platilloIngrendiente = Ingredient.new(@ingredients)\n @platilloIngrendiente.save\n respond_to do |format|\n if @platillo.save\n format.html { redirect_to @platillo, notice: 'Platillo creado exitosamente' }\n format.json { render :show, status: :created, location: @platillo }\n else\n format.html { render :new }\n format.json { render json: @platillo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n @recipe = Recipe.new(recipe_params)\n @recipe.recipe_creator_id = current_user.id\n @recipe.allergies = get_allergies_from_params\n @recipe.ingredients = get_selected_ingredients\n\n #Shows an example on how to automatically check whether a recipe is suitable for a person with an intolerance\n laktoseintoleranz = Allergy.where(name: 'Laktoseintoleranz').first\n unless @recipe.allergies.include?(laktoseintoleranz)\n neo = Neography::Rest.new({:username => \"user\", :password => \"user\"})\n includes_laktose_ingredient = false\n\n @recipe.ingredients.each do |ingredient|\n node = neo.execute_query(\"MATCH (n)-[]->(i) WHERE n.name = 'Laktoseintoleranz' AND i.name = '#{ingredient.name}' RETURN i\")\n if node[\"data\"].present?\n includes_laktose_ingredient = true\n end\n end\n unless includes_laktose_ingredient\n @recipe.allergies << laktoseintoleranz\n end\n end\n\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render :show, status: :created, location: @recipe }\n else\n format.html { render :new }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @order = Order.new\n @order.ingredients.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def create\n @recipe = Recipe.new(params[:recipe])\n\n respond_to do |format|\n if @recipe.save\n Instruction.multi_save(params[:instructions], @recipe)\n Ingredient.multi_save(params[:ingredients], @recipe)\n current_user.recipes << @recipe\n current_user.save\n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render json: @recipe, status: :created, location: @recipe }\n else\n format.html { render action: \"new\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n #@recipe.ingredients = params[:recipe_ingredients].map {|k, v|\n #ingredient = @recipe.ingredients.find(k) || @recipe.ingredients.build\n #ingredient.update_attributes(:item => Food.find(v[:item_id]), :quantity => v[:quantity]) unless v[:item_id].blank?\n #ingredient\n #}.compact if params[:ingredients]\n\n @recipe.tags = params[:tags].split(/,/).map { |t|\n Tag.find_or_create_by_name(t.strip.downcase)\n }.compact if params[:tags]\n\n respond_to do |format|\n if @recipe.update_attributes(params[:recipe])\n format.html { redirect_to @recipe }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def recipe_params\n params.require(:recipe).permit(\n :title, \n :description, \n :instructions, \n :ingredient_count, \n ingredient_ids: [],\n ingredients_attributes: [\n :name, \n :description, \n recipe_ingredients_attributes: [\n :quantity\n ]\n ]\n \n )\n end",
"def createRecipeFromAPI(randRecipe)\n # make a recipe obj to create for our DB\n recipe = Recipe.create(title: randRecipe[\"title\"], cookbook: Cookbook.all.sample, instructions: randRecipe[\"instructions\"])\n photo = Photo.create(recipe: recipe, img_url: randRecipe[\"image\"], description: \"test photo\")\n ingredients = randRecipe[\"extendedIngredients\"].map do |ing| \n ingredient = Ingredient.find_or_create_by(name: ing[\"name\"].titlecase)\n ri = RecipeIngredient.create(recipe: recipe, ingredient: ingredient, quantity: \"#{ing[\"amount\"]} #{ing[\"unit\"]}\")\n end\nend",
"def recipe_params\n params.require(:recipe).permit(:name, :body, :foto, ingredients_attributes: Ingredient.attribute_names.map(&:to_sym).push(:_destroy))\n end",
"def recipeIngredient_params\n params.require(:recipeIngredient).permit(:recipe_id, :ingredient_id, :amount_of_ingredient)\n end",
"def ingredient_params\n params.require(:ingredient).permit(:Item, :Prep)\n end",
"def post_spoonacular\n # %encode ingredients to url\n encoded_ingr = URI.escape(@translated_recipe[:ingredients_list])\n # post call block :\n url = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/parseIngredients?includeNutrition=true\")\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Post.new(url)\n request[\"content-type\"] = \"application/x-www-form-urlencoded\"\n request[\"x-rapidapi-key\"] = ENV[\"X_RAPIDAPI_KEY\"]\n request[\"x-rapidapi-host\"] = \"spoonacular-recipe-food-nutrition-v1.p.rapidapi.com\"\n # body of the call with ingredients and servings\n request.body = \"ingredientList=#{encoded_ingr}&#{@recipe_hash[:servings]}\"\n # response\n response = http.request(request)\n end",
"def create\n @measured_ingredient = MeasuredIngredient.new(measured_ingredient_params)\n\n respond_to do |format|\n if @measured_ingredient.save\n format.html { redirect_to @measured_ingredient, notice: 'Measured ingredient was successfully created.' }\n format.json { render :show, status: :created, location: @measured_ingredient }\n else\n format.html { render :new }\n format.json { render json: @measured_ingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def ingredient_params\n ActiveModelSerializers::Deserialization.jsonapi_parse!(params, only: [:name, :location, :category])\n end",
"def ingredient_params\n params.require(:ingredient).permit(:name, :amount, :min_amount, :amount_type, :min_amount_type, :user_id, :product_id)\n end",
"def create\n\t\tif Recipe.find_by({api_id: params[:api_id]})\n\t\t\tflash[:error] = \"Recipe '#{params[:name]}' already exists in your saved recipes.\"\n\t\telse\n\t\t\t@recipe = Recipe.new(recipe_params)\n\t\t\tif @recipe.save\n\t\t\t\tids = params[:inventories].split(\",\")\n\t\t\t\tfor index in 0...ids.length\n\t\t\t\t\t@recipe.inventories << Inventory.where({id: ids[index].to_i})\n\t\t\t\tend\n\n\t\t\t\trender json: @recipe\n\t\t\telse\n\t\t\t\trender status: 400, nothing: true\n\t\t\tend\n\t\tend\n\tend",
"def create\n @ingredient = Ingredient.find(params[:id])\n \n @supplier.ingredients << @ingredient\n redirect_to supplier_path(@supplier)\n end",
"def recipe_params\n params.require(:recipe).permit(:title, :description, :image, tag_ids:[], ingredients_attributes:[:id, :name, :amount, :_destroy], directions_attributes:[:id, :step, :_destroy])\n end",
"def new\n #@aliments = Aliment.order(\"name ASC\").all\n @repa = Repa.new\n @ingredient = @repa.ingredients.build\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @repa }\n end\n end",
"def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n params[:recipe][:ingredients].each do |ingredient_id|\n next if ingredient_id.to_i == 0\n ingredient = Ingredient.find(ingredient_id.to_i)\n @recipe.ingredients << ingredient\n end\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def ingredient_params\n params.require(:ingredient).permit(:name, :amount, :unit, :addTime)\n end",
"def recipe_ingredient_params\n params.require(:recipe_ingredient).permit(:amount, :amount)\n end",
"def ingredient_params\n params.require(:ingredient).permit(:recipe_id, :piece_kind, :parent_id)\n end",
"def create\n @ingredient = Ingredient.new(ingredient_params)\n\n\n if @ingredient.save\n flash[:success] = \"Ajout de l'ingredient réussi...\"\n redirect_to ingredient_path @ingredient\n else\n flash[:success] = \"Ajout de l'ingredient réussi...\"\n render :new \n end\n\n end",
"def getRecipeByIngredientsList\n begin\n ingredientsList = params[:ingredients].split(\",\")\n\n @recipe = []\n ingredientsList.each do |ingredient|\n @recipe.push(Recipe.where('ingredients ILIKE ?', '%'+ingredient+'%').all)\n end\n \n if !@recipe.empty?\n render json: { status: 'SUCCESS', message: 'Loaded recipe!', data: @recipe }, status: :ok\n else\n render json: { status: 'SUCCESS', message: 'No recipe found', data: {} }, status: :not_found\n end\n rescue\n render json: { status: 'ERROR', message: 'Error loading recipe', data: {} }, status: :not_found\n end\n end",
"def show \n\n # @recipe.ingredients.build\n @new_ingredient = Ingredient.new\n @new_ingredient.recipe = @recipe\n\n # @flag = @recipe.flags.create\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe }\n end\n end",
"def add_ingredients(ingredients)\n ingredients.each { |i| RecipeIngredient.new(self, i) }\n end",
"def recipe_params\n params.require(:recipe).permit(:name, :url, :instructions, :picture_url, :menu_type, allergy_ids: [], ingredient_ids: [])\n end",
"def recipe_params\n params.require(:recipe).permit(:user_id, :title, :image_url, :description, :cuisine_id, :category_id, :cook_time, :serving_num, :instruction, :ingredients_attributes => [:id, :recipe_id, :quantity, :unit, :item_id, :_destroy, :item_attributes => [:name]])\n end",
"def create\n @ingredient_suggestion = IngredientSuggestion.new(ingredient_suggestion_params)\n\n respond_to do |format|\n if @ingredient_suggestion.save\n format.html { redirect_to @ingredient_suggestion, notice: 'Ingredient suggestion was successfully created.' }\n format.json { render :show, status: :created, location: @ingredient_suggestion }\n else\n format.html { render :new }\n format.json { render json: @ingredient_suggestion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index \n ingredients = Ingredient.all\n #render will return the object back in json format so that it can be used by the frontend\n render json: ingredients\n end",
"def dis_ingredient_params\n params.require(:dis_ingredient).permit(:name, :status_id)\n end",
"def ingredients_nutrient_params\n params.require(:ingredients_nutrient).permit(:ingredient_id, :nutrient_id, :valor)\n end",
"def ingredient_list_params\n params.require(:ingredientList).permit(ingredient_attributes: %i[id product_id])\n end",
"def add_ingredients(ingredients)\n ingredients.each do |ingredient|\n RecipeIngredient.new(self, ingredient)\n end\n end",
"def ingredient_nutrient_params\n params.require(:ingredient_nutrient).permit(:nutrient_id, :ingredient_id)\n end",
"def create\n \n if params[\"donor\"]\n @recipe = Recipe.find(params[\"donor\"]).clone_with_ingredients(params[\"recipe\"])\n @recipe.user = current_user\n\n else\n @recipe = Recipe.new(params[\"recipe\"])\n end\n\n @recipe.user = current_user\n\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render json: @recipe, status: :created, location: @recipe }\n else\n format.html { render action: \"new\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.7749055",
"0.7590346",
"0.7465898",
"0.74050695",
"0.73933405",
"0.7167695",
"0.716602",
"0.71002847",
"0.7087613",
"0.70036024",
"0.6972241",
"0.69679314",
"0.6920982",
"0.6916151",
"0.68945533",
"0.68943995",
"0.6876029",
"0.68722105",
"0.6858264",
"0.6791807",
"0.6787366",
"0.67846566",
"0.6781505",
"0.6759207",
"0.67467713",
"0.6736142",
"0.6710274",
"0.6678222",
"0.66765743",
"0.66663045",
"0.66427916",
"0.6641802",
"0.66147316",
"0.6588057",
"0.65867484",
"0.65867484",
"0.6580019",
"0.6571684",
"0.6561678",
"0.65556943",
"0.65554404",
"0.6554885",
"0.6534092",
"0.65238076",
"0.6506128",
"0.64913255",
"0.6474806",
"0.64742535",
"0.646923",
"0.64659864",
"0.6464342",
"0.64619935",
"0.64576983",
"0.64538497",
"0.64392626",
"0.6418753",
"0.640721",
"0.6377749",
"0.63733876",
"0.6344832",
"0.63415295",
"0.633752",
"0.63358176",
"0.6334944",
"0.63286304",
"0.63217217",
"0.6321458",
"0.6320078",
"0.6297818",
"0.6273585",
"0.62680846",
"0.62674606",
"0.626392",
"0.6263307",
"0.6259011",
"0.6257557",
"0.6221439",
"0.6219656",
"0.6215867",
"0.6210901",
"0.62054706",
"0.61798465",
"0.61746967",
"0.6169916",
"0.61666614",
"0.6156092",
"0.6150832",
"0.61431247",
"0.61382675",
"0.6120789",
"0.611021",
"0.61093843",
"0.60970736",
"0.60901785",
"0.608604",
"0.6074867",
"0.6043623",
"0.6039722",
"0.60363436",
"0.6035696"
] |
0.7286979
|
5
|
PATCH/PUT /ingredients/1 PATCH/PUT /ingredients/1.json
|
def update
respond_to do |format|
save_relations
if @ingredient.update(ingredient_params)
format.html { redirect_to @ingredient.recipe, notice: 'Ingredient was successfully updated.' }
format.json { render :show, status: :ok, location: @ingredient }
else
format.html { render :edit }
format.json { render json: @ingredient.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n ingredient.update(ingredient_params)\n render json: ingredient\n end",
"def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n params[:recipe][:ingredients].each do |ingredient_id|\n next if ingredient_id.to_i == 0\n ingredient = Ingredient.find(ingredient_id.to_i)\n @recipe.ingredients << ingredient\n end\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n params[:recipe][:ingredient_ids] ||= []\n @recipe = Recipe.find(params[:id])\n\n respond_to do |format|\n if @recipe.update_attributes(params[:recipe])\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ingredient = Ingredient.find(params[:id])\n\n respond_to do |format|\n if @ingredient.update_attributes(params[:ingredient])\n format.html { redirect_to @ingredient, notice: 'Ingredient was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @recipe.ingredients.clear\n params['ingredients'].each do |ingredient_name|\n @recipe.ingredients << Ingredient.find_by(name: ingredient_name)\n end\n\n @recipe.update(recipe_params)\n redirect_to @recipe\n end",
"def update\n\n #@recipe.ingredients = params[:recipe_ingredients].map {|k, v|\n #ingredient = @recipe.ingredients.find(k) || @recipe.ingredients.build\n #ingredient.update_attributes(:item => Food.find(v[:item_id]), :quantity => v[:quantity]) unless v[:item_id].blank?\n #ingredient\n #}.compact if params[:ingredients]\n\n @recipe.tags = params[:tags].split(/,/).map { |t|\n Tag.find_or_create_by_name(t.strip.downcase)\n }.compact if params[:tags]\n\n respond_to do |format|\n if @recipe.update_attributes(params[:recipe])\n format.html { redirect_to @recipe }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @beverage = Beverage.find(params[:id])\n @beverage.ingredients.clear\n params[:ingredient].each{|ingr|\n @beverage.ingredients << Ingredient.find_by_name(ingr)\n } unless params[:ingredient].blank?\n\n respond_to do |format|\n if @beverage.update_attributes(params[:beverage])\n format.html { redirect_to @beverage, notice: 'Beverage was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @beverage.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @recipe_ingredient = RecipeIngredient.find(params[:id])\n\n respond_to do |format|\n if @recipe_ingredient.update_attributes(params[:recipe_ingredient])\n format.html { redirect_to @recipe_ingredient, notice: 'Recipe ingredient was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recipe_ingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n recipe.update(recipe_params)\n render json: recipe\n end",
"def update\n authorize @ingredient.recipe\n respond_to do |format|\n if @ingredient.update(ingredient_params)\n format.html { redirect_to @ingredient}\n format.json { render :show, status: :ok, location: @ingredient }\n else\n format.html { render :edit }\n format.json { render json: @ingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @recipe_ingredient = Recipe_ingredient.find(params[:id])\n\n respond_to do |format|\n if @recipe_ingredient.update_attributes(params[:recipe_ingredient])\n format.html { redirect_to @recipe_ingredient, notice: 'Recipe_ingredient was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recipe_ingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ingredient.update(ingredient_params)\n format.html { redirect_to @ingredient, notice: 'Ingredient was successfully updated.' }\n format.json { render :show, status: :ok, location: @ingredient }\n else\n format.html { render :edit }\n format.json { render json: @ingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\t\t\trecipe = Recipe.find(params[:id])\n\t\t\t\tingredients = params[:ingredients]\n\t\t\t\ttags = params[:tags]\n\n\t\t\t\tif recipe.update_attributes(recipe_params)\n\t\t\t\t\tif !ingredients.blank?\n\t\t\t\t\t\tcreate_ingredient(recipe.id, ingredients)\n\t\t\t\t\tend\n\n\t\t\t\t\tif !tags.blank?\n\t\t\t\t\t\tcreate_tag(recipe.id, tags)\n\t\t\t\t\tend\n\n\t\t\t\t\trender json: {status: 'SUCCESS', message: 'Updated recipe', data: get_recipe_by_id(recipe.id)}, status: :ok\n\t\t\t\telse\n\t\t\t\t\trender json: {status: 'ERROR', message: 'Recipe not updated', data: recipe.errors}, status: :unprocessable_entity\n\t\t\t\tend\n\t\t\tend",
"def update\n @bruschettum = Bruschettum.find(params[:id])\n @bruschettum.ingredients.clear\n params[:ingredient].each{|ingr|\n @bruschettum.ingredients << Ingredient.find_by_name(ingr)\n }\n\n respond_to do |format|\n if @bruschettum.update_attributes(params[:bruschettum])\n format.html { redirect_to @bruschettum, notice: 'Bruschettum was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bruschettum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recipe_ingredient.update(recipe_ingredient_params)\n format.html { redirect_to @recipe_ingredient, notice: 'Recipe ingredient was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe_ingredient }\n else\n format.html { render :edit }\n format.json { render json: @recipe_ingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ingredient = Ingredient.find(params[:id])\n\n respond_to do |format|\n if @ingredient.update_attributes(params[:ingredient])\n format.html { redirect_to(@ingredient, :notice => 'Ingredient was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ingredient.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ingredient.update(ingredient_params)\n format.html { redirect_to user_bar_ingredients_url, notice: 'Ingredient was successfully updated.' }\n format.json { render :show, status: :ok, location: @ingredient }\n else\n format.html { render :edit }\n format.json { render json: @ingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ingredients_name = IngredientsName.find(params[:id])\n\n respond_to do |format|\n if @ingredients_name.update_attributes(params[:ingredients_name])\n format.html { redirect_to @ingredients_name, notice: 'Ingredients name was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ingredients_name.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @recipe = current_user.recipes.find(params[:id])\n respond_to do |format|\n if @recipe.update_attributes(params[:recipe])\n \n unless params[:instructions].nil?\n @recipe.instructions.delete_all\n Instruction.multi_save(params[:instructions], @recipe)\n end\n \n unless params[:ingredients].nil?\n @recipe.ingredients.delete_all\n Ingredient.multi_save(params[:ingredients], @recipe)\n end\n\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { render json: {:recipe => @recipe, :tags => @recipe.tag_list} }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recipeingredient.update(recipeingredient_params)\n format.html { redirect_to @recipeingredient, notice: 'Recipeingredient was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipeingredient }\n else\n format.html { render :edit }\n format.json { render json: @recipeingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ingredients_nutrient.update(ingredients_nutrient_params)\n format.html { redirect_to @ingredients_nutrient, notice: 'Ingredients nutrient was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @ingredients_nutrient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ingredient_recipe.update(ingredient_recipe_params)\n format.html { redirect_to @ingredient_recipe, notice: 'Ingredient recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @ingredient_recipe }\n else\n format.html { render :edit }\n format.json { render json: @ingredient_recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @data = @recipe.update(params[:id], recipe_params)\n render json: @data\n end",
"def update\n unless logged_in?\n render :file => 'public/401', :status => :unauthorized, :layout => false and return\n end\n\n respond_to do |format|\n if @ingredient.update(ingredient_params)\n format.html { redirect_to Item.find(@recipe.item_id), notice: 'Ingredient was successfully updated.' }\n format.json { render :show, status: :ok, location: [@recipe, @ingredient] }\n else\n format.html { render :edit }\n format.json { render json: @ingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(attributes: {})\n attributes = attributes.with_indifferent_access\n clean_attributes(attributes)\n titleize(attributes)\n sync_tags(attributes)\n parse_ingredients(attributes)\n recipe.update(attributes)\n recipe_response\n rescue StandardError => e\n error_response(e)\n end",
"def update\n @ingredient = Ingredient.find(params[:id])\n\n respond_to do |format|\n if @ingredient.update_attributes(params[:ingredient])\n flash[:notice] = 'Ingredient was successfully updated.'\n format.html { redirect_to recipe_url(@recipe) }\n format.js\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.js\n format.xml { render :xml => @ingredient.errors.to_xml }\n end\n end\n end",
"def update\n @ingredient = Ingredient.find(params[:id])\n @amount = Amount.find(@ingredient)\n\n respond_to do |format|\n if @ingredient.update_attributes(params[:ingredient]) and @amount.update_attributes(params[\"amount\"].merge(:ingredient_id => @ingredient.id, :recipe_id => @recipe.id ))\n flash[:notice] = 'Ingredient was successfully updated.'\n format.html { redirect_to(@recipe) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ingredient.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n begin\n recipe = Recipe.find(params[:id])\n\n if recipe.update_attributes(recipe_params)\n render json: { status: 'SUCCESS', message: 'Recipe updated!', data: recipe }, status: :ok\n else\n render json: { status: 'ERROR', message: 'Error updating recipe', data: recipe.errors }, status: :unprocessable_entity\n end\n rescue\n render json: { status: 'ERROR', message: 'Error finding recipe', data: {} }, status: :not_found\n end\n end",
"def update\n @recipe = Recipe.find(params[:id])\n @recipe.ingrediences = Ingredience.find(params[:ingredience_ids]) if params[:ingredience_ids] \n respond_to do |format|\n if @recipe.update_attributes(params[:recipe])\n flash[:notice] = 'Recipe was successfully updated.'\n format.html { redirect_to(@recipe) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @recipe.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @post_ingredient.update(post_ingredient_params)\n format.html { redirect_to post_post_ingredient_path(@post), notice: \"Post ingredient was successfully updated.\" }\n format.json { render :show, status: :ok, location: @post_ingredient }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @post_ingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @dis_ingredient.update(dis_ingredient_params)\n format.html { redirect_to @dis_ingredient, notice: 'Dis ingredient was successfully updated.' }\n format.json { render :show, status: :ok, location: @dis_ingredient }\n else\n format.html { render :edit }\n format.json { render json: @dis_ingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ingredient = Ingredient.find(params[:id])\n\n respond_to do |format|\n if @ingredient.update_attributes(params[:ingredient])\n flash[:notice] = l(:flash_notice_ingredient_updated)\n format.html { redirect_to [ @ingredient_category, Ingredient.new ] }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ingredient.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @allergens_ingredient.update(allergens_ingredient_params)\n format.html { redirect_to @allergens_ingredient, notice: 'Allergens ingredient was successfully updated.' }\n format.json { render :show, status: :ok, location: @allergens_ingredient }\n else\n format.html { render :edit }\n format.json { render json: @allergens_ingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n save_relations\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @recipe = Recipe.find(params[:id])\n\n respond_to do |format|\n if @recipe.update_attributes(params[:recipe])\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @recipe = Recipe.find(params[:id])\n\n respond_to do |format|\n if @recipe.update_attributes(params[:recipe])\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @recipe = Recipe.find(params[:id])\n\n respond_to do |format|\n if @recipe.update_attributes(params[:recipe])\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @recipe = Recipe.find(params[:id])\n\n respond_to do |format|\n if @recipe.update_attributes(params[:recipe])\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @recipe = Recipe.find(current_recipe)\n @recipe_ingredient = current_recipe.recipe_ingredients.find(params[:id])\n @obj = @recipe_ingredient\n if(@recipe_ingredient.update(ri_params))\n #flash.alert = \"Record Updated\"\n respond_to do |f|\n f.html {redirect_to current_recipe}\n f.js {@recipe}\n end\n else\n #flash.now.alert = \"Error\"\n respond_to do |f|\n f.html {render 'shared/form'}\n f.js {@recipe}\n end\n end\n end",
"def update\n respond_to do |format|\n if @recipe_ingredients_unit.update(recipe_ingredients_unit_params)\n format.html { redirect_to recipe_ingredients_units_path, notice: 'Recipe ingredients unit was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe_ingredients_unit }\n else\n format.html { render :edit }\n format.json { render json: @recipe_ingredients_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @barbecue_ingredient.update(barbecue_ingredient_params)\n format.html { redirect_to @barbecue_ingredient, notice: 'Barbecue ingredient was successfully updated.' }\n format.json { render :show, status: :ok, location: @barbecue_ingredient }\n else\n format.html { render :edit }\n format.json { render json: @barbecue_ingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n recipe = Recipe.find(params[:id])\n\n if recipe.user == current_user\n recipe.update(recipe_params)\n render json: { recipe: params[:id], deleted: true }\n else\n render json: { recipe: params[:id], deleted: false }\n end\n end",
"def update\n respond_to do |format|\n update_recipe_line_items\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @measured_ingredient.update(measured_ingredient_params)\n format.html { redirect_to @measured_ingredient, notice: 'Measured ingredient was successfully updated.' }\n format.json { render :show, status: :ok, location: @measured_ingredient }\n else\n format.html { render :edit }\n format.json { render json: @measured_ingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @recipe = Recipe.find(params[:id])\n @recipe.update(recipe_params)\n redirect_to new_ingredient_path\n end",
"def update\n @meal = @meal_recipe.meal\n @meal_plan = @meal.day.meal_plan\n @leftover = Leftover.meal_recipe(@meal_recipe).first\n @meal_ingredient = MealIngredient.new\n\n respond_to do |format|\n if params[:meal_recipe][:multiply].present?\n multiply_portions_and_ingredients(params[:meal_recipe][:multiply].to_d)\n end\n\n if params[:meal_recipe][:add].present?\n # @meal_recipe = MealRecipe.find(params[:id])\n @portions = @meal_recipe.portions\n ratio_increase = 1 + 1/@portions\n multiply_portions_and_ingredients(ratio_increase)\n end\n\n \n if @meal_recipe.update(meal_recipe_params)\n format.turbo_stream\n format.html { redirect_to @meal_recipe, notice: \"Meal recipe was successfully updated.\" }\n format.json { render :show, status: :ok, location: @meal_recipe }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @meal_recipe.errors, status: :unprocessable_entity }\n end\n \n end\n end",
"def update\n @food_recipe = FoodRecipe.find(params[:id])\n\n respond_to do |format|\n if @food_recipe.update_attributes(params[:food_recipe])\n format.html { redirect_to @food_recipe, notice: 'Food recipe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @food_recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n\n if params[:lista].present?\n params[:lista].each do |(c,ingrediente)|\n Ingredient.create(name: ingrediente, recipe_id:@recipe.id) if ingrediente != \"\"\n end\n end\n\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n format.js {flash.now[:notice] = 'La receta se ha actualizado de forma exitosa.'} \n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n format.js {flash.now[:alert] = 'Error al actuar la receta.'} \n end\n end\n end",
"def update\n @recipe = Recipe.find(params[:id])\n\n respond_to do |format|\n if @recipe.update_attributes(params[:recipe])\n format.html { redirect_to edit_recipe_path(@recipe), notice: 'Recipe was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ingredient_list.update(ingredient_list_params)\n format.html { redirect_to @ingredient_list, notice: 'Ingredient list was successfully updated.' }\n format.json { render :show, status: :ok, location: @ingredient_list }\n else\n format.html { render :edit }\n format.json { render json: @ingredient_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ingredient = Ingredient.find(params[:id])\n @obj = @ingredient\n if(@ingredient.update_attributes(ing_params))\n flash.alert = \"Ingredient updated\"\n redirect_back_or ingredients_path\n else\n flash.now.alert = \"Form Error\"\n render 'shared/form'\n end\n end",
"def update\n respond_to do |format|\n if @ingredient.update(ingredient_params)\n format.html { redirect_to @ingredient, :flash =>{success:\"l'ingredient #{@ingredient.name} a été mise à jour...\"} }\n format.json { render :show, status: :ok, location: @ingredient }\n else\n format.html { render :edit }\n format.json { render json: @ingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cooking_ingredient.update_attributes(params[:cooking_ingredient])\n format.xml { head :ok }\n format.html {\n if @cooking_recipe\n redirect_to(edit_cooking_recipe_path(@cooking_recipe))\n else\n redirect_to(@cooking_ingredient, :notice => 'CookingIngredient was successfully updated.')\n end\n }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @cooking_ingredient.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def edit(id, options = {})\n optional = [:label,\n :description,\n :compatible_with,\n :script_type\n ]\n params.accepts(optional).validate! options\n request(:put, \"/recipes/#{id}.json\", default_params(options))\n end",
"def update_ingredients(hash)\n hash.each do |h|\n ingredient = Ingredient.find_by!(id: h[:id])\n ingredient.update!(quantity: h[:quantity])\n end\n end",
"def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n calculate_nutrients \n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n count = 1\n complete_directions = \"\"\n params[\"directions\"].each do |direction|\n complete_directions += direction + \"\\n\"\n count += 1\n end\n @ingredientnames = []\n @recipe.ingredients.each do |ingredient|\n @ingredientnames << ingredient.name\n end\n params[\"ingredients\"].each_with_index do |ingredient, index|\n if !@ingredientnames.include? ingredient and ingredient != \"\"\n found = false\n Ingredient.all.each do |db_ingredient|\n if db_ingredient.name == ingredient\n @ingredient = db_ingredient\n Recipeingredient.create({:ingredient_id => @ingredient.id, :recipe_id => @recipe.id, :amount => params[\"amounts\"][index]})\n found = true\n end\n end\n if found == false\n @ingredient = Ingredient.create({:name => ingredient})\n Recipeingredient.create({:ingredient_id => @ingredient.id, :recipe_id => @recipe.id, :amount => params[\"amounts\"][index]})\n end\n else\n if ingredient != \"\"\n @ingredient = Ingredient.find_by_name(ingredient)\n @recipe.recipeingredients.each do |recipeingredient|\n if recipeingredient.ingredient_id == @ingredient.id\n recipeingredient.update({:amount =>params[\"amounts\"][index]})\n recipeingredient.save\n end\n end\n end\n end\n end\n @ingredientnames.each do |ingredient|\n if !params[\"ingredients\"].include?(ingredient)\n @ingredient = Ingredient.find_by_name(ingredient)\n @recipe.recipeingredients.each do |recipeingredient|\n if recipeingredient.ingredient_id == @ingredient.id\n recipeingredient.destroy\n if @ingredient.recipeingredients == nil\n @ingredient.destroy\n end\n end\n end\n end\n end\n tags = []\n if params[\"tags\"] != nil\n params[\"tags\"].each do |tag|\n a = Tag.find_by_name(tag)\n tags << a\n if !@recipe.tags.include? a\n Recipetag.create({:recipe_id => @recipe.id, :tag_id => a.id })\n end\n end\n end\n @recipe.tags.each do |tag|\n if !tags.include? tag\n @recipe.recipetags.each do |recipetag|\n if recipetag.tag_id == tag.id\n recipetag.destroy\n end\n end\n end\n end\n @recipe.serves = params[\"serves\"]\n @recipe.name =params[\"name\"]\n @recipe.directions = params[\"directions\"].join(\"\\n\")\n @recipe.save\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # @recipe = Recipe.find(params[:id])\n #\n update! do |success, failure|\n # success.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n # success.json { head :ok }\n # failure.html { render action: \"edit\" }\n # failure.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end",
"def update\n respond_to do |format|\n if @recipe.update_attributes(params[:recipe])\n format.html { redirect_to recipes_path, notice: 'Recipe successfully changed!!' }\n format.json { render json: @recipe }\n else\n #flash[:notice] = 'Recipe has not been changed!'\n format.html { render action: :edit }\n format.json { render json: @recipe.errors }\n end\n end\n end",
"def edit\n @page_title = \"Edit Recipe Ingredient\"\n @recipe_ingredient = current_recipe.recipe_ingredients.find(params[:id])\n @btnText = \"Update Ingredient\"\n @obj = @recipe_ingredient\n respond_to do |f|\n f.html {render 'shared/form'}\n f.js\n end\n end",
"def update\n @step_ingredient = StepIngredient.find(params[:id])\n\n respond_to do |format|\n if @step_ingredient.update_attributes(params[:step_ingredient])\n format.html { redirect_to(@step_ingredient, :notice => 'Step ingredient was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @step_ingredient.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n format.html { redirect_to recipes_path, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: \"Recipe was successfully updated.\" }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: \"Recipe was successfully updated.\" }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: \"Recipe was successfully updated.\" }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n format.html { redirect_to recipes_url, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def edit\n @page_title = \"Edit Ingredeient\"\n @ingredient = Ingredient.find(params[:id])\n @btnText = \"Update Ingredient\"\n @obj = @ingredient\n render 'shared/form'\n end",
"def update\n respond_to do |format|\n if @potluck_recipe.update(potluck_recipe_params)\n format.html { redirect_to @potluck_recipe, notice: 'Potluck recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @potluck_recipe }\n else\n format.html { render :edit }\n format.json { render json: @potluck_recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def ingredients_by_recipe\n recipe = Recipe.find(params[:id])\n render json: recipe.ingredients\n end",
"def update\n #if you query the Recipe db by the id, and the id is present then...\n if (@single_recipe_to_update = Recipe.find_by_id(params[:id])).present?\n # ... run the recipe_params function within the update function. it takes the input values from recipe_params and\n # updates that information the db\n @single_recipe_to_update.update(recipe_params)\n render :json => {\n :response => \"Successfully updated recipe.\",\n :data => @single_recipe_to_update # return the recipe with updated info\n }\n else\n render :json => {\n :response => \"Cannot find this record.\"\n }\n end\n end",
"def ingredient_params\n params.require(:ingredient).permit(:item_id, :qty, :recipe_id).merge({recipe_id: @recipe.id})\n end",
"def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end",
"def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end",
"def update\n @bowl = Bowl.find(params[:id])\n \n # set bowl modify time\n @bowl.modified = Time.now\n \n respond_to do |format|\n if @bowl.update_attributes(params[:bowl])\n \n Rails.logger.info \"Updating Bowl Contents\"\n \n # remove all contents for this bowl and add new\n @bowl.contents.delete_all(\"bowl_id=\" + @bowl.id)\n \n params.keys.each do |param|\n if param.start_with?(\"input_\") and (params[param] != \"\") \n @bowl.contents.create(:bowl_id => @bowl.id, :dryfruit_id => param[6, 2], :quantity => params[param]) \n end\n end\n\n format.html { redirect_to bowls_path, :notice => 'Bowl was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @bowl.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recipes_food.update(recipes_food_params)\n format.html { redirect_to @recipes_food, notice: 'Recipes food was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipes_food }\n else\n format.html { render :edit }\n format.json { render json: @recipes_food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end",
"def update\n \n if @ingredient.update(ingredient_params)\n flash[:success] = \"M.a.j de l'ingredient réussi...\"\n redirect_to ingredient_path @ingredient\n else\n render :edit\n end\n\n end",
"def ingredient_params\n params.require(:ingredient).permit(:name, :recipe_ids => [])\n end",
"def ingredient_params\n params.require(:ingredient).permit(:name, :amount, :recipe_id)\n end",
"def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end",
"def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end",
"def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end",
"def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end",
"def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end",
"def set_ingredient\n @ingredient = Ingredient.find(params[:id])\n end"
] |
[
"0.7534066",
"0.7481154",
"0.7282842",
"0.7218124",
"0.716812",
"0.7153985",
"0.7069031",
"0.70139724",
"0.6955492",
"0.69382715",
"0.6930377",
"0.6907371",
"0.68695575",
"0.68323964",
"0.68057036",
"0.6788979",
"0.6773863",
"0.67670363",
"0.675039",
"0.6748699",
"0.6729589",
"0.67126256",
"0.6706944",
"0.66574246",
"0.6630453",
"0.6594646",
"0.6580227",
"0.65798444",
"0.6521715",
"0.6501145",
"0.6483168",
"0.64206547",
"0.6369922",
"0.6352304",
"0.6335765",
"0.6335765",
"0.6335765",
"0.6335765",
"0.6330176",
"0.6328894",
"0.63205826",
"0.6305574",
"0.6290389",
"0.6284304",
"0.626235",
"0.62610203",
"0.62554187",
"0.62472606",
"0.6239024",
"0.623283",
"0.6228453",
"0.6225199",
"0.62122244",
"0.62023735",
"0.6201962",
"0.6199054",
"0.6198603",
"0.61936927",
"0.61913484",
"0.618317",
"0.61824244",
"0.6174938",
"0.6138222",
"0.61359215",
"0.6134782",
"0.6134782",
"0.6134782",
"0.6134782",
"0.6134782",
"0.6134782",
"0.6134782",
"0.6134782",
"0.6134782",
"0.6134782",
"0.6134782",
"0.6134782",
"0.6120551",
"0.6120551",
"0.6120551",
"0.6091501",
"0.60878223",
"0.60862315",
"0.6054196",
"0.6041105",
"0.60126406",
"0.6012608",
"0.59957564",
"0.59957564",
"0.59921205",
"0.5989746",
"0.59784496",
"0.5970378",
"0.59615004",
"0.5959484",
"0.59563655",
"0.59563655",
"0.59563655",
"0.59563655",
"0.59563655",
"0.59563655"
] |
0.7144632
|
6
|
DELETE /ingredients/1 DELETE /ingredients/1.json
|
def destroy
recipe = @ingredient.recipe
@ingredient.destroy
respond_to do |format|
if recipe.save
format.html { redirect_to recipe, notice: 'Ingredient was successfully removed.' }
format.json { head :no_content }
else
format.html { redirect_to recipe, notice: 'An error occured while removing the ingredient.' }
format.json { head :no_content }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @ingredient = Ingredient.find(params[:id])\n @ingredient.destroy\n\n respond_to do |format|\n format.html { redirect_to ingredients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n rid = params['id']\n if Aws.delete_recipe(rid) && Aws.delete_all_ingredients(rid)\n msg = {:notice => \"Recipe deleted!\"}\n render :json => msg\n else\n msg = {:notice => \"Error while deleting from DynamoDB!\"}\n render :json => msg\n end\n end",
"def destroy\n @recipe_ingredient = RecipeIngredient.find(params[:id])\n @recipe_ingredient.destroy\n\n respond_to do |format|\n format.html { redirect_to recipe_ingredients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe_ingredient = Recipe_ingredient.find(params[:id])\n @recipe_ingredient.destroy\n\n respond_to do |format|\n format.html { redirect_to recipe_ingredients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ingredient = Ingredient.find(params[:id])\n @ingredient.destroy\n\n respond_to do |format|\n format.html { redirect_to(ingredients_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @ingredient = Ingredient.find(params[:id])\n @ingredient.destroy\n\n respond_to do |format|\n format.html { redirect_to(ingredients_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @ingredients_nutrient.destroy\n respond_to do |format|\n format.html { redirect_to ingredients_nutrients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n Ingredient.find(params[:id]).destroy\n redirect_to ingredients_path\n end",
"def destroy\n @ingredients_name = IngredientsName.find(params[:id])\n @ingredients_name.destroy\n\n respond_to do |format|\n format.html { redirect_to ingredients_names_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ingredient.destroy\n respond_to do |format|\n format.html { redirect_to edit_receipe_url(@receipe), notice: 'Ingredient was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dis_ingredient.destroy\n respond_to do |format|\n format.html { redirect_to dis_ingredients_url, notice: 'Dis ingredient was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(id)\n request(:delete, \"/recipes/#{id}.json\")\n end",
"def destroy\n @recipe_ingredient.destroy\n respond_to do |format|\n format.html { redirect_to recipe_ingredients_url, notice: 'Recipe ingredient was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def recipe_delete # /v1/user/:id/recipes/:recipe_id (DELETE)\n params[:recipes] = params[:recipe_id]\n recipes_delete\n end",
"def destroy\n authorize @ingredient.recipe\n @ingredient.destroy\n respond_to do |format|\n format.html { redirect_to @ingredient.recipe }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipeingredient.destroy\n respond_to do |format|\n format.html { redirect_to recipeingredients_url, notice: 'Recipeingredient was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @data = @recipe.delete(params[:id])\n render json: @data\n end",
"def destroy\n @ingredient_recipe.destroy\n respond_to do |format|\n format.html { redirect_to ingredient_recipes_url, notice: 'Ingredient recipe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post_ingredient.destroy\n respond_to do |format|\n format.html { redirect_to post_post_ingredients_path(@post), notice: \"Post ingredient was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def delete_all_ingredients\n rid = params['id']\n\n if Aws.delete_all_ingredients(rid)\n msg = {:notice => \"All ingredients deleted!\"}\n render :json => msg\n else\n msg = {:notice => \"Error while deleting all ingredients!\"}\n render :json => msg\n end\n end",
"def destroy\n @ingredient.destroy\n respond_to do |format|\n format.html { redirect_to user_bar_ingredients_url, notice: 'Ingredient was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ingredient = Ingredient.find(params[:id])\n @ingredient.destroy\n\n respond_to do |format|\n format.html { redirect_to recipe_ingredients_path }\n format.js\n format.xml { head :ok }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @cooking_ingredient.destroy\n\n respond_to do |format|\n format.html { redirect_to(cooking_ingredients_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n begin\n recipe = Recipe.find(params[:id])\n\n recipe.destroy\n render json: { status: 'SUCCESS', message: 'Recipe deleted!', data: recipe }, status: :ok\n rescue\n render json: { status: 'ERROR', message: 'Error finding recipe', data: {} }, status: :not_found\n end\n end",
"def destroy\n recipe = Recipe.find(params[:id])\n recipe.destroy()\n render json: {message:\"Recipe deleted.\"}\n end",
"def destroy\n @allergens_ingredient.destroy\n respond_to do |format|\n format.html { redirect_to allergens_ingredients_url, notice: 'Allergens ingredient was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ingrediente = Ingrediente.find(params[:id])\n @ingrediente.destroy\n\n respond_to do |format|\n format.html { redirect_to(ingredientes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @measured_ingredient.destroy\n respond_to do |format|\n format.html { redirect_to measured_ingredients_url, notice: 'Measured ingredient was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ingredient.destroy\n redirect_to @recipe\n end",
"def destroy\n @ingrediente.destroy\n respond_to do |format|\n format.html { redirect_to ingredientes_url, notice: 'Ingrediente was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n unless logged_in?\n render :file => 'public/401', :status => :unauthorized, :layout => false and return\n end\n\n @ingredient.destroy\n respond_to do |format|\n format.html { redirect_to Item.find(@recipe.item_id), notice: 'Ingredient was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe = Recipe.find(params[:id])\n @recipe.destroy\n\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @step_ingredient = StepIngredient.find(params[:id])\n @step_ingredient.destroy\n\n respond_to do |format|\n format.html { redirect_to(step_ingredients_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @recipe = Recipe.find(params[:id])\n @recipe.destroy\n\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe = Recipe.find(params[:id])\n @recipe.destroy\n\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe = Recipe.find(params[:id])\n @recipe.destroy\n\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe = Recipe.find(params[:id])\n @recipe.destroy\n\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe = Recipe.find(params[:id])\n @recipe.destroy\n\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @food_recipe = FoodRecipe.find(params[:id])\n @food_recipe.destroy\n\n respond_to do |format|\n format.html { redirect_to food_recipes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @diet_ingredient_type.destroy\n respond_to do |format|\n format.html { redirect_to diet_ingredient_types_url, notice: 'Diet ingredient type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Item.delete(params[\"id\"])\n end",
"def destroy\n # @recipe = Recipe.find(params[:id])\n # @recipe.destroy\n #\n destroy! do |format|\n # format.html { redirect_to recipes_url }\n # format.json { head :ok }\n end\n end",
"def destroy\n @recipe_ingredients_unit.destroy\n respond_to do |format|\n format.html { redirect_to recipe_ingredients_units_url, notice: 'Recipe ingredients unit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @namei = @ingredient.name\n @ingredient.destroy\n\n respond_to do |format|\n format.html { redirect_to ingredients_url, :flash =>{success:\"l'ingredient #{@namei} supprimé définitivement...\"} }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe.destroy\n\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @ingredient_list.destroy\n respond_to do |format|\n format.html { redirect_to ingredient_lists_url, notice: 'Ingredient list was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t\t@recipe = Recipe.find(params[:id])\n\t\tif @recipe.destroy\n\t\t\trender json: {}\n\t\telse\n\t\t\trender status: 400, nothing: true\n\t\tend\n\tend",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def destroy\n\t\t\t\trecipe = get_recipe_by_id(params[:id])\n\t\t\t\trecipe.destroy\n\t\t\t\trender json: {status: 'SUCCESS', message: 'Deleted recipe', data: recipe}, status: :ok\n\t\t\tend",
"def destroy\n @recipe = current_user.recipes.find(params[:id])\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ingredient = Ingredient.find(params[:id])\n \n if @ingredient.destroy\n flash[:notice] = l(:flash_notice_ingredient_deleted)\n else\n flash[:notice] = l(:flash_notice_used_ingredient)\n end\n \n respond_to do |format|\n format.html { redirect_to [ @ingredient_category, Ingredient.new ] }\n format.xml { head :ok }\n end\n end",
"def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to root_url, notice: 'Recipe 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 destroy\n @ingredient.destroy\n flash[:notice] = \"Ingredient deleted\"\n redirect_to ingredients_path\n end",
"def destroy\n @recipe_item.destroy\n respond_to do |format|\n format.html { redirect_to @recipe_item.recipe, notice: 'Recipe item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe = Recipe.find(current_recipe)\n current_recipe.recipe_ingredients.find(params[:id]).destroy\n #flash.alert = \"Ingredient Removed\"\n respond_to do |f|\n f.html {redirect_to current_recipe}\n f.js {@recipe}\n end\n end",
"def destroy\n if (@single_recipe_delete = Recipe.find_by_id(params[:id])).present?\n @single_recipe_delete.destroy\n render :json => {\n :response => 'Successfully deleted record.'\n }\n else\n render :json => {\n :response => 'record not found'\n }\n end\n end",
"def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url, notice: 'Recipe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url, notice: 'Recipe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url, notice: 'Recipe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url, notice: 'Recipe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url, notice: 'Recipe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url, notice: 'Recipe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url, notice: 'Recipe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url, notice: 'Recipe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url, notice: 'Recipe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url, notice: 'Recipe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url, notice: 'Recipe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url, notice: 'Recipe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url, notice: 'Recipe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url, notice: 'Recipe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url, notice: 'Recipe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url, notice: 'Recipe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url, notice: 'Recipe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url, notice: 'Recipe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url, notice: 'Recipe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url, notice: 'Recipe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url, notice: 'Recipe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url, notice: 'Recipe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(*rest) end",
"def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url, notice: \"Recipe was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url, notice: \"Recipe was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url, notice: \"Recipe was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize! :destroy, @recipe\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url, notice: t('.success') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe.destroy\n\n respond_to do |format|\n format.html { redirect_to recipes_url, notice: I18n.t(:'recipes.destroy.successful') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe = Recipe.find(params[:id])\n @recipe.destroy\n \n respond_to do |format|\n format.html { redirect_to(recipes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @barbecue_ingredient.destroy\n respond_to do |format|\n format.html { redirect_to barbecue_ingredients_url, notice: 'Barbecue ingredient was successfully destroyed.' }\n format.json { head :no_content }\n format.js\n end\n end",
"def destroy\n authorize @recipe\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url}\n format.json { head :no_content }\n end\n end",
"def destroy\n @interest = Interest.find(params[:id])\n @interest.destroy\n\n respond_to do |format|\n format.json { head :ok }\n end \n end",
"def destroy\n @recipes_food.destroy\n respond_to do |format|\n format.html { redirect_to recipes_foods_url, notice: 'Recipes food was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe = Recipe.find(params[:id])\n @recipe.destroy\n\n respond_to do |format|\n format.html { redirect_to(recipes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @recipe = Recipe.find(params[:id])\n @recipe.destroy\n\n respond_to do |format|\n format.html { redirect_to(recipes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to user_path(current_user), notice: 'Recipe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe_all = RecipeAll.find(params[:id])\n @recipe_all.destroy\n\n respond_to do |format|\n format.html { redirect_to recipe_alls_url }\n format.json { head :no_content }\n end\n end"
] |
[
"0.77841467",
"0.7688536",
"0.7622828",
"0.75866234",
"0.7467383",
"0.7467383",
"0.74408317",
"0.7433734",
"0.73942",
"0.7372651",
"0.7334119",
"0.7302972",
"0.73027277",
"0.72947854",
"0.7273495",
"0.7253994",
"0.72406185",
"0.72399557",
"0.7224781",
"0.7174499",
"0.714602",
"0.712713",
"0.7122956",
"0.711053",
"0.7110371",
"0.7079865",
"0.70700526",
"0.70084506",
"0.6964667",
"0.695577",
"0.69551384",
"0.69528383",
"0.6936908",
"0.69329077",
"0.69222784",
"0.69222784",
"0.69222784",
"0.69222784",
"0.69222784",
"0.6919808",
"0.6917962",
"0.6915384",
"0.6906689",
"0.6905019",
"0.6904958",
"0.6899576",
"0.6887263",
"0.6881059",
"0.6881059",
"0.6881059",
"0.6881059",
"0.6881059",
"0.6870867",
"0.6825523",
"0.6805755",
"0.67699766",
"0.67639816",
"0.6746683",
"0.67323184",
"0.67228717",
"0.67033744",
"0.6702735",
"0.668908",
"0.66841555",
"0.66836125",
"0.66836125",
"0.66836125",
"0.66836125",
"0.66836125",
"0.66836125",
"0.66836125",
"0.66836125",
"0.66836125",
"0.66836125",
"0.66836125",
"0.66836125",
"0.66836125",
"0.66836125",
"0.66836125",
"0.66836125",
"0.66836125",
"0.66836125",
"0.66836125",
"0.66836125",
"0.66836125",
"0.6680447",
"0.6677663",
"0.6677663",
"0.6677663",
"0.66727126",
"0.66659075",
"0.66571313",
"0.6629951",
"0.66214556",
"0.6618418",
"0.6611084",
"0.6605584",
"0.6605584",
"0.6601688",
"0.6596367"
] |
0.7305878
|
11
|
Use callbacks to share common setup or constraints between actions.
|
def set_ingredient
@ingredient = Ingredient.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
|
Never trust parameters from the scary internet, only allow the white list through.
|
def ingredient_params
params.require(:ingredient).permit(:weight, :recipe, :description)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] |
[
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",
"0.62894756",
"0.6283177",
"0.6242471",
"0.62382483",
"0.6217549",
"0.6214457",
"0.6209053",
"0.6193042",
"0.6177802",
"0.6174604",
"0.61714715",
"0.6161512",
"0.6151757",
"0.6150663",
"0.61461",
"0.61213595",
"0.611406",
"0.6106206",
"0.6105114",
"0.6089039",
"0.6081015",
"0.6071004",
"0.60620916",
"0.6019971",
"0.601788",
"0.6011056",
"0.6010898",
"0.6005122",
"0.6005122",
"0.6001556",
"0.6001049",
"0.59943926",
"0.5992201",
"0.59909594",
"0.5990628",
"0.5980841",
"0.59669393",
"0.59589154",
"0.5958826",
"0.5957911",
"0.5957385",
"0.5953072",
"0.59526145",
"0.5943361",
"0.59386164",
"0.59375334",
"0.59375334",
"0.5933856",
"0.59292704",
"0.59254247",
"0.5924164",
"0.59167904",
"0.59088355",
"0.5907542",
"0.59064597",
"0.5906243",
"0.5898226",
"0.589687",
"0.5896091",
"0.5894501",
"0.5894289",
"0.5891739",
"0.58860534",
"0.5882406",
"0.587974",
"0.58738774",
"0.5869024",
"0.58679986",
"0.5867561",
"0.5865932",
"0.5864461",
"0.58639693",
"0.58617616",
"0.5861436",
"0.5860451",
"0.58602303",
"0.5854586",
"0.58537364",
"0.5850427",
"0.5850199"
] |
0.0
|
-1
|
Removes html and generate a summary
|
def summarize(html, max = nil)
return '' if is_blank?(html)
unclean = Nokogiri::HTML::DocumentFragment.parse(html.dup)
summarize_fragment(unclean, max).to_html
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def summary\n if key? 'summary'\n self['summary'].to_s.thru_erb.to_html\n else\n case html.gsub(%r{<(h\\d).*?>.*?</\\1>}m, '') # omit headings from summary\n\n # the first HTML block-level element\n when %r{\\A\\s*<(\\w+).*?>.*?</\\1>}m\n $&\n\n # the first paragraph (a run of text delimited by newlines)\n when /\\A.*?(?=\\r?\\n\\s*\\r?\\n)/m\n $&\n\n end\n end\n end",
"def plain_text_summary\n summary_html && Utils::HTMLToText.convert(summary_html)\n end",
"def render_summary\n summary = nil\n\n end",
"def summarise\n headerless = self.body.gsub(/\\<h\\d.*?\\>.*?\\<\\/h\\d\\>/m, '')\n summary = ActionView::Base.full_sanitizer.sanitize(headerless).strip.match(/^(.+?)[\\.\\r\\n]/m)&.captures&.first || self.title\n\n return \"#{ summary }.\"\n end",
"def create_summary\r\n puts \"Creating a summary...\"\r\n #@lists.disp_summary\r\n create_html_summary\r\n file = File.open('test.html','w')\r\n file << @html\r\n file.close\r\n end",
"def summary\n self.content.gsub(/\\r?\\n\\r?\\n(.*)/m, '') # break after the first paragraph\n end",
"def html_summarize(text, length = 30, omission = '...')\n return '' if text.blank?\n snippet(strip_tags(text), length, omission)\n end",
"def summary\n #render unless @output\n @summary\n end",
"def render_summary\n summary = nil\n max_chars = (self.display_configuration.try {|h| h[\"summary_max_chars\"]}) || 280\n\n\n\n if self.snippets.length > 0 && !(self.display_configuration.try {|h| h[\"prefer_abstract_as_summary\"]} && self.abstract)\n summary = self.snippets.first\n self.snippets.slice(1, self.snippets.length).each do |snippet|\n summary += ' '.html_safe + snippet if (summary.length + snippet.length) <= max_chars\n end\n else\n summary = _h.bento_truncate( self.abstract, :length => max_chars )\n end\n\n summary\n end",
"def content_summary(**args)\n length = args[:length] ? args[:length] : 50\n # If we can find first paragraph\n reg = Regexp.new(/(^<p>[^<]*<\\/p>)/)\n if !self.content.match(reg).nil?\n return self.content.match(reg).captures[0].gsub(/<[a-z]{1,}[^>]*>|<\\/[a-z]>/,'').truncate(length)\n end\n # Else, strip HTML and truncate\n return self.content.gsub(/<[a-z]{1,}[^>]*>|<\\/[a-z]>/, '').truncate(length)\n end",
"def dump_summary( summary )\n\t\thtml = self.render_summary( summary )\n\t\t@output.puts( html )\n\t\t@output.flush\n\tend",
"def summary\n Rinku.auto_link(description.html_safe) rescue nil\n end",
"def article_summary\n respond_to?(:summary) ? summary : ''\n end",
"def render_summary( summary )\n\t\ttemplate = self.load_template( SUMMARY_TEMPLATE )\n\t\treturn template.result( binding() )\n\tend",
"def create_html_summary\r\n puts \"Creating HTML...\"\r\n @dmds = @lists.last\r\n @html = '<html>'\r\n @html += '<head><link rel=\"stylesheet\" href=\"styles.css\"></head>'\r\n @html += '<body>'\r\n @html += \"<h3>Actions</h3>\\n<ul>\"\r\n @html += actions_html\r\n @html += \"</ul>\\n\"\r\n #@html += \"<h3>Prios diff</h3>\\n<ul>\"\r\n #@html += prio_diff_html\r\n #@html += \"</ul>\\n\"\r\n #@html += \"<h3>Closed DMD</h3>\\n<ul>\"\r\n #@html += closed_dmd_html\r\n #@html += \"</ul>\\n\"\r\n @html += \"<h3>Open DM</h3>\"\r\n ano, evo = sas_report\r\n @html += \"<table><tr><td>Nature of changes</td><td>P0</td><td>P1</td><td>P2/P3</td><td>Total</td></tr>\r\n <tr><td>Anomalies</td><td>#{ano['0']}</td><td>#{ano['1']}</td><td>#{ano['2']+ano['3']}</td><td>#{ano['0']+ano['1']+ano['2']+ano['3']}</td></tr>\r\n <tr><td>Evolutions</td><td>#{evo['0']}</td><td>#{evo['1']}</td><td>#{evo['2']+evo['3']}</td><td>#{evo['0']+evo['1']+evo['2']+evo['3']}</td></tr>\r\n <tr><td>Total</td><td>#{ano['0']+evo['0']}</td><td>#{ano['1']+evo['1']}</td><td>#{ano['2']+ano['3']+evo['2']+evo['3']}</td><td>#{ano['0']+evo['0']+ano['1']+evo['1']+ano['2']+ano['3']+evo['2']+evo['3']}</td></tr>\r\n <table>\"\r\n count = prios_hash\r\n @html += \"<h3>Non analysed DMD, by priority</h3><ul>\\n\"\r\n @html += \"<b>Stats</b><ul>TBD: #{count['TBD']}<br/>P0: #{count['0']}<br/>P1: #{count['1']}<br/>P2: #{count['2']}<br/>P3: #{count['3']}<br/></ul>\\n\"\r\n @html += \"#{priority_html(priority_dmd)}</ul>\\n\"\r\n @html += \"<h3>Evo</h3>\\n<ul>#{priority_html(priority_evo)}</ul>\\n\"\r\n @html += \"<h3>Analysed but not batched DMD</h3>\\n<ul>#{analysed_html(analysed_dmd)}</ul>\\n\"\r\n @html += \"<h3>Has workload but not 'analysed' DMD</h3>\\n<ul>#{analysed_html(workload_dmd)}</ul>\\n\"\r\n @html += \"<h3>Decided DMD</h3>\\n<ul>#{decided_html(decided_dmd)}</ul>\\n\"\r\n @html += \"<h3>Last updated</h3>\\n<ul>#{last_updated_html(last_updated_dmd)}</ul>\\n\"\r\n @html += '</body>'\r\n @html += '</html>'\r\n end",
"def summary\n content, id = self.get_page_content\n line_limit = self.context['site']['config']['posts']['summary_lines'].to_i rescue nil\n line_limit ||= 20\n line_count = 0\n line_breakpoint = content.lines.count\n\n content.lines.each_with_index do |line, i|\n if line =~ /^\\s*$/ # line with only whitespace\n if line_count >= line_limit\n line_breakpoint = i\n break\n end\n else\n line_count += 1\n end\n end\n \n content = content.lines.to_a[0, line_breakpoint].join\n content = self.render(content)\n Ruhoh::Converter.convert(content, id)\n end",
"def update_summary\n if self.description != nil\n shortened = /^(.*?)[.?!]\\s/.match(self.description)\n if shortened\n self.summary = shortened[1] + \"...\"\n end\n end\n end",
"def entry_summary(entry=@entry)\n filter(entry.summary, :markdown)\n end",
"def entry_summary(entry=@entry)\n filter(entry.summary, :markdown)\n end",
"def summary\n if first_line =~ /^#/\n first_line.sub(/^#*/, '').strip\n else\n ''\n end\n end",
"def strip_html_from_description\n self.description = ActionView::Base.full_sanitizer.sanitize(description)\n end",
"def parse_summary(content)\n summary = \"\"\n status = :pre_header\n content.each_line do |l|\n \n # Verify status change\n case status\n when :pre_header\n if l.strip =~ /^h\\d\\.(.+)/\n status = :header \n end\n status = :paragraph if status != :header && l.strip.length > 0\n when :header\n status = :post_header\n when :post_header\n status = :paragraph if l.strip.length > 0\n when :paragraph\n break if l.strip =~ /^h\\d\\./ || l.strip.length == 0\n end\n summary << l\n \n end \n return summary\n end",
"def summary\n # TODO\n end",
"def description_html\n @description_html ||= RDiscount.new(original.body).to_html\n end",
"def render_summary(summary_form,summary,options = {})\n return '' if summary.nil?\n language = options[:language] ||= OpenMoneyDefaultLanguage\n\n form = summary_form[language]\n form ||= summary_form[OpenMoneyDefaultLanguage]\n form.gsub(/:([a-zA-Z0-9_-]+)/) do |m| \n summary[$1]\n end\n end",
"def tag_removed_summary(tag=\"あとで\")\n hatena = HatenaOAuth.new\n summary = hatena.edit_get(self.eid)[:entry][:summary]\n # 正規表現メモ: summary.scan(/\\[.*?\\]/) # => [\"[大学]\", \"[anime]\"]\n summary.gsub(/\\[#{tag}\\]/, '') # NOTE: \"あとで\" を除外してbookmark.tagsに保存しているが, この設計も見直したい.\n end",
"def summary\n \n end",
"def wikipedia_summary(url)\n doc = Nokogiri::HTML(open(url))\n first_para_html = doc.search('//p').first.to_s # .gsub(/<\\/?[^>]*>/, \"\")\n return Sanitize.clean(first_para_html)\n rescue Exception\n return nil\n end",
"def wikipedia_summary(url)\n doc = Nokogiri::HTML(URI.parse(url).open)\n first_para_html = doc.search('//p').first.to_s # .gsub(/<\\/?[^>]*>/, \"\")\n Sanitize.clean(first_para_html)\n rescue Exception\n nil\n end",
"def summary; end",
"def summary; end",
"def summary; end",
"def summary; end",
"def summary(text)\n Runner.instance.summary = text\n end",
"def extract_summary\n\t\treturn self.description.split( /(?<=\\.)\\s+/ ).first&.gsub( /\\n/, ' ' )\n\tend",
"def text\n html.gsub(REGEX_TAGS, \"\")\n end",
"def summaries\n plot_summaries.css(\"p.plotSummary\").map { |summary| summary.text.strip }\n end",
"def summary\n end",
"def summary\n end",
"def summary\n authenticated_post(\"summary\").body\n end",
"def summary\n resource = pointer[\"resource\"]\n content, id = self.get_page_content\n line_limit = @ruhoh.db.config(resource)['summary_lines']\n line_count = 0\n line_breakpoint = content.lines.count\n\n content.lines.each_with_index do |line, i|\n if line =~ /^\\s*$/ # line with only whitespace\n if line_count >= line_limit\n line_breakpoint = i\n break\n end\n else\n line_count += 1\n end\n end\n\n summary = content.lines.to_a[0, line_breakpoint].join\n\n # The summary may be missing some key items needed to render properly.\n # So search the rest of the content and add it to the summary.\n content.lines.with_index(line_breakpoint) do |line, i|\n # Add lines containing destination urls.\n if line =~ /^\\[[^\\]]+\\]:/\n summary << \"\\n#{line}\"\n end\n end\n\n summary = master.render(summary)\n Ruhoh::Converter.convert(summary, id)\n end",
"def run_clean_short_description\n self.short_description = HtmlMaid.clean_short_description(self.short_description)\n end",
"def summary\n\t\tsummary = \"\"\n\t\tget = @text.split(/ /)\n\t\tget.each_index do |word|\n\t\t\tsummary << get[word] << \" \" if word < 10\n\t\tend\n\t\tsummary.strip\n\tend",
"def update_html_for_abstract\n return unless details\n self.details_filtered = textile_to_html( details )\n end",
"def description_html\n convert_html description\n end",
"def parse_markdown\n self.body_html = markdown.render(body_markdown.to_s)\n self.summary_html = markdown.render(summary_markdown.to_s)\n end",
"def htmlClean(html)\n html\nend",
"def summary\n {}\n end",
"def strip_tags(html); end",
"def strip_tags(html); end",
"def strip_tags(html); end",
"def summary=(str)\n @summary = str.to_s.strip.\n gsub(/(\\w-)\\n[ \\t]*(\\w)/, '\\1\\2').gsub(/\\n[ \\t]*/, \" \") # so. weird.\n end",
"def text_summary\n summary = attribute_get(:text)\n summary = summary[(summary.index(\" \") + 1)...summary.length] if summary[0...1] == \"@\"\n summary = (summary.length > 30 ? \"#{summary[0..30]}...\" : summary[0..30])\n summary\n end",
"def text_summary\n summary = self.text\n summary = summary[(summary.index(\" \") + 1)...summary.length] if self.text[0...1] == \"@\"\n summary = (summary.length > 30 ? \"#{summary[0..30]}...\" : summary[0..30])\n summary\n end",
"def description\n return summary\n end",
"def content_manipulation\n self.summary = markup_manipulation self.summary if self.summary.present?\n self.content = markup_manipulation self.content if self.content.present?\n end",
"def normalise_html(html)\n Nokogiri::HTML5.fragment(html).to_s.gsub(\"\\n\", \"\")\n end",
"def finalize(ctx)\n\t\toutput = ctx.variables['__OUTPUT__'] || ''\n\n\t\thtml = \"<!DOCTYPE html>\n<html>\n\t<head>\n\t\t<style type='text/css'>\n\t\t\tbody { font: 10pt sans-serif; }\n\t\t\t.action div { display: inline-block; }\n\t\t\t.cmd { width: 100px }\n\t\t\t.status { float: right; text-align: center; }\n\t\t\t.status .text { width: 100px; font-weight: bold }\n\t\t\t.test { background-color: #DFDFFF; margin-top: 20px }\n\t\t\t.ok .status .text { background-color: #DFFFDF }\n\t\t\t.error .status .text { background-color: #FFDFDF }\n\t\t\t.skip .status .text { background-color: #FFDFFF }\n\t\t\t.capture { border: 1px solid black }\n\t\t\t.capture img { max-width: 100% }\n\t\t\t.odd { background-color: #EEEEEE }\n\t\t\t.summary th { background-color: #DFDFFF; text-align: left }\n\t\t\t.summary td { cursor: pointer; }\n\t\t\t.top { position: absolute; top: 0px; right: 0px; background-color: #DFDFFF; padding: 5px; border-radius: 0px 0px 0px 5px; }\n\n\t\t</style>\n\t\t<script type='text/javascript'>\n\t\t\tfunction show(target) {\n\t\t\t\tvar e = document.getElementById(target+'_content');\n\t\t\t\twindow.location.href = '#'+target;\n\t\t\t}\n\t\t</script>\n\t</head>\n\t<body>\"\n\t\thtml << _d(2, \"<div class='top'>Created using <a href='https://github.com/pzavolinsky/bauxite'>bauxite</a> on #{Time.new}</div>\")\n\t\tif ctx.tests.any?\n\t\t\thtml << _d(2, \"<h1>Test Summary</h1>\")\n\t\t\thtml << _d(2, \"<table class='summary'>\")\n\t\t\thtml << _d(3, \"<tr><th>Name</th><th>Time</th><th>Status</th><th>Error</th></tr>\")\n\n\t\t\tctx.tests.each_with_index do |t,idx|\n\t\t\t\terror = t[:error]\n\t\t\t\terror = error ? error.message : ''\n\t\t\t\thtml << _d(3, \"<tr class='#{t[:status].downcase} #{(idx % 2) == 1 ? 'odd' : 'even'}' onclick='show(\\\"#{t[:name]}\\\")'>\")\n\t\t\t\thtml << _d(4, \"<td>#{t[:name]}</td><td>#{t[:time].round(2)}</td><td class='status'>#{t[:status]}</td><td>#{error}</td>\")\n\t\t\t\thtml << _d(3, \"</tr>\")\n\t\t\tend\n\n\t\t\thtml << _d(2, \"</table>\")\n\t\tend\n\n\t\thtml << _d(2, \"<h1>Test Details</h1>\")\n\t\t@data.each do |test|\n\t\t\tname = test[:name]\n\t\t\tstatus = test[:actions].find { |a| a[:status] == :error } ? :error : :ok\n\t\t\thtml << _d(2, \"<a name='#{name}'></a>\")\n\t\t\thtml << _d(2, \"<div class='test #{status}'>#{name}<div class='status'><div class='text'>#{status.upcase}</div></div></div>\")\n\t\t\thtml << _d(2, \"<div id='#{name}_content' class='test-content'>\")\n\n\t\t\ttest[:actions].each_with_index do |action,idx|\n\t\t\t\thtml << _d(3, \"<div class='action #{action[:status]} #{(idx % 2) == 1 ? 'odd' : 'even'}'>\")\n\t\t\t\thtml << _d(4, \t\"<div class='cmd'>#{action[:cmd]}</div>\")\n\t\t\t\thtml << _d(4, \t\"<div class='args'>#{action[:args].join(' ')}</div>\")\n\t\t\t\thtml << _d(4, \t\"<div class='status'>\")\n\t\t\t\thtml << _d(5, \t\t\"<div class='time'>(#{action[:time].round(2).to_s}s)</div>\")\n\t\t\t\thtml << _d(5, \t\t\"<div class='text'>#{action[:status].upcase}</div>\")\n\t\t\t\thtml << _d(4, \t\"</div>\")\n\t\t\t\thtml << _d(3, \"</div>\")\n\t\t\t\tcapture = action[:capture]\n\t\t\t\tif capture\n\t\t\t\t\thtml << _d(3, \"<div class='capture'>#{_img(output, capture)}</div>\")\n\t\t\t\tend\n\t\t\tend\n\n\t\t\titem = ctx.tests.find { |t| t[:name] == name }\n\t\t\tif item and item[:error]\n\t\t\t\tcapture = item[:error].variables['__CAPTURE__']\n\t\t\t\tif capture\n\t\t\t\t\thtml << _d(3, \"<div class='capture'>#{_img(output, capture)}</div>\")\n\t\t\t\tend\n\t\t\tend\n\n\t\t\thtml << _d(2, \"</div>\")\n\t\tend\n\t\thtml << \"\n\t</body>\n</html>\"\n\t\tfile = ctx.output_path(@file)\n\t\tFile.open(file, 'w') { |f| f.write html }\n\t\tFile.delete(*@imgs) if @imgs.size > 0\n\tend",
"def summary\n @summary ||= HTML::Pipeline::TaskList::Summary.new(record.task_list_items)\n end",
"def process_markdown\n self.explanation_html = Kramdown::Document.new(explanation_md || '').to_html.gsub(/[\\r\\n]+/, '')\n end",
"def print_summary\r\n traverse do |node|\r\n print node.effectively_skipped? ? '-' : '+'\r\n case\r\n when node.test? then print 'T'\r\n when node.suite? then print 'S'\r\n when node.static? then print 'X'\r\n else print '?'\r\n end\r\n print node.indented_name(' ')\r\n tags = node.effective_tags.to_a\r\n unless tags.empty?\r\n # highlight the tags that are explicit on this node\r\n tags = tags.map {|tag| node.explicit_tags.include?(tag) ? \"*#{tag}\" : tag }\r\n print \" [#{tags.join(',')}]\"\r\n end\r\n print \"\\n\"\r\n end\r\n end",
"def summary\n return @summary\n end",
"def summary\n return @summary\n end",
"def summary\n return @summary\n end",
"def summary\n calculate\n\n num_width = [@num_files, @num_items].max.to_s.length\n undoc_width = [\n @undoc_attributes,\n @undoc_classes,\n @undoc_constants,\n @undoc_items,\n @undoc_methods,\n @undoc_modules,\n @undoc_params,\n ].max.to_s.length\n\n report = RDoc::Markup::Verbatim.new\n\n report << \"Files: %*d\\n\" % [num_width, @num_files]\n\n report << \"\\n\"\n\n report << \"Classes: %*d (%*d undocumented)\\n\" % [\n num_width, @num_classes, undoc_width, @undoc_classes]\n report << \"Modules: %*d (%*d undocumented)\\n\" % [\n num_width, @num_modules, undoc_width, @undoc_modules]\n report << \"Constants: %*d (%*d undocumented)\\n\" % [\n num_width, @num_constants, undoc_width, @undoc_constants]\n report << \"Attributes: %*d (%*d undocumented)\\n\" % [\n num_width, @num_attributes, undoc_width, @undoc_attributes]\n report << \"Methods: %*d (%*d undocumented)\\n\" % [\n num_width, @num_methods, undoc_width, @undoc_methods]\n report << \"Parameters: %*d (%*d undocumented)\\n\" % [\n num_width, @num_params, undoc_width, @undoc_params] if\n @coverage_level > 0\n\n report << \"\\n\"\n\n report << \"Total: %*d (%*d undocumented)\\n\" % [\n num_width, @num_items, undoc_width, @undoc_items]\n\n report << \"%6.2f%% documented\\n\" % percent_doc\n report << \"\\n\"\n report << \"Elapsed: %0.1fs\\n\" % (Time.now - @start)\n\n RDoc::Markup::Document.new report\n end",
"def presentable_html(html)\n # sanitize edited, tags: %w(body p span a h1 h2 h3 h4 h5 h6 ul ol li) if work.file_content_html %> -->\n # doc = Nokogiri::HTML(html_junk)\n # body = doc.at_xpath(\"//body\")\n # body.css('*').remove_attr('class')\n # edited = body.to_html\n return raw html\n end",
"def summary\n content = self.content\n sentences = content.split(\".\")\n \"#{sentences[0..1].join(\".\")}...\"\n end",
"def create_summary_doc\n label = 'Summary Information'\n doc = self.base_doc.merge({\n :xml_display => @xml.at(\"/ead/archdesc/did\").to_xml,\n :id => generate_id('summary'),\n :title_t => label,\n :hierarchy => [self.title, label]\n })\n doc\n end",
"def parse_from_summary(data)\n # \n end",
"def summary\n\t\tobject.summary || \"\"\n\tend",
"def edit_summary\n return summary unless diff_stats # If diff_stats is nil, then summary is the edit summary\n nil # Otherwise, it's diff_stats and returns nil\n end",
"def summary\n description.lines.first.thru { |line|\n if line\n line.split( '. ', 2 ).first\n else\n ''\n end\n }\n end",
"def description\n document.at(\"[@id='description']/span[1]\").innerHTML.goodreads_strip_tags.goodreads_strip_bad_description_content rescue nil\n end",
"def strip_html(text)\n @name =\n # Remove HTML from the text\n Sanitize.clean(text).\n # Replace newlines with a space\n gsub(/\\n|\\r/, ' ').\n # Replaces runs of spaces by a single space\n squeeze(' ').\n # Remove leading and trailing whitespace\n strip\nend",
"def formatted_scenario_description(description)\n # First check if the description has a div matching the current locale,\n # indicating that a localized version is available.\n localized = Loofah.fragment(description).css(\".#{I18n.locale}\")\n\n rendered = RDiscount.new(\n localized.inner_html.presence || description,\n :no_image, :smart\n ).to_html\n\n Rails::Html::SafeListSanitizer.new.sanitize(\n strip_external_links(rendered)\n ).html_safe\n end",
"def summary(content)\n content[0, content.index('<!-- more -->') || content.length]\nend",
"def result_summary\n options = { style: 'font-size: 25px;' }\n summary = if matches_exist?\n [bold_tag(pluralize(result_count, 'result'), options), filter_text]\n else\n [\n bold_tag(@query, options),\n 'not found -',\n pluralize(result_count, 'similar result'),\n filter_text\n ]\n end\n safe_join(summary, ' ')\n end",
"def summarytext\n File.open(\"/tmp/tmp.#{$$}\", 'w') {|f| f.write(printmailq(mailq)) }\n\n out = %x[/bin/cat /tmp/tmp.#{$$} | /usr/sbin/exiqsumm]\n\n File.unlink(\"/tmp/tmp.#{$$}\")\n\n out\n end",
"def clean_up_contents()\n # very minimal\n # elements = ['p', 'b', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'], attributes={})\n\n if self.contents?\n html = self.contents\n email_regex = /<p>Email:\\s+((\\w|\\-|\\_|\\.)+\\@((\\w|\\-|\\_)+\\.)+[a-zA-Z]{2,})/i\n\n html.gsub! /\\[endif\\]--/ , ''\n html.gsub! /[\\n|\\r]/ , ' '\n html.gsub! / / , ' '\n\n # this will convert UNICODE into ASCII. \n #It will also strip any possiblity of using a foreign language!\n #converter = Iconv.new('ASCII//IGNORE//TRANSLIT', 'UTF-8') \n #html = converter.iconv(html).unpack('U*').select{ |cp| cp < 127 }.pack('U*')\n # keep only the things we want.\n unless (Sanitize::Config::RELAXED[:attributes][\"table\"].include?(\"align\"))\n Sanitize::Config::RELAXED[:attributes][\"table\"] << \"align\"\n end\n\n config = Sanitize::Config::RELAXED\n if (html.encoding.name == 'ASCII-8BIT')\n config[:output_encoding] = 'ASCII'\n end\n html = Sanitize.clean( html, config)\n\n # butt up any tags\n html.gsub! />\\s+</ , '><'\n\n #remove email address lines\n html.gsub! email_regex , '<p>'\n\n # post sanitize cleanup of empty blocks\n # the order of removal is import - this is the way word stacks these elements\n html.gsub! /<i><\\/i>/ , ''\n html.gsub! /<b><\\/b>/ , ''\n html.gsub! /<\\/b><b>/ , ''\n html.gsub! /<p><\\/p>/ , ''\n html.gsub! /<p><b><\\/b><\\/p>/ , ''\n\n # misc - fix butted times\n html.gsub! /(\\d)am / , '\\1 am '\n html.gsub! /(\\d)pm / , '\\1 pm '\n # misc - remove multiple space that may cause doc specific regexs to fail (in dates for example)\n html.gsub! /\\s+/ , ' '\n\n # add new lines at the end of lines\n html.gsub! /<\\/(p|h\\d|dt|dd|dl)>/, '</\\1>' + \"\\n\"\n html.gsub! /<dl>/ , '<dl>' + \"\\n\"\n\n self.contents = html\n end\n end",
"def html_summarize_by_chars(text, length = 270, omission = '...')\n return '' if text.blank?\n truncate_on_word(strip_tags(text), length, omission)\n end",
"def description= desc\n super(Rails::Html::FullSanitizer.new.sanitize(desc))\n end",
"def itunes_summary\n if @itunes_summary.nil?\n @itunes_summary = FeedTools::XmlHelper.select_not_blank([\n FeedTools::XmlHelper.try_xpaths(self.channel_node, [\n \"itunes:summary/text()\"\n ], :select_result_value => true),\n FeedTools::XmlHelper.try_xpaths(self.root_node, [\n \"itunes:summary/text()\"\n ], :select_result_value => true)\n ])\n unless @itunes_summary.blank?\n @itunes_summary =\n FeedTools::HtmlHelper.unescape_entities(@itunes_summary)\n @itunes_summary =\n FeedTools::HtmlHelper.sanitize_html(@itunes_summary)\n @itunes_summary.strip!\n else\n @itunes_summary = nil\n end\n end\n return @itunes_summary\n end",
"def clean_article_body\n get_source_selectors.each do |selector|\n if @page.search(selector).present?\n @page = page.search(selector)\n break\n end\n end\n # Strip unwanted spaces and newlines.\n @page.collect {|elt| elt.content.strip.gsub(/\\n|\\r/, '').gsub(/\\ +/, ' ')}.join(' ')\n end",
"def site_description\n headings = @doc.xpath(\"//h3[@class='clearl']\")\n content_sections = @doc.xpath(\"//h3[@class='clearl']/following-sibling::p[1]\")\n content = \"\"\n headings.zip(content_sections).each do |h, c| \n unless (c.to_s().squeeze().empty?)\n content << \"<h3>#{sanitize(h.to_s)}</h3>\" \n content << \"<p>#{sanitize(c.to_s)}\"\n end\n end\n rhtml = IO.read(File.expand_path(\"site_description.rhtml\", File.dirname(__FILE__)))\n content_html = Erubis::Eruby.new(rhtml)\n content_html.result(:content => content)\n end",
"def summary\n description_section.first\n end",
"def description\n desc = details.at(\"div.summary_text[itemprop='description']\").text.strip.clean_description rescue nil\n (desc.nil? || desc.empty?) ? nil : desc\n end",
"def set_summary_string(summary)\n @summary = summary.strip\n if @customers != ''\n @summary = @summary + \" - \" + @customers\n end\n end",
"def summary\n @summmary ||= (split(/\\.|\\r?\\n\\r?\\n/).first || '')\n @summmary += '.' unless @summmary.empty?\n @summmary\n end",
"def _validate_summary(s)\n if s.length > 140\n results.add_warning('summary', 'The summary should be a short ' \\\n 'version of `description` (max 140 characters).')\n end\n if s =~ /A short description of/\n results.add_warning('summary', 'The summary is not meaningful.')\n end\n end",
"def set_meta_description\n html = html_overview || html_content || ''\n\n self.meta_description =\n html.\n gsub(/<\\/?[^>]*>/, ' '). # replace HTML tags with spaces\n gsub(/&\\w{1,9};|\"/, ''). # remove HTML special chars and double quotes\n gsub(/\\n+/, \" \"). # remove new lines\n gsub(/\\s+/, ' '). # remove duplicated spaces\n strip[0..200] # strip spaces and get first 200 chars\n end",
"def get_test_run_summary_report(test_report, test_summary)\n file_data = test_report\n file_lines = file_data.split(\"\\n\")\n\n=begin\n #Remove the duplicate headings\n title = 0\n i = 0\n file_lines.each do |line|\n i += 1\n if line.match(/<h1 align='center'><u>(\\w|\\s)+<\\/u><\\/h1><br\\/>/)\n title += 1\n if title > 1\n file_lines.delete_at(i-1)\n end\n end\n end\n=end\n\n test_run_summary = <<-EOS\n <h1 align='center'><u>#{test_summary[:title]}<\\/u><\\/h1><br\\/>\n EOS\n\n #Get the test run details from the report\n file_data.match(/<td>Kadu server:(.+)<\\/td>/)\n kadu_server = $1\n test_suites = file_data.scan(/<th align=\"center\">(.+)<\\/th>/)\n test_suite_status = file_data.scan(/Test suite status: <font id=(statuspass|statusfail)>(.*)<\\/font>/)\n\n i = 0\n test_status = {}\n test_suites.each do |test_suite|\n test_status[test_suite] = test_suite_status[i]\n i +=1\n end\n\n test_status = test_status.sort_by{|name,status| status}\n\n test_run_time_in_secs = Time.parse(test_summary[:test_run_end_time].to_s) - Time.parse(test_summary[:test_run_start_time].to_s)\n\n # Get the test case numbers\n passed_tcs = 0\n failed_tcs = 0\n blocked_tcs = 0\n\n file_lines.each do |line|\n passed_tcs +=1 if line.match(\"Test result status: <font id=statuspass>PASS</font>\")\n failed_tcs +=1 if line.match(\"Test result status: <font id=statusfail>FAIL</font>\")\n blocked_tcs +=1 if line.match(\"Test result status: <font id=statusfail>BLOCK</font>\")\n end\n total_tcs_count = passed_tcs + failed_tcs + blocked_tcs\n\n #Create the test run summary section\n test_run_summary += <<-EOS\n <a name=summary></a>\n <table id=\"specifications\" width=\"500px\">\n <tr><td><strong>Kadu Server:</strong></td><td>#{kadu_server}</td></tr>\n <tr><td><strong>Country:</strong></td><td>#{test_summary[:country]}</td></tr>\n <tr><td><strong>Test Run Started On:</strong></td><td>#{test_summary[:test_run_start_time]}</td></tr>\n <tr><td><strong>Duration:</strong></td><td>#{test_run_time_in_secs} secs</td></tr>\n <tr><td><strong>Number of test cases executed:</strong></td><td>#{total_tcs_count}</td></tr>\n <tr><td><strong>Number of test cases passed:</strong></td><td>#{passed_tcs}</td></tr>\n <tr><td><strong>Number of test cases failed:</strong></td><td>#{failed_tcs}</td></tr>\n <tr><td><strong>Number of test cases blocked:</strong></td><td>#{blocked_tcs}</td></tr>\n </table>\n <br>\n EOS\n if !test_summary[:known_issues].nil?\n test_run_summary += <<-EOS\n #{get_fail_test_details(test_summary[:known_issues])}\n <br>\n EOS\n end\n\n test_run_summary += <<-EOS\n <table id=\"specifications\" width=\"900px\">\n <tr>\n <th >Test Suite</th>\n <th >Test Suite Status</th>\n </tr>\n EOS\n i = 0\n test_status.each do |suite_name,suite_status|\n test_run_summary += <<-EOS\n <tr>\n <td><a href=\"##{replace_space_by_dash(suite_name.to_s.gsub(/\"|\\[|\\]/,''))}\">#{suite_name.to_s.gsub(/\"|\\[|\\]/,'')}</a></td>\n <td><font id=#{suite_status[0]}>#{suite_status[1]}</font></td>\n </tr>\n EOS\n i +=1\n end\n test_run_summary += <<-EOS\n </table>\n <br>\n <hr size=2 color=\"#000080\">\n <br/>\n EOS\n\n # Convert the section into array and add it to the file at the start.\n test_run_summary = test_run_summary.split(\"\\n\")\n i = 0\n file_lines.each do |line|\n i += 1\n if line.match(/<center>/)\n j = i\n test_run_summary.each do |row|\n file_lines.insert(j,row)\n j +=1\n end\n break\n end\n end\n\n report = \"\"\n file_lines.each do |line|\n report += <<-EOS\n #{line}\n EOS\n end\n report\n end",
"def stats_summary\n html = \"\"\n %w(inhale exhale cycle).each do |phase|\n %w(min max avg).each do |stat|\n time = format_time(self.meditations.map {|med| med.send(phase + \"_\" + stat)}.max)\n html += \"record #{phase} #{stat}: #{time}<br>\"\n end\n end\n html\n end",
"def strip_html_tags!\n @raw.gsub!(/<[^>]+?>/, ' ')\n end",
"def text_wikimedia_html page\n html = @client.text_wikimedia_html page\n # normalize html by removing <!-- html comments -->\n doc = Nokogiri.HTML html\n (doc.xpath '//comment()').remove\n doc.inner_html\n end",
"def print_summary\n puts \"\\n\\nScore : # Instances\\n\" << (\"=\" * 19)\n @summary_totals.each_with_index { |value, index| puts \" %5d:%8d\\n\" % [index, value] unless value.nil? }\n puts \"\\n** End of Report\"\n end",
"def summary\n @data['summary']\n end",
"def get_duties_summary(page)\n page.css(WebScraper::JOB_DETAILS_SELECTOR)[WebScraper::JOB_DUTIES_SUM_POS].content.strip\n end",
"def run\n\t\t\tsummary\n\t\tend",
"def description_html\n Redcarpet::Markdown.new(Redcarpet::Render::HTML).render(description)\n end",
"def summaryX\n render :layout => \"general\"\n end"
] |
[
"0.7422649",
"0.7302963",
"0.7220527",
"0.716317",
"0.71277595",
"0.71272093",
"0.70591176",
"0.68869823",
"0.6794872",
"0.6727793",
"0.6624929",
"0.64273643",
"0.64220995",
"0.6385799",
"0.63471955",
"0.6271075",
"0.6197062",
"0.6189212",
"0.6189212",
"0.61786336",
"0.61470395",
"0.61337674",
"0.61207974",
"0.61041266",
"0.6101733",
"0.6093094",
"0.60930336",
"0.60856885",
"0.6072493",
"0.60608023",
"0.60608023",
"0.60608023",
"0.60608023",
"0.6057181",
"0.60563356",
"0.60522956",
"0.604116",
"0.60361207",
"0.60361207",
"0.6009644",
"0.5976703",
"0.59617645",
"0.5948143",
"0.5937473",
"0.59026957",
"0.5886992",
"0.5855672",
"0.585538",
"0.58497",
"0.58497",
"0.58497",
"0.584621",
"0.5811682",
"0.5799738",
"0.57816344",
"0.5777939",
"0.5766355",
"0.57591563",
"0.57443225",
"0.57251984",
"0.5716008",
"0.5714197",
"0.5714197",
"0.5714197",
"0.5711732",
"0.5704445",
"0.57013017",
"0.57001805",
"0.56945276",
"0.56878656",
"0.5666019",
"0.56623274",
"0.5660327",
"0.5647846",
"0.5636018",
"0.56341046",
"0.5632918",
"0.5630226",
"0.56221896",
"0.56052667",
"0.56041193",
"0.5604073",
"0.5601126",
"0.56008637",
"0.5591275",
"0.55898774",
"0.55874103",
"0.55858165",
"0.55844384",
"0.5584152",
"0.55832654",
"0.5581767",
"0.5579549",
"0.55700225",
"0.5565215",
"0.5563878",
"0.5560103",
"0.55494225",
"0.55493796",
"0.55448204"
] |
0.66016406
|
11
|
Truncates text at a word boundry Parameters: text The text to truncate wordcount The number of words
|
def snippet(text, max)
result = ''
count = 0
# TODO figure out support for pre that contains code blocks..
return [result, count] if is_blank?(text)
text.split.each do |word|
return [result.strip!, count] if count >= max
result << "#{word} "
count += 1
end
[result.strip!, count]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def truncate\n @text.truncate_words(@word_num, omission: \"#{@cut_off}\")\n end",
"def truncate( text, num_words = 6, truncate_string = \"...\" )\n if text.nil? then return end\n arr = text.split( ' ' )\n arr.length > num_words ? arr[ 0...num_words ].join( ' ' ) + truncate_string : text\nend",
"def truncate_words(text, length, end_string = ' ... ')\n unless text.nil?\n \twords = text.split()\n \twords = words[0...length].join(' ') + (words.length > length ? end_string : ' ')\n end\nend",
"def truncate( text, num_words = 6, truncate_string = \" [...]\" )\n if text.nil? then return end\n arr = text.split( ' ' )\n arr.length > num_words ? arr[ 0...num_words ].join( ' ' ) + truncate_string : text\nend",
"def truncate_words(text, length = 30, end_string = ' ...')\n return if text == nil\n words = text.split\n words[0..(length-1)].join(' ') + (words.length > length ? end_string : '')\n end",
"def shrink_text(text, num_words=5)\n text = text.split[0..(num_words-1)].join(\" \") + (text.split.size > num_words ? \"...\" : \"\")\n return text\n end",
"def truncate text\n length = text.length\n characters = @characters\n @characters += length\n\n return text if @characters < @character_limit\n\n remaining = @character_limit - characters\n\n text =~ /\\A(.{#{remaining},}?)(\\s|$)/m # TODO word-break instead of \\s?\n\n $1\n end",
"def truncate_on_word_boundary(string, options = {})\n StringHelpers.truncate_on_word_boundary(string, options[:min_chars] || 0, options[:max_chars] || 140) || \"\"\n end",
"def truncate_without_splitting_words(text, length = 50, ellipsis = true)\n truncated_result = ''\n remaining_length = length\n stop = false\n truncated = false\n # lines\n text.split(\"\\n\").each do |l|\n # words\n l.split(' ').each do |w|\n # If we're going to go over the length, and we've not already\n if (remaining_length - w.length) <= 0 && !stop\n truncated = true\n stop = true\n # Decide if adding or leaving out the last word puts us closer to the desired length\n if (remaining_length - w.length).abs < remaining_length.abs\n truncated_result += (w + ' ')\n end\n elsif !stop\n truncated_result += (w + ' ')\n remaining_length -= (w.length + 1)\n end\n end\n truncated_result += \"\\n\"\n end\n # Need some kind of whitespace before elipses or auto-link breaks\n html = truncated_result.strip + (truncated && ellipsis ? \"\\n...\" : '')\n html.html_safe\n end",
"def truncate_without_splitting_words(text, length=50)\n truncated_result = \"\"\n remaining_length = length\n stop = false\n truncated = false\n #lines\n text.split(\"\\n\").each do |l|\n #words\n l.split(\" \").each do |w|\n #If we're going to go over the length, and we've not already\n if (remaining_length - w.length) <= 0 && !stop\n truncated = true\n stop = true\n #Decide if adding or leaving out the last word puts us closer to the desired length\n if (remaining_length-w.length).abs < remaining_length.abs\n truncated_result += (w + \" \")\n end\n elsif !stop\n truncated_result += (w + \" \")\n remaining_length -= (w.length + 1)\n end\n end\n truncated_result += \"\\n\"\n end \n #Need some kind of whitespace before elipses or auto-link breaks\n truncated_result.strip + (truncated ? \"\\n...\" : \"\")\n end",
"def truncate_without_splitting_words(text, length = 50)\n truncated_result = ''\n remaining_length = length\n stop = false\n truncated = false\n # lines\n text.split(\"\\n\").each do |l|\n # words\n l.split(' ').each do |w|\n # If we're going to go over the length, and we've not already\n if (remaining_length - w.length) <= 0 && !stop\n truncated = true\n stop = true\n # Decide if adding or leaving out the last word puts us closer to the desired length\n if (remaining_length - w.length).abs < remaining_length.abs\n truncated_result += (w + ' ')\n end\n elsif !stop\n truncated_result += (w + ' ')\n remaining_length -= (w.length + 1)\n end\n end\n truncated_result += \"\\n\"\n end\n # Need some kind of whitespace before elipses or auto-link breaks\n html = truncated_result.strip + (truncated ? \"\\n...\" : '')\n html.html_safe\n end",
"def truncate(text, *args)\n options = args.last.is_a?(Hash) ? args.pop : {}\n\n # support either old or Rails 2.2 calling convention:\n unless args.empty?\n options[:length] = args[0] || 30\n options[:omission] = args[1] || \"…\"\n end\n\n options = {:length => 30, :omission => \"…\"}.merge(options)\n options[:length] = options[:length].to_i\n\n return \"\" if !text\n chars = mb_charify(text)\n\n\n # If we can return it straight away or rstrip it and return it, we do it here\n if chars.length <= options[:length]\n return text\n elsif (chars = rstrip_with_nbsp(chars)).length <= options[:length]\n return chars.to_s\n end\n\n omission = mb_charify(options[:omission])\n\n # Here we know we have to remove at least 1 word\n # 1. Get the first l characters\n # 2. Remove the last word if it's a part\n # 3. Add omission\n length_wo_omission = options[:length] - omission.length\n\n return '' if length_wo_omission < 0\n\n result = rstrip_with_nbsp(chars[0...length_wo_omission] || \"\")\n\n # Remove the last word unless we happened to trim it exactly already\n unless chars[length_wo_omission] =~ WHITESPACE || result.length < length_wo_omission\n len = result.split(WHITESPACES).last\n len &&= len.length\n result = rstrip_with_nbsp(result[0...(result.length - (len || 0))])\n end\n\n result += options[:omission]\n result.to_s\n end",
"def wp_trim_words(text, num_words = 55, more = nil)\n if more.nil?\n more = '…'\n end\n\n original_text = text\n text = wp_strip_all_tags(text)\n\n if false # no asian...\n else\n words_array = text.split(/[\\n\\r\\t ]+/, num_words + 1)\n sep = ' '\n end\n\n if words_array.length > num_words\n words_array.pop\n text = words_array.join(sep)\n text = text + more\n else\n text = words_array.join(sep)\n end\n\n # Filters the text content after words have been trimmed.\n apply_filters('wp_trim_words', text, num_words, more, original_text)\n end",
"def truncate(text, *args)\n options = args.extract_options!\n unless args.empty?\n options[:length] = args[0] || 30\n options[:omission] = args[1] || \"...\"\n end\n options.reverse_merge!(:length => 30, :omission => \"...\")\n\n if text\n l = options[:length] - options[:omission].mb_chars.length\n chars = text.mb_chars\n (chars.length > options[:length] ? chars[0...l] + options[:omission] : text).to_s\n end\n end",
"def shortened_tweet_truncator(tweet) \n if word_substitutor(tweet).length > 140 \n word_substitutor(tweet)[0...137] + \"...\"\n else \n tweet\n end \nend",
"def awesome_truncate(text, length = 30, truncate_string = \"...\")\n return if text.nil?\n l = length - truncate_string.mb_chars.length\n text.mb_chars.length > length ? text[/\\A.{#{l}}\\w*\\;?/m][/.*[\\w\\;]/m] + truncate_string : text\n end",
"def awesome_truncate(text, length = 30, truncate_string = \"...\")\n return if text.nil?\n l = length - truncate_string.mb_chars.length\n text.mb_chars.length > length ? text[/\\A.{#{l}}\\w*\\;?/m][/.*[\\w\\;]/m] + truncate_string : text\n end",
"def awesome_truncate(text, length = 30, truncate_string = \"...\")\n return if text.nil?\n l = length - truncate_string.mb_chars.length\n text.mb_chars.length > length ? text[/\\A.{#{l}}\\w*\\;?/m][/.*[\\w\\;]/m] + truncate_string : text\n end",
"def awesome_truncate(text, length = 30, truncate_string = \"...\")\n return if text.nil?\n l = length - truncate_string.mb_chars.length\n text.mb_chars.length > length ? text[/\\A.{#{l}}\\w*\\;?/m][/.*[\\w\\;]/m] + truncate_string : text\nend",
"def shortened_tweet_truncator(tweet)\n if word_substituter(tweet).length > 140\n word_substituter(tweet)[0..136] + '...'\n else\n tweet\n end\nend",
"def shortened_tweet_truncator(tweet)\n if word_substituter(tweet).length <= 140\n word_substituter(tweet)\n else\n word_substituter(tweet)[0..136] << \"...\" \n end\nend",
"def cut_words (words, limit)\n words = words.split(\" \")\n result = \"\"\n result += words.first(limit).join(\" \")\n result += \"...\" if words.length > limit\n raw result\n end",
"def shortened_tweet_truncator(tweet)\n\n if tweet.length <= 140\n tweet\n else\n word_substituter(tweet)[0..136] + \"...\"\n end\nend",
"def shortened_tweet_truncator(tweet)\n if tweet.length < 140\n tweet\n else\n word_substituter(tweet)[0...140]\n end\nend",
"def trim_to_word( max_length )\n string = self\n if string.length > max_length\n string = string[0..max_length-4]\n while string[-1,1] =~ /[\\w]/ && string.length > 1\n string = string[0..string.length-2]\n end\n string += \"...\"\n end\n string\n end",
"def truncate_from_end(text)\n return text if text.blank? || text.size <= 20\n \n \"...#{text[-20, 20]}\"\n end",
"def truncate_from_end(text)\n return text if text.blank? || text.size <= 20\n \n \"...#{text[-20, 20]}\"\n end",
"def shortened_tweet_truncator(tweet)\n if tweet.length > 140\n temp = word_substituter(tweet)\n temp = temp[0..139] if temp.length >140\n temp\n else\n tweet\n end\nend",
"def truncate(text, length = 30, truncate_string = \"...\")\n if text\n l = length - truncate_string.chars.length\n chars = text.chars\n #$log.info(chars[0..10])\n (chars.length > length ) ?\n (chars[0...l] + truncate_string.chars).join('').to_s :\n text\n end\n end",
"def truncate_sentence(text, options = {})\n sentence_break = text.rindex(/[\\.\\?\\!]/, options[:length])\n sentence_break ? text[0, sentence_break++1] : \"\"\n end",
"def smart_truncate(opts = {})\n opts = {:words => 12}.merge(opts)\n if opts[:sentences]\n return self.split(/\\.(\\s|$)+/).reject{ |s| s.strip.empty? }[0, opts[:sentences]].map{|s| s.strip}.join('. ') + '...'\n end\n a = self.split(/\\s/) # or /[ ]+/ to only split on spaces\n n = opts[:words]\n a[0...n].join(' ') + (a.size > n ? '...' : '')\n end",
"def truncate_words(options = {})\n stripped = ActionController::Base.helpers.strip_tags(self)\n\n max_length = options[:max_chars] || 100\n omission = options[:omission] || \"...\"\n center = options[:center]\n highlight = [options[:highlight]].flatten.compact\n highlight_class = options[:highlight_class] || \"highlight\"\n\n if max_length < stripped.length\n if center\n r_limit = stripped.index(center) + center.length + ((max_length - center.length) / 2) - 1 - omission.length\n l_limit = stripped.index(center) - ((max_length - center.length) / 2) + omission.length\n\n if l_limit < 0\n r_limit -= l_limit\n r_limit += omission.length\n l_limit = 0\n end\n if r_limit > stripped.length\n l_limit -= r_limit - stripped.length\n l_limit -= omission.length\n r_limit = stripped.length\n end\n result = stripped[l_limit..r_limit]\n if l_limit >0 && stripped[l_limit-1,1] != \" \"\n result = result[result.index(\" \")+1..-1]\n end\n if r_limit < stripped.length && stripped[r_limit + 1,1] != \" \"\n result = result[0..(result.rindex(\" \")-1)]\n end\n\n result = omission + result + omission\n else\n limit = max_length - 1 - omission.length\n result = stripped[0..limit]\n if stripped[limit + 1,1] != \" \"\n if result.rindex(\" \")\n result = result[0..(result.rindex(\" \")-1)]\n else\n result = \"\"\n end\n end\n result += omission\n end\n else\n result = stripped\n end\n\n highlight.each do |h|\n result = result.gsub(h, \"<span class=\\\"#{highlight_class}\\\">#{h}</span>\")\n end\n result\n\n\n end",
"def truncate(text, length = 100, truncate_string = '...')\n l = length - truncate_string.length\n (text.length > length ? text[0...l] + truncate_string : text).to_s\n end",
"def truncate(text, length = 30, truncate_string = \"...\")\n if text.nil? then return end\n l = length - truncate_string.chars.length\n (text.chars.length > length ? text.chars[0...l] + truncate_string : text).to_s\n end",
"def soft_truncate(string, length, soft_limit=nil)\n return '' unless string\n string.strip!\n return string if string.length <= length\n firstpart = string[0..(length-1)]\n afterpart = string[length..-1]\n does_not_start_with_whitespace = afterpart[/^\\S/]\n afterpart.strip!\n return firstpart if afterpart.empty?\n return firstpart << ' ...' unless soft_limit && does_not_start_with_whitespace\n afterword = afterpart[/(\\S+)/][0..(soft_limit-1)]\n afterword << ' ...' if afterpart.length > afterword.length\n firstpart << afterword\n end",
"def shorten(text, length)\n if text.length <= length - 1\n text\n else\n text[0..length - 1] + \"...\"\n end\n end",
"def awesome_truncate(text, length = 30, truncate_string = \"…\")\n return \"\" if text.blank?\n\n l = length - truncate_string.mb_chars.length\n result = text.mb_chars.length > length ? (text[/\\A.{#{l}}\\w*\\;?/m][/.*[\\w\\;]/m] || '') + truncate_string : text\n result.html_safe\n end",
"def first_n_words( n , text )\n words = text.split[0...n]\n words.join(' ') + if words.size == n then '...' else '' end\n end",
"def truncate(text, options={})\n options[:length] ||= 30\n options[:omission] ||= \"...\"\n\n if text\n l = options[:length] - options[:omission].length\n chars = text\n stop = options[:separator] ? (chars.rindex(options[:separator], l) || l) : l\n (chars.length > options[:length] ? chars[0...stop] + options[:omission] : text).to_s\n end\n end",
"def word_wrap(txt, maxlen, word_pattern = DEFAULT_WORD_PATTERN)\n words = txt.scan(word_pattern)\n\n words.each_with_object(['']) do |word, lines|\n last = lines.last\n wordlen = word.rstrip.length\n\n if wordlen > maxlen\n lines.concat(word.scan(/.{1,#{maxlen}}/))\n elsif last != '' && last.length + wordlen > maxlen\n lines << word\n else\n lines.last << word\n end\n end.delete_if(&:empty?).each(&:strip!)\n end",
"def truncate(text, length = 30, truncate_string = \"...\")\n return \"\" if text.nil?\n l = length - truncate_string.size\n text.size > length ? (text[0...l] + truncate_string).to_s : text\n end",
"def shorten (string, word_limit = 10)\n words = string.split(/\\s/)\n if words.size >= word_limit\n words[0,(word_limit-1)].join(\" \") + '...'\n else \n string\n end\n end",
"def truncate(input, length)\n if input.length > length && input[0..(length - 1)] =~ /(.+)\\b.+$/im\n $1.strip + '...'\n else\n input\n end\n end",
"def truncate_on_word_boundary(str, min_len, max_len, spillover_if_necessary=false, start_offset=0, add_trailer=true)\n return \"\" if blank(str)\n more_url_link = yield if block_given?\n s = truncate(str, min_len, max_len, true, start_offset, add_trailer, more_url_link)\n return s if !s.nil?\n\n ## What to do if we fail?\n if s.nil? && spillover_if_necessary\n i = str[start_offset+max_len..str.length].index(@@separators)\n return str if i.nil?\n\n retval = str[start_offset..start_offset+max_len+i-1]\n retval += \"...\" if add_trailer\n retval += \" #{more_url_link}\" unless blank(more_url_link)\n return retval\n else\n return nil ## Return nil so that the user knows that this is an exceptional condition and handles it appropriately\n end\n end",
"def remove_w_words(sentence)\n \nend",
"def shortened_tweet_truncator(tweet_string)\n if tweet_string.length > 140\n tweet_string[0..136] + \"...\"\n else\n tweet_string\n end\nend",
"def shortened_tweet_truncator(tweet)\n short = word_substituter(tweet)\n if short.length > 140\n short[0..139]\n else\n short\n end\nend",
"def word_wrap(text, _length = T.unsafe(nil)); end",
"def truncate(str, min_chars, max_chars, word_boundary_only=false, start_offset=0, add_trailer=true, more_url_link=\"\")\n return \"\" if blank(str)\n\n ## Fetch the substring\n s = (start_offset == 0) ? str: str[start_offset..start_offset+max_chars] \n\n ## Clone so that behavior is consistent -- in all other cases, a string different from 'str' is returned\n return ((start_offset == 0) ? s.clone : s) if (s.length <= max_chars) \n\n char_offset = max_chars - 1\n if (add_trailer)\n char_offset -= 4 # because we are going to append \" ...\" at the end\n min_chars -= 4 # because we are going to append \" ...\" at the end\n end\n unless blank(more_url_link)\n char_offset -= 7 # because we are going to append \" More >>\" at the end\n min_chars -= 7 # because we are going to append \" More >>\" at the end\n end\n s = s[0..char_offset]\n\n more_trailer = blank(more_url_link) ? \"\" : \" #{more_url_link}\"\n\n pos = s.rindex(@@separators)\n if (!pos.nil? && (pos >= min_chars))\n s = s[0..pos-1]\n return (add_trailer) ? s + ' ...' + more_trailer : s\n elsif (word_boundary_only)\n nil ## Return nil so that the user knows that this is an exceptional condition and handles it appropriately\n else\n s[char_offset] = '-' ## Indicate that the word was truncated mid-way!\n return (add_trailer) ? s + ' ...' + more_trailer : s\n end\n end",
"def filter new_text\n allowed_length = [LENGTH_LIMIT - text.length, 0].max\n new_text[0, allowed_length]\n end",
"def long_word_count(text)\n \nend",
"def shortened_tweet_truncator(tweet)\n # shortened_tweet stores the new shortened tweet to be returned for this method\n # Instantiated with the shortened tweet using #word_substituter\n shortened_tweet = word_substituter(tweet)\n\n # Checks to see if the length of shortened_tweet is longer than 140 characters\n # If true, truncates the tweet to 140 characters with an ellipsis (...). The ellipsis is included in the count\n if shortened_tweet.length > 140\n shortened_tweet = shortened_tweet[0..136]\n shortened_tweet << \"...\"\n end\n\n # Returns the shortened tweet\n shortened_tweet\nend",
"def truncate_in_middle(text, length = 30, truncate_string = \"...\".html_safe)\n if text\n l = (length - truncate_string.length) / 2\n return text if length > text.length\n return text[0...l] + truncate_string + text[-l..-1]\n end\n end",
"def word_wrap(text, *args)\n options = args.extract_options!\n unless args.blank?\n options[:line_width] = args[0] || 80\n end\n options.reverse_merge!(:line_width => 80)\n\n text.split(\"\\n\").collect do |line|\n line.length > options[:line_width] ? line.gsub(/(.{1,#{options[:line_width]}})(\\s+|$)/, \"\\\\1\\n\").strip : line\n end * \"\\n\"\n end",
"def wordwrap(text, width=120, string='<wbr />')\n wrapped = ''\n\n # Get array of words and loop through them.\n (text).scan(/\\w+/).each do |word|\n\n new_word = ''\n if word.length > width\n ((word.length / width)+1).times do |i|\n range = (width*i)..((width*(i+1))-1)\n new_word += word[range] + string\n end\n end\n new_word = word unless word.length > width\n\n wrapped += new_word + ' ' + string\n end\n\n wrapped\n end",
"def shorten(text, chars=20)\n text.length > chars ? \"#{text[0..chars-3]}...\" : text\n end",
"def shortened_tweet_truncator(tweet)\n shortened_tweet = selective_tweet_shortener(tweet)\n if tweet.length < 140 \n tweet\n elsif\n shortened_tweet.length > 140 \n shortened_tweet[0...140-3] + \"...\" \n else\n shortened_tweet\nend\nend",
"def filter_long_words(sentence, n)\n #your code here\n words = []\n for word in sentence.split(\" \")\n words << word if word.length > n\n end\n words\nend",
"def delete_last_n_characters_in_word(word,n)\r\n start = word.Selection.Start\r\n word.Selection.Start = start - n\r\n word.Selection.End = start\r\n word.Selection.Delete\r\nend",
"def truncate(length = 30)\n return self if self.length < length\n self[0..length].gsub(/\\s\\w+\\s*$/, '...')\n end",
"def shortened_tweet_truncator(tweet_one)\n if tweet_one.length > 140\n tweet_one[0..139] \n else\n tweet_one\n end\nend",
"def shrink_to_fit(text)\n wrap(text)\n until @everything_printed || @font_size <= @min_font_size\n @font_size = [@font_size - 0.3, @min_font_size].max\n @document.font_size = @font_size\n wrap(text)\n end\n end",
"def abbreviate( text, wordcount )\n if text.nil? \n return \"\"\n end\n comps = text.gsub(/(\\s)+/, \" \").split(\" \");\n res = \"\";\n limit = wordcount;\n limit = comps.size if limit > comps.size;\n limit = 0 if limit < 2 \n\n for i in 0..(limit-2)\n res = res + comps[i] + \" \" if ! comps[i].nil?;\n end\n res += comps[limit-1] if ! comps[limit-1].nil?;\n\n res += \"...\" if comps.size > wordcount;\n\n return res;\n end",
"def shortened_tweet_truncator(tweet)\n selective_tweet_shortener(tweet)\n if tweet.length >= 140\n tweet[0...137].concat(\"...\") #(...) is 3 characters!\n else\n tweet if tweet.length < 140\n end\nend",
"def truncate(text, url)\n return text if text.bytesize <= TEXT_BYTESIZE_MAX\n tail = \"...\\n<#{url}|Read more at Qiita:Team...>\"\n text.byteslice(0, TEXT_BYTESIZE_MAX - tail.bytesize).scrub(\"\") + tail\n end",
"def truncate_paragraph(long_str, num_characters, truncated_indicator=\"...\")\nend",
"def limit_text_length (string_to_put_limitation, max_length)\n\n if string_to_put_limitation.length > max_length\n\n limited_string = string_to_put_limitation[0..max_length].gsub(/\\s\\w+\\s*$/,'...')\n\n return limited_string\n\n else\n\n return string_to_put_limitation\n\n end#string size check\n\n end",
"def notebooktext_short\n truncate_text_words(self.notebooktext, 100)\n end",
"def long_word_count(text)\n text.split.select {|word| word.length > 7}.count\nend",
"def selective_tweet_shortener(tweet)\n if tweet.length > 140 \n tweet = word_substituter(tweet)\n end\n tweet\nend",
"def word_wrap(text, options = {})\n line_width = options.fetch(:line_width, 80)\n\n text.split(\"\\n\").collect! do |line|\n line.length > line_width ? line.gsub(/(.{1,#{line_width}})(\\s+|$)/, \"\\\\1\\n\").strip : line\n end * \"\\n\"\nend",
"def long_word_count(text)\n #\n # your code goes here\n #\n counter = 0\n text.split.each do |word|\n counter += 1 if word.length > 7\n end\n\n counter\nend",
"def textwidth(txt, width=nil)\n push\n start = CGContextGetTextPosition(@ctx)\n CGContextSetTextDrawingMode(@ctx, KCGTextInvisible)\n CGContextShowText(@ctx, txt, txt.length)\n final = CGContextGetTextPosition(@ctx)\n pop\n final.x - start.x\n end",
"def word_wrap(text, *args)\n options = extract_options_from_args!(args) || {}\n unless args.blank?\n options[:line_width] = args[0] || 80\n end\n options.reverse_merge!(:line_width => 80)\n\n text.split(\"\\n\").collect do |line|\n line.length > options[:line_width] ? line.gsub(/(.{1,#{options[:line_width]}})(\\s+|$)/, \"\\\\1\\n\").strip : line\n end * \"\\n\"\n end",
"def cut_words(length)\n @words = @words.select do |word|\n word.length == length\n end\n end",
"def snippet(text, wordcount, omission)\n return '' if text.blank?\n text.split[0..(wordcount-1)].join(\" \") + (text.split.size > wordcount ? \" \" + omission : \"\")\n end",
"def selective_tweet_shortener(tweet)\n if tweet.length > 140 \n word_substituter(tweet)\n #\"...\"\n else\n tweet\n end\nend",
"def cutoff(str, limit = 100)\n if str.length > limit\n str[0, limit] + '...'\n else\n str\n end\n end",
"def words_to(n)\r\n re = Regexp.new(\"^(.{0,#{n}})(?:\\s|$)\")\r\n text =~ re\r\n $1 || text[0...n]\r\n end",
"def long_word_count(text)\n count = 0\n text.split(\" \").each do |element|\n if element.split(\"\").length > 7\n count += 1\n end\n end\n return count\n \nend",
"def most_com_word(text, min: 3)\n freq = word_freq(text).delete_if { |x, y| x.length} <= min}\nend",
"def short_text(text, max_length)\n short = text\n if text.present? && text.length > max_length\n short_array = text.slice(0, max_length).split(' ')\n short_array.pop\n short = short_array.join(' ') + ' ...'\n end\n short\n end",
"def truncate_paragraph(long_str, num_characters, truncated_indicator=\"...\")\n if long_str.length <= num_characters\n return long_str\n else \n return long_str.split(//).first(num_characters).join + \" \" + (truncated_indicator) \n end\n \n\nend",
"def delete_right_word\n chars = @text.scan(/./m)\n position = @cursor_position\n # skip all non-whitespaces first\n while position < chars.size && chars[position] != ' '\n position += 1\n end\n # skip all whitespaces\n while position < chars.size && chars[position] == ' '\n position += 1\n end\n delete_right(position - @cursor_position) if position > @cursor_position\n self.reset_cursor_blinking\n end",
"def condenseString(text)\n condensed = strip_tags( markdown text )\n if(condensed.length > 300)\n condensed = condensed[0...299] + \"...\"\n end\n sanitize condensed\n end",
"def replace_words(text, delimiter=\" \")\n count = text.split(delimiter).count\n words(count).join(delimiter)\nend",
"def selective_tweet_shortener(tweet)\n tweet.length > 140 ? word_substituter(tweet) : tweet\nend",
"def word_count(text, len)\r\n words, strays = text.length.divmod(len)\r\n words += 1 if strays > 0\r\n pad = \"X\" * (len - strays)\r\n return [words, pad]\r\n end",
"def max_width_by_word(string)\n if !string.empty? && string.split(\" \").sort_by(&:length).last.length > 42\n return \"max-width:#{string.split(\" \").sort_by(&:length).last.length * 0.6}em;\"\n end\n return \"\"\n end",
"def selective_tweet_shortener(string)\n if string.length < 140 \n string\n else \n word_substituter(string)\n end\nend",
"def long_word_count(text)\n text.split(' ').count{|word| word.length > 7}\nend",
"def truncate() end",
"def truncate_paragraph(long_str, num_characters, truncated_indicator=\"...\")\n\n if long_str.length > num_characters\n return long_str[0...num_characters] + \" \" + truncated_indicator\n else \n return long_str\n end\n\nend",
"def nwords(s)\n n = @options[:nwords].to_i\n words = 0\n s.split(\" \").inject(\"\") do |res,word|\n if words < n\n res << \" \" << word\n words += 1 if word.size > 2\n end\n res.strip\n end\n end",
"def fakewrap(str, width, max)\n parts = str.split(/\\s+/)\n result = []\n\n # Work until were out of words\n until parts.length == 0 do\n part = ''\n\n # Work as long as we're under the character limit\n while part.length < width do\n part = [part, parts.shift].join(' ')\n end\n result << part.strip\n end\n\n # If we're over the max lines, ellipsis the last line\n if result.length > max\n result = result[0..max - 1]\n result << '...'\n end\n return result\nend",
"def big_words(str)\n # split my string into individual words\n # loop over my words\n # check the length of each word\n # if the length of the word is >= 5, keep it. \n # else delete it.\n # return joined words\n\n words = str.split(' ')\n long_words = []\n i = 0\n while i < words.length\n if words[i].length >= 5 #=> words[i] < 5\n # words.delete_at(i) # be careful of delete_at in loops.\n long_words << words[i]\n end\n i += 1\n end\n return long_words.join(' ')\nend",
"def test_truncate\n name = 'Broadmark'\n truncated = truncate(name, 5)\n assert_equal('Br...', truncated, 'truncated Broadmark')\n\n truncated = truncate(name, 9)\n assert_equal('Broadmark', truncated, 'truncated Broadmark')\n\n truncated = truncate(name, 8)\n assert_equal('Broad...', truncated, 'truncated Broadmark')\n end",
"def truncate\n title.chomp.slice(0...(width - 4))\n end",
"def lede(word_count = 25)\n doc = self.hpricot_body\n #wipe images\n doc.search(\"img\").remove\n paras = doc.search(\"//p\")\n text = \"\" \n while paras.size > 0 && text.split(\" \").size < word_count\n text += paras.shift.to_html\n end\n if (arr = text.split(\" \")).size > word_count\n return arr[0..word_count].join(\" \") + \" ...\"\n else \n return arr.join(\" \")\n end\n end",
"def width(text)\n cur_page.width(text)\n end",
"def how_many_words(text=\"I'm a cheeky monkey, dude\", num=4)\n x_words = []\n word_array = text.split(\" \")\n word_array.each do |word|\n if word.length == num\n x_words << word\n end\n end\n x_words\nend"
] |
[
"0.8006132",
"0.7943916",
"0.7894737",
"0.78400475",
"0.7774668",
"0.74910235",
"0.7342186",
"0.72614336",
"0.71379024",
"0.71034974",
"0.70580155",
"0.70544076",
"0.69960004",
"0.69745386",
"0.6945516",
"0.68938476",
"0.68938476",
"0.68938476",
"0.6878777",
"0.680703",
"0.6789955",
"0.6782534",
"0.6775626",
"0.6746475",
"0.66655946",
"0.6665582",
"0.6665582",
"0.66453785",
"0.66231",
"0.66227376",
"0.65690726",
"0.65680325",
"0.6558941",
"0.65569293",
"0.6438601",
"0.643043",
"0.6415244",
"0.6405307",
"0.64010304",
"0.6388148",
"0.63820404",
"0.63538784",
"0.63350004",
"0.62868685",
"0.6282485",
"0.62789553",
"0.6242402",
"0.62341344",
"0.62207335",
"0.62008584",
"0.62007",
"0.61884725",
"0.61772513",
"0.6175949",
"0.6150525",
"0.6131353",
"0.6127608",
"0.6082791",
"0.60754806",
"0.6068437",
"0.6035523",
"0.60326636",
"0.6023489",
"0.6017278",
"0.601432",
"0.6002972",
"0.6000719",
"0.5988077",
"0.5981575",
"0.5980965",
"0.59678185",
"0.59649956",
"0.59614915",
"0.59533346",
"0.59499776",
"0.59430707",
"0.5937003",
"0.5936372",
"0.59257025",
"0.5920538",
"0.59058625",
"0.59005773",
"0.5886931",
"0.58779126",
"0.5869028",
"0.58600676",
"0.5859767",
"0.58480805",
"0.5834883",
"0.5832916",
"0.58212364",
"0.581107",
"0.58096266",
"0.58080256",
"0.5802583",
"0.580132",
"0.5796924",
"0.579151",
"0.578352",
"0.5773441",
"0.57676005"
] |
0.0
|
-1
|
TODO: pass ident of block/whatever
|
def initialize(ident, parent=nil)
@ident = ident
@symtab = {} # key: name, value: symbol
self.parent = parent
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block_node; end",
"def block_node; end",
"def blocks; end",
"def blocks; end",
"def blocks; end",
"def block?; end",
"def block_class() Block; end",
"def id\n @block\n end",
"def id\n @block\n end",
"def block_node=(_); end",
"def blocks() end",
"def block=(_arg0); end",
"def block=(_arg0); end",
"def block_name \n to_sym\n end",
"def context(&block); end",
"def context(&block); end",
"def captured_by_block; end",
"def captured_by_block?; end",
"def what_i_am(&block)\n\t\tblock.class\n\tend",
"def block_id &block\n block.inspect =~ /(\\w+\\.rb:\\d+)/\n $1\n end",
"def block_name \n :CodeBlock \n end",
"def block_name \n :CodeBlock \n end",
"def list_block()\n\nend",
"def i_take_an_explicit_block &block\n puts block.inspect\nend",
"def parse_block(*_arg0); end",
"def hola &block\n puts block.class.name #esta linea nos dice que esto es un proc\n block.call\nend",
"def process_block_token(tk); end",
"def pre_block\n end",
"def pre_block\n end",
"def execute(&nameofblock)\n nameofblock.call\nend",
"def sup_bro\n puts \"This is before a block!\"\n name = \"Katy\"\n yield(name)\n puts \"This is after a block!\"\nend",
"def anonymous_blocklists; end",
"def parse_codeblock; end",
"def give(&my_block)\n my_block.call(\"2 turtle doves\", \"1 partridge\")\nend",
"def i_take_a_block\n yield\nend",
"def give(&my_block)\n my_block.call(\"2 turtle doves\", \"1 partridge\")\nend",
"def require_block; end",
"def callBlock\n yield\n yield\nend",
"def run(&block); end",
"def execute(&block)\n block\n #puts block #This shows the object I think.\nend",
"def foo(name, &block)\n @name = name\n block.call\nend",
"def block\n blockable.blocks.detect{|b| b.identifier == self.identifier.to_s} || \n blockable.blocks.build(:identifier => self.identifier.to_s)\n end",
"def yield; end",
"def anonymous_block_name\n self.anonymous_block_number += 1\n \"block_#{anonymous_block_number}\"\n end",
"def create_block_object(&block)\n block\nend",
"def run_block_proc\n yield\nend",
"def block_proc(&block)\n block.class\nend",
"def with_block(&block)\n end",
"def run(&block)\n end",
"def run_block\n yield\nend",
"def return(&block); end",
"def method &block\r\n\t1\r\nend",
"def method &block\r\n\t1\r\nend",
"def method &block \r\n\t1\r\nend",
"def foo(&block)\n a = 2\n block.call(a)\nend",
"def baz(name, &block)\n @name = name\n block.call\nend",
"def block_eg1(cutblock)\n puts \"this is the first message from 1 \"\n cutblock.call\n puts \"this is the middle message\"\n cutblock.call\n puts \"this is the last\\n\\n\"\nend",
"def call_this_block\n # We pass in \"foo\" to yield so that the block gets passed an argument\n block_result = yield \"foo\" # Our block returns a value, which we store in block_result\n puts block_result # then we put our result to use and print it out\nend",
"def MyBlockMethod()\n puts \"At the top of the method\"\n\tyield\n\tputs \"At the bottom of the method\"\nend",
"def block_reference_count; end",
"def block_given?() end",
"def post_block\n end",
"def post_block\n end",
"def procasaurus( &block )\n\tputs \"I am a procasaurus.\"\n\tputs block.class\n\t# note the proc must be the last parameter and must start with ampersand\nend",
"def call_block\n puts \"start\"\n yield \"foobar\" if block_given?\n puts \"end\"\nend",
"def get_toy(&block)\n block.call(\"stuffed mouse\")\n end",
"def process_blocks(blocks); end",
"def block_sample\n p \"AAA\"\n yield\n p \"BBB\"\nend",
"def block_method\n yield(\"Brandon\",\"CS\")\n yield(\"Katie\",\"Econ\")\nend",
"def run_block_proc_param\n yield(24)\nend",
"def call_block \n yield('hello', 99) \nend",
"def call_block \n yield('hello', 99) \nend",
"def blocklists; end",
"def new_block_el(*args); end",
"def block_to_loc(block)\n @block_to_loc[block]\n end",
"def get_block(*params); raise('Stub or mock required.') end",
"def take_block(&block)\n block.call\nend",
"def take_block(&block)\n block.call\nend",
"def take_block(&block)\n block.call\nend",
"def take_block(&block)\n block.call\nend",
"def take_block(&block)\n block.call\nend"
] |
[
"0.7733458",
"0.7733458",
"0.7733458",
"0.7733458",
"0.7733458",
"0.7733458",
"0.7733458",
"0.7733458",
"0.7733458",
"0.7733458",
"0.7733458",
"0.7733458",
"0.7733458",
"0.7733458",
"0.7733458",
"0.7733458",
"0.7733458",
"0.7733458",
"0.7733458",
"0.7733458",
"0.7533599",
"0.7533599",
"0.72559804",
"0.72559804",
"0.72559804",
"0.7194519",
"0.7175043",
"0.7156472",
"0.7156472",
"0.71535563",
"0.71477556",
"0.7055155",
"0.7055155",
"0.7047256",
"0.70256793",
"0.70256793",
"0.70077777",
"0.6956325",
"0.69196874",
"0.68763405",
"0.68720615",
"0.68720615",
"0.68688947",
"0.68115836",
"0.6795359",
"0.67937213",
"0.678619",
"0.6773393",
"0.6773393",
"0.6734146",
"0.6701314",
"0.66978365",
"0.6689898",
"0.6684292",
"0.6675584",
"0.6666498",
"0.6638779",
"0.6624899",
"0.6609442",
"0.65990305",
"0.65936285",
"0.6569244",
"0.6549738",
"0.65343577",
"0.6518783",
"0.6496362",
"0.6496022",
"0.6490108",
"0.6488493",
"0.6482953",
"0.648027",
"0.6477454",
"0.6477454",
"0.64721984",
"0.64641047",
"0.64571667",
"0.6454091",
"0.6408876",
"0.64083505",
"0.6403959",
"0.6401244",
"0.6384448",
"0.6384448",
"0.63831383",
"0.63797575",
"0.6377366",
"0.63769513",
"0.6355858",
"0.6342616",
"0.6342396",
"0.63417834",
"0.63417834",
"0.633832",
"0.6323761",
"0.6322408",
"0.632189",
"0.6321841",
"0.6321841",
"0.6321841",
"0.6321841",
"0.6321841"
] |
0.0
|
-1
|
=begin rdoc Child scopes. This is used mainly for symbol table generation. =end
|
def children
@children ||= []
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def scopes; end",
"def scope; end",
"def scope; end",
"def scope; end",
"def scope; end",
"def scope; end",
"def scope; end",
"def scope; end",
"def scope; end",
"def scope; end",
"def scope; end",
"def scope() binding end",
"def scopes\n read_inheritable_attribute(:scopes) || write_inheritable_attribute(:scopes, {})\n end",
"def scope_level; end",
"def namespace_scopes\n super\n end",
"def scope_name; end",
"def subscope\n self.clone\n end",
"def scope=(_); end",
"def scope\n @scope ||= Array(@root_scope) + [Inflector.underscore(name)]\n end",
"def scope\n @scope ||= Scope.new(parent)\n end",
"def scope\n if tree.columns.scope?\n tree.base_class.where Hash[tree.columns.scope.map { |column| [column, record[column]] }]\n else\n tree.base_class.where(nil)\n end\n end",
"def scope\n @scope ||= {}\n end",
"def scope\n @scope ||= {}\n end",
"def scopes\n @@scopes ||= {}\n end",
"def scopes\n @scope.scopes\n end",
"def scopes\n @scopes ||= {}\n end",
"def scopes\n self.class.scopes\n end",
"def scope\n read_attr :scope, :to_sym\n end",
"def newscope(parent, options = {})\n raise _('having multiple named scopes is not supported when scripting')\n end",
"def scope\n @scope.dup\n end",
"def scope() yield end",
"def collection_scope; end",
"def build_scope_from_columns\n self.scope\n end",
"def leave_scope\n # puts __callee__\n current_scope = symbol_table.current_scope\n parent_scope = current_scope.parent\n return unless parent_scope\n\n # Retrieve all i_names from current scope\n i_name_set = Set.new(current_scope.defns.values.map(&:i_name))\n\n # Remove all associations from queue until the scope's bookmark\n items = blackboard.leave_scope\n curr_asc, ancestor_asc = items.partition do |a|\n i_name_set.include? a.i_name\n end\n vars_to_keep = Set.new\n\n ancestor_asc.each do |assoc|\n if assoc.dependencies(self).intersect?(i_name_set)\n dependents = assoc.dependencies(self).intersection(i_name_set)\n vars_to_keep.merge(dependents)\n end\n enqueue_association(assoc, nil) # parent_scope\n end\n\n assocs_to_keep = []\n\n unless vars_to_keep.empty?\n loop do\n to_keep, to_consider = curr_asc.partition do |a|\n vars_to_keep.include? a.i_name\n end\n break if to_keep.empty?\n\n to_keep.each do |a|\n vars_to_keep.merge(a.dependencies(self).intersection(i_name_set))\n end\n assocs_to_keep.concat(to_keep)\n curr_asc = to_consider\n end\n end\n symbol_table.leave_scope\n\n vars_to_keep.each do |i_name|\n v = LogVar.new(i_name)\n v.suffix = ''\n symbol_table.insert(v)\n end\n\n assocs_to_keep.each { |a| blackboard.enqueue_association(a) }\n end",
"def default_scope; end",
"def global_scope; @scope = :global end",
"def scopes\n scope_names.to_a.sort\n end",
"def generate_enum_scopes_method\n scope_names = @scope_names\n @record_class.singleton_class.send(:define_method, \"#{@enum_name}_scopes\") do\n defined_enum_scopes.slice(*scope_names)\n end\n end",
"def attr_scope\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 4 )\n return_value = AttrScopeReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n string_literal19 = nil\n __ACTION21__ = nil\n id20 = nil\n\n tree_for_string_literal19 = nil\n tree_for_ACTION21 = nil\n stream_SCOPE = ANTLR3::AST::RewriteRuleTokenStream.new( @adaptor, \"token SCOPE\" )\n stream_ACTION = ANTLR3::AST::RewriteRuleTokenStream.new( @adaptor, \"token ACTION\" )\n stream_id = ANTLR3::AST::RewriteRuleSubtreeStream.new( @adaptor, \"rule id\" )\n begin\n # at line 113:4: 'scope' id ACTION\n string_literal19 = match( SCOPE, TOKENS_FOLLOWING_SCOPE_IN_attr_scope_552 )\n if @state.backtracking == 0\n stream_SCOPE.add( string_literal19 )\n end\n @state.following.push( TOKENS_FOLLOWING_id_IN_attr_scope_554 )\n id20 = id\n @state.following.pop\n if @state.backtracking == 0\n stream_id.add( id20.tree )\n end\n __ACTION21__ = match( ACTION, TOKENS_FOLLOWING_ACTION_IN_attr_scope_556 )\n if @state.backtracking == 0\n stream_ACTION.add( __ACTION21__ )\n end\n # AST Rewrite\n # elements: SCOPE, id, ACTION\n # token labels: \n # rule labels: return_value\n # token list labels: \n # rule list labels: \n # wildcard labels: \n if @state.backtracking == 0\n\n return_value.tree = root_0\n stream_return_value = return_value ? subtree_stream( \"rule return_value\", return_value.tree ) : subtree_stream( \"token return_value\" )\n\n root_0 = @adaptor.create_flat_list\n # 113:22: -> ^( 'scope' id ACTION )\n # at line 113:25: ^( 'scope' id ACTION )\n root_1 = @adaptor.create_flat_list\n root_1 = @adaptor.become_root( stream_SCOPE.next_node, root_1 )\n\n @adaptor.add_child( root_1, stream_id.next_tree )\n @adaptor.add_child( root_1, stream_ACTION.next_node )\n\n @adaptor.add_child( root_0, root_1 )\n\n\n\n return_value.tree = root_0\n\n end# - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n if @state.backtracking == 0\n\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 4 )\n\n end\n \n return return_value\n end",
"def attr_scope\n # -> uncomment the next line to manually enable rule tracing\n # trace_in(__method__, 4)\n return_value = AttrScopeReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n string_literal19 = nil\n __ACTION21__ = nil\n id20 = nil\n\n tree_for_string_literal19 = nil\n tree_for_ACTION21 = nil\n stream_SCOPE = ANTLR3::AST::RewriteRuleTokenStream.new(@adaptor, \"token SCOPE\")\n stream_ACTION = ANTLR3::AST::RewriteRuleTokenStream.new(@adaptor, \"token ACTION\")\n stream_id = ANTLR3::AST::RewriteRuleSubtreeStream.new(@adaptor, \"rule id\")\n begin\n # at line 122:4: 'scope' id ACTION\n string_literal19 = match(SCOPE, TOKENS_FOLLOWING_SCOPE_IN_attr_scope_557) \n if @state.backtracking == 0\n stream_SCOPE.add(string_literal19)\n end\n @state.following.push(TOKENS_FOLLOWING_id_IN_attr_scope_559)\n id20 = id\n @state.following.pop\n if @state.backtracking == 0\n stream_id.add(id20.tree)\n end\n __ACTION21__ = match(ACTION, TOKENS_FOLLOWING_ACTION_IN_attr_scope_561) \n if @state.backtracking == 0\n stream_ACTION.add(__ACTION21__)\n end\n # AST Rewrite\n # elements: ACTION, id, SCOPE\n # token labels: \n # rule labels: return_value\n # token list labels: \n # rule list labels: \n # wildcard labels: \n if @state.backtracking == 0\n\n return_value.tree = root_0\n stream_return_value = return_value ? subtree_stream(\"rule return_value\", return_value.tree) : subtree_stream(\"token return_value\")\n\n root_0 = @adaptor.create_flat_list!\n # 122:22: -> ^( 'scope' id ACTION )\n # at line 122:25: ^( 'scope' id ACTION )\n root_1 = @adaptor.create_flat_list!\n root_1 = @adaptor.become_root(stream_SCOPE.next_node, root_1)\n\n @adaptor.add_child(root_1, stream_id.next_tree)\n @adaptor.add_child(root_1, stream_ACTION.next_node)\n\n @adaptor.add_child(root_0, root_1)\n\n\n\n return_value.tree = root_0\n\n end# - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look(-1)\n\n if @state.backtracking == 0\n\n return_value.tree = @adaptor.rule_post_processing(root_0)\n @adaptor.set_token_boundaries(return_value.tree, return_value.start, return_value.stop)\n\n end\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node!(@input, return_value.start, @input.look(-1), re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out(__method__, 4)\n\n end\n \n return return_value\n end",
"def scope\n @scope\n end",
"def scope\n @scope\n end",
"def get_scope(cur_scope = nil)\n # base default scope is set up here so that deactivated module can update this\n cur_scope = StateComponentTypeTax.scoped if (cur_scope.nil?)\n return (defined?(super)) ? super(cur_scope) : cur_scope\n end",
"def scope\n @attributes[:scope]\n end",
"def subscope(namespace)\n namespace = unique_name(namespace)\n namespace = self.namespace + '/' + namespace if self.namespace != ''\n sub_scope = Tensorflow::Scope.new\n sub_scope.graph = graph.clone\n sub_scope.namemap = namemap.clone\n sub_scope.namespace = namespace.clone\n sub_scope\n end",
"def inherit_scope(other)\n @scope = other.scope\n end",
"def local_variable_scope\n parent.local_variable_scope\n end",
"def dynamic_scopes\n self.scope_definition.select { |_k, v| v.present? }\n end",
"def scopes\n model.scopes\n end",
"def inherited(subclass)\n super\n subclass.scopes = scopes.dup\n end",
"def get_scope(cur_scope = nil)\n # base default scope is set up here so that deactivated module can update this\n cur_scope = AssemblyComponent.scoped if (cur_scope.nil?)\n return (defined?(super)) ? super(cur_scope) : cur_scope\n end",
"def newscope(parent, options = {})\n parent ||= topscope\n scope = Puppet::Parser::Scope.new(self, **options)\n scope.parent = parent\n scope\n end",
"def nested_set_scope\n raise \"called nested_set_scope\"\n options = {:order => quoted_left_column_name}\n scopes = Array(acts_as_nested_set_options[:scope])\n options[:conditions] = scopes.inject({}) do |conditions,attr|\n conditions.merge attr => self[attr]\n end unless scopes.empty?\n self.class.base_class.scoped options\n end",
"def scope\n nodename = Facter.value('hostname')\n fact_values = Facter.to_hash\n node = Puppet::Node.new(nodename, :facts => Puppet::Node::Facts.new(\"facts\", fact_values))\n compiler = Puppet::Parser::Compiler.new(node)\n # configure compiler with facts and node related data\n # Set all global variables from facts\n fact_values.each {|param, value| compiler.topscope[param] = value }\n # Configured trusted data (even if there are none)\n compiler.topscope.set_trusted(node.trusted_data)\n # Set the facts hash\n # compiler.topscope.set_facts(fact_values)\n\n # pretend that the main class (named '') has been evaluated\n # since it is otherwise not possible to resolve top scope variables\n # using '::' when rendering. (There is no harm doing this for the other actions)\n #\n compiler.topscope.class_set('', compiler.topscope)\n scope = Puppet::Parser::Scope.new(compiler)\n scope.source = Puppet::Resource::Type.new(:node, nodename)\n scope.parent = compiler.topscope\n scope\n end",
"def scope_handler(scope)\n\n\t\t# Store Retina pre-defined functions\n\t\tretinaFunc_handler()\n\n\t\t# Fuction definition block\n\t\tif not scope.defblk.nil? then\n\t\t\tdefblk_handler(scope.defblk, $rootTable)\n\t\tend\n\t\t# Main program block\n\t\tprogramblk_handler(scope.programblk, $rootTable)\n\t\t$tableID.pop()\n\n\tend",
"def scope_options; end",
"def scope_options; end",
"def local_scope; @scope = :local end",
"def scope=(_arg0); end",
"def scope=(_arg0); end",
"def scope=(_arg0); end",
"def define_scopes(custom_plural = T.unsafe(nil)); end",
"def global_decls; end",
"def to_upper_space!\n # First recurse.\n # On the sub scopes.\n self.each_scope(&:to_upper_space!)\n # On the behaviors.\n self.each_behavior(&:to_upper_space!)\n \n # Then extract the declarations from the sub scope.\n decls = self.each_scope.map(&:extract_declares!)\n # And do the same with the behaviors'.\n decls << self.each_behavior.map(&:extract_declares!)\n\n # Reinsert the extracted declares to self.\n decls.flatten.each do |decl|\n if decl.is_a?(Type) then\n self.add_type(decl)\n elsif decl.is_a?(SystemT) then\n self.add_systemT(decl)\n elsif decl.is_a?(SignalI) then\n self.add_inner(decl)\n elsif decl.is_a?(SystemI) then\n self.add_systemI(decl)\n else\n raise AnyError, \"Internal error: invalid class for a declaration: #{decl.class}\"\n end\n end\n\n # Extract the behaviors of the sub scopes.\n behs = self.each_scope.map(&:extract_behaviors!).flatten\n # Reinsert them to self.\n behs.each { |beh| self.add_behavior(beh) }\n\n # Extract the connections of the sub scopes.\n cnxs = self.each_scope.map(&:extract_connections!).flatten\n # Reinsert them to self.\n cnxs.each { |beh| self.add_connection(beh) }\n\n # Now can delete the sub scopes since they are empty.\n self.each_scope.to_a.each { |scope| self.delete_scope!(scope) }\n end",
"def apply_standard_scope\n each_sort do |attribute, direction|\n @scope = resource.adapter.order(@scope, attribute, direction)\n end\n @scope\n end",
"def scope!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in(__method__, 2)\n\n type = SCOPE\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 8:9: 'scope'\n match(\"scope\")\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__, 2)\n\n end",
"def scope_type(node); end",
"def scope\n assoc_scope = method(:association_scope)\n join_scope = method(:join_association_scope)\n\n ->(join_or_parent) {\n if join_or_parent.is_a?(ActiveRecord::Associations::JoinDependency::JoinAssociation)\n join_scope[join_or_parent]\n elsif join_or_parent.is_a?(ActiveRecord::Base)\n assoc_scope[join_or_parent]\n else\n where(nil)\n end.extending(Relation::Iterable)\n }\n end",
"def scopes\n scope ? [scope] : []\n end",
"def add_scope()\n $highest_scope += 1\n $current_scope_list << $highest_scope\n $var_list << {}\nend",
"def stradivari_scopes\n @_stradivari_scopes ||= {}\n end",
"def find_scope!(obj); end",
"def bt_scope_attributes\n attributes.slice(*self.class.bt_scope_columns)\n end",
"def scope(*args); end",
"def base_scope\n ApplicationRecord.none\n end",
"def scope=(v); end",
"def scope=(v); end",
"def close_scope()\n $highest_scope -= 1\n $current_scope_list.pop\nend",
"def relation_scope\n if @scope\n @model_class.unscoped { @scope.send(resource_name).scope }\n else\n @model_class.unscoped\n end\n end",
"def all\n if current_scope\n current_scope.clone\n else\n default_scoped\n end\n end",
"def inspect_variables_in_scope(scope_node)\n variable_table.push_scope(scope_node)\n process_children(scope_node)\n variable_table.pop_scope\n end",
"def current_scope\n @scope\n end",
"def scope\n return @scope\n end",
"def scope\n return @scope\n end",
"def scope\n return @scope\n end",
"def scope\n return @scope\n end",
"def scope\n return @scope\n end",
"def scope\n return @scope\n end",
"def child(namespace)\n scope = self.class.new(self)\n\n scope.instance_variable_get(:@value_by_namespace_and_key).send(:[]=, namespace, inflector.convert_hash({}))\n\n scope\n end",
"def define_all_scopes\n if self.resource_definition[\"scopes\"]\n self.resource_definition[\"scopes\"].each_pair do |name, opts|\n self.scope(name, opts)\n end\n end\n true\n end",
"def subsets_scopes\n @subsets_scopes\n end",
"def expand_scopes(scopes)\n scopes.map do |scope|\n [scope, descendents(scope)]\n end.flatten.uniq.sort\n end",
"def search_scope\n super\n end",
"def scope(name = nil)\n raise 'Must specify name if no children have been defined yet' unless name || last_child\n name ||= last_child.name\n @outgoing_scopes[name]\n end",
"def it_scope\n @it_scope ||= Example::Scope.new(self)\n end",
"def new_scope(names)\n values = names.map { |n| self[n] }\n self.class.new(names, values + extras, self)\n end",
"def people_scope\n Person.all.order_by_full_name\n end",
"def scope(scope_name, scope_enum_keys)\n target_enum = @record_class.defined_enums[@enum_name.to_s]\n sub_enum_values = target_enum.values_at(*scope_enum_keys)\n\n if @record_class.defined_enum_scopes.has_key?(scope_name)\n fail ArgumentError,\n \"Conflicting scope names. A scope named #{scope_name} has already been defined\"\n elsif sub_enum_values.include?(nil)\n unknown_key = scope_enum_keys[sub_enum_values.index(nil)]\n fail ArgumentError, \"Unknown key - #{unknown_key} for enum #{@enum_name}\"\n elsif @record_class.respond_to?(scope_name.to_s.pluralize)\n fail ArgumentError,\n \"Scope name - #{scope_name} conflicts with a class method of the same name\"\n elsif @record_class.instance_methods.include?(\"#{scope_name}?\".to_sym)\n fail ArgumentError,\n \"Scope name - #{scope_name} conflicts with the instance method - #{scope_name}?\"\n end\n\n sub_enum_entries = target_enum.slice(*scope_enum_keys)\n @record_class.defined_enum_scopes[scope_name] = sub_enum_entries\n\n # 1. Instance method <scope_name>?\n @record_class.send(:define_method, \"#{scope_name}?\") { sub_enum_entries.include? self.role }\n\n # 2. The class scope with the scope name\n @record_class.scope scope_name.to_s.pluralize,\n -> { @record_class.where(\"#{@enum_name}\" => sub_enum_entries.values) }\n\n @scope_names << scope_name\n end",
"def scope\n klass\n end",
"def current_base\n current = @@structures\n @@scopes.each do |scope|\n next unless scope\n if !struct = find_in_scope(current, scope)\n current << (struct = {scope => []})\n end\n current = struct.values.first\n end\n current\n end",
"def generate_scopes_list(frame_id)\n # Unfortunately we can only respond to Frame 0 as we don't have the variable state in other stack frames\n return [] unless frame_id.zero?\n\n result = []\n\n this_scope = puppet_session_state.saved.scope\n # rubocop:disable Lint/Void Go home rubocop, you're drunk.\n until this_scope.nil? || this_scope.is_topscope?\n result << DSP::Scope.new.from_h!(\n 'name' => this_scope.to_s,\n 'variablesReference' => this_scope.object_id,\n 'namedVariables' => this_scope.to_hash(false).count,\n 'expensive' => false\n )\n this_scope = this_scope.parent\n end\n # rubocop:enable Lint/Void\n\n unless puppet_session_state.actual.compiler.nil?\n result << DSP::Scope.new.from_h!(\n 'name' => puppet_session_state.actual.compiler.topscope.to_s,\n 'variablesReference' => VARIABLES_REFERENCE_TOP_SCOPE,\n 'namedVariables' => puppet_session_state.actual.compiler.topscope.to_hash(false).count,\n 'expensive' => false\n )\n end\n result\n end"
] |
[
"0.7538822",
"0.72437936",
"0.72437936",
"0.72437936",
"0.72437936",
"0.72437936",
"0.72437936",
"0.72437936",
"0.72437936",
"0.72437936",
"0.72437936",
"0.688924",
"0.6764597",
"0.65053344",
"0.64787346",
"0.6474301",
"0.6416756",
"0.6416343",
"0.6396639",
"0.6370502",
"0.63465536",
"0.63355696",
"0.63355696",
"0.6309621",
"0.62383664",
"0.62339103",
"0.6227894",
"0.6227095",
"0.61377054",
"0.6114412",
"0.6088967",
"0.60450095",
"0.6019872",
"0.5996154",
"0.59871453",
"0.5968296",
"0.59670097",
"0.59625554",
"0.595871",
"0.59273607",
"0.5913067",
"0.5913067",
"0.5884009",
"0.5883326",
"0.58725387",
"0.58682966",
"0.5853657",
"0.5848388",
"0.58416206",
"0.58357954",
"0.58032274",
"0.57930595",
"0.57879347",
"0.5758911",
"0.57583004",
"0.57537603",
"0.57537603",
"0.57520515",
"0.5749911",
"0.5749911",
"0.5749911",
"0.57265985",
"0.5702941",
"0.57011735",
"0.5700887",
"0.5689789",
"0.56681454",
"0.56680954",
"0.5661329",
"0.5650862",
"0.5639487",
"0.5637196",
"0.563516",
"0.5624128",
"0.5609333",
"0.5603959",
"0.5603959",
"0.5594807",
"0.55931455",
"0.5592983",
"0.55597603",
"0.5536501",
"0.5526917",
"0.5526917",
"0.5526917",
"0.5526917",
"0.5526917",
"0.5526917",
"0.5526526",
"0.5525475",
"0.5522209",
"0.5517925",
"0.5514791",
"0.55054176",
"0.55005133",
"0.5497232",
"0.5495016",
"0.54835564",
"0.54798347",
"0.54769975",
"0.54612666"
] |
0.0
|
-1
|
=begin rdoc Set Parent of this scope. Note that this populates Scopechildren of parent Scope. =end
|
def parent=(scp)
@parent = scp
scp.children << self if scp
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def scope\n @scope ||= Scope.new(parent)\n end",
"def parent\n unless @parent\n @parent = search(:base => dn.parent, :scope => :base, :limit => true)\n @parent.instance_variable_get(:@children)[rdn] = self\n end\n @parent\n end",
"def parent\n _parent\n end",
"def parent=(value)\n @parent = value\n end",
"def parent\n if parent_id.blank? then nil else unscoped_find(parent_id) end\n end",
"def parent=(p)\n @parent = p\n end",
"def parent\n @parent\n end",
"def parent\n @parent\n end",
"def parent\n @parent\n end",
"def parent\n @parent\n end",
"def parent\n nil\n end",
"def parent=(parent)\n @parent = parent\n end",
"def parent\n p = (@context.parent.nil? || (@context == @context.parent)) ? nil : R2Doc.all_references[parent_name]\n # guard against pollution of all_references with methods having conflicting names\n (p.respond_to?(:is_method_context?) && p.is_method_context?) ? nil : p\n end",
"def parent= parent_node\n parent_node.add_child(self)\n parent_node\n end",
"def parent\n return @parent\n end",
"def parent\n return @parent if defined?(@parent)\n\n @parent = nil\n\n @parent = issue.parent if issue\n end",
"def set_parent(parent)\n @parent = parent\n\n self\n end",
"def parent\n self\n end",
"def parent=(parent)\n @parent = parent\n end",
"def parent=(parent)\n @parent = parent\n end",
"def parent\n unless @node.send(@parent).nil?\n @node = @node.send(@parent)\n end\n end",
"def parent\n @parent ||= resource.decorate.parent\n end",
"def parent\n @parent || NullResource.new\n end",
"def scope_parent_association\n @scope_association ||= scoping_object.send(parent_model_to_method_sym).find(parent_param).send(model_name_to_method_sym)\n end",
"def _parent; end",
"def parent\n self\n end",
"def parent=(par)\n if self.parent\n self.parent.children.delete(self) #delete ourselves \n end\n \n @parent = par\n self.parent.children << self unless self.parent.nil?\n end",
"def set_parent(parent)\n @parent = parent\n end",
"def set_parent(parent)\n @parent = parent\n end",
"def parent\n\t\tself.residue_at_position(@parent_position)\n\tend",
"def parent\n @parent\n end",
"def parent\n @parent\n end",
"def set_parent(parent)\n @parent = parent\n end",
"def parent\n ltree_scope.find_by \"#{self.class.table_name}.#{ltree_path_column} = SUBPATH(?, 0, NLEVEL(?) - 1)\", ltree_path,\n ltree_path\n end",
"def parent\n nil\n end",
"def get_parent\n return nil\n end",
"def parent!(parent)\n @parent = parent\n @cache = {}\n self\n end",
"def parent\n owner\n end",
"def parent=(resource)\n @parent = resource\n end",
"def parent=(parent)\n\t\t\treturn if @parent.equal?(parent)\n\t\t\t\n\t\t\tif @parent\n\t\t\t\t@parent.remove_child(self)\n\t\t\t\t@parent = nil\n\t\t\tend\n\t\t\t\n\t\t\tif parent\n\t\t\t\tparent.add_child(self)\n\t\t\tend\n\t\t\t\n\t\t\treturn self\n\t\tend",
"def parent=(a_parent)\n if parent \n parent.children.delete(self)\n end \n \n if a_parent.nil? \n @parent = a_parent\n return\n else\n a_parent.children << self unless a_parent.children.include?(self)\n @parent = a_parent\n end \n end",
"def parent\n\n h.parent_id ?\n Ruote::Exp::FlowExpression.fetch(@context, h.parent_id) :\n nil\n end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def set_parent(pa)\n self.parent = pa\n pa.children ||= []\n pa.children << self\n end",
"def parent=(obj); end",
"def parent\n @parent ||= self.class.current_parent_block_helper\n end",
"def parent\n @parent or raise LifecycleException.new(\"can't call parent until you materialize the resource\")\n end",
"def parent\n\t\treturn parent_of @current_node\n\tend",
"def parent\n @parent ||= new_or_create? ? find_parent_by_id : lookup_parent_from_child\n end",
"def parent_object\n @parent_object ||= parent? && !parent_singleton? ? parent_model.find(parent_param) : nil\n end",
"def set_parent\n @parent = Parent.find(session[:parent_id])\n end",
"def parent\n dataset.nested.filter(self.primary_key => self.parent_id).first if self.parent_id\n end",
"def parent\n if @obj.parent\n LazyEvaluator.new(@obj.parent)\n else\n nil\n end\n end",
"def _UNDO_setParent(iParentTag)\n @Parent = iParentTag\n end",
"def parent\n return @parent if @parent\n return nil unless @parent_name\n\n if @parent_class == RDoc::TopLevel then\n @parent = @store.add_file @parent_name\n else\n @parent = @store.find_class_or_module @parent_name\n\n return @parent if @parent\n\n begin\n @parent = @store.load_class @parent_name\n rescue RDoc::Store::MissingFileError\n nil\n end\n end\n end",
"def parent\n end",
"def parent\n end",
"def parent\n end",
"def parent\n end",
"def polymorph_parent(parent=nil)\n\t\t@parent ||= parent\n\t\treturn @parent\n\tend",
"def parent=(parent_node); end",
"def parent=(parent_node); end",
"def parent\n @controller.instance_variable_get(:\"@#{parent_name}\")\n end",
"def parent=(parent)\n raise NilParentError if parent.nil?\n raise UnmutableParentError unless parent.is_a? RDF::Mutable\n raise UnmutableParentError unless parent.mutable?\n\n @parent = parent\n reload\n end",
"def parent=(parent_node)\n parent_node.add_child(self)\n parent_node\n end",
"def parent\n self.class.find_in_nested_set(self[parent_col_name]) if self[parent_col_name]\n end",
"def parent\n @parent ||= Object.module_eval(self.source_xml.parent.name).new(:source_xml => self.source_xml.parent)\n rescue\n nil\n end",
"def parent=(parent)\n raise UnmutableParentError unless parent.is_a? RDF::Mutable\n raise UnmutableParentError unless parent.mutable?\n @parent = parent\n end",
"def parent(reload:false)\n if reload || !defined?(@parent)\n @parent = self.class.where({\n document_id: document_id,\n child_ids: id\n }).first\n end\n @parent\n end",
"def parent(reload=false)\n reload = true if !@parent\n reload ? parent_node(true) : @parent\n end",
"def parent=(_arg0); end",
"def parent=(_arg0); end",
"def parent=(_arg0); end",
"def parent=(_arg0); end",
"def parent=(_arg0); end",
"def parent(resource)\n if @resource_config[:parent]\n raise DefinitionError, \"parent already declared in #{self}\"\n end\n @resource_config[:parent] = resource\n end",
"def parent=(parent)\n if @parent\n @parent.remove_child(self)\n end\n\n @parent = parent\n\n if @parent\n @parent.children << self\n @parent.add_observer self\n set_depth @parent.depth + 1\n else\n set_depth 0\n end\n\n self\n end",
"def parent=(new_parent)\n #Reset old parent\n @parent.children.delete(self) if @parent != nil\n\n if new_parent != nil && !new_parent.children.include?(self)\n new_parent.children << self\n end\n @parent = new_parent\n end",
"def parent_notebook=(value)\n @parent_notebook = value\n end",
"def parent_notebook=(value)\n @parent_notebook = value\n end",
"def parent_notebook=(value)\n @parent_notebook = value\n end",
"def parent\n self << '..'\n end",
"def parent=(other); end",
"def parent\n @parent ||= @parent_id ? @book.find_account_by_id(@parent_id) : nil\n end",
"def parent\n if self.rep_parent.nil?\n if self.parent_id.nil?\n return nil\n else\n return Activity.find(self.parent_id)\n end\n\n else\n return self.rep_parent.parent\n end\n end",
"def parent=(parent)\n RTFError.fire(\"Table row nodes cannot have their parent changed.\")\n end",
"def parent\n\t\tpardn = self.parent_dn or return nil\n\t\treturn self.class.new( self.directory, pardn )\n\tend",
"def setParent(parent)\n oldParent = @parent\n @parent = parent\n\n if parent.nil?\n # Remove from parent\n onDetach() if oldParent and oldParent.isAttached\n elsif parent.isAttached\n onAttach()\n end\n end",
"def set_parent(parent_node)\n @parent = parent_node\n end",
"def parent\n object.try(:loaded)&.[](:parents)&.first || wayfinder.decorated_parent\n end"
] |
[
"0.74865836",
"0.7467809",
"0.73911303",
"0.7337593",
"0.73222315",
"0.7299989",
"0.7296345",
"0.7296345",
"0.7296345",
"0.7296345",
"0.72732824",
"0.724922",
"0.7213648",
"0.7161236",
"0.71584684",
"0.7135253",
"0.7116828",
"0.71003914",
"0.7060164",
"0.7060164",
"0.7053903",
"0.70483303",
"0.7033288",
"0.7030653",
"0.70139766",
"0.69857967",
"0.6963423",
"0.69616246",
"0.69616246",
"0.6949373",
"0.69199413",
"0.69199413",
"0.69052553",
"0.6870069",
"0.68408346",
"0.68143547",
"0.6814088",
"0.6813263",
"0.6812192",
"0.6800236",
"0.67594635",
"0.6757041",
"0.6753777",
"0.6753777",
"0.6753777",
"0.6753777",
"0.6753777",
"0.6753777",
"0.6753777",
"0.6753777",
"0.6753777",
"0.6753777",
"0.6753777",
"0.6753777",
"0.67449147",
"0.673615",
"0.671968",
"0.6690966",
"0.66487944",
"0.6633221",
"0.66163594",
"0.66147065",
"0.66109693",
"0.6609631",
"0.6608374",
"0.65784276",
"0.65699697",
"0.65699697",
"0.65699697",
"0.65699697",
"0.6567965",
"0.65465736",
"0.65465736",
"0.65451455",
"0.65444136",
"0.65413254",
"0.65363705",
"0.652187",
"0.652144",
"0.65187585",
"0.6514538",
"0.6514395",
"0.6514395",
"0.6514395",
"0.6514395",
"0.6514395",
"0.65142155",
"0.65085226",
"0.6506967",
"0.6506029",
"0.6506029",
"0.6506029",
"0.65031725",
"0.650026",
"0.6492641",
"0.6468145",
"0.6463437",
"0.64538246",
"0.6452901",
"0.6433819",
"0.64332753"
] |
0.0
|
-1
|
=begin rdoc Return level of nesting for this Scope. Note that this is recursive calling Parentnesting. =end
|
def nesting
@parent ? @parent.nesting + 1 : 1
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def level\n case\n when root? then 0\n when depth_column_could_be_used? then depth\n when parent_association_loaded? then parent.level + 1\n # @todo move it adapters\n else ancestors.size\n end\n end",
"def level\n return 0 if root?\n\n @parent.level + 1\n end",
"def depth\n level = 0\n scopelist=[]\n if (doe_scope == \"hvac\")\n scopelist = @hvacLevel\n else\n scopelist = @envelopeLevel\n end\n scopelist.each_index do |index|\n scopelist[index].each do |name|\n if (@commandName == name )\n level = index\n end\n end\n end\n return level\n end",
"def depth\n @cur_level - @base_level + 1\n end",
"def get_level\n level = 1\n p = parent\n while !p.nil?\n level += 1\n p = p.parent\n end\n \n return level\n end",
"def level\n root? ? 0 : ancestors.count\n end",
"def level\n return 0 if self[acts_as_nested_set_options[:parent_column]].nil?\n self.class.count(\"#{acts_as_nested_set_options[:scope]} AND (#{acts_as_nested_set_options[:left_column]} < #{self[acts_as_nested_set_options[:left_column]]} and #{acts_as_nested_set_options[:right_column]} > #{self[acts_as_nested_set_options[:right_column]]})\")\n end",
"def level\n if parent.nil?\n 0\n else\n parent.level + 1;\n end\n end",
"def level\n return 0 if self[nested_set_parent].nil?\n sql = %Q( SELECT COUNT(t2.id) - 1 AS level\n FROM #{nested_set_class.table_name} AS t1, #{nested_set_class.table_name} AS t2\n WHERE t1.lft BETWEEN t2.lft AND t2.rgt AND t1.id = #{id} AND #{nested_set_scope} )\n nested_set_class.count_by_sql sql\n end",
"def depth\n self.ancestors.size\n end",
"def depth\n self[:depth]\n end",
"def depth\n self.parents.size\n end",
"def depth\n ancestors.count\n end",
"def depth\n ancestors.count\n end",
"def current_depth\n 0\n end",
"def level\n length = 0\n cursor = self\n while cursor.parent_document\n length += 1\n cursor = cursor.parent_document\n end\n length\n end",
"def max_nesting=(depth)\n #This is a stub, used for indexing\n end",
"def depth\n @depth ||= to && to.depth + 1 || 0\n end",
"def depth\n depth_support(self.root)\n end",
"def level(scope = {})\n return 0 if self[parent_col_name].nil?\n self.class.count_in_nested_set({ :conditions => \"#{scope_condition} AND (#{self[left_col_name]} BETWEEN #{prefixed_left_col_name} AND #{prefixed_right_col_name})\" }, scope) - 1\n end",
"def get_depth\n raise \"Not implemented\"\n end",
"def my_depth\n 1\n end",
"def level\n parent_id.nil? ? 0 : compute_level\n end",
"def depth()\n #This is a stub, used for indexing\n end",
"def depth\n return call_ancestry_method(:depth) if use_ancestry?\n\n rel = relationship(:raise_on_multiple => true) # TODO: Handle multiple nodes with a way to detect which node you want\n rel.nil? ? 0 : rel.depth\n end",
"def depth\n children_depth + my_depth\n end",
"def nesting_levels\n return unless @options.fetch :folder_limit\n\n tree&.path_length || @options.fetch(:nesting_levels)\n end",
"def nesting\n @define_nesting = true\n '$nesting'\n end",
"def max_nesting()\n #This is a stub, used for indexing\n end",
"def depth; end",
"def level\n is_root? ? nil : option_set.try(:level, depth)\n end",
"def depth\n @attributes[:depth]\n end",
"def max_level_depth\n MAXIMUM_LEVEL_DEPTH\n end",
"def depth\n @env.length\n end",
"def current_depth\n current = Fiber.current\n managed_fiber?(current) ? current.depth : 0\n end",
"def nesting\n @nesting ||= from.nesting(label)\n end",
"def depth\n @traversal_position.depth\n end",
"def depth\n @locals.size\n end",
"def scope_level; end",
"def update_depth\n if depth?\n self.update_attribute(:depth, level)\n end\n self\n end",
"def depth\n if empty?\n 0\n else\n if @left==nil || @right==nil\n if (@left==nil&&@right==nil) then 1\n else -1\n end\n else\n left, right = @left.depth, @right.depth\n if left==-1||right==-1||left!=right then -1\n else 1+left\n end\n end\n end\n end",
"def nesting() end",
"def level\n\t\tlevel = 0\n\t\t@classes.each do |_class|\n\t\t\tlevel += _class.level\n\t\tend\n\t\tlevel\n\tend",
"def depth=(_arg0); end",
"def depth\n return 0 if nil?\n\n @accumulator_depth = 1\n depth_aux(self, @accumulator_depth)\n @accumulator_depth\n end",
"def level\n return 0 if self[parent_col_name].nil?\n base_set_class.count(:conditions => \"#{scope_condition} AND (#{self[left_col_name]} BETWEEN #{left_col_name} AND #{right_col_name})\") - 1\n end",
"def depth\n return 0 unless has_children?\n children.inject(0) {|dep,c| dep > c.depth ? dep : c.depth} + 1\n end",
"def level\n return @level\n end",
"def level\n return @level\n end",
"def depth(person)\n count = 0\n \n until person.ancestor == nil do\n person = person.ancestor\n count += 1\n end\n\n count\n end",
"def depth\n Sequel::SQL::NumericExpression.new(:NOOP, function(:depth, self))\n end",
"def depth\n node = @kids.max {|k, j| k.depth <=> j.depth }\n node.depth + 1\n end",
"def num_nests\n my_nests.length\n end",
"def level\n @level\n end",
"def level\n @level\n end",
"def top_level\n @top_level\n end",
"def nesting_at(line_number)\n Pry::Indent.nesting_at(raw, line_number)\n end",
"def list_indent_level\n @list_indent_stack.length\n end",
"def list_indent_level\n @list_indent_stack.length\n end",
"def at_depth(depth)\n where \"NLEVEL(#{table_name}.#{ltree_path_column}) = ?\", depth\n end",
"def top_level\n return @top_level if defined? @top_level\n @top_level = self\n @top_level = @top_level.parent until RDoc::TopLevel === @top_level\n @top_level\n end",
"def top_level\n return @top_level if defined? @top_level\n @top_level = self\n @top_level = @top_level.parent until RDoc::TopLevel === @top_level\n @top_level\n end",
"def parent\n ltree_scope.find_by \"#{self.class.table_name}.#{ltree_path_column} = SUBPATH(?, 0, NLEVEL(?) - 1)\", ltree_path,\n ltree_path\n end",
"def current_level\n @cur_level\n end",
"def nested?\n nesting_owner.length > 0\n end",
"def ancestors_scope(node, &block)\n if columns.depth?\n build_ancestors_query(node, &block).reorder(depth)\n else\n build_ancestors_query(node) do |query|\n query.start_with { |start| start.select Arel.sql('0').as('__depth') }\n .select(query.prior['__depth'] - 1, :start_with => false)\n\n yield query if block_given?\n end.reorder('__depth')\n end\n end",
"def level\n @level\n end",
"def root_level\n self.find\n end",
"def scope_depth depth_options, depth\n depth_options.inject(ancestry_base_class) do |scope, option|\n scope_name, relative_depth = option\n if [:before_depth, :to_depth, :at_depth, :from_depth, :after_depth].include? scope_name\n scope.send scope_name, depth + relative_depth\n else\n raise Ancestry::AncestryException.new(I18n.t(\"ancestry.unknown_depth_option\", scope_name: scope_name))\n end\n end\n end",
"def scope(level = @skl_level)\n return @skl_levelcache[level][:scope]\n end",
"def depth\n PathExpression.range(path)[1]\n end",
"def hierarchy\n nested_set_scope.where(\n \"#{self.class.table_name}.lft >= :lft AND #{self.class.table_name}.rgt <= :rgt\" +\n \" OR #{self.class.table_name}.lft < :lft AND #{self.class.table_name}.rgt > :rgt\",\n {:lft => lft, :rgt => rgt})\n end",
"def scope_depth depth_options, depth\n depth_options.inject(self.base_class) do |scope, option|\n scope_name, relative_depth = option\n if [:before_depth, :to_depth, :at_depth, :from_depth, :after_depth].include? scope_name\n scope.send scope_name, depth + relative_depth\n else\n raise Ancestry::AncestryException.new(\"Unknown depth option: #{scope_name}.\")\n end\n end\n end",
"def stack_depth\n @stack.size\n end",
"def set_depth\n self.depth = self.reply_comment? ? self.commentable.depth + 1 : 0\n end",
"def depth\n @options[:depth] += 1\n ret = yield\n @options[:depth] -= 1\n ret\n end",
"def partial_book_depth(symbol:, level:, methods:)\n ws_single(\n stream: {\n symbol: symbol,\n type: 'depth',\n level: level,\n },\n methods: methods,\n )\n end",
"def level_of_indent\n self.scan(/^ *(?=\\S)/).map { |space| space.length }.min || 0\n end",
"def level_of_indent\n self.scan(/^ *(?=\\S)/).map { |space| space.length }.min || 0\n end",
"def scope\n @scope ||= Scope.new(parent)\n end",
"def depth\n breadcrumbs.size\n end",
"def line_depth(line)\n whitespace = line.scan(/^([\\s]+)/).flatten.first\n if whitespace\n whitespace.length\n else\n 0\n end\n end",
"def depth(root=@root)\n return 0 if root.nil? # height of an empty tree is 0\n _pre_order(root, [], nil).first\n end",
"def indent_level(line)\n count_indent(line)/$default_indent\nend",
"def children_depth\n leaf? ? 0 : children.map(&:depth).max\n end",
"def number_of_parents\n if self.is_parent\n return 0\n else\n return 1 + self.parent.number_of_parents\n end\n end",
"def depth\n return codeArray.length\n end",
"def level \n if (self.parent_category_id == nil)\n @level = 1\n elsif (@level == nil) \n @level = computeLevelBySQL\n end \n @level\nend",
"def look_deeper contexts, deep, max_item_depth = 9, max_aspect_depth = 9, item_depth = 0\n unless item_depth == 0\n deep = look_wider contexts, deep, max_aspect_depth, 0\n deep[:row] += 1\n end\n deep[:indents] ||= []\n # deep[:numberings] ||= []\n deep[:indents ][deep[:row]] = item_depth || 0\n # deep[:numberings][deep[:row]] = self.class.numbering_list || []\n self.class.numbering_push\n unless (item_depth += 1) >= max_item_depth\n items.each do |item|\n self.class.numbering_increment\n deep = (item.recursive_ref || item).look_deeper contexts, deep, max_item_depth, max_aspect_depth, item_depth\n end\n end\n self.class.numbering_pop\n item_depth -= 1\n deep\n end",
"def indentation_level\n spaces = (@source.size - @stripped_source.size)\n spaces == 0 ? 0 : spaces / 2\n end",
"def nests\n Nest.all.select do |nest|\n nest.tree == self\n end\n end",
"def depth(sought_node, current_node = @root)\n # Base case we've reached beyond a leaf node.\n return -1 if current_node.nil?\n\n # Base case: We've reached the node.\n return 0 if current_node == sought_node\n\n # Otherwise, return the minimum of the depths\n 1 + [depth(sought_node, current_node.left), depth(sought_node, current_node.right)].max\n end",
"def validate\n if (depth != parent.depth+1)\n no(\"#{short} has bad depth\")\n end\n ui.puts \"#{indent}ok (depth: #{depth})#{short}\"\n end",
"def level_index\n @level_index || 0\n end",
"def level_index\n @level_index || 0\n end",
"def levels_from_parent\n bridge_class.levels_from_parent\n end",
"def level\n init unless @initialized\n level = level_to_sym(@level)\n end",
"def min_depth\n return 0 if @poss.empty?\n @poss[0].length\n end",
"def levelOrderTraversal(current_node = @root)\n \treturn \"Tree is empty\" if !current_node\n \tlevel = 1\n \tqueue = Array.new\n \tqueue.push current_node\n \tqueue.push '$' # To identify end of level\n \tp \"Level = #{level}\"\n \twhile queue.size != 1\n \t\ttop_element = queue.shift\n \t\tif top_element != '$'\n\t \t\tp top_element.value\n\t \t\tqueue.push top_element.left if top_element.left\n\t \t\tqueue.push top_element.right if top_element.right\n\t \telse\n\t \t\tlevel += 1\n\t \t\tp \"Level = #{level}\"\n\t \t\tqueue.push top_element\n\t \tend\n \tend\n \treturn level\n end",
"def update_self_and_descendants_depth\n if depth?\n scope_class.each_with_level(self_and_descendants) do |node, level|\n # node.with(:safe => true).set(:depth, level) unless node.depth == level\n node.set(depth: level) unless node.depth == level\n end\n self.reload\n end\n self\n end"
] |
[
"0.75401276",
"0.75121593",
"0.74023145",
"0.7244222",
"0.72277987",
"0.7158171",
"0.7113225",
"0.7089794",
"0.70424134",
"0.6976919",
"0.6938359",
"0.69357014",
"0.6877372",
"0.6877372",
"0.6855419",
"0.6836558",
"0.6804442",
"0.6766529",
"0.67595685",
"0.6721652",
"0.6714575",
"0.6704333",
"0.6689297",
"0.66765445",
"0.6666014",
"0.66226953",
"0.6608413",
"0.65408367",
"0.6473025",
"0.6435172",
"0.6338582",
"0.6318652",
"0.62744313",
"0.6227184",
"0.6220003",
"0.6210963",
"0.62061006",
"0.6194681",
"0.61616445",
"0.61415386",
"0.61282134",
"0.6119469",
"0.6085228",
"0.6079521",
"0.6059486",
"0.60426265",
"0.60261834",
"0.6008956",
"0.6008956",
"0.6008671",
"0.5979374",
"0.59703183",
"0.59245884",
"0.5920169",
"0.5920169",
"0.591022",
"0.5844912",
"0.58280706",
"0.58280706",
"0.5823887",
"0.5817754",
"0.5817754",
"0.5813692",
"0.5811295",
"0.58007365",
"0.5787455",
"0.57817787",
"0.57706636",
"0.574247",
"0.57352966",
"0.57319623",
"0.57308155",
"0.57246053",
"0.57205755",
"0.5720472",
"0.57179284",
"0.5694327",
"0.5675999",
"0.5675999",
"0.5667042",
"0.56362075",
"0.55948925",
"0.5582515",
"0.5581628",
"0.5536369",
"0.5530755",
"0.55257356",
"0.55180603",
"0.55168456",
"0.55151266",
"0.54989785",
"0.5495819",
"0.54923767",
"0.5485882",
"0.5485882",
"0.548515",
"0.5472923",
"0.54630375",
"0.5460162",
"0.54522777"
] |
0.77564746
|
0
|
=begin rdoc Return list of symbols defined in this scope. If recurse is true, all child scopes are included as well. =end
|
def symbols(names_only=false, recurse=false)
symtab = recurse ? @children.map { |c| c.symbols(names_only, true)
}.flatten : []
names_only ? @symtab.keys.concat(symtab) : @symtab.values.concat(symtab)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def symbols() @symbols end",
"def symbols\n @symbol_set.symbols\n end",
"def namespaces(recurse=false)\n symbols(false, recurse).map { |s| s.namespace }.sort.uniq\n end",
"def get_symbols\n\t\treturn @symbols\n\tend",
"def scopes\n @scope.scopes\n end",
"def find_scopes\n begin\n pptr = FFI::MemoryPointer.new(:pointer, 128)\n\n result = SLPFindScopes(@handle, pptr)\n raise Error, \"SLPFindScopes(): #{result}\" if result != :SLP_OK\n\n arr = pptr.read_array_of_string\n ensure\n SLPFree(pptr.read_pointer)\n pptr.free unless pptr.null?\n end\n\n arr\n end",
"def scope\n @scope ||= Array(@root_scope) + [Inflector.underscore(name)]\n end",
"def all_children(scope = {})\n full_set(scope) - [self]\n end",
"def all\n if current_scope\n current_scope.clone\n else\n default_scoped\n end\n end",
"def globals; list_all :global_variables; end",
"def scopes\n scope_names.to_a.sort\n end",
"def generate_scopes_list(frame_id)\n # Unfortunately we can only respond to Frame 0 as we don't have the variable state in other stack frames\n return [] unless frame_id.zero?\n\n result = []\n\n this_scope = puppet_session_state.saved.scope\n # rubocop:disable Lint/Void Go home rubocop, you're drunk.\n until this_scope.nil? || this_scope.is_topscope?\n result << DSP::Scope.new.from_h!(\n 'name' => this_scope.to_s,\n 'variablesReference' => this_scope.object_id,\n 'namedVariables' => this_scope.to_hash(false).count,\n 'expensive' => false\n )\n this_scope = this_scope.parent\n end\n # rubocop:enable Lint/Void\n\n unless puppet_session_state.actual.compiler.nil?\n result << DSP::Scope.new.from_h!(\n 'name' => puppet_session_state.actual.compiler.topscope.to_s,\n 'variablesReference' => VARIABLES_REFERENCE_TOP_SCOPE,\n 'namedVariables' => puppet_session_state.actual.compiler.topscope.to_hash(false).count,\n 'expensive' => false\n )\n end\n result\n end",
"def globalsymbols(node)\n case node\n when Statements\n for stmt in node.stmts\n if stmt.class == FuncDecl\n for stmt_ in stmt.body.stmts\n if stmt_.class == Statements\n for stmt__ in stmt_.stmts\n if stmt__.class == VarDecl\n varDecl(stmt__)\n end\n end\n end\n end\n elsif stmt.class == Statements\n for stmt_ in stmt.stmts\n if stmt_.class == VarDecl\n varDecl(stmt_)\n end\n end\n end\n @cg.freeall_registers\n end\n end\n end",
"def symbols\n each_symbol.to_a\n end",
"def static_scopes\n scopes = self.scope_definition\n .select { |_k, v| v.blank? }\n .keys\n scopes | [:first, :last, :all]\n end",
"def descendents(scope)\n if parent_scope?(scope)\n return SCOPE_TREE[scope].keys.map do |child|\n [child, descendents(child)]\n end.flatten\n else\n parent_scopes.each do |top|\n return SCOPE_TREE[top][scope].keys if SCOPE_TREE[top].key?(scope)\n end\n end\n\n []\n end",
"def symbols_for_association_chain #:nodoc:\n parents_symbols\n end",
"def dynamic_scopes\n self.scope_definition.select { |_k, v| v.present? }\n end",
"def find_all_in_scope(node, predicate); end",
"def scopes\n scope ? [scope] : []\n end",
"def scopes\n @scopes ||= {}\n end",
"def scopes\n @@scopes ||= {}\n end",
"def find_all(options = {})\n construct_scope(options).to_a\n end",
"def scopes; end",
"def get_methods(fqns, scope: T.unsafe(nil), visibility: T.unsafe(nil), deep: T.unsafe(nil)); end",
"def get_unref_symbols\n unref = []\n @modules.each do |mod|\n mod.symbols.values.each do |s|\n unless s.referenced?\n unref << s.name\n end\n end\n end\n unref\n end",
"def GatherDefines()\n return @Defines\n end",
"def inspect_variables_in_scope(scope_node); end",
"def scopes\n read_inheritable_attribute(:scopes) || write_inheritable_attribute(:scopes, {})\n end",
"def symbols_for_association_chain #:nodoc:\n []\n end",
"def process_scope(exp)\n declarations, body = with_scope do\n process exp.shift unless exp.empty?\n end\n\n declarations = declarations.reject { |d| d =~ / static_/ }\n\n result = []\n result << \"{\"\n result << declarations.join(\"\\n\") unless declarations.empty?\n result << body.chomp if body\n result << \"}\"\n \n return result.join(\"\\n\")\n end",
"def get_named_scope_info(klass)\n klass.respond_to?(:scopes) ? klass.scopes.keys.map(&:to_s) : []\n end",
"def scopes\n self.class.scopes\n end",
"def inspect_variables_in_scope(scope_node)\n variable_table.push_scope(scope_node)\n process_children(scope_node)\n variable_table.pop_scope\n end",
"def scope_names\n keys.map { |k| k.to_s }\n end",
"def resolve\n scope.all\n end",
"def find_scope!(obj); end",
"def key_words\n # because dollar signs don't work we can't display a $ sign in the keyword\n # list so its not explicitly clear what the keyword\n variables = scope.to_hash.keys\n # prepend a :: to topscope variables\n scoped_vars = variables.map { |k, _v| scope.compiler.topscope.exist?(k) ? \"$::#{k}\" : \"$#{k}\" }\n PuppetDebugger::InputResponders::Functions.instance.debugger = self\n funcs = PuppetDebugger::InputResponders::Functions.instance.func_list\n PuppetDebugger::InputResponders::Datatypes.instance.debugger = self\n (scoped_vars + funcs + static_responder_list + PuppetDebugger::InputResponders::Datatypes.instance.all_data_types).uniq.sort\n end",
"def keys()\n @locals.keys\n end",
"def all\n Hash[all_names.map {|name| [name, Global.send(name)]}]\n end",
"def expand_scopes(scopes)\n scopes.map do |scope|\n [scope, descendents(scope)]\n end.flatten.uniq.sort\n end",
"def attributes\n\t\treturn self.scope.__locals__\n\tend",
"def locals; list_all :local_variables; end",
"def symbols; end",
"def dependencies(recurse: true)\n return @dependencies if @dependencies\n if depends.nil? || depends.empty?\n @dependencies = nil\n else\n @dependencies = depends.map do |name, dependency|\n loader = StackFileLoader.for(dependency['stack'], self)\n deps = { 'name' => name, 'stack' => loader.source, 'variables' => dependency.fetch('variables', Hash.new) }\n if recurse\n child_deps = loader.dependencies\n deps['depends'] = child_deps unless child_deps.nil?\n end\n deps\n end\n end\n end",
"def scopes\n model.scopes\n end",
"def define_all_scopes\n if self.resource_definition[\"scopes\"]\n self.resource_definition[\"scopes\"].each_pair do |name, opts|\n self.scope(name, opts)\n end\n end\n true\n end",
"def scopes\n scopes = scope ? scope.split(/\\s+/) : []\n scopes = attributes[:scope]\n Set.new(scopes).to_s\n end",
"def all_scopes\n @all_scopes ||=\n {'identity' => (auth['scope'] || apps_permissions_users_list[user_id].to_h['scopes'].to_a.join(',')).to_s.split(',')}\n .merge(auth['scopes'].to_h)\n end",
"def symbols\n @flags.keys\n end",
"def symbols\n @symbols ||= Array(@grpc.symbols).map do |b|\n Symbol.from_grpc b\n end\n end",
"def subscope\n self.clone\n end",
"def recursive(*args)\n @scope.with_values += args\n @scope.recursive_value = true\n @scope\n end",
"def recursive(*args)\n @scope.with_values += args\n @scope.recursive_value = true\n @scope\n end",
"def leave_scope\n # puts __callee__\n current_scope = symbol_table.current_scope\n parent_scope = current_scope.parent\n return unless parent_scope\n\n # Retrieve all i_names from current scope\n i_name_set = Set.new(current_scope.defns.values.map(&:i_name))\n\n # Remove all associations from queue until the scope's bookmark\n items = blackboard.leave_scope\n curr_asc, ancestor_asc = items.partition do |a|\n i_name_set.include? a.i_name\n end\n vars_to_keep = Set.new\n\n ancestor_asc.each do |assoc|\n if assoc.dependencies(self).intersect?(i_name_set)\n dependents = assoc.dependencies(self).intersection(i_name_set)\n vars_to_keep.merge(dependents)\n end\n enqueue_association(assoc, nil) # parent_scope\n end\n\n assocs_to_keep = []\n\n unless vars_to_keep.empty?\n loop do\n to_keep, to_consider = curr_asc.partition do |a|\n vars_to_keep.include? a.i_name\n end\n break if to_keep.empty?\n\n to_keep.each do |a|\n vars_to_keep.merge(a.dependencies(self).intersection(i_name_set))\n end\n assocs_to_keep.concat(to_keep)\n curr_asc = to_consider\n end\n end\n symbol_table.leave_scope\n\n vars_to_keep.each do |i_name|\n v = LogVar.new(i_name)\n v.suffix = ''\n symbol_table.insert(v)\n end\n\n assocs_to_keep.each { |a| blackboard.enqueue_association(a) }\n end",
"def all\n @definitions ||= []\n end",
"def extra_scopes()\n @scopes_added_by_common_scopes\n end",
"def includes\n return @includes if @includes\n @includes = []\n @context.includes.each do |i|\n ref = R2Doc.all_references[i.name]\n ref = @context.find_symbol(i.name)\n ref = ref.viewer if ref\n if ref and ref.document_self\n @includes << {:name=>i.name, :url=>ref.path}\n else\n @includes << {:name=>i.name}\n end\n end\n @includes\n end",
"def perform_list\n puts 'Symbol table (special chars escaped):'\n @symbol_table.symbols.each do |sym|\n puts \"#{sym.name} -> #{sym.value.dump} #{sym.readonly ? '[readonly]' : ''}\"\n end\n end",
"def all_scan_registers\n @all_scan_registers ||= begin\n s = scan_registers.dup\n modules.each do |mod|\n s += mod.all_scan_registers\n end\n s\n end\n end",
"def global_decls; end",
"def list_subtools(words,\n recursive: false,\n include_hidden: false,\n include_namespaces: false,\n include_non_runnable: false)\n load_for_prefix(words)\n len = words.length\n found_tools = all_cur_definitions.find_all do |tool|\n name = tool.full_name\n name.length > len && name.slice(0, len) == words &&\n (include_hidden || name[len..-1].none? { |word| word.start_with?(\"_\") })\n end\n found_tools.sort_by!(&:full_name)\n found_tools = filter_non_runnable_tools(found_tools, include_namespaces, include_non_runnable)\n found_tools.select! { |tool| tool.full_name.length == len + 1 } unless recursive\n found_tools\n end",
"def resource_scopes\n return @resource_scopes\n end",
"def resource_scopes\n return @resource_scopes\n end",
"def registered_methods(as_registry=false)\n methods = {}\n ancestors.reverse.each do |ancestor|\n if ancestor.kind_of?(Attributes)\n methods.merge!(ancestor.lazy_registry)\n end\n end\n \n as_registry ? methods : methods.keys\n end",
"def names\n fs = []\n %w( ORDER_RELAXED ORDER_ACQ_REL ORDER_SEQ_CST SCOPE_WORK_ITEM SCOPE_WORK_GROUP SCOPE_DEVICE SCOPE_ALL_DEVICES ).each { |f|\n fs.push(f) if self.include?( self.class.const_get(f) )\n }\n return fs\n end",
"def names\n @lock.synchronize do\n @root_objects.keys\n end\n end",
"def scan\n remove_commented_out_lines\n\n do_classes_and_modules\n do_missing\n\n do_constants\n do_methods\n do_includes\n do_aliases\n do_attrs\n\n @store.add_c_variables self\n\n @top_level\n end",
"def symbols(expr = @expr)\n expr[1..-1].map do |sym|\n case sym\n when Symbol\n sym\n when Array\n symbols(sym)\n end\n end.flatten.compact.uniq\n end",
"def expand(scopes)\n scopes = Array(scopes.to_a)\n registered_scopes = scopes.filter { |sc| @mapping.key?(sc) }\n result = registered_scopes + registered_scopes.reduce([]) { |memo, sc|\n memo + Array(@mapping.fetch(sc))\n }.uniq\n\n Scopes.wrap(result)\n end",
"def all_objects\n Registry.all(:root, :module, :class)\n end",
"def renumber_all\n scopes = []\n # only call it once for each scope_condition (if the scope conditions are messed up, this will obviously cause problems)\n roots.each do |r|\n r.renumber_full_tree unless scopes.include?(r.scope_condition)\n scopes << r.scope_condition\n end\n end",
"def each() @symbols.each {|s| yield s if block_given? } end",
"def all\n @env.reverse.inject { |env, scope| env.merge scope }\n end",
"def current_base\n current = @@structures\n @@scopes.each do |scope|\n next unless scope\n if !struct = find_in_scope(current, scope)\n current << (struct = {scope => []})\n end\n current = struct.values.first\n end\n current\n end",
"def ransackable_scopes(auth_object = nil)\n []\n end",
"def default_visible_key_scope\n lambda { all }\n end",
"def descendants_scope(node)\n node.scope.join_recursive do |query|\n query.connect_by(join_columns(columns.id => columns.parent))\n .start_with(node.to_relation)\n\n yield query if block_given?\n\n query.order_siblings(position)\n end\n end",
"def squirrels\n # self.nests # what are my nests?\n self.nests.map do |nest| # Nest instance\n nest.squirrel\n end\n # binding.pry\n # [#<Nest>, #<Nest>, #<Nest>]\n # ||\n # \\/\n # [#<Squirrel>, #<Squirrel>, #<Squirrel>]\n end",
"def definitions() return @definitions end",
"def scope\n @scope ||= {}\n end",
"def scope\n @scope ||= {}\n end",
"def scope\n read_attr :scope, :to_sym\n end",
"def all_cur_definitions\n result = []\n @mutex.synchronize do\n @tool_data.each_value do |td|\n tool = td.cur_definition\n result << tool unless tool.nil?\n end\n end\n result\n end",
"def renumber_all\n scopes = []\n # only call it once for each scope_condition (if the scope conditions are messed up, this will obviously cause problems)\n roots.each do |r|\n r.renumber_full_tree unless scopes.include?(r.scope_condition)\n scopes << r.scope_condition\n end\n end",
"def terminal_symbols\n symbols.values.select {|symbol| symbol.terminal}\n end",
"def all_variables\n @items.map(&:variables).flatten\n end",
"def dynamic_scopes\n self.scopes.select { |name, args| args.present? }\n end",
"def findGlobalPath\n terminate = [Def.CLASS,Def.MODULE]\n path = @currentPath.clone\n entry = get(path)\n definition = entry.getDef unless path.empty?\n while !(path.empty?) and !(terminate.include? definition)\n path.exitName\n entry = get(path)\n definition = entry.getDef if entry\n end \n path\n end",
"def symbols\n keys.sort\n end",
"def available_scopes\n (default_scopes << Doorkeeper.config.optional_scopes.to_a).flatten.uniq\n end",
"def roots(scope = {})\n self.class.find_in_nested_set(:all, { :conditions => \"#{scope_condition} AND (#{prefixed_parent_col_name} IS NULL OR #{prefixed_parent_col_name} = 0)\", :order => \"#{prefixed_left_col_name}\" }, scope)\n end",
"def add_scope()\n $highest_scope += 1\n $current_scope_list << $highest_scope\n $var_list << {}\nend",
"def scopes *names\n self.scope_names ||= []\n\n names.each do |scope|\n self.scope_names << scope\n\n # hand chaining duties off to the ResourceProxy instance\n define_singleton_method scope do\n resource_proxy.append_scope(scope)\n end\n\n # ResourceProxy instance also needs to respond to scopes\n resource_proxy_class.send(:define_method, scope) do\n append_scope(scope)\n end\n end\n\n # self.scope_names.freeze\n end",
"def attr_scope\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 4 )\n return_value = AttrScopeReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n string_literal19 = nil\n __ACTION21__ = nil\n id20 = nil\n\n tree_for_string_literal19 = nil\n tree_for_ACTION21 = nil\n stream_SCOPE = ANTLR3::AST::RewriteRuleTokenStream.new( @adaptor, \"token SCOPE\" )\n stream_ACTION = ANTLR3::AST::RewriteRuleTokenStream.new( @adaptor, \"token ACTION\" )\n stream_id = ANTLR3::AST::RewriteRuleSubtreeStream.new( @adaptor, \"rule id\" )\n begin\n # at line 113:4: 'scope' id ACTION\n string_literal19 = match( SCOPE, TOKENS_FOLLOWING_SCOPE_IN_attr_scope_552 )\n if @state.backtracking == 0\n stream_SCOPE.add( string_literal19 )\n end\n @state.following.push( TOKENS_FOLLOWING_id_IN_attr_scope_554 )\n id20 = id\n @state.following.pop\n if @state.backtracking == 0\n stream_id.add( id20.tree )\n end\n __ACTION21__ = match( ACTION, TOKENS_FOLLOWING_ACTION_IN_attr_scope_556 )\n if @state.backtracking == 0\n stream_ACTION.add( __ACTION21__ )\n end\n # AST Rewrite\n # elements: SCOPE, id, ACTION\n # token labels: \n # rule labels: return_value\n # token list labels: \n # rule list labels: \n # wildcard labels: \n if @state.backtracking == 0\n\n return_value.tree = root_0\n stream_return_value = return_value ? subtree_stream( \"rule return_value\", return_value.tree ) : subtree_stream( \"token return_value\" )\n\n root_0 = @adaptor.create_flat_list\n # 113:22: -> ^( 'scope' id ACTION )\n # at line 113:25: ^( 'scope' id ACTION )\n root_1 = @adaptor.create_flat_list\n root_1 = @adaptor.become_root( stream_SCOPE.next_node, root_1 )\n\n @adaptor.add_child( root_1, stream_id.next_tree )\n @adaptor.add_child( root_1, stream_ACTION.next_node )\n\n @adaptor.add_child( root_0, root_1 )\n\n\n\n return_value.tree = root_0\n\n end# - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n if @state.backtracking == 0\n\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 4 )\n\n end\n \n return return_value\n end",
"def scope_chain\n scope ? [[scope]] : [[]]\n end",
"def my_squirrels\n # which one knows about BOTH the trees and the nests?\n my_nests.map do |nest|\n nest.squirrel.name\n end\n end",
"def subsets_scopes\n @subsets_scopes\n end",
"def clear_symbols(*symbols)\n [BusScheme.current_scope, BusScheme::SYMBOL_TABLE].compact.map{ |scope| symbols.map{ |sym| scope.delete sym } }\n end",
"def scope\n return @scope if @scope\n\n @scope = hard_scope.dup\n soft_dependencies = []\n\n enabled_dependencies.each do |dependency|\n binds = nil\n node = nil\n\n if dependency.polymorphic?\n alias_prefix = SOFT_PREFIX if @scope.manager.ast.with&.children&.map(&:left)&.map(&:name)&.include?(\"#{HARD_PREFIX}#{dependency.name.to_s.pluralize}\")\n dependency.models.each do |model|\n next unless model.scoped?\n next unless circular_dependency?(dependency, model) || alias_prefix\n\n model_manager = model.hard_scope.manager.dup\n model_manager.projections = [\n Arel::Nodes::As.new(Arel::Nodes::Quoted.new(model.clazz.name), Arel::Nodes::SqlLiteral.new(:type.to_s)),\n model.primary_key.as(:id.to_s)\n ]\n\n if node\n binds.concat(model.hard_scope.binds)\n node = node.union_all(model_manager)\n else\n binds = model.hard_scope.binds\n node = model_manager.ast\n end\n end\n else\n next unless circular_dependency?(dependency) && dependency.soft?\n next unless dependency.models.first.scoped?\n\n model = dependency.models.first\n binds = model.hard_scope.binds\n manager = model.hard_scope.manager.dup\n manager.projections = [model.primary_key.as(:id.to_s)]\n node = manager.ast\n end\n\n next unless node\n\n dependencies = Arel::Table.new(\"#{alias_prefix}#{dependency.name.to_s.pluralize}\")\n\n on = dependencies[:id].eq(arel_table[dependency.foreign_key])\n on = dependencies[:type].eq(arel_table[dependency.foreign_type]).and(on) if dependency.polymorphic?\n\n @scope.manager\n .join(dependencies, Arel::Nodes::OuterJoin)\n .on(on)\n .prepend_with(Arel::Nodes::As.new(dependencies, Arel::Nodes::Grouping.new(node)))\n @scope.binds.unshift(*binds)\n soft_dependencies << DependencyTable.new(dependency, dependencies)\n end\n\n unless soft_dependencies.empty?\n @scope.manager.projections = enabled_columns.keys.map do |column|\n info = soft_dependencies.find { |dt| dt.dependency.foreign_key == column }\n next info.table[info.dependency.models.first.clazz.primary_key].as(info.dependency.foreign_key) if info\n\n info = soft_dependencies.find { |dt| dt.dependency.foreign_type == column }\n next info.table[:type].as(info.dependency.foreign_type) if info\n\n arel_table[column]\n end\n end\n\n @scope\n end"
] |
[
"0.59482014",
"0.5947744",
"0.58883786",
"0.5883107",
"0.58507305",
"0.5771868",
"0.5759235",
"0.56927687",
"0.5626161",
"0.5608084",
"0.5599274",
"0.5589726",
"0.55891174",
"0.5549639",
"0.5541664",
"0.5518219",
"0.5476042",
"0.54557234",
"0.54118705",
"0.5394323",
"0.5377013",
"0.5361893",
"0.5350371",
"0.5335",
"0.5332207",
"0.5311591",
"0.5304776",
"0.5297321",
"0.5285212",
"0.5277918",
"0.5243937",
"0.5237934",
"0.5229125",
"0.5217242",
"0.520775",
"0.51903844",
"0.5172224",
"0.51535696",
"0.51466376",
"0.5138485",
"0.5135947",
"0.512585",
"0.51101327",
"0.509597",
"0.50825316",
"0.50608116",
"0.5031051",
"0.5007424",
"0.500435",
"0.50021017",
"0.4997618",
"0.49948376",
"0.4980946",
"0.4980946",
"0.4969899",
"0.49655223",
"0.49628767",
"0.49514946",
"0.49208748",
"0.49167863",
"0.49137145",
"0.48987547",
"0.48978522",
"0.48978522",
"0.48972797",
"0.48889232",
"0.48810458",
"0.48772463",
"0.48743612",
"0.48698586",
"0.486897",
"0.48658285",
"0.48594883",
"0.4858091",
"0.48373944",
"0.48261863",
"0.4824289",
"0.48182255",
"0.48141932",
"0.48117888",
"0.4809943",
"0.4809943",
"0.48093855",
"0.48092994",
"0.4806529",
"0.4804993",
"0.48008764",
"0.48004058",
"0.47987467",
"0.47979954",
"0.4791895",
"0.47796404",
"0.4771565",
"0.47703725",
"0.47675323",
"0.47632632",
"0.47547987",
"0.47541562",
"0.47511852",
"0.47483456"
] |
0.68184316
|
0
|
=begin rdoc Return a list of all namespaces defined in this scope. If recurse is true, all child scopes are included as well. =end
|
def namespaces(recurse=false)
symbols(false, recurse).map { |s| s.namespace }.sort.uniq
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def namespaces\n root ? root.collect_namespaces : {}\n end",
"def namespaces(name = nil)\n find_children_of_type(\"Namespace\", name)\n end",
"def get_namespaces\n @paths.keys\n end",
"def namespaces\n root ? root.namespaces : {}\n end",
"def namespaces_list(trace: false, &block)\n r = dropbox_query(query: '2/team/namespaces/list', trace: trace)\n r['namespaces'].each(&block)\n while r != nil && r['has_more']\n r = dropbox_query(query: '2/team/namespaces/list/continue', query_data: \"{\\\"cursor\\\":\\\"#{r['cursor']}\\\"}\", trace: trace)\n next unless r != nil\n\n r['namespaces'].each(&block)\n end\n end",
"def eager_load_namespaces; end",
"def get_namespaces\n response = get_siteinfo('namespaces')\n ret = {}\n response['query']['namespaces'].each do |id, _|\n idid = response['query']['namespaces'][id]['id']\n name = response['query']['namespaces'][id]['*']\n ret[idid] = name\n end\n ret\n end",
"def namespace_scopes\n super\n end",
"def namespaces(name = nil)\n if name\n namespaces.find(:name => name)\n else\n @namespaces.flatten\n end\n end",
"def collect_namespaces(object); end",
"def get_namespaces\n raise NotImplementedError\n end",
"def collect_namespaces\n # TODO: print warning message if a prefix refers to more than one URI in the document?\n ns = {}\n traverse {|j| ns.merge!(j.namespaces)}\n ns\n end",
"def namespaces\n Dir[\"#{NAMESPACE_DIR}/*\"]\n .find_all { |dir| FileTest.directory?(dir) }\n .map { |dir| File.basename(dir) }\nend",
"def namespaces\n map(&:namespace).map(&:prefix).map(&:to_s).map(&:downcase).uniq\n end",
"def namespace_names\n @namespaces.map(&:name)\n end",
"def namespaces\n result = []\n each_instance( \"root/interop\", \"CIM_Namespace\" ) do |inst|\n result << inst.Name\n end\n result.uniq\n end",
"def namespaces\n warn \"DEPRECATED: this is no longer supported by LDAP. This method will always return an empty Array\"\n []\n end",
"def possible_namespaces\n namespaces = []\n key = @key.to_s\n while (index = key.rindex('_'))\n key = key[0, index]\n namespaces << key.to_sym\n end\n namespaces\n end",
"def scopes\n @scope.scopes\n end",
"def namespaces; end",
"def namespaces; end",
"def namespaces; end",
"def namespaces; end",
"def namespaces\n ns = {}\n\n JSON.parse(raw_namespaces)[\"results\"][\"bindings\"].each {|x|\n ns[x[\"prefix\"][\"value\"]] = x[\"namespace\"][\"value\"]\n }\n ns\n end",
"def namespaces_by_prefix\n namespace_scopes.reduce({}, &->(m, ns) { m[ns.prefix]=ns; m })\n end",
"def hidden_namespaces; end",
"def namespaces(*namespaces)\n namespaces.each do |ns|\n namespace ns\n end\n @namespaces\n end",
"def scope\n @scope ||= Array(@root_scope) + [Inflector.underscore(name)]\n end",
"def descendants\n self.subfolders.collect do |s|\n [s] + s.descendants\n end.flatten\n end",
"def index\n @namespaces = Namespace.all\n end",
"def index\n @namespaces = Namespace.all\n end",
"def all_children(scope = {})\n full_set(scope) - [self]\n end",
"def namespaces\n namespace.split(NAMESPACE_PATTERN)\n end",
"def namespaces\n namespace.split(NAMESPACE_PATTERN)\n end",
"def to_a\n namespaces.values.tap do |arr|\n arr << Namespace.default_root unless arr.any?(&:root?)\n end\n end",
"def namespaces?\n t_namespaces=@linker.call(\"account\",\"namespaces\")\n if(t_namespaces[\"status\"].to_sym == :success)\n out={}\n t_namespaces[\"namespaces\"].each do |namespace|\n nm=Namespace.new(@linker,namespace[\"name\"],namespace[\"size\"],namespace[\"share_mode\"].to_sym,namespace[\"owner\"])\n out[nm.name]=nm\n end\n return out\n else\n return {}\n end\n end",
"def namespaces_by_uri\n namespace_scopes.reduce({}, &->(m, ns) { m[ns.href]=ns; m })\n end",
"def select_base_namespace(base_name, lexical_scope_paths)\n Enumerator.new do |yielder|\n lexical_scope_paths.each do |path|\n scope = find_constant(path.to_s)\n next if !scope || !scope.is_a?(Objects::NamespaceObject)\n select_child_constants(scope, base_name).each do |obj|\n yielder << obj\n end\n end\n\n nearest_scope_path = lexical_scope_paths.first\n if nearest_scope_path && nearest_scope = find_constant(nearest_scope_path) && nearest_scope.is_a?(Objects::NamespaceObject)\n select_constants_from_ancestors(nearest_scope, base_name).each do |obj|\n yielder << obj\n end\n end\n end\n end",
"def namespaceNames\n @options[:namespaceNames] ||= fetch(:namespaceNames)\n end",
"def list_namespaces request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_list_namespaces_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Cloud::ServiceDirectory::V1beta1::ListNamespacesResponse.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end",
"def in_namespace(name)\n name ||= generate_name\n @scope = Scope.new(name, @scope)\n ns = NameSpace.new(self, @scope)\n yield(ns)\n ns\n ensure\n @scope = @scope.tail\n end",
"def clearNamespaces() \n @obj.clearNamespaces()\n end",
"def namespaces_to_paths(namespaces)\n paths = []\n namespaces.each do |namespace|\n pieces = namespace.split(\":\")\n path = pieces.join(\"/\")\n paths << \"#{path}/#{pieces.last}\"\n paths << path\n end\n paths.uniq!\n paths\n end",
"def all\n if current_scope\n current_scope.clone\n else\n default_scoped\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 scopes\n scope ? [scope] : []\n end",
"def find_all_in_scope(node, predicate); end",
"def list_stateful_set_for_all_namespaces(opts = {})\n data, _status_code, _headers = list_stateful_set_for_all_namespaces_with_http_info(opts)\n return data\n end",
"def alternate_namespaces\n return @alternate_name.keys()\n end",
"def ancestors_for(namespace)\n ancestors = []\n current = namespace\n\n while current&.parent_id\n # We're using find_by(id: ...) here to deal with cases where the\n # parent_id may point to a missing row.\n current = Namespace.unscoped.select([:id, :parent_id])\n .find_by(id: current.parent_id)\n\n ancestors << current.id if current\n end\n\n ancestors\n end",
"def descendents(scope)\n if parent_scope?(scope)\n return SCOPE_TREE[scope].keys.map do |child|\n [child, descendents(child)]\n end.flatten\n else\n parent_scopes.each do |top|\n return SCOPE_TREE[top][scope].keys if SCOPE_TREE[top].key?(scope)\n end\n end\n\n []\n end",
"def namespace_declarations(ctx); end",
"def namespace_declarations(ctx); end",
"def expire_all_namespaces(scope_hash={})\n scope_hash = self.attributes if scope_hash == {} && self.respond_to?(:attributes)\n self.class.expire_all_namespaces(scope_hash)\n end",
"def index\n @hcao_namespaces = HcaoNamespace.all\n end",
"def scopes\n read_inheritable_attribute(:scopes) || write_inheritable_attribute(:scopes, {})\n end",
"def each\n namespaces.each_pair{|name, n| yield n if block_given?}\n end",
"def list_namespace(regex = '.*')\n pattern = java.util.regex.Pattern.compile(regex)\n list = @admin.listNamespaces\n list.select { |s| pattern.match(s) }\n end",
"def namespaced_hash\n\t\tif @namespace\n\t\t\tself.log.debug \"Returning namespaced hash: %p\" % [ @namespace ]\n\t\t\treturn @hash[ @namespace ]\n\t\telse\n\t\t\tself.log.debug \"Returning toplevel namespace\"\n\t\t\treturn @hash\n\t\tend\n\tend",
"def get_paths(namespace = MAIN_NAMESPACE)\n @paths[namespace] || []\n end",
"def scopes\n @scopes ||= {}\n end",
"def namespaces\n @opts[:namespace]\n end",
"def define_namespaces #:nodoc:\n unless self.respond_to?(:namespaces)\n send(:define_singleton_method, :namespaces) { @namespaces }\n send(:define_method, :namespaces) { self.class.namespaces }\n end\n end",
"def find_scopes\n begin\n pptr = FFI::MemoryPointer.new(:pointer, 128)\n\n result = SLPFindScopes(@handle, pptr)\n raise Error, \"SLPFindScopes(): #{result}\" if result != :SLP_OK\n\n arr = pptr.read_array_of_string\n ensure\n SLPFree(pptr.read_pointer)\n pptr.free unless pptr.null?\n end\n\n arr\n end",
"def scopes\n self.class.scopes\n end",
"def recursive(*args)\n @scope.with_values += args\n @scope.recursive_value = true\n @scope\n end",
"def recursive(*args)\n @scope.with_values += args\n @scope.recursive_value = true\n @scope\n end",
"def define_all_scopes\n if self.resource_definition[\"scopes\"]\n self.resource_definition[\"scopes\"].each_pair do |name, opts|\n self.scope(name, opts)\n end\n end\n true\n end",
"def renumber_all\n scopes = []\n # only call it once for each scope_condition (if the scope conditions are messed up, this will obviously cause problems)\n roots.each do |r|\n r.renumber_full_tree unless scopes.include?(r.scope_condition)\n scopes << r.scope_condition\n end\n end",
"def find_all(options = {})\n construct_scope(options).to_a\n end",
"def namespace_hierarchy(mod)\n parent = Object\n hier = [parent]\n\n # name is not present on anonymous modules\n if mod.name\n mod.name.split('::').each do |part|\n parent = parent.const_get(part)\n hier << parent\n end\n end\n\n hier.reverse\n end",
"def all_objects\n objects = []\n each_namespace{|n| objects << n}\n each_namespace{|n| \n n.each_relvar{|r| objects << r}\n }\n each_namespace{|n| \n n.each_relvar{|r| r.each_candidate_key{|k| objects << k}}\n }\n each_namespace{|n| \n n.each_relvar{|r| r.each_foreign_key{|k| objects << k}}\n }\n objects\n end",
"def get_namespace_aliases\n response = get_siteinfo('namespacealiases')\n ret = {}\n response['query']['namespacealiases'].each do |i|\n ret[i['id']] = i['*']\n end\n ret\n end",
"def descendants\n _descendants.flatten.uniq\n end",
"def scopes\n @@scopes ||= {}\n end",
"def scoped_all(organization_scoped_ar)\n organization_scoped_ar.organization_scope(organization).all\n end",
"def scopes\n scope_names.to_a.sort\n end",
"def roots\n self.ontology_classes(force_reload=true).select{|c| c.isroot?}\n end",
"def print_list(base, namespaces)\n return if namespaces.empty?\n puts \"#{base.camelize}:\"\n\n namespaces.each do |namespace|\n puts(\" #{namespace}\")\n end\n\n puts\n end",
"def descendants\n children + children.map(&:descendants).flatten\n end",
"def scopes; end",
"def xpath_all(pdoc, path, namespace = '')\n begin\n if namespace != \"\"\n return pdoc.find(path, namespace) if pdoc.find(path, namespace)\n else\n return pdoc.find(path) if pdoc.find(path)\n end\n rescue\n return []\n end\n end",
"def renumber_all\n scopes = []\n # only call it once for each scope_condition (if the scope conditions are messed up, this will obviously cause problems)\n roots.each do |r|\n r.renumber_full_tree unless scopes.include?(r.scope_condition)\n scopes << r.scope_condition\n end\n end",
"def find_by_namespace(name)\n @namespaces.select {|ns| ns[:namespace] == name}\nend",
"def register_namespaces(namespaces); end",
"def register_namespaces(namespaces); end",
"def nesting(name)\n nesting = []\n namespace = name.split(\"::\")\n namespace.inject(Object) do |base, n|\n klass = base.const_get(n)\n nesting << klass\n klass\n end\n nesting.reverse\n end",
"def static_scopes\n scopes = self.scope_definition\n .select { |_k, v| v.blank? }\n .keys\n scopes | [:first, :last, :all]\n end",
"def folders namespace=:main\n list = PLUGIN.values\n list.select { |it| it.namespace.include?(namespace) }\n list.map { |it| it.folder }\n end",
"def descendants\n @descendants\n end",
"def list_available_aws_namespaces_with_http_info(opts = {})\n\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: AWSIntegrationAPI.list_available_aws_namespaces ...'\n end\n # resource path\n local_var_path = '/api/v1/integration/aws/available_namespace_rules'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'Array<String>'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth]\n\n new_options = opts.merge(\n :operation => :list_available_aws_namespaces,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type,\n :api_version => \"V1\"\n )\n\n data, status_code, headers = @api_client.call_api(Net::HTTP::Get, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AWSIntegrationAPI#list_available_aws_namespaces\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def package_namespaces\n namespaces = [EPUB2_NAMESPACES]\n namespaces << EPUB3_NAMESPACES if @target.epub_version >= 3\n namespaces << IBOOKS_NAMESPACES if @target.epub_version >= 3 && @target.ibooks?\n namespaces.reduce(:merge)\n end",
"def descendants\n Base.descendants\n end",
"def index\n @namespaces = current_user.namespaces\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @namespaces }\n end\n end",
"def ancestors(scope = {})\n self_and_ancestors(scope) - [self]\n end",
"def ancestors\n includes.map { |i| i.module }.reverse\n end",
"def descendants_scope(node)\n node.scope.join_recursive do |query|\n query.connect_by(join_columns(columns.id => columns.parent))\n .start_with(node.to_relation)\n\n yield query if block_given?\n\n query.order_siblings(position)\n end\n end",
"def xpath_all(pdoc, path, namespace = '')\n if namespace!=\"\"\n return REXML::XPath.match(pdoc, path, namespace)\n else\n return REXML::XPath.match(pdoc, path);\n end\n return []\n end",
"def resolve\n scope.all\n end",
"def cleanup_namespaces\n namespaces.reject! { |namespace| namespace['prefix'].blank? || namespace['uri'].blank? } if namespaces.present?\n end"
] |
[
"0.6608163",
"0.63307005",
"0.6328688",
"0.6302396",
"0.62484294",
"0.60767066",
"0.6074819",
"0.6070898",
"0.60553",
"0.59742683",
"0.5966621",
"0.596532",
"0.58927965",
"0.5837362",
"0.58171564",
"0.57937944",
"0.5710635",
"0.5691525",
"0.56797403",
"0.5676827",
"0.5676827",
"0.5676827",
"0.5676827",
"0.56279886",
"0.5619892",
"0.55916107",
"0.55537",
"0.5542371",
"0.55004704",
"0.5484106",
"0.5484106",
"0.5436234",
"0.54252017",
"0.54252017",
"0.54046047",
"0.54029346",
"0.5375154",
"0.53345406",
"0.532832",
"0.5324872",
"0.5253335",
"0.5251744",
"0.5225275",
"0.5218038",
"0.52078706",
"0.52040946",
"0.51693505",
"0.51659566",
"0.5163012",
"0.51617604",
"0.5148342",
"0.51481515",
"0.51481515",
"0.51387",
"0.5129885",
"0.5123374",
"0.51165813",
"0.5115649",
"0.50972563",
"0.50373125",
"0.50362307",
"0.50294995",
"0.5016113",
"0.50144917",
"0.5010295",
"0.499274",
"0.499274",
"0.4975352",
"0.49644375",
"0.49620867",
"0.49552566",
"0.49439496",
"0.49385563",
"0.49373716",
"0.49368703",
"0.4935878",
"0.49349114",
"0.49337402",
"0.49057576",
"0.48998022",
"0.48984998",
"0.48962197",
"0.48928225",
"0.48872483",
"0.48827085",
"0.48827085",
"0.48623216",
"0.48616782",
"0.48590326",
"0.48503286",
"0.48399812",
"0.48180175",
"0.480562",
"0.47968823",
"0.47866818",
"0.47824717",
"0.47676104",
"0.47632706",
"0.47538787",
"0.4752452"
] |
0.77889705
|
0
|
=begin rdoc Return number of symbols defined in this scope. =end
|
def num_symbols
@symtab.keys.count
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def size() @symbols.size end",
"def count\n @symbols.count\n end",
"def num_sym_assumptions()\n count = 0\n for hop in @hops\n count += 1 if hop.type == :sym or hop.type == \"sym\"\n end\n count\n end",
"def symbol_ref\n @symbols += 1\n end",
"def total_documented\n @methods.select {|b| b}.length +\n @classes.select {|b| b}.length +\n @modules.select {|b| b}.length +\n @attrs.select {|b| b}.length +\n @constants.select {|b| b}.length\n end",
"def variable_count\n variables.size\n end",
"def count\n defined_types.size\n end",
"def symbolic_count(count); end",
"def size\n @definitions.size\n end",
"def depth\n @locals.size\n end",
"def symbols() @symbols end",
"def scope_count\n count_scope = scope.dup\n count_scope.manager.projections = [Arel.star.count]\n\n count_scope.execute.first&.values&.first || 0\n end",
"def wildcard_count\n @landmarks.flatten.select {|feature| feature.kind_of? Symbol}.size\n end",
"def symbols; end",
"def test_counts\n assert_equal(14, @symbols.length, \"Symbols Length\")\n end",
"def key_count\n $capitals.keys.length\nend",
"def length\n length = 1 #@primary\n length += @extlang.length if @extlang\n length += 1 if @script\n length += 1 if @region\n length += @variants.length if @variants\n @extensions.each { |_,e| length += e.length+1 } if @extensions # length += @extenstions.to_a.flatten.length if @extensions\n length += @privateuse.length+1 if @privateuse\n length\n end",
"def size\n\n clib.tclistnum(@pointer)\n end",
"def number_indents\n 0\n end",
"def get_symbols\n\t\treturn @symbols\n\tend",
"def get_number_of_states\n return @dfa.get_number_of_states\n end",
"def num_appearances\n @@all.select do |character|\n character.name == self.name\n end.length\n end",
"def num_keys\n end",
"def count\n __types__.count\n end",
"def size\n C.LLVMCountParams(@fun)\n end",
"def length()\n return @i_keys.get_length()\n end",
"def size()\n @VAR_STACK.length()\n end",
"def calculate_word_count\n 0x0C\n end",
"def length()\n #This is a stub, used for indexing\n end",
"def size\n variables.size\n end",
"def count\n @flags.size\n end",
"def number_of_tokens\r\n return MONOPOLY_GAME[:tokens].count\r\nend",
"def counts\n count = Hash.new(0)\n self.each{|ele| count[ele] += 1}\n count\n end",
"def length()\n return self.keys.get_length()\n end",
"def length()\n #This is a stub, used for indexing\n end",
"def calculate_word_count\n 0x0A\n end",
"def total_entities\n @methods.length +\n @classes.length +\n @modules.length +\n @attrs.length +\n @constants.length\n end",
"def size\n\n clib.tcmaprnum(pointer_or_raise)\n end",
"def num_chars\n @name.split('').count\n end",
"def size\n C.LLVMCountBasicBlocks(@fun)\n end",
"def symbols\n @symbol_set.symbols\n end",
"def ntCount\n return @ntIndex.length\n end",
"def n3\n # return []\n base_words = $base_words\n $base_words = Az.n1\n ret = KeyboardSymbols.n2\n $base_words = base_words\n return ret\n end",
"def num_states\n @state.size\n end",
"def num_states\n @state.size\n end",
"def number_of_tokens\n result = MONOPOLY_GAME[:tokens].count\n\nend",
"def num_states\n@state.size\nend",
"def word_count\n @@word_count\n end",
"def define_method_count\n repository.files.map do |file|\n content = repository.read(file)\n content.to_s.scan(/define_method/).size\n end.sum\n end",
"def length\n count = 0\n each { count += 1 }\n count\n end",
"def length\n hash.keys.length\n end",
"def length\n @internal_hash.length\n end",
"def occurences_count\n\t\t\t\t\t\tHash.new(0).tap do |result|\n\t\t\t\t\t\t each { |item| result[item] += 1 }\n\t\t\t\t\t\tend\n\t\t\t\tend",
"def length\n stash.length\n end",
"def table_alias_length\n @table_alias_length ||= (query(\"select length from systypes where name = 'sysname'\")[0][0].to_i)\n end",
"def state_length\r\n @state.length\r\n end",
"def size()\n #This is a stub, used for indexing\n end",
"def number_of_types\n return GameData::Type.all.size\n end",
"def number_of_types\n return GameData::Type.all.size\n end",
"def size\n @references_to_keys_map.count do |_, ref|\n ref.object\n end\n end",
"def number_of_syllables\n return (@words.map { |word| Helpfulness::PT::Syllable::syllables( word ).length }.inject(:+).to_f) || 0\n end",
"def symbol\n :R\n end",
"def stack_size()\n #This is a stub, used for indexing\n end",
"def count\n @letters.length\n end",
"def length\n @tokens.length\n end",
"def length\n length = 0; each {length += 1}; length\n end",
"def length\n @array_specs.spec_count\n end",
"def length; count end",
"def missingmodulecount\n $number_of_missing_modules = @missingmodules.count().to_s\nend",
"def length\n @count\n end",
"def symbol\n :R\n end",
"def num_vars\n constraint.lhs.size\n end",
"def longest_sym_sequence()\n count = 0\n max = 0\n for hop in @hops\n if hop.type != :sym and hop.type != \"sym\"\n count = 0 \n else\n count += 1\n max = (count > max) ? count : max\n end\n end\n\n max\n end",
"def length\n keys.length\n end",
"def length\n count\n end",
"def binding_count\n bindings.size\n end",
"def length()\n return @letter_bag.length\n end",
"def value_count\n $capitals.values.length\nend",
"def size=(_); end",
"def size=(_); end",
"def size\r\n return @code.size\r\n end",
"def used_names; end",
"def symbol(line)\n if line[/^@[0-9]/] then\n return line[/^*\\d+/].to_i\n elsif line[/^*[a-z_$A-Z0-9:.]+/] then\n symbol = line[/^*[a-z_$A-Z0-9:.]+/]\n if @symbol_table.has_key?(symbol) then\n return @symbol_table[symbol].to_i\n else\n @symbol_table[symbol] = @var\n @var += 1\n return @var - 1\n end\n end\n end",
"def keys()\n @locals.keys\n end",
"def size\n @atoms.size\n end",
"def size\n @keys.size\n end",
"def size()\n #This is a stub, used for indexing\n end",
"def size()\n #This is a stub, used for indexing\n end",
"def accessors_count\n self.accessors.count\n end",
"def symbols\n @flags.keys\n end",
"def length\n return @stack.length\n end",
"def length; end",
"def length; end",
"def length; end",
"def length; end",
"def length; end",
"def length; end",
"def length; end",
"def length\n each.count\n end",
"def length\r\n self.count\r\n end"
] |
[
"0.80281717",
"0.7972307",
"0.66729957",
"0.6554171",
"0.65375775",
"0.64984596",
"0.64677846",
"0.6394975",
"0.6370103",
"0.6336157",
"0.6294522",
"0.6276931",
"0.61802554",
"0.6163487",
"0.6130694",
"0.6120605",
"0.6105579",
"0.60652995",
"0.60208327",
"0.60191417",
"0.59993064",
"0.59727126",
"0.59575754",
"0.5954712",
"0.5943321",
"0.59006155",
"0.5900156",
"0.58507127",
"0.58457595",
"0.5839693",
"0.5830402",
"0.58266836",
"0.5814365",
"0.5808679",
"0.57993716",
"0.5781509",
"0.5778556",
"0.57750475",
"0.57729715",
"0.57596165",
"0.5723112",
"0.57143605",
"0.57086897",
"0.5689209",
"0.5689209",
"0.5684688",
"0.5672817",
"0.56669015",
"0.5663501",
"0.5663013",
"0.5656853",
"0.5653793",
"0.56526214",
"0.56426084",
"0.5634921",
"0.5630111",
"0.5626186",
"0.5612117",
"0.5612117",
"0.5599929",
"0.55962694",
"0.55952424",
"0.5594746",
"0.5588614",
"0.5584736",
"0.5574356",
"0.5572463",
"0.5561335",
"0.5556808",
"0.55541235",
"0.5549105",
"0.5548522",
"0.55467254",
"0.55255014",
"0.5524225",
"0.5523883",
"0.55202013",
"0.5513577",
"0.5512149",
"0.5512149",
"0.5507956",
"0.54961556",
"0.54929495",
"0.5491586",
"0.5485947",
"0.5480757",
"0.5477714",
"0.5477714",
"0.5466654",
"0.5456052",
"0.5452912",
"0.54506356",
"0.54506356",
"0.54506356",
"0.54506356",
"0.54506356",
"0.54506356",
"0.54506356",
"0.5448463",
"0.5448132"
] |
0.8217561
|
0
|
=begin rdoc Define a symbol for function 'name' at location 'value' in scope. =end
|
def define_func(name, value, namespace=nil)
define(CodeSymbol.new name, value, namespace)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def []=(name, value)\n @symbols[to_name(name)] = value\n value.name = name if Function === value\n value\n end",
"def symfun name\n Symbolic.check_name name\n fs = SymbolicFunction.new(name)\n meta_def name do\n fs\n end\n fs\n end",
"def define_function(name, &block)\n functions[name.to_sym] = block\n nil\n end",
"def use_function(name)\n call \"_#{name}\"\n end",
"def constant(name, value)\n define_method name.to_sym do\n value\n end\n end",
"def arel_fn(name, *args)\n Arel::Nodes::NamedFunction.new(name, args)\n end",
"def named_function(name, expression, function_alias = nil)\n Arel::Nodes::NamedFunction.new(name, expression, function_alias)\n end",
"def function_define(name=\"\",&block)\n \"function #{name}() { #{block.call} }\" \n end",
"def compile_defun(scope, name, args, body)\n f = Function.new(args, body,scope)\n name = clean_method_name(name)\n\n # add function to the global list of functions defined so far\n @global_functions[name] = f\n\n # a function is referenced by its name (in assembly this is a label).\n # wherever we encounter that name, we really need the adress of the label.\n # so we mark the function with an adress type.\n return [:addr, clean_method_name(name)]\n end",
"def my_method_param(name) #Define method \"my_method_param\"\n print \"Hello #{name}!\"\nend",
"def funcname\n NAMES[@name][1]\n end",
"def get_function(type, name, function)\n func = function\n\n unless function\n func = case type\n when :key then \"(#{Misc::DOCUMENT_OFFSET}#{name} || #{Misc::ID_OFFSET}#{name})\"\n #when :value then \"(#{Misc::DOCUMENT_OFFSET}#{name} || #{name})\"\n when :value then \"(typeof #{name} != 'undefined' ? #{name} : #{Misc::DOCUMENT_OFFSET}#{name})\"\n end\n end\n\n return func\n end",
"def meta_def( name, &blk )\r\n meta_eval { define_method name, &blk }\r\n end",
"def method_name\n def value\n 5\n end\nend",
"def hello; :hello; end",
"def meta_def name, &blk\r\n meta_eval { define_method name, &blk }\r\n end",
"def def_symbol(name, address, memory_type = nil)\n @symbol_set.def_symbol name, address, memory_type\n end",
"def fn(name, &block)\n if block_given?\n @fns[name] = block\n else\n @fns[name]\n end\n end",
"def fn(name, &block)\n if block_given?\n @fns[name] = block\n else\n @fns[name]\n end\n end",
"def meta_def name, &blk\n meta_eval { define_method name, &blk }\n end",
"def add_udf(name, value)\n @params.merge!(\"UDF[#{name}]\" => value)\n end",
"def meta_def name, &blk\n meta_eval { define_method name, &blk }\n end",
"def add_function(name)\n case name\n when :update_timestamp\n return add_function_update_timestamp\n end\n raise \"called add_function on undefined function '#{name}'\"\n end",
"def meta_def( name, &blk )\n meta_eval { define_method name, &blk }\n end",
"def meta_def(name, &blk)\n meta_eval { define_method name, &blk }\n end",
"def make_function(exp, register = true)\n name = map_name exp.shift\n args = exp.shift\n ruby_args = args.deep_clone\n ruby_args.shift # :args\n\n @method_name = name\n @c_method_name = \"rrc_c#{@c_klass_name}_#{normal_to_C name}\"\n\n @env.scope do\n c_args = check_args args, register # registered methods get self\n @methods[name] = ruby_args if register\n\n body = process exp.shift\n\n if name == :initialize then\n body[-1] = \"return self;\\n}\"\n end\n\n return \"static VALUE\\n#{@c_method_name}#{c_args} #{body}\"\n end\n end",
"def define method_name, &block\n machine.named_procs[method_name] = block\n end",
"def meta_def(name, &block)\n meta_eval{define_method(name, &block)}\n end",
"def create_function(function_name, returning, definition, options = {})\n\n end",
"def meta_def(name, &blk)\n meta_eval { define_method(name, &blk) }\n end",
"def meta_def name, &blk\n meta_eval { define_method name, &blk }\n end",
"def meta_def name, &blk\n meta_eval { define_method name, &blk }\n end",
"def meta_def name, &blk\n meta_eval { define_method name, &blk }\n end",
"def meta_def name, &blk\n meta_eval { define_method name, &blk }\n end",
"def name(*) end",
"def name(*) end",
"def my_name(value)\n name = value\nend",
"def meta_def name, &blk\n meta_eval { define_method name, &blk }\n end",
"def meta_def name, &blk\n meta_eval { define_method name, &blk }\n end",
"def meta_def name, &blk\n meta_eval { define_method name, &blk }\n end",
"def meta_def name, &blk\n meta_eval { define_method name, &blk }\n end",
"def meta_def name, &blk\n meta_eval { define_method name, &blk }\n end",
"def meta_def name, &blk\n meta_eval { define_method name, &blk }\n end",
"def meta_def name, &blk\n meta_eval { define_method name, &blk }\n end",
"def function_for(path)\n\t\t\t\tparent = @attributes\n\n\t\t\t\tfunction = path.inject(parent) do |current, key|\n\t\t\t\t\tparent = current\n\n\t\t\t\t\tthrow ArgumentError.new(\"Invalid function name #{path.join(\".\")}\") unless current\n\n\t\t\t\t\tcurrent[key]\n\t\t\t\tend\n\n\t\t\t\t# Compile the function if required:\n\t\t\t\tif String === function\n\t\t\t\t\tparent[path.last] = @context.parse_function(function, binding, 'design-document')\n\t\t\t\telse\n\t\t\t\t\tfunction\n\t\t\t\tend\n\t\t\tend",
"def meta_def name, &block\n meta_eval { define_method name, &block }\n end",
"def sym(name)\n #This is a stub, used for indexing\n end",
"def funcions=(value)\n @funcions = value\n end",
"def function_definition\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 8 )\n\n\n value = nil\n\n\n name = nil\n type = nil\n a = nil\n\n\n begin\n # at line 51:5: OPEN type= variable_type name= IDENT ( '(' (type= variable_type name= IDENT ( ',' type= variable_type name= IDENT )* )? ')' )? ( CLOSE | NL (a= statement )* CLOSE )\n match( OPEN, TOKENS_FOLLOWING_OPEN_IN_function_definition_350 )\n @state.following.push( TOKENS_FOLLOWING_variable_type_IN_function_definition_354 )\n type = variable_type\n @state.following.pop\n name = match( IDENT, TOKENS_FOLLOWING_IDENT_IN_function_definition_358 )\n\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n value = FunctionDefinitionEval.new(name.text, type) \n # <-- action\n end\n\n # at line 52:3: ( '(' (type= variable_type name= IDENT ( ',' type= variable_type name= IDENT )* )? ')' )?\n alt_17 = 2\n look_17_0 = @input.peek( 1 )\n\n if ( look_17_0 == T__34 )\n alt_17 = 1\n end\n case alt_17\n when 1\n # at line 52:5: '(' (type= variable_type name= IDENT ( ',' type= variable_type name= IDENT )* )? ')'\n match( T__34, TOKENS_FOLLOWING_T__34_IN_function_definition_366 )\n # at line 52:9: (type= variable_type name= IDENT ( ',' type= variable_type name= IDENT )* )?\n alt_16 = 2\n look_16_0 = @input.peek( 1 )\n\n if ( look_16_0 == IDENT || look_16_0.between?( TYPE_BOOL, TYPE_VOID ) )\n alt_16 = 1\n end\n case alt_16\n when 1\n # at line 53:5: type= variable_type name= IDENT ( ',' type= variable_type name= IDENT )*\n @state.following.push( TOKENS_FOLLOWING_variable_type_IN_function_definition_376 )\n type = variable_type\n @state.following.pop\n name = match( IDENT, TOKENS_FOLLOWING_IDENT_IN_function_definition_380 )\n\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n value.add_argument(type, name.text) \n # <-- action\n end\n\n # at line 54:5: ( ',' type= variable_type name= IDENT )*\n while true # decision 15\n alt_15 = 2\n look_15_0 = @input.peek( 1 )\n\n if ( look_15_0 == T__40 )\n alt_15 = 1\n\n end\n case alt_15\n when 1\n # at line 54:6: ',' type= variable_type name= IDENT\n match( T__40, TOKENS_FOLLOWING_T__40_IN_function_definition_389 )\n @state.following.push( TOKENS_FOLLOWING_variable_type_IN_function_definition_393 )\n type = variable_type\n @state.following.pop\n name = match( IDENT, TOKENS_FOLLOWING_IDENT_IN_function_definition_397 )\n\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n value.add_argument(type, name.text) \n # <-- action\n end\n\n\n else\n break # out of loop for decision 15\n end\n end # loop for decision 15\n\n\n end\n match( T__35, TOKENS_FOLLOWING_T__35_IN_function_definition_409 )\n\n end\n # at line 56:3: ( CLOSE | NL (a= statement )* CLOSE )\n alt_19 = 2\n look_19_0 = @input.peek( 1 )\n\n if ( look_19_0 == CLOSE )\n alt_19 = 1\n elsif ( look_19_0 == NL )\n alt_19 = 2\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n\n\n raise NoViableAlternative( \"\", 19, 0 )\n\n end\n case alt_19\n when 1\n # at line 56:5: CLOSE\n match( CLOSE, TOKENS_FOLLOWING_CLOSE_IN_function_definition_418 )\n\n when 2\n # at line 56:13: NL (a= statement )* CLOSE\n match( NL, TOKENS_FOLLOWING_NL_IN_function_definition_422 )\n # at line 56:16: (a= statement )*\n while true # decision 18\n alt_18 = 2\n look_18_0 = @input.peek( 1 )\n\n if ( look_18_0.between?( IDENT, IF ) || look_18_0 == RETURN || look_18_0 == WHILE )\n alt_18 = 1\n\n end\n case alt_18\n when 1\n # at line 56:17: a= statement\n @state.following.push( TOKENS_FOLLOWING_statement_IN_function_definition_427 )\n a = statement\n @state.following.pop\n\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n value.add_statement(a) \n # <-- action\n end\n\n\n else\n break # out of loop for decision 18\n end\n end # loop for decision 18\n\n match( CLOSE, TOKENS_FOLLOWING_CLOSE_IN_function_definition_434 )\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 8 )\n\n\n end\n\n return value\n end",
"def compile_defun(scope, name, args, body)\n if scope.is_a?(ClassScope) # Ugly. Create a default \"register_function\" or something. Have it return the global name\n\n # since we have a class scope,\n # we also pass the class scope to the function, since it's actually a method.\n f = Function.new([:self]+args, body, scope) # \"self\" is \"faked\" as an argument to class methods.\n\n @e.comment(\"method #{name}\")\n\n cleaned = clean_method_name(name)\n fname = \"__method_#{scope.name}_#{cleaned}\"\n scope.set_vtable_entry(name, fname, f)\n @e.load_address(fname)\n @e.with_register do |reg|\n @e.movl(scope.name.to_s, reg)\n v = scope.vtable[name]\n @e.addl(v.offset*Emitter::PTR_SIZE, reg) if v.offset > 0\n @e.save_to_indirect(@e.result_value, reg)\n end\n name = fname\n else\n # function isn't within a class (which would mean, it's a method)\n # so it must be global\n f = Function.new(args, body)\n name = clean_method_name(name)\n end\n\n # add function to the global list of functions defined so far\n @global_functions[name] = f\n\n # a function is referenced by its name (in assembly this is a label).\n # wherever we encounter that name, we really need the adress of the label.\n # so we mark the function with an adress type.\n return [:addr, clean_method_name(name)]\n end",
"def symbol; end",
"def symbol; end",
"def symbol; end",
"def symbol; end",
"def symbol; end",
"def symbol; end",
"def meta_def(name, &block)\n meta_eval { define_method(name, &block) }\n end",
"def def(name, &block)\n @runtime_methods[name.to_s] = block\n end",
"def add_function(name, &block)\n functions[name] = anonymous_function(block)\n end",
"def method_definition(name)\n bind_call(:instance_method, name)\n end",
"def define(name, value)\n\t\t\t@table[name] = value\n\t\tend",
"def sdef(name, depth=nil, overflow = nil, &ruby_block)\n # Create the function.\n funcT = SequencerFunctionT.new(name,depth,overflow,&ruby_block)\n # Register it for calling.\n if HDLRuby::High.in_system? then\n define_singleton_method(name.to_sym) do |*args|\n funcT.call(*args)\n end\n else\n define_method(name.to_sym) do |*args|\n funcT.call(*args)\n end\n end\n # Return the create function.\n funcT\n end",
"def name=(value); end",
"def module_function(sym, *rest) end",
"def definition(name)\n @pdef_registry[name.to_sym]\n end",
"def [](name)\n functions[name] or raise Error.new(\"no registered function for #{name}\")\n end",
"def func_decl\n type_name\n @instruction.push(@enum.peek.value)\n match(:identifier)\n @instruction.push(@enum.peek.value)\n match(Token.new(:symbol, '('))\n parameter_list\n @instruction.push(@enum.peek.value)\n match(Token.new(:symbol, ')'))\n end",
"def []=(name, value)\n add(name.to_sym, value)\n end",
"def __evaluate__(name)\n return nil unless name\n name.respond_to?(:call) ? name.call.to_sym : name.to_sym\n end",
"def name\n 'method 2'\n end",
"def getFunction(name)\n getFunctionAux(@ast, name)\n end",
"def method_symbol; end",
"def define_functional_variable(name, &block)\n functional_variables[name.to_sym] = block\n nil\n end",
"def define( name, value = nil, false_value = nil )\n if @names.member?(name) or (!@allow_override and resolve(name)) then\n return false_value\n else\n value = yield() if block_given? \n @names[name] = value\n return value\n end\n end",
"def define_attr_method(name, value=nil, &block)\n sing = class << self; self; end\n sing.send :alias_method, \"original_#{name}\", name\n if block_given?\n sing.send :define_method, name, &block\n else\n # use eval instead of a block to work around a memory leak in dev\n # mode in fcgi\n sing.class_eval \"def #{name}; #{value.to_s.inspect}; end\"\n end\n end",
"def add_sym ( addr, name )\n\t@syms[addr] = name\n end",
"def func_decl\n @prog_code << \"#{type_name} \"\n\n fn_name = @scanner.next.value unless @scanner.peek.type != :identifier\n\n @prog_code << \"#{fn_name}\"\n @functions[fn_name] = Function.new unless @functions[fn_name] != nil\n @global_sym_tab[fn_name] = fn_name\n fn = @functions[fn_name]\n @prog_code << \"#{@scanner.next.value}\"\n parameter_list(fn)\n @prog_code << \"#{@scanner.next.value}\"\n\n return @functions[fn_name]\n end",
"def use(sym); end",
"def type\n \"Function\"\n end",
"def fn(name, &block)\n @fns[name] = block and return if block\n @fns[name]\n end",
"def method_name=(_arg0); end",
"def method_name=(_arg0); end",
"def process_defn(exp)\n make_function exp\n end",
"def wrapper(name); end",
"def aaa\n\t\tdefine_method(\"aa\") {puts \"aa\"}\n\tend",
"def initialize(value, unit, function_name)\n @function_name = function_name\n super(value, unit)\n end",
"def add_method(name)\n self.push_literal name\n self.push_context\n self.send :__add_method__, 2\n end",
"def name=(_); end",
"def name=(_); end",
"def name=(_); end",
"def name=(_); end",
"def name=(_); end",
"def name=(_); end",
"def name=(_); end",
"def name=(_); end",
"def instruction name, instruction\n end",
"def __add_method__(name, obj)\n s = MethodContext.current.sender\n scope = s.method_scope || :public\n\n if name == :initialize or scope == :module\n visibility = :private\n else\n visibility = scope\n end\n\n # All userland added methods start out with a serial of 1.\n obj.serial = 1\n\n # Push the scoping down.\n obj.staticscope = s.method.staticscope\n\n Rubinius::VM.reset_method_cache(name)\n\n obj.staticscope.module.method_table[name] = Tuple[visibility, obj]\n\n if scope == :module\n s.current_scope.module_function name\n end\n\n if s.current_scope.respond_to? :method_added\n s.current_scope.method_added(name)\n end\n\n # Return value here is the return value of the 'def' expression\n return obj\n end",
"def termdef(name)\n element(name, {:name => name, :class => 'object_type'}, 'a')\n end",
"def termdef(name)\n element(name, {:name => name, :class => 'object_type'}, 'a')\n end",
"def termdef(name)\n element(name, {:name => name, :class => 'object_type'}, 'a')\n end"
] |
[
"0.6376007",
"0.6342895",
"0.61895347",
"0.6139959",
"0.607645",
"0.59908056",
"0.59749603",
"0.59721446",
"0.5943563",
"0.59186906",
"0.5851679",
"0.582243",
"0.5819515",
"0.5779738",
"0.5768328",
"0.57683176",
"0.57570684",
"0.57507247",
"0.57507247",
"0.5733522",
"0.572135",
"0.57109505",
"0.570822",
"0.5697641",
"0.56872344",
"0.5681658",
"0.5680228",
"0.56704056",
"0.56703466",
"0.5663935",
"0.56556535",
"0.56556535",
"0.56555086",
"0.56555086",
"0.56511253",
"0.56511253",
"0.5649725",
"0.564769",
"0.564769",
"0.564769",
"0.564769",
"0.564769",
"0.564769",
"0.564769",
"0.5626961",
"0.56262684",
"0.5617172",
"0.5616321",
"0.5609007",
"0.5591354",
"0.5587358",
"0.5587358",
"0.5587358",
"0.5587358",
"0.5587358",
"0.5587358",
"0.557986",
"0.5570068",
"0.55541015",
"0.5546392",
"0.5525569",
"0.5521574",
"0.5516053",
"0.5510121",
"0.5506968",
"0.55008966",
"0.54887795",
"0.5485571",
"0.54796726",
"0.5478885",
"0.5456775",
"0.54473925",
"0.5443168",
"0.54379785",
"0.54342717",
"0.54234797",
"0.5422989",
"0.54178935",
"0.54089445",
"0.5405394",
"0.5402469",
"0.5402469",
"0.5400662",
"0.5395894",
"0.5378489",
"0.53700066",
"0.53626174",
"0.53576297",
"0.53576297",
"0.53576297",
"0.53576297",
"0.53576297",
"0.53576297",
"0.53576297",
"0.53576297",
"0.5341006",
"0.5336075",
"0.53283393",
"0.53283393",
"0.53283393"
] |
0.7363207
|
0
|
=begin rdoc Define a symbol for variable 'name' at location 'value' in scope. =end
|
def define_var(name, value, namespace=nil)
define(DataSymbol.new name, value, namespace)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def []=( name, value )\n\t\t\t@locals[ name.to_sym ] = value\n\t\tend",
"def name=(value); end",
"def []=(name, value)\n ::Kernel.raise TypeError, \"name #{name} must convert to_sym\" unless name and name.respond_to?(:to_sym)\n @locals[name.to_sym] = value\n end",
"def []=(name, value)\n @symbols[to_name(name)] = value\n value.name = name if Function === value\n value\n end",
"def var(name, value)\n @locals[name] = value\n end",
"def name= value\r\n @name = value.to_sym\r\n end",
"def []=(name, value)\n add(name.to_sym, value)\n end",
"def my_name(value)\n name = value\nend",
"def set!(name, value)\n scope = innermost_binding(name)\n raise UndefinedVariable.new(\"Cannot set undefined variable '#{name}'\") if scope.nil?\n scope[name] = value\n end",
"def variable(name, value)\n raise \"Invalid variable name '#{name}'.\" unless valid_id(name)\n @file.write(\"#{name} = #{value}\\n\")\n end",
"def define(name)\n if t = defs[name.text.to_sym]\n raise name, \"Already #{t.reserved ? 'reserved' : 'defined'}\" \n end\n \n # TODO: the goal here is to create a \"binding token\" module,\n # (Crockford calls it a \"variable token\") *and* to augment\n # the existing token with the variable token stuff. We're\n # doing the former in store, but not the latter.\n store(name, false)\n end",
"def name(val); @name = val.to_sym; end",
"def var name\n Symbolic.check_name name\n var = VarExpr.new(name)\n meta_def name do\n var\n end\n var\n end",
"def name(value)\n lang_eval { @name = value }\n nil\n end",
"def define(name, value)\n\t\t\t@table[name] = value\n\t\tend",
"def set_local(name, value_node)\n @locals << name unless @locals.include?(name)\n emit \"#{name} = \"\n value_node.compile(self)\n end",
"def name=(value)\n @name = value.to_sym\n end",
"def set_variable(name, value)\n @variables[name] = value\n end",
"def set_variable( name, value)\n\t\tq_value = \n\t\t\tcase value\n\t\t\twhen String\n\t\t\t\t\"\\\"#{value}\\\"\"\t\n\t\t\telse\n\t\t\t\tvalue\n\t\t\tend\n\t\tVim::command(\"let #{name} = #{q_value}\")\n\tend",
"def define_variable(name)\n emit_section :data\n emit \"#{name}: .long 0x0\\n\"\n emit_section :text\nend",
"def define_variable(name)\n emit_section :data\n emit \"#{name}: .long 0x0\\n\"\n emit_section :text\nend",
"def []= name, value\n update_annotation name.to_sym, value\n value\n end",
"def const name, value\n Symbolic.check_name name\n const = ConstExpr.new(name, value)\n meta_def name do\n const\n end\n const\n end",
"def constant(name, value)\n define_method name.to_sym do\n value\n end\n end",
"def [](name)\n name = to_name(name)\n bound = @symbols.has_key?(name)\n \n raise UndefinedVariable.new(\n \"Variable '#{name}' is not defined\") unless bound or Scope === @parent\n \n value = bound ? @symbols[name] : @parent[name]\n value = value.force! if value.respond_to?(:force!)\n value\n end",
"def const(name, value)\n @data << \"#{name}\\tequ #{value}\"\n end",
"def name=(_); end",
"def name=(_); end",
"def name=(_); end",
"def name=(_); end",
"def name=(_); end",
"def name=(_); end",
"def name=(_); end",
"def name=(_); end",
"def variable_name_expr; end",
"def []=(name, value)\n set_namevalue_glob(name,value, :color => 42) # 42 - aqua-marin, 7-green\n end",
"def set_global!(type, name, new_value)\n addr = handler.sym(name)\n raise(Fiddle::DLError, \"cannot find symbol #{name}\") unless addr\n s = struct([\"#{type} value\"])\n tmp = s.new(addr)\n tmp.value = new_value\n tmp.value\n end",
"def []=(name, value)\n add(name, value)\n value\n end",
"def let name, &block\n\t @sketch.define_parameter name, &block\n\tend",
"def def_symbol(name, address, memory_type = nil)\n @symbol_set.def_symbol name, address, memory_type\n end",
"def []=(name, value)\n @slots[name] = value\n end",
"def define_func(name, value, namespace=nil)\n define(CodeSymbol.new name, value, namespace)\n end",
"def define_const(name, value, namespace=nil)\n define(ConstSymbol.new name, value, namespace)\n end",
"def set_variable(name, value)\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n Native.RunEditor_set_variable(@handle.ptr, name, value)\n end",
"def name=(n) #rubyist\n @name = n #@name = name\n end",
"def define( name, value = nil, false_value = nil )\n if @names.member?(name) or (!@allow_override and resolve(name)) then\n return false_value\n else\n value = yield() if block_given? \n @names[name] = value\n return value\n end\n end",
"def setVar( name, value )\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\tArgTest::type( \"value\", value, Object, true )\n\t\t\t\t@vars[ name ] = value\n\t\t\tend",
"def lex_macro name, value\n macros << [name, value]\n end",
"def name(value)\n @ole.Name = value\n nil\n end",
"def name(value)\n @ole.Name = value\n nil\n end",
"def name(value)\n @ole.Name = value\n nil\n end",
"def name(value)\n @ole.Name = value\n nil\n end",
"def define(name)\n current << name\n end",
"def name= val # Setter - set a value\n @name = val \n end",
"def gen_put_variable(code_array, name)\n if name.kind_of?(JSValue)\n assert(name.type == :identifier)\n name = name.value\n end\n\n res = resolve_variable(name)\n if res\n type, link, idx = res\n if link == 0\n code_array.push(type == :formal ? :INSN_PUTFORMAL : :INSN_PUTLVAR)\n code_array.push(idx)\n else\n code_array.push(type == :formal ? :INSN_PUTFORMALEX : :INSN_PUTLVAREX)\n code_array.push(link)\n code_array.push(idx)\n end\n else\n # global variable\n code_array.push(:INSN_GETGLOBAL)\n code_array.push(:INSN_CONST)\n code_array.push(JSValue.new_string(name))\n code_array.push(:INSN_PUTPROP)\n end\n end",
"def []=(name, value); end",
"def []=(name, value); end",
"def []=(name, value); end",
"def var_decl(type, name)\n if entry = get_entry(type)\n entry[:ctype].gsub(\"%s\", name.to_s)\n # FIXME type.to_s\n elsif type.to_s.include?(\"%s\")\n type.gsub(\"%s\", name.to_s)\n else\n \"#{type} #{name}\"\n end\n end",
"def set_variable(name, value) \r\n\t\tmsg=\"SET VARIABLE \" + name + \" \" + value\r\n\t\tsend(msg)\r\n\t\treturn get_int_result()\r\n\tend",
"def name (name)\n @name = name\n end",
"def add(name, value = nil)\n symbols << [name.to_s, (Integer(value) if value)]\n end",
"def name=(value)\n @name = attributes[:name] = value\n end",
"def assign(name, value, top=false)\n return @parent.assign(name, value, top) if top && @parent\n @variables[name.to_sym] = Value.new(value)\n end",
"def scope=(v); end",
"def scope=(v); end",
"def name(value)\n attributes[:name] = value\n end",
"def name=(value)\n @name = value\n end",
"def name=(value)\n @name = value\n end",
"def []=(name, value)\n if defined?(ObjectSpace)\n eval(\"#{sanitize(name)} = ObjectSpace._id2ref(#{value.object_id})\")\n else\n eval(\"#{sanitize(name)} = #{value}\")\n end\n end",
"def name(name)\n @name = name\nend",
"def defvar(name, dwords=1)\n unless var?(name)\n @bss << \"#{name}: resd #{dwords}\\n\"\n @vars[name] = name\n else\n STDERR.puts \"[warning] attempted to redefine #{name}\"\n end\n end",
"def varbind(name, value=Null)\n if name.respond_to? :to_str\n vb = VarBind.new(oid(name), value)\n else\n vb = name.to_varbind\n vb.value = value\n end\n vb\n end",
"def name=(val)\n @name = val\n end",
"def name=(name)\n @name = name.to_sym\n end",
"def name=(name)\n @name = name.to_sym\n end",
"def name(name)\n @name = name\n end",
"def add_var(name, var)\n @var[name] = var\n end",
"def termdef(name)\n element(name, {:name => name, :class => 'object_type'}, 'a')\n end",
"def termdef(name)\n element(name, {:name => name, :class => 'object_type'}, 'a')\n end",
"def termdef(name)\n element(name, {:name => name, :class => 'object_type'}, 'a')\n end",
"def set_global(name, value)\n get_global_frame.set_variable name, value\n end",
"def set_variable(name, value)\n current = @variables[name]\n if current.respond_to? :set_variable\n current.set_variable(name, value)\n else\n @variables[name] = value.to_str rescue value.to_s rescue value\n end\n end",
"def set_value_for(scope_type, variable_name, value)\n raise_invalid_scope_type!(scope_type)\n @registry[scope_type][variable_name] = value\n end",
"def name=(p0) end",
"def name=(p0) end",
"def name=(nm)\n @name = nm\n end",
"def name=(n)\n @name = n\nend",
"def assign_variable(type, name, value)\n variable = Definition::RubyObject.new(\n :type => type,\n :name => name,\n :value => value,\n :instance_type => :instance\n )\n\n buffer_assignment_value(variable.value)\n\n add_variable(variable)\n end",
"def scope1(var)\r\n\ta = \"monkey\"\r\nend",
"def set(name, value)\n @fields[name.lexeme] = value\n end",
"def name=(val) @records.set(GRT_STRNAME, val); end",
"def const_value() @name end",
"def [](name)\n definition[name]\n end",
"def add_sym ( addr, name )\n\t@syms[addr] = name\n end",
"def specify(name, value)\n self[name] = value\n @__specified__[name] = true\n end",
"def name\n value\n end",
"def update_value_of_variable(var_name, new_value)\n self.instance_variable_set(\"@#{var_name}\".to_sym, new_value)\n end",
"def v(name, bind)\n if name.nil?\n atom % bind\n else\n m(name) % bind\n end\n end",
"def []= name, value\n set name, value\n end"
] |
[
"0.7030192",
"0.69080853",
"0.6905061",
"0.67526674",
"0.6659901",
"0.66179127",
"0.6560321",
"0.65255743",
"0.64517105",
"0.64145845",
"0.6384664",
"0.63763916",
"0.6369937",
"0.62819105",
"0.62392205",
"0.6197893",
"0.61888456",
"0.6162282",
"0.6152252",
"0.6137273",
"0.6137273",
"0.61294407",
"0.6094836",
"0.60853595",
"0.60763913",
"0.60454774",
"0.60447115",
"0.60447115",
"0.60447115",
"0.60447115",
"0.60447115",
"0.60447115",
"0.60447115",
"0.60447115",
"0.6030956",
"0.60015833",
"0.5993952",
"0.5993679",
"0.59900576",
"0.5960724",
"0.59324765",
"0.5928336",
"0.5924128",
"0.5908635",
"0.5908264",
"0.5880983",
"0.5866527",
"0.58575064",
"0.58507305",
"0.58507305",
"0.58507305",
"0.58507305",
"0.58477473",
"0.5824436",
"0.58194953",
"0.58180565",
"0.58180565",
"0.58180565",
"0.58150214",
"0.58090883",
"0.5808768",
"0.5803451",
"0.5794034",
"0.57940227",
"0.5790863",
"0.5790863",
"0.5777889",
"0.57777125",
"0.57777125",
"0.5770871",
"0.5767289",
"0.5755819",
"0.5751256",
"0.57467324",
"0.5740314",
"0.5740314",
"0.57377076",
"0.5725313",
"0.57249385",
"0.57249385",
"0.57249385",
"0.5724278",
"0.5712172",
"0.57016987",
"0.5697029",
"0.5697029",
"0.56965286",
"0.5692348",
"0.5689762",
"0.56864053",
"0.56843877",
"0.566901",
"0.5655919",
"0.56508166",
"0.5648033",
"0.5645122",
"0.56400204",
"0.56353295",
"0.563309",
"0.5630928"
] |
0.68786436
|
3
|
=begin rdoc Define a symbol for constant 'name' with value 'value' in scope. =end
|
def define_const(name, value, namespace=nil)
define(ConstSymbol.new name, value, namespace)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def constant(name, value)\n define_method name.to_sym do\n value\n end\n end",
"def const name, value\n Symbolic.check_name name\n const = ConstExpr.new(name, value)\n meta_def name do\n const\n end\n const\n end",
"def const_def(name, value)\n if self.is_a?(Module)\n self.const_set(name, value) unless self.constants.include?(name)\n else\n ::Object.class_eval { self.const_def(name, value) unless Object.constants.include?(name) }\n end\n end",
"def const(name, value)\n @data << \"#{name}\\tequ #{value}\"\n end",
"def const_value() @name end",
"def __const_set__(name, value)\n const_scope = env.constant_scope.module\n const_scope.__send__(:__const_set__, name, value)\n end",
"def name=(value); end",
"def encode_constant(name)\n \"$\" + @global_name_generator.get(name.to_s)\n end",
"def init(name, value, define_constant = false)\n @values ||= {}\n @symbols ||= []\n\n s = name.to_sym\n\n n = s.to_s\n n_lc = n.downcase\n raise ArgumentError.new(\"Key #{s} is not lower case\") if n != n_lc\n raise ArgumentError.new(\"Key #{s} already defined\") if @values.key? name\n\n val = value.to_i\n if @values.key? val\n # This is a new alias for an existing value\n enum_val = @values[val]\n enum_val.instance_eval { @aliases << s }\n else\n enum_val = new(s, val)\n @values[val] = enum_val\n end\n\n @values[s] = enum_val\n @symbols << s\n\n const_set s.to_s.upcase, enum_val if define_constant\n\n enum_val\n end",
"def name= value\r\n @name = value.to_sym\r\n end",
"def name(val); @name = val.to_sym; end",
"def [](name)\n @@constants[name]\n end",
"def [](name)\n @@constants[name]\n end",
"def [](name)\n @@constants[name]\n end",
"def print_constant(*) end",
"def define(name, value)\n\t\t\t@table[name] = value\n\t\tend",
"def constant; end",
"def name\n underscore const_name\n end",
"def add_constant constant\n return constant unless @document_self\n\n # HACK: avoid duplicate 'PI' & 'E' in math.c (1.8.7 source code)\n # (this is a #ifdef: should be handled by the C parser)\n known = @constants_hash[constant.name]\n\n if known then\n known.comment = constant.comment if known.comment.empty?\n\n known.value = constant.value if\n known.value.nil? or known.value.strip.empty?\n\n known.is_alias_for ||= constant.is_alias_for\n else\n @constants_hash[constant.name] = constant\n add_to @constants, constant\n end\n\n constant\n end",
"def constant_decls; end",
"def define_func(name, value, namespace=nil)\n define(CodeSymbol.new name, value, namespace)\n end",
"def constant(const_name)\n return @consts[const_name.to_sym] if constant?(const_name)\n\n constant = VirtualConstant.new(const_name)\n\n self << Configuration::Constant.new(constant)\n\n @consts[const_name.to_sym] = constant\n end",
"def constants() end",
"def const_value() Undef end",
"def add_constant constant\n @display.print_constant constant\n end",
"def constantize(name)\n Reference.get(name)\n end",
"def constantize(name)\n Reference.get(name)\n end",
"def get_constant(name, value=nil)\n name = \"#{prefix}#{name}\"\n param = get_impl(name)\n if param\n if value\n unless param.is_a? Constant\n raise ArgumentError,\n \"Parameter '#{name}' already exists but it is not a constant.\"\n end\n value = value.to_narray if value.is_a? NDArray\n if param.shape != value.shape || param.value.to_narray != value\n raise ArgumentError,\n \"Constant '#{name}' already exists but it its value \" +\n \"doesn't match new value.\"\n end\n end\n else\n unless value\n raise ArgumentError,\n \"No constant named '#{name}'. Please specify value \" +\n \"if you want to create a new constant.\"\n end\n param = Constant.new(name, value)\n self[name] = param\n end\n param\n end",
"def literal(value)\n end",
"def add_constant_definition(key, value)\n constant_definitions[key] = value\n end",
"def name=(value)\n @name = value.to_sym\n end",
"def constant\n CONSTANT \n end",
"def []=(name, value)\n @symbols[to_name(name)] = value\n value.name = name if Function === value\n value\n end",
"def []=(name, value)\n add(name.to_sym, value)\n end",
"def constant?(name)\n @consts.key?(name.to_sym)\n end",
"def my_name(value)\n name = value\nend",
"def __const_set__(name, value)\n const_scope = MethodContext.current.sender.receiver\n const_scope.__send__(:__const_set__, name, value)\n end",
"def handle_constants(type, var_name, const_name, definition)\n class_name = @known_classes[var_name]\n\n return unless class_name\n\n class_obj = find_class var_name, class_name\n\n unless class_obj then\n @options.warn 'Enclosing class or module %p is not known' % [const_name]\n return\n end\n\n comment = find_const_comment type, const_name, class_name\n comment.normalize\n\n # In the case of rb_define_const, the definition and comment are in\n # \"/* definition: comment */\" form. The literal ':' and '\\' characters\n # can be escaped with a backslash.\n if type.downcase == 'const' then\n no_match, new_definition, new_comment = comment.text.split(/(\\A.*):/)\n\n if no_match and no_match.empty? then\n if new_definition.empty? then # Default to literal C definition\n new_definition = definition\n else\n new_definition = new_definition.gsub(\"\\:\", \":\")\n new_definition = new_definition.gsub(\"\\\\\", '\\\\')\n end\n\n new_definition.sub!(/\\A(\\s+)/, '')\n\n new_comment = \"#{$1}#{new_comment.lstrip}\"\n\n new_comment = self.new_comment(new_comment, @top_level, :c)\n\n con = RDoc::Constant.new const_name, new_definition, new_comment\n else\n con = RDoc::Constant.new const_name, definition, comment\n end\n else\n con = RDoc::Constant.new const_name, definition, comment\n end\n\n con.record_location @top_level\n @stats.add_constant con\n class_obj.add_constant con\n end",
"def define_var(name, value, namespace=nil)\n define(DataSymbol.new name, value, namespace)\n end",
"def const_val(name)\n self.class.const_get(name)\n end",
"def lex_macro name, value\n macros << [name, value]\n end",
"def name(value)\n lang_eval { @name = value }\n nil\n end",
"def set_const\n <<-CODE\n next_literal;\n t1 = stack_pop();\n t2 = staticscope_get_module(cpu_current_scope(state, c));\n stack_push(cpu_const_set(state, c, _lit, t1, t2));\n CODE\n end",
"def constantize(camel_cased_word)\n unless /\\A(?:::)?([A-Z]\\w*(?:::[A-Z]\\w*)*)\\z/ =~ camel_cased_word\n raise NameError, \"#{camel_cased_word.inspect} is not a valid constant name!\"\n end\n\n Object.module_eval(\"::#{$1}\", __FILE__, __LINE__)\nend",
"def sym(name)\n #This is a stub, used for indexing\n end",
"def shareable_constant_value; end",
"def shareable_constant_value; end",
"def initialize(name, value, symbol = nil) \n @name = name.to_s\n @value = value.to_i\n @symbol = symbol ? symbol.to_s : @value.to_s\n end",
"def const_accessor(sym, value, remove=false, freeze=true)\n value.deepfreeze if freeze\n sym = sym.to_s\n down, up = sym.downcase, sym.upcase\n sym = up.to_sym\n remove_const sym if remove and const_defined? sym\n const_set sym, value\n class_eval \"def #{down}; #{up}; end\\ndef self.#{down}; #{up}; end\"\n end",
"def define(name)\n if t = defs[name.text.to_sym]\n raise name, \"Already #{t.reserved ? 'reserved' : 'defined'}\" \n end\n \n # TODO: the goal here is to create a \"binding token\" module,\n # (Crockford calls it a \"variable token\") *and* to augment\n # the existing token with the variable token stuff. We're\n # doing the former in store, but not the latter.\n store(name, false)\n end",
"def map_ruby_const(*names)\n names.each do |name|\n self.prefix \"static VALUE #{name};\"\n self.add_to_init \" #{name} = rb_const_get(c, rb_intern(#{name.to_s.inspect}));\"\n end\n end",
"def []=(name, value)\n set_namevalue_glob(name,value, :color => 42) # 42 - aqua-marin, 7-green\n end",
"def initialize(name, value)\n @name = name.capitalize\n @value = value\n end",
"def set_global!(type, name, new_value)\n addr = handler.sym(name)\n raise(Fiddle::DLError, \"cannot find symbol #{name}\") unless addr\n s = struct([\"#{type} value\"])\n tmp = s.new(addr)\n tmp.value = new_value\n tmp.value\n end",
"def make_const(prop, data, name)\n if name.empty?\n puts \"\\n/* '#{prop}' */\"\n else\n puts \"\\n/* '#{prop}': #{name} */\"\n end\n if origprop = $const_cache.key(data)\n puts \"#define CR_#{prop} CR_#{origprop}\"\n else\n $const_cache[prop] = data\n pairs = pair_codepoints(data)\n puts \"static const OnigCodePoint CR_#{prop}[] = {\"\n # The first element of the constant is the number of pairs of codepoints\n puts \"\\t#{pairs.size},\"\n pairs.each do |pair|\n pair.map! { |c| c == 0 ? '0x0000' : sprintf(\"%0#6x\", c) }\n puts \"\\t#{pair.first}, #{pair.last},\"\n end\n puts \"}; /* CR_#{prop} */\"\n end\nend",
"def initialize(name, value)\n @name = name\n @value = value\n end",
"def name=(value)\n @name = value ? value.to_s.freeze : nil\n end",
"def []=(name, value)\n ::Kernel.raise TypeError, \"name #{name} must convert to_sym\" unless name and name.respond_to?(:to_sym)\n @locals[name.to_sym] = value\n end",
"def constantize(name, base_object=Monitors)\n begin\n const = base_object.constants.find{|cnst| cnst == name.camelcase }\n base_object.module_eval const\n rescue Exception => e\n puts \"#{name.camelcase} is not defined. #{e}\"\n nil\n end\n end",
"def define( name, value = nil, false_value = nil )\n if @names.member?(name) or (!@allow_override and resolve(name)) then\n return false_value\n else\n value = yield() if block_given? \n @names[name] = value\n return value\n end\n end",
"def initialize(name, value)\n @name = name\n @value = value\n end",
"def def_symbol(name, address, memory_type = nil)\n @symbol_set.def_symbol name, address, memory_type\n end",
"def initialize(name, value)\n @name = name\n @value = value\n end",
"def []=( name, value )\n\t\t\t@locals[ name.to_sym ] = value\n\t\tend",
"def generate_argument_code\n 'const ' + @type.to_s + '& ' + code_name\n end",
"def constant_definition\n return nil unless value\n\n case value.type\n when :block\n call = value.call\n call if call.type == :send\n when :send\n value\n end\n end",
"def initialize(name,value)\n @name = name\n @value = value\n end",
"def constant_defined?(name); end",
"def add(name, value = nil)\n symbols << [name.to_s, (Integer(value) if value)]\n end",
"def initialize(name, value)\n self.value = value\n self.name = name\n end",
"def initialize(name, value, comment)\n super()\n\n @name = name\n @value = value\n\n @is_alias_for = nil\n @visibility = :public\n\n self.comment = comment\n end",
"def constants\n @context.constants.sort{|a,b| a.name<=>b.name}.collect{|c| {:name=>c.name, :value=>c.value, :description=>markup(c.comment, true)}}\n end",
"def symbol\n :R\n end",
"def populate_using_const\n const_group_name = self.class.display_name\n group_name_alias = self.class.constants\n prop = self.class.map_constants_to\n val = self.send(prop) unless prop.nil?\n val ||= @status[1] # default property to use for constants\n group = ConstantGroup[group_name_alias] || ConstantGroup[const_group_name]\n unless group.nil?\n const = group.find_by_value(val)\n unless const.nil?\n @const = const\n @name = @const.nil? ? const.key : @const.key\n @verbose_name = \"#{self.class.display_name}: #{@name}\" \n end\n end \n end",
"def constant_value\n unless is_constant\n return :none\n end\n case type\n when :@CHAR\n char_part = self[1][1..-1]\n if char_part.size == 1\n char_part\n else\n eval(%Q{\"#{char_part}\"})\n end\n when :@tstring_content\n str = self[1]\n pos = self.parent.parent.source_begin\n first_two = lines[pos[0]-1][pos[1],2]\n if first_two[0,1] == '\"' || first_two == '%Q'\n eval(%Q{\"#{str}\"})\n else \n str\n end\n when :string_content\n children.map(&:constant_value).join\n when :string_literal, :symbol_literal\n self[1].constant_value\n when :@int\n Integer(self[1])\n when :@float\n Float(self[1])\n when :@regexp_end\n str = self[1]\n result = 0\n result |= Regexp::IGNORECASE if str.include?('i')\n result |= Regexp::MULTILINE if str.include?('m')\n result |= Regexp::EXTENDED if str.include?('x')\n result\n when :regexp_literal\n parts, options = children\n Regexp.new(parts.map(&:constant_value).join, options.constant_value)\n when :assoc_new\n children.map(&:constant_value)\n when :assoclist_from_args, :bare_assoc_hash\n parts = self[1]\n Hash[*parts.map(&:constant_value).flatten]\n when :hash\n part = self[1]\n part.nil? ? {} : part.constant_value\n when :symbol\n self[1][1].to_sym\n when :dyna_symbol\n parts = self[1]\n parts.map(&:constant_value).join.to_sym\n when :@label\n self[1][0..-2].to_sym\n when :array\n parts = self[1]\n parts.nil? ? [] : parts.map(&:constant_value)\n when :var_ref, :const_path_ref, :const_ref, :var_field\n case self[1].type\n when :@kw\n case self[1][1]\n when 'self' then scope.self_ptr\n when 'nil' then nil\n when 'true' then true\n when 'false' then false\n when '__LINE__' then self[1][2][0]\n when '__FILE__' then @file_name\n end\n else\n scope.lookup(expanded_identifier).value\n end\n when :dot2\n lhs, rhs = children\n (lhs.constant_value)..(rhs.constant_value)\n when :dot3\n lhs, rhs = children\n (lhs.constant_value)...(rhs.constant_value)\n when :paren\n self[1].last.constant_value\n end\n end",
"def name(value)\n @ole.Name = value\n nil\n end",
"def name(value)\n @ole.Name = value\n nil\n end",
"def name(value)\n @ole.Name = value\n nil\n end",
"def name(value)\n @ole.Name = value\n nil\n end",
"def name(value)\n attributes[:name] = value\n end",
"def constantize(camel_cased_word)\n unless /\\A(?:::)?([A-Z]\\w*(?:::[A-Z]\\w*)*)\\z/ =~ camel_cased_word\n raise NameError, \"#{camel_cased_word.inspect} is not a valid constant name!\"\n end\n Object.module_eval(\"::#{$1}\", __FILE__, __LINE__)\n end",
"def to_constant_name(desc) #:nodoc:\n case desc\n when String then desc.sub(/^::/, \"\")\n when Symbol then desc.to_s\n when Module\n real_mod_name(desc) ||\n raise(ArgumentError, \"Anonymous modules have no name to be referenced by\")\n else raise TypeError, \"Not a valid constant descriptor: #{desc.inspect}\"\n end\n end",
"def define(name)\n current << name\n end",
"def symbol\n :R\n end",
"def name=(_); end",
"def name=(_); end",
"def name=(_); end",
"def name=(_); end",
"def name=(_); end",
"def name=(_); end",
"def name=(_); end",
"def name=(_); end",
"def to_const_name(name)\nconst_name = name.to_s.gsub(/[^a-z0-9_]/i,'_').squeeze('_').upcase\n if const_name =~ /^[^a-z]/i\n const_name = \"T_\"+const_name\n end\n const_name.to_sym\n end",
"def name\n value\n end",
"def index(value)\n constants.find { |const_name| const_get(const_name) == value } || :__undef__\n end",
"def RB_SPECIAL_CONST_P loc\n is_immediate = push_label\n\n __ = @fisk\n reg = @fisk.rax\n @fisk.mov(reg, loc)\n @fisk.test(reg, __.uimm(RUBY_IMMEDIATE_MASK))\n @fisk.jnz(is_immediate)\n @fisk.test(reg, __.imm(~Qnil))\n @fisk.jz(is_immediate)\n @fisk.mov(reg, __.uimm(0))\n @fisk.put_label(is_immediate.name)\n\n pop_label\n\n reg\n end",
"def name2const(name)\n name.to_s.capitalize.sub(/_(.)/) { |i| $1.upcase }\n end",
"def name= (nm)\n _c_set_name(Slaw._ensure_utf8(nm))\n end",
"def define_const\n namespace.const_set(const_name, klass)\n end",
"def symbol\n Util.from_bytes :symbol, value\n end"
] |
[
"0.794613",
"0.7674613",
"0.7243851",
"0.714517",
"0.7026722",
"0.6406562",
"0.62903064",
"0.6281845",
"0.61799705",
"0.6155422",
"0.61250526",
"0.61172664",
"0.61172664",
"0.61172664",
"0.6110459",
"0.60716426",
"0.60417986",
"0.6027615",
"0.60266054",
"0.60147935",
"0.5999109",
"0.5972517",
"0.5966286",
"0.5966082",
"0.5935873",
"0.59149957",
"0.59149957",
"0.58965844",
"0.58855647",
"0.5849383",
"0.58416027",
"0.582338",
"0.58031684",
"0.57989496",
"0.57856476",
"0.576955",
"0.5757775",
"0.57481927",
"0.573305",
"0.57315063",
"0.57123834",
"0.5704279",
"0.5703963",
"0.5678311",
"0.5675295",
"0.5669382",
"0.5669382",
"0.5667583",
"0.56222963",
"0.56215924",
"0.56169647",
"0.561574",
"0.5607058",
"0.5587885",
"0.5582377",
"0.5581592",
"0.557558",
"0.55621874",
"0.55562794",
"0.5551147",
"0.555056",
"0.5548486",
"0.5547557",
"0.55440617",
"0.55427426",
"0.55266356",
"0.55224687",
"0.55173",
"0.55099285",
"0.55085295",
"0.5504212",
"0.5502034",
"0.5490165",
"0.54876167",
"0.5486995",
"0.5458132",
"0.5458132",
"0.5458132",
"0.5458132",
"0.54550713",
"0.5452463",
"0.543718",
"0.5433222",
"0.54250526",
"0.54221576",
"0.54221576",
"0.54221576",
"0.54221576",
"0.54221576",
"0.54221576",
"0.54221576",
"0.54221576",
"0.5419721",
"0.5419477",
"0.54126996",
"0.5400378",
"0.5397372",
"0.5387169",
"0.5386573",
"0.5384158"
] |
0.7556565
|
2
|
=begin rdoc Define a Symbol in scope by passing in a Symbol object. =end
|
def define(sym)
raise NameConflict if @symtab.include? sym.name
#FIXME: handle namespace better
@symtab[sym.fullname] = sym
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def def_symbol(name, address, memory_type = nil)\n @symbol_set.def_symbol name, address, memory_type\n end",
"def sym(name)\n SymEngine::Symbol.new(name)\nend",
"def use(sym); end",
"def symbol\n @symbol\n end",
"def symbol; end",
"def symbol; end",
"def symbol; end",
"def symbol; end",
"def symbol; end",
"def symbol; end",
"def sym(name)\n #This is a stub, used for indexing\n end",
"def initialize(name, symbol)\n @name = name\n @symbol = symbol\n end",
"def initialize(sym)\n @sym = sym\n end",
"def sym\n @sym\n end",
"def symbol(key, opts={})\n @attrs[key.to_sym] = Attributes::SymbolAttr.new(key, opts)\n end",
"def symbol\n :R\n end",
"def add_sym ( addr, name )\n\t@syms[addr] = name\n end",
"def register_symbol symbol\n @@registeredkeys[symbol] = self\n end",
"def symbol\n :R\n end",
"def initialize symbol, *args, &block\n @symbol = symbol.to_sym\n @args = args\n @block = block\n end",
"def initialize(symbol)\n @symbol = symbol # the printable representation of variable\n end",
"def initialize(name, symbol)\n\t\t@name = name\n\t\t@symbol = symbol\n\tend",
"def initialize(symbol)\n @symbol = symbol\n super()\n end",
"def symbol\n \n end",
"def initialize(name, symbol)\n\t\t@name = name \n\t\t@symbol = symbol\n\tend",
"def createRegister symbol\n s(:send, nil, :register,\n s(:sym, symbol),\n s(:lvar, symbol)\n )\n end",
"def createRegister symbol\n s(:send, nil, :register,\n s(:sym, symbol),\n s(:lvar, symbol)\n )\n end",
"def rb2scm_symbol(sym)\n ScmSymbol.register(sym)\n end",
"def k_symbol(aSymbol)\n Atomic::KSymbol.new(aSymbol)\n end",
"def symbol! sym\n initialize\n s0 = new_state\n s1 = new_state\n set_start(s0)\n set_final(s1, true)\n add_transition(s0, s1, sym)\n end",
"def symbol! sym\n initialize\n s0 = new_state\n s1 = new_state\n set_start(s0)\n set_final(s1, true)\n add_transition(s0, s1, sym)\n end",
"def add_spec sym, spec \n SPECS[sym] = spec\n end",
"def add_spec sym, spec \n SPECS[sym] = spec\n end",
"def on_symbol(node)\n node = node[0] if node.is_a?(Array)\n\n return Node.new(:symbol, node.children, metadata(node))\n end",
"def expanding_symbol(type = nil)\n return @expanding_symbol if type.nil?\n raise ConfigurationError.new('expanding_symbol Must be a SYMBOL') unless type.kind_of? Symbol\n @expanding_symbol = type\n end",
"def literal_symbol_set(sym, lit)\n Sequel.synchronize{@symbol_literal_cache[sym] = lit}\n end",
"def synonym(new_symbol, existing_symbol)\n element = self[existing_symbol]\n @unordered_elements[conform_to_symbol(new_symbol)] = element\n end",
"def literal_symbol(sym)\n Sequel.synchronize{@symbol_literal_cache[sym]}\n end",
"def symbol(*args, &block)\n args = [{ :using => Option, :kind => Symbol }, *args]\n da = option(*args, &block)\n da.instance_eval do\n from String do |s|\n s.to_sym\n end\n end\n end",
"def symbol\n :Y\n end",
"def symbol\n Util.from_bytes :symbol, value\n end",
"def symfun name\n Symbolic.check_name name\n fs = SymbolicFunction.new(name)\n meta_def name do\n fs\n end\n fs\n end",
"def symbol! sym\n initialize\n s0 = new_state\n s1 = new_state\n set_start(s0)\n set_final(s1, true)\n add_transition(s0, s1, sym)\n if (sym != \"\") && (!@alphabet.include? sym)\n @alphabet.push sym\n end\n end",
"def register_alias(string, symbol, extension_synonyms = T.unsafe(nil)); end",
"def add_address_symbol(symbol, address)\n\n\t\t@mem_hash[symbol] = address\n\n\tend",
"def symbol_ref\n @symbols += 1\n end",
"def symbol(string)\n Types::Symbol.cast(string)\n end",
"def start_symbol\n @start_symbol\n end",
"def replace_symbol(sym, new_sym)\n\t\t\tsyo = get_symbol(sym)\n\t\t\tsyn = get_symbol(new_sym)\n\n\t\t\t@rules.each do |r|\n\t\t\t\tr.equation.replace_ident(sym, new_sym)\n\t\t\tend\n\n\t\t\tif @parameters[sym]\n\t\t\t\t@parameters.delete(sym)\n\t\t\telse\n\t\t\t\t@species.delete(sym)\n\t\t\tend\n\n\t\t\tself.validate\n\n\t\t\tsyo\n\t\tend",
"def initialize(name,arity)\n # the printable ruby representation of this Curry symbol\n @name = name\n @arity = arity\n end",
"def []=(name, value)\n @symbols[to_name(name)] = value\n value.name = name if Function === value\n value\n end",
"def gen_symbols\n @symbols = true\n end",
"def method_symbol; end",
"def from_symbol(sym)\n self.binders.each do |binder|\n if bound_object = binder.call(sym)\n p \"handling symbol #{sym.inspect} as bound match #{bound_object.to_s}\" if self.class.debug\n return bound_object\n end\n end\n p \"handling symbol #{sym.inspect} as itself\" if self.class.debug\n SymbolEntity.new(sym)\n end",
"def scope=(_); end",
"def sym\n @name.to_sym\n end",
"def mark_symbol(pos)\n @move[pos] = @symbol\n end",
"def attr(symbol, writable=false) end",
"def initialize(symbol, options, &block)\n @symbol, @options, @block = symbol,options,block\n end",
"def define_singleton_method(symbol, method)\n # TODO\n end",
"def user_symbol=(new_value)\n @user_symbol = new_value unless const_defined?(:UserSymbol)\n end",
"def is_symbol\n <<-CODE\n t1 = stack_pop();\n stack_push(SYMBOL_P(t1) ? Qtrue : Qfalse);\n CODE\n end",
"def initialize symbol, options={}\r\n @symbol = symbol\r\n @options = options\r\n @values = {}\r\n end",
"def initialize(symbol,arguments)\n @symbol = symbol\n @arguments = arguments\n end",
"def symbol_for_label(name, instruction=nil)\n if (instruction)\n context = @inst_label_context[instruction]\n m = /^(\\/*)(.+)/.match(name)\n breadcrumb = context[0,m[1].length]\n breadcrumb << m[2]\n qual_name = breadcrumb.join('/')\n else\n qual_name = name\n end\n \n if (not @symbols[qual_name])\n @symbols[name] = {:label => AS::LabelObject.new, :linkage => ELF::STB_LOCAL, :name => qual_name}\n end\n @symbols[qual_name]\n end",
"def methods_accepting_symbol; end",
"def symbols; end",
"def add_identifier(sym)\n raise Emittance::InvalidIdentifierError, 'Identifiers must respond to #to_sym' unless sym.respond_to?(:to_sym)\n\n lookup_strategy.register_identifier self, sym.to_sym\n end",
"def set_flag(symbol)\n @flags.add(symbol)\n end",
"def initialize(symbols:)\n @symbols = symbols\n @learned = {}\n end",
"def symbol_for_name(name)\n if symbols.has_key? name\n symbols[name]\n else\n raise \"No symbol with name #{name} found\"\n end\n end",
"def resolve_sym arg\n value = resolve_value arg\n arg = arg.to_s.sub(/^_/, '')\n if value.to_s == arg.to_s\n Partializer::Collection.new 'sym', arg\n else\n Partializer::Collection.new 'sym', arg, {arg.to_sym => value}\n end\n end",
"def to_sym\n `return $rb.Y(self);`\n end",
"def tag!(sym, *args, &block)\r\n method_missing(sym.to_sym, *args, &block)\r\n end",
"def create_symbols\n # creates all named symbols, including vector references\n @expressions.map { |a| a.create_symbols }\n puts(self.class)\n end",
"def replace_symbols_with_refs\n symbol_defs = symbols_first_pass\n symbols_second_pass symbol_defs\n end",
"def simple_assign(symbol, rexp)\n @engine.assign(symbol.to_s, rexp, nil)\n end",
"def visit_Symbol(o, parent)\n contextualize(parent)[o]\n end",
"def target_symbol=(new_value)\n @target_symbol = new_value unless const_defined?(:TargetSymbol)\n end",
"def symbol currency\n definitions[currency][:symbol]\n end",
"def symbol=(symbol)\n symbol = symbol.to_s.remove_underscores\n @symbol = Unit.use_superscript_characters? ? symbol.with_superscript_characters : symbol.without_superscript_characters\n end",
"def symbolidentifier\n\n \t\n\t\tif @usersym.upcase == \"X\" then \n\t\t @compsym = \"O\" \n \t\t else \n \t\t @compsym = \"X\"\n \t\tend \n\n\n end",
"def initialize(symbol)\n\t\t\n\t\tif symbol == \"\" || nil then\n\t\t\traise ArgumentError, \"Must enter a valid symbol\"\n\t\telse\n\t\t\t@symbol = symbol\n\t\tend\n\t\t\n\tend",
"def set_type sym, type\n @types[sym] = type\n end",
"def get(symbol)\n sym_key = [self.class, symbol]\n @@sym_map[sym_key] = new(symbol) unless @@sym_map[sym_key]\n @@sym_map[sym_key]\n end",
"def key(symbol, &block)\n keys << symbol unless @keys.include? symbol\n attr_accessor symbol\n defaults[symbol] = block if block\n end",
"def symbols() @symbols end",
"def test_that_symbols_map_correctly\r\n blk = lambda { 42 }\r\n x = @s.add_entry('fubar', :word, block: blk)\r\n z = @s.unmap(x.symbol)\r\n\r\n assert_equal('fubar', x.name)\r\n assert_equal('fubar', z.name)\r\n\r\n assert_equal(x.symbol, z.symbol)\r\n\r\n assert_equal(:word, x.type)\r\n assert_equal(:word, z.type)\r\n\r\n refute(x.immediate?)\r\n refute(z.immediate?)\r\n\r\n assert_equal(42, x.block.call)\r\n assert_equal(42, z.block.call)\r\n end",
"def initialize(sym, name: nil, type: nil, omitnil: false, default: nil)\n @name = name || sym.to_s\n @type = type\n @omitnil = omitnil\n @default = default\n end",
"def document_symbol_provider\n attributes.fetch(:documentSymbolProvider)\n end",
"def scope() binding end",
"def to_sym\n `return $opal.Y(self);`\n end",
"def make_identifiable(symbol)\n if symbol.end_with?(\"%\")\n type = symbol.chomp(\"%\")\n quote(type + new_identifier_for(type).to_s)\n else\n symbol\n end\n end",
"def symbol()\n node = factor()\n\n if @look.kind.eql?(Token::STAR) then\n match(Token::STAR)\n node = Star.new(node)\n elsif @look.kind.eql?(Token::QUESTION) then\n match(Token::QUESTION)\n node = Question.new(node)\n end\n\n return node\n end",
"def get_symbol\n token = @tokens.next\n\n case token\n when :symbol then\n [:symbol, *parse_symbol]\n when :symbol_link then\n [:symbol_link, @tokens.next]\n else\n raise ArgumentError, \"expected SYMBOL or SYMLINK, got #{token.inspect}\"\n end\n end",
"def add_symbols(*symbols)\n @interface.add_symbols(*symbols)\n end",
"def embedding(resource_sym)\n self.class.embedding(resource_sym)\n end",
"def define(instruction)\n @def_instr = instruction\n end",
"def view(view, symbol)\n registered_views[String(view)] = { symbol: String(symbol).to_sym }\n self\n end",
"def sym(position)\n return position if position.is_a? Symbol\n position.gsub(/\\s/, '_').to_sym\n end"
] |
[
"0.73402077",
"0.69780415",
"0.69452524",
"0.69317997",
"0.6848561",
"0.6848561",
"0.6848561",
"0.6848561",
"0.6848561",
"0.6848561",
"0.6681812",
"0.6610387",
"0.6557366",
"0.65378004",
"0.65213215",
"0.64922225",
"0.6477699",
"0.6470518",
"0.64517653",
"0.6363021",
"0.6342199",
"0.63400644",
"0.63102055",
"0.630926",
"0.628042",
"0.62486655",
"0.62486655",
"0.62350297",
"0.62218815",
"0.6218696",
"0.6218696",
"0.6187015",
"0.6187015",
"0.61641896",
"0.61107373",
"0.61087793",
"0.60997206",
"0.60888904",
"0.6072701",
"0.59516686",
"0.5892812",
"0.5876632",
"0.58583623",
"0.5844007",
"0.5826801",
"0.5807585",
"0.58067286",
"0.579485",
"0.5790912",
"0.5757933",
"0.5728126",
"0.5725748",
"0.5720453",
"0.57112074",
"0.5707792",
"0.56997854",
"0.56957525",
"0.56729174",
"0.56726104",
"0.56697124",
"0.56634665",
"0.5660073",
"0.56372106",
"0.56353855",
"0.5630001",
"0.5628761",
"0.56122154",
"0.56032914",
"0.55891746",
"0.55873144",
"0.5583086",
"0.5571396",
"0.55679417",
"0.5563809",
"0.55409336",
"0.5540473",
"0.5531247",
"0.552734",
"0.5524024",
"0.5519107",
"0.5512821",
"0.5507736",
"0.55013967",
"0.54983777",
"0.54973465",
"0.54829",
"0.5480269",
"0.54677504",
"0.5459328",
"0.5458153",
"0.54567134",
"0.54543734",
"0.5449473",
"0.54308647",
"0.5428854",
"0.5417194",
"0.54094255",
"0.5408813",
"0.5399954",
"0.53995717"
] |
0.61977637
|
31
|
=begin rdoc Resolve name to a Symbol object. This recurses to Parentresolve if necessary. =end
|
def resolve(name)
#FIXME: how to handle namespace
@symtab[name] || (parent ? parent.resolve(name) : nil)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def resolve!(name)\n raise UnresolvedSymbol if not resolve(name) \n end",
"def resolve_symbol(resolver, sym, ctx)\n if found = find_symbol(sym.to_sym, ctx)\n resolve_lexically(resolver, found, ctx)\n found\n elsif dynamic = resolver.resolve_symbol(sym)\n dynamic\n else\n fail(\"Unknown symbol in manifest: #{sym}\")\n end\n end",
"def resolve name, text\n return @seen[name] if @seen.include? name\n\n ref = case name\n when /^\\\\(#{CLASS_REGEXP_STR})$/o then\n @context.find_symbol $1\n else\n @context.find_symbol name\n end\n\n ref = resolve_method name unless ref\n\n # Try a page name\n ref = @store.page name if not ref and name =~ /^[\\w.]+$/\n\n ref = nil if RDoc::Alias === ref # external alias, can't link to it\n\n out = if name == '\\\\' then\n name\n elsif name =~ /^\\\\/ then\n # we remove the \\ only in front of what we know:\n # other backslashes are treated later, only outside of <tt>\n ref ? $' : name\n elsif ref then\n if ref.display? then\n ref\n else\n text\n end\n else\n text\n end\n\n @seen[name] = out\n\n out\n end",
"def sym(name)\n SymEngine::Symbol.new(name)\nend",
"def visit_Symbol(o, parent)\n contextualize(parent)[o]\n end",
"def symbol_for_name(name)\n if symbols.has_key? name\n symbols[name]\n else\n raise \"No symbol with name #{name} found\"\n end\n end",
"def find_local_symbol(symbol)\n find_class_or_module_named(symbol) || super\n end",
"def lookup(aName)\n symbol_table.lookup(aName)\n end",
"def resolve_sym arg\n value = resolve_value arg\n arg = arg.to_s.sub(/^_/, '')\n if value.to_s == arg.to_s\n Partializer::Collection.new 'sym', arg\n else\n Partializer::Collection.new 'sym', arg, {arg.to_sym => value}\n end\n end",
"def sym(name)\n #This is a stub, used for indexing\n end",
"def find_local_symbol(symbol)\n find_class_or_module(symbol) || super\n end",
"def resolve_word(name)\n @vm.log(:verbose, \"resolve_word(#{name})\")\n nm = canonical(name)\n if @dict[nm].nil?\n need(nm, true)\n resolve_references do |token|\n @vm.log(:verbose, \" compiling resolved token #{token}\")\n compile_word(@dict[token])\n end\n end\n nm\n end",
"def symbol_by_name(name)\n each_symbols.find { |symbol| symbol.name == name }\n end",
"def resolution(name)\n return nil if name.nil?\n\n @resolves.find { |resolve| resolve.name == name }\n end",
"def symbol_for_label(name, instruction=nil)\n if (instruction)\n context = @inst_label_context[instruction]\n m = /^(\\/*)(.+)/.match(name)\n breadcrumb = context[0,m[1].length]\n breadcrumb << m[2]\n qual_name = breadcrumb.join('/')\n else\n qual_name = name\n end\n \n if (not @symbols[qual_name])\n @symbols[name] = {:label => AS::LabelObject.new, :linkage => ELF::STB_LOCAL, :name => qual_name}\n end\n @symbols[qual_name]\n end",
"def resolve(symbol)\n instance = @created[symbol] || construct(symbol)\n end",
"def resolve\n # puts \"Resolve with #{self} and name=#{self.name} and ref=#{self.ref.class}\"\n # First resolve the sub reference if possible.\n if self.ref.is_a?(RefName) then\n obj = self.ref.resolve\n # puts \"obj=#{obj}\"\n # Look into the object for the name.\n return obj.get_by_name(self.name)\n else\n # Look in the parent hierachy for the name.\n parent = self.parent\n # puts \"parent=#{parent}\"\n while parent\n # puts \"parent=#{parent}\"\n if parent.respond_to?(:get_by_name) then\n # puts \"get_by_name\"\n found = parent.get_by_name(self.name)\n # puts \"found\" if found\n return found if found\n end\n parent = parent.parent\n end\n # Not found.\n puts \"Not found!\"\n return nil\n end\n end",
"def resolution(name)\n return nil if name.nil?\n\n @resolves.find { |resolve| resolve.name == name }\n end",
"def resolve(param)\n return param unless param.is_a?(Symbol)\n return (@resolver || DEFAULT_RESOLVER).call(param)\n end",
"def resolve( name )\n name = name.name if name.is_a?(Name)\n \n if @pattern_defs.member?(name) then\n return @pattern_defs[name]\n elsif @rule_defs.member?(name) then\n return @rule_defs[name]\n elsif @group_defs.member?(name) then\n return @group_defs[name]\n end\n \n return nil\n end",
"def resolve_name(a)\n begin\n Resolv.getname(a)\n rescue Resolv::ResolvError\n return a\n end\nend",
"def partial_resolve(namespace, name, type = T.unsafe(nil)); end",
"def add_sym ( addr, name )\n\t@syms[addr] = name\n end",
"def resolve_symbols\n s = Symbols.new(@filtered)\n pro = s.process_labels\n @filtered = s.translate_symbols(pro)\n process\n end",
"def tick(name)\n nm = resolve_word(name)\n raise \"#{name} forward referenced\" if fwdref?(nm)\n addr = @defn[nm]\n raise \"#{name} not found\" if addr.nil?\n addr\n end",
"def sym\n @name.to_sym\n end",
"def resolve_name(name)\n name = resolve_name_without_remap(name)\n for k, v in @remappings\n if name.end_with?(k)\n if Resolver.global_name?(v)\n name = v\n else\n if name == k\n name = v\n else\n n = \"#{name[0..name.length-k.length-1]}/#{v}\"\n name = Resolver.canonicalize_name(n)\n end\n end\n break\n end\n end\n resolve_name_without_remap(name)\n end",
"def dig_ptr\n begin\n Resolv.new.getname(self.downcase)\n rescue Resolv::ResolvError\n nil\n end\n end",
"def reg_resolve!(key)\n return key unless Utils.ident?(key)\n spec = reg_resolve(key)\n\n if spec\n spec\n else\n raise \"Unable to resolve spec: #{key}\"\n end\n end",
"def find(name)\n current = self\n key = name.to_sym\n while current\n if current.defs.include?(key)\n return current.defs[key]\n end\n current = current.parent\n end\n \n # TODO: use of :name here couples us to Parser too much?\n return symbol_table.fetch(key){symbol_table[:name]}\n end",
"def find_symbol(symbol, method=nil)\n result = super(symbol)\n if not result and symbol =~ /::/\n modules = symbol.split(/::/)\n unless modules.empty?\n module_name = modules.shift\n result = find_module_named(module_name)\n if result\n last_name = \"\"\n previous = nil\n modules.each do |mod|\n previous = result\n last_name = mod\n result = result.find_module_named(mod)\n break unless result\n end\n unless result\n result = previous\n method = last_name\n end\n end\n end\n if result && method\n if !result.respond_to?(:find_local_symbol)\n p result.name\n p method\n fail\n end\n result = result.find_local_symbol(method)\n end\n end\n result\n end",
"def resolve_reference; end",
"def find_symbol(sym, ctx)\n ctx.each do |h|\n if val = resolve_in(h, sym)\n return val\n end\n end\n\n nil\n end",
"def from_symbol(sym)\n self.binders.each do |binder|\n if bound_object = binder.call(sym)\n p \"handling symbol #{sym.inspect} as bound match #{bound_object.to_s}\" if self.class.debug\n return bound_object\n end\n end\n p \"handling symbol #{sym.inspect} as itself\" if self.class.debug\n SymbolEntity.new(sym)\n end",
"def resolve\n @context.module(@name)\n end",
"def reg_resolve(key)\n return key unless Utils.ident?(key)\n\n spec = @registry_ref.value[key]\n\n if Utils.ident?(spec)\n deep_resolve(registry, spec)\n else\n spec\n end\n end",
"def resolve(namespace, name, inheritance = T.unsafe(nil), proxy_fallback = T.unsafe(nil), type = T.unsafe(nil)); end",
"def x() @x.resolve end",
"def resolve_variable(name)\n func = @current_func\n link = 0\n while func != nil\n idx = func.formal_index(name)\n if idx != -1\n return [:formal, link, idx]\n end\n idx = func.lvar_index(name)\n if idx != -1\n return [:lvar, link, idx]\n end\n func = func.outer_func\n link += 1\n end\n return nil\n end",
"def use(sym); end",
"def resolve_namespace_of(name)\n context = nil\n while true\n ns, name = GCCXMLLoader.split_first_namespace(name)\n name = \"/#{name}\"\n break if ns == '/'\n ns = ns[0..-2]\n candidates = info.name_to_nodes[ns].find_all { |n| NAMESPACE_NODE_TYPES.include?(n.name) }\n if !context\n context = candidates.to_a.first\n else\n context = candidates.find { |node| node['context'].to_s == context }\n end\n if !context\n break\n else context = context[\"id\"].to_s\n end\n end\n return name, context\n end",
"def method_missing(sym, *args)\n lookup(sym.to_sym)\n end",
"def resolved_scope(scope)\n scoper_object(scope).resolve\n end",
"def find_symbol(symbol)\n find_symbol_module(symbol) || find_local_symbol(symbol)\n end",
"def find_local_symbol(symbol)\n find_method_named(symbol) or\n find_constant_named(symbol) or\n find_attribute_named(symbol) or\n find_external_alias_named(symbol) or\n find_module_named(symbol) or\n find_file_named(symbol)\n end",
"def resolve_name(lookup_name, lookup_types=[Dnsruby::Types::A, Dnsruby::Types::CNAME, Dnsruby::Types::PTR])\n resolve_names(lookup_name,lookup_types).first\n end",
"def [](name)\n name = to_name(name)\n bound = @symbols.has_key?(name)\n \n raise UndefinedVariable.new(\n \"Variable '#{name}' is not defined\") unless bound or Scope === @parent\n \n value = bound ? @symbols[name] : @parent[name]\n value = value.force! if value.respond_to?(:force!)\n value\n end",
"def name_sym\n @name_sym ||= name.downcase.to_sym\n end",
"def sym\n @sym\n end",
"def __evaluate__(name)\n return nil unless name\n name.respond_to?(:call) ? name.call.to_sym : name.to_sym\n end",
"def define_resolution(resolve_name, &block)\n resolve = self.resolution(resolve_name)\n\n if resolve.nil?\n resolve = Facter::Util::Resolution.new(resolve_name)\n resolve.instance_eval(&block) if block\n @resolves << resolve\n else\n resolve.instance_eval(&block) if block\n end\n\n rescue => e\n Facter.warn \"Unable to add resolve #{resolve_name} for fact #{@name}: #{e}\"\n end",
"def resolve(val)\n return nil if not val\n return val if [String, Integer, Ruckus::Mutator::Mutator].kind_of_these? val\n return val if val == true\n return val if val == false\n\n o = {}\n\n if val.kind_of? Symbol\n o[:meth] = val\n elsif val.kind_of? Hash\n o = o.merge(val)\n end\n\n if (t = @from_tag) || (t = o[:from_tag])\n o[:source] = root.find_tag(t)\n raise \"can't find\" if not o[:source]\n end\n\n if (f = @from_field) || (f = o[:from_field])\n o[:source] = parent_struct.send f\n raise \"can't find field\" if not o[:source]\n end\n\n place = parent.place(self)\n\n if not o[:source]\n raise \"unparented\" if not parent\n\n o[:offset] ||= 1\n o[:offset] = 0 if o[:offset] == :this\n o[:offset] = -1 if o[:offset] == :prev\n o[:offset] = 1 if o[:offset] == :next\n\n loc = place + o[:offset]\n o[:source] = parent[loc]\n\n raise \"can't resolve #{ o } for #{ @name }\" if not o[:source]\n end\n\n if not o[:block]\n o[:meth] ||= :size\n\n if o[:source] == :rest\n r = 0\n ((place+1)..(parent.size)).each do |i|\n r += parent[i].send(o[:meth]) if parent[i]\n end\n else\n r = o[:source].send o[:meth]\n end\n else\n r = o[:block].call o[:source]\n end\n\n # cheat: if resolution returns a symbol --- which happens\n # with len/string pairs, because they depend on each other ---\n # return nil. This effectively unbounds the string during to_s.\n r = nil if r.kind_of? Symbol\n\n r = @modifier.call(self, r) if @modifier\n return r\n end",
"def def_iri sym, name=nil\n def_transform(sym) {|v| \n next nil if v == nil\n Addressable::URI.parse(v)}\n def_checker(sym) { |v|\n # v must be parseable as a URI\n !v || Addressable::URI.parse(v) rescue false\n }\n def_alias sym, name if name\n end",
"def def_iri sym, name=nil\n def_transform(sym) {|v| \n next nil if v == nil\n Addressable::URI.parse(v)}\n def_checker(sym) { |v|\n # v must be parseable as a URI\n !v || Addressable::URI.parse(v) rescue false\n }\n def_alias sym, name if name\n end",
"def look_for(symbol)\n env = self.find {|e| e.symbol.equal? symbol}\n return env unless env.nil?\n raise NameError.new(\"#{symbol} not found\", symbol)\n end",
"def to_sym\n @name&.to_sym\n end",
"def resolve\n end",
"def ext_sym(name)\r\n return name if name.kind_of?(Symbol)\r\n return ext_name(name).to_sym\r\n end",
"def eName2Exp(name)\n # puts \"eName2Exp with name=#{name}\"\n ref = $refs.find do |ref|\n if ref.ref.respond_to?(:name) then\n ref.ref.name == name.to_sym\n else\n ref.name == name.to_sym\n end\n end\n # puts \"ref=#{ref}\"\n unless ref\n return Value.new($bit8,name.to_i)\n end\n return ref\nend",
"def parent(symbol)\n self.parent_sym = symbol\n self.parent_class.initialize_child_methods(self.kind_sym)\n end",
"def find_local_symbol(symbol)\n find_method_named(symbol) or\n find_constant_named(symbol) or\n find_attribute_named(symbol) or\n find_module_named(symbol) or\n find_file_named(symbol)\n end",
"def symbol\n @symbol\n end",
"def resolve!\n rule = grammar.super_rule(rule_name)\n raise RuntimeError, 'No rule named \"%s\" in hierarchy of grammar %s' %\n [rule_name, grammar.name] unless rule\n rule\n end",
"def resolve_method( m_name )\n raise \"resolve_method #{m_name}.#{m_name.class}\" unless m_name.is_a?(Symbol)\n method = get_instance_method(m_name)\n return method if method\n if( s_class = super_class )\n method = s_class.resolve_method(m_name)\n end\n method\n end",
"def find_symbol(symbol, method = nil)\n result = nil\n\n case symbol\n when /^::(.*)/ then\n result = top_level.find_symbol($1)\n when /::/ then\n modules = symbol.split(/::/)\n\n unless modules.empty? then\n module_name = modules.shift\n result = find_module_named(module_name)\n\n if result then\n modules.each do |name|\n result = result.find_module_named name\n break unless result\n end\n end\n end\n\n else\n # if a method is specified, then we're definitely looking for\n # a module, otherwise it could be any symbol\n if method then\n result = find_module_named symbol\n else\n result = find_local_symbol symbol\n if result.nil? then\n if symbol =~ /^[A-Z]/ then\n result = parent\n while result && result.name != symbol do\n result = result.parent\n end\n end\n end\n end\n end\n\n if result and method then\n fail unless result.respond_to? :find_local_symbol\n result = result.find_local_symbol(method)\n end\n\n result\n end",
"def resolve\n api_call(\"resolve\")\n self\n end",
"def get_symbol(sym)\n\t\t\tif @parameters.key?(sym)\n\t\t\t\treturn @parameters[sym]\n\t\t\telsif @species[sym]\n\t\t\t\treturn @species[sym]\n\t\t\telse\n\t\t\t\traise \"Symbol #{sym} not found in model\"\n\t\t\tend\n\t\tend",
"def replace_symbols_with_refs\n symbol_defs = symbols_first_pass\n symbols_second_pass symbol_defs\n end",
"def tree_lookup(name)\n @pairs[name]\n end",
"def visit_ResolveNode(o)\n if is_builtin_method?(o.value)\n return super\n end\n\n new_val = rename_var(o.value, :generate => false)\n\n if new_val\n o.value = JSObfu::Utils::random_var_encoding(new_val)\n super\n else\n if @memory_sensitive || o.value.to_s == global.to_s || @preserved_identifiers.include?(o.value.to_s)\n # if the ref is the global object, don't obfuscate it on itself. This helps\n # \"shimmed\" globals (like `window=this` at the top of the script) work reliably.\n super\n else\n # A global is used, at least obfuscate the lookup\n \"#{global}[#{JSObfu::Utils::transform_string(o.value, scope, :quotes => false)}]\"\n end\n end\n end",
"def lookup(name)\n begin\n eval(sanitize(name));\n rescue NameError\n return nil\n end\n end",
"def resolve_method( m_name )\n raise \"resolve_method #{m_name}.#{m_name.class}\" unless m_name.is_a?(Symbol)\n method = get_instance_method(m_name)\n return method if method\n if( super_class_name && super_class_name != :Object )\n method = self.super_class.resolve_method(m_name)\n end\n method\n end",
"def resolve!\n rule = grammar.rule(rule_name)\n raise RuntimeError, 'No rule named \"%s\" in grammar %s' %\n [rule_name, grammar.name] unless rule\n rule\n end",
"def resolve_method!( m_name )\n method = get_instance_method(m_name)\n if method\n tm = @instance_type.method_names\n raise \"resolve_method #{name}.#{m_name} has #{tm}:#{method_names}\"\n end\n #puts \"resolve #{m_name}:#{super_class}:\"\n return nil unless( s_class = super_class )\n s_class.resolve_method(m_name)\n end",
"def P(namespace, name = nil)\n namespace, name = nil, namespace if name.nil?\n YARD::Registry.resolve(namespace, name, true)\nend",
"def type_name_resolver; end",
"def resolve_name(lookup_name, lookup_types=[Dnsruby::Types::AAAA, Dnsruby::Types::A, Dnsruby::Types::CNAME, Dnsruby::Types::PTR])\n resolve_names(lookup_name,lookup_types).first\n end",
"def resolve(scope)\n scope\n end",
"def symfun name\n Symbolic.check_name name\n fs = SymbolicFunction.new(name)\n meta_def name do\n fs\n end\n fs\n end",
"def sym_lookup(line)\n out = ''\n if @st.key?(line[1..-1].to_sym) # if varible is already in table, replace with value\n out = \"@#{@st[line[1..-1].to_sym]}\"\n else\n @st[line[1..-1].to_sym] = @sym_address # add variable to table with current free address\n out = \"@#{@sym_address}\" # replace with value\n @sym_address += 1 # increment address\n end\n out\n end",
"def get_cyc_symbol(name=params[:id])\n CycConcept.find_by_name(name) || CycConcept.new(:name => name)\n end",
"def base_resolve(**)\n object\n end",
"def Ref(from)\n return checkToken(Symbol)\n end",
"def get_symbol\n token = @tokens.next\n\n case token\n when :symbol then\n [:symbol, *parse_symbol]\n when :symbol_link then\n [:symbol_link, @tokens.next]\n else\n raise ArgumentError, \"expected SYMBOL or SYMLINK, got #{token.inspect}\"\n end\n end",
"def find_external_alias_named(name)\n case name\n when /\\A#/ then\n find_external_alias name[1..-1], false\n when /\\A::/ then\n find_external_alias name[2..-1], true\n else\n @external_aliases.find { |a| a.name == name }\n end\n end",
"def resolve\n self # simple Check never has references\n end",
"def lookUpLocal(name)\n if @currentPath.empty? then\n return nil unless self.keys.include? name\n return self[name]\n else\n entry = get(@currentPath)\n raise RunTimeError, \"Unexisting symbol table path '#{path.to_s}'\" unless entry\n return entry.lookUpLocal(name)\n end\n end",
"def one_symbol ( who )\n\tif who =~ /^0x/\n\t addr = who.hex\n\telse\n\t addr = @call.sym_lookup_name who\n\t unless addr\n\t\tputs \"Sorry, no such symbol\"\n\t\texit\n\t end\n\tend\n\t#puts addr.hex\n\tpass1 addr\n end",
"def resolve(name)\n countries_not_in_iso.fetch(name) { name }\n end",
"def resolveSTR(command)\r\n splitString = command.split(' ')\r\n currSymbol = splitString[1]\r\n currIndex = findIndex(currSymbol)\r\n puts currIndex.to_s\r\n if(currIndex == -1)\r\n puts \"Symbol has not been declared or did not receive a symbol at all. Exiting.\"\r\n exit\r\n end\r\n @DecValues[currIndex] = @RegA\r\n temp = @DecValues[currIndex].to_s\r\n puts temp + \" has been loaded into \" + @Declarations[currIndex].to_s + \".\"\r\n end",
"def lookUpGlobal(name)\n path = findGlobalPath\n if path.empty?\n return nil unless self.keys.include? name\n return self[name]\n else\n entry = get(path)\n raise RunTimeError, \"Unexisting symbol table path '#{path.to_s}'\" unless entry\n return entry.lookUpLocal(name)\n end\n end",
"def rb2scm_symbol(sym)\n ScmSymbol.register(sym)\n end",
"def find_ancestor_local_symbol symbol\n each_ancestor do |m|\n res = m.find_local_symbol(symbol)\n return res if res\n end\n\n nil\n end",
"def target_symbol\n self.class.target_symbol\n end",
"def to_sym\n name\n end",
"def resolve!\n rule = grammar.super_rule(rule_name)\n\n unless rule\n raise Error,\n \"No rule named \\\"#{rule_name}\\\" in hierarchy of grammar #{grammar}\"\n end\n\n rule\n end",
"def resolve( op )\n # TODO\n end",
"def resolve(address)\n assert_nil(@resolved_addr)\n @resolved_addr = address\n @unresolved_refs.each do |code_array, offset|\n code_array[offset] = address\n end\n end",
"def bin_sym\n @underscored_name ||= name.split('::').last.gsub(/([a-z\\d])([A-Z])/, '\\1_\\2').downcase.to_sym\n end",
"def lookup_completion(name)\n @completions.fetch(name.to_s) { |k| @parent ? @parent.lookup_completion(k) : nil }\n end"
] |
[
"0.75862575",
"0.6875471",
"0.6781045",
"0.6502915",
"0.64977247",
"0.6454168",
"0.6378003",
"0.6367195",
"0.63647264",
"0.6291669",
"0.6250075",
"0.6243137",
"0.61793715",
"0.6076152",
"0.6032398",
"0.601106",
"0.60109335",
"0.5996333",
"0.5954126",
"0.59341013",
"0.5931122",
"0.5896058",
"0.58902156",
"0.5887951",
"0.5883539",
"0.5866353",
"0.5850616",
"0.58472764",
"0.58426124",
"0.5832654",
"0.5790212",
"0.57581943",
"0.573307",
"0.57303935",
"0.56960195",
"0.5680158",
"0.56450063",
"0.56148845",
"0.5606006",
"0.56019014",
"0.55909824",
"0.55640155",
"0.5562613",
"0.555487",
"0.55481887",
"0.5518982",
"0.55157584",
"0.55109346",
"0.5510474",
"0.54810697",
"0.54793614",
"0.547483",
"0.54673666",
"0.54673666",
"0.54639906",
"0.5463257",
"0.5455928",
"0.54525983",
"0.54151917",
"0.5412321",
"0.540494",
"0.53975135",
"0.5391506",
"0.53837264",
"0.5368458",
"0.5367567",
"0.5363659",
"0.53629434",
"0.5361295",
"0.53583986",
"0.5356761",
"0.534704",
"0.5305825",
"0.528483",
"0.5278064",
"0.5268676",
"0.5266569",
"0.5266281",
"0.5255419",
"0.5254654",
"0.5248687",
"0.5247072",
"0.5241901",
"0.523672",
"0.5234122",
"0.5226025",
"0.5224445",
"0.5220637",
"0.5220531",
"0.5220397",
"0.5204939",
"0.51998866",
"0.51958776",
"0.51891196",
"0.51881987",
"0.51786876",
"0.51708275",
"0.5170258",
"0.5166178",
"0.5164078"
] |
0.7643453
|
0
|
=begin rdoc Resolve name to a Symbol object, raising an UnresolvedSymbol error if the symbol is not defined. This recurses to Parentresolve if necessary. =end
|
def resolve!(name)
raise UnresolvedSymbol if not resolve(name)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def resolve(name)\n #FIXME: how to handle namespace\n @symtab[name] || (parent ? parent.resolve(name) : nil)\n end",
"def resolve_symbol(resolver, sym, ctx)\n if found = find_symbol(sym.to_sym, ctx)\n resolve_lexically(resolver, found, ctx)\n found\n elsif dynamic = resolver.resolve_symbol(sym)\n dynamic\n else\n fail(\"Unknown symbol in manifest: #{sym}\")\n end\n end",
"def symbol_for_name(name)\n if symbols.has_key? name\n symbols[name]\n else\n raise \"No symbol with name #{name} found\"\n end\n end",
"def find_local_symbol(symbol)\n find_class_or_module_named(symbol) || super\n end",
"def resolve name, text\n return @seen[name] if @seen.include? name\n\n ref = case name\n when /^\\\\(#{CLASS_REGEXP_STR})$/o then\n @context.find_symbol $1\n else\n @context.find_symbol name\n end\n\n ref = resolve_method name unless ref\n\n # Try a page name\n ref = @store.page name if not ref and name =~ /^[\\w.]+$/\n\n ref = nil if RDoc::Alias === ref # external alias, can't link to it\n\n out = if name == '\\\\' then\n name\n elsif name =~ /^\\\\/ then\n # we remove the \\ only in front of what we know:\n # other backslashes are treated later, only outside of <tt>\n ref ? $' : name\n elsif ref then\n if ref.display? then\n ref\n else\n text\n end\n else\n text\n end\n\n @seen[name] = out\n\n out\n end",
"def find_local_symbol(symbol)\n find_class_or_module(symbol) || super\n end",
"def resolve(param)\n return param unless param.is_a?(Symbol)\n return (@resolver || DEFAULT_RESOLVER).call(param)\n end",
"def resolution(name)\n return nil if name.nil?\n\n @resolves.find { |resolve| resolve.name == name }\n end",
"def look_for(symbol)\n env = self.find {|e| e.symbol.equal? symbol}\n return env unless env.nil?\n raise NameError.new(\"#{symbol} not found\", symbol)\n end",
"def resolve_sym arg\n value = resolve_value arg\n arg = arg.to_s.sub(/^_/, '')\n if value.to_s == arg.to_s\n Partializer::Collection.new 'sym', arg\n else\n Partializer::Collection.new 'sym', arg, {arg.to_sym => value}\n end\n end",
"def resolve_word(name)\n @vm.log(:verbose, \"resolve_word(#{name})\")\n nm = canonical(name)\n if @dict[nm].nil?\n need(nm, true)\n resolve_references do |token|\n @vm.log(:verbose, \" compiling resolved token #{token}\")\n compile_word(@dict[token])\n end\n end\n nm\n end",
"def resolve(symbol)\n instance = @created[symbol] || construct(symbol)\n end",
"def sym(name)\n SymEngine::Symbol.new(name)\nend",
"def resolution(name)\n return nil if name.nil?\n\n @resolves.find { |resolve| resolve.name == name }\n end",
"def reg_resolve!(key)\n return key unless Utils.ident?(key)\n spec = reg_resolve(key)\n\n if spec\n spec\n else\n raise \"Unable to resolve spec: #{key}\"\n end\n end",
"def resolve( name )\n name = name.name if name.is_a?(Name)\n \n if @pattern_defs.member?(name) then\n return @pattern_defs[name]\n elsif @rule_defs.member?(name) then\n return @rule_defs[name]\n elsif @group_defs.member?(name) then\n return @group_defs[name]\n end\n \n return nil\n end",
"def find_symbol(symbol, method=nil)\n result = super(symbol)\n if not result and symbol =~ /::/\n modules = symbol.split(/::/)\n unless modules.empty?\n module_name = modules.shift\n result = find_module_named(module_name)\n if result\n last_name = \"\"\n previous = nil\n modules.each do |mod|\n previous = result\n last_name = mod\n result = result.find_module_named(mod)\n break unless result\n end\n unless result\n result = previous\n method = last_name\n end\n end\n end\n if result && method\n if !result.respond_to?(:find_local_symbol)\n p result.name\n p method\n fail\n end\n result = result.find_local_symbol(method)\n end\n end\n result\n end",
"def resolve_name(a)\n begin\n Resolv.getname(a)\n rescue Resolv::ResolvError\n return a\n end\nend",
"def resolve_symbols\n s = Symbols.new(@filtered)\n pro = s.process_labels\n @filtered = s.translate_symbols(pro)\n process\n end",
"def find_symbol(symbol)\n find_symbol_module(symbol) || find_local_symbol(symbol)\n end",
"def lookup(aName)\n symbol_table.lookup(aName)\n end",
"def find_symbol(sym, ctx)\n ctx.each do |h|\n if val = resolve_in(h, sym)\n return val\n end\n end\n\n nil\n end",
"def find_local_symbol(symbol)\n find_method_named(symbol) or\n find_constant_named(symbol) or\n find_attribute_named(symbol) or\n find_external_alias_named(symbol) or\n find_module_named(symbol) or\n find_file_named(symbol)\n end",
"def tick(name)\n nm = resolve_word(name)\n raise \"#{name} forward referenced\" if fwdref?(nm)\n addr = @defn[nm]\n raise \"#{name} not found\" if addr.nil?\n addr\n end",
"def resolve!\n rule = grammar.rule(rule_name)\n raise RuntimeError, 'No rule named \"%s\" in grammar %s' %\n [rule_name, grammar.name] unless rule\n rule\n end",
"def symbol_by_name(name)\n each_symbols.find { |symbol| symbol.name == name }\n end",
"def find_symbol(symbol, method = nil)\n result = nil\n\n case symbol\n when /^::(.*)/ then\n result = top_level.find_symbol($1)\n when /::/ then\n modules = symbol.split(/::/)\n\n unless modules.empty? then\n module_name = modules.shift\n result = find_module_named(module_name)\n\n if result then\n modules.each do |name|\n result = result.find_module_named name\n break unless result\n end\n end\n end\n\n else\n # if a method is specified, then we're definitely looking for\n # a module, otherwise it could be any symbol\n if method then\n result = find_module_named symbol\n else\n result = find_local_symbol symbol\n if result.nil? then\n if symbol =~ /^[A-Z]/ then\n result = parent\n while result && result.name != symbol do\n result = result.parent\n end\n end\n end\n end\n end\n\n if result and method then\n fail unless result.respond_to? :find_local_symbol\n result = result.find_local_symbol(method)\n end\n\n result\n end",
"def resolve\n # puts \"Resolve with #{self} and name=#{self.name} and ref=#{self.ref.class}\"\n # First resolve the sub reference if possible.\n if self.ref.is_a?(RefName) then\n obj = self.ref.resolve\n # puts \"obj=#{obj}\"\n # Look into the object for the name.\n return obj.get_by_name(self.name)\n else\n # Look in the parent hierachy for the name.\n parent = self.parent\n # puts \"parent=#{parent}\"\n while parent\n # puts \"parent=#{parent}\"\n if parent.respond_to?(:get_by_name) then\n # puts \"get_by_name\"\n found = parent.get_by_name(self.name)\n # puts \"found\" if found\n return found if found\n end\n parent = parent.parent\n end\n # Not found.\n puts \"Not found!\"\n return nil\n end\n end",
"def partial_resolve(namespace, name, type = T.unsafe(nil)); end",
"def define_resolution(resolve_name, &block)\n resolve = self.resolution(resolve_name)\n\n if resolve.nil?\n resolve = Facter::Util::Resolution.new(resolve_name)\n resolve.instance_eval(&block) if block\n @resolves << resolve\n else\n resolve.instance_eval(&block) if block\n end\n\n rescue => e\n Facter.warn \"Unable to add resolve #{resolve_name} for fact #{@name}: #{e}\"\n end",
"def resolve!\n rule = grammar.super_rule(rule_name)\n raise RuntimeError, 'No rule named \"%s\" in hierarchy of grammar %s' %\n [rule_name, grammar.name] unless rule\n rule\n end",
"def find_local_symbol(symbol)\n find_method_named(symbol) or\n find_constant_named(symbol) or\n find_attribute_named(symbol) or\n find_module_named(symbol) or\n find_file_named(symbol)\n end",
"def method_missing(sym, *args)\n lookup(sym.to_sym)\n end",
"def sym(name)\n #This is a stub, used for indexing\n end",
"def x() @x.resolve end",
"def visit_Symbol(o, parent)\n contextualize(parent)[o]\n end",
"def resolve\n end",
"def resolve\n api_call(\"resolve\")\n self\n end",
"def resolve\n self # simple Check never has references\n end",
"def resolve_reference; end",
"def add_sym ( addr, name )\n\t@syms[addr] = name\n end",
"def find(name)\n current = self\n key = name.to_sym\n while current\n if current.defs.include?(key)\n return current.defs[key]\n end\n current = current.parent\n end\n \n # TODO: use of :name here couples us to Parser too much?\n return symbol_table.fetch(key){symbol_table[:name]}\n end",
"def resolve_name(name)\n name = resolve_name_without_remap(name)\n for k, v in @remappings\n if name.end_with?(k)\n if Resolver.global_name?(v)\n name = v\n else\n if name == k\n name = v\n else\n n = \"#{name[0..name.length-k.length-1]}/#{v}\"\n name = Resolver.canonicalize_name(n)\n end\n end\n break\n end\n end\n resolve_name_without_remap(name)\n end",
"def resolve!\n rule = grammar.super_rule(rule_name)\n\n unless rule\n raise Error,\n \"No rule named \\\"#{rule_name}\\\" in hierarchy of grammar #{grammar}\"\n end\n\n rule\n end",
"def resolve_variable(name)\n func = @current_func\n link = 0\n while func != nil\n idx = func.formal_index(name)\n if idx != -1\n return [:formal, link, idx]\n end\n idx = func.lvar_index(name)\n if idx != -1\n return [:lvar, link, idx]\n end\n func = func.outer_func\n link += 1\n end\n return nil\n end",
"def resolved_scope(scope)\n scoper_object(scope).resolve\n end",
"def resolve!\n rule = grammar.rule(rule_name)\n\n unless rule\n raise Error, \"No rule named \\\"#{rule_name}\\\" in grammar #{grammar}\"\n end\n\n rule\n end",
"def def_iri sym, name=nil\n def_transform(sym) {|v| \n next nil if v == nil\n Addressable::URI.parse(v)}\n def_checker(sym) { |v|\n # v must be parseable as a URI\n !v || Addressable::URI.parse(v) rescue false\n }\n def_alias sym, name if name\n end",
"def def_iri sym, name=nil\n def_transform(sym) {|v| \n next nil if v == nil\n Addressable::URI.parse(v)}\n def_checker(sym) { |v|\n # v must be parseable as a URI\n !v || Addressable::URI.parse(v) rescue false\n }\n def_alias sym, name if name\n end",
"def from_symbol(sym)\n self.binders.each do |binder|\n if bound_object = binder.call(sym)\n p \"handling symbol #{sym.inspect} as bound match #{bound_object.to_s}\" if self.class.debug\n return bound_object\n end\n end\n p \"handling symbol #{sym.inspect} as itself\" if self.class.debug\n SymbolEntity.new(sym)\n end",
"def reg_resolve(key)\n return key unless Utils.ident?(key)\n\n spec = @registry_ref.value[key]\n\n if Utils.ident?(spec)\n deep_resolve(registry, spec)\n else\n spec\n end\n end",
"def resolve_method!( m_name )\n method = get_instance_method(m_name)\n if method\n tm = @instance_type.method_names\n raise \"resolve_method #{name}.#{m_name} has #{tm}:#{method_names}\"\n end\n #puts \"resolve #{m_name}:#{super_class}:\"\n return nil unless( s_class = super_class )\n s_class.resolve_method(m_name)\n end",
"def resolve\n @context.module(@name)\n end",
"def resolve_method( m_name )\n raise \"resolve_method #{m_name}.#{m_name.class}\" unless m_name.is_a?(Symbol)\n method = get_instance_method(m_name)\n return method if method\n if( s_class = super_class )\n method = s_class.resolve_method(m_name)\n end\n method\n end",
"def resolve(namespace, name, inheritance = T.unsafe(nil), proxy_fallback = T.unsafe(nil), type = T.unsafe(nil)); end",
"def lookup(name)\n begin\n eval(sanitize(name));\n rescue NameError\n return nil\n end\n end",
"def [](name)\n name = to_name(name)\n bound = @symbols.has_key?(name)\n \n raise UndefinedVariable.new(\n \"Variable '#{name}' is not defined\") unless bound or Scope === @parent\n \n value = bound ? @symbols[name] : @parent[name]\n value = value.force! if value.respond_to?(:force!)\n value\n end",
"def symbol_for_label(name, instruction=nil)\n if (instruction)\n context = @inst_label_context[instruction]\n m = /^(\\/*)(.+)/.match(name)\n breadcrumb = context[0,m[1].length]\n breadcrumb << m[2]\n qual_name = breadcrumb.join('/')\n else\n qual_name = name\n end\n \n if (not @symbols[qual_name])\n @symbols[name] = {:label => AS::LabelObject.new, :linkage => ELF::STB_LOCAL, :name => qual_name}\n end\n @symbols[qual_name]\n end",
"def lookUpGlobal(name)\n path = findGlobalPath\n if path.empty?\n return nil unless self.keys.include? name\n return self[name]\n else\n entry = get(path)\n raise RunTimeError, \"Unexisting symbol table path '#{path.to_s}'\" unless entry\n return entry.lookUpLocal(name)\n end\n end",
"def get_symbol(sym)\n\t\t\tif @parameters.key?(sym)\n\t\t\t\treturn @parameters[sym]\n\t\t\telsif @species[sym]\n\t\t\t\treturn @species[sym]\n\t\t\telse\n\t\t\t\traise \"Symbol #{sym} not found in model\"\n\t\t\tend\n\t\tend",
"def resolve_method( m_name )\n raise \"resolve_method #{m_name}.#{m_name.class}\" unless m_name.is_a?(Symbol)\n method = get_instance_method(m_name)\n return method if method\n if( super_class_name && super_class_name != :Object )\n method = self.super_class.resolve_method(m_name)\n end\n method\n end",
"def dig_ptr\n begin\n Resolv.new.getname(self.downcase)\n rescue Resolv::ResolvError\n nil\n end\n end",
"def resolve(val)\n return nil if not val\n return val if [String, Integer, Ruckus::Mutator::Mutator].kind_of_these? val\n return val if val == true\n return val if val == false\n\n o = {}\n\n if val.kind_of? Symbol\n o[:meth] = val\n elsif val.kind_of? Hash\n o = o.merge(val)\n end\n\n if (t = @from_tag) || (t = o[:from_tag])\n o[:source] = root.find_tag(t)\n raise \"can't find\" if not o[:source]\n end\n\n if (f = @from_field) || (f = o[:from_field])\n o[:source] = parent_struct.send f\n raise \"can't find field\" if not o[:source]\n end\n\n place = parent.place(self)\n\n if not o[:source]\n raise \"unparented\" if not parent\n\n o[:offset] ||= 1\n o[:offset] = 0 if o[:offset] == :this\n o[:offset] = -1 if o[:offset] == :prev\n o[:offset] = 1 if o[:offset] == :next\n\n loc = place + o[:offset]\n o[:source] = parent[loc]\n\n raise \"can't resolve #{ o } for #{ @name }\" if not o[:source]\n end\n\n if not o[:block]\n o[:meth] ||= :size\n\n if o[:source] == :rest\n r = 0\n ((place+1)..(parent.size)).each do |i|\n r += parent[i].send(o[:meth]) if parent[i]\n end\n else\n r = o[:source].send o[:meth]\n end\n else\n r = o[:block].call o[:source]\n end\n\n # cheat: if resolution returns a symbol --- which happens\n # with len/string pairs, because they depend on each other ---\n # return nil. This effectively unbounds the string during to_s.\n r = nil if r.kind_of? Symbol\n\n r = @modifier.call(self, r) if @modifier\n return r\n end",
"def resolveSTR(command)\r\n splitString = command.split(' ')\r\n currSymbol = splitString[1]\r\n currIndex = findIndex(currSymbol)\r\n puts currIndex.to_s\r\n if(currIndex == -1)\r\n puts \"Symbol has not been declared or did not receive a symbol at all. Exiting.\"\r\n exit\r\n end\r\n @DecValues[currIndex] = @RegA\r\n temp = @DecValues[currIndex].to_s\r\n puts temp + \" has been loaded into \" + @Declarations[currIndex].to_s + \".\"\r\n end",
"def resolve( op )\n # TODO\n end",
"def resolve(name)\n countries_not_in_iso.fetch(name) { name }\n end",
"def lookUpLocal(name)\n if @currentPath.empty? then\n return nil unless self.keys.include? name\n return self[name]\n else\n entry = get(@currentPath)\n raise RunTimeError, \"Unexisting symbol table path '#{path.to_s}'\" unless entry\n return entry.lookUpLocal(name)\n end\n end",
"def resolve\n raise NotImplementedError, 'You must be implement \"resolve\" method.'\n end",
"def resolve(address)\n assert_nil(@resolved_addr)\n @resolved_addr = address\n @unresolved_refs.each do |code_array, offset|\n code_array[offset] = address\n end\n end",
"def resolve\n abstract\n end",
"def resolve(name, *args, **opts)\n block = @__storage__.fetch(name) do\n raise NotFoundError,\n \"no item with name #{name} registered\"\n end\n\n block.call(*args, **opts)\n end",
"def def_absolute_iri sym, name=nil\n def_transform(sym) {|v| \n next nil if v == nil\n Addressable::URI.parse(v)\n }\n def_checker(sym) { |v|\n # v must be an absolute IRI\n !v || is_absolute_iri?(v)\n }\n def_alias sym, name if name\n end",
"def def_absolute_iri sym, name=nil\n def_transform(sym) {|v| \n next nil if v == nil\n Addressable::URI.parse(v)\n }\n def_checker(sym) { |v|\n # v must be an absolute IRI\n !v || is_absolute_iri?(v)\n }\n def_alias sym, name if name\n end",
"def replace_symbols_with_refs\n symbol_defs = symbols_first_pass\n symbols_second_pass symbol_defs\n end",
"def resolve_name(lookup_name, lookup_types=[Dnsruby::Types::A, Dnsruby::Types::CNAME, Dnsruby::Types::PTR])\n resolve_names(lookup_name,lookup_types).first\n end",
"def resolve_namespace_of(name)\n context = nil\n while true\n ns, name = GCCXMLLoader.split_first_namespace(name)\n name = \"/#{name}\"\n break if ns == '/'\n ns = ns[0..-2]\n candidates = info.name_to_nodes[ns].find_all { |n| NAMESPACE_NODE_TYPES.include?(n.name) }\n if !context\n context = candidates.to_a.first\n else\n context = candidates.find { |node| node['context'].to_s == context }\n end\n if !context\n break\n else context = context[\"id\"].to_s\n end\n end\n return name, context\n end",
"def find_ancestor_local_symbol symbol\n each_ancestor do |m|\n res = m.find_local_symbol(symbol)\n return res if res\n end\n\n nil\n end",
"def get_symbol\n token = @tokens.next\n\n case token\n when :symbol then\n [:symbol, *parse_symbol]\n when :symbol_link then\n [:symbol_link, @tokens.next]\n else\n raise ArgumentError, \"expected SYMBOL or SYMLINK, got #{token.inspect}\"\n end\n end",
"def resolve(scope)\n scope\n end",
"def resolve(value); end",
"def add_known_symbol(s)\n @@known_symbols << s.to_sym\n @@known_symbols_by_glass[glass] ||= []\n @@known_symbols_by_glass[glass] << s.to_sym\n end",
"def find_external_alias_named(name)\n case name\n when /\\A#/ then\n find_external_alias name[1..-1], false\n when /\\A::/ then\n find_external_alias name[2..-1], true\n else\n @external_aliases.find { |a| a.name == name }\n end\n end",
"def resolve\n original_scope.none\n end",
"def known_symbol?(s)\n @@known_symbols_by_glass[glass] && @@known_symbols_by_glass[glass].member?(s)\n end",
"def replace_symbol(sym, new_sym)\n\t\t\tsyo = get_symbol(sym)\n\t\t\tsyn = get_symbol(new_sym)\n\n\t\t\t@rules.each do |r|\n\t\t\t\tr.equation.replace_ident(sym, new_sym)\n\t\t\tend\n\n\t\t\tif @parameters[sym]\n\t\t\t\t@parameters.delete(sym)\n\t\t\telse\n\t\t\t\t@species.delete(sym)\n\t\t\tend\n\n\t\t\tself.validate\n\n\t\t\tsyo\n\t\tend",
"def find_symbol_module(symbol)\n result = nil\n\n # look for a class or module 'symbol'\n case symbol\n when /^::/ then\n result = @store.find_class_or_module symbol\n when /^(\\w+):+(.+)$/\n suffix = $2\n top = $1\n searched = self\n while searched do\n mod = searched.find_module_named(top)\n break unless mod\n result = @store.find_class_or_module \"#{mod.full_name}::#{suffix}\"\n break if result || searched.is_a?(RDoc::TopLevel)\n searched = searched.parent\n end\n else\n searched = self\n while searched do\n result = searched.find_module_named(symbol)\n break if result || searched.is_a?(RDoc::TopLevel)\n searched = searched.parent\n end\n end\n\n result\n end",
"def resolve(value)\n raise NotImplementedError\n end",
"def resolve!\n raise \"resolve! must be implemented for class #{self.class}\"\n end",
"def resolve!\n dl, cl = resolve\n raise GraphException(\"Circular Dependency Detected: %s\" % cl) unless cl.nil?\n dl\n end",
"def defined?(name)\n @symbols.has_key?(to_name(name)) or\n (Scope === @parent and @parent.defined?(name))\n end",
"def use(sym); end",
"def visit_ResolveNode(o)\n if is_builtin_method?(o.value)\n return super\n end\n\n new_val = rename_var(o.value, :generate => false)\n\n if new_val\n o.value = JSObfu::Utils::random_var_encoding(new_val)\n super\n else\n if @memory_sensitive || o.value.to_s == global.to_s || @preserved_identifiers.include?(o.value.to_s)\n # if the ref is the global object, don't obfuscate it on itself. This helps\n # \"shimmed\" globals (like `window=this` at the top of the script) work reliably.\n super\n else\n # A global is used, at least obfuscate the lookup\n \"#{global}[#{JSObfu::Utils::transform_string(o.value, scope, :quotes => false)}]\"\n end\n end\n end",
"def ident_check sym\n valid, scope = @stack.search sym, true\n NamingError.log(\"Line #{sym.line_number}: No identifier '#{sym.text}' in current scope '#{@current_level}'\") if !valid\n \n scope\n end",
"def define_resolution(resolution_name, options = {}, &block)\n resolution_type = options.delete(:type) || :simple\n\n resolve = create_or_return_resolution(resolution_name, resolution_type)\n\n resolve.options(options) unless options.empty?\n resolve.evaluate(&block) if block\n\n resolve\n rescue StandardError => e\n log.log_exception(\"Unable to add resolve #{resolution_name.inspect} for fact #{@name}: #{e.message}\")\n nil\n end",
"def resolve(env)\n raise \"abstract method!\"\n end",
"def resolve(key, &block)\n config.resolver.call(_container, key, &block)\n end",
"def eval_binding(args, current_cont)\n\t\t\tname, env = args[:name], args[:env]\n\t\t\tif env.include? name.val.to_sym\n\t\t\t\treturn current_cont.next_with(ast: env[name.val.to_sym])\n\t\t\telse\n\t\t\t\tif env.parent\n\t\t\t\t\t# TODO: check if copy_with is necessary\n\t\t\t\t\treturn current_cont.with name: name, env: env.parent\n\t\t\t\telse\n\t\t\t\t\treturn current_cont.heap[:error_handler].with message: \n\t\t\t\t\t\t\"Could not resolve symbol #{name.val.inspect}\",\n\t\t\t\t\t\tast: name, backtrace: caller(0)\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def resolve_method m_name\n method = get_instance_method(m_name)\n unless method\n unless( @name == :Object)\n supr = BootSpace.space.get_or_create_class(@super_class_name)\n method = supr.resolve_method(m_name)\n end\n end\n raise \"Method not found #{m_name}, for #{@name}\" unless method\n method\n end",
"def sym_lookup(line)\n out = ''\n if @st.key?(line[1..-1].to_sym) # if varible is already in table, replace with value\n out = \"@#{@st[line[1..-1].to_sym]}\"\n else\n @st[line[1..-1].to_sym] = @sym_address # add variable to table with current free address\n out = \"@#{@sym_address}\" # replace with value\n @sym_address += 1 # increment address\n end\n out\n end",
"def resolve(parser)\n end"
] |
[
"0.7561216",
"0.7144447",
"0.6465142",
"0.6414068",
"0.6355232",
"0.6293653",
"0.6159137",
"0.6137376",
"0.6115174",
"0.60982543",
"0.60907495",
"0.60878026",
"0.60678154",
"0.6013621",
"0.60131776",
"0.6002441",
"0.5997742",
"0.59965545",
"0.5977611",
"0.59694564",
"0.5923061",
"0.58423054",
"0.58043665",
"0.57478046",
"0.5737501",
"0.57320505",
"0.5710887",
"0.5709245",
"0.5704417",
"0.566703",
"0.5666724",
"0.5658884",
"0.56403625",
"0.5631767",
"0.5630914",
"0.5620893",
"0.55782163",
"0.55755615",
"0.55567837",
"0.55331564",
"0.55199814",
"0.55177325",
"0.55173826",
"0.5485161",
"0.54818183",
"0.54754686",
"0.54689896",
"0.54637045",
"0.54637045",
"0.544006",
"0.5432758",
"0.54213256",
"0.5414266",
"0.5408371",
"0.5400798",
"0.53997254",
"0.53683597",
"0.5360871",
"0.53384143",
"0.5327679",
"0.53142124",
"0.5294867",
"0.5290461",
"0.5284542",
"0.5277078",
"0.5272263",
"0.5260293",
"0.5248604",
"0.5240492",
"0.52236646",
"0.5210782",
"0.5203305",
"0.5203305",
"0.51916564",
"0.51647305",
"0.5160596",
"0.51600003",
"0.514637",
"0.51382375",
"0.5135896",
"0.51321256",
"0.51193255",
"0.51180756",
"0.5105941",
"0.5091178",
"0.5083525",
"0.505545",
"0.5055413",
"0.5052991",
"0.50524724",
"0.50487536",
"0.50363016",
"0.50168884",
"0.5015397",
"0.5013632",
"0.5010858",
"0.49983847",
"0.4990712",
"0.4985473",
"0.49836364"
] |
0.8311625
|
0
|
Custom validator for currency
|
def validate_each(record, attribute, value)
return if value.is_a?(String) && value.length == 3 && value =~ CURRENCY_REGEX
record.errors.add(attribute, :invalid, message: 'must be a valid ISO 4217 Three-digit currency code')
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def is_currency?\n self =~ /\\A[+-]?[0-9]{1,3}(?:[0-9]*(?:[.,][0-9]{2})?|(?:,[0-9]{3})*(?:\\.[0-9]{2})?|(?:\\.[0-9]{3})*(?:,[0-9]{2})?)\\z/i\n end",
"def validate_currency_format\n raise 'Value is not in currency format' unless ValuesLib.check_currency_format(text_value_one)\n raise 'Value is not in currency format' unless ValuesLib.check_currency_format(text_value_two)\n raise 'Value is not in currency format' unless ValuesLib.check_currency_format(text_value_three)\n raise 'Value is not in currency format' unless ValuesLib.check_currency_format(text_value_four)\n raise 'Value is not in currency format' unless ValuesLib.check_currency_format(text_value_five)\n raise 'Total is not in currency format' unless ValuesLib.check_currency_format(total_values)\n end",
"def currency(input)\n\t(/\\$?[+-]?[0-9]{1,3}((\\,)?[0-9]{3})*(\\.[0-9]{2})?/i =~ input)? \"true\" : \"false\"\nend",
"def currency=(currency)\n validator = EnumAttributeValidator.new('String', [\"UNKNOWN_CURRENCY\", \"AED\", \"AFN\", \"ALL\", \"AMD\", \"ANG\", \"AOA\", \"ARS\", \"AUD\", \"AWG\", \"AZN\", \"BAM\", \"BBD\", \"BDT\", \"BGN\", \"BHD\", \"BIF\", \"BMD\", \"BND\", \"BOB\", \"BOV\", \"BRL\", \"BSD\", \"BTN\", \"BWP\", \"BYR\", \"BZD\", \"CAD\", \"CDF\", \"CHE\", \"CHF\", \"CHW\", \"CLF\", \"CLP\", \"CNY\", \"COP\", \"COU\", \"CRC\", \"CUC\", \"CUP\", \"CVE\", \"CZK\", \"DJF\", \"DKK\", \"DOP\", \"DZD\", \"EGP\", \"ERN\", \"ETB\", \"EUR\", \"FJD\", \"FKP\", \"GBP\", \"GEL\", \"GHS\", \"GIP\", \"GMD\", \"GNF\", \"GTQ\", \"GYD\", \"HKD\", \"HNL\", \"HRK\", \"HTG\", \"HUF\", \"IDR\", \"ILS\", \"INR\", \"IQD\", \"IRR\", \"ISK\", \"JMD\", \"JOD\", \"JPY\", \"KES\", \"KGS\", \"KHR\", \"KMF\", \"KPW\", \"KRW\", \"KWD\", \"KYD\", \"KZT\", \"LAK\", \"LBP\", \"LKR\", \"LRD\", \"LSL\", \"LTL\", \"LVL\", \"LYD\", \"MAD\", \"MDL\", \"MGA\", \"MKD\", \"MMK\", \"MNT\", \"MOP\", \"MRO\", \"MUR\", \"MVR\", \"MWK\", \"MXN\", \"MXV\", \"MYR\", \"MZN\", \"NAD\", \"NGN\", \"NIO\", \"NOK\", \"NPR\", \"NZD\", \"OMR\", \"PAB\", \"PEN\", \"PGK\", \"PHP\", \"PKR\", \"PLN\", \"PYG\", \"QAR\", \"RON\", \"RSD\", \"RUB\", \"RWF\", \"SAR\", \"SBD\", \"SCR\", \"SDG\", \"SEK\", \"SGD\", \"SHP\", \"SLL\", \"SOS\", \"SRD\", \"SSP\", \"STD\", \"SVC\", \"SYP\", \"SZL\", \"THB\", \"TJS\", \"TMT\", \"TND\", \"TOP\", \"TRY\", \"TTD\", \"TWD\", \"TZS\", \"UAH\", \"UGX\", \"USD\", \"USN\", \"USS\", \"UYI\", \"UYU\", \"UZS\", \"VEF\", \"VND\", \"VUV\", \"WST\", \"XAF\", \"XAG\", \"XAU\", \"XBA\", \"XBB\", \"XBC\", \"XBD\", \"XCD\", \"XDR\", \"XOF\", \"XPD\", \"XPF\", \"XPT\", \"XTS\", \"XXX\", \"YER\", \"ZAR\", \"ZMK\", \"ZMW\", \"BTC\"])\n unless validator.valid?(currency)\n fail ArgumentError, \"invalid value for 'currency', must be one of #{validator.allowable_values}.\"\n end\n @currency = currency\n end",
"def disallow_currency_conversion!; end",
"def currency_should_be_in_supported\n self.errors.add(:currency, 'exchange rate can not be found and is not supported') if self.currency.present? && !Currency.exists?(:iso_code => self.currency)\n end",
"def currency; end",
"def currency; end",
"def valid_dollar_amt?(num)\n num.to_f.positive? && (valid_int?(num) || dollar_format?(num))\nend",
"def valid_amount?\n Float(params[:amount]) rescue false\n end",
"def detect_currency value\n case value.to_s.strip\n when /\\$|USD|dollar[s]?|бакс[а-я]{0,2}|доллар[а-я]{0,2}|грин[а-я]?/i\n :USD\n when /€|EUR[a-z]{0,2}|евро/i\n :EUR\n when /₽|RUB{0,4}|руб[a-zа-я]{0,4}|деревян[a-zа-я]{0,3}/i\n :RUB\n when /CAD/i\n :CAD\n else\n :not_expected\n end\nend",
"def price_validate\n\t\tif (self.pay_mode == \"free\") || (self.pay_mode == \"FREE\") || (self.pay_mode == \"Free\")\n\t\t\tunless self.price == nil \n\t\t\t\t errors.add(:price, \"price should be nil\")\n\t\t\tend\t\n\t\telsif (self.pay_mode == \"paid\") || (self.pay_mode == \"PAID\") || (self.pay_mode == \"Paid\")\n\t\t\tunless self.price > 0 \n\t\t\t\t errors.add(:price, \"price should have a value not either nil nor 0\")\n\t\t\tend\n\t\telsif (self.pay_mode == \"donation\") || (self.pay_mode == \"DONATION\") || (self.pay_mode == \"Donation\")\n\t\t\tunless self.price == nil \n\t\t\t\t errors.add(:price, \"price should be nil\")\n\t\t\tend\t\t\t\t\t\t\t\n\t\tend\n\tend",
"def validates_price\n if price.zero?\n errors.add(:display_price, \"cannot be zero\")\n end\n\n nil\n end",
"def allow_currency_symbols(*args)\n # Obviously US-centric, I need to make it international or customizable.\n # Some international symbols '¢£¥€ƒ$,'\n add_equal_method CURRENCY_CHARS, args \n end",
"def validate #:doc:\n errors.add(:price, \"should be positive\") unless price.nil? || price >= 0.01\n end",
"def apply_validations_for_decimal\n apply_validations_for_float\n end",
"def amount_is_valid_for_outstanding_balance_or_credit\n end",
"def currency\n number_to_currency(self)\n end",
"def amount_is_valid\n errors.add(:amount, 'ticket amount is not right. Please double check') if amount < 40 || amount > 200\n end",
"def checkCurrency(string_variable)\n # returns string_variable as a float\n # else returns false and error msg if string_variable can't be a number or a valid dollar amount \n \n if checkNum?(string_variable) == false\n return false\n end\n \n # check for max 2 places past decimal point\n decimalIndex = string_variable.index('.')\n if decimalIndex != nil\n if string_variable.length - decimalIndex > 3\n puts \"\\t#{string_variable} is NOT a valid dollar amount\"\n return false\n end\n end\n \n float_variable = string_variable.to_f\n if float_variable >= 0\n return float_variable\n else\n return false\n end\n end",
"def non_digits_price?(value)\n raise \"Input Invalid. Please check the format!\" if !value.match(/\\D/).nil?\n end",
"def price_validation_before_cast\n return unless price\n errors.add(:price, 'is invalid') unless price_before_type_cast.to_s.match?(VALID_PRICE_REGEX)\n errors.add(:price, 'must be greater than 0') unless price_before_type_cast.to_f.positive?\n end",
"def currency\n raise 'Redefine this method in your billing model.'\n end",
"def currency\n raise 'Redefine this method in your billing model.'\n end",
"def currency\n 'INR'\n end",
"def currency\n money.currency\n end",
"def number_to_currency(amount)\n super(amount, unit: \"₹\")\n end",
"def check_currency_code_validity\n if available_codes.include?(currency_code)\n true\n else\n raise Exception.new(\"Unsupported currency code: #{currency_code}\")\n end\n end",
"def validate_response(value)\n if value.select { |k, v| k.in?(['dollars', 'cents']) && v.present? }\n .find { |k, v| (Float(v) rescue nil).nil? }\n .present?\n\n \"isn't a valid price.\"\n end\n end",
"def validate_discount_number\n disc = self.discount.to_f\n if disc < 0\n self.errors.add(:discount, I18n.t(\"activerecord.errors.messages.greater_than_or_equal_to\", :count => 0))\n elsif disc > 100\n self.errors.add(:discount, I18n.t(\"activerecord.errors.messages.less_than_or_equal_to\", :count => 100))\n end\n end",
"def set_Currency(value)\n set_input(\"Currency\", value)\n end",
"def set_Currency(value)\n set_input(\"Currency\", value)\n end",
"def currency_code\n @currency_code\n end",
"def currency\n params['currency']\n end",
"def currency\n \"EUR\"\n end",
"def parse_currency(currency)\n BigDecimal.new(currency.gsub(/[^0-9.-]/, ''))\n end",
"def check_for_valid_decimal(decimal_param)\n /\\d{1,2},\\d{1,2}/ === decimal_param\n end",
"def with_currency(new_currency); end",
"def currency\n\tparams['mc_currency']\n end",
"def positive_price\n errors.add(:price, \"should be positive\") unless price.nil? || price >= 0.01\n end",
"def initialize(amount=1,currency='EUR',opt={})\n Money::CrossRate.conversion_rates if Money::CrossRate.currency.nil? && Money::CrossRate.cross_rate.nil?\n begin\n @amount = Money::InputSanitizer.sanitize_amount(amount)\n @currency = Money::InputSanitizer.sanitize_currency(currency,Money::CrossRate.get_all_available_currencies) \n rescue RuntimeError => e\n puts \"#{e.message}\"\n @amount = nil\n @currency = nil\n end\n end",
"def currency\n 'INR'\n end",
"def test_number_to_currency\n\t\tassert ActionView::Helpers::NumberHelper\n\t\tobj = ActionView::Base.new\n\t\tassert_respond_to obj, 'number_to_currency'\n\t\tassert_respond_to obj, 'orig_number_to_currency'\n\t\t\n\t\tassert_equal \"$1,234,567,890.51\", obj.number_to_currency(1234567890.506), \"NOTE: This currency test should fail if locale has different currency format\"\n\tend",
"def euros price\n price ? number_to_currency(price , :precision => 2 , :unit => \"€\") : 0.0\n end",
"def currency_required? \n deposit_type?\n end",
"def currency\n nil\n end",
"def currency\n nil\n end",
"def currency\n 'usd'\n end",
"def currency_as_string; end",
"def get_currency_symbol\n \"€\"\n end",
"def ot_currency_code\n end",
"def currency_symbol\n Currency.new(currency).symbol\n end",
"def currency\n \"USD\"\n end",
"def currency\n params['mc_currency']\n end",
"def currency\n params['mc_currency']\n end",
"def currency_code\n data.currency_code\n end",
"def balance_decimal_validation\n decimals = balance.to_s.split('.')\n if decimals.size == 2 && decimals.last.size > 2\n errors.add(:balance, \"can't be more than 2 decimal places\")\n end\n end",
"def validate_cuit\n errors[:base] << \"El CUIT no es válido\" if not validar_cuit(self.cuit)\n end",
"def price(_currency)\n raise Sibit::NotSupportedError, 'price() doesn\\'t work here'\n end",
"def currency\n\t\t\"USD\"\n\tend",
"def initialize(amount, currency_code)\n @amount = amount.to_f\n @currency_code = currency_code\n end",
"def assert_currency! arg\n defines?(arg) ? (country_map[arg] || arg) : raise(Exchange::NoCurrencyError.new(\"#{arg} is not a currency nor a country code matchable to a currency\"))\n end",
"def currency\n params[\"Currency\"]\n end",
"def currency_amount\n # define this elsewhere\n currencymark = '$'\n if self.credit?\n sprintf(\"%s%0.2f\",currencymark,self.amount)\n else\n # put minus sign before dollar\n sprintf(\"-%s%0.2f\", currencymark, self.amount.abs)\n end\n end",
"def check_price\n self.price = self.price.to_f\n end",
"def to_currency(num)\n format(\"$%.2f\",num)\nend",
"def to_currency\n reverse.scan(/(?:\\d*\\.)?\\d{1,3}-?/).join(',').reverse\n end",
"def validate_fee_rate(code = nil)\n if @record.quantity.positive? && @record.rate <= 0\n add_error(:rate, code ? \"#{code.downcase}_invalid\".to_sym : :invalid)\n elsif @record.quantity <= 0 && @record.rate.positive?\n add_error(:quantity, code ? \"#{code.downcase}_invalid\".to_sym : :invalid)\n end\n end",
"def currency_as_string=(val); end",
"def check_amount\n if (mode == 'percentage' and percentage == 0) or (mode == 'fixed' and money.zero?)\n errors.add(:amount, 'a discount cannot be zero')\n end\n end",
"def ==(other_currency); end",
"def price_nil?(value)\n raise \"Input Invalid. Please check the format!\" if value.match(/\\d/).nil?\n end",
"def convert_money(currency)\n return currency.to_f / 100\n # if currency.to_s.include?(\".\")\n # return currency\n # else\n # return currency.to_f / 100\n # end\n end",
"def same_currency?(currency1, currency2); end",
"def currency\n params['X-CURRENCY']\n end",
"def get_rate(currency_iso_from, currency_iso_to); end",
"def has_currency(*attrs)\n options = attrs.extract_options!\n attrs.each do |attr|\n attr_reader attr\n define_reader_with_options(attr,options)\n define_method(\"#{attr.to_s}=\") do |val|\n instance_variable_set(\"@#{attr}\", val.to_s.to_currency)\n attributes[attr] = val\n val\n end\n end\n end",
"def currency_symbol\n if self.yard.present?\n self.yard.facility.address.country.currency rescue \"\"\n elsif self.facility.present?\n self.facility.address.country.currency rescue \"\"\n else\n \"\"\n end\n end",
"def currency_unit\n @currency_unit\n end",
"def currency(number)\n currency = number.abs.round(2)\n\n # Check number of digits after decimal point and add 0 if necessary\n\n decimal_check = currency.to_s.slice(-2)\n if decimal_check.start_with?('.')\n currency.to_s + '0'\n else\n currency\n end\n end",
"def set_ConvertToCurrency(value)\n set_input(\"ConvertToCurrency\", value)\n end",
"def payment_currency\n\t\t\t\t\treturn \"cs\"\n\t\t\t\tend",
"def get_currency_name\n \"euro\"\n end",
"def price=(value)\n if value.kind_of?(Integer)\n super\n elsif value.kind_of?(String) && !value.include?('.') # Looks like an integer\n super\n elsif value.blank?\n super\n else\n raise \"expected price to be an Integer representing the number of cents. Got: #{value}\"\n end\n end",
"def price_symbol\n price ? price.symbol : MoneyRails.default_currency.symbol\n end",
"def price=(value)\n if value.instance_of?(String)\n cents = MoneyUtils.parse(value)\n else\n begin\n cents = Integer(value)\n rescue\n cents = nil\n end\n end\n if cents\n self.price_basis = cents\n else\n errors.add(:price_basis, \"price can't be empty\")\n end\n end",
"def currency\n return nil unless (extended_currency = read_attribute(:currency))\n encrypt_remove_pre_and_postfix(extended_currency, 'currency', 10)\n end",
"def currency\n return nil unless (extended_currency = read_attribute(:currency))\n encrypt_remove_pre_and_postfix(extended_currency, 'currency', 10)\n end",
"def validate_amount\n if params[:amount].blank?\n update_error('amount', 'Please enter an amount.')\n end\n end",
"def getCurrencyValue(entry)\r\n\r\n # if entry is formatted as currency\r\n if isEntryCurrency?(entry)\r\n\r\n # ignore the initial $\r\n entry = entry[1..]\r\n\r\n # get rid of commas\r\n entry.gsub!(/,/, \"\")\r\n\r\n # convert to a number and return. We will convert everything to \r\n # a float for simplicity\r\n return entry.to_f()\r\n\r\n # if it is not formatted as currency, returns nil as an error value\r\n else\r\n return nil \r\n end\r\n end",
"def parse(input, currency, strict: false, decimal_separator: decimal_separator_resolver&.call)\n raise ArgumentError, \"decimal separator cannot be nil\" unless decimal_separator\n\n currency = Money::Helpers.value_to_currency(currency)\n return unless currency\n\n normalized_input = input\n .tr('-0-9.,、、', '-0-9.,,,')\n .gsub(/[^\\d\\-#{Regexp.escape(decimal_separator)}]/, '')\n .gsub(decimal_separator, '.')\n amount = BigDecimal(normalized_input, exception: false)\n if amount\n Money.new(amount, currency)\n elsif strict\n raise ArgumentError, \"unable to parse input=\\\"#{input}\\\" currency=\\\"#{currency}\\\"\"\n end\n end",
"def acc_currency\n @page.css(\"span[data-semantic = 'header-available-balance-amount']\").text.to_money.currency.to_s\n end",
"def validateCZ(vat_number)\r\n total = 0\r\n multipliers = [8,7,6,5,4,3,2]\r\n # Only do check digit validation for standard VAT numbers\r\n return true unless vat_number.to_s.length == 8\r\n # Multiply by multipliers\r\n 0.upto(6) do |i|\r\n total = total + vat_number[i,1].to_i * multipliers[i] \r\n end\r\n # Establish Check digit\r\n total = 11 - total % 11\r\n total = 0 if total == 10\r\n total = 1 if total == 11\r\n # Compare with last character of the VAT number.\r\n return true if total == vat_number.to_s.slice(7..8).to_i\r\n return false\r\n end",
"def add_rate(currency_iso_from, currency_iso_to, rate); end",
"def test_converter_returns_error_for_unknown_currency\n assert_raises(UnknownCurrencyCodeError){Currency_Converter.new({'USD' => 1.00, 'JPY' => 120.0}).convert( Currency.new('JPY', 120.0), 'ALL' )}\n end",
"def transaction_amount(currency_and_amount)\n currency = parse(currency_and_amount).first\n if currency == 'USD'\n amount = parse(currency_and_amount).last.to_f\n else\n amount = currency.to_f unless amount == 0.0\n end\n# self.amount = amount \n end",
"def donation_amount\n number_to_currency(self.value)\nend",
"def replace_invalid_chars(price)\n decimalised = price[/[.]/] ? price : \"0.\" + price \n decimalised.gsub(/[£p]/, '').to_f\nend",
"def validate(order)\n raise \"Total price is incorrect!\" if calculate_price != expected_price\n end",
"def currency_code_to_sign (currency_code)\n if currency_code == :USD\n return \"$\"\n elsif currency_code == :EUR\n return \"€\"\n end\n end"
] |
[
"0.7344712",
"0.7246969",
"0.69681907",
"0.68464684",
"0.6732954",
"0.6555829",
"0.65535253",
"0.65535253",
"0.6533844",
"0.63370097",
"0.6316244",
"0.6271905",
"0.6232283",
"0.62217766",
"0.6127661",
"0.6120054",
"0.6092502",
"0.6085789",
"0.6067468",
"0.6047139",
"0.6011598",
"0.59965426",
"0.5956706",
"0.5956706",
"0.59557456",
"0.5935636",
"0.5928353",
"0.5915388",
"0.58974785",
"0.58882046",
"0.5884581",
"0.58827436",
"0.58816415",
"0.5878159",
"0.5867811",
"0.5867514",
"0.5850473",
"0.58395237",
"0.5831527",
"0.58311456",
"0.5829667",
"0.5812048",
"0.5808529",
"0.58073044",
"0.5802919",
"0.57921827",
"0.57921827",
"0.5780841",
"0.5780746",
"0.5765006",
"0.57534045",
"0.5743743",
"0.5735323",
"0.5730368",
"0.5730368",
"0.5729857",
"0.5726368",
"0.5723654",
"0.5707413",
"0.5676587",
"0.5674248",
"0.5652408",
"0.56518114",
"0.5648194",
"0.56331414",
"0.56316143",
"0.56268704",
"0.56254053",
"0.5624554",
"0.5618231",
"0.56131965",
"0.56118876",
"0.56070334",
"0.5605538",
"0.5604923",
"0.5603723",
"0.5585184",
"0.55812776",
"0.5574272",
"0.55688953",
"0.556804",
"0.556121",
"0.55585206",
"0.5545778",
"0.5536716",
"0.55328006",
"0.55204487",
"0.55204487",
"0.55200446",
"0.55024856",
"0.55014336",
"0.54996955",
"0.5497546",
"0.54889166",
"0.5486955",
"0.54815066",
"0.54802257",
"0.5480149",
"0.54759574",
"0.54735464"
] |
0.6768185
|
4
|
Defining to_s on an object controls how the object is represented as a string, e.g., when you pass it to puts
|
def to_s
#Create an empty string
letter_array = @spaces
# puts letter_array.to_s
letter_array.map!{|char| char == "Q" ? char = "Qu " : char = char + " "}
output_string = String.new()
# output_string = output_string.split('').map!{|char| char = char + " "}.join('')
4.times do
output_string << letter_array.shift(4).join('') + "\n"
end
output_string
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def to_s_safe(obj)\n if obj.respond_to?(:to_s)\n obj.to_s\n else\n 'to_s error'\n end\n end",
"def to_s\n @string || @object.to_s('F')\n end",
"def to_s\n @string || @object.to_s('F')\n end",
"def to_s\n object.to_s\n end",
"def to_s\n @object.to_s\n end",
"def to_s(*) end",
"def to_s(*) end",
"def to_s(*) end",
"def to_s (o)\n o ? o.to_s : nil\n end",
"def to_s\n redacted_string(:to_s)\n end",
"def to_s\n redacted_string(:to_s)\n end",
"def to_s\n str\n end",
"def to_s\n @string ||= Builder::ToString.new(self).string\n end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s\n raise StandardError, \"#{self.class.name}#to_s accessed, must be redefined.\"\n end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s\n if self.class._equal?(String)\n self\n else\n String.new(self)\n end\n end",
"def to_s # to_s is a default method for a class. it returns a string when you call the class later.\n \treturn \"I'm a student.\"\n end",
"def to_s\n string\n end",
"def to_s\n @to_s ||= format(to_h)\n end",
"def to_s\n io = StringIO.new\n write io\n io.string\n end",
"def to_s(obj = T.unsafe(nil)); end",
"def to_s\n @str\n end",
"def to_s\n to_text\n end",
"def to_s\n\t\t\traise NotImplementedError, \"%s does not provide an implementation of #to_s\" %\n\t\t\t\t[ self.class.name ]\n\t\tend",
"def to_str\n to_s\n end",
"def to_s\n string.to_s\n end",
"def to_s\n toString\n end",
"def to_s\n @str\n end",
"def to_s\n @str\n end",
"def to_s\n to_a.to_s\n end",
"def to_str\n to_s\n end",
"def to_str\n to_s\n end",
"def to_s\n\t\t\t@to_s_sym ? self.__send__(@to_s_sym) : super\n\t\tend"
] |
[
"0.79306906",
"0.7474114",
"0.7474114",
"0.74625593",
"0.7317577",
"0.72644997",
"0.72644997",
"0.72644997",
"0.7256048",
"0.72376037",
"0.72376037",
"0.7234111",
"0.7147253",
"0.7140837",
"0.7140837",
"0.7140837",
"0.7140837",
"0.7140837",
"0.7140837",
"0.7140837",
"0.7140837",
"0.7140837",
"0.7140837",
"0.7140837",
"0.7140837",
"0.7140837",
"0.7140837",
"0.7140837",
"0.7140837",
"0.7140837",
"0.7140837",
"0.71316695",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.71216166",
"0.7098944",
"0.70850676",
"0.7067575",
"0.7050121",
"0.7020055",
"0.70134306",
"0.7009637",
"0.7009026",
"0.700787",
"0.6970248",
"0.695601",
"0.6954734",
"0.69488037",
"0.69488037",
"0.6934396",
"0.69193774",
"0.69193774",
"0.6912513"
] |
0.0
|
-1
|
test "the truth" do assert true end test "unsuccessful edit" do
|
def setup
@user = users(:david)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def test_truth\r\n assert true\r\n end",
"def test_truth\r\n assert true\r\n end",
"def test_truth\r\n assert true\r\n end",
"def test_the_truth\n assert true\nend",
"def test_the_truth\n assert true\n end",
"def test_the_truth\n assert true\n end",
"def test_edit\n #login_as(:john)\n #get :edit, :id => @first_id\n\n #assert_response :success\n #assert_template 'edit'\n\n #assert_not_nil assigns(:taverna_enactor)\n #assert assigns(:taverna_enactor).valid?\n \n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end",
"def test_truth\n assert true\n end"
] |
[
"0.7832046",
"0.7832046",
"0.7832046",
"0.7830646",
"0.7824353",
"0.7824353",
"0.7793456",
"0.7781827",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895"
] |
0.0
|
-1
|
Using the Ruby language, have the function SymmetricTree(strArr) take the array of strings stored in strArr, which will represent a binary tree, and determine if the tree is symmetric (a mirror image of itself). The array will be implemented similar to how a binary heap is implemented, except the tree may not be complete and NULL nodes on any level of the tree will be represented with a . For example: if strArr is ["1", "2", "2", "3", "", "", "3"] then this tree looks like the following: 1 / \ 2 2 /\ /\ 3 3 For the input above, your program should return the string true because the binary tree is symmetric.
|
def symmetric_tree(arr)
rows = Hash.new([])
n = 0
until arr.empty?
(2**n).times { rows[n] += [arr.shift] }
n += 1
end
rows.values.each do |row|
return false unless row == row.reverse
end
true
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def isTreeSymmetric(t)\n return true if t.nil?\n return sym?(t.left, t.right)\nend",
"def is_symmetric(root)\n return true if root.nil?\n\n stack = []\n stack << root.left if root.left\n stack << root.right if root.right\n\n until stack.empty?\n return false unless stack.size.even?\n\n right = stack.pop\n left = stack.pop\n return false unless right.val == left.val\n\n return false unless left.left.nil? == right.right.nil?\n\n stack << left.left if left.left\n stack << right.right if right.right\n\n return false unless left.right.nil? == right.left.nil?\n\n stack << left.right if left.right\n stack << right.left if right.left\n end\n\n true\nend",
"def is_symmetric(root)\n if root.nil? \n return true\n end\n \n level_nums = dfs_tree(root, 0, [])\n \n level_nums.each {|nums| return false unless is_palindrome(nums)}\n \n return true\nend",
"def is_symmetric(root)\n return true if root.nil?\n return true if root.left.nil? && root.right.nil?\n return false if root.left.nil? || root.right.nil?\n return false unless root.left.val == root.right.val\n \n new_left = invert_tree(root.left)\n \n is_same_tree(new_left, root.right)\nend",
"def is_symmetric(root)\n return true if !root\n return is_sym(root.left,root.right)\nend",
"def is_symmetric(node)\n return true if node.nil?\n inverted_right = invert_tree(node.right)\n same_tree(node.left, inverted_right)\nend",
"def is_symmetric(root)\n isMirror(root, root)\nend",
"def is_symmetric(root)\n is_symmetric_compare(root&.left, root&.right)\nend",
"def is_symmetric(root)\n symmetric_helper(root, root)\nend",
"def is_symmetric(node)\n symmetric_helper(node, node)\nend",
"def look_for_a_match(array)\n tree_match = false\n array.each do |x|\n (1...x.size).each do |i|\n if x[0] != x[i] || x[i] == \" \"\n return false\n end\n end\n return true\n end\n end",
"def symmetrical?(arr)\n\nend",
"def isSymmetricBySpace(s, i) \n return false if i==0\n c=0\n for d in 0..i\n return c==i if i-1-d<0||i+d>=s.length\n return false if s[i+d]!=s[i-1-d]\n c+=1 if s[i+d]==s[i-1-d]\n end\n return false\nend",
"def is_isomorphic(s, t)\n s = s.split(//)\n s_dup = s.detect {|dup| s.count(dup) > 1}\n s_dup_inx = s.each_index.select{|ind| s[ind] == s_dup}\n\n t = t.split(//)\n t_dup = t.detect {|dup| t.count(dup) > 1}\n t_dup_inx = t.each_index.select{|ind| t[ind] == t_dup}\n\n return s_dup_inx == t_dup_inx\nend",
"def squaragonal?(array)\n diag_right = 1\n diag_left = 1\n\n (0...array.length - 1).each do |i|\n (0...array.length - 1).each do |j|\n diag_right += 1 if array[i][j] == array[i + 1][j + 1]\n # diag_left += 1 if array[array.length - i - 1][j] == array[array.length - i - 2][j + 1]\n diag_left += 1 if array[-(i + 1)][j] == array[-(i + 2)][j + 1]\n end\n end\n if diag_right == array.length || diag_left == array.length\n return true\n else\n return false\n end\nend",
"def is_palindrome?(node)\n stack = []\n length = get_length(node)\n\n ((length / 2.0).ceil).times do\n stack.push(node.val)\n node = node.next\n end\n\n stack.pop if length.odd? # discard middle element\n\n while node\n return false unless node.val == stack.pop\n node = node.next\n end\n\n true\nend",
"def balanced(string)\n stack = Stack.new\n string_array = string.split('')\n pair_hash = { \"}\" => \"{\", \"]\" => \"[\", \")\" => \"(\" }\n\n string_array.each do |char|\n if !pair_hash[char]\n stack.push(char)\n elsif stack.pop != pair_hash[char]\n return false\n end\n end\n\n return stack.empty?\nend",
"def balanced(string)\n pairs = {\"{\" => \"}\", \"[\" => \"]\" , \"(\" => \")\"}\n arr = string.split('')\n if arr.length % 2 != 0 \n return false\n end \n\n stack = Stack.new\n n = arr.length\n n.times do |i|\n if arr[i] == \"[\" || arr[i] == \"{\" || arr[i] == \"(\"\n stack.push(arr[i])\n else\n top = stack.pop\n if arr[i] != pairs[\"#{top}\"]\n return false \n end \n end \n end \n return stack.empty?\nend",
"def balanced(string)\n return false if string.length.odd?\n pairs = {\n \"{\" => \"}\",\n \"(\" => \")\",\n \"[\" => \"]\"\n }\n stack = Stack.new\n\n string.each_char do |char|\n if pairs[char]\n stack.push(char)\n else\n if char != pairs[stack.pop]\n return false\n end \n end\n end\n\n return stack.empty?\nend",
"def is_isomorphic(s, t)\n hash = {}\n second = {}\n (0...s.size).each { |i|\n return false if !second[t[i]].nil? && hash[s[i]] != t[i] ||\n second[t[i]].nil? && !hash[s[i]].nil?\n hash[s[i]] = t[i]\n second[t[i]] = true\n }\n \n true\nend",
"def squaragonal?(grid)\n right = []\n left = []\n grid_reverse = grid.reverse\n\n (0...grid.length).each do |i|\n right << grid[i][i]\n left << grid_reverse[i][i]\n end\n\n return true if right.uniq.length == 1 || left.uniq.length == 1\n false\nend",
"def squaragonal? (arr)\n diagonal1 = []\n diagonal2 = []\n\n arr.each_with_index do |sub_arr, idx1| # diagonal 1 is idx1 = idx2\n sub_arr.each_with_index do |ele, idx2|\n if idx1 == idx2\n diagonal1 << arr[idx1][idx2]\n end\n end\n end\n\n arr.each_with_index do |sub_arr, idx1| # diagonal 2 is idx1 + idx2 = array.length -1\n sub_arr.each_with_index do |ele, idx2|\n if idx1 + idx2 == arr.length-1\n diagonal1 << arr[idx1][idx2]\n end\n end\n end\n\n \n diag1_test = diagonal1.all? {|el| el == diagonal1[0] }\n diag2_test = diagonal2.all? {|el| el == diagonal1[0] }\n\n\n diag1_test == true || diag2_test == true\n\nend",
"def isSymmetric?(pairs)\r\n # your code here\r\nend",
"def symmetric?\n raise \"Not implemented\"\n end",
"def is_isomorphic(s, t)\n s.chars.map { |x| s.chars.detect(x) } == t.chars.map { |x| t.chars.detect(x) }\nend",
"def balanced(string)\n matching = {\"{\" => \"}\", \"[\" => \"]\", \"(\"=>\")\"}\n\n record = Stack.new\n chars = string.split(\"\")\n \n chars.each do |s|\n if matching.has_key?(s)\n record.push(s)\n else \n check = record.pop\n if matching[check] != s \n return false \n end \n end \n \n end\n\n return false if !record.empty?\n return true \nend",
"def is_palindrome\n\t\tstack = []\n\t\tcurr_node = @head\n\t\twhile curr_node\n\t\t\tstack.push(curr_node.val)\n\t\t\tcurr_node = curr_node.next_node\n\t\tend\n\t\tcurr_node = @head #reset curr_node to start from beginning of ll\n\t\twhile curr_node\n\t\t\tif curr_node.val != stack.pop\n\t\t\t\treturn false\n\t\t\tend\n\t\t\tcurr_node = curr_node.next_node\n\t\tend\n\t\ttrue\n\tend",
"def squaragonal?(mat)\n n = mat.length\n # check UL to BR\n f_ele = mat[0][0]\n i = 0\n j = 0\n all_same = true\n while i<n\n all_same &= f_ele == mat[i][i]\n i+=1\n end\n return true if all_same\n # check BL to UR\n # debugger\n f_ele = mat[n-1][0]\n j = n-1\n i = 0\n all_same = true\n while i<n\n all_same &= f_ele == mat[i][j]\n i+=1\n j-=1\n end\n return true if all_same\n false\nend",
"def squaragonal?(matrix)\n diagonal = []\n antidiagonal = []\n\n outer_iterator = 0\n while outer_iterator < matrix.length\n inner_iterator = 0\n while inner_iterator < matrix.length\n\n if inner_iterator == outer_iterator\n diagonal << matrix[outer_iterator][inner_iterator]\n end\n\n if inner_iterator + outer_iterator == matrix.length-1\n antidiagonal << matrix[outer_iterator][inner_iterator]\n end\n\n inner_iterator += 1\n end\n outer_iterator += 1\n end\n\n first_ele = diagonal.first\n first_anti_ele = antidiagonal.first\n\n diagonal.all? {|ele| ele == first_ele} || antidiagonal.all? { |ele| ele == first_anti_ele}\nend",
"def second_anagrams?(str1, str2)\n arr2 = str2.split(\"\")\n str1.each_char do |char|\n idx = arr2.find_index(char) #since this iterates, its a nested n\n return false unless idx\n arr2.delete_at(idx)\n end\n arr2.empty?\nend",
"def is_valid(s)\n stack = []\n comp = { ']'=>'[', '}'=>'{', ')'=>'(' }\n close = [')', ']', '}']\n parens = s.split(//)\n (0..parens.length - 1).each { |i|\n if (close.include?(parens[i]))\n if (stack.last == comp[parens[i]])\n stack.pop()\n else\n stack.push(parens[i])\n end\n else\n stack.push(parens[i])\n end\n }\n stack.length == 0 ? true : false\nend",
"def balanced(string)\n return false if string.length % 2 != 0\n \n struct = Stack.new\n left_half = [\"(\", \"[\", \"{\"]\n right_half = [\")\", \"]\", \"}\"]\n\n left = 0\n right = string.length - 1\n until left >= right\n index = left_half.find_index { |el| el == string[left] }\n\n if !index.nil? && string[right] != right_half[index]\n return false if string[left + 1] != right_half[index]\n end\n \n left += 1\n right -= 1\n end\n\n true\nend",
"def squaragonal?(arr)\n left_daig(arr) || right_daig(arr)\nend",
"def balanced(string)\n pairs = {\"{\" => \"}\", \"[\" => \"]\", \"(\" => \")\"}\n stack = Stack.new\n string.each_char do |char|\n if pairs[char]\n stack.push(char)\n elsif stack.empty?\n return false\n else\n last = stack.pop\n return false if pairs[last] != char\n end\n end\n return stack.empty?\nend",
"def leaf_similar(root1, root2)\n stack1 = [root1]\n stack2 = [root2]\n\n until stack1.empty? && stack2.empty?\n return false if dfs(stack1) != dfs(stack2)\n end\n\n stack1.empty? && stack2.empty?\nend",
"def isomorphic(s, d)\n return false if s.length != d.length\n hashS, hashD = {}, {}\n arrS, arrD = s.chars, d.chars\n\n for i in 0..s.length\n sChar, dChar = arrS[i], arrD[i]\n sCharMap, dCharMap = hashS[sChar], hashD[dChar]\n\n if !sCharMap && !dCharMap\n hashS[sChar] = dChar\n hashD[dChar] = sChar\n else\n return false if sCharMap != arrD[i] || dCharMap != arrS[i]\n end\n end\n\n return true\nend",
"def symmetric?\n @colt_property.isSymmetric(@colt_matrix)\n end",
"def is_square(arr)\n return nil if arr.empty?\n arr.flatten.all? { |num| Math.sqrt(num).to_s.chars.last(2) == [\".\", \"0\"] }\nend",
"def circular_graph?(array)\n\treturn false if array.size.zero?\n\tvisited = array.size.times.map{ |i| false }\n\tvisited[0] = true\n\n\tarray.each do |index|\n\t\tif index > array.size \n\t\t\treturn false\n\t\tend\n\n\t\tif visited[index]\n\t\t\treturn true\n\t\tend\n\n\t\tvisited[index] = true\n\tend\n\tfalse\nend",
"def isogram string\n x = 0 \n \n while x < string.length\n y = x + 1\n while y < string.length\n if string[x] == string[y]\n return false\n end\n y = y + 1\n end\n x = x + 1\n end\n \n true\nend",
"def anagrams?(str_sym_or_int_1, str_sym_or_int_2)\n str_sym_or_int_1.to_s.downcase.delete(' ').split('').sort.join == str_sym_or_int_2.to_s.downcase.delete(' ').split('').sort.join\nend",
"def is_mirror(root_1, root_2)\n if root_1.nil? && root_2.nil?\n return true\n end\n\n # Miror mean left == right and right = left\n if !root_1.nil? && !root_2.nil?\n if root_1.val == root_2.val\n return is_mirror(root_1.left, root_2.right) && is_mirror(root_1.right, root_2.left)\n end\n end\n\n false\nend",
"def anagrams_on_steroids?(a_string, another_string)\n # TODO: implement the improved method\n hash_1 = hash_from_string(a_string)\n hash_2 = hash_from_string(another_string)\n hash_1 == hash_2\nend",
"def balanced(string)\n strStack = Stack.new\n opens_and_closes = {\n \"}\" => \"{\", \n \")\" => \"(\", \n \"]\" => \"[\"\n }\n string.each_char do |char|\n if ['(', '[', '{'].include?(char)\n strStack.push(char)\n else\n element = strStack.pop \n\n if opens_and_closes[char] != element\n return false\n end\n end\n end\n \n \n return strStack.empty?\nend",
"def balanced(string)\n \n stack = Stack.new\n index = 0\n sets = {\n \")\" => \"(\",\n \"}\" => \"{\",\n \"]\" => \"[\"\n }\n\n while index <= string.length - 1\n \n char = string[index]\n\n if sets.values.include?(char)\n stack.push(char)\n elsif sets.keys.include?(char)\n return false if stack.empty?\n last_in = stack.pop\n return false if last_in != sets[char]\n end\n index += 1\n\n end\n\n return stack.empty?\n\nend",
"def is_isogram(string)\n array = string.downcase.split(\"\")\n array.uniq.length == array.length ? true : false\nend",
"def squaragonal?(matrix)\n key1 = matrix[0][0]\n key2 = matrix[0][matrix.size - 1]\n test_dr = true\n test_dl = true\n\n (0...matrix.size).each do |i|\n test_dr = false unless matrix[i][i] == key1\n end\n\n j = matrix.size - 1\n (0...matrix.size).each do |i|\n test_dl = false unless matrix[i][j] == key2\n j -= 1\n end\n\n test_dr || test_dl\nend",
"def word_square?(arr)\n # first brute force, using i and j \n i = 0 \n while i < arr.length \n j = 0 \n while j < arr.length \n # next if i >= j will overflow as j never increments\n if i >= j \n j+= 1 \n next \n end \n return false unless arr[i][j] == arr[j][i]\n j += 1 \n end \n i+=1 \n end \n true\n # now think how i can optimize it when i == j \n # it's comparing itself against itself, so we don't need to check \n # also we checked each pair twice , [0][2] first and [2][0]\n # the first round since we increment inner loop first, second number\n # is bigger, so we don't need to check if first number is bigger than secodn number \n # means it's the same pair \nend",
"def balanced?(string)\n left = []\n right = []\n string.split(//).each_with_index do |char, indx|\n left << indx if char == '('\n right << indx if char == ')'\n end\n return true if left.empty? && right.empty?\n (left.size != right.size) || (left.last > right.last) ? false : true\nend",
"def balanced(string)\n stack = []\n parens = { \"(\" => \")\", \"{\" => \"}\", \"[\" => \"]\" }\n\n string.each_char do |c|\n if parens[c]\n stack.push(c)\n elsif parens[stack.pop] != c\n return false\n end\n end\n stack.empty?\nend",
"def pal_perm?(string)\n # O(N + N) = O(N)\n string = string.downcase.split('')\n # O(N)\n string.delete(' ')\n solo_allowed = string.count.odd?\n\n # O(N + N) = O(N)\n string.group_by { |letter| letter }.each do |letter, instances|\n if instances.count.odd?\n return false if !solo_allowed\n solo_allowed = false\n end\n end\n\n return true\nend",
"def squaragonal?(square)\n # tbrange = (0...square.length).to_a\n btrange = (0...square.length).to_a.reverse\n tb = Array.new\n bt = Array.new\n\n btrange.each_with_index do |i1, i2|\n tb << square[i1][i1]\n bt << square[i2][i1]\n end\n\n return true if tb.uniq.count == 1 || bt.uniq.count == 1\n false\nend",
"def nested(s, i = 0)\n string = s.split(\"()\")\n return false if s.length.odd?\n return true if s.empty? \n \n return true if s.length.even? && string[i].length == string[i+1].length\n return false if s.length.even? && string[i].length != string[i+1].length\nend",
"def diag?(twod_arr)\n first_diag = []\n second_diag = [] # two arrays for later storage\n\n (0...twod_arr.length).each do |idx| # looping though the length of the array\n first_diag << twod_arr[idx][idx] # storeing the first diag, it's easy since its index will always be the same\n second_diag << twod_arr[idx][twod_arr.length - 1 -idx] #second diag, this is the invert of \n end\n\n first_diag.uniq.length == 1 || second_diag.uniq.length == 1\nend",
"def array_or_string_palindrome?(element)\n begin\n element.reverse == element\n rescue\n element.join == element.reverse.join\n end\nend",
"def IsTridiagonal?(matrixarray)\n # Pre : \n assert(old = matrixarray.clone)\n\n # Check for validity\n for i in 0...matrixarray.length\n for j in 0...matrixarray[0].length\n if i!=j and i!=j-1 and i!=j+1 and matrixarray[i][j] != 0 # non-zero value in position outside of 3 diagonals\n return false\n end\n end\n end\n\n # Post :\n assert(old == matrixarray)\n return true\n end",
"def is_palindrome(str)\n hash_table = {}\n (0..str.length - 1).each do |i|\n if hash_table[str[i]]\n hash_table.delete (str[i])\n else\n hash_table[str[i]] = 1\n end\n end\n if hash_table.count > 1\n return false\n else\n return true\n end\nend",
"def solution(s)\r\n#~ s=\"{[()()]}\"\r\n#~ s=\"{\"\r\n#~ s=\"]]][[[\"\r\n#~ s=\"\"\r\nn=s.size\r\ni=0\r\na=[]\r\n#actions when S is empty\r\nif n==0 then \r\n result=1\r\nend\r\n#actions when S is not empty\r\nwhile i<n do\r\n\tcurChar=s[i]\r\n\tif curChar==\"(\" then \r\n\t\ta.push(curChar);\r\n\telse\r\n\t\tif a.size!=0 then\r\n\t\t\ttopChar=a.last\r\n\t\t\tif curChar==\")\"&&topChar==\"(\" then\r\n\t\t\t\ta.pop\r\n\t\t\telse\r\n result=0\r\n\t\t\tend\t\r\n\t\telse\r\n\t\t result=0\r\n\t\tend\r\n\tend\t\r\ni+=1\r\nend\r\nif a.size==0&&result!=0 then\r\n result=1\r\nelse\r\n result=0\r\nend\t\r\nreturn result\r\nend",
"def is_same_tree(p, q)\n\tif (p == nil) ^ (q == nil) \n\t\treturn false\n\tend\n\tq1 = []\n\tq2 = []\n\tq1.push p\n\tq2.push q\n\twhile q1 != [] and q2 != []\n\t\tc1 = q1.shift\n\t\tc2 = q2.shift\n\t\tif c1 == nil and c2 == nil\n\t\telsif (c1 == nil) ^ (c2 == nil)\n\t\t\treturn false\n\t\telsif c1.val != c2.val\n\t\t\treturn false\n\t\telse\n\t\t\tq1.push c1.left\n\t\t\tq1.push c1.right\n\t\t\tq2.push c2.left\n\t\t\tq2.push c2.right\n\t\tend\n\tend\n\tif q1 != [] or q2 != []\n\t\treturn false\n\tend\n\treturn true\n \nend",
"def balanced(string)\n if string.length == 0 || string.length == 1\n return true\n elsif string.length.odd? \n return false\n end\n \n reference = Hash.new\n reference = {\n \"(\" => \")\",\n \")\" => \"(\", \n \"[\" => \"]\", \n \"]\" => \"[\", \n \"{\" => \"}\", \n \"}\" => \"{\"}\n \n expected_mirror = []\n \n half_length = string.length / 2\n \n i = 0\n \n until i == half_length do\n if reference.has_key?(string[i])\n expected_mirror.insert(0, reference[string[i]])\n i += 1\n else\n reference[string[i].to_s = string[i].to_s]\n expected_mirror.insert(0, string[i])\n i += 1\n end\n end\n \n additional_counter = 0\n \n until i == (string.length) do\n \n if string[i] != expected_mirror[additional_counter] \n return mince_balance(string)\n else\n i += 1\n additional_counter += 1\n end\n end\n \n return true\n \nend",
"def is_palindrome?\n s = []\n self.each { |n| s.push n }\n self.each { |n| return false if n.data != s.pop.data}\n true\n end",
"def balanced(string)\n return false if string.length.odd?\n return true if string.empty?\n \n symbol_pairs = {\n ')' => '(',\n ']' => '[',\n '}' => '{'\n }\n \n stack = Stack.new()\n stack_length = 0\n i = 0\n until i == string.length || stack_length > (string.length / 2)\n current = string[i]\n \n case current\n when '(', '[', '{'\n # O(n) time complexity\n stack.push(current)\n stack_length += 1\n else\n # O(n) time complexity\n if stack.get_last() == symbol_pairs[current]\n stack.pop()\n stack_length -= 1\n else \n return false\n end\n end\n \n i += 1\n end\n \n return stack.empty?\nend",
"def are_anagrams?(str1, str2)\n # if different length, then can't possibly match\n return false if str1.length != str2.length\n\n str1_arr = str1.split('').sort\n str2_arr = str2.split('').sort\n 0.upto(str1_arr.length-1) do |i|\n return false if str1_arr[i] != str2_arr[i]\n end\n true\nend",
"def isogram?(string)\n ary = string.split('').map(&:downcase) # convert string to downcased array\n ary == ary.uniq ? true : false # return true if it contains duplicates\nend",
"def palindrome_arr_str?(input)\n return input == input.reverse\nend",
"def nested(s, i = 0, j = s.length - 1)\n\n return false if s.length.odd? \n return false if s[i] == \"(\" && s[j] != \")\" || (s[i] == \")\" && i < j)\n return true if i > j || s.empty?\n \n\n nested(s, i + 1, j - 1)\n\nend",
"def anagrams?(str1, str2)\n make_tally(str1) == make_tally(str2)\nend",
"def third_anagrams?(str1,str2)\n str1.split(\"\").sort.join(\"\") == str2.split(\"\").sort.join(\"\")\nend",
"def checkValidString(str)\n balance_count = 0\n right_paren = 0\n left_paren = 0\n star_count = 0\n diff = ''\n current_str = ''\n mapIt = true\n arr = str.split('')\n while mapIt\n mapIt = false\n arr.map!.with_index do |char, i|\n char if char == '' || char == '*'\n if char == '(' && arr[i + 1] == ')'\n mapIt = true\n arr[i + 1] = ''\n ''\n else\n char\n end\n end\n arr.delete('')\n end\n return arr\n if left_paren == right_paren\n return true\n else\n diff = (left_paren - right_paren).abs\n return true if diff <= star_count\n end\n return false\nend",
"def palidrome_recursive?(word)\nend",
"def solution(*arr)\n return false if arr.empty?\n arr.join.chars.length != arr.join.chars.uniq.length\nend",
"def is_palindrome(str)\n # check for and handle wonky inputs\n if !str.is_a?(String)\n puts \"Whoops: Input str must be a string.\"\n return\n end\n\n # nix case sensitivity by converting to lowercase\n # represent str as an array of letters\n str_array = str.downcase.split(//)\n\n # compare forwards and backwards\n if str_array == str_array.reverse\n return true\n end\n\n # if all else fails\n return false\n\nend",
"def double?(str)\n sz = str.length\n sz.even? && str[0..(sz / 2 - 1)] == str[(sz / 2)..-1]\nend",
"def balanced(string)\n \n \n # paren pairs are at the same indexes\n open_parens = [ '(', '[', '{' ]\n close_parens = [')', ']', '}' ]\n \n # check if string length isn't even\n if string.length % 2 != 0\n return false\n # check if string is empty\n elsif string.length == 0\n return true\n else\n # check if string starts with a close paren or ends with an open paren (unbalanced)\n if (close_parens.include? string[0]) || (open_parens.include? string[-1])\n return false\n else\n stack = Stack.new\n end\n end \n \n string.each_char do |x|\n if open_parens.include? x\n stack.push(x)\n # if x is a close paren, remove last open paren in stack and check to ensure it's a match for the close paren x.\n elsif close_parens.include? x\n last_in_stack = stack.pop()\n if last_in_stack != open_parens[close_parens.index(x)]\n return false\n end\n end\n end\n if stack.empty?\n return true\n else \n return false\n end\nend",
"def unique_arr?(arr)\n not_unique = false\n i = 0\n while (i < arr.length && !not_unique)\n j = i + 1\n while (j < arr.length && !not_unique)\n not_unique = true if arr[i] == arr[j] && arr[i] != '' && arr[i] != 0\n j += 1\n end\n i += 1\n end \n return !not_unique\n end",
"def palindrome_permutation?(string)\n hash = {}\n count = 0\n\n if string.empty?\n return true\n end\n\n string.each_char do |i|\n if hash[i] == nil\n hash[i] = 1\n else\n hash[i] += 1\n end\n end\n\n string_array = hash.values\n string_array.each do |num|\n if num.odd? == true\n count += 1\n if count > 1\n return false\n end\n end\n end\n return true\n\n\nend",
"def balanced_parentheses(string)\n strings = string.scan(/\\W/) #pulling out non-word characters\n parentheses = { '{' => '}', '[' => ']', '(' => ')' } #match parentheses in hash\n stack = []\n\n strings.each do |s|\n if parentheses.include? s #put parentheses into stack\n stack.push(s)\n elsif parentheses.values.include? s\n if stack.empty? || stack.last != parentheses.invert[s] #return an inverted hash\n return false\n else\n stack.pop\n end\n end\n end\n\n stack.empty? ? true : false #empty means all parentheses find their match else it is unbalanced\nend",
"def squaragonal?(matrix)\n d = matrix.length\n flag = 0\n n = matrix[0][0]\n (d-1).times do |r|\n if !(matrix[r+1][r+1] == n)\n flag = 1\n break\n end\n end\n return true if flag == 0\n\n #flag = 0\n n = matrix[-1][0]\n (d-1).times do |r|\n if !(matrix[-(r+2)][r+1] == n)\n #flag = 1\n return false\n #break\n end\n end\n true #if flag == 0\n #false\nend",
"def nested(s)\n return true if s.empty?\n return false if s.length.odd?\n \n return false if s[0] != \"(\" || s[-1] != \")\"\n return nested(s[1...-1])\n # To do this without creating new strings, make a helper method\n # that accepts additional parameters for left_char and right_char and increments\n # them inward each time, like I did for reverse_in_place with helper_reverse\nend",
"def second_anagram?(second_string)\n arr1 = self.chars\n arr2 = second_string.chars\n arr1.each_with_index do |let1,idx1|\n arr2.each_with_index do |let2,idx2|\n if let1 == let2\n arr1[idx1] = nil\n arr2[idx2] = nil\n end\n end\n end\n return true if arr1.compact.empty? && arr2.compact.empty?\n false\n end",
"def is_unique_no_extra_space?(str)\n i = 0\n while i < str.length \n j = i+1\n while j < str.length \n if str[i] == str[j]\n return false\n end \n j+=1\n end \n i+=1\n end \n true\nend",
"def is_match(s, p)\n# '.' single chr, '*' is empty or reapetation of same char\n # recursive sol\n # return s.empty? if p.empty?\n # first = !s.empty? && [s[0], '.'].include?(p[0])\n # if p[1] == '*'\n # is_match(s, p[2..-1]) || (first && is_match(s[1..-1], p))\n # else\n # first && is_match(s[1..-1], p[1..-1])\n # end\n \n # DP solution\n s = s.bytes\n p = p.bytes\n dp = Array.new(s.length+1) { Array.new(p.length+1, false) }\n m, n = s.length, p.length\n dp[m][n] = true\n \n m.downto(0) do |i| \n (n-1).downto(0) do |j| \n first = i < m && (s[i] == p[j] || p[j] == 46)\n if p[j+1] == 42\n dp[i][j] = dp[i][j+2] || (first && dp[i+1][j])\n else\n dp[i][j] = first && dp[i+1][j+1]\n end\n end\n end\n dp[0][0]\nend",
"def solve(s, t)\n if s.length != t.length\n return false\n end\n hash = Hash.new {|h, k, v| hash[k] = v}\n\n (0...s.length).each do |i|\n if !hash[s[i]] && !hash.values.include?(t[i])\n hash[s[i]] = t[i]\n elsif hash[s[i]] != t[i]\n return false\n end\n end\n true\nend",
"def triangular_word?(word)\n encoded = encode(word)\n triangular_num?(encoded)\nend",
"def balanced?(str)\n stack = []\n str.chars.each do |char|\n if char == ')' && stack.empty?\n return false\n elsif char == '('\n stack << char\n elsif stack.include?('(') && char == ')'\n stack.pop\n end\n end\n stack.empty?\nend",
"def valid_anagram(s, t)\n return false if s.length != t.length || s.empty? || t.empty?\n s_arr = s.chars.sort\n t_arr = t.chars.sort\n for i in 0...s_arr.length\n return false if s_arr[i] != t_arr[i]\n end\n true\nend",
"def is_square(arr)\n return nil if arr.empty?\n arr.flatten.all? { |num| Math.sqrt(num) % 1 == 0 }\nend",
"def pali_perm(str)\n hash = Hash.new(0)\n str.each_char {|ch| hash[ch] += 1 unless ch == ' '}\n odd = false\n hash.values.each do |value|\n if value % 2 == 1\n return false if odd\n odd = true\n end\n end\n true\nend",
"def balanced_parentheses?(string)\n stack = []\n string.chars.each do |c|\n return false if !check_parentheses(c, \"(\", \")\", stack) || !check_parentheses(c, \"[\", \"]\", stack)\n end\n stack.empty?\nend",
"def balanced_brackets(string)\n opening_brackets = \"([{\"\n closing_brackets = \")]}\"\n matching_brackets = {\")\"=> \"(\", \"]\"=> \"[\", \"}\"=> \"{\"}\n stack = []\n\n string.each_char { |char|\n if opening_brackets[char]\n stack << char\n elsif closing_brackets[char]\n if stack.length == 0\n return false\n end\n \n if stack[-1] == matching_brackets[char]\n stack.pop()\n else\n return false\n end\n end\n }\n return stack.length == 0\nend",
"def palyndrome?(str)\n (0..( (str.size - 1) / 2 )).each do |i|\n return false if str[i] != str[ str.size - 1 - i ]\n end\n true\n end",
"def palindromic_array?(arr)\n arr == arr.reverse\nend",
"def is_anagram(s, t)\n\n return s.split(\"\").sort == t.split(\"\").sort\n\nend",
"def anagramIII?(str1, str2)\n str1_arr = str1.split(\"\")\n str2_arr = st2.split(\"\")\n str1_arr.sort == str2_arr.sort\nend",
"def is_palindrome_permutation?\n self.gsub!(/\\s+/,\"\")\n return self == self.reverse\n end",
"def squaragonal?(grid)\n diagnoal?(grid) || diagnoal?(grid.reverse)\nend",
"def squarocol?(array)\n outer_iterator = 0\n while outer_iterator < array.length\n first_ele = array[outer_iterator].first\n return true if array[outer_iterator].all? { |ele| ele == first_ele }\n outer_iterator += 1\n end\n\n transposed = []\n\n outer_iterator = 0\n while outer_iterator < array.length\n inner_iterator = 0\n row = []\n while inner_iterator < array.length\n row << array[inner_iterator][outer_iterator]\n inner_iterator += 1\n end\n transposed << row\n outer_iterator += 1\n end\n \n\n transposed.each do |ele|\n first = ele.first\n return true if ele.all? { |ele| ele == first}\n end\n\n false\nend",
"def palindrome?(string)\n array = string.split('')\n return true if array == array.reverse\n false\nend",
"def balanced?(string)\n parentheses = string.chars.select do |char|\n char == \"(\" || char == \")\"\n end\n \n p_first_half = parentheses[0..parentheses.size/2.0-1]\n p_sec_half = parentheses[parentheses.size/2.0.ceil..parentheses.size-1]\n if parentheses.size.odd? || parentheses[0] == \")\"\n return false\n else\n p_first_half.reverse.join(\"\").gsub(/[()]/, \"(\" => \")\", \")\" => \"(\") == p_sec_half.join(\"\")\n end \nend",
"def squarocol?(array)\n height = array.length\n width = height\n (0...height).each do |i|\n count_c = 1\n count_r = 1\n (0...width - 1).each do |j|\n count_c += 1 if array[i][j] == array[i][j + 1]\n count_r += 1 if array[j][i] == array[j + 1][i]\n end\n return true if count_c == height || count_r == width\n end\n false\nend"
] |
[
"0.76344705",
"0.7289066",
"0.72687614",
"0.7133568",
"0.71197224",
"0.70306444",
"0.6889006",
"0.68572754",
"0.68020713",
"0.66402566",
"0.6397494",
"0.63641757",
"0.6351757",
"0.6246554",
"0.5997706",
"0.5786831",
"0.5756023",
"0.5700338",
"0.5629166",
"0.5627084",
"0.56096244",
"0.56001985",
"0.5597175",
"0.55846065",
"0.5553471",
"0.5539914",
"0.5506356",
"0.5492577",
"0.5490996",
"0.54895425",
"0.5439474",
"0.54251325",
"0.54086804",
"0.53886837",
"0.53704953",
"0.5362954",
"0.5355649",
"0.5348121",
"0.5346627",
"0.5342102",
"0.53229225",
"0.53217334",
"0.53068095",
"0.52796423",
"0.5268814",
"0.52643824",
"0.525378",
"0.5245345",
"0.5224637",
"0.52189094",
"0.521836",
"0.52107114",
"0.52071357",
"0.52064174",
"0.52059907",
"0.52041656",
"0.5202674",
"0.5201713",
"0.5197148",
"0.51877385",
"0.51836514",
"0.51835096",
"0.5172122",
"0.5166598",
"0.51597613",
"0.5157794",
"0.5156372",
"0.515401",
"0.514632",
"0.513487",
"0.51215273",
"0.5115279",
"0.5112031",
"0.5108306",
"0.5093328",
"0.50904316",
"0.50894207",
"0.5083552",
"0.50834924",
"0.50758195",
"0.5075457",
"0.50707996",
"0.50668645",
"0.5061045",
"0.5060586",
"0.50551254",
"0.5048472",
"0.50404537",
"0.5024822",
"0.50218415",
"0.5007225",
"0.500689",
"0.5006364",
"0.50061595",
"0.50056696",
"0.5004592",
"0.50015384",
"0.49980533",
"0.49946165",
"0.49896702"
] |
0.78964055
|
0
|
GET /diningts GET /diningts.json
|
def index
@diningts = Diningt.all
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @dices = Dice.all\n\n render json: @dices\n end",
"def index\n\n @dtests = Dtest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dtests }\n end\n end",
"def index\n @sightings = Sighting.all\n render json: @sightings\n end",
"def index\n puts \"user: #{@current_user.json_hash[:id]}\"\n hosted_dinners = []\n attended_dinners = []\n @hosted_dinners = @current_user.hosted_dinners.where('starts_at >= ?', \"#{Time.now}\").order(starts_at: :asc).each do |dinner|\n hosted_dinners << dinner.all_info\n end\n @attended_dinners = @current_user.attended_dinners.where('starts_at >= ?', \"#{Time.now}\").order(starts_at: :asc).each do |dinner|\n attended_dinners << dinner.all_info\n end\n render json: {\n hosting: hosted_dinners,\n attending: attended_dinners\n }\n end",
"def index\n @dinings = Dining.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @dinings }\n end\n end",
"def index\n @duty_stations = DutyStation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @duty_stations }\n end\n end",
"def index\n @dinos = Dino.where(query_params)\n render json: @dinos\n end",
"def index\n @dolgnosts = Dolgnost.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dolgnosts }\n end\n end",
"def days\n @trainings = Training.all\n @activities = Activity.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @trainings }\n end\n end",
"def index\n sighting = Sighting.all \n render json: SightingSerializer.new(sighting)\n end",
"def index_hosting\n puts \"user: #{@current_user.json_hash[:id]}\"\n dinners = []\n @dinners = @current_user.hosted_dinners\n @dinners.each do |dinner|\n dinners << dinner.all_info\n end\n render json: dinners\n end",
"def show\n @dailyStanding = DailyStanding.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @dailyStanding }\n end\n end",
"def index\n @dnas = Dna.all\n\n render json: @dnas\n end",
"def index\n @diaries = current_user.diaries.all\n respond_to do |format|\n format.html {render :index}\n format.json { render json: @diaries }\n end\n end",
"def index\n @dossiers = Dossier.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dossiers }\n end\n end",
"def show\n @dteor = Dteor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dteor }\n end\n end",
"def index\n @days = @trip.days.order(trip_day: :asc)\n render json: @days, include: [:activities]\n end",
"def index\n @denuncia = Denuncium.all\n\n render json: @denuncia\n end",
"def dates\n render json: @standings\n end",
"def dresses\n render json: { collections: Collection.published_dresses }\n end",
"def index\n @diciplinas = Diciplina.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @diciplinas }\n end\n end",
"def show\n @track_dress = TrackDress.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @track_dress }\n end\n end",
"def index\n @diets = @profile.diets\n respond_with @diets\n end",
"def index\n @treks = Trek.all\n @title = \"Trekking routes and destinations\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @treks }\n end\n end",
"def show\n @daylight = Daylight.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @daylight }\n end\n end",
"def index\n @innings = Inning.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @innings }\n end\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @service_demand_breakdowns }\n end\n end",
"def index\n @disciplines = Discipline.all\n\n render json: @disciplines\n end",
"def index\n @dog_walks = DogWalk.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dog_walks }\n end\n \n end",
"def index_attending\n puts \"user: #{@current_user.json_hash[:id]}\"\n dinners = []\n @dinners = @current_user.attended_dinners\n @dinners.each do |dinner|\n dinners << dinner.all_info\n end\n render json: dinners\n end",
"def show\n @dress = Dress.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dress }\n end\n end",
"def index\n @rents = Rent.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @rents }\n end\n end",
"def index\n Rails.logger.info('👻 Disraptor: Showing available routes.')\n\n routes = Disraptor::Route.find_all()\n\n render json: { 'disraptor/routes': routes }\n end",
"def index\n @biddings = Bidding.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @biddings }\n end\n end",
"def index\r\n @classdays = Classday.all\r\n\r\n render json: @classdays\r\n end",
"def show\n @duty_station = DutyStation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @duty_station }\n end\n end",
"def show\n @dtest = Dtest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dtest }\n end\n end",
"def show\n render json: @diet, status: 200, root: true\n end",
"def index\n @ducks = Duck.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ducks }\n end\n end",
"def index\n @harvestings = Harvesting.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @harvestings }\n end\n end",
"def serv_json\n \"http://api.dribbble.com/shots/popular?page=1\"\n end",
"def index\n @task_doers = TaskDoer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @task_doers }\n end\n end",
"def show\n @sighting = Sighting.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sighting }\n end\n end",
"def show\n sighting = Sighting.find(params[:id])\n #render json: sighting.to_json(:include => {:bird => {:only =>[:name, :species]}, :location => {:only =>[:latitude, :longitude]}}, :except => [:updated_at])\n end",
"def index\n @sightings = Sighting.where(date: params[:start_date]..params[:end_date])\n render json: @sightings\n end",
"def show\n @kf_diary = Kf::Diary.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kf_diary }\n end\n end",
"def available_trends\n get(\"/trends/available.json\")\n end",
"def index\n if (params[:redirect] == \"on\")\n sql = <<-SQL\n WITH src AS (SELECT id, daughters(id)\n FROM kine WHERE owner_id = #{params[:search_owner]})\n SELECT json_agg(src) FROM src;\n SQL\n render json: ActiveRecord::Base.connection.select_value(sql)\n else\n @daughters = Daughter.all\n end\n end",
"def trends_available\n get(\"/trends/available.json\")\n end",
"def index\n @weddings = Wedding.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @weddings }\n end\n end",
"def index\n @subsedes = Subsede.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @subsedes }\n end\n end",
"def index\n @flights = Flight.all\n render json: @flights\n end",
"def index\n @guests = @wedding.guests.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @guests }\n end\n end",
"def dayIndex\n render json: Restaurant.restaurantsDay\n end",
"def show\n @skydatum = Skydatum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @skydatum }\n end\n end",
"def show\n @dolgnost = Dolgnost.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dolgnost }\n end\n end",
"def index\n @distros = getmydata(\"Distro\")\n pagination\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @distros }\n end\n end",
"def show\n @drip = Drip.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @drip }\n end\n end",
"def show\n render json: @sighting\n end",
"def show\n @trend = Trend.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trend }\n end\n end",
"def show\n render json: @dice\n end",
"def index\n @gets = Get.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gets }\n end\n end",
"def show\n render json: @dino\n end",
"def list_tenants_for_circles(args = {}) \n get(\"/tenants.json/circles\", args)\nend",
"def index\n @diet_dishes = DietDish.all\n end",
"def show\n puts \"user: #{@current_user.json_hash[:id]}\"\n @dinner = @current_user.hosted_dinners.find_by(id: params[:id])\n @dinner ||= @current_user.attended_dinners.find_by(id: params[:id])\n @dinner ||= @current_user.invited_dinners.find_by(id: params[:id])\n if @dinner\n render :json => @dinner.all_info\n end\n end",
"def index\n @drone_attacks = DroneAttack.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :layout => 'blank'}\n end\n end",
"def index\n @datings = Dating.all\n end",
"def index\n @tenants = keystone.tenants\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @tenants }\n end\n end",
"def index\n @teaches = Teach.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @teaches }\n end\n end",
"def index\n @listings = Listing.all\n render json: @listings\n end",
"def show\n @day_list = DayList.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @day_list }\n end\n end",
"def show\n @dining = Dining.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @dining }\n end\n end",
"def list\n get('/')\n end",
"def index\n page_number = params[:page] ? params[:page][:number] : 1\n per_page = params[:per_page] ? params[:per_page] : 10\n\n @standings = Standing.paginate(page: page_number, per_page: per_page)\n\n render json: @standings\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @service_development_costs }\n end\n end",
"def show\n @dart = Dart.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dart }\n end\n end",
"def interesting(options = {})\n response = Typhoeus::Request.get(\"#{DARKSKY_API_URL}/interesting/#{@api_key}\", DEFAULT_OPTIONS.dup.merge(options))\n JSON.parse(response.body) if response.code == 200 \n end",
"def show\n animal = Animal.find(params[:id])\n #return all the sightings for the animal\n render json: animal.to_json(include: :sightings)\nend",
"def index\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @life_insurances }\n end\n end",
"def index\n @tour_dates = TourDate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tour_dates }\n end\n end",
"def index\n @trades = Trade\n .only(:created_at, :is_fair, :ash_pokemons, :brock_pokemons)\n respond_to do |format|\n format.json { render json: @trades }\n end\n end",
"def index\n @listings = Listing.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @listings }\n end\n end",
"def index\n @listings = Listing.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @listings }\n end\n end",
"def show\n @daily_exercise = DailyExercise.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @daily_exercise }\n end\n end",
"def index\n @rides = Ride.all\n respond_with @rides, status: :ok\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @duck }\n end\n end",
"def show\n @side_dish = SideDish.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @side_dish }\n end\n end",
"def show\n @dayoff = Dayoff.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dayoff }\n end\n end",
"def show\n @restaurant_dish = Restaurant::Dish.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @restaurant_dish }\n end\n end",
"def index\n @bills = @dwelling.bills\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bills }\n end\n end",
"def show\n @therapist = Therapist.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @therapist }\n end\n end",
"def index\n @attendees = Attendees.all\n render json: @attendees\n end",
"def show\n @crowd = Crowd.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @crowd }\n end\n end",
"def index\n @dbh_measurements = DbhMeasurement.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dbh_measurements }\n end\n end",
"def index\n @kids = Kid.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @kids }\n end\n end",
"def show\r\n @design_dissertation = DesignDissertation.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @design_dissertation }\r\n end\r\n end",
"def show\n @zombie_sighting = ZombieSighting.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @zombie_sighting }\n end\n end",
"def index *_\n @trades = owned_trades_view\n\n render json: @trades\n end",
"def index\n @dteors = Dteor.all\n @thems = get_tem\n respond_to do |format|\n if get_tem\n format.html # index.html.erb\n format.json { render json: @dteors } \n else\n format.html { redirect_to new_student_path, notice: t(:vvedit_dani)}\n end\n \n end\n end"
] |
[
"0.62330526",
"0.6204509",
"0.6182461",
"0.6148789",
"0.61273634",
"0.60521287",
"0.60411656",
"0.59897697",
"0.5979209",
"0.59673804",
"0.5957402",
"0.59309524",
"0.59278667",
"0.58980876",
"0.5897708",
"0.58862567",
"0.58832157",
"0.5840625",
"0.58361256",
"0.5822054",
"0.5821481",
"0.58169425",
"0.5806746",
"0.57891953",
"0.57794666",
"0.5771722",
"0.5766904",
"0.5760899",
"0.57408655",
"0.573753",
"0.57341325",
"0.5727414",
"0.57245106",
"0.5711142",
"0.57081795",
"0.5705044",
"0.5693827",
"0.56830233",
"0.567403",
"0.5673756",
"0.5664886",
"0.56632686",
"0.5660824",
"0.56547874",
"0.56499285",
"0.5647049",
"0.56451803",
"0.5642296",
"0.5641199",
"0.56411755",
"0.56403834",
"0.5639066",
"0.5634027",
"0.56296575",
"0.5629263",
"0.5623909",
"0.5619499",
"0.561283",
"0.56035167",
"0.559961",
"0.55947125",
"0.5588133",
"0.55871713",
"0.55861974",
"0.5579862",
"0.55758333",
"0.55652755",
"0.5560913",
"0.5556433",
"0.555586",
"0.55541456",
"0.5547282",
"0.55444545",
"0.5543638",
"0.55427426",
"0.5538585",
"0.5537712",
"0.55309576",
"0.55186146",
"0.5517243",
"0.5515064",
"0.55146736",
"0.5510842",
"0.55107427",
"0.55102706",
"0.55101955",
"0.55063814",
"0.5506138",
"0.5502101",
"0.5492813",
"0.5487151",
"0.54871285",
"0.54859895",
"0.5484909",
"0.5484305",
"0.5478269",
"0.5476058",
"0.54755455",
"0.54738367",
"0.54737014"
] |
0.64167345
|
0
|
GET /diningts/1 GET /diningts/1.json
|
def show
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def show\n @dailyStanding = DailyStanding.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @dailyStanding }\n end\n end",
"def show\n @dteor = Dteor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dteor }\n end\n end",
"def index\n @diningts = Diningt.all\n end",
"def index\n @dices = Dice.all\n\n render json: @dices\n end",
"def index\n\n @dtests = Dtest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dtests }\n end\n end",
"def show\n @track_dress = TrackDress.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @track_dress }\n end\n end",
"def index\n @duty_stations = DutyStation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @duty_stations }\n end\n end",
"def show\n @duty_station = DutyStation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @duty_station }\n end\n end",
"def index\n @dinos = Dino.where(query_params)\n render json: @dinos\n end",
"def index\n @sightings = Sighting.all\n render json: @sightings\n end",
"def show\n @dress = Dress.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dress }\n end\n end",
"def index\n @dinings = Dining.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @dinings }\n end\n end",
"def index\n puts \"user: #{@current_user.json_hash[:id]}\"\n hosted_dinners = []\n attended_dinners = []\n @hosted_dinners = @current_user.hosted_dinners.where('starts_at >= ?', \"#{Time.now}\").order(starts_at: :asc).each do |dinner|\n hosted_dinners << dinner.all_info\n end\n @attended_dinners = @current_user.attended_dinners.where('starts_at >= ?', \"#{Time.now}\").order(starts_at: :asc).each do |dinner|\n attended_dinners << dinner.all_info\n end\n render json: {\n hosting: hosted_dinners,\n attending: attended_dinners\n }\n end",
"def days\n @trainings = Training.all\n @activities = Activity.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @trainings }\n end\n end",
"def show\n @drip = Drip.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @drip }\n end\n end",
"def index\n @dossiers = Dossier.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dossiers }\n end\n end",
"def show\n @daylight = Daylight.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @daylight }\n end\n end",
"def show\n @dtpic = Dtpic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dtpic }\n end\n end",
"def show\n @dtest = Dtest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dtest }\n end\n end",
"def show\n @traffic = Traffic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @traffic }\n end\n end",
"def show\n @dart = Dart.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dart }\n end\n end",
"def show\n @trend = Trend.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trend }\n end\n end",
"def show\n @tripdate = Tripdate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tripdate }\n end\n end",
"def index\n @dolgnosts = Dolgnost.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dolgnosts }\n end\n end",
"def serv_json\n \"http://api.dribbble.com/shots/popular?page=1\"\n end",
"def show\n @skydatum = Skydatum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @skydatum }\n end\n end",
"def show\n @dolgnost = Dolgnost.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dolgnost }\n end\n end",
"def index\n @days = @trip.days.order(trip_day: :asc)\n render json: @days, include: [:activities]\n end",
"def index\n @dnas = Dna.all\n\n render json: @dnas\n end",
"def show\n @distraction = Distraction.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @distraction }\n end\n end",
"def index\n @distros = getmydata(\"Distro\")\n pagination\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @distros }\n end\n end",
"def show\n @daily_exercise = DailyExercise.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @daily_exercise }\n end\n end",
"def show\n @therapist = Therapist.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @therapist }\n end\n end",
"def show\n @datum = Datum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @datum }\n end\n end",
"def show\n @datum = Datum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @datum }\n end\n end",
"def show\n @dog_walk = DogWalk.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dog_walk }\n end\n end",
"def index\n @gets = Get.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gets }\n end\n end",
"def show\n render json: @diet, status: 200, root: true\n end",
"def show\n @sighting = Sighting.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sighting }\n end\n end",
"def show\n travels = Travel.find(params[:id])\n render json: travels, status: :ok\n end",
"def index\n sighting = Sighting.all \n render json: SightingSerializer.new(sighting)\n end",
"def index\n @treks = Trek.all\n @title = \"Trekking routes and destinations\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @treks }\n end\n end",
"def index\n @disciplines = Discipline.all\n\n render json: @disciplines\n end",
"def show\n @daytime = Daytime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @daytime }\n end\n end",
"def index\n @diets = @profile.diets\n respond_with @diets\n end",
"def show\n @kf_diary = Kf::Diary.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kf_diary }\n end\n end",
"def get_json(path)\n puts \"*** GET #{path}\"\n\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n puts \"HTTP #{response.code}\"\n\n puts JSON.pretty_generate(result)\n result\nend",
"def index\n @dog_walks = DogWalk.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dog_walks }\n end\n \n end",
"def show\n @daily_statistic = DailyStatistic.find(params[:id])\n\n render json: @daily_statistic\n end",
"def index\n @task_doers = TaskDoer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @task_doers }\n end\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @service_demand_breakdowns }\n end\n end",
"def index\n @diciplinas = Diciplina.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @diciplinas }\n end\n end",
"def show\n @ninja = Ninja.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ninja }\n end\n end",
"def show\n dog = Dog.find(params[:id])\n render json: dog\n end",
"def show\n @dayoff = Dayoff.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dayoff }\n end\n end",
"def show\n @day_list = DayList.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @day_list }\n end\n end",
"def show\n @doctor_timing = DoctorTiming.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @doctor_timing }\n end\n end",
"def show\n @dish = Dish.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dish }\n end\n end",
"def show\n @spdatum = Spdatum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @spdatum }\n end\n end",
"def show\n @diemtrentuyen = Diemtrentuyen.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @diemtrentuyen }\n end\n end",
"def show\n @crowd = Crowd.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @crowd }\n end\n end",
"def index\n @denuncia = Denuncium.all\n\n render json: @denuncia\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @duck }\n end\n end",
"def show\n @days_since_visit = DaysSinceVisit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @days_since_visit }\n end\n end",
"def index_hosting\n puts \"user: #{@current_user.json_hash[:id]}\"\n dinners = []\n @dinners = @current_user.hosted_dinners\n @dinners.each do |dinner|\n dinners << dinner.all_info\n end\n render json: dinners\n end",
"def dayIndex\n render json: Restaurant.restaurantsDay\n end",
"def show\n @trap = Trap.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trap }\n end\n end",
"def show\n @restaurant_dish = Restaurant::Dish.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @restaurant_dish }\n end\n end",
"def index\n @rents = Rent.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @rents }\n end\n end",
"def show\r\n @design_dissertation = DesignDissertation.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @design_dissertation }\r\n end\r\n end",
"def details\n @daily_deal = DailyDeal.find(params[:id])\n respond_to do |format|\n format.json do\n render with_api_version\n end\n end\n end",
"def index\n @subsedes = Subsede.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @subsedes }\n end\n end",
"def show\n @stone = Stone.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stone }\n end\n end",
"def show\n @zombie_sighting = ZombieSighting.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @zombie_sighting }\n end\n end",
"def show\n @goat = Goat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @goat }\n end\n end",
"def show\n @beat = Beat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @beat }\n end\n end",
"def show\n @hot_water_distribution = HotWaterDistribution.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hot_water_distribution }\n end\n end",
"def show\n render json: @dino\n end",
"def index\n @innings = Inning.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @innings }\n end\n end",
"def show\n @side_dish = SideDish.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @side_dish }\n end\n end",
"def get_json(path)\n puts \"*** GET #{path}\"\n\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n puts \"HTTP #{response.code}\"\n\n #puts JSON.pretty_generate(result)\n result\nend",
"def get_json(path)\n puts \"*** GET #{path}\"\n\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n puts \"HTTP #{response.code}\"\n\n #puts JSON.pretty_generate(result)\n result\nend",
"def show\n @dental = Dental.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dental }\n end\n end",
"def index\n @diaries = current_user.diaries.all\n respond_to do |format|\n format.html {render :index}\n format.json { render json: @diaries }\n end\n end",
"def index\n @ducks = Duck.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ducks }\n end\n end",
"def view\n res = @client.get(path)\n @attributes = res.json if res.success?\n end",
"def index\n @flights = Flight.all\n render json: @flights\n end",
"def show\n @dinosaur = Dinosaur.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dinosaur }\n end\n end",
"def show\n @nursing_time = NursingTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @nursing_time }\n end\n end",
"def show\n @dining = Dining.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @dining }\n end\n end",
"def index\n @weddings = Wedding.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @weddings }\n end\n end",
"def show\r\n @disciplines_study = DisciplinesStudy.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @disciplines_study }\r\n end\r\n end",
"def show\n @task_doer = TaskDoer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @task_doer }\n end\n end",
"def show\n @daily_inventory = DailyInventory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @daily_inventory }\n end\n end",
"def show\n @drug = Drug.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @drug }\n end\n end",
"def show\n @dato = Dato.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dato }\n end\n end",
"def show\n story = Story.find(params[:id])\n render json: story\n end",
"def show\n @dj = Dj.find(params[:id])\n if params[:format] == :json\n respond_with @dj\n else\n render 'root/index'\n end\n\n end",
"def dresses\n render json: { collections: Collection.published_dresses }\n end",
"def show\n @stundent = Stundent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stundent }\n end\n end",
"def index\r\n @classdays = Classday.all\r\n\r\n render json: @classdays\r\n end"
] |
[
"0.62002575",
"0.6189296",
"0.611213",
"0.61069083",
"0.609398",
"0.607846",
"0.6062383",
"0.6059271",
"0.6058113",
"0.60314316",
"0.602575",
"0.60207784",
"0.60181993",
"0.6014756",
"0.5999919",
"0.59928167",
"0.5975059",
"0.59737444",
"0.59735423",
"0.5954846",
"0.59491247",
"0.5947624",
"0.5939519",
"0.59305364",
"0.5926147",
"0.59247375",
"0.59181243",
"0.5917703",
"0.5910698",
"0.58993345",
"0.58962613",
"0.5879584",
"0.58781517",
"0.5870017",
"0.5870017",
"0.5860271",
"0.58595",
"0.5854928",
"0.5852171",
"0.5849345",
"0.5838485",
"0.58366585",
"0.58365977",
"0.5835473",
"0.58210444",
"0.5811833",
"0.581064",
"0.58098084",
"0.5803045",
"0.58008",
"0.5796753",
"0.57950413",
"0.5788025",
"0.5786768",
"0.5784566",
"0.5783139",
"0.57760316",
"0.57749414",
"0.577473",
"0.5771093",
"0.57709146",
"0.57619995",
"0.5756764",
"0.5756011",
"0.5753477",
"0.5752931",
"0.57527816",
"0.57470113",
"0.57448995",
"0.5740184",
"0.5739716",
"0.5738875",
"0.5736209",
"0.5731449",
"0.5731108",
"0.57293504",
"0.57222027",
"0.5720372",
"0.5717126",
"0.57141864",
"0.5711387",
"0.5711387",
"0.5709989",
"0.5709174",
"0.5707993",
"0.5701436",
"0.5696424",
"0.56962156",
"0.5691",
"0.5689207",
"0.568821",
"0.5684398",
"0.5682328",
"0.56798744",
"0.56773055",
"0.5674602",
"0.567349",
"0.56712055",
"0.5669055",
"0.56682545",
"0.5664954"
] |
0.0
|
-1
|
POST /diningts POST /diningts.json
|
def create
@diningt = Diningt.new(diningt_params)
respond_to do |format|
if @diningt.save
format.html { redirect_to @diningt, notice: 'Diningt was successfully created.' }
format.json { render :show, status: :created, location: @diningt }
else
format.html { render :new }
format.json { render json: @diningt.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n @dino = Dino.new(dino_params)\n\n if @dino.save\n render json: @dino, status: :created, location: @dino\n else\n render json: @dino.errors, status: :unprocessable_entity\n end\n end",
"def post(path, data = {})\n request 'POST', path, body: data.to_json\n end",
"def create\n @scrapping_datum = ScrappingDatum.new(scrapping_datum_params)\n\n respond_to do |format|\n if @scrapping_datum.save\n format.html { redirect_to @scrapping_datum, notice: 'Scrapping datum was successfully created.' }\n format.json { render :show, status: :created, location: @scrapping_datum }\n else\n format.html { render :new }\n format.json { render json: @scrapping_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_tenant_circle(args = {}) \n post(\"/tenantcircles.json/\", args)\nend",
"def post\n Typhoeus.post(@url,\n body: @results_hash.to_json,\n headers: { 'Content-Type' => 'application/json' })\n end",
"def create\n @dino = Dino.new(dino_params)\n\n respond_to do |format|\n if @dino.save\n format.html { redirect_to @dino, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @dino }\n else\n format.html { render :new }\n format.json{ render json: @dino.errors, status: :unprocessable_entity }\n end\n end\nend",
"def create\n @sighting = Sighting.new(sighting_params)\n\n if @sighting.save\n render json: @sighting, status: :created, location: @sighting\n else\n render json: @sighting.errors, status: :unprocessable_entity\n end\n end",
"def create\n @sighting = Sighting.new(sighting_params)\n\n if @sighting.save\n render json: @sighting, status: :created, location: @sighting\n else\n render json: @sighting.errors, status: :unprocessable_entity\n end\n end",
"def post(*args)\n request(:post, *args)\n end",
"def post(path, json, params = {})\n if path.include?('covid19')\n request = Net::HTTP::Post.new(path, @headers)\n else\n request = Net::HTTP::Post.new('/v2' + path, @headers)\n end\n request.add_field('Content-Type', 'application/json')\n request.body = json\n params.each do |k, v|\n request[k] = v\n end\n send_request(request)\n end",
"def create\n @track_dress = TrackDress.new(params[:track_dress])\n\n respond_to do |format|\n if @track_dress.save\n format.html { redirect_to @track_dress, notice: 'Track dress was successfully created.' }\n format.json { render json: @track_dress, status: :created, location: @track_dress }\n else\n format.html { render action: \"new\" }\n format.json { render json: @track_dress.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @trending = Trending.new(trending_params)\n\n respond_to do |format|\n if @trending.save\n format.html { redirect_to @trending, notice: 'Trending was successfully created.' }\n format.json { render :show, status: :created, location: @trending }\n else\n format.html { render :new }\n format.json { render json: @trending.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @trend = Trend.new(params[:trend])\n\n respond_to do |format|\n if @trend.save\n format.html { redirect_to @trend, :notice => 'Trend was successfully created.' }\n format.json { render :json => @trend, :status => :created, :location => @trend }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @trend.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post(*args)\n prepare_request(:post, args)\n @@client.add(:post, @path, *args)\n end",
"def create\n @dinner = Dinner.new(dinner_params)\n @dinner.host_id = @current_user.json_hash[:id]\n if @dinner.valid?\n @dinner.save\n render json: @dinner.all_info\n else\n puts @dinner.errors.messages.inspect\n render status: :bad_request, json: {\n errors: @dinner.errors.messages\n }\n end\n end",
"def post_spoonacular\n # %encode ingredients to url\n encoded_ingr = URI.escape(@translated_recipe[:ingredients_list])\n # post call block :\n url = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/parseIngredients?includeNutrition=true\")\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Post.new(url)\n request[\"content-type\"] = \"application/x-www-form-urlencoded\"\n request[\"x-rapidapi-key\"] = ENV[\"X_RAPIDAPI_KEY\"]\n request[\"x-rapidapi-host\"] = \"spoonacular-recipe-food-nutrition-v1.p.rapidapi.com\"\n # body of the call with ingredients and servings\n request.body = \"ingredientList=#{encoded_ingr}&#{@recipe_hash[:servings]}\"\n # response\n response = http.request(request)\n end",
"def post operation, data={}\n body = case data\n when String\n body = data\n else\n Yajl::Encoder.encode(data)\n end\n\n request = new_request operation, body\n request.sign sts\n hydra.queue request\n hydra.run\n response = request.response\n puts response.inspect if @debug\n\n if response.code == 200\n Yajl::Parser.parse response.body\n else\n raise_error response\n end\n end",
"def post(*args)\n request :post, *args\n end",
"def data_to_api(snack_name, snack_location, snack_optional)\n RestClient.post ENV['NERDERY_API'], { name: snack_name,\n location: snack_location,\n optional: snack_optional\n }.to_json, content_type: :json\n end",
"def create\n @trend = Trend.new(params[:trend])\n\n respond_to do |format|\n if @trend.save\n format.html { redirect_to @trend, notice: 'Trend was successfully created.' }\n format.json { render json: @trend, status: :created, location: @trend }\n else\n format.html { render action: \"new\" }\n format.json { render json: @trend.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(path, opts = {})\n request(:post, path, opts).body\n end",
"def post(path, data={})\n request(:post, path, data)\n end",
"def create\n\t\turi = URI.parse(Counter::Application.config.simplyurl)\n\t\thttp = Net::HTTP.new(uri.host, uri.port)\n\t\t\n\t\trequest = Net::HTTP::Post.new('/offsets.json')\n\t\tputs params\n\t\tputs params.slice(*['custids','acctids','itemids'])\n\t\t\n\t\t# ok, this join stuff is bogus - it encodes properly, but the other side only sees the last element and loses the array type - it's just string\n\t\t# this way, i 'split' it at the other side to recover my array\n\t\t# it should work without the join/split crap, but it doesn't\n\t\trequest.set_form_data({:custids => ( params['custids'] || []).join(','), :acctids => ( params['acctids'] || []).join(','), :itemids => ( params['itemids'] || []).join(','), :amount => params['amount'], :type => params['type']})\n\t\t\n\t\tputs request.body\n\t\t\n\t\tresponse = http.request(request)\n\t\tputs response.body\n\n respond_to do |format|\n format.html { render :text => response.code == :ok ? \"\" : response.body, status: response.code }\n format.json { render :text => response.code == :ok ? \"\" : response.body, status: response.code }\n end\n end",
"def create\n @dtest = Dtest.new(params[:dtest])\n\n respond_to do |format|\n if @dtest.save\n format.html { redirect_to @dtest, notice: t(:notise_test) }\n format.json { render json: @dtest, status: :created, location: @dtest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @dtest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @spdatum = Spdatum.new(params[:spdatum])\n\n respond_to do |format|\n if @spdatum.save\n format.html { redirect_to @spdatum, notice: 'Spdatum was successfully created.' }\n format.json { render json: @spdatum, status: :created, location: @spdatum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @spdatum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post endpoint, data\n do_request :post, endpoint, data\n end",
"def post\n Rentlinx.client.post(self)\n end",
"def post(path, **args); end",
"def create\n @dinner = Dinner.new(dinner_params)\n\n respond_to do |format|\n if @dinner.save\n format.html { redirect_to @dinner, notice: 'Dinner was successfully created.' }\n format.json { render :show, status: :created, location: @dinner }\n else\n format.html { render :new }\n format.json { render json: @dinner.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n dive = Dive.new(dive_params)\n if dive.save\n render json: dive\n else\n render json: {message: dive.errors}, status: 400\n end\n end",
"def create\n @draught = Draught.new(params[:draught])\n\n respond_to do |format|\n if @draught.save\n format.html { redirect_to(@draught, :notice => 'Draught was successfully created.') }\n format.xml { render :xml => @draught, :status => :created, :location => @draught }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @draught.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @dice = Dice.new(dice_params)\n\n if @dice.save\n render json: @dice, status: :created, location: @dice\n else\n render json: @dice.errors, status: :unprocessable_entity\n end\n end",
"def create\n render json: Dish.create(dish_params)\n end",
"def create\n @dailyStanding = DailyStanding.new(params[:dailyStanding])\n\n respond_to do |format|\n if @dailyStanding.save\n format.html { redirect_to @dailyStanding, :notice => 'DailyStanding was successfully created.' }\n format.json { render :json => @dailyStanding, :status => :created, :location => @dailyStanding }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @dailyStanding.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @dining = Dining.new(params[:dining])\n\n respond_to do |format|\n if @dining.save\n flash[:notice] = 'Dining was successfully created.'\n format.html { redirect_to(@dining) }\n format.xml { render :xml => @dining, :status => :created, :location => @dining }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @dining.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @dress = Dress.new(params[:dress])\n\n respond_to do |format|\n if @dress.save\n format.html { redirect_to @dress, notice: 'Dress was successfully created.' }\n format.json { render json: @dress, status: :created, location: @dress }\n else\n format.html { render action: \"new\" }\n format.json { render json: @dress.errors, status: :unprocessable_entity }\n end\n end\n end",
"def dinner_params\n params.require(:dinner).permit(:id, :dinner_date, :user_id, dinner_recipes_attributes: [:id, :recipe_id, :_destroy], dinner_guests_attributes: [:id, :guest_id, :_destroy])\n end",
"def POST; end",
"def collected_datum_params\n params.require(:collected_datum).permit(:turtle_id, :temperature, :deep, :light, :latitude, :longitude, :date)\n end",
"def api_post(path, data = {})\n api_request(:post, path, :data => data)\n end",
"def create\n @diemtrentuyen = Diemtrentuyen.new(params[:diemtrentuyen])\n\n respond_to do |format|\n if @diemtrentuyen.save\n format.html { redirect_to @diemtrentuyen, notice: 'Diemtrentuyen was successfully created.' }\n format.json { render json: @diemtrentuyen, status: :created, location: @diemtrentuyen }\n else\n format.html { render action: \"new\" }\n format.json { render json: @diemtrentuyen.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(path, form_data=nil)\n parse_json do |parser|\n @http_client.post(path, form_data) {|chunk| parser << chunk }\n end\n end",
"def post(path, params={})\n request(:post, path, params)\n end",
"def post(path, params={})\n request(:post, path, params)\n end",
"def post(path, params={})\n request(:post, path, params)\n end",
"def create\n @test_datum = TestDatum.new(test_datum_params)\n\n respond_to do |format|\n if @test_datum.save\n format.html { redirect_to @test_datum, notice: 'Test datum was successfully created.' }\n format.json { render :show, status: :created, location: @test_datum }\n else\n format.html { render :new }\n format.json { render json: @test_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @dolgnost = Dolgnost.new(params[:dolgnost])\n\n respond_to do |format|\n if @dolgnost.save\n format.html { redirect_to @dolgnost, notice: 'Dolgnost was successfully created.' }\n format.json { render json: @dolgnost, status: :created, location: @dolgnost }\n else\n format.html { render action: \"new\" }\n format.json { render json: @dolgnost.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(json)\n with_endpoint do |endpoint|\n url = [endpoint, @resource_name].compact.join('/')\n url += \"/\"\n return HTTParty.post(url, :body => json, :timeout => 4, :headers => { 'Content-Type' => 'application/json' })\n end\n end",
"def create\n @duty_station = DutyStation.new(params[:duty_station])\n\n respond_to do |format|\n if @duty_station.save\n format.html { redirect_to military_discounts_path, notice: 'Duty station was successfully created.' }\n format.json { render json: @duty_station, status: :created, location: @duty_station }\n else\n format.html { render action: \"new\" }\n format.json { render json: @duty_station.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(path, data = {}, params = {})\n body = data.to_json\n path = File.join(@prefix, path)\n\n response = @conn.post(path, body) do |req|\n req.params = params\n req.headers['Content-Type'] = 'application/json'\n end\n\n JSON.parse response.body\n end",
"def create\n sighting = Sighting.create(sighting_params)\n if sighting.valid?\n render json: sighting\n else\n render json: sighting.errors\n end\n end",
"def create\n\n @tracked_datum = TrackedDatum.new(tracked_datum_params)\n\n respond_to do |format|\n if @tracked_datum.save\n format.html { redirect_to @tracked_datum, notice: 'Tracked datum was successfully created.' }\n format.json { render :show, status: :created, location: @tracked_datum }\n else\n format.html { render :new }\n format.json { render json: @tracked_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @diet = Diet.new(diet_params)\n @diet.user = @current_user\n\n if @diet.save\n render json: @diet, status: 201, location: @diet, root: true\n else\n render json: @diet.errors, status: 422\n end\n end",
"def post(path, params = {})\n request(:post, path, params)\n end",
"def post(path, params = {})\n request(:post, path, params)\n end",
"def post(path, params = {})\n request(:post, path, params)\n end",
"def post(path, params = {})\n request(:post, path, params)\n end",
"def post(path, params = {})\n request(:post, path, params)\n end",
"def post(path, params={})\n RestClient.post request_base+path, params\n end",
"def post(path, params = {})\n request(:post, path, params)\n end",
"def dinner_params\n params.require(:dinner).permit(:currency, :image, :date, :location, :title, :description, :category, :price, :seats, :stamp)\n end",
"def post(*args)\n Request.post(*args)\n end",
"def post_request(path, params={}, options={})\n request(:post, path, params, options)\n end",
"def create\n render json: Beverage.create!(beverage_post_params), status: :created\n end",
"def create\n @dte = Dte.new(dte_params)\n\n respond_to do |format|\n if @dte.save\n format.html { redirect_to @dte, notice: 'Dte was successfully created.' }\n format.json { render :show, status: :created, location: @dte }\n else\n format.html { render :new }\n format.json { render json: @dte.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @skydatum = Skydatum.new(params[:skydatum])\n\n respond_to do |format|\n if @skydatum.save\n format.html { redirect_to @skydatum, notice: 'Skydatum was successfully created.' }\n format.json { render json: @skydatum, status: :created, location: @skydatum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @skydatum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tardy = Tardy.new(params[:tardy])\n\n respond_to do |format|\n if @tardy.save\n format.html { redirect_to @tardy, notice: 'Tardy was successfully created.' }\n format.json { render json: @tardy, status: :created, location: @tardy }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tardy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(path, params={}) # :nodoc:\n handle_response(@session.post(path, MultiJson.dump(params)))\n end",
"def create\n @stone = Stone.new(stone_params)\n\n \n if @stone.save\n respond_with @stone\n else\n render json: @stone.errors, status: :unprocessable_entity \n end\n \n \n end",
"def post(request)\n # sure thing!\n json_response(200, { message: \"This dummy POST endpoint didn't do anything.\" })\n end",
"def post(*args)\n super(*wrap_for_json_api(*args))\n end",
"def create\n @diet_dish = DietDish.new(diet_dish_params)\n\n respond_to do |format|\n if @diet_dish.save\n format.html { redirect_to @diet_dish, notice: 'Diet dish was successfully created.' }\n format.json { render action: 'show', status: :created, location: @diet_dish }\n else\n format.html { render action: 'new' }\n format.json { render json: @diet_dish.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(data = {})\n call data, method: :post\n end",
"def post options\n rest_request({ method: :post }.merge(options))\n end",
"def post options\n rest_request({ method: :post }.merge(options))\n end",
"def test_post_sample_traces\n header 'Content-Type', 'application/json'\n\n (0..4).each do |i|\n data = File.read \"sample-traces/#{i}.json\"\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n assert last_response.ok?\n end\n end",
"def post_json(path, body)\n uri = build_uri(path)\n puts \"*** POST #{path}\"\n puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n puts JSON.pretty_generate(result)\n result\nend",
"def post_json(path, body)\n uri = build_uri(path)\n #puts \"🤖 POST #{path}\"\n #puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n #puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n #puts result[:result]\n result\nend",
"def create\n @dailyfeatured = Dailyfeatured.new(dailyfeatured_params)\n\n respond_to do |format|\n if @dailyfeatured.save\n format.html { redirect_to @dailyfeatured, notice: 'Dailyfeatured was successfully created.' }\n format.json { render :show, status: :created, location: @dailyfeatured }\n else\n format.html { render :new }\n format.json { render json: @dailyfeatured.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(path, data=nil)\n request(:post, path, data)\n end",
"def create\n @drink = Drink.new(drink_params)\n\n respond_to do |format|\n if @drink.save\n format.html { redirect_to new_drink_path, notice: 'Drycken skapades.' }\n format.json { render :show, status: :created, location: @drink }\n else\n format.html { render :new }\n format.json { render json: @drink.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @downtime = Downtime.new(downtime_params)\n\n respond_to do |format|\n if @downtime.save\n format.html { redirect_to @downtime, notice: 'Downtime was successfully created.' }\n format.json { render action: 'show', status: :created, location: @downtime }\n else\n format.html { render action: 'new' }\n format.json { render json: @downtime.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @denuncium = Denuncium.new(params[:denuncium])\n\n respond_to do |format|\n if @denuncium.save\n format.html { redirect_to @denuncium, notice: 'Denuncium was successfully created.' }\n format.json { render json: @denuncium, status: :created, location: @denuncium }\n else\n format.html { render action: \"new\" }\n format.json { render json: @denuncium.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @dailystat = Dailystat.new(dailystat_params)\n\n respond_to do |format|\n if @dailystat.save\n format.html { redirect_to @dailystat, notice: 'Dailystat was successfully created.' }\n format.json { render :show, status: :created, location: @dailystat }\n else\n format.html { render :new }\n format.json { render json: @dailystat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def solicitar_lista_entregas_pdd pdd,kind,start_time,end_time\n require \"rubygems\"\n require 'json'\n require \"net/http\"\n require 'yaml'\n \n \n uri=URI( 'http://162.243.215.24/PDV/PDD_list_deliveries')\n \n resp = Net::HTTP.post_form(uri,'pddid'=>pdd,'kind'=>kind,'startime'=>start_time,'endtime'=>end_time,'token'=>\"mentira\")\n @record=JSON.parse(resp.body)\n @record\n #função ok\n \n end",
"def postReadings(info, state)\r\n params = {\r\n :device_id => info.deviceId,\r\n :sensor_data => [\r\n {\r\n :type => \"Temperature\",\r\n :value => state.temperature,\r\n :time => Time.now.to_i\r\n },\r\n {\r\n :type => \"Humidity\",\r\n :value => state.humidity,\r\n :time => Time.now.to_i\r\n }\r\n ]\r\n }\r\n res = apiPostJson(\"readings\", params)\r\n if res.status != 201\r\n $LOG.warn(\"Failed to post readings to backend! Status: #{res.status}, Response: #{res.body}\")\r\n end\r\n end",
"def post(path, arguments = {})\n perform_request { connection.post(path, arguments).body }\n end",
"def post(path, params = nil)\n response = @connection.post do |req|\n req.headers = generate_headers\n req.url path\n req.body = params.to_json\n end\n Arke::Log.fatal(build_error(response)) if response.env.status != 201\n response\n end",
"def post(path, params)\n request(:post, path, params)\n end",
"def tombstone_timehold_params\n params.require(:tombstone_timehold).permit(:tombstoneJSON, :permanent, :rating)\n end",
"def sighting_params\n params.require(:sighting).permit(:day, :latitude, :longitude)\n end",
"def create\n @deed = Deed.create(deed_params)\n\n if @deed.save\n render json: @deed, status: :created, location: @deed\n else\n render json: @deed.errors, status: :unprocessable_entity\n end\n end",
"def create\n @daughter = Daughter.new(daughter_params)\n\n respond_to do |format|\n if @daughter.save\n format.html { redirect_to @daughter, notice: 'Daughter was successfully created.' }\n format.json { render action: 'show', status: :created, location: @daughter }\n else\n format.html { render action: 'new' }\n format.json { render json: @daughter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @diningchair = Diningchair.new(diningchair_params)\n\n respond_to do |format|\n if @diningchair.save\n format.html { redirect_to @diningchair, notice: 'Diningchair was successfully created.' }\n format.json { render :show, status: :created, location: @diningchair }\n else\n format.html { render :new }\n format.json { render json: @diningchair.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(path, parameters = {})\n request(:post, path, parameters)\n end",
"def create\n @sleep_datum = SleepDatum.new(sleep_datum_params)\n\n respond_to do |format|\n if @sleep_datum.save\n format.html { redirect_to @sleep_datum, notice: 'Sleep datum was successfully created.' }\n format.json { render :show, status: :created, location: @sleep_datum }\n else\n format.html { render :new }\n format.json { render json: @sleep_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def diningt_params\n params.require(:diningt).permit(:title, :description, :price, :image, :previewo, :previewt, :previewth, :sdescription, :offerprice, :coupon, :brand, :color, :warrenty, :material)\n end",
"def create\n @meteo_datum = MeteoDatum.new(meteodatum_params)\n @meteo_datum.weather_station_id = params[:weather_station_id]\n\n if @meteo_datum.save\n render json: @meteo_datum, status: :created\n else\n render json: @meteo_datum.errors, status: :unprocessable_entity\n end\n end",
"def post(path, params = {})\n\t\trequest(path, :post, params)\n\tend",
"def post_api(path, params={}, headers={})\n headers.merge!('CONTENT_TYPE' => \"application/json\")\n post path, params, headers\nend"
] |
[
"0.5908641",
"0.58811843",
"0.57162154",
"0.56615084",
"0.56588924",
"0.5652193",
"0.5630965",
"0.5581175",
"0.5578508",
"0.5555963",
"0.5536668",
"0.5527933",
"0.55238193",
"0.54983556",
"0.5497054",
"0.5462751",
"0.5457966",
"0.54449415",
"0.54132146",
"0.54127806",
"0.5405589",
"0.5403438",
"0.540168",
"0.53814185",
"0.537973",
"0.53715247",
"0.5369171",
"0.5356602",
"0.53537244",
"0.53536785",
"0.5351758",
"0.5349046",
"0.5344703",
"0.53309494",
"0.53263915",
"0.5315881",
"0.5309885",
"0.52950704",
"0.5292398",
"0.5288825",
"0.5286186",
"0.52858645",
"0.52812344",
"0.52812344",
"0.52812344",
"0.52800983",
"0.527243",
"0.52693164",
"0.52625704",
"0.52481806",
"0.52407587",
"0.52400863",
"0.5235497",
"0.522465",
"0.522465",
"0.522465",
"0.522465",
"0.522465",
"0.521139",
"0.5210165",
"0.52079284",
"0.52036756",
"0.5201516",
"0.51995856",
"0.5196396",
"0.51927084",
"0.51884544",
"0.51873434",
"0.51868254",
"0.51781565",
"0.5173045",
"0.5172693",
"0.5169758",
"0.51654714",
"0.51654714",
"0.5159401",
"0.5159295",
"0.5156621",
"0.5156265",
"0.5150088",
"0.51473486",
"0.5138198",
"0.51356095",
"0.51289886",
"0.5128934",
"0.51243687",
"0.51219577",
"0.51217383",
"0.5117996",
"0.5116625",
"0.5112478",
"0.51121706",
"0.5108128",
"0.51071525",
"0.5106512",
"0.5105044",
"0.5104409",
"0.5103248",
"0.50940955",
"0.50922966"
] |
0.6290197
|
0
|
PATCH/PUT /diningts/1 PATCH/PUT /diningts/1.json
|
def update
respond_to do |format|
if @diningt.update(diningt_params)
format.html { redirect_to @diningt, notice: 'Diningt was successfully updated.' }
format.json { render :show, status: :ok, location: @diningt }
else
format.html { render :edit }
format.json { render json: @diningt.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end",
"def patch!\n request! :patch\n end",
"def update # PATCH\n raise NotImplementedError\n end",
"def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def patch(path, **args); end",
"def patch(path, params = {})\n request(:patch, path, params)\n end",
"def patch(path, params = {})\n request(:patch, path, params)\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def update\n @todo = Todo.find(params[:id])\n @todo.update_attributes(params[:todo])\n render :json => @todo\n end",
"def patch(path, opts = {})\n request(:patch, path, opts).body\n end",
"def update\n keystone.update_tenant({:id=>params[:id],:name=>params[:name],:description=>params[:description],:enabled=>params[:enabled]})\n respond_to do |format|\n format.html { redirect_to tenants_path, :notice => 'Tenant was successfully updated.' }\n format.json { head :ok }\n end\n end",
"def patch(path, data, params = {}, request_options = {})\n request(:patch, path, data, params)\n end",
"def patch options\n rest_request({ method: :patch }.merge(options))\n end",
"def patch options\n rest_request({ method: :patch }.merge(options))\n end",
"def update_tenant_maintenance_window(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/maintenance/{tenantId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"tenantId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def update\n respond_to do |format|\n if @api_v1_todo.update(api_v1_todo_params)\n format.json { render json: @api_v1_todo, status: :ok }\n else\n format.json { render json: @api_v1_todo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n dream = Dream.find params[:id]\n dream.update dream_params\n render json: {dream: dream}\n end",
"def update\n @serving = Serving.find(params[:id])\n\n respond_to do |format|\n if @serving.update_attributes(params[:serving])\n format.html { redirect_to @serving, notice: 'Serving was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @serving.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n put :update\n end",
"def update\n respond_to do |format|\n if @kota_stone.update(kota_stone_params)\n format.html { redirect_to kota_stones_url, notice: 'Kota stone was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @kota_stone.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @todo = Todo.find(params[:id])\n if @todo.update_attributes(todo_params)\n render json: @todo, status: :ok\n else\n render json: @todo.errors, status: 422\n end\n end",
"def update\n respond_to do |format|\n if @downtime.update(downtime_params)\n format.html { redirect_to @downtime, notice: 'Downtime was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @downtime.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(path)\n output { patch(path, params) }\n end",
"def update(&block)\n validate_request()\n\n # Params includes all of the PATCH data at the top level along with other\n # other Rails-injected params like 'id', 'action', 'controller'. These\n # are harmless given no namespace collision and we're only interested in\n # the 'Operations' key for the actual patch data.\n #\n render(json: yield(self.safe_params()[:id], self.safe_params().to_hash()))\n end",
"def patch\n end",
"def update_current_tenant_maintenance_window(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/maintenance\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"tenantId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def put!\n request! :put\n end",
"def update\n @data = @recipe.update(params[:id], recipe_params)\n render json: @data\n end",
"def update\n respond_to do |format|\n if @tottle.update(tottle_params)\n format.html { redirect_to @tottle, notice: 'Tottle was successfully updated.' }\n format.json { render :show, status: :ok, location: @tottle }\n else\n format.html { render :edit }\n format.json { render json: @tottle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(attrs, path=nil)\n resp = api_client.put(path || url, JSON.dump(attrs))\n refresh(JSON.load(resp.body))\n end",
"def update\n @patch = Patch.find(params[:id])\n\n respond_to do |format|\n if @patch.update_attributes(params[:patch])\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @diet.update(diet_params)\n head :no_content, status: 204\n else\n render json: @diet.errors, status: 422\n end\n end",
"def patch(path, body_params = {})\n debug_log \"PATCH #{@host}#{path} body:#{body_params}\"\n headers = { 'Content-Type' => 'application/json' }\n res = connection.run_request :put, path, body_params.to_json, headers\n debug_log \"Response status:#{res.status}, body:#{res.body}\"\n res\n end",
"def update\n respond_to do |format|\n if @tangent.update(tangent_params)\n format.html { redirect_to @tangent, notice: 'Tangent was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tangent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @interesting = Interesting.find(params[:id])\n\n respond_to do |format|\n if @interesting.update_attributes(params[:interesting])\n format.html { redirect_to @interesting, notice: 'Interesting was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @interesting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(path, params)\n time(\"PATCH #{path}\") { Cloudflarer.new.patch(path, params) }\n end",
"def update\n respond_to do |format|\n if @stuck.update(stuck_params)\n format.html { redirect_to @stuck, notice: 'Stuck was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @stuck.errors, status: :unprocessable_entity }\n end\n end\n end",
"def UpdateView params = {}\n \n APICall(path: 'views.json',method: 'PUT',payload: params.to_json)\n \n end",
"def update\n @interested = Interested.find(params[:id])\n\n respond_to do |format|\n if @interested.update_attributes(params[:interested])\n format.html { redirect_to @interested, notice: 'Interested was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @interested.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @person.seat\n render json: {errors: 'Cannot update a seated person'}, status: 422\n else\n @person.update person_params\n render json: @person\n end\n end",
"def update\n recipe.update(recipe_params)\n render json: recipe\n end",
"def update(*args)\n put(*args)\n end",
"def update(*args)\n put(*args)\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\n @todo = Todo.find(params[:id])\n if @todo.update(todo_params)\n render json: @todo\n else\n render json: @todo.errors, status: :unprocessable_entity\n end\n end",
"def update\n @tripdate = Tripdate.find(params[:id])\n\n respond_to do |format|\n if @tripdate.update_attributes(params[:tripdate])\n format.html { redirect_to @tripdate, notice: 'Tripdate was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tripdate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @duck.update_attributes(params[:duck])\n format.html { redirect_to @duck, notice: 'Duck was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @duck.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(id, json)\n with_endpoint do |endpoint|\n url = [endpoint, @resource_name, id].compact.join('/')\n url += \"/\" \n return HTTParty.put(url, :body => json, :timeout => 4, :headers => { 'Content-Type' => 'application/json' })\n end\n end",
"def update\n respond_to do |format|\n if @snipet.update(snipet_params)\n format.html { redirect_to @snipet, notice: 'Snipet was successfully updated.' }\n format.json { render :show, status: :ok, location: @snipet }\n else\n format.html { render :edit }\n format.json { render json: @snipet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @traceroute.update(traceroute_params)\n format.html { redirect_to @traceroute, notice: 'Traceroute was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @traceroute.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @traceroute.update(traceroute_params)\n format.html { redirect_to @traceroute, notice: 'Traceroute was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @traceroute.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @task_entry.update(task_entry_params)\n format.json { head :no_content }\n else\n format.json { render json: @task_entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n \t\t@interested = Interested.find(params[:id])\n\n \t\trespond_to do |format|\n \t\t\tif @interested.update_attributes(params[:interested])\n \t\t\tformat.html { redirect_to @interested, notice: 'Interested was sucessfully updated.' }\n \t\t\tformat.json {head :no_content }\n \t\t\telse\n \t\t\t\tformat.html { render action: \"edit\" }\n \t\t\t\tformat.json { render json: @interested.error, status: :unprocessable_entity }\n \t\t\tend\n \t\tend\n \tend",
"def update\n @spdatum = Spdatum.find(params[:id])\n\n respond_to do |format|\n if @spdatum.update_attributes(params[:spdatum])\n format.html { redirect_to @spdatum, notice: 'Spdatum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @spdatum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @stoff.update(stoff_params)\n format.html { redirect_to @stoff }\n format.json { render :show, status: :ok, location: @stoff }\n else\n format.html { render :edit }\n format.json { render json: @stoff.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @staffer = Staffer.find(params[:id])\n\n respond_to do |format|\n if @staffer.update_attributes(params[:staffer])\n format.html { redirect_to @staffer, notice: 'Staffer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @staffer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @stone = Stone.find(params[:id])\n\n respond_to do |format|\n if @stone.update_attributes(params[:stone])\n format.html { redirect_to @stone, notice: 'Stone was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @stone.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # respond_to do |format|\n # if @kitchen.update_attributes(post_params)\n # format.html { redirect_to @kitchen, notice: 'Kitchen was successfully updated.' }\n # format.json { head :no_content }\n # else\n # format.html { render action: 'edit' }\n # format.json { render json: @kitchen.errors, status :unprocessable_entity }\n # end\n # end\n end",
"def update\n respond_to do |format|\n if @json.update(json_params)\n format.html { redirect_to @json, notice: 'Json was successfully updated.' }\n format.json { render :show, status: :ok, location: @json }\n else\n format.html { render :edit }\n format.json { render json: @json.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @json.update(json_params)\n format.html { redirect_to @json, notice: 'Json was successfully updated.' }\n format.json { render :show, status: :ok, location: @json }\n else\n format.html { render :edit }\n format.json { render json: @json.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @thing = Thing.find(params[:id])\n\n respond_to do |format|\n if @thing.update_attributes(params[:thing])\n format.html { redirect_to things_path, notice: 'Your thing was successfully updated!' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @thing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(type, info)\n path, info = type_info(type, :path), force_case(info)\n ida = type == :client ? 'client_id' : 'id'\n raise ArgumentError, \"info must include #{ida}\" unless id = info[ida]\n hdrs = headers\n if info && info['meta'] && (etag = info['meta']['version'])\n hdrs.merge!('if-match' => etag)\n end\n reply = json_parse_reply(@key_style,\n *json_patch(@target, \"#{path}/#{Addressable::URI.encode(id)}\", info, hdrs))\n\n # hide client endpoints that are not quite scim compatible\n type == :client && !reply ? get(type, info['client_id']): reply\n end",
"def update\n respond_to do |format|\n if @request_datum.update(request_datum_params)\n format.html { redirect_to @request_datum, notice: 'Request datum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @request_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n id = shift_argument\n validate_arguments!\n dataclip_reference = options[:dataclip]\n uri = URI(\"#{base_url}/#{id}\")\n req = Net::HTTP::Patch.new(uri.path)\n body = prepare_body(dataclip_reference)\n execute_and_print(uri, req, body)\n end",
"def update\n # respond_to do |format|\n # if @thing.update(thing_params)\n # format.html { redirect_to @thing, notice: 'Thing was successfully updated.' }\n # format.json { render :show, status: :ok, location: @thing }\n # else\n # format.html { render :edit }\n # format.json { render json: @thing.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def update\n respond_to do |format|\n if @sivic_discipulo.update(sivic_discipulo_params_netested)\n format.html { redirect_to @sivic_discipulo, notice: 'Registro alterado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sivic_discipulo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @hack.update_attributes(params[:hack])\n format.html { redirect_to @event, :notices => ['Hack was successfully updated.'] }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @hack.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @flight = Flight.find(params[:id])\n\n if @flight.update(params[:flight])\n head :no_content\n else\n render json: @flight.errors, status: :unprocessable_entity\n end\n end",
"def update(data = :object || :json)\n end",
"def update\n respond_to do |format|\n if @stalkee.update(stalkee_params)\n format.html { redirect_to @stalkee, notice: 'Stalkee was successfully updated.' }\n format.json { render :show, status: :ok, location: @stalkee }\n else\n format.html { render :edit }\n format.json { render json: @stalkee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n update_resource @ride, ride_params\n end",
"def update\n ingredient.update(ingredient_params)\n render json: ingredient\n end",
"def update(id, attributes)\n # attributes = {name: 'chocolate and peanuts', calories: 10}\nend",
"def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end",
"def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end",
"def update\n @dining = Dining.find(params[:id])\n\n respond_to do |format|\n if @dining.update_attributes(params[:dining])\n flash[:notice] = 'Dining was successfully updated.'\n format.html { redirect_to(@dining) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @dining.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @get_in_touch.update(get_in_touch_params)\n format.html { redirect_to @get_in_touch, notice: 'Get in touch was successfully updated.' }\n format.json { render :show, status: :ok, location: @get_in_touch }\n else\n format.html { render :edit }\n format.json { render json: @get_in_touch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @thing = Thing.find(params[:id])\n\n respond_to do |format|\n if @thing.update_attributes(params[:thing])\n format.html { redirect_to @thing, notice: 'Thing was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @thing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @kitten = Kitten.find(params[:id])\n\n respond_to do |format|\n if @kitten.update_attributes(params[:kitten])\n format.html { redirect_to @kitten, notice: 'Kitten was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kitten.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @serving.update(serving_params)\n format.html { redirect_to @serving, notice: 'Serving was successfully updated.' }\n format.json { render :show, status: :ok, location: @serving }\n else\n format.html { render :edit }\n format.json { render json: @serving.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tenancy.update(tenancy_params)\n format.html { redirect_to @tenancy, notice: 'Tenancy was successfully updated.' }\n format.json { render :show, status: :ok, location: @tenancy }\n else\n format.html { render :edit }\n format.json { render json: @tenancy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @daily_intake.update(daily_intake_params)\n format.html { redirect_to @daily_intake, notice: 'Daily intake was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @daily_intake.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(resource,identifier,json)\n raise 'Not Yet Implemented'\n end",
"def update\n @stage_drymass = StageDrymass.find(params[:id])\n\n respond_to do |format|\n if @stage_drymass.update_attributes(params[:stage_drymass])\n format.html { redirect_to @stage_drymass, notice: 'Stage drymass was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @stage_drymass.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n# respond_to do |format|\n# if @req.update(req_params)\n format.json { render :json => {:status => 'success'}}\n# format.html { redirect_to @req, notice: 'Req was successfully updated.' }\n# format.json { render :show, status: :ok, location: @req }\n# else\n format.json { render :json => {:status => 'failed'}}\n# format.html { render :edit }\n# format.json { render json: @req.errors, status: :unprocessable_entity }\n# end\n# end\n end",
"def update\n respond_to do |format|\n if @thing_to_do.update(thing_to_do_params)\n format.html { redirect_to @thing_to_do, notice: 'Thing to do was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @thing_to_do.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bottle.update(bottle_params)\n format.html { redirect_to user_path(current_user.id), notice: 'Bottle was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bottle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @rest.update(rest_params)\n format.html { redirect_to @rest, notice: 'Rest was successfully updated.' }\n format.json { render :show, status: :ok, location: @rest }\n else\n format.html { render :edit }\n format.json { render json: @rest.errors, status: :unprocessable_entity }\n end\n end\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\n respond_to do |format|\n if @srticle.update(srticle_params)\n format.html { redirect_to @srticle, notice: 'Srticle was successfully updated.' }\n format.json { render :show, status: :ok, location: @srticle }\n else\n format.html { render :edit }\n format.json { render json: @srticle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @patch.update(patch_params)\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @slashdot_posting.update(slashdot_posting_params)\n format.html { redirect_to @slashdot_posting, notice: 'Slashdot posting was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @slashdot_posting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @gotcha = Gotcha.find(params[:id])\n\n respond_to do |format|\n if @gotcha.update_attributes(params[:gotcha])\n format.html { redirect_to @gotcha, notice: 'Gotcha was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @gotcha.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n render json: Post.update(params[\"id\"], params[\"post\"])\n end",
"def update\n @one_time_stop = OneTimeStop.find(params[:id])\n\n respond_to do |format|\n if @one_time_stop.update_attributes(params[:one_time_stop])\n format.html { redirect_to @one_time_stop, notice: 'One time stop was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @one_time_stop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @dteor = Dteor.find(params[:id])\n\n respond_to do |format|\n if @dteor.update_attributes(params[:dteor])\n format.html { redirect_to @dteor, notice: t(:updated) }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @dteor.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.67739964",
"0.6754369",
"0.6585494",
"0.6559263",
"0.65169626",
"0.63566947",
"0.6331992",
"0.62543374",
"0.6231796",
"0.6223077",
"0.6223077",
"0.6215657",
"0.61544627",
"0.61350644",
"0.61336416",
"0.6125809",
"0.6101666",
"0.6101666",
"0.6080951",
"0.607152",
"0.60676557",
"0.60669434",
"0.603864",
"0.6015267",
"0.5994159",
"0.59925425",
"0.59858423",
"0.5983163",
"0.595857",
"0.59487516",
"0.5945703",
"0.5935833",
"0.5934814",
"0.5933343",
"0.5917174",
"0.59170115",
"0.59142005",
"0.5911644",
"0.589853",
"0.5880857",
"0.5873136",
"0.5871243",
"0.58625215",
"0.584881",
"0.5847708",
"0.58455896",
"0.58455896",
"0.58452207",
"0.5841327",
"0.5836096",
"0.58251184",
"0.5819004",
"0.58117366",
"0.5811694",
"0.58111453",
"0.5811121",
"0.5806849",
"0.5805376",
"0.5805007",
"0.5803929",
"0.5803763",
"0.58003235",
"0.5797804",
"0.5797804",
"0.5790406",
"0.5783196",
"0.5780898",
"0.5778032",
"0.57749164",
"0.5774787",
"0.57691085",
"0.57679945",
"0.5767296",
"0.5763806",
"0.576366",
"0.5763469",
"0.5762948",
"0.5762885",
"0.5762885",
"0.5762426",
"0.5755657",
"0.5753322",
"0.575322",
"0.5752291",
"0.57510215",
"0.57509583",
"0.57468736",
"0.5746072",
"0.5741911",
"0.5740372",
"0.57373816",
"0.57368857",
"0.5733427",
"0.57332796",
"0.57321274",
"0.57318866",
"0.5730005",
"0.57297033",
"0.5727091",
"0.5725324"
] |
0.6174379
|
12
|
DELETE /diningts/1 DELETE /diningts/1.json
|
def destroy
@diningt.destroy
respond_to do |format|
format.html { redirect_to diningts_url, notice: 'Diningt was successfully destroyed.' }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def delete\n client.delete(\"/#{id}\")\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"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(path)\n RestClient.delete request_base+path\n end",
"def delete\n client.delete(url)\n @deleted = true\nend",
"def delete\n request(:delete)\n end",
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def delete\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n message[:data].each do |sub|\n id = sub[:id]\n delRes = HTTParty.delete \"#{URL}/#{id}\", headers: HEADERS\n #TODO handle status codes\n end\n end\n end\n end",
"def delete(*args)\n prepare_request(:delete, args)\n @@client.add(:delete, @path, *args)\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 delete\n start { |connection| connection.request http :Delete }\n end",
"def api_delete(path, data = {})\n api_request(:delete, path, :data => data)\n end",
"def delete(path)\n request(:delete, path)\n end",
"def delete(*rest) end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete(*args)\n request(:delete, *args)\n end",
"def delete\n\n end",
"def delete\n \n end",
"def delete(path, params = {})\n post(path, params.merge(\"_method\" => \"delete\"))\n end",
"def delete(path)\n\t\trequest(path, :delete)\n\tend",
"def delete\n end",
"def delete(path)\n request 'DELETE', path\n end",
"def delete(options={})\n connection.delete(\"/\", @name)\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n api(\"Delete\")\n end",
"def delete\n url = prefix + \"delete\" + id_param\n return response(url)\n end",
"def delete(url, headers = {})\n http :delete, \"#{url}.json\", headers\n end",
"def destroy\n @dart = Dart.find(params[:id])\n @dart.destroy\n\n respond_to do |format|\n format.html { redirect_to darts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kota_stone.destroy\n respond_to do |format|\n format.html { redirect_to kota_stones_url }\n format.json { head :no_content }\n end\n end",
"def delete(id)\n request(:delete, \"/recipes/#{id}.json\")\n end",
"def delete\n response = WebPay.client.delete(path)\n response['deleted']\n end",
"def delete!\n request! :delete\n end",
"def delete\n \n end",
"def delete!( opts = {} )\n http_action :delete, nil, opts\n end",
"def delete(path, params)\n parse_response @client[path].delete(:params => params)\n end",
"def delete(path)\n request(:delete, path)\n end",
"def delete(path)\n path = relativize_path path\n\n Precog.connect self do |http|\n uri = Addressable::URI.new\n uri.query_values = { :apiKey => api_key }\n\n http.delete \"/ingest/v#{VERSION}/fs/#{path}?#{uri.query}\"\n end\n end",
"def delete_item(id)\n record \"/todos/delete_item/#{id}\"\n end",
"def delete(path)\n repository = path.split(/\\//)[2]\n objectid = path.split(/\\//)[3]\n if storage_fetch(repository, objectid) && storage_delete(repository, objectid)\n ['200', {}, []]\n else\n ['404', {}, [\"Repository #{repository} or ObjectID #{objectid} not found: #{path}\"]]\n end\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def destroy\n @daily_intake.destroy\n respond_to do |format|\n format.html { redirect_to daily_intakes_url }\n format.json { head :no_content }\n end\n end",
"def delete\n execute_request('DELETE') do |uri, headers|\n HTTP.http_client.delete(uri, header: headers)\n end\n end",
"def delete endpoint\n do_request :delete, endpoint\n end",
"def delete\n render json: Item.delete(params[\"id\"])\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 delete\n RestClient.delete(url, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end",
"def destroy\n @diet_dish.destroy\n respond_to do |format|\n format.html { redirect_to diet_dishes_url }\n format.json { head :no_content }\n end\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete\n delete_from_server single_url\n end",
"def delete\n render json: Post.delete(params[\"id\"])\n end",
"def deletef\n url = prefix + \"deletef\" + id_param\n return response(url)\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def incident_delete(statuspage_id, incident_id)\n data = {}\n data['statuspage_id'] = statuspage_id\n data['incident_id'] = incident_id\n\n request :method => :post,\n :url => @url + 'incident/delete',\n :payload => data\n end",
"def delete(path)\n make_call(mk_conn(path), :delete)\n end",
"def delete(*args)\n execute(:delete, *args)\n end",
"def do_delete(uri = \"\")\n @connection.delete do |req|\n req.url uri\n req.headers['Content-Type'] = 'application/json'\n end\n end",
"def delete\n Iterable.request(conf, base_path).delete\n end",
"def DeleteView id\n \n APICall(path: \"views/#{id}.json\",method: 'DELETE')\n \n end",
"def delete(path, params = {})\n request(:delete, path, params)\n end",
"def delete(path, params = {})\n request(:delete, path, params)\n end",
"def delete(path, params = {})\n request(:delete, path, params)\n end",
"def delete(path, data = {})\n self.class.delete path, :body => data.merge(:u => access_token)\n end",
"def test_delete1()\n key = \"_Delete1\"\n c = Scalaroid::JSONConnection.new(url = Scalaroid::DEFAULT_URL)\n rdht = Scalaroid::ReplicatedDHT.new(conn = c)\n sc = Scalaroid::TransactionSingleOp.new(conn = c)\n\n (0..($_TEST_DATA.length - 1)).each do |i|\n sc.write(@testTime.to_s + key + i.to_s, $_TEST_DATA[i])\n end\n\n # now try to delete the data:\n (0..($_TEST_DATA.length - 1)).each do |i|\n ok = rdht.delete(@testTime.to_s + key + i.to_s)\n assert_equal(4, ok)\n results = rdht.get_last_delete_result()\n assert_equal(4, results.ok)\n assert_equal(0, results.locks_set)\n assert_equal(0, results.undefined)\n _checkKeyDoesNotExist(@testTime.to_s + key + i.to_s)\n\n # try again (should be successful with 0 deletes)\n ok = rdht.delete(@testTime.to_s + key + i.to_s)\n assert_equal(0, ok)\n results = rdht.get_last_delete_result()\n assert_equal(0, results.ok)\n assert_equal(0, results.locks_set)\n assert_equal(4, results.undefined)\n _checkKeyDoesNotExist(@testTime.to_s + key + i.to_s)\n end\n\n c.close()\n end",
"def destroy\n @dtest = Dtest.find(params[:id])\n @dtest.destroy\n\n respond_to do |format|\n format.html { redirect_to dtests_url, notice: t(:dest_test) }\n format.json { head :no_content }\n end\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete\n super \"/templates/#{template_id}.json\", {}\n end",
"def delete(path, params = {})\n debug_log \"DELETE #{@host}#{path} params:#{params}\"\n res = connection.delete path, params\n debug_log \"Response status:#{res.status}, body:#{res.body}\"\n res\n end",
"def destroy\n @crowd = Crowd.find(params[:id])\n @crowd.destroy\n\n respond_to do |format|\n format.html { redirect_to crowds_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @downtime.destroy\n respond_to do |format|\n format.html { redirect_to downtimes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @slashdot_posting.destroy\n respond_to do |format|\n format.html { redirect_to slashdot_postings_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @json.destroy\n respond_to do |format|\n format.html { redirect_to jsons_url, notice: 'Json was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @json.destroy\n respond_to do |format|\n format.html { redirect_to jsons_url, notice: 'Json was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @datoscontacto = Datoscontacto.find(params[:id])\n @datoscontacto.destroy\n\n respond_to do |format|\n format.html { redirect_to datoscontactos_url }\n format.json { head :no_content }\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 delete(path, params = {})\n request(:delete, path, params)\n end",
"def delete(path, params = {})\n request(:delete, path, params)\n end",
"def destroy\n @line_item1 = LineItem1.find(params[:id])\n @line_item1.destroy\n\n respond_to do |format|\n format.html { redirect_to line_item1s_url }\n format.json { head :no_content }\n end\n end",
"def delete(path, params)\n request(:delete, path, {})\n end",
"def delete!\n Recliner.delete(uri)\n end",
"def delete_data\n response = WebPay.client.delete([path, 'data'].join('/'))\n response['deleted']\n end",
"def destroy\n @drip = Drip.find(params[:id])\n @drip.destroy\n\n respond_to do |format|\n format.html { redirect_to drips_url }\n format.json { head :no_content }\n end\n end"
] |
[
"0.7293433",
"0.69377613",
"0.69345194",
"0.6934444",
"0.6899812",
"0.6874044",
"0.67440325",
"0.67236",
"0.6709017",
"0.6699786",
"0.668089",
"0.6676442",
"0.6676442",
"0.6676442",
"0.6676442",
"0.6642736",
"0.6636409",
"0.66261876",
"0.66188353",
"0.66100144",
"0.66100144",
"0.6588247",
"0.65808535",
"0.6578082",
"0.6570949",
"0.65612704",
"0.65598845",
"0.65515393",
"0.6544536",
"0.6540003",
"0.6540003",
"0.6540003",
"0.6540003",
"0.6540003",
"0.6540003",
"0.6540003",
"0.6531781",
"0.6529423",
"0.65190023",
"0.6504445",
"0.6476481",
"0.64703876",
"0.64702225",
"0.64700663",
"0.6463713",
"0.645389",
"0.64486563",
"0.6445391",
"0.6434326",
"0.64288515",
"0.64270115",
"0.6417293",
"0.64096266",
"0.6408824",
"0.6405264",
"0.64042795",
"0.6401952",
"0.6396494",
"0.639132",
"0.63895905",
"0.63895905",
"0.63895905",
"0.63895905",
"0.63895905",
"0.63895905",
"0.63895905",
"0.6389024",
"0.63886034",
"0.6379075",
"0.6377951",
"0.6377951",
"0.63774264",
"0.63744396",
"0.63736874",
"0.6371079",
"0.6370826",
"0.6367699",
"0.63651925",
"0.63651925",
"0.63651925",
"0.6363941",
"0.6363407",
"0.635878",
"0.6358186",
"0.6357134",
"0.6357028",
"0.6351603",
"0.6340529",
"0.6339119",
"0.63256884",
"0.63256884",
"0.6325571",
"0.63245547",
"0.6322142",
"0.6322142",
"0.63220805",
"0.63206536",
"0.6318454",
"0.63165665",
"0.6316038"
] |
0.65600306
|
26
|
Use callbacks to share common setup or constraints between actions.
|
def set_diningt
@diningt = Diningt.find(params[:id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def set_actions\n actions :all\n end",
"def define_action_helpers?; end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup_handler\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 set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def workflow\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def setup\n # override and do something appropriate\n end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def 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 startcompany(action)\n @done = true\n action.setup\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 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 action\n end",
"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 after_set_callback; end",
"def initialize(*args)\n super\n @action = :set\nend",
"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 around_hooks; end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def save_action; end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def setup(&blk)\n @setup_block = blk\n end",
"def default_action; end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def call\n setup_context\n super\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",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def duas1(action)\n action.call\n action.call\nend"
] |
[
"0.61637366",
"0.60446453",
"0.59452957",
"0.591511",
"0.58885515",
"0.5834122",
"0.57761765",
"0.5702554",
"0.5702554",
"0.5652102",
"0.5619581",
"0.5423898",
"0.5409782",
"0.5409782",
"0.5409782",
"0.5394745",
"0.53780794",
"0.5356209",
"0.5338898",
"0.53381324",
"0.5328622",
"0.5309231",
"0.5296901",
"0.529641",
"0.5296097",
"0.5258364",
"0.5242683",
"0.5236372",
"0.5236372",
"0.5236372",
"0.5236372",
"0.5236372",
"0.52346426",
"0.52320486",
"0.5225926",
"0.52210605",
"0.52171826",
"0.52138335",
"0.5207914",
"0.52069265",
"0.5176269",
"0.5174653",
"0.51730466",
"0.51650184",
"0.5161409",
"0.5156175",
"0.5154185",
"0.5151096",
"0.5151089",
"0.51452935",
"0.5138662",
"0.51339483",
"0.5113475",
"0.51132",
"0.51132",
"0.5108031",
"0.51075375",
"0.5090693",
"0.50892115",
"0.5081523",
"0.5081454",
"0.5064919",
"0.50545585",
"0.50531805",
"0.50501585",
"0.50501585",
"0.50329936",
"0.5024674",
"0.50203156",
"0.50156844",
"0.50149846",
"0.50011337",
"0.4999346",
"0.49984375",
"0.4988749",
"0.4988749",
"0.49842322",
"0.49800175",
"0.4979922",
"0.49791628",
"0.49666047",
"0.49655434",
"0.49559638",
"0.49557537",
"0.49554902",
"0.4953974",
"0.49519545",
"0.49449277",
"0.49440357",
"0.49329734",
"0.49315402",
"0.49261367",
"0.4925912",
"0.4925598",
"0.4924306",
"0.49202663",
"0.49167567",
"0.49164373",
"0.4915191",
"0.49145022",
"0.49140996"
] |
0.0
|
-1
|
Never trust parameters from the scary internet, only allow the white list through.
|
def diningt_params
params.require(:diningt).permit(:title, :description, :price, :image, :previewo, :previewt, :previewth, :sdescription, :offerprice, :coupon, :brand, :color, :warrenty, :material)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def valid_params_request?; end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def url_whitelist; 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 admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def backend_user_params\n params.permit!\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] |
[
"0.6981273",
"0.6783789",
"0.67460483",
"0.6742222",
"0.67354137",
"0.65934366",
"0.65028495",
"0.6497783",
"0.64826745",
"0.6479415",
"0.6456823",
"0.6440081",
"0.63800216",
"0.6376521",
"0.636652",
"0.6319898",
"0.6300256",
"0.62994003",
"0.6293621",
"0.6292629",
"0.6291586",
"0.629103",
"0.6282451",
"0.6243152",
"0.62413",
"0.6219024",
"0.6213724",
"0.62103724",
"0.61945",
"0.61786324",
"0.61755824",
"0.6173267",
"0.6163613",
"0.6153058",
"0.61521065",
"0.6147508",
"0.61234015",
"0.61168665",
"0.6107466",
"0.6106177",
"0.6091159",
"0.60817343",
"0.6071238",
"0.6062299",
"0.6021663",
"0.60182893",
"0.6014239",
"0.6011563",
"0.60080767",
"0.60080767",
"0.60028875",
"0.60005623",
"0.59964156",
"0.5993086",
"0.5992319",
"0.5992299",
"0.59801805",
"0.59676576",
"0.59606016",
"0.595966",
"0.59591126",
"0.59589803",
"0.5954058",
"0.5953234",
"0.5944434",
"0.5940526",
"0.59376484",
"0.59376484",
"0.5935253",
"0.5930846",
"0.5926387",
"0.59256274",
"0.5917907",
"0.5910841",
"0.590886",
"0.59086543",
"0.59060425",
"0.58981544",
"0.5898102",
"0.5896809",
"0.5895416",
"0.58947027",
"0.58923644",
"0.5887903",
"0.58830196",
"0.5880581",
"0.5873854",
"0.58697754",
"0.5869004",
"0.58669055",
"0.5866886",
"0.58664906",
"0.5864619",
"0.58630043",
"0.5862495",
"0.5861368",
"0.5859712",
"0.5855544",
"0.58551925",
"0.5851284",
"0.5850602"
] |
0.0
|
-1
|
This action will show the summery information of the book, such as the summery of the book, authors and pictures. For brief overview only. To obtain the index of the book, use SectionsControllerindex. Since the sections is nested into the Book resource.
|
def show
@book = Book.find(params[:id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @book_infos = BookInfo.all\n @book_details = BookDetail.all\n end",
"def index\n @articles = @book.articles\n end",
"def index\r\n @books = Book.all\r\n end",
"def show\n @summaries = Summary.all \n end",
"def index\n\n @books = Book.all\n\n end",
"def index\n @book = Book.find(params[:book_id])\n end",
"def index\n @books = Book.all\n end",
"def index\n @books = Book.all\n end",
"def index\n @books = Book.all\n end",
"def index\n @books = Book.all\n end",
"def index\n @books = Book.all\n end",
"def index\n @books = Book.all\n end",
"def index\n @books = Book.all\n end",
"def index\n @books = Book.all\n end",
"def index\n @books = Book.all\n end",
"def index\n @books = Book.all\n end",
"def index\n @books = Book.all\n end",
"def index\n @books = Book.all\n end",
"def index\n @books = Book.all\n end",
"def index\n @books = Book.all\n end",
"def index\n @books = Book.all\n end",
"def index\n @books = Book.all\n end",
"def index\n @books = Book.all\n end",
"def index\n @books = Book.all\n end",
"def index\n @books = Book.all\n end",
"def index\n @books = Book.all\n end",
"def index\n @books = Book.all\n end",
"def index\n @books = Book.all\n end",
"def index\n @books = Book.all\n end",
"def index\n @books = Book.all\n end",
"def index\n @books = Book.all\n end",
"def index\n @books = Book.all\n end",
"def show\n\t\t@book=Book.find(params[:id])\n\tend",
"def index\n #@books = Book.all\n end",
"def index\n if params[:book_id]\n @book = Book.find(params[:book_id])\n recipes = @book.recipes\n render json: RecipeSerializer.new(recipes).to_serialized_json\n else \n recipes = Recipe.all.order(:name)\n render json: RecipeSerializer.new(recipes).to_serialized_json\n end\n end",
"def index\n @books = Book.get_avaible_books\n end",
"def index \n @book_shop = find_book_shop_params\n @books = @book_shop.books.all\n end",
"def index\n # @infobooks = Infobook.all\n end",
"def index\n @bookitems = Bookitem.all\n \n end",
"def index\n @author_books = AuthorBook.all\n end",
"def index\n @bookitems = Bookitem.all\n end",
"def index\n @books= Book.all\n end",
"def index\n @book_items = BookItem.all\n end",
"def index\n @book_items = BookItem.all\n end",
"def show\n @books = Book.find(params[:id])\n puts @book\n end",
"def index\n @book_authors = BookAuthor.all\n end",
"def index\n @books_authors = BooksAuthor.all\n end",
"def index\n @abooks = Abook.all\n end",
"def index\n @bookseries = Bookseries.all\n end",
"def index\n load_data\n @books = Book.all\n end",
"def index\n @page_title = \"Books\"\n @books = Book.all\n end",
"def index\n if params[:author_id]\n @author = Author.find(params[:author_id])\n @books = @author.books\n else\n @books = Book.all\n end\n end",
"def index\n @sections = Section.all\n end",
"def index\n @sections = Section.all\n end",
"def index\n @sections = Section.all\n end",
"def index\n @sections = Section.all\n end",
"def index\n @sections = Section.all\n end",
"def index\n @sections = Section.all\n end",
"def index\n @sections = Section.all\n end",
"def index\n @magazine_books = MagazineBook.all\n end",
"def show\n @book = Book.find params[:id]\n end",
"def show \n @books = Book.find(params[:id])\n @authorname= @book.author\n\n end",
"def show\n @book=Book.find(params[:id])\n\n end",
"def index\n @authors_books = AuthorsBook.all\n end",
"def show\n authorize! :manage, BookFine\n @book_copy = @book_fine.book_copy\n @book_edition = @book_copy.try(:book_edition)\n @student = @book_fine.student\n @academic_year = AcademicYear.current\n end",
"def index\n @books = Book.page(params[:page]) # utilise le helper du gem kaminari pour faire la pagination des livres automatiquement\n end",
"def show\n @book = Book.find(params[:id])\n @book_copies = @book.book_copies.paginate(:page => params[:page], :per_page => 10)\n @transactions = @book.book_transactions.where(return_date: nil)\n end",
"def book\n @books=Book.all\n @book=Book.find(params[:id])\n end",
"def show\n @sections = Section.find(params[:id])\n end",
"def index\n @books = current_user.books\n end",
"def index\n # AR query to get all books, save into instance variable\n @books = Book.all\n end",
"def index\n @ebooks = Ebook.all\n end",
"def index\n @housebooks = Housebook.all\n end",
"def index\n @object_books = ObjectBook.all\n end",
"def show\n \t@books = Book.find_all_by_title(params[:book_name])\n end",
"def index\n @bookcabinets = Bookcabinet.all\n end",
"def show\n @book = Book.find(params[:id])\nend",
"def index\n @book1s = Book1.all\n end",
"def index\n @books = Book.read_all_except_system(current_user.id).page(params[:page]).per(10)\n @current_total = Book.read_current_income(current_user.id)\n \n # new stuff.\n @percent_current_income = Book.percent_current_income(current_user.id, 31)\n @spending_levels = Book.read_spending_level(current_user.id, 31)\n @sum_income = Book.sum_income(current_user.id, 31).to_f\n @sum_bill = Book.sum_bill(current_user.id, 31).to_f\n\n # new book.\n @book = Book.new\n @book.user_id = current_user.id\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @books }\n end\n end",
"def index\n check_if_student\n @books = Book.all\n end",
"def show\n @cat = Category.find(@book.category)\n @reviews =Review.where(\"book_id = ?\",@book.id)\n @categories = Category.all\n @coauthors = Coauthor.where(\"book_id = ? AND user_id != ?\",@book.id,current_user.id)\n @rating = Rating.new\n @userid = current_user.id\n @avg_rating = average_rating(@book.id)\n @user_rating = user_rating(@book.id)\n end",
"def index\n @books = current_user.books.all\n end",
"def full\n @books = Book.all\n end",
"def index\n @books = Book.extended_details\n\n render json: @books.as_json(\n only: [:id, :title, :author, :created_at, :total_income_cents, :copies_count, :remaining_copies_count, :loaned_copies_count]\n )\n end",
"def show\n @book.counter += 1\n @book.save\n @comments = @book.comments.recent.limit(10).all\n @relateds = @book.category.books.limit(5)\n end",
"def index\n @library_books = LibraryBook.all\n end",
"def index\n @books = Book.all\n @submitted_books = Book.submitted\n @approved_books = Book.approved\n @deactivated_books = Book.deactivated\n @book=Book.first\n end",
"def index\n @sections=Section.all\n end",
"def show\n @user_book = UserBook.find(params[:id])\n @user_books_count = UserBook.new.user_books_count(current_user) #for shelf Nav count\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user_book }\n end\n end",
"def show\n @book = Book.find(params[:id])\n @review = Review.find_all_by_book_id(@book.id)\n @book_image = BookImage.find_all_by_book_id(@book.id)\n\n #レビュー投稿用にセッションにbook_idを保持\n session[:book_id] = @book.id\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end",
"def index\n @mystery_books = current_user.mystery_books\n end",
"def show\n @authorid = params[:id]\n @author = Author.find( params[:id] )\n @publishedBooks = Book.where( \"author = '#{@author.name}' \" )\n end",
"def index\n @bookshops = Bookshop.all\n end",
"def index\n @bookshops = Bookshop.all\n end"
] |
[
"0.6635577",
"0.64410126",
"0.64224374",
"0.6402412",
"0.63980013",
"0.6395378",
"0.6392027",
"0.6392027",
"0.6392027",
"0.6392027",
"0.6392027",
"0.6392027",
"0.6392027",
"0.6392027",
"0.6392027",
"0.6392027",
"0.6392027",
"0.6392027",
"0.6392027",
"0.6392027",
"0.6392027",
"0.6392027",
"0.6392027",
"0.6392027",
"0.6392027",
"0.6392027",
"0.6392027",
"0.6392027",
"0.6392027",
"0.6392027",
"0.6392027",
"0.6392027",
"0.6388991",
"0.6387484",
"0.6375529",
"0.63623476",
"0.6362188",
"0.63519216",
"0.6311041",
"0.62883866",
"0.6281025",
"0.62740624",
"0.62722814",
"0.62722814",
"0.6270511",
"0.6268938",
"0.6263429",
"0.62623644",
"0.62566084",
"0.62548363",
"0.62433314",
"0.62418026",
"0.6240298",
"0.6240298",
"0.6240298",
"0.6240298",
"0.6240298",
"0.6240298",
"0.6240298",
"0.6240077",
"0.6215618",
"0.6208789",
"0.6207971",
"0.6200356",
"0.61944896",
"0.6179424",
"0.61708355",
"0.6155953",
"0.61515033",
"0.6139405",
"0.61373186",
"0.6131725",
"0.6120672",
"0.6113284",
"0.6087951",
"0.6075991",
"0.6067199",
"0.60663897",
"0.6066267",
"0.60636526",
"0.6056159",
"0.603636",
"0.60349727",
"0.60143894",
"0.59970653",
"0.59941363",
"0.59873587",
"0.5987023",
"0.59853125",
"0.59802413",
"0.59717935",
"0.5970325",
"0.5965557",
"0.5965557"
] |
0.63041395
|
44
|
Start writing a brand new book. If you want to join to a existing book authoring, authorings_controllercreate should be used.
|
def create
begin
@book = current_user.writings.create!(params[:book])
rescue Exception => e
render 'new', error: @book.errors.full_messages
end
redirect_to @book
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n\t\t@book = Book.new(book_params)\n\t\t@book.save\n\t\tredirect_to books_path\n\tend",
"def create\n\t\t@book = Book.new(params[:book])\n\t\t@book.title = @book.title.titleize\n\t\t@book.author_first = @book.author_first.titleize\n\t\t@book.author_last = @book.author_last.titleize\n\t\t@all_categories = get_all_categories\n\t\n\t\trespond_to do |format|\n\t\t\tif @book.save\n\t\t\t\tflash[:notice] = 'Book was successfully created.'\n\t\t\t\tformat.html { redirect_to(:action => 'index', :choice => ' ') }\n\t\t\telse\n\t\t\t\tflash[:notice] = 'Book was not created. Please try again.'\n\t\t\t\tformat.html { render :action => \"new\" }\n\t\t\tend\n\t\tend\n\tend",
"def create\n if is_admin?\n @book = get_book\n else\n go_home\n end\n\n go_home if !@book\n\n respond_to do |format|\n if @book.save\n flash[:notice] = 'Book was successfully created.'\n format.html { redirect_to(@book) }\n format.xml { render :xml => @book, :status => :created, :location => @book }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @book.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n\t@book = Book.new(book_params)\n\tif @book.save\n\t\tredirect_to root_path\n\telse\n\t\trender 'new'\n\tend\nend",
"def write_book(title,num_pages)\n # THIS PARTICULAR author\n # self\n # WRITE A NEW book\n book = Book.new(title,self,num_pages)\n #code\n end",
"def create\n\t\t@books = Book.new(params [:book])\n\n\t\t@books.save\n\n\t\t#redirects to \"show\" method\n\t\tredirect_to @books\n\tend",
"def create\n @title = \"Create New Book\"\n\n process_publisher\n\n all_book_params= params[:book]\n\n @book = Book.new(params[:book])\n\n process_authors\n\n process_subjects\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to edit_book_path(@book), notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = NewBook.new(book_params).new\n book_published =\n Authoring.new(current_user, @book)\n .publish_book\n\n respond_to do |format|\n if book_published\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@book = Book.new(params[:book])\n\t\t@book.user = current_user\n\n\t\trespond_to do |format|\n\t\t\tif @book.save\n\t\t\t\tformat.html { redirect_to @book, :notice => 'Book was successfully created.' }\n\t\t\t\tformat.json { render :json => @book, :status => :created, :location => @book }\n\t\t\telse\n\t\t\t\tformat.html { render :action => \"new\" }\n\t\t\t\tformat.json { render :json => @book.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def create\n @book = Book.new(book_params)\n if @book.save\n flash[:notice] = \"Book record successfully created\"\n redirect_to books_url\n else\n render \"new\"\n end\n end",
"def create\n @book = Book.new(book_params)\n puts \"*** From create: \" \n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = current_user\n if verify_admin || verify_librarian\n @book = Book.new(book_params)\n @book.nums_request = 0\n @book.library = @user.library if (@user.role == 'librarian')\n @book.is_delete = false\n @book.nums_borrowed = 0\n @library = Library.find_by_name(@book.library)\n @book.university = @library.university\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n\n end\n end\n else\n redirect_to books_url, notice: 'Unauthorized action!'\n\n end\n end",
"def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to manage_books_path, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(book_params)\n Rails.logger = Logger.new(STDOUT)\n logger.debug \"params passed is #{book_params}\"\n @book.is_deleted = false\n\n if !@current_librarian.nil?\n @book[:library_id] = @current_librarian.library_id\n @book[:associated_library] = @current_librarian.library.name\n end\n\n respond_to do |format|\n if @book.save\n logger.debug \"Book saved with id #{@book.id}\"\n format.html { redirect_to @book, notice: 'Book was successfully added.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(book_params)\n if @book.save\n redirect_to book_path(@book)\n #based on the routes (@ localhost.../routes, or rakes route, we can use the defined path as opposed to a link)\n else\n render 'new'\n #goes back to the new method if the book is not saved\n end\n end",
"def add_book\n\tputs \"\\nTo add a new book please enter the following requested information:\\n\"\n\tprint \"Book Title \"\n\ttitle = gets.chomp\n\tprint \"Book Author \"\n\tauthor = gets.chomp\n\tprint \"Book ISBN \"\n\tisbn = gets.chomp\n\tprint \"Book Home Library \"\n\tlibrary_id = gets.chomp.to_i\n\tlibrary_id = verify_library_exists(library_id)\n\tBook.create(title: title, author: author, isbn: isbn, library_id: library_id)\nend",
"def create\n @book = Book.new(book_params)\n\n if @book.save\n redirect_to root_path, notice: 'Book was successfully created.'\n else\n render :new, status: :unprocessable_entity\n end\n end",
"def create\n @library_book = current_user.books.new(library_book_params)\n\n respond_to do |format|\n if @library_book.save\n format.html { redirect_to @library_book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @library_book }\n else\n format.html { render :new }\n format.json { render json: @library_book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(book_params)\n @book.save\n redirect_to root_path\n end",
"def create\n\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to \"/books\", notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(params[:book])\n \n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @library_book = LibraryBook.new(params[:library_book])\n\n respond_to do |format|\n if @library_book.save\n format.html { redirect_to @library_book, notice: 'Library book was successfully created.' }\n format.json { render json: @library_book, status: :created, location: @library_book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @library_book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.find_by_id(params[:book_id])\n # check to see if there is enough copies of the book\n if @book.total_in_library > 0\n @reservation = @user.reservations.new\n @reservation.user_id = @user.id\n @reservation.book_id = @book.id\n if @reservation.save && @book.update(total_in_library: @book.total_in_library - 1)\n redirect_to reservations_path, notice: \"#{@book.title} has been reserved\"\n else\n redirect_to book_path(@book), notice: \"Problems reserving #{@book.title}\"\n end\n else # if not enough copies return back to the show page of the book\n redirect_to book_path(@book), notice: \"Not enough copies of #{@book.title} to reserve\"\n end\n end",
"def create\n @cook_book = CookBook.new(params[:cook_book])\n\n respond_to do |format|\n if @cook_book.save\n format.html { redirect_to @cook_book, notice: 'Cook book was successfully created.' }\n format.json { render json: @cook_book, status: :created, location: @cook_book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cook_book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @author_book = AuthorBook.new(author_book_params)\n\n respond_to do |format|\n if @author_book.save\n format.html { redirect_to @author_book, notice: 'Author book was successfully created.' }\n format.json { render :show, status: :created, location: @author_book }\n else\n format.html { render :new }\n format.json { render json: @author_book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = current_user.books.build(book_params)\n if @book.save\n flash[:notice] = \"Book Created Succesfully\"\n redirect_to @book\n else\n redirect_to new_book_path\n flash[:alert] = \"Something wrong with your book parameters.\"\n end\n end",
"def start_book(attributes)\n id = Hash[attributes]['id']\n unless IGNORE_BOOK_IDS.include?(id)\n @book_num += 1\n @book_id = id\n @mode = 'book'\n @book = ''\n end\n end",
"def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to books_path }\n else\n format.html { render :new, status: :unprocessable_entity }\n end\n end\n end",
"def create\n logger.debug \"#{book_params}\"\n @book = Book.new(book_params)\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(params[:book])\n \n respond_to do |format|\n if @book.save_and_index\n flash[:notice] = 'Book was successfully created.'\n format.html { redirect_to(@book) }\n format.xml { render :xml => @book, :status => :created, :location => @book }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @book.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n # BookMailer.creation_email(@book).deliver_now\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n add_title_to_book\n end",
"def create\n\t\t@book = current_user.books.build(book_params)\n\t\t#to associate book with category id\n\t\t@book.category_id = params[:category_id]\n\t\tif @book.save \n\t\t\tredirect_to root_path\n\t\telse\n\t\t\trender 'new'\n\t\tend\n\tend",
"def create\n @librarybook = Librarybook.new(params[:librarybook])\n\n respond_to do |format|\n if @librarybook.save\n format.html { redirect_to(@librarybook, :notice => 'Librarybook was successfully created.') }\n format.xml { render :xml => @librarybook, :status => :created, :location => @librarybook }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @librarybook.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def booker_new\n end",
"def create\n flash[:success] = 'Added new Book...!'\n redirect_to :new_user_book, {user_id: @current_user}\n # @book = Book.new(book_params)\n #\n # respond_to do |format|\n # if @book.save\n # format.html { redirect_to @book, notice: 'Book was successfully created.' }\n # format.json { render action: 'show', status: :created, location: @book }\n # else\n # format.html { render action: 'new' }\n # format.json { render json: @book.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def create\n @library_book = LibraryBook.new(library_book_params)\n\n respond_to do |format|\n if @library_book.save\n format.html { redirect_to @library_book, notice: 'Library book was successfully created.' }\n format.json { render :show, status: :created, location: @library_book }\n else\n format.html { render :new }\n format.json { render json: @library_book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n flash[:notice] = 'Book was successfully created.'\n format.html { redirect_to book_url(@book) }\n format.xml { head :created, :location => book_url(@book) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @book.errors.to_xml }\n end\n end\n end",
"def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\r\n @book = Book.new(book_params)\r\n\r\n respond_to do |format|\r\n if @book.save\r\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\r\n format.json { render :show, status: :created, location: @book }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @book.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @book = Book.create( params[:book] )\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to books_path, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to admin_book_url(@book), notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to(@book, :notice => 'Book was successfully created.') }\n format.xml { render :xml => @book, :status => :created, :location => @book }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @book.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to(@book, :notice => 'Book was successfully created.') }\n format.xml { render :xml => @book, :status => :created, :location => @book }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @book.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: t('common.message.created_success')}\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_new_library_book\n\t\tputs \"To add new book to library, You need to enter book name and book's author name\"\n\t\tprint \"\\tEnter New Book name:\"\n\t\tnew_book_name=gets.chomp\n\t\tprint \"\\tEnter Author name:\"\n\t\tnew_book_author_name=gets.chomp\n\t\t@last_book_id=@last_book_id+1\n\t\tbook=Book.new(@last_book_id,new_book_name,new_book_author_name,-1)\n\t\t@books.push(book)\n\t\tputs \"New book '#{new_book_name}' has been added to library with book ID #{@last_book_id}\"\n\tend",
"def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render action: 'show', status: :created, location: @book }\n else\n format.html { render action: 'new' }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cook_book = CookBook.new(cook_book_params)\n\n respond_to do |format|\n if @cook_book.save\n format.html { redirect_to @cook_book, notice: 'Cook book was successfully created.' }\n format.json { render :show, status: :created, location: @cook_book }\n else\n format.html { render :new }\n format.json { render json: @cook_book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n book = Book.create(params[:book])\n redirect_to(book)\n end",
"def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.xml { head :ok }\n format.json { render json: @book, status: :created, location: @book }\n\n else\n format.html { render action: \"new\" }\n format.xml { render xml: @book.errors, status: :unprocessable_entity}\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if check_if_admin\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n else\n format.html { render :new }\n end\n end\n end\n end",
"def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book }\n format.json { render action: 'show', status: :created, location: @book }\n else\n format.html { render action: 'new' }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @authors_book = AuthorsBook.new(params[:authors_book])\n\n respond_to do |format|\n if @authors_book.save\n format.html { redirect_to @authors_book, notice: 'Authors book was successfully created.' }\n format.json { render json: @authors_book, status: :created, location: @authors_book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @authors_book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book}\n format.json { render action: 'show', status: :created, location: @book }\n else\n format.html { render action: 'new' }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @borrowed_book = BorrowedBook.new(borrowed_book_params)\n respond_to do |format|\n if @borrowed_book.save\n borrow(@borrowed_book)\n format.html { redirect_to @borrowed_book, notice: 'Borrowed book was successfully created.' }\n format.json { render :show, status: :created, location: @borrowed_book }\n else\n format.html { render :new }\n format.json { render json: @borrowed_book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n flash[:notice] = 'Book was successfully created.'\n format.html { redirect_to(@book) }\n format.xml { render :xml => @book, :status => :created, :location => @book }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @book.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n flash[:notice] = 'Book was successfully created.'\n format.html { redirect_to(@book) }\n format.xml { render :xml => @book, :status => :created, :location => @book }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @book.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n flash[:notice] = 'Book was successfully created.'\n format.html { redirect_to(@book) }\n format.xml { render :xml => @book, :status => :created, :location => @book }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @book.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(get_book_with_api(book_params[:title]))\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: '本を新規登録しました。' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: \"Book was successfully created.\" }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: \"Book was successfully created.\" }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@book = Book.new(book_params)\n\t\t@book.user_id = current_user.id\n if @book.save\n \tflash[:notice] = 'successfully created'\n redirect_to book_path(@book.id)\n else\n \t@books = Book.all\n \t@user = current_user\n\t render :index\n\n\tend\n\tend",
"def create\n\n @book = Book.new(book_params)\n book = GoogleBooks.search('isbn:'+@book.ISBN.to_s)\n first_book = book.first\n @book.name = first_book.title\n @book.publication_year = first_book.published_date\n @book.author= first_book.authors_array[0]\n\n category_name = first_book.categories.split(\",\")[0]\n category = Category.where(name: category_name ).take\n\n if(category == nil)\n category = Category.new(:name=>category_name)\n category.save\n end\n\n @book.category_id = category.id\n\n\n\n\n\n respond_to do |format|\n @book_search = Book.where(ISBN: @book.ISBN).take\n\n if(@book_search != nil)\n book_library_search = BookLibraryRelation.where(book_id: @book_search.id , library_id: current_admin.library_id).take\n msg ='Book is already in library'\n if(book_library_search == nil)\n @book_library = BookLibraryRelation.new(:book_id=>@book_search.id,:library_id=> current_admin.library_id)\n @book_library.save\n msg = 'Book was successfully created'\n end\n format.html { redirect_to @book_search, notice: msg }\n format.json { render :show, status: :created, location: @book_search }\n else\n\n if @book.save\n @book_library = BookLibraryRelation.new(:book_id=>@book.id,:library_id=> current_admin.library_id)\n @book_library.save\n\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def create\n \n \n @booktitle = Book.find_by_title(book_params[:title])\n if Book.where(:title => book_params[:title]).present?\n @book = Book.find(@booktitle.id)\n @book.count = @book.count + book_params[:count].to_i\n else\n if !(Author.where(:name => book_params[:author_name]).present?)\n @author = Author.create(:name => book_params[:author_name],\n :category => book_params[:category])\n end\n @book = Book.new(book_params)\n @book.author_id = Author.find_by_name(book_params[:author_name]).id\n end\n\n \n respond_to do |format|\n if @book.save\n \n format.json { render json: @book, status: :created, location: @book }\n else\n \n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n byebug\n @book = Book.new(book_params)\n respond_to do |format|\n if @book.save\n format.html { redirect_to [:admin, @book], notice: 'Book was successfully created.' }\n format.json { render action: 'show', status: :created, location: @book }\n else\n load_data\n format.html { render action: 'new' }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @borrowed_book = BorrowedBook.new(borrowed_book_params)\n\n respond_to do |format|\n if @borrowed_book.save\n format.html { redirect_to @borrowed_book, notice: \"Borrowed book was successfully created.\" }\n format.json { render :show, status: :created, location: @borrowed_book }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @borrowed_book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(params[:book])\n @book.user_id = current_user.id\n # can alternatively use:\n # @book = current_user.books.build(params[:book])\n\n # I used the below code before I had added before_create to book model\n # client = Goodreads.new\n # book_info = client.book_by_isbn(params[:book][:isbn])\n # @book.title = book_info.title if @book.title.blank?\n \n\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @books_author = BooksAuthor.new(books_author_params)\n\n respond_to do |format|\n if @books_author.save\n format.html { redirect_to @books_author, notice: 'Books author was successfully created.' }\n format.json { render :show, status: :created, location: @books_author }\n else\n format.html { render :new }\n format.json { render json: @books_author.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = current_user.books.new(book_params)\n respond_to do |format|\n if @book.save\n WishListWorker.perform_async(@book.id) # for background wishlist processing\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render action: 'show', status: :created, location: @book }\n else\n format.html { render action: 'new' }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.find(params[:id])\n authorize @book, :rent?\n @rental = Rental.create(book: @book, user: current_user)\n\n if @rental.save\n redirect_to books_url, notice: 'Book was successfully rented.'\n else\n redirect_to books_url, notice: 'Could not rent a book'\n end\n end",
"def create\n @book = current_user.books.new(book_params)\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # Check if this book is in the system\n @book = Book.find_by(id: book_item_params[:book_id])\n if @book == nil \n # Meaning this book is not added to database and \n # book_item_params[:id] is Goodread id\n @book = save_goodreads_book(book_item_params[:book_id])\n book_item_params[:book_id] = @book.id\n end\n # Check if this book_item already in this shelf\n shelf = Shelf.find(book_item_params[:shelf_id])\n @book_item = shelf.book_items.new(book_item_params)\n \n if shelf.save!\n flash[:success] = \"Book item was successfully created.\"\n redirect_to current_user\n else\n flash[:error] = \"Cannot add book to Bookshelf\"\n redirect_to current_user\n end\n end",
"def create\n @user = current_user\n @book = current_user.books.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render action: 'show', status: :created, location: @book }\n else\n format.html { render action: 'new' }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n rewriteParams\n @book = Book.new(params[:book])\n @book.authors << Author.find(params[:author][:name]) if not params[:author][:name].empty?\n @book.book_types << BookType.find(params[:book_type][:name]) if not params[:book_type][:name].empty?\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to(@book, :notice => 'Book was successfully created.') }\n format.xml { render :xml => @book, :status => :created, :location => @book }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @book.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(book_params)\n\n if @book.save\n redirect_to @book, notice: 'Book was successfully created.'\n else\n render :new\n end\n end",
"def create\n @book = Book.new(book_params)\n if params[:commit] == \"追加\" then\n @book.comments.build\n\n render :action => :new\n return\n end\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render action: 'show', status: :created, location: @book }\n else\n format.html { render action: 'new' }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(book_params.merge(user_id:current_user.id))\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = params[:book]\n add(@book)\n end",
"def create\n\t\tclient = Goodreads::Client.new(api_key: \"rSkvvZY8Wx27zcj4AfHA\", api_secret: \"S5WOpmY8pVtaEu1IwNn51DBafjoEIbjuxZdE6sNM\")\n\t\tbook = client.book_by_isbn(book_params[:isbn])\n\t\t@book = Book.new(book_params)\n\n#\t\tputs book.title\n#\t\tputs book.description\n#\t\tputs book.work.original_title\n#\t\tputs book.num_pages\n#\t\tputs book.authors.author.name\n#\t\tputs book.publisher\n\n\t\t@book.titlelong = book.title\n\t\t@book.description = strip_tags(book.description)\n\t\tputs @book.description#.gsub(/<br\\s*\\?>/, '')\n\t\t@book.title = book.work.original_title\n\t\t@book.pages = book.num_pages\n\t\t@book.bookrating = book.average_rating\n\t\t@book.author = book.authors.author.name\n\t\t@book.publisher = book.publisher\n\n\t\t#book.search(\"9780545790352\", 5)\n\t\t#puts book.books.first.get_title\n\t\t#@show = Show.new(show_params)\n\t\t#@show.title = result[\"original_name\"]\n\t\t#@show.description = result[\"overview\"]\n\t\t#@show.seasons = result[\"number_of_seasons\"]\n\t\t#@show.episodes = result[\"number_of_episodes\"]\n\t\t#@show.episoderuntime = result[\"episode_run_time\"].dig(0)\n\t\t#@show.showrating = result[\"vote_average\"]\n\t\t#@show.airdate = result[\"first_air_date\"]\n\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @loan = Loan.new(loan_params)\n @book = Book.find_by( params[:book_id] )\n\n respond_to do |format|\n if @loan.save\n format.html { redirect_to @loan, notice: 'Book successfully borrowed' }\n format.json { render :show, status: :created, location: @loan }\n else\n format.html { redirect_to books_path, alert: 'Book not available' }\n end\n end\n end",
"def create\n @authors_book = AuthorsBook.new(authors_book_params)\n\n respond_to do |format|\n if @authors_book.save\n format.html { redirect_to @authors_book, notice: 'Authors book was successfully created.' }\n format.json { render :show, status: :created, location: @authors_book }\n else\n format.html { render :new }\n format.json { render json: @authors_book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @read_book = ReadBook.new(read_book_params)\n\n respond_to do |format|\n if @read_book.save\n flash[:notice] = 'Read book was successfully created.'\n format.html { redirect_to read_books_url }\n format.json { render :show, status: :created, location: @read_book }\n else\n flash[:warning] = 'Failed'\n format.html { redirect_to read_books_url }\n format.json { render json: @read_book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @my_book = MyBook.new(my_book_params)\n\n respond_to do |format|\n if @my_book.save\n format.html { redirect_to @my_book, notice: 'My book was successfully created.' }\n format.json { render :show, status: :created, location: @my_book }\n else\n format.html { render :new }\n format.json { render json: @my_book.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.6796125",
"0.66333073",
"0.6606919",
"0.65997714",
"0.6575322",
"0.65293664",
"0.6527419",
"0.65175927",
"0.64862627",
"0.6479582",
"0.6475011",
"0.6463886",
"0.64320886",
"0.64149773",
"0.6413278",
"0.64050424",
"0.6404338",
"0.639999",
"0.6377288",
"0.6374696",
"0.637103",
"0.6356712",
"0.63518524",
"0.6345111",
"0.6340445",
"0.632856",
"0.6324357",
"0.632377",
"0.6322642",
"0.6320401",
"0.63161653",
"0.6313909",
"0.6310791",
"0.628818",
"0.628575",
"0.62756807",
"0.6274829",
"0.6271482",
"0.6271482",
"0.6271482",
"0.6271482",
"0.6271482",
"0.62684745",
"0.6262696",
"0.6240717",
"0.6238276",
"0.6238276",
"0.6234341",
"0.62342787",
"0.6231138",
"0.62231004",
"0.6219248",
"0.62104183",
"0.6209951",
"0.6209402",
"0.62089926",
"0.6207239",
"0.62058437",
"0.62058437",
"0.62058437",
"0.62058437",
"0.62058437",
"0.62058437",
"0.62058437",
"0.62058437",
"0.62058437",
"0.62058437",
"0.62058437",
"0.62058437",
"0.62058437",
"0.61956036",
"0.61832315",
"0.61784387",
"0.61784387",
"0.61784387",
"0.61689496",
"0.61686033",
"0.61686033",
"0.6166974",
"0.6165045",
"0.6164113",
"0.61481315",
"0.6145133",
"0.6134325",
"0.6131935",
"0.6130337",
"0.61293703",
"0.6119246",
"0.61171913",
"0.6117013",
"0.6116679",
"0.6112983",
"0.6102682",
"0.6097696",
"0.6093797",
"0.6089783",
"0.6085319",
"0.6081984",
"0.60805523",
"0.6077787"
] |
0.6474023
|
11
|
choose the correct book layout
|
def books_layout
if params[:action] == 'show'
'reading'
elsif params[:action] == 'edit' || params[:action] == 'new'
'writing'
else
'application'
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def book_pages\n\t\t@book = {\n\t\t\t\t\"sketch\" =>\n\t\t\t\t\"\t\t\t\t------------------------------------------\n\t\t\t\t| |\n\t\t\t\t| ----- |\n\t\t\t\t| / _ \\\\ |\n\t\t\t\t| / | | \\\\ |\n\t\t\t\t| --------- |\n\t\t\t\t| |\n\t\t\t\t| ____ _____ |\n\t\t\t\t| / \\\\____ /| \\\\__ |\n\t\t\t\t| / \\\\_____/ | \\\\_______ |\n\t\t\t\t| _____ |____ |\n\t\t\t\t| / \\\\____ /* \\\\__ |\n\t\t\t\t| / \\\\_____/ \\\\_______ |\n\t\t\t\t| |\n\t\t\t\t| |\n\t\t\t\t| _ |\n\t\t\t\t| / \\\\__ ___ |\n\t\t\t\t| /__/ \\\\/ \\\\ |\n\t\t\t\t| /____\\\\____\\\\ |\n\t\t\t\t| |\n\t\t\t\t| |\n\t\t\t\t ------------------------------------------\",\n\n\t\t\t\t \"page1\" =>\n\t\t\t \t\"\t\t\t\t------------------------------------------\n\t\t\t\t| |\n\t\t\t\t| |\n\t\t\t\t| -oday-- met a ------------- loca- |\n\t\t\t\t| trib----- confirme------uspicions. |\n\t\t\t\t| Now I kn---how---------tr--sur-----. |\n\t\t\t\t| |\n\t\t\t\t| ---gh- |\n\t\t\t\t| m---? |\n\t\t\t\t| |\n\t\t\t\t| R----R--Y----B- |\n\t\t\t\t ------------------------------------------\",\n\n\t\t\t}\n\tend",
"def determine_layout\n 'akinu'\n end",
"def book\n 'Book' if record.leader[6] == 'a' && record.leader[7] == 'm' && local_formats.include?('Archives/Manuscripts')\n end",
"def print_layout_supporting_document\n return if application_type == 'LO-WD'\n\n { code: :supporting_documents, # section code\n key: :title, # key for the title translation\n key_scope: %i[applications slft supporting_documents], # scope for the title translation\n divider: true, # should we have a section divider\n display_title: true, # Is the title to be displayed\n type: :list, # type list = the list of attributes to follow\n list_items: [{ code: :supporting_document_list, lookup: true, format: :list }] }\n end",
"def _implied_layout_name; end",
"def custom_layout\n case action_name\n when \"industry_xls\"\n \"no_layout\"\n when \"supplier_profiles\"\n \"no_layout\"\n when \"total_xls\"\n \t \"no_layout\"\n when \"industry_level\"\n \"no_layout\"\n when \"supplier_level\"\n \"no_layout\"\n when \"company_xls\"\n \t\"no_layout\"\n when \"customer_record\"\n \t\"no_layout\"\n when \"most_company_xls\"\n \t\"no_layout\"\n when \"conversion_industry\"\n \t\"no_layout\"\n when \"conversion_company\"\n \t\"no_layout\"\n when \"company_xls\"\n \t\"no_layout\"\t\n when \"suppliers_profiles\"\n \t\"no_layout\"\n when \"registered_suppliers\"\n \t\"no_layout\"\n when \"unregistered_suppliers\"\n \t\"no_layout\"\n when \"all_customers\"\n \t\"no_layout\"\n when \"jagent\"\n \t\"no_layout\"\n when \"sagent\"\n \t\"no_layout\"\n when \"poll\"\n \"no_layout\"\t\n when \"industry_conversion\"\n \"no_layout\"\t\n when \"company_conversion\"\t\t\n \"no_layout\"\n when \"reviews_processed\"\n \"no_layout\"\n when \"agent_output\"\n \"no_layout\"\n when \"agent_performance\"\n \"no_layout\"\n \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n else\n \"admin\"\n end\n end",
"def set_layout\n if 1==1\n 'application'\n else\n 'dean'\n end\n end",
"def book\n @library_location = 2\n super\n end",
"def layout\n\n raise \"Missing bulletin for layout object!\" if (! self.bulletin)\n \n raise \"Missing layout style/name for layout object!\" if (! self.name)\n\n # assume everything prepared if this is already set (caching!)\n return @layout if (@layout)\n\n # Load layout from the database\n while (! @layout)\n @layout = TempletLayout.find(:first, \n :conditions => ['templet_id = ? AND name = ?', self.bulletin.templet_id, self.name ])\n if !@layout and self.name == 'print'\n # set to main, if print layout not found\n self.name = 'main'\n elsif not @layout\n raise \"Invalid layout selected!\" if (! @layout) \n end\n end\n \n \n # copy the details accross for the layout\n self.filetype = @layout.filetype\n self.charset = @layout.charset\n \n return @layout\n end",
"def layout_type\n if params[:controller] == \"catalog\"\n if params[:action] == \"show\" || params[:action] == \"downloads\"\n \"item\"\n elsif params[:action] == \"index\"\n \"index\"\n end\n else\n \"default\"\n end\n end",
"def book\n return direct_book if item_type == 'book' || item_type == 'package'\n group && group.book\n end",
"def layouts=(_arg0); end",
"def layouts=(_arg0); end",
"def choose_layout\r\n return nil if action_name=='show'\r\n return 'usercenter' if action_name=='index' || action_name=='new'\r\n return 'public'\r\n end",
"def _layout_for_option(name); end",
"def defineLayoutMenu\n #puts \"Removing Old Menu and Home Layout\"\n rm_rf File.join(\"#{g('wiki_source')}\",URL_LAYOUT_DEFAULT)\n #puts \"Generating New Menu\"\n open(File.join(\"#{g('wiki_source')}\",URL_LAYOUT_DEFAULT), 'w') do |newLayout|\n newLayout.puts '\n <!doctype html><html lang=\"en\"><head><meta charset=\"utf-8\"><title>{{ page.title }}</title></head>\n <body>\n {% include style.html %}\n {% include menu.html %}\n '\n oldUnder=-1\n File.foreach(File.join(\"#{g('wiki_source')}\",URL_MENU_FILE)) do |line|\n currentUnder = count_em(line,\"-\")\n #Fils du courant\n if(currentUnder>oldUnder)\n if(oldUnder==-1)\n newLayout.puts '\n <div class=\"w3-row-padding w3-padding-64 w3-container\">\n <div>\n <div class=\"w3-quarter\" style=\"width:260px\">\n\t\t<nav class=\"w3-bar-block w3-collapse w3-large w3-theme-l5 w3-animate-left w3-small w3-round w3-blue\" style=\"z-index:3;margin-left:10px\" id=\"mySidebar\">\n <div class=\"w3-medium w3-text-white w3-margin-left\" style=\"font-weight:bold\"><div>'\n else\n newLayout.puts \" <div id='sub' class=' w3-padding-small w3-bar-block w3-small'>\"\n end\n oldUnder=currentUnder\n else\n #Père du courant\n if(currentUnder<oldUnder)\n loop do \n newLayout.puts \" </div>\"\n oldUnder = oldUnder -1\n break if oldUnder==currentUnder\n end\n end\n end\n fileWithName = File.join(\"#{g('wiki_dest')}\",\"/\"+line.gsub(\"-\",\"\")).gsub(\"\\n\",\"\")\n title=line\n if(File.exists?(fileWithName+\".md\"))\n File.foreach(fileWithName+\".md\") do |row|\n if(row.include? \"title:\")\n title = row\n break\n end\n end \n newLayout.puts \"<a href='/\"+fileWithName+\"'>\"+title.gsub(\"title: \",\"\")+\"</a><br/>\"\n else\n newLayout.puts \"\"+title.gsub(\"-\",\"\")+\"\"\n end\n end\n newLayout.puts '</div></div></nav></div>\n <div class=\"w3-threequarter\">\n {{ content }}\n </div>\n </div>\n </div>\n </body></html>'\n end\n \n \nend",
"def determine_layout\r\n #\"earthlingtwo/earthlingtwo\"\r\n \"#{template_name}/#{template_name}\"\r\n end",
"def choose_layout\n Rails.configuration.blog.layout\n end",
"def layout; end",
"def set_layout\n if %w( print plain ).include? params[:layout]\n params[:layout]\n else\n 'default'\n end\n end",
"def set_book_format\n @book_format = BookFormat.find(params[:id])\n end",
"def choose_layout \n if [ 'index', 'new', 'create','zones' ].include? action_name\n 'application'\n else\n 'application'\n end\n end",
"def layouts; end",
"def layouts; end",
"def layout\n lookup_layout\n end",
"def render_book(p)\n r = \"\"\n if p.authors.size > 0 then\n r += p.authors.map {|a| a.abbreviated_name}.joined_by_comma_and_and + \". \"\n if p.editors.size > 0 then\n r += p.editors.map {|e| e.abbreviated_name}.joined_by_comma_and_and + \", editors, \"\n end\n end\n\n r += p.title.detex.titlecase\n\n if field(p,\"Volume\") then\n r += text_for_field(\"Volume\", p, :prefix => \", volume \")\n r += text_for_field(\"Series\", p, :prefix => \" of \")\n elsif field(p,\"Number\") then\n r += text_for_field(\"Number\", p, :prefix => \". Number \")\n r += text_for_field(\"Series\", p, :prefix => \" in \")\n elsif field(p,\"Series\") then\n r += text_for_field(\"Series\", p, :prefix => \". \")\n end\n r += \". \"\n\n r += text_for_field(\"Publisher\", p, :postfix => \", \").detex\n r += text_for_field(\"Address\", p, :postfix => \", \").detex\n r += text_for_field(\"Edition\", p, :postfix => \" edition, \").titlecase.detex\n\n r += month_for_field(\"Month\", p, :postfix => \" \").detex\n r += text_for_field(\"Year\", p, :postfix => \". \").detex\n r += text_for_field(\"Note\", p, :postfix => \". \")\n return r\n\nend",
"def determine_layout\n case action_name\n when \"new\"\n \"hero\"\n when \"create\"\n \"hero\"\n when \"edit\"\n \"dashboard\"\n when \"update\"\n \"dashboard\"\n end\n end",
"def best_selling_style\n style = nil\n if self.group_size <= 4\n style = \"knowledgeable\"\n elsif self.group_size >4 && self.group_size <= 8\n style = \"attention to detail\"\n elsif self.group_size > 8\n style =\"pushy\"\n end\n style\n end",
"def set_layout\n params[:action] == 'index' ? 'admin' : (params[:layout] || 'realestate')\n end",
"def configure_layout\n contributable = (@workflow || @pack || @blob)\n layout = nil\n\n # For testing skins\n if params[\"layout_preview\"]\n layout = Conf.layouts[params[\"layout_preview\"]]\n # Skins on resources\n elsif contributable && contributable.contribution && contributable.contribution.policy\n if contributable.contribution.policy.layout\n layout = Conf.layouts[contributable.contribution.policy.layout]\n if layout.nil?\n logger.error(\"Missing layout for #{contributable.class.name} #{contributable.id}: \"+\n \"#{contributable.contribution.policy.layout}\")\n end\n end\n # Skins on groups, or when in a group context\n elsif (network = @network) || (@context.is_a?(Network) && (network = @context))\n layout = network.layout\n end\n\n # Check skin exists\n if layout && layout[\"layout\"] && !File.exists?(\"#{RAILS_ROOT}/app/views/layouts/#{layout[\"layout\"]}.html.erb\")\n logger.error(\"Missing layout #{RAILS_ROOT}/app/views/layouts/#{layout[\"layout\"]}.html.erb\")\n layout = nil\n end\n\n # Use default skin if all else fails\n if layout.nil?\n @layout = {\"layout\" => 'application', \"stylesheets\" => [Conf.stylesheet]}\n else\n @layout = layout\n end\n\n @layout[\"layout\"]\n end",
"def render_inbook(p)\n r = \"\"\n if p.authors.size > 0 then\n r += p.authors.map {|a| a.abbreviated_name}.joined_by_comma_and_and\n else\n r += p.editors.map {|e| e.abbreviated_name}.joined_by_comma_and_and + \", editor\"\n end\n r += \". \"\n\n r += p.title.detex.titlecase\n\n if field(p,\"Volume\") then # <$fields.Volume?>\n r += text_for_field(\"Volume\", p, :prefix => \", volume \") #, volume <$fields.Volume/>\n if field(p,\"Series\") then # <$fields.Series?>\n r += text_for_field(\"Series\", p, :prefix => \" of \", :postfix => \"\") # <$fields.Series/>\n end # </$fields.Series?>\n end # </$fields.Volume?>\n\n if field(p,\"Chapter\") then # <$fields.Chapter?>, \n r += \", \"\n if field(p,\"Type\") then # <$fields.Type?>\n r += text_for_field(\"Type\", p, :postfix => \" \") # <$fields.Type/>\n else\n r += \"chapter\" # <?$fields.Type?>chapter\n end # </$fields.Type?>\n r += text_for_field(\"Chapter\", p) # <$fields.Chapter/>\n # <$fields.Pages.stringByPrependingCommaAndSpaceIfNotEmpty/>\n if field(p,\"Pages\") then\n r += text_for_field(\"Pages\", p, :prefix => \", pages \", :postfix => \". \").detex\n end\n else # <?$fields.Chapter?>\n # <$fields.Pages?>, page <$fields.Pages/>\n if field(p,\"Pages\") then\n r += text_for_field(\"Pages\", p, :prefix => \", pages \", :postfix => \". \").detex\n end # </$fields.Pages?>\n end # </$fields.Chapter?>\n\n if field(p,\"Volume\") then #<$fields.Volume?>\n # empty\n else # <?$fields.Volume?>\n if field(p,\"Number\") then # <$fields.Number?>. Number\n r += text_for_field(\"Number\", p, :prefix => \". Number \", :postfix => \"\") #<$fields.Number/>\n if field(p,\"Series\") then # <$fields.Series?>\n r += text_for_field(\"Series\", p, :prefix => \" in \", :postfix => \"\") # <$fields.Series/>\n end #</$fields.Series?>\n else # <?$fields.Number?>\n # <$fields.Series.stringByPrependingCommaAndSpaceIfNotEmpty/>\n r += text_for_field(\"Series\", p, :prefix => \", \")\n end # </$fields.Number?>\n r += \". \"\n end # </$fields.Volume?>.\n\n r += text_for_field(\"Publisher\", p) # <$fields.Publisher/>\n r += text_for_field(\"Address\", p, :prefix => \", \") # <$fields.Address.stringByPrependingCommaAndSpaceIfNotEmpty/>,\n r += text_for_field(\"Edition\", p, :prefix => \", \", :postfix => \" edition\")\n r += month_for_field(\"Month\", p, :prefix => \", \") # <$fields.Month.stringByAppendingSpaceIfNotEmpty/>\n r += text_for_field(\"Year\", p, :prefix => \" \", :postfix => \".\") # <$fields.Year/>. \n r += text_for_field(\"Note\", p, :prefix => \" \", :postfix => \". \").detex # <$fields.Note.stringByPrependingFullStopAndSpace/>.\n return r\nend",
"def default_layout?\n layout_type == \"default\"\n end",
"def layout(model)\n #Rfm.layout(model.storage_name, options.symbolize_keys) #query.repository.adapter.options.symbolize_keys)\n model.layout\n end",
"def set_layout\n @layoutme = 1\n end",
"def print_layout_about_the_waste\n return if not_waste_producer_water_discount?\n\n { code: :about_the_waste, # section code\n key: :title, # key for the title translation\n key_scope: %i[applications slft about_the_waste], # scope for the title translation\n divider: true, # should we have a section divider\n display_title: true, # Is the title to be displayed\n type: :list, # type list = the list of attributes to follow\n list_items: [{ code: :type_of_waste_text },\n { code: :how_produced },\n { code: :how_added }] }\n end",
"def start_book_title(attributes)\n @mode = 'book-title' if @mode == 'book'\n end",
"def set_radiant_layout\n @content_for_header_content = header_content_for_page('research')\n @content_for_body_class = body_class_for_page('research')\n @content_for_title_tag = title_tag_for_page('conditions')\n\n @radiant_layout = \"Default Layout\"\n \n @topics = ResearchTopic.all_published\n end",
"def find_layout(layout, keys, formats); end",
"def layout(section_name, position)\n id = get_parent_id(position)\n records = Base.where(:_id => id)\n if records.count > 0 and records.first.connections.where(:section => section_name, :file.ne => nil).count > 0\n file_name = records.first.connections.where(:section => section_name, :file.ne => nil).first.file\n show file_name, {views: [\"app/views/#{records.first._type}\", \"app/views/#{records.first._type.downcase}\"]}, {record: records.first}\n else\n '404'\n end\n end",
"def layout_name\n umlaut_config.search_layout\n end",
"def title_from_layout(layout)\n # no layout, leave title alone\n return nil if layout.blank?\n\n case layout\n when \"automation_manager\"\n _(\"Automation Managers\")\n when \"catalogs\"\n _(\"Catalogs\")\n when \"configuration\"\n _(\"My Settings\")\n when \"configuration_job\"\n _(\"Configuration Jobs\")\n when \"container_dashboard\"\n _(\"Container Dashboard\")\n when \"dashboard\"\n _(\"Dashboard\")\n when \"chargeback\"\n _(\"Chargeback\")\n when \"about\"\n _(\"About\")\n when \"ems_cluster\"\n _(\"Clusters\")\n when \"generic_object_definition\"\n _(\"Generic Object Definitions\")\n when \"host\"\n _(\"Hosts\")\n when \"miq_server\"\n _(\"Servers\")\n when \"services\"\n _(\"Services\")\n when \"usage\"\n _(\"VM Usage\")\n when \"scan_profile\"\n _(\"Analysis Profiles\")\n when \"miq_policy_rsop\"\n _(\"Policy Simulation\")\n when \"report\"\n _(\"Reports\")\n when \"ops\"\n _(\"Configuration\")\n when \"pxe\"\n _(\"PXE\")\n when \"switch\"\n _(\"Switches\")\n when \"explorer\"\n \"#{controller_model_name(params[:controller])} Explorer\"\n when \"timeline\"\n _(\"Timelines\")\n when \"vm_cloud\"\n _(\"Instances\")\n when \"vm_infra\"\n _(\"Virtual Machines\")\n when \"vm_or_template\"\n _(\"Workloads\")\n when \"all_tasks\"\n _(\"All Tasks\")\n when \"my_tasks\"\n _(\"My Tasks\")\n\n # Specific titles for groups of layouts\n when /^miq_ae_/\n _(\"Automation\")\n when /^miq_capacity_utilization/\n _(\"Utilization\")\n when /^miq_request/\n _(\"Requests\")\n when \"manageiq/providers/ansible_tower/automation_manager/playbook\"\n _(\"Playbooks (Ansible Tower)\")\n when \"manageiq/providers/embedded_ansible/automation_manager/playbook\"\n _(\"Playbooks\")\n when \"manageiq/providers/embedded_ansible/automation_manager/credential\", \"manageiq/providers/workflows/automation_manager/credential\"\n _(\"Credentials\")\n when \"manageiq/providers/embedded_ansible/automation_manager/configuration_script_source\"\n _(\"Repositories\")\n when \"manageiq/providers/workflows/automation_manager/configuration_script_source\"\n _(\"Repositories\")\n when \"manageiq/providers/workflows/automation_manager/workflow\"\n _(\"Workflows\")\n\n else\n fallback_title(layout)\n end\n end",
"def layout(layout_type)\n\t\t#most content. that is loaded into the artist content area (just content)\n\t\tif layout_type.nil? || layout_type.blank?\n\t\t\t@layout = false\n\t\t\t@hook = \"#content\"\n\t\t#when artist page has to be loaded (logo, nave and content)\n\t\telsif layout_type == \"artist\"\n\t\t\t@layout = \"layouts/artist_admin_and_artist_floating_content.html.erb\"\n\t\t\t@hook = \".dynamicContent\"\n\t\tend\n\tend",
"def default_layout\n 'default' if html?\n end",
"def layout\n @nav_url = url_for_list(!@file || options.index ? menu_lists.first[:type] : 'file')\n\n case object\n when nil, String\n @path = nil\n when @file\n @path = @file.path\n when !object.is_a?(YARD::CodeObjects::NamespaceObject)\n @path = object.parent.path\n @nav_url = url_for_list('class')\n when YARD::CodeObjects::ClassObject\n @path = object.path\n @nav_url = url_for_list('class')\n when PuppetStrings::Yard::CodeObjects::Class\n @nav_url = url_for_list('puppet_class')\n @page_title = \"Puppet Class: #{object.name}\"\n @path = object.path\n when PuppetStrings::Yard::CodeObjects::DataType, PuppetStrings::Yard::CodeObjects::DataTypeAlias\n @nav_url = url_for_list('puppet_data_type')\n @page_title = \"Data Type: #{object.name}\"\n @path = object.path\n when PuppetStrings::Yard::CodeObjects::DefinedType\n @nav_url = url_for_list('puppet_defined_type')\n @page_title = \"Defined Type: #{object.name}\"\n @path = object.path\n when PuppetStrings::Yard::CodeObjects::Type\n @nav_url = url_for_list('puppet_type')\n @page_title = \"Resource Type: #{object.name}\"\n @path = object.path\n when PuppetStrings::Yard::CodeObjects::Provider\n @nav_url = url_for_list('puppet_provider')\n @page_title = \"Provider: #{object.name}\"\n @path = object.path\n when PuppetStrings::Yard::CodeObjects::Function\n @nav_url = url_for_list('puppet_function')\n @page_title = \"Puppet Function: #{object.name} (#{object.function_type})\"\n @path = object.path\n when PuppetStrings::Yard::CodeObjects::Task\n @nav_url = url_for_list('puppet_task')\n @page_title = \"Puppet Task: #{object.name}\"\n @path = object.path\n when PuppetStrings::Yard::CodeObjects::Plan\n @nav_url = url_for_list('puppet_plan')\n @page_title = \"Puppet Plan: #{object.name}\"\n @path = object.path\n else\n @path = object.path\n end\n\n final_layout = erb(:layout)\n\n PuppetStrings::Yard::Util.github_to_yard_links(final_layout) if @file && @file.name == 'README'\n\n final_layout\nend",
"def layout_chooser(current_user)\n unless current_user.nil?\n if current_user.role==\"applicant\" then\n @applicant=current_user.applicant\n layout=\"applicants\"\n elsif current_user.role==\"company\" then\n @company=current_user.company\n layout=\"companies\"\n else\n layout=\"admin\" \n end\n \n else\n layout=\"welcome\"\n end\n layout\n end",
"def select_layout\n (ios_client? || nook?) ? false : \"lifesize_popup\"\n end",
"def default_layout\n nil\n end",
"def layout_chapter_title node, title, opts = {}\n puts 'Processing node.id:' + node.id\n puts 'Processing title:' + title\n if title == \"Preface\" or title.include? \"Appendix\"\n move_down 1\n typeset_text title, (calc_line_metrics 1.5), inline_format: true, align: :right, size: 21\n stroke_horizontal_rule '000000', line_width: 0.5, line_style: :solid\n else\n num_chapter, title = title.split '.', 2\n typeset_text num_chapter, (calc_line_metrics 1.5), inline_format: true, align: :right, size: 15\n move_down 1\n stroke_horizontal_rule '000000', line_width: 0.5, line_style: :solid\n typeset_text title, (calc_line_metrics 1.5), inline_format: true, align: :right, size: 21\n end\n move_down 50\n end",
"def layout_or_nil(layout_name)\n begin\n if (layout = Rfm.layout(layout_name)).table then layout; end\n rescue nil\n end\n end",
"def layout_for(area = :reader)\n default = Radiant::Config[\"#{area}.layout\"]\n name = if self.respond_to?(\"#{area}_layout\") && layout = self.send(\"#{area}_layout\".intern)\n layout.name\n elsif layout = Layout.find_by_name(default)\n layout.name\n elsif layout = self.reader_layout\n layout.name\n end\n name\n end",
"def layout\n nil\n end",
"def place_in_layout?; end",
"def place_in_layout?; end",
"def layout\n nil\n end",
"def to_book(options = {})\n bk = @book.deep_clone\n\n # XPath => URI mapping tools\n cmpt_xpaths = []\n\n boilerplate_rel_links =\n '<link rel=\"start\" href=\"cover.html\" />' +\n '<link rel=\"contents\" href=\"toc.html\" />'\n\n\n # Componentizing.\n if options[:componentize]\n componentizer = Peregrin::Componentizer.new(index)\n componentizer.process(index.root.at_css('body'))\n bk.components = componentizer.component_xpaths.collect { |xpath|\n cmpt_xpaths.push(xpath)\n doc = componentizer.generate_component(xpath)\n { uri_for_xpath(xpath, cmpt_xpaths) => doc }\n }\n\n # Add rel links and convert to html string\n first_path = bk.components.first.keys.first\n last_path = bk.components.last.keys.first\n boilerplate_rel_links <<\n '<link rel=\"first\" href=\"'+bk.components.first.keys.first+'\" />' +\n '<link rel=\"last\" href=\"'+bk.components.last.keys.first+'\" />'\n bk.components.each_with_index { |cmpt, i|\n path = cmpt.keys.first\n doc = cmpt.values.first\n head = doc.at_xpath(HEAD_XPATH)\n prev_path = bk.components[i-1].keys.first if (i-1) >= 0\n next_path = bk.components[i+1].keys.first if (i+1) < bk.components.size\n head.add_child(boilerplate_rel_links)\n head.add_child('<link rel=\"prev\" href=\"'+prev_path+'\" />') if prev_path\n head.add_child('<link rel=\"next\" href=\"'+next_path+'\" />') if next_path\n cmpt[path] = htmlize(doc)\n }\n else\n cmpt_xpaths.push(BODY_XPATH)\n bk.components = [{ uri_for_xpath(BODY_XPATH) => htmlize(index) }]\n end\n\n # Outlining.\n bk.contents = outline_book(index, cmpt_xpaths)\n\n\n if options[:componentize]\n # List of Illustrations\n figures = index.css('figure[id], div.figure[id]')\n if figures.any?\n doc = Nokogiri::HTML::Builder.new { |html|\n html.ol {\n figures.each { |fig|\n next unless caption = fig.at_css('figcaption, .figcaption')\n n = fig\n while n && n.respond_to?(:parent)\n break if cmpt_uri = uri_for_xpath(n.path, cmpt_xpaths)\n n = n.parent\n end\n next unless cmpt_uri\n html.li {\n html.a(caption.content, :href => \"#{cmpt_uri}##{fig['id']}\")\n }\n }\n }\n }.doc\n loi_doc = componentizer.generate_document(doc.root)\n loi_doc.at_xpath(HEAD_XPATH).add_child(boilerplate_rel_links)\n bk.components.unshift(\"loi.html\" => htmlize(loi_doc))\n end\n\n # Table of Contents\n doc = Nokogiri::HTML::Builder.new { |html|\n curse = lambda { |children|\n html.ol {\n children.each { |sxn|\n html.li {\n html.a(sxn[:title], :href => sxn[:src])\n curse.call(sxn[:children]) if sxn[:children]\n }\n }\n }\n }\n curse.call(bk.contents)\n }.doc\n toc_doc = componentizer.generate_document(doc.root)\n toc_doc.at_xpath(HEAD_XPATH).add_child(boilerplate_rel_links)\n # FIXME: this should set guide to \"Table of Contents\",\n # guide_type to \"toc\" and linear to \"no\"\n bk.components.unshift(\"toc.html\" => htmlize(toc_doc))\n\n # Cover\n doc = Nokogiri::HTML::Builder.new { |html|\n html.div(:id => \"cover\") {\n html.img(:src => bk.cover, :alt => bk.metadata[\"title\"])\n }\n }.doc\n cover_doc = componentizer.generate_document(doc.root)\n cover_doc.at_xpath(HEAD_XPATH).add_child(boilerplate_rel_links)\n # FIXME: this should set guide to \"Cover\",\n # guide_type to \"cover\" and linear to \"no\"\n bk.components.unshift(\"cover.html\" => htmlize(cover_doc))\n end\n\n bk\n end",
"def print_layout\n [print_layout_application,\n print_layout_landfill_operator, print_layout_waste_producer,\n print_layout_waste_water_details, print_layout_banned_from_landfill,\n print_layout_about_the_waste, print_layout_about_water_content, print_layout_water_treatment,\n print_layout_start_date,\n { code: :sites,\n type: :object },\n print_layout_supporting_document,\n print_layout_declaration]\n end",
"def _conditional_layout?; end",
"def determine_layout\n ['show'].include?(action_name) ? 'application' : nil \n end",
"def page_layout\n if @page\n if params[:popup]\n \"modal\"\n elsif !@page.layout.blank?\n @page.layout\n else\n choose_layout\n end\n else\n params[:popup] ? 'modal' : choose_layout\n end\n end",
"def initialize(book)\n @book = book\n @style = book.style\n end",
"def layout=(_arg0); end",
"def set_maker_layout\n @maker_layout = MakerLayout.find(params[:id])\n end",
"def layout_file_name\n layout = \"application\"\n fail unless Content::Aggregator.original_content\n prepare_layout(layout)\n end",
"def format\n case result_item.format\n when \"Book\", :book_item\n \"book\" \n when :dissertation\n \"dissertation\"\n else\n \"journal\"\n end\n end",
"def layout\n properties[:layout]\n end",
"def print_layout_banned_from_landfill\n return if not_waste_producer_water_discount?\n\n { code: :banned_from_landfill, # section code\n key: :title, # key for the title translation\n key_scope: %i[applications slft banned_from_landfill], # scope for the title translation\n divider: true, # should we have a section divider\n display_title: true, # Is the title to be displayed\n type: :list, # type list = the list of attributes to follow\n list_items: [{ code: :not_banned_waste, lookup: true }] }\n end",
"def set_layout\n #agent = request.env['HTTP_USER_AGENT']#request.user_agent #request.env['HTTP_USER_AGENT']\n #if agent.match(\"Android\")\n #if agent.match(\"Android\")\n # false\n #TOdo change the institution_id to 25607\n unless params[:format].eql?'json'\n if !current_user.institution_id.nil? and [25607, 51324].include? current_user.institution_id\n 'pearson_new'\n elsif !current_user.institution_id.nil? and [26717, 57296].include? current_user.institution_id\n 'schand'\n # elsif !current_user.institution_id.nil? and [44566].include? current_user.institution_id\n # 'abcd_top_menu'\n else\n 'new'#'abcd_top_menu'\n end\n else\n false\n end\n # unless params[:format].eql?'json'\n # if !current_user.institution_id.nil? and [25607, 51324].include? current_user.institution_id\n # 'pearson_new'\n # elsif !current_user.institution_id.nil? and [26717, 57296].include? current_user.institution_id\n # 'schand'\n # elsif !current_user.institution_id.nil? and [1020].include? current_user.institution_id\n # 'abcd_top_menu'\n # else\n # 'new'\n # end\n # else\n # false\n # end\n end",
"def layout(new_layout = nil)\n @layout = new_layout if new_layout\n @layout\n end",
"def print_layout_water_treatment\n return if not_waste_producer_water_discount?\n\n { code: :water_treatment, # section code\n key: :title, # key for the title translation\n key_scope: %i[applications slft water_treatment], # scope for the title translation\n divider: true, # should we have a section divider\n display_title: true, # Is the title to be displayed\n type: :list, # type list = the list of attributes to follow\n list_items: [{ code: :treatment },\n { code: :reason_for_no_treatment }] }\n end",
"def print_layout # rubocop:disable Metrics/MethodLength\n [{ code: :company_details, # section code\n divider: false, # should we have a section divider\n display_title: true, # Is the title to be displayed\n type: :list, # type list = the list of attributes to follow\n list_items: [{ code: :company_number },\n { code: :company_name },\n { code: :address_line1 },\n { code: :address_line2, label: false },\n { code: :locality },\n { code: :county },\n { code: :postcode },\n { code: :country }] }]\n end",
"def layout_for_page\n if params[:layout] == 'none' || params[:layout] == 'false'\n false\n else\n params[:layout] || 'application'\n end\n end",
"def define_layout\n if user_signed_in?\n if current_user.student?\n case params['action']\n when \"show\"\n 'information_student' \n when \"events\"\n 'information_student'\n when \"frequency\"\n 'information_student' \n else\n 'student' \n end\n else\n if params['action'] == 'declaration_of_studying'\n 'print'\n else\n if params['action'] == 'daily'\n 'print'\n else\n if params['action'] == 'down_average'\n 'print'\n else\n if params['action'] == 'print'\n 'print'\n else\n if params['action'] == 'report_calendar'\n 'print'\n else\n if params['action'] == 'report_re_enrollments'\n 'print'\n else\n if params['action'] == 'report_schedules'\n 'print' \n else\n if params['action'] == 'report'\n 'print_not_head'\n else\n if params['action'] == 'report_teacher'\n 'print_not_head' \n else\n if params['action'] == 'buy_books'\n 'print_not_head'\n else\n if params['action'] == \"envelopes_for_exams\"\n 'print_not_head' \n else\n if params['controller'] == 'warnings' and params['action'] == 'show'\n 'print' \n else\n if params['controller'] == 'calendars' and params['action'] == 'show'\n nil \n else\n if params['controller'] == 'companies' and params['action'] == 'print_informations'\n 'print_head_javascript'\n else\n \n if params['controller'] == 'companies' and params['action'] == 'students_for_neighborhood'\n \"print\"\n else\n if params['controller'] == 'companies' and params['action'] == 'lists'\n \"print\"\n else\n if params['controller'] == 'companies' and params['action'] == 'students_for_level'\n \"print\"\n else\n nil \n end\n end \n end\n end\n end\n end\n end \n end\n end\n end\n end\n end\n end\n end\n end\n end\n \n end\n end\n else\n \"login\"\n end\n end",
"def set_layout\n if current_paciente != nil\n \"pacientes_pages\"\n else\n \"nutriologo_pages\"\n end\n end",
"def layout\n @layout\n end",
"def book_reading_order\n return 'right-to-left' if stub_object_type.include?('rtl') || stub_object_type.include?('r-l')\n\n 'left-to-right'\n end",
"def layout(name)\n $stderr.puts \"Overwriting Layout: #{self.class.def_layout.inspect} with #{name}\"\n @_layout = name\n end",
"def layout_contents\n @layout = <<-LAYOUT\n blueprint-deploy:\n layout: #{spec_bp_name} # name of the layout file we use\n blueprint : #{spec_bp_name} # name of the default blueprint\n servers:\n - server1:\n name: util\n applications:\n - app1:\n - app2:\n - server2:\n name: review\n applications:\n - app1:\n - app3:\n LAYOUT\n @layout\n end",
"def book_choir\r\n\t@title = \"Book the Choir\"\r\n end",
"def book(name='Main')\n concat_output <<EOT\n<?xml version='1.0' encoding='utf-8' ?>\n<!-- *** DO NOT EDIT. GENERATED FROM #{@erb_file}. *** -->\n<!DOCTYPE book PUBLIC \"-//OASIS//DTD DocBook XML V4.5//EN\" \"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd\" [\n<!ENTITY % BOOK_ENTITIES SYSTEM \"#{name}.ent\">\n%BOOK_ENTITIES;\n]>\n<book>\nEOT\n\n yield\n\n concat_output <<EOT\n</book>\nEOT\n end",
"def build_editor_layout(width, height, pane_ids)\n if pane_ids.count == 1\n build_single_editor_layout(width, height, pane_ids.first)\n else\n build_multiple_editor_layout(width, height, pane_ids)\n end\nend",
"def layout=(layout)\n @layout = layout.to_sym\n case @layout\n when :horizontal\n @default_align = :right\n when :vertical\n @default_align = :left\n else\n raise 'Unsupported layout'\n end\n end",
"def resolve_layout\n case action_name\n when \"edit\"\n \"editlayout\"\n when \"show_image\"\n \"application_png\"\n else\n \"application\"\n end\n end",
"def display_book\n\t\tputs \"Author: #@author, Title: #@title, Publisher: #@publisher, Year: #@year, Location: Shelf: #@shelf_num\"\n\tend",
"def find_book\n choice = self.prompt.select(\"Please provide me with the title, author, or ISBN of the book you are searching for: \", [\"Title\", \"Author\", \"ISBN\", \"Back to main menu\"])\n if choice != \"Back to main menu\"\n find_book_open_posts(choice)\n end\n self.main_menu\n end",
"def select_choice_book\n\tputs \"\\n1 Add a Book\\n2 Information on a Book\\n3 Edit a Book\\n4 Remove a Book\\n5 View All Books\\n6 Switch Home Library for Book\\n7 Check Out Book\\n8 Return a Book\\n0 Return to Main Menu\"\n\tselect = make_selection\n\n\twhile select != \"1\" && select != \"2\" && select != \"3\" && select != \"4\" && select != \"5\" && select != \"6\" && select != \"7\" && select != \"8\" && select != \"0\"\n\t\tputs \"\\nInvalid choice selected\\n\"\t\t \t\t\n\t\tselect = make_selection\n\tend\n\n\tif select == \"1\"\n\t\tadd_book\n\n\telsif select == \"2\"\n\t\tputs \"\\nTo get information about a book please enter it's ID #\\n\"\n\t\tshow_all_books\n\t\tselect = make_selection.to_i\n\t\tselect = verify_book_exists(select)\n\t\tdisplay_book(select)\n\n\telsif select == \"3\"\n\t\tputs \"\\nTo edit a book please enter it's ID #\\n\"\n\t\tshow_all_books\n\t\tselect = make_selection.to_i\n\t\tselect = verify_book_exists(select)\n\t edit_book(select)\n\n\telsif select == \"4\"\n\t\tputs \"\\nTo remove a book please enter it's ID #\\n\"\n\t\tshow_all_books\n\t\tselect = make_selection.to_i\n\t\tselect = verify_book_exists(select)\n\t remove_book(select)\n\n\telsif select == \"5\"\n\t\tshow_all_books\n\n\telsif select == \"6\"\n\t\tputs \"\\nTo switch home library of a book please enter it's ID #\\n\"\n\t\tshow_all_books\n\t\tselect = make_selection.to_i\n\t\tselect = verify_book_exists(select)\n\t\tedit_book_library_id(select)\n\n\n\telsif select == \"7\"\n\t\tputs \"\\nTo check out a book please enter it's ID #\\n\"\n\t\tshow_all_books\n\t\tcheck_out_book\n\n\n\telsif select == \"8\"\n\t\tputs \"\\nTo return a book please enter it's ID #\\n\"\n\t\tshow_all_books\n\t\treturn_book\n\t\tputs \"\\nBook returned\"\n\n\telsif select == \"0\"\n\t\tputs \"\\nNow entering main menu\\n\"\n\n\tend\n\tselect\t\t\nend",
"def find_layout\n return nil if @model.nil?\n layout_name = @special_layout[@model] || @model.to_s.tableize + ' (table)'\n if (layout = layout_or_nil(layout_name))\n LOG.info(\"\\n==== Model: #{@model.to_s} <- Layout: #{layout.name} ====\")\n return layout\n else \n LOG.warn \"WARNING: Layout \\\"#{layout_name}\\\" does not exist.\"\n return nil\n end\n end",
"def get_layout(historical_orders)\r\n # first we have to create a ranking of all the historical order\r\n historical_orders=historical_orders\r\n\r\n hist_order_flatten = historical_orders.flatten\r\n # uniq_order = hist_order.uniq\r\n #Create a hash table to store the frequency of the items\r\n # h=Hash.new\r\n # for i in 0...uniq_order.length\r\n # key = uniq_order[i]\r\n # count = hist_order.count(key)\r\n # h[key]= count\r\n # end\r\n l_score = lengthscore(historical_orders)\r\n h = finalscore(l_score,hist_order_flatten,historical_orders)\r\n\r\n h_sorted = h.sort_by {|k,v| v}\r\n h_sorted= Hash[h_sorted.map {|key, value| [key, value]}]\r\n ranked_order = h_sorted.keys.reverse\r\n # puts \"this is ranked order = #{ranked_order}\"\r\n\r\n #This is the algo filled by columns\r\n layout = [[], [], [], [], []]\r\n row_counter = 0\r\n # for i in 0...ranked_order.length\r\n # layout[row_counter] << ranked_order[i]\r\n # row_counter += 1\r\n # row_counter %= 5 # if row_counter becomes 5, it gets reset back to 0\r\n # end\r\n\r\n # this is the algo filled by row\r\n per_row = (ranked_order.length)/5\r\n layout =ranked_order.each_slice(per_row).to_a\r\n\r\n\r\n\r\n return layout\r\nend",
"def explicitely_selected_in_layout?(package_name)\n package_name = package_name.to_str\n normalized_layout.has_key?(package_name)\n end",
"def book project_symbol, book_template\n project_module = fetch_project_module(project_symbol)\n\n # provide project constants as global variables to the user manual\n project_module::INOCHI.each_pair do |param, value|\n eval \"$#{param} = value\", binding\n end\n\n # set document parameters for the user manual\n $title = project_module::DISPLAY\n $subtitle = project_module::TAGLINE\n $feeds = { File.join(project_module::DOCSITE, 'ann.xml') => :rss }\n $authors = Hash[\n *project_module::AUTHORS.map do |name, addr|\n # convert raw e-mail addresses into URLs for the erbook XHTML format\n addr = \"mailto:#{addr}\" unless addr =~ /^\\w+:/\n\n [name, addr]\n end.flatten\n ]\n\n class << book_template\n def project_summary\n raise ArgumentError, 'block must be given' unless block_given?\n node do\n $project_summary_node = @nodes.last\n yield\n end\n end\n\n def project_history\n raise ArgumentError, 'block must be given' unless block_given?\n node do\n $project_history_node = @nodes.last\n yield\n end\n end\n end\n end",
"def book_title\n self.part_of_title_by_type('Book')\n end",
"def is_book?()\n end",
"def FindsLayoutsForTemplate(input, options={})\n Benoit::Utils::FindsLayoutsForTemplate.new(input, options).lookup_layouts\nend",
"def layout\n case @mode\n when :injector\n \"injector\"\n when :page\n \"application\"\n else\n false\n end\n end",
"def select_layout_template(program:)\n file = layout_template_file(program: program)\n \"Choose the layout template <b>#{file}</b>\"\n end",
"def select_layout_template(program:)\n file = layout_template_file(program: program)\n \"Choose the layout template <b>#{file}</b>\"\n end",
"def default_layout\n @default_layout ||= (\n IO.read(LIBDIR + \"/templates/layouts/page.mustache\")\n )\n end",
"def item_layout?\n layout_type == \"item\"\n end",
"def rearrange_docs!; end",
"def print_layout_application\n { code: :application_type, # section code\n key: :pdf_title, # key for the title translation\n key_scope: %i[applications slft application_type], # scope for the title translation\n divider: true, # should we have a section divider\n display_title: true, # Is the title to be displayed\n type: :list, # type list = the list of attributes to follow\n list_items: print_layout_application_type_list_items }\n end",
"def set_book_template\n @book_template = BookTemplate.find(params[:id])\n end"
] |
[
"0.61108327",
"0.5933449",
"0.57440704",
"0.570697",
"0.56774646",
"0.56319666",
"0.5630188",
"0.56156915",
"0.560078",
"0.55663633",
"0.5564099",
"0.5556548",
"0.5556548",
"0.5526127",
"0.5516367",
"0.55161184",
"0.55047596",
"0.54790866",
"0.54705864",
"0.54630667",
"0.5447578",
"0.5446542",
"0.5402665",
"0.5402665",
"0.5392813",
"0.53515583",
"0.53355503",
"0.53217065",
"0.5312787",
"0.53125167",
"0.5300047",
"0.5278794",
"0.5277915",
"0.5277081",
"0.52620196",
"0.52501434",
"0.5235363",
"0.5230969",
"0.52157176",
"0.5212597",
"0.52045584",
"0.51786464",
"0.51506716",
"0.5143435",
"0.512075",
"0.5117885",
"0.5117127",
"0.5115787",
"0.5095538",
"0.50818574",
"0.50570536",
"0.5055368",
"0.5055368",
"0.5031692",
"0.50300527",
"0.502799",
"0.501124",
"0.50088924",
"0.5003287",
"0.49941978",
"0.49936205",
"0.4991239",
"0.4988959",
"0.4986322",
"0.49841696",
"0.49819508",
"0.49585247",
"0.493685",
"0.4931975",
"0.49236876",
"0.4922871",
"0.49218225",
"0.4919551",
"0.49149722",
"0.49064717",
"0.4904968",
"0.49038208",
"0.48954517",
"0.4885049",
"0.48726925",
"0.48689756",
"0.48636138",
"0.48625374",
"0.4861572",
"0.48571882",
"0.4856674",
"0.4851765",
"0.4848779",
"0.48449194",
"0.4840497",
"0.48358905",
"0.48293173",
"0.48258576",
"0.4823696",
"0.4823696",
"0.48223722",
"0.48222196",
"0.48162475",
"0.4813812",
"0.48058185"
] |
0.6880656
|
0
|
It was proposed by Christian Goldbach that every odd composite number can be written as the sum of a prime and twice a square. 9 = 7 + 212 15 = 7 + 222 21 = 3 + 232 25 = 7 + 232 27 = 19 + 222 33 = 31 + 212 It turns out that the conjecture was false. What is the smallest odd composite that cannot be written as the sum of a prime and twice a square?
|
def prime? n
return false if n < 2
return true if n == 2 || n == 3
(2..(n ** 0.5)).each{|x| return false if n % x == 0}
return true
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def if_prime_pattern(n)\n return false if n % 3 == 0\n return false if n % 7 == 0\n return false if n % 13 == 0\n\n # (n^2 + 13) % 7 == 0\n return false if n % 7 == 1 or n % 7 == 6\n # (n^2 + 3) % 7 == 0\n return false if n % 7 == 2 or n % 7 == 5\n # (n^2 + 9) % 13 == 0\n return false if n % 13 == 2 or n % 13 == 11\n # (n^2 + 1) % 13 == 0\n return false if n % 13 == 5 or n % 13 == 8\n # (n^2 + 3) % 13 == 0\n return false if n % 13 == 6 or n % 13 == 7\n\n $primes.each do |p|\n break if p > n + 1\n [1, 3, 7, 9, 13, 27].each do |a|\n return false if (n * n + a) % p == 0\n end\n end\n\n # tests above primes are consecutive\n [5, 11, 15, 17, 19, 21, 23, 25].each do |b|\n $primes.each do |p|\n # tests up to the biggest prime less than the square root of n * n + 25\n # the condition p > n + 1 works for 10, and certainly works for big enough n\n return false if p > n + 1\n break if (n * n + b) % p == 0\n end\n end\n true\nend",
"def prime?(num)\n # return false if num < 2\n return true if [2, 3].include? num\n return false if (num % 2).zero? || (num % 3).zero?\n\n i = 5\n s = 2\n\n while (i * i) <= num\n return false if (num % i).zero?\n\n i += s\n s = 6 - s\n end\n true\nend",
"def sum_primes max_number\n sum = 2\n (3..max_number).each do |test_num|\n next if test_num.even?\n prime = true\n # sqrttest = test_num**0.5\n (2..Math.sqrt(test_num)).each do |factor|\n prime = false if (test_num % factor == 0)\n break unless prime\n end\n sum += test_num if prime\n #puts test_num if prime\n end\n return sum\nend",
"def check_prime? n \nn_max_two=Math.sqrt(n).floor \nnot_count=0 \nfor i in 2..n_max_two\n if n % i == 0 \nnot_count +=1 \n end \nend \nif not_count > 0 \n return false \n else \n return true \nend \nend",
"def composite?(num)\n return false if num < 2\n (2...num).any? { |ele| num % ele == 0 }\nend",
"def anti_prime?(num)\n max = 0\n sum_i_array = []\n (1..num).each do |n|\n sum_i = 0\n (1..n).each { |i| sum_i += 1 if n % i == 0 }\n sum_i_array << sum_i\n end\n sum_i_array[-1] == sum_i_array.max\nend",
"def is_prime_2(n)\n\tif n <= 1\n\t\treturn false\n\telsif n == 2 || n == 3\n\t\treturn true\n\telsif n % 2 == 0 || n % 3 == 0\n\t\treturn false\n\telse\n\t\tcounter = 5\n\t\twhile counter*counter <= n\n\t\t\tif n % counter == 0 || n % (counter+2) == 0\n\t\t\t\treturn false\n\t\t\tend\n\t\t\tcounter += 6\n\t\tend\n\tend\n\treturn true\nend",
"def solve\n n = 33\n while true\n begin\n n += 2\n end while n.prime?\n\n s, ds = 2, 6\n while s < n && !(n - s).prime?\n s += ds\n ds += 4\n end\n\n break if s >= n\n end\n \n n\n end",
"def is_prime(n)\n # Returns True if n is prime. \n # This is modified and refactored for Ruby and for numbers less than 2.\n # So far, this is the fastest method I've found.\n # The idea is that all primes except 2 and 3 are of the form 6k - 1 and 6k + 1.\n # Also, this is 4 times faster than #prime_v2?, which is itself 247 times faster than #prime?\n if n < 2 \n return false\n elsif n == 2 or n == 3\n return true\n elsif n % 2 == 0 or n % 3 == 0\n return false\n else\n square_root = (n ** 0.5).to_i\n i = 5\n w = 2\n\n while i <= square_root\n if n % i == 0\n return false\n end\n\n i += w\n w = 6 - w\n end\n end\n\n return true\nend",
"def anti_prime?(num)\n counter = count_divisors(num)\n counters = []\n \n (1...num).each do |i|\n if i.even? #unnecessary to add .even\n counters << count_divisors(i)\n end\n end\n counters.each do |c| \n if c > counter\n return false\n end\n end\n true\nend",
"def prime?(num)\n return false if num == 1\n return true if num == 2 or num == 3 or num == 5 or num == 7\n return false if num % 2 == 0 or num % 3 == 0 or num % 5 == 0 or num % 7 == 0\n (11..Math.sqrt(num).ceil).each do |i| \n return false if num % i == 0\n end\n true \nend",
"def is_prime?(num)\n return false if num.even?\n for i in (2..((num/2.round) + 1))\n return false if num % i == 0\n end\n return true\nend",
"def is_prime?(num)\n return false if num.even?\n for i in (2..((num/2.round) + 1))\n return false if num % i == 0\n end\n return true\nend",
"def coprime?(n1, n2)\n (2...Math.sqrt([n1, n2].max)).each do |el|\n return false if n1 % el === 0 && n2 % el === 0\n end\n\n true\nend",
"def isprime(n)\n if n == 1\n return false\n elsif n == 2\n return true\n else\n (2..Math.sqrt(n).ceil).each { |e| n % e == 0 ? (return false) : next }\n return true\n end\nend",
"def findNextPrime( knownPrimes, knownPrimeSquares )\n nextPrimeFound = false\n\n primeCount = 0\n isPrime = true\n candidate = knownPrimes.last + 2\n if knownPrimes.last == 2\n candidate = 3\n end\n\n while not nextPrimeFound\n while knownPrimeSquares.at( primeCount ) <= candidate\n if candidate % knownPrimes.at( primeCount ) == 0\n isPrime = false\n break\n end\n primeCount += 1\n end\n\n if isPrime\n knownPrimes << candidate\n knownPrimeSquares << candidate * candidate\n nextPrimeFound = true\n else\n isPrime = true\n end\n\n primeCount = 1\n candidate += 2\n end\nend",
"def prime?(n)\n factor = 2\n if n <= 1\n return false\n end\n if n == 2\n return true\n end\n if n == 3\n return true\n end\n if n % 2 == 0\n return false\n end\n if n % 3 == 0\n return false\n end\n if n < 12\n if n % 2 == 0\n return false\n end\n if n % 3 == 0\n return false\n end\n if n % 5 == 0\n return false\n end\n if n % 7 == 0\n return true\n end\n if n % 11 == 0\n return true\n end\n end\n \n ##################REVISIT FOR BETTER ALGORITHM/ASK INSTRUCTOR\n if n == 105557\n return true\n end\n i = 5 \n \n while i * i <= n\n if n % i == 0 or n % (i + 2) == 0\n return false\n end\n i += 6\n end\nend",
"def coprime?(num1, num2)\n # div1 = get_divisors(num1)\n # div2 = get_divisors(num2)\n # # if num1.even? && num2.even?\n # # return false\n # if div1.one? { |ele| div2.include?(ele)}\n # return true\n # else\n # return false\n # end\n\n (2..num1).none? {|factor| num1 % factor == 0 && num2 % factor == 0}\n\n\nend",
"def odd_not_prime(x)\n full_arr = (1..x).to_a\n odd_arr = full_arr.select { |x| x.odd? }\n odd_and_prime = odd_arr.select { |x| !prime?(x) }\n odd_and_prime.size\nend",
"def prime2?\n # Eliminate some simple cases\n return nil if self == 0 or self == 1 # Neither one nor zero are prime or composite\n small_primes = [2, 3, 5, 7, 11, 13]\n return true if small_primes.include?(self)\n\n # According to https://en.wikipedia.org/wiki/Primality_test,\n # All primes except 2 and 3 are of the form:\n # 6k ± 1\n # So we just need to test all k such that 6k + 1 < sqrt n\n return false if (self % 2 == 0)\n return false if (self % 3 == 0)\n max_k = (Math.sqrt(self).floor / 6) + 1\n (small_primes.max..max_k).each do |k|\n return false if (self % (6 * k - 1) == 0)\n return false if (self % (6 * k + 1) == 0)\n end\n return true\n end",
"def coprime? (num_1, num_2)\n smaller = [num_1, num_2].min\n (1..smaller).each do |num|\n if num_1 % num == 0 && num_2 % num == 0 && num != 1\n return false\n end\n end\n return true\nend",
"def circular_primes(max)\n idx = 2 #numbers lower than 2 aren't prime\n circ_primes = []\n\n while idx<max\n if only_odd_digits?(idx) #Check to see if all digits in number are odd\n if is_circular_prime?(idx)\n circ_primes << idx\n end\n end\n\n if idx%2==0 #Only check odd numbers, because evens besides 2 aren't prime\n idx += 1\n else\n idx +=2\n end\n end\n\n return circ_primes.length\nend",
"def is_perfect_square(num)\n return true if num < 2\n\n x = num / 2\n x = (x + num / x) / 2 while x * x > num\n\n x * x == num\nend",
"def is_prime(number)\n return false if number < 3 || number.even?\n\n square = Math.sqrt(number).to_i\n\n !(3..square).any? { |x| number % x == 0 }\nend",
"def coprime?(x, y)\n (2..[x, y].min).none? { |i| x % i == 0 and y % i == 0 }\nend",
"def PrimeNumber?(number)\n return false if number<2 || number%2 ==0\n (3..number-1).select(&:odd?).each do |i|\n return false if number%i == 0\n end\n true\nend",
"def isPrime?(num)\n if ((num == 2) || (num == 5))\n return true\n end\n if (num % 2) == 0\n return false\n end\n if (num % 5) == 0\n return false\n end\n x = Math.sqrt(num)+1\n for i in 2...x\n if((num % i) == 0)\n return false\n end\n end\nend",
"def perfects (n)\n return (1..n).select { |x| x==(1...x).select { |i| x%i==0 }.inject(:+) }\nend",
"def prime(max)\n (1..max).select { |x| (1..max).count { |y| x % y == 0 } == 2 }\nend",
"def prime_checker(num)\n digits = num.to_s.chars\n permutations = digits.permutation(digits.size).map { |n| n.join.to_i }.uniq\n # permutations.reject! { |num| num.to_s.size < digits.size }\n permutations.each do |permutation|\n return 1 if prime?(permutation)\n end\n 0\nend",
"def is_prime(n)\n\n\tif n <= 1\n\t\treturn false\n\tend\n\n\tif n <= 3\n\t\treturn true\n\tend\n\n\tif (n % 2 == 0 || n % 3 == 0)\n\t\treturn false\n\tend\n\n\ti = 5\n\n\twhile i * i <= n\n\n\t\tif n % i == 0 || n % (i + 2) == 0\n\t\t\treturn false\n\t\tend\n\n\t\ti += 6\n\tend\n\n\treturn true\n\t\nend",
"def anti_prime?(num)\n (1...num).none? { |before| factors(before).length > factors(num).length}\nend",
"def perfect_square(number)\n return true if number == 1\n (2..(number / 2)).each do |squ|\n return true if (squ * squ) == number\n end\n false\nend",
"def prime?(integer)\n return false if integer < 2 || (integer.even? && integer != 2)\n\n n = Math.sqrt(integer).floor\n (2..n).none? { |x| (integer % x).zero? }\nend",
"def is_prime?(x)\n return false if x == 1\n return true if x == 2 || x == 3\n return false if x % 2 == 0 || x % 3 == 0\n limit = (x ** (1/2.0)).to_i\n i = 1\n a = 6*i - 1\n b = 6*i + 1\n\n while a <= limit || b <= limit\n return false if x % a == 0 || x % b == 0\n i += 1\n a = 6*i - 1\n b = 6*i + 1\n end\n\n return true\nend",
"def prime?(n)\n return false if n == 1\n return true if n == 2\n\n (2..(Math.sqrt(n).to_i + 1)).each { |rn| return false if n % rn == 0 }\n\n true\nend",
"def is_prime?(n)\n root = Math.sqrt(n)\n return false if n < 2\n return true if n < 4\n return false if n %2 == 0\n return true if n < 9\n return false if n % 3 == 0\n i = 5\n while i < root\n return false if n % i == 0\n return false if n % (i + 2) == 0\n i += 6\n end\n return true\nend",
"def is_prime(n)\n if(n != 2)\n n_sqrt = Math.sqrt(n).round\n for i in 2..n_sqrt\n return false if(n%i==0)\n end\n end\n return true\nend",
"def is_prime? number\n root_floor = (number ** 0.5).floor\n\n # Only check if there are divisors up to the square root. If there are any\n # divisors greater than the square root, there must be divisors less than the\n # square root\n divisors_up_to_square_root = nontrivial_divisors_of(number, {upper_limit: root_floor})\n divisors_up_to_square_root.empty?\nend",
"def is_prime?(number)\n \n if number == 2 then return true end\n if number%2 == 0 then return false end\n if number == 3 then return true end\n if number%3 == 0 then return false end\n \n square_root= Math.sqrt(number).to_i # .to_i is not necessary, but it doesn't hurt (9<9.5 is true)\n \n divisor= 5\n while divisor <= square_root\n \n if number%divisor == 0 then return false end\n \n divisor+= 2\n if number%divisor == 0 then return false end\n \n divisor+= 4\n end\n # note the sequence of divisors, 5,7,11,13,17,19,23,25,29,31... <- these are the set of numbers not divisible by either 2 or 3 or both\n \n return true\nend",
"def is_prime?(number)\n return false if number < 2\n\n #Start at 2, since anything lower isn't prime\n idx = 2\n\n #Anything above has a conjugatae divisor less than sqrt number.\n while idx < number**0.5\n\n if number%idx==0\n return false\n end\n\n #After 2, only check odd numbers for primeness\n if idx%2==0\n idx += 1\n else\n idx += 2\n end\n end\n\n return true\nend",
"def prime(n)\n return 2 if n == 1\n return 3 if n == 2\n primes = [2,3]\n (3..n).each do \n last = primes.last\n a = last + 2\n prime = false\n while prime == false\n prime = true\n primes.each do |p|\n if a % p == 0\n a = a + 1\n prime = false\n break\n end\n end\n end\n primes << a\n end\n primes.last\n end",
"def getSumPrime()\n def isPrime(n)\n return false if n <= 1\n 2.upto(Math.sqrt(n).to_i) do |x|\n return false if n%x == 0\n end\n true\n end\n\n sum=0\n (2..2000000).each { |x| sum=sum+x if isPrime(x) }\n puts sum\nend",
"def coprime?(num_1, num_2)\n (2...num_1).each do |div|\n if num_1 % div == 0 && num_2 % div == 0\n return false\n end\n end\n true\nend",
"def sum_of_primes(n)\n prime_array = []\n (2..n).each do |i|\n next unless prime_number?(i)\n prime_array << i\n end\n prime_array.inject(:+)\nend",
"def p7\n\tprimes = [2]\n\t(1...10001).each do\n\t\tprime = next_prime(primes[-1])\n\t\tprimes << prime\n\tend\n\tprimes[-1]\nend",
"def problem3(num)\n prime = num\n while num%2==0 do num/=2 end\n (3..Math.sqrt(num).to_i).step(2).each { |pf|\n break if num < pf\n while num%pf==0 do\n num/=pf\n prime = pf\n end\n }\n prime\nend",
"def bi_prime?(num)\n (2...num).each do |i|\n if num % i == 0 && !((2...i).any? { |x| i % x == 0 })\n j = num / i\n return true if !((2...j).any? { |x| j % x == 0 })\n end\n end\n\n false\nend",
"def isPrime(num)\n \n prime_test = 3\n if num.odd? && num != 1 && num.is_a?(Integer)\n while (num % prime_test != 0) && prime_test < (num / 5*7*11 ) do prime_test += 2 end\n prime_test = num if (num % prime_test != 0) && prime_test < num\n else\n prime_test = num if num == 2\n end\n return (num == prime_test) ? true : false\n \n\n # #===== other sol 1:\n # require 'prime'\n # num.prime?\n \n # #===== other sol 2:\n # num > 1 && (1..num/2).select {|n| num % n == 0}.size == 1 ? true : false\n \n # #===== other sol 3:\n # return false if num < 2\n # (2...num).to_a.select{|x| num%x == 0}.compact.empty?\nend",
"def is_prime?(n)\n end",
"def nth_prime(n)\n primes = []\n x = 2\n while primes.size < n\n primes << x if (2..Math.sqrt(x)).all? {|i| x % i != 0 }\n x += 1\n end\n primes\nend",
"def circular_prime?(number)\n if number.to_s.size == 1\n return true\n end\n rotations = circular_rotations(number)\n rotations.each do |r|\n if !prime?(r)\n return false\n end\n end\n return true\nend",
"def coprime?(num_1, num_2)\n (2..num_1).each do |div| #don't want to chk 1, so start from 2.. then next num till num_1\n if num_1 % div == 0 && num_2 % div == 0\n return false\n end\n end\n return true\nend",
"def is_prime (number)\n if [1,2,3,5,7,11].include?(number)\n return TRUE\n end\n if number % 2 == 0 and number != 2\n # p \"not prime, divisible by 2\"\n return FALSE\n elsif number % 3 == 0 and number != 3\n # p \"not prime, divisible by 3\"\n return FALSE\n elsif number % 5 == 0 and number != 5\n # p \"not prime, divisible by 5\"\n return FALSE\n elsif number % 7 == 0 and number != 7\n # p \"not prime, divisible by 7\"\n return FALSE\n else\n divisor = 2\n # from one to the square root of a number is all the numbers it could be divided by\n # because after the square root you're repeating yourself.\n while divisor <= (Math.sqrt(number)).ceil\n # while divisor is less than the square root of the ( smallest integer greater than the number )\n if number % divisor == 0 and number != divisor\n return FALSE\n elsif (Math.sqrt(number)).ceil == divisor\n # if the divisor is equal to the square root of the ( smallest integer greater than the number )\n return TRUE\n else\n # increment the divisor\n divisor = divisor + 1\n end\n end\n end\nend",
"def anti_prime?(num)\n num_divisors = divisors(num).length\n\n (1..num).each do |div|\n return false if divisors(div).length > num_divisors\n end\n \n return true\nend",
"def coprime?(num_1,num_2)\n (2..num_1).none?{|fac| num_1 % fac == 0 && num_2 % fac == 0}\nend",
"def squared_primes(array)\n array.find_all{|x| (2..x-1).select(){|i| x % i == 0}.count == 0 && x > 1}.map{|p| p*p}\nend",
"def anti_prime?(number)\n divisor_count = divisors(number)\n (2..number).each do |num| \n return false if divisors(num) > divisor_count \n end \n true\nend",
"def prime(nth_prime)\n n = 0\n prime = 1\n primes = []\n while( n < nth_prime )\n prime += 1\n prime_found = true\n # refactor to use a helper\n (2..( prime-1 ) ).each do |num|\n prime_found = false if prime % num == 0\n break unless prime_found\n end\n if prime_found\n primes << prime\n n+=1\n end\n end\n primes.reduce(:+)\nend",
"def anti_prime?(num)\n num_facts = count_facts(num)\n (1...num).all? { |i| num_facts > count_facts(i) }\nend",
"def coprime?(num_1, num_2)\n for i in 2..num_2\n if num_1 % i == 0\n return false\n else \n return true\n end\n end\n for n in 2..num_1\n if num_2 % n == 0\n return false\n else\n return true\n end\n end\nend",
"def summation_of_primes_2(max)\n sieve = Array.new(max, true)\n sieve[0] = sieve[1] = false # 0 and 1 aren't primes\n sum = 0\n\n p = 2\n while p < sieve.size\n # Mark all composites off\n k = 1\n while k * p < max\n sieve[k * p] = false\n k += 1\n end\n\n sum += p\n\n # Find next prime\n while !sieve[p] and p < sieve.size\n p += 1\n end\n end\n\n sum\nend",
"def prime_proof2(n)\n \n puts n\n # if the last digit isn't 1,3,7, or 9, then thats the only digit we need to check.\n if [1,3,7,9].include? n % 10\n rotate_digits2(n, 0, [0,2,4,5,6,8]) do |test|\n return false if Primes.isPrime?(test)\n end\n return true\n end\n \n len = (Math.log(n) / Math.log(10)).floor + 1\n s = n.to_s\n 0.upto(len) do |i|\n rotate_digits2(n, i) do |test|\n return false if Primes.isPrime?(test)\n end\n end\n puts \"true\"\n exit\nend",
"def bi_prime?(num)\n factors = []\n\n (2...num).each do |factor|\n factors << factor if num % factor == 0 \n end\n\n return false if factors.length > 2\n \n factors.each do |number|\n (2...number).each do |factor|\n return false if number % factor == 0\n end\n end\n\n true\nend",
"def is_prime? n\n for m in 2..(Math.sqrt(n))\n if n%m == 0\n return false\n end\n end\n return true\nend",
"def prime?(num)\n return false if num == 1\n\n return true if num < 4\n\n i = 1\n while i <= Math.sqrt(num)\n i += 1\n next if even_above_two(i)\n\n return false if num % i == 0\n end\n\n true\nend",
"def prime?(integer)\n if integer > 1\n arr = Array.new\n for i in 2..(Math.sqrt(integer).round)\n arr << i\n end\n arr.each do |i|\n return false if integer % i == 0\n end\n return true\n else\n return false\n end\nend",
"def prime?(num)\n return false if num < 2\n\n return true if num <= 3\n\n return false if (num % 2).zero? || (num % 3).zero?\n\n i = 5\n while i < Math.sqrt(num)\n return false if (num % i).zero?\n\n i += 1\n end\n true\nend",
"def squared_primes(array)\n prime = array.find_all do |x| \n divisible = (2..x-1).select {|i| x % i == 0 }\n divisible.count == 0\n end\n prime.map{|p| p*p}\nend",
"def compute_primes\n nums = (@max_checked..@max_checked * 2).map { |x| x.odd? ? x : nil }.to_a\n 1.upto(@primes.index { |p| p * p > @max_checked * 2 }) do |i|\n start_idx = -@max_checked % @primes[i] # prime[i]'s 1st multiple's index\n\n (start_idx..nums.size).step(@primes[i]) { |x| nums[x] = nil }\n end\n @max_checked *= 2\n @primes += nums.compact\n end",
"def is_prime?(num)\n if num > 2 \n if num % 2 == 0\n return false\n end\n i = 3 # start at 3\n maxn = num**(0.5) # go up to the square root of num\n while i <= maxn\n if num % i === 0\n return false\n end\n i = i+2 # count up by 2 to check only odd numbers\n end\n true\n elsif num == 2 # special case for 2\n true\n else\n false\n end\nend",
"def sum_primes(num)\n nums = Hash.new{true}\n\n (2...num**(0.5)).each do |x|\n if nums[x]\n i = x\n while x*i < num\n nums[x*i] = false\n i += 1\n end\n end\n end\n \n sum = 0\n (2...num).each { |x| sum += x if nums[x] }\n sum\nend",
"def is_prime(n) \n return false if n == 1\n return true if n < 4\n return false if (n % 2) == 0 \n return true if n < 9 \n return false if (n % 3) == 0 \n r = Math.sqrt(n).floor \n f = 5\n while (f <= r)\n return false if (n % f) == 0 \n return false if (n % (f + 2)) == 0\n f = f + 6\n end\n return true\nend",
"def is_prime?(n)\n if n == 2\n return true\n end\n\n (2...n).each do |i|\n if n % i == 0\n return false\n end\n end\n true\nend",
"def count_primes(number)\n # create an array from 2-num\n # for each number in the array of possible primes\n # modulo the number by each n\n # if the number % n is 0, it's not a prime number\n # unless the number and n are the same\n possible_primes = (2...number).to_a\n possible_primes.select! do |num|\n # need to return true if num is prime, false if it is not\n # binding.pry if num == 3\n half_num = num\n results = (2...half_num).select do |n|\n # if num % n == 0, means that n evenly divides into num making it not prime\n num % n == 0\n end\n results.empty?\n # any number within results evenly divided into the num\n # making the num not prime\n # so if results is empty, it means that nothing divided into the num\n # making the num prime\n end\n possible_primes.count\nend",
"def coprime?(num_1, num_2)\n\n # return boolean saying whether in the ennumerable none of the numbers\n # between 2 and num_1 divides both num_1 AND num_2 at the same time\n (2..num_1).none? { |n| num_1 % n == 0 && num_2 % n == 0}\n\nend",
"def prime? (number)\n if number == 2\n return true\n elsif number < 2\n return false\n else\n for num in 2..Math.sqrt(number)\n if number % num == 0\n return false\n else\n return true\n end\n end\n end\nend",
"def perfects(n)\n return (6..n).select {|x| factors(x).reduce(:+) == 2*x}\nend",
"def isPrime(num)\n return false if num < 2\n\n sqrt_num = Math.sqrt(num).floor\n 2.upto(sqrt_num){|i|\n if num % i == 0\n return false # 割り切れたら素数でない\n end\n }\n return true\nend",
"def perfect_square?(num)\n (1..num).each do |p|\n if p * p == num\n return true\n end\n end\n return false\nend",
"def prime?(number)\n a = []\n n = (2...number).to_a\n if number == 1 || number == 0 || number.negative?\n false\n else\n n.collect {|x| a << number % x}\n if a.include?(0)\n false\n else\n true\n end\n end\n # (2...number).to_a.each {|x| (number/x).integer? ? false : true}\nend",
"def odd_not_prime(num)\n # code here\n (1..num).step(2).to_a.select { |i| !is_prime?(i) }.count\n\nend",
"def cp1\n\tnumPerm = []\n\tpermPrime = true\n\ttotal = 0;\n\t100.upto(200) do |x|\n\t\t#if (x % 1000 == 0) then p x end\n\t\tif(isPrime(x) == false) then next end\n\t\tnumPer = splitNumberifOdd(x)\n\t\tif(numPer == false) then next end\n\t\tnumPer = numPer.permutation().to_a\n\t\tnumPer = numPer.map {|y| y.join.to_i}\n\t\tpermPrime = true\n\t\tnumPer.each do |perm|\n\t\t\t#printf \"checking %s \\n\", perm\n\t\t\tif(isPrime(perm) == false) then permPrime = false; printf \"x %d- failed %d \\n\",x, perm; break end\n\t\tend\n\t\t#p permPrime\n\t\tif (permPrime == true) then total = total + 1; p x end\n\tend\n\ttotal + 13\nend",
"def perfect_square?(num)\n (1..num).each do |n|\n product = n*n\n return true if product == num\n return false if product > num # short-circuit: too big now!\n end\n\n return false\nend",
"def odd_not_prime(integer_input)\n counter = 0\n odd_integer = 1\n while odd_integer <= integer_input\n if odd_integer == 1\n counter +=1\n odd_integer += 2\n next\n end\n 2.upto(odd_integer-1)do |divisor|\n if odd_integer % divisor == 0\n counter += 1\n break\n end\n end\n odd_integer += 2\n end\n counter\nend",
"def is_prime(n)\n for d in 2..(Math.sqrt(n))\n if (n % d) == 0\n return false\n end\n end\n true\nend",
"def anti_prime?(num)\n num_fact_len = factors(num).length\n\n (2...num).each do |n|\n n_fact_len = factors(n).length\n if n_fact_len > num_fact_len\n return false\n end\n end\n\n return true\nend",
"def is_prime?(num)\n return false if num == 1\n return true if num == 2 \n (2..Math.sqrt(num)+1).each do |x|\n return false if num%x == 0\n end\n true\nend",
"def is_prime?(num)\n return true if num == 1 || num == 2\n return false if num % 2 == 0\n int = 3\n while int <= Math::sqrt(num)\n return false if num % int == 0\n int += 2\n end\n true\nend",
"def recurringCycleLengthOfPrime(n)\n return 0 if n == 2 || n == 5\n\n # Solve multiplicative order of 10 (mod n)\n i = 1\n until (10 ** i - 1) % n == 0\n i = i.next\n end\n\n i\nend",
"def is_prime(n) \r\n\treturn false if n == 1 || n % 2 == 0 \r\n i = 2\r\n while i <= Math.sqrt(n)\r\n if n % i == 0\r\n return false\r\n\t\tend\t\r\n i += 1\r\n\tend\t\r\n true\r\nend",
"def is_prime?(number)\n result = true\n\n # 2 is the only even prime number\n if number == 2\n result = true\n elsif number < 2 or number % 2 == 0\n result = false\n else\n # if there aren't any multiples of n before the square root\n # of n, there aren't any at all.\n root = Math.sqrt(number).ceil\n (3..root).each do |i|\n if number % i == 0\n result = false\n break\n end\n end\n end\n return result\nend",
"def isprime(n)\n \n for x in (3..(n**0.5).abs+2)\n if n % x == 0\n return false\n end\n return true\n end\nend",
"def problem_60a\n num_cut = 5\n# simple\n pairs = {}\n seen_primes = []\n num_primes = 0\n last = start = Time.now\n Primes.each do |p|\n next if p == 2\n b = p.to_s\n seen_primes.each_index do |sp_i|\n sp = seen_primes[sp_i]\n a = sp.to_s\n ai,bi = a.to_i,b.to_i\n ab = (a + b).to_i\n ba = (b + a).to_i\n\n if ba.prime? && ab.prime?\n # We have a pair that works both ways so add the peer to each prime\n pairs[ai] = aa = ((pairs[ai] || []) << bi).uniq\n pairs[bi] = bb = ((pairs[bi] || []) << ai).uniq\n next unless pairs[bi].length >= num_cut - 1 # bi is biggest of pair\n\n check = ([ai] + aa) & ([bi] + bb)\n if check.length >= num_cut\n puts \"Try #{check.inspect}\"\n perm = check.permutation(2).to_a\n new = perm.select do |x,y|\n (x.to_s + y.to_s).to_i.prime? && (x.to_s + y.to_s).to_i.prime?\n end\n if new.length == perm.length\n n = new.flatten.uniq\n sum = n.reduce(&:+)\n puts \"#{n.inspect} *** #{sum}\"\n return sum\n end\n end\n end\n end\n seen_primes << p\n end\n nil\nend",
"def is_prime?(num)\n\n return false if num<2\n\n (2...num).none? {|factor| num%factor == 0}\n\nend",
"def anti_prime?(num)\n anti_factors = factors(num)\n (1...num).none? { |i| anti_factors.length < factors(i).length }\nend",
"def prime?(number)\n if number <= 1\n return false\n end\n (2..Math.sqrt(number)).each do |n|\n if number%n == 0\n return false\n end\n end\n return true\nend",
"def perfect_num?(n)\n if n == 1\n return \"deficient\"\n end\n div_array = []\n (1...n).each do |x|\n if n % x == 0\n div_array << x\n end\n end\n sum = div_array.inject(:+)\n if sum < n\n return \"deficient\"\n elsif sum == n\n return \"perfect\"\n else\n return \"abundant\"\n end\nend",
"def prime number\n return true if number==2\n max = Math.sqrt number\n for i in 2..max\n return false if number%i==0\n end\n return true\nend",
"def primes(n)\n return (2..n).select {|x| factors(x).size() == 2}\nend",
"def circular_primes_of (n)\n res = [n]\n tmp = origin = n.to_s\n (origin.length-1).times do |i|\n tmp.concat(tmp[0]); tmp[0] = ''\n if prime? tmp.to_i then res << tmp.to_i else return nil end\n end\n res\nend"
] |
[
"0.70197606",
"0.6976313",
"0.697596",
"0.69655925",
"0.69559234",
"0.69549006",
"0.69368637",
"0.69122845",
"0.6885894",
"0.68812287",
"0.6868595",
"0.68174845",
"0.68174845",
"0.6804397",
"0.67900175",
"0.67875063",
"0.67739856",
"0.67710984",
"0.6762837",
"0.6762235",
"0.6759351",
"0.6749761",
"0.67435014",
"0.6737571",
"0.6735203",
"0.67343646",
"0.6718759",
"0.6712877",
"0.6710808",
"0.6707748",
"0.6706058",
"0.67007035",
"0.66982615",
"0.66838133",
"0.6680684",
"0.66800654",
"0.6671602",
"0.66703516",
"0.6667215",
"0.6665071",
"0.6660333",
"0.66571695",
"0.66522163",
"0.6650686",
"0.6650302",
"0.66409504",
"0.66400206",
"0.66395557",
"0.6638544",
"0.663719",
"0.6636695",
"0.6635209",
"0.6630696",
"0.6629923",
"0.66240215",
"0.66225505",
"0.6622525",
"0.6617926",
"0.6615307",
"0.6613467",
"0.66114354",
"0.6609375",
"0.66046405",
"0.660277",
"0.6601549",
"0.66007745",
"0.6597798",
"0.65956837",
"0.6593892",
"0.65929353",
"0.65922004",
"0.6590091",
"0.65893275",
"0.6583925",
"0.65833557",
"0.65826607",
"0.6581536",
"0.6581468",
"0.6577124",
"0.65767515",
"0.6576546",
"0.657483",
"0.65724725",
"0.6565179",
"0.65626234",
"0.6560722",
"0.6560355",
"0.6557934",
"0.6554853",
"0.6552041",
"0.65442824",
"0.65423185",
"0.65419674",
"0.6541782",
"0.65414196",
"0.6540312",
"0.6539977",
"0.6536429",
"0.65357226",
"0.65349114",
"0.653386"
] |
0.0
|
-1
|
The ShareThis widget defines a bunch of attributes you can customize. Facebook seems to ignore them (it uses title and description meta tags instead). MySpace, however, only works if you set these attributes.
|
def sharethis_options(post)
content_tag :script, :type=>"text/javascript" do
<<-eos
SHARETHIS.addEntry({
title:'#{escape_javascript(post.title)}',
content:'#{escape_javascript(truncate_words(post.post, 75, '...' ))}'
}, {button:true});
eos
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def share_button(options={})\n %(\n <fb:share-button class=\"meta\">\n #{SHARE_META_OPTIONS.select {|o| options.keys.include?(o) }.collect {|o| %(<meta name=\"#{o}\" content=\"#{options[o]}\" />)}.join(\"\\n\") }\n #{SHARE_LINK_OPTIONS.select {|o| options.keys.include?(o) }.collect {|o| %(<link rel=\"#{o}\" href=\"#{options[o]}\" />)}.join(\"\\n\")}\n </fb:share-button>\n )\n end",
"def set_Share(value)\n set_input(\"Share\", value)\n end",
"def initialize(attributes={})\n super(attributes)\n @share_edit_args = []\n end",
"def show\n set_meta_tags og: {\n url: \"#{request.base_url + request.original_fullpath}\",\n type: \"website\",\n title: \"#{@news.title} Software Libre y Codigo Abierto Panama\",\n description: @news.news_content.content,\n site_name: \"floss-pa\",\n image: \"https://floss-pa.net/images/logo.png}\"\n }\n set_meta_tags twitter: {\n card: \"summary\",\n description: @news.news_content.content,\n title: @news.title,\n creator: \"@flosspa\",\n image: {\n _: \"https://floss-pa.net/images/logo.png}\",\n width: 100,\n height: 100,\n },\n domain: \"Floss-pa\"\n }\n\n\n set_meta_tags author: user_custom_path(@news.user,@news.user.name.gsub(/\\s/,'-'))\n end",
"def share\n self.slug = SecureRandom.urlsafe_base64\n self.published_at = Time.now\n end",
"def meta_fb_ogtitle_tag\n \"<meta property=\\\"og:title\\\" content=\\\"#{@meta[:fb_ogtitle]}\\\" />\" if @meta[:fb_ogtitle]\n end",
"def share_params\n params.require(:share).permit(:title, :content, :image, :image_cache)\n end",
"def facebook_card\n tags = {\"og:type\" => \"article\",\n \"og:title\" => model.pretty_title,\n \"og:description\" => model.description,\n \"og:url\" => Rails.application.routes.url_helpers.blog_post_url(model),\n \"fb:app_id\" => SimpleBlog.fb_app_id}\n set_hash_meta_tags(tags, \"property\") + set_image_meta_tags(model.images, \"og:image\", \"property\")\n end",
"def social_shares(e)\n return unless (e.facebook_share || e.instagram_share || e.linkedin_share || e.xing_share || e.twitter_share)\n c = '<div class=\"social button-wrapper\"> '.html_safe\n\n if e.facebook_share\n c+= \"<a class='fb-share' title='#{t('ShareOnFacebook')}' onclick='#{onclick_social_ga_js('Facebook')}' href='https://www.facebook.com/sharer/sharer.php?u=#{request.url}'>#{t('Share')}</a>\".html_safe\n end\n if e.instagram_share\n c+= \"<a class='ig-share' title='#{t('FollowOnInstagram')}' onclick='#{onclick_social_ga_js('Instagram')}' href='https://www.instagram.com/#{SemiStatic::Engine.config.instagramID&.sub('@', '')}'>#{t('Share')}</a>\".html_safe\n end\n if e.xing_share\n c+= \"<a class='xi-share' title='#{t('ShareOnXing')}' onclick='#{onclick_social_ga_js('Xing')}' href='https://www.xing-share.com/app/user?op=share;sc_p=xing-share;url=#{request.url}'>#{t('Share')}</a>\".html_safe\n end\n if e.linkedin_share\n c+= \"<a class='li-share' title='#{t('ShareOnLinkedIn')}' onclick='#{onclick_social_ga_js('LinkedIn')}' href='https://www.linkedin.com/cws/share?url=#{request.url}'>#{t('Share')}</a>\".html_safe\n end\n if e.twitter_share\n c+= \"<a class='tw-share' title='#{t('ShareOnTwitter')}' onclick='#{onclick_social_ga_js('Twitter')}' href='https://twitter.com/intent/tweet?url=#{request.url}&hashtags=#{SemiStatic::Engine.config.site_name.parameterize}'>#{t('Share')}</a>\".html_safe\n end\n if e.email_share\n c+= mail_to nil, t('Share'), {:subject => e.merged_main_entry.title, :body => request.url, :title => t('ShareViaEmail'), :class => 'em-share', :onclick => \"#{onclick_social_ga_js('Email')}\"}\n end\n c += '</div>'.html_safe\n end",
"def show\n\n set_meta_tags og: {\n title: @newsletter.title,\n description: truncate(@newsletter.greeting, :length => 300, :separator => /\\w/, :omission => \"…\"),\n image: root_url[0..-2] + ActionController::Base.helpers.asset_url('newsletter.png'),\n url: preview_newsletter_url(@newsletter)\n }, title: @newsletter.title\n\n end",
"def show\n set_meta_tags title: @item.title, reverse: true\n @rss = Rss.find(@item.rss_id)\n set_meta_tags twitter: {\n card: \"photo\",\n site: request.url,\n title: @item.title,\n image: @item.image,\n }\n end",
"def set_site_meta_tags\n config = ZanoboRails::Crawlable.configuration\n\n site_ids = {\n separator: config.page_title_sitename_separator,\n reverse: config.page_title_sitename_pos == 'right'\n }\n\n if config.gplus_id.present?\n site_ids[:publisher] = \"https://plus.google.com/#{config.gplus_id}\"\n end\n if config.twitter_id.present?\n site_ids[:twitter] = \"@#{config.twitter_id}\"\n end\n if config.fb_app_id.present?\n site_ids[:fb] = { app_id: \"@#{config.fb_app_id}\" }\n end\n if config.site_name.present?\n site_ids[:open_graph] = { site_name: config.site_name }\n site_ids[:site] = config.site_name\n end\n\n set_meta_tags(site_ids)\n end",
"def set_AllowShare(value)\n set_input(\"AllowShare\", value)\n end",
"def artist_social(artist)\n\t #-----------For Artist Meta Tags----------------\n\n\t #Page Title, Facebook Title and Twitter Title\n\t @social_title = artist.name+\" on Three Repeater\"\n\t #Meta description (google), Facebook Description, and Twitter Card Description\n\t @social_descrip = artist.bio\n\n\t #logic around figuring out which facebook url is used\n\t facebook_url(artist)\n\n\t #Twitter ID\n\t @social_twitter_name = artist.twitter_name\n\n\t #Image for twitter and FB\n\t @social_image = artist.logo.to_s\n\n\t #------------------------------------------------\n\n end",
"def share_with_facebook_url(opts)\n\n # Generates an url that will 'share with Facebook', and can includes title, url, summary, images without need of OG data.\n #\n # URL generate will be like\n # http://www.facebook.com/sharer.php?s=100&p[title]=We also do cookies&p[url]=http://www.wealsodocookies.com&p[images][0]=http://www.wealsodocookies.com/images/logo.jpg&p[summary]=Super developer company\n #\n # For this you'll need to pass the options as\n #\n # { :url => \"http://www.wealsodocookies.com\",\n # :title => \"We also do cookies\",\n # :images => {0 => \"http://imagelink\"} # You can have multiple images here\n # :summary => \"My summary here\"\n # }\n\n url = \"http://www.facebook.com/sharer.php?s=100\"\n\n parameters = []\n\n opts.each do |k,v|\n key = \"p[#{k}]\"\n\n if v.is_a? Hash\n v.each do |sk, sv|\n parameters << \"#{key}[#{sk}]=#{sv}\"\n end\n else\n parameters << \"#{key}=#{v}\"\n end\n\n end\n\n url + parameters.join(\"&\")\n end",
"def share(name)\n name_li(name).button(:title=>\"Share content\").click\n self.wait_until { self.text.include? \"Or, share it on a webservice:\" }\n self.class.class_eval { include ShareWithPopUp }\n end",
"def pinterest_share_button(picture, attributes = { :class => 'pinterest-share' })\n options = {\n :url => picture_url(picture),\n :media => URI.join(root_url, picture.image.url),\n :description => picture.dressing_tips\n }\n attributes[:target] = '_blank'\n attributes[:title] = t('social_media.share_on_pinterest')\n link_to image_tag('icons/pinterest.png'), pinterest_share_url(options), attributes\n end",
"def set_meta_tags_for_company(company)\n co_meta_info = CompanyMetaInfoAdapter.new(company)\n\n set_meta_tags title: co_meta_info.title,\n description: co_meta_info.description,\n keywords: co_meta_info.keywords,\n og: { title: helpers.full_page_title( page_title: co_meta_info.title),\n description: co_meta_info.og[:description] }\n\n end",
"def create_facebook_meta_tag(contest)\n %Q(<meta property=\"og:url\" content=\"#{contest_url(contest)}\" />\n <meta property=\"og:type\" content=\"website\" />\n <meta property=\"og:title\" content=\"#{contest.title}\" />\n <meta property=\"og:image\" content=\"#{contest.image.url(:original)}\" />).html_safe\n end",
"def share_icons_page(url_or_story_obj, opts={})\n # Resolve a relative path to an absolute url\n url_or_story_obj = LocalSite.home_page(@local_site) + url_or_story_obj if url_or_story_obj.class == String && url_or_story_obj !~ %r{^https?:}\n\n opts[:class] ||= \"share_page_tools\"\n\t\tdisplay = \"<div class=\\\"#{opts[:class]}\\\">\"\n\t\tdisplay += \"#{fb_like_iframe(url_or_story_obj, :type => opts[:page_type], :layout => opts[:fb_like_layout], :show_faces => opts[:fb_like_show_faces], :width => opts[:fb_like_width], :height => opts[:fb_like_height])}\" unless opts[:fb_like_below]\n #---- No Facebook Share anymore since FB has deprecated that in favour of FB like ---\n\t\t#display += fb_share_link(url_or_story_obj, :type => opts[:fb_share_type]) + \n\t\tdisplay += tweet_page(url_or_story_obj, :tweet_text => opts[:tweet_text], :link_text => opts[:twitter_link_text], :type => opts[:page_type], :toolbar => opts[:toolbar]) + \n \t\temail_page(url_or_story_obj, :link_text => opts[:email_link_text], :class => opts[:email_class], :title => opts[:email_title], :type => opts[:page_type], :toolbar => opts[:toolbar]) +\n \t\taddthis_page(url_or_story_obj, :link_text => opts[:addthis_link_text], :type => opts[:page_type])\n \t\tdisplay += \"<div style=\\\"clear:both; padding-top:14px\\\">#{fb_like_iframe(url_or_story_obj, :layout => opts[:fb_like_layout], :show_faces => opts[:fb_like_show_faces], :width => opts[:fb_like_width], :height => opts[:fb_like_height])}</div>\" if opts[:fb_like_below]\n display += \t\"</div>\"\n\tend",
"def set_meta( title, *description )\n\t\t@title = title\n\t\t@description = description.first[0..200] unless description.first.blank?\n\tend",
"def facebook_share_params\n params.require(:facebook_share).permit(:url, :post_id, :sharecount)\n end",
"def api_friendly_ref_type\n 'share'\n end",
"def share_params\n params.require(:share).permit(:activity_id, :content, :object_ids)\n end",
"def injectable_meta \n set_meta_tags title: \"#{controller_name.humanize.titleize + ' - ' + action_name.capitalize}\",\n description: 'NoBull Software Co.\\'s NoBull Website Ordering Thingy™!👋' ,\n keywords: 'webapp, web site development, business information',\n index: false,\n nofollow: true,\n icon: [\n { href: \"#{ActionController::Base.helpers.asset_path('favicon.ico')}\"},\n { href: \"#{ActionController::Base.helpers.asset_path('favicon-96x96.png')}\", sizes: '32x32 96x96', type: 'image/png' },\n { href: \"#{ActionController::Base.helpers.asset_path('apple-icon.png')}\", rel: 'apple-touch-icon-precomposed', sizes: '32x32', type: 'image/png' },\n ]\n end",
"def share_as_keywords\n spec_keywords('share_as')\n end",
"def set_individual_action_meta_information(args={})\n\t\t\t@title = args[:title]\n\t\t\t@meta_description = args[:description]\n\t\tend",
"def default_metatags record = nil\n @default_metatags ||= begin\n tags = {\n 'description' => translate('tagline'),\n 'og:site_name' => translate('we_meditate'),\n 'og:url' => request.original_url,\n 'og:image' => ApplicationController.helpers.image_url('metadata/preview.png'),\n 'og:locale' => locale,\n # 'og:locale:alternate' => Rails.configuration.published_locales.map(&:to_s),\n 'twitter:site' => Rails.application.config.twitter_handle,\n 'twitter:creator' => Rails.application.config.twitter_handle,\n }\n\n set_record_metatags!(tags, record) if record.present?\n tags['og:title'] = tags['title']\n tags['og:description'] = tags['description']\n tags\n end\n end",
"def twitter_share_button(picture, attributes = { :class => 'twitter-share' })\n options = {\n :url => picture_url(picture),\n :text => t('social_media.tweet_template', :url => picture_url(picture))\n }\n attributes[:target] = '_blank'\n attributes[:title] = t('social_media.share_on_twitter')\n link_to image_tag('icons/twitter.png'), twitter_share_url(options), attributes\n end",
"def share(item)\n name_li(name).button(:title=>\"Share content\").click\n self.wait_until { @browser.text.include? \"Or, share it on a webservice:\" }\n self.class.class_eval { include ShareWithPopUp }\n end",
"def facebook_share(deal_url)\n response = { \n :id => self.id,\n\t :name => self.title,\n\t :caption => self.merchant.name,\n\t :description => self.description, \n\t :picture => self.deal_images.size > 0 ? self.deal_images[0].image.url : '',\n\t :url => deal_url\n\t }\n\t return response\n end",
"def collectible_share_button decorator, size=nil, options={}\n if current_user\n if size.is_a? Hash\n size, options = nil, size\n end\n entity = decorator.object\n button = button_to_submit '',\n new_user_invitation_path(shared_class: entity.class.to_s, shared_id: entity.id),\n 'glyph-share',\n size,\n options.merge(mode: :modal, title: 'Share This')\n content_tag :div, button, class: 'share-button glyph-button'\n end\n end",
"def handle_title(name, attrs) \n \n end",
"def share_text_long_html\n # For now, just make it the same as short version\n \"<b>#{self.share_text_long}</b>\"\n end",
"def hash\n [private_widget_share, saml, saml_autocreate_access_role, saml_autocreate_users_domains, saml_can_be_enabled, saml_idp_endpoint, saml_idp_initiated_login, saml_idp_metadata_uploaded, saml_login_url, saml_strict_mode].hash\n end",
"def site_meta\n end",
"def site_meta\n end",
"def share\n self.slug = SecureRandom.urlsafe_base64\n end",
"def show\n desc = @event.desc.truncate(160)\n\n set_meta_tags description: desc,\n og: {\n title: \"Cosplay event - #{@event.title}\",\n type: 'website',\n description: desc,\n image: @event.image.attached? ? @event.image.variant(resize: \"1024\", interlace: \"plane\").processed.service_url : nil\n }\n end",
"def set_static_page_metatags! tags, record\n if record.role == 'home'\n tags['title'] = translate('we_meditate')\n image = MediaFile.find_by(id: record.content_blocks.first['data']['image']['id']) if record.content_blocks.present?\n elsif record.parsed_content.present? && record.parsed_content['mediaFiles'].present?\n image = MediaFile.find_by(id: record.parsed_content['mediaFiles'].first)\n end\n\n tags['og:image'] = image_url image.file_url if image.present?\n tags['og:type'] = 'website' if %w[home contact privacy articles meditations subtle_system].include?(record.role)\n end",
"def og(*args, &block)\n options = Map.options_for(args)\n\n tagz {\n options.each do |name, value|\n name = name.to_s\n\n unless name =~ /^og:/\n name = \"og:#{ name }\"\n end\n\n content = Array(value).join(', ')\n\n meta_(:property => name, :content => content)\n __\n end\n }\n end",
"def set_facebook_share\n @facebook_share = FacebookShare.find(params[:id])\n end",
"def show\n # set_meta_tags MetaTag.new({host: request.host, movie: @movie}).hash_options\n impressionist(@post, nil, { unique: [:session_hash] })\n @post.impressionist_count(:filter => :params)\n\n set_meta_tags title: @post.title,\n site: 'Cat Blog',\n description: @post.summary,\n keywords: @post.keywords,\n og: {\n title:'Cat Blog',\n description: @post.summary,\n type: 'website',\n url: post_url(@post)\n }\n\n\n\n end",
"def share_params\n\t params.require(:share).permit(:user_email, :edit, :comments)\n\t end",
"def post_shareable_params\n params.require(:post_shareable).permit(:post_id, :slug, :photo_id, :facebook_headline, :facebook_description, :twitter_headline)\n end",
"def facebook_og_tags(options={})\n Liker::Config.button_defaults ||= {}\n options[:button_config] ||= {}\n [ Liker::Config.site_name ? tag(:meta, :property => 'og:site_name', :content => Liker::Config.site_name) : nil,\n Liker::Config.page_id ? tag(:meta, :property => 'fb:page_id', :content => Liker::Config.page_id) : nil,\n og_image_tag(Liker::Config.image_url),\n # todo add fb:admins and other OG tags\n tag(:meta, :property => 'og:type', :content => options[:type] || 'article'),\n options[:title].present? ? tag(:meta, :property => 'og:title', :content => options[:title]) : nil,\n options[:description].present? ? tag(:meta, :property => 'og:description', :content => options[:description]) : nil,\n options[:url].present? ? tag(:meta, :property => 'og:url', :content => options[:url]) : nil\n ].compact.join(\"\\n\").html_safe + \"\\n\"\n end",
"def set_record_metatags! tags, record\n tags['title'] = record.name\n tags['description'] = record.excerpt if record.respond_to?(:excerpt)\n tags['og:url'] = wm_url_for(record)\n tags['og:type'] = 'article'\n tags['og:image'] = record.thumbnail.url if record.try(:thumbnail).present?\n tags['og:article:published_time'] = record.created_at.to_s(:db)\n tags['og:article:modified_time'] = record.updated_at.to_s(:db)\n tags['og:article:section'] = record.category&.name if record.is_a?(Article)\n tags['twitter:card'] = 'summary'\n\n set_locale_metatags!(tags, record) if record.try(:translatable?)\n set_static_page_metatags!(tags, record) if record.is_a?(StaticPage)\n set_video_metatags!(tags, record) if record.try(:vimeo_metadata).present?\n end",
"def share_on_facebook_url(object)\n url = member_url([@tier, @topic, object])\n \"http://www.facebook.com/share.php?u=#{url}\"\n end",
"def share_params\n params.require(:share).permit(:user_id, :shared_type, :shared_id, :comment)\n end",
"def marketing_name\n super\n end",
"def widget_attrs(widget)\n {}\n end",
"def share_content\n self.div(:id=>\"entity_actions\").span(:class=>\"entity_share_content\").click\n self.wait_until { @browser.text.include? \"Who do you want to share with?\" }\n self.class.class_eval { include ShareWithPopUp }\n end",
"def set_share\n @share = Share.friendly.find(params[:id])\n end",
"def customize\n @title = \"Payload_Free_Package\"\n @reverse_domain = \"com.anycorp\"\nend",
"def share_name=(new_name)\n @share_edit_args += [ \"-n\", new_name ]\n end",
"def fb_page_title\n \"\"\n end",
"def prepare_meta_tags(options = {})\n defaults = {\n author: nil,\n authors: [],\n description: nil,\n description_og: nil,\n description_twitter: nil,\n images: [],\n #is_duplicate?: false,\n # # used to determine if we should rel=canonical, true if viewing a paginated\n # just comparing request url to canonical for now\n # form of a full-page-enabled resource\n keywords: [],\n nofollow?: false,\n noindex?: false,\n page: nil, # Have to throw this into the title\n pages: nil, # along with this\n title: nil, # Just the descriptive part of the title\n #title_format: nil, # Title with placeholders for sitename, pages, and separators\n # disabling this for now, because getting it to with with meta-tags\n # current title passing scheme would require reading placement and\n # then monkey-patching parameters\n #title_separator: '|', #set this at higher level # '-', 'on', ':', etc\n #title_site_name_position: 'right', #set this at higher level\n #title_site_name: SITE_IDS[:NAME], # provided earlier on, meta-tags ties to other site identifier tags\n title_og: nil,\n title_twitter: nil,\n type: 'page', # og and twitter need types, we generate from our map if missing\n type_og: nil,\n type_twitter: nil,\n video: nil,\n url: nil, # canonical, required by og \"#{request.url}\"\n url_current: request.url,\n url_next: nil, # if paged and no full-page alternative\n url_prev: nil, # if paged and no full-page alternative\n }\n options.reverse_merge! defaults\n\n # @todo Raise some errors if mandatory things are missing as required by\n # og and twitter, i.e.\n # We want this to fill out as much as possible, but it needs a base of info\n # description\n # title (except certain cards...)\n # url - this is the big one, always needed\n # image_url - for og\n if options[:url].blank?\n raise MetaTagError, 'No url defined for content, required by OG and needed if protocol different from canonical'\n end\n\n # initialize return array\n return_values = {\n author: [],\n og: { image: []},\n twitter: { creator: []}\n }\n\n # Authors\n options[:authors] << options[:author] if options[:author]\n options[:authors].each do |author|\n if author.has_key?(:gplus_id) and (id = author[:gplus_id])\n return_values[:author] << \"https://plus.google.com/#{id}\"\n end\n if author.has_key?(:twitter_id)\n return_values[:twitter][:creator] << id\n end\n end\n\n # Descriptions\n return_values[:description] = options[:description]\n return_values[:og][:description] = options[:description_og]\n return_values[:twitter][:description] = options[:description_twitter]\n\n # Images\n # @todo existence checks and warnings for sizes, AR, filesize, etc\n # @todo Need to take in all images and distribute to each stream according to size appropriateness,\n # unless specifically tagged to a stream\n\n # Images - OG\n # @todo pass https url through secure_url, width and height once after\n # https://github.com/kpumuk/meta-tags/issues/63 is resolved\n options[:images].each do |image|\n if image.has_key? :url\n return_values[:og][:image] << image[:url]\n\n #if image.has_key? :width and image.has_key? :height\n # return_values[:og][:image][:width] = image[:width].to_i\n # return_values[:og][:image][:height] = image[:height].to_i\n #end\n end\n end\n\n # Images - Twitter\n # Falls back to open graph, let's rely on that for now\n # @todo Support custom images for twitter\n\n # Keywords\n return_values[:keywords] = options[:keywords]\n\n # Noindex, nofollow\n # @todo Build in checking for if these are turned off for this object type somewhere\n return_values[:noindex] = options[:noindex?]\n return_values[:nofollow] = options[:nofollow?]\n\n # Titles\n return_values[:og][:title] = options[:title_og] if options[:title_og]\n return_values[:twitter][:title] = options[:title_twitter] if options[:title_twitter]\n\n #if options.has_key)[:title_format]\n # #if options[:title_page_format]\n #\n # end\n # return_values[:title] = options[:title_format].gsub(['special','characters'],['value','otherval'])\n #else\n if options[:pages] and options[:page] and options[:pages] > 1 and options[:page] > 1\n return_values[:title] = [\n options[:title],\n t('pagination.page_x_of_y', page: options[:page], pages: options[:pages])\n ]\n else\n return_values[:title] = options[:title]\n end\n #end\n\n # Types\n og_content_type = options[:type_og]\n if og_content_type and ZanoboRails::Crawlable.content_types_for(:og).include? og_content_type\n return_values[:og][:type] = og_content_type\n elsif type_provided = (general_type = options[:type] and ZanoboRails::Crawlable.general_content_types.include? general_type)\n return_values[:og][:type] = ZanoboRails::Crawlable::Advisor.og_content_type_for(general_type)\n else\n # Type is REQUIRED, we really should test for required values.\n return_values[:og][:type] = ZanoboRails::Crawlable::Advisor.recommend(:content_type, :og).to_s\n end\n\n twitter_content_type = options[:type_twitter]\n if twitter_content_type and ZanoboRails::Crawlable.content_types_for(:twitter).include? twitter_content_type\n return_values[:twitter][:type] = twitter_content_type\n elsif type_provided\n return_values[:twitter][:type] = ZanoboRails::Crawlable.twitter_content_type_for(general_type)\n else\n # Type is REQUIRED\n return_values[:twitter][:type] = ZanoboRails::Crawlable::Advisor.recommend(:content_type, :twitter).to_s\n end\n\n # URLS\n # og:url\n # twitter:url\n # rel=canonical\n return_values[:og][:url] = options[:url]\n return_values[:twitter][:url] = options[:url]\n return_values[:canonical] = options[:url] unless request.url == options[:url]\n return_values[:next] = options[:url_next]\n return_values[:prev] = options[:url_prev]\n\n # Video\n #og:video => {\n # :director => 'http://www.imdb.com/name/nm0000881/',\n # :writer => ['http://www.imdb.com/name/nm0918711/', 'http://www.imdb.com/name/nm0177018/']\n #}\n\n # Tell og and twitter to use primary description and title if nothing is customized to them\n return_values[:og][:description] = :description if return_values[:og][:description].nil?\n return_values[:twitter][:description] = :description if return_values[:twitter][:description].nil?\n return_values[:og][:title] = :title if return_values[:og][:title].nil?\n return_values[:twitter][:title] = :title if return_values[:twitter][:title].nil?\n\n return_values\n end",
"def show\n @page_title = @podcast.title\n @page_description = @podcast.extrait\n @page_keywords = \"Podcasts, enseignements, Parole de Dieu, méditation, Jesus Christ\"\n\n set_meta_tags og: {\n title: @podcast.title,\n type: \"article\",\n url: request.url,\n image: rails_blob_path(@podcast.cover)\n }\n\n # adding acticle og\n set_meta_tags article: {\n published_time: @podcast.created_at,\n modified_time: @podcast.updated_at,\n section: @podcast.type_podcast.name,\n tag: \"MPPP\"\n }\n\n # adding twitter card\n set_meta_tags twitter: {\n title: @podcast.title,\n creator: \"MPPP\",\n card: @podcast.extrait,\n site: request.url,\n image: rails_blob_path(@podcast.cover)\n }\n track \"Viewed Podcast\", title: @podcast.title\n end",
"def sharing=(sharing)\n validator = EnumAttributeValidator.new('String', [\"sharingNone\", \"sharingMultiWriter\"])\n unless validator.valid?(sharing)\n fail ArgumentError, \"invalid value for \\\"sharing\\\", must be one of #{validator.allowable_values}.\"\n end\n @sharing = sharing\n end",
"def meta_tag(key)\n value = @item[key] || @config[:meta_data][key]\n if key == :author && value[0] == \"@\" && author_full_name = item[:author_full_name]\n value = %Q{#{author_full_name} (#{value})}\n end\n return '<meta name=\"%s\" content=\"%s\">' % [key, value] if value\n end",
"def share?(option = {})\n attribution = option[:attr] || false\n commercial = option[:comml] || false\n derivative = option[:deriv] || false\n share_alike = option[:sa] || false\n\n # Can't share CC-liecensed works without attribution, unless Public Domain\n if(!attribution && !@license.eql?('PublicDomain'))\n return false\n end\n\n # Can't share CC-licensed works \"remixed\", if under and non-deriv license\n if(derivative &&\n %w{Attribution-NoDerivs Attribution-NonCommercial-NoDerives}.include?(@license))\n return false\n end\n\n ...\n\n end\n\nend",
"def set_seo_meta(title, options = {})\r\n #todo\r\n keywords = options[:keywords] || \"问答\"\r\n description = options[:description] || \"Kejian.TV 课件交流系统是中国最大的教育资源在线集散平台,同时,课件交流系统也是中国最专业的在线学习社区。\"\r\n\r\n if title.length > 0\r\n @seo[:title] = \"#{title}\"\r\n end\r\n @seo[:keywords] = keywords\r\n @seo[:description] = description\r\n end",
"def prepare_meta_tags(options={})\n site_name = I18n.t('meta_tag.site_name')\n title = I18n.t('meta_tag.title')\n description = I18n.t('meta_tag.description')\n image = options[:image] || ActionController::Base.helpers.image_url('/homepage/teaser_bg.jpg')\n current_url = request.url\n\n # Let's prepare a nice set of defaults\n defaults = {\n site: site_name,\n title: title,\n image: image,\n description: description,\n keywords: %w[bookmarks web mobile free application],\n twitter: {\n site_name: site_name,\n site: '@wundermarks',\n card: 'summary',\n description: :description,\n image: image\n },\n og: {\n url: current_url,\n site_name: site_name,\n title: :title,\n image: image,\n description: :description,\n type: 'website'\n }\n }\n\n options.reverse_merge!(defaults)\n\n set_meta_tags options\n end",
"def render_shareable(options = {}, &block)\r\n buttons = Shareable::Helpers::SocialButtons.new self, refine_options(options)\r\n buttons.to_s\r\n end",
"def share_params\n params.require(:share).permit(:author_id, :title, :content, :actable_id, :actable_type, attachment_file_attributes: [:document, :attachment_id])\n end",
"def store_metadata\n html = HTMLParse.new(url)\n self.meta_title = html.title\n self.meta_desc = html.desc\n end",
"def add_company_share(company_id, share)\n path = \"/companies/#{company_id}/shares\"\n defaults = {visibility: {code: \"anyone\"}}\n post(path, MultiJson.dump(defaults.merge(share)), \"Content-Type\" => \"application/json\")\n end",
"def html_branding\n @attributes[:html_branding]\n end",
"def share_to_fb_timeline?\n self.fb_action_id == FBSharing::Underway\n end",
"def custom_meta_data\n end",
"def set_meta_tags_title\n set_meta_tags site: 'benradler.com'\n end",
"def set_meta_tags_for_url_path(base_url, request_fullpath)\n\n page_title = t(LOCALE_TITLE_KEY, default: SiteMetaInfoDefaults.title)\n page_desc = t(LOCALE_DESCRIPTION_KEY, default: SiteMetaInfoDefaults.description)\n\n set_meta_tags site: SiteMetaInfoDefaults.site_name,\n title: page_title,\n description: page_desc,\n keywords: create_keywords\n\n set_page_meta_images\n\n set_og_meta_tags(site_name: SiteMetaInfoDefaults.site_name,\n title: helpers.full_page_title(page_title: page_title),\n description: page_desc,\n type: t(LOCALE_TYPE_KEY, default: SiteMetaInfoDefaults.og_type),\n base_url: base_url,\n fullpath: request_fullpath)\n\n set_facebook_meta_tags\n\n set_twitter_meta_tags(card: t(LOCALE_TWITTER_CARD_KEY, default: SiteMetaInfoDefaults.twitter_card_type))\n\n end",
"def share(s)\n\t\treturn unless share?\n\t\t\n\t\tif s.resource.is_a?(Song)\n\t\t\t# fix message to either\n\t\t\t# - the user's message\n\t\t\t# - title by artist\n\t\t\t# - title\n\t\t\tmsg = s.message\n\t\t\tif msg.to_s == \"\"\n\t\t\t\tmsg = s.resource.title\n\t\t\t\ta = s.resource.artists.collect { |x| x.name }.to_sentence\n\t\t\t\tmsg += \" by #{a}\" unless a.to_s == \"\"\n\t\t\tend\n\t\t\tlogger.debug \"share message: #{msg}\"\n\t\t\t\n\t\telsif s.resource.is_a?(Playlist)\n\t\t\t# fix message to either\n\t\t\t# - the user's message\n\t\t\t# - playlist by user\n\t\t\tmsg = s.message\n\t\t\tif msg.to_s == \"\"\n\t\t\t\tmsg = \"#{s.resource.name} by #{s.resource.user.name}\"\n\t\t\tend\n\t\t\tlogger.debug \"share message: #{msg}\"\n\t\tend\n\t\t\n\t\tbegin\n\t\t\tcase [provider, s.resource_type]\n\t\t\twhen [\"facebook\", \"Song\"]\n\t\t\t\tshare_song_on_facebook(s, msg)\n\t\t\t\n\t\t\twhen [\"facebook\", \"Playlist\"]\n\t\t\t\tshare_playlist_on_facebook(s, msg)\n\t\t\t\t\n\t\t\twhen [\"twitter\", \"Song\"]\n\t\t\t\tshare_song_on_twitter(s, msg)\n\t\t\t\n\t\t\twhen [\"twitter\", \"Playlist\"]\n\t\t\t\tshare_playlist_on_twitter(s, msg)\t\t\n\t\t\tend\n\t\trescue Exception => e\n\t\t\tlogger.debug \"error sharing #{s.resource.display} on #{provider}\"\n\t\t\tcatch_error(s, e)\n\t\tend\n\tend",
"def attributes\n super.merge('url' => url, 'display_url' => display_url)\n end",
"def set_bookmark_meta_data\n begin\n page = Pismo::Document.new(self.full_url)\n self.name = page.html_title\n self.favicon_url = page.favicon\n self.description = page.description\n rescue => e\n self.description = \"Error => #{e}\"\n ensure\n self.save\n end\n end",
"def share_button(options = {}, &block)\n defaults = {\n url: default_url,\n label: 'Share',\n target: '_blank',\n class: 'facebook-share-button'\n }\n\n settings = defaults.merge options\n\n url = \"#{SHARE_URL}?u=#{CGI.escape settings[:url]}\"\n label = settings[:label]\n settings.delete(:url)\n settings.delete(:label)\n\n if block_given?\n link_to(url, settings, &block)\n else\n link_to label, url, settings\n end\n end",
"def share_text_short\n \"I'm looking at #{self.latest_name.titleize} on Dinesafe.\"\n end",
"def seo_title\n meta_title.blank? ? name : meta_title\n end",
"def share_id=(value)\n @share_id = value\n end",
"def share_params\n params.require(:share).permit(:avatar,:user_id,:username,:email, :body, :created_at, :updated_at, :location, :car_make, :price, :route, :distance, :date, :luggage, :experience,:superuser_id)\n end",
"def custom_meta_data\n {\n position: 7,\n title_before: I18n.t('admin.website')\n }\n end",
"def share_params\n params[:share]\n end",
"def display_social_bookmarks?; true end",
"def override_default_settings(store)\n return unless store.ecwid?\n store.update_settings :widgets,\n product_rating_autoembed: true,\n product_summary_autoembed: true,\n product_tabs_autoembed: true\n end",
"def fb_page_title\n site_title\n end",
"def add_share(share)\n path = \"/people/~/shares\"\n defaults = {:visibility => {:code => \"anyone\"}}\n post(path, MultiJson.dump(defaults.merge(share)), \"Content-Type\" => \"application/json\")\n end",
"def twitter_share_url(options = {})\n \"https://twitter.com/share?#{options.to_query}\"\n end",
"def render_sharing?\n true\n end",
"def fbook\n @user = Koala::Facebook::API.new(ENV[\"ACCESS_TOKEN\"])\n if self.title != nil\n @user.put_connections(\"me\", \"feed\", :message => \"#{self.title} - #{self.short_desc} ($#{self.price})\")\n end\n end",
"def to_meta_tag_options(host = nil)\n meta_tags = { 'title' => title,\n 'description' => description,\n 'keywords' => keywords,\n 'og:title' => fb_title,\n 'og:description' => fb_description }\n meta_tags['og:image'] = \"http://#{host}#{fb_image.url}\" if host.present? && fb_image?\n meta_tags.select { |key, value| value.present? }\n end",
"def share\n # Find the relevant campaign by it's slug\n @campaign = Campaign.find params[:id]\n\n # The base URL that we can tweet from. This opens up a new tweet\n # window on Twiter's website. URL parameters like the actual\n # tweet content are filled in via javascript\n @twitter_link = \"https://twitter.com/intent/tweet\"\n end",
"def share\n @share ? @share : 'yes'\n end",
"def share_text_long\n # For now, just make it the same as short version\n \"\" + self.share_text_short\n end",
"def set_meta\n meta.tap do |m|\n m.tag = [{\n system: META_SYSTEM,\n code: META_CODE,\n display: META_DISPLAY\n }]\n end\n end",
"def set_seo_meta(title,keywords = '',desc = '')\n if title\n @page_title = \"#{title}\"\n if params[:page]\n @page_title += \" » (First#{params[:page]}Page)\"\n end\n @page_title += \" » #{@setting.site_name}\"\n else\n @page_title = @setting.site_name\n end\n @meta_keywords = keywords\n @meta_description = desc\n end",
"def album_social(artist,album)\n\n\t #-----------For Album Meta Tags----------------\n\n\t #Page Title, Facebook Title and Twitter Title\n\t @social_title = @album.al_name+\" by \"+ @artist.name+\" on Three Repeater\"\n\t #Meta description (google), Facebook Description, and Twitter Card Description\n\t @social_descrip = album.description\n\n\t #facebook url\n\t @social_fb_url = artist_show_album_url(artist.url_slug,album.album_url_slug)\n\n\n\t #Twitter ID\n\t @social_twitter_name = artist.twitter_name\n\n\t #Image for twitter and FB\n\t if album.art.blank?\n\t\t @social_image = artist.logo.to_s\n\t else\n\t\t @social_image = album.art.to_s\n\t end\n\n end",
"def dashboard\n @meta_data = {:page_title => \"Chicago Ideas Week | Dashboard\", :og_image => \"\", :og_title => \"Chicago Ideas Week\", :og_type => \"article\", :og_desc => \"\"}\n @user = current_user\n end",
"def facebook_share_feature(feature)\n link_to \"recommend on fb\", \"https://www.facebook.com/sharer/sharer.php?u=#{feature_point_url(feature)}\", :class => \"facebook\"\n end",
"def protected_attributes=(attributes = nil)\n attributes = attributes.is_a?(Hash) ? attributes.symbolize_keys : {}\n send :attributes=, attributes.only(:author, :email, :summary, :content, :attachment), false\n end",
"def set_video_metatags! tags, record\n metadata = record.vimeo_metadata\n metadata = metadata[:horizontal] if metadata.key?(:horizontal)\n return unless metadata.present?\n\n tags.merge!({\n 'og:type' => 'video.other',\n 'og:image' => metadata[:thumbnail],\n 'og:video' => metadata[:download_url],\n 'og:video:duration' => metadata[:duration],\n 'og:video:release_date' => record.created_at.to_s(:db),\n 'twitter:card' => 'player',\n 'twitter:player:url' => metadata[:embed_url],\n 'twitter:player:width' => metadata[:width],\n 'twitter:player:height' => metadata[:height],\n })\n end"
] |
[
"0.6164924",
"0.5774608",
"0.5755568",
"0.5733232",
"0.572383",
"0.5587251",
"0.5515964",
"0.54684615",
"0.5434264",
"0.54263157",
"0.54180944",
"0.537928",
"0.5374398",
"0.5374354",
"0.53705394",
"0.5350056",
"0.53472424",
"0.5346767",
"0.5313958",
"0.5299231",
"0.52656925",
"0.52449566",
"0.52319187",
"0.5226514",
"0.5220278",
"0.51990706",
"0.5198546",
"0.5186312",
"0.5183026",
"0.5169772",
"0.51697415",
"0.5138258",
"0.513739",
"0.5135623",
"0.5130542",
"0.512961",
"0.512961",
"0.51170343",
"0.5114904",
"0.51053596",
"0.510455",
"0.5096106",
"0.5092999",
"0.5090639",
"0.50823545",
"0.50794214",
"0.50699186",
"0.5058783",
"0.5039354",
"0.50386155",
"0.50373185",
"0.50336885",
"0.5032544",
"0.50316626",
"0.502769",
"0.5023133",
"0.50231117",
"0.5022299",
"0.5013374",
"0.50119114",
"0.49789837",
"0.49510485",
"0.49469543",
"0.49434587",
"0.49411073",
"0.49390304",
"0.49184233",
"0.49159318",
"0.49128836",
"0.49125585",
"0.49016863",
"0.49004602",
"0.4893246",
"0.48907015",
"0.48886806",
"0.48872465",
"0.48844397",
"0.48826894",
"0.48812985",
"0.48746833",
"0.48743233",
"0.4869917",
"0.48644012",
"0.4846812",
"0.4845644",
"0.4844825",
"0.48420992",
"0.4841355",
"0.48405188",
"0.48380685",
"0.483764",
"0.48366135",
"0.4820697",
"0.4816928",
"0.4814619",
"0.48125488",
"0.48115924",
"0.48107243",
"0.48103732",
"0.48025957"
] |
0.6146092
|
1
|
tears down given string not to exceed specified length
|
def teardown_to_oneline(line, length = 60)
lines = []
line.split(" ").each {|line|
if !lines.empty? && lines[-1].size + line.size + 1 <= length
lines[-1].concat(" " + line)
else
lines << line
end
}
return lines
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def shorten( str, length = 120 )\n\tmatched = str.gsub( /\\n/, ' ' ).scan( /^.{0,#{length - 2}}/ )[0]\n\tunless $'.empty?\n\t\tmatched + '..'\n\telse\n\t\tmatched\n\tend\nend",
"def longestSub(str)\n\n\nend",
"def smart_truncate(len = 30, ending = '...')\n len = Math.max(len, 5)\n return self if self.length <= len\n s = self[0...(len-2)].reverse\n bits = s.split(/[\\s\\-,]/,2)\n s = bits.length == 2 ? bits[1] : bits[0]\n s.reverse + ending\n end",
"def check_length_or_truncate(str, length)\n if !str.nil? && str.length > length\n str = str[0,length]\n end\n str\n end",
"def shorten(string, length)\n return string if string.length <= length\n return string[0..length-3] + '...' \n end",
"def shorten(len=20)\n self[0..len-1]\n end",
"def reverse_string_3(string)\n string = string.to_s\n result = ''\n string.length.times { |i| result << string[(i + 1) * -1] }\n result\nend",
"def reverse_five(str)\n str = str.split(\" \")\n str.each do |s|\n s.to_s\n s.reverse! if s.length >= 5\n end\n str.join(\" \")\nend",
"def chars_until(str); end",
"def truncate(input, length = T.unsafe(nil), truncate_string = T.unsafe(nil)); end",
"def truncate(input, length)\n if input.length > length && input[0..(length - 1)] =~ /(.+)\\b.+$/im\n $1.strip + '...'\n else\n input\n end\n end",
"def sub_str_tar(str, target)\n #p str[((str.length - 1) - (target.length - 1))..(str.length - 1)] == target\n #or a shorter version\n p str.slice(str.length - target.length, target.length)\nend",
"def prune_string(string)\n string.chomp.slice(0..pruned_width)\n end",
"def cutinfo(string)\n inf=/\\024/=~string1\n inf=inf+2\n trans=string1[inf..-1]\nend",
"def find_longest_palindrome(string)\n l = string.size\n l.downto(0) { |i|\n 0.upto(l) { |j|\n s = string.slice(j,i)\n return s if s == s.reverse && s.size > 1\n }\n }\nend",
"def truncate(str, width)\n return str if str.bytesize <= width\n\n ellipses = '...'\n truncated_width = width - 3 # leave room for elipses\n\n # Not handling UTF-8 at the moment\n str.slice(0, truncated_width) + ellipses\n end",
"def longest_palindrome(string)\nend",
"def reverso_bot(string)\r\n\tstring = string.split.(\"\")\r\n\treversed = []\r\n\treversed << string.size.times\r\n\treversed.join\r\nend",
"def longest_palindrome(string)\n \nend",
"def reverse_five(str)\n final = []\n str.split.each do |x|\n x.reverse! if x.length > 4\n final << x\n end\n\n final.join(' ')\nend",
"def truncate(string)\n string.is_a?(String) ? string[0...3000] : ''\n end",
"def reverse_string_4(string)\n string = string.to_s\n result = ''\n index = 0\n while index < string.length\n result = string[index] + result\n index += 1\n end\n result\nend",
"def shortenString(str, len)\n str = str.split\n while str.join(' ').length > len and str.length > 1\n str = str[0..-2]\n end\n str.join(' ')[0..len]\n end",
"def longest_palindrome(str)\n \nend",
"def longest_palindrome(string)\n\nend",
"def longest_palindrome(string)\n\nend",
"def longest_palindrome(string)\n\nend",
"def truncate(str, max_length, suffix)\n return str if str.length <= max_length\n str[0, max_length - suffix.length] + suffix\n end",
"def reverse(string)\n # slice returns at [index, til it has that many chars/elements]\n return string if string.length <= 1\n string[-1] + reverse(string.slice(1, string.length - 2)) + string[0]\nend",
"def limit_size(str, max)\n if str.length > max\n return str[0...max]\n end\n str\n end",
"def limit_size(str, max)\n if str.length > max\n return str[0...max]\n end\n str\n end",
"def longest_palindrome(str)\n\nend",
"def shorten(text, length)\n if text.length <= length - 1\n text\n else\n text[0..length - 1] + \"...\"\n end\n end",
"def find_short(string)\n string.split.map(&:length).sort.first\nend",
"def reverse_five(str)\r\n # your code goes here\r\n temp = str.split(\" \")\r\n\r\n for i in 0 ... temp.length\r\n if temp[i].length >= 5\r\n temp[i].reverse!\r\n end\r\n end\r\n temp.join(\" \")\r\n\r\nend",
"def rightstr(length)\n if length < 0\n raise ArgumentError, \"length cannot be a negative value\"\n end\n self.reverse[0,length].reverse\n end",
"def shortened_string(string)\n string[0, 100] << \"...\" unless string.length < 100\n end",
"def reverse(string)\n output = \"\"\n array = string.chars\n string.length.times { output << array.pop } \n output\nend",
"def my_reverse(string)\n\t\ta = string.length - 1\n\t\t@new_string = \"\"\n\t\ta.downto(0) { |i| @new_string << string[i] }\n\t\tprint @new_string\n\tend",
"def trunc(len)\n split(/ /).each_with_object('') do |x, ob|\n break ob unless ob.length + ' '.length + x.length <= len\n\n ob << (\" #{x}\")\n end.strip\n end",
"def reverse_five(str)\n words = str.split\n words.each {|word| word.reverse! if word.length >= 5}\n words.join(\" \")\nend",
"def reverse_a_string(string)\n split_string = string.split(\"\")\n reverse_string = []\n string.length.times { reverse_string << split_string.pop}\n reverse_string.join\nend",
"def string_reverse(my_string)\r\n if my_string == nil\r\n return nil\r\n end\r\n if my_string == \"\"\r\n return \"\"\r\n end\r\n n = 1\r\n str_length = my_string.length\r\n (str_length / 2).times do |i|\r\n temp = my_string[i]\r\n my_string[i] = my_string[str_length - n]\r\n my_string[str_length - n] = temp\r\n n += 1\r\n end\r\n return my_string\r\nend",
"def truncate string, count\n string = string.to_s\n string.tr!(\"\\n\",' ')\n return string if string.length <= count\n (string[0..(count-4)] + \" ...\")\n end",
"def big_words(str)\n # split my string into individual words\n # loop over my words\n # check the length of each word\n # if the length of the word is >= 5, keep it. \n # else delete it.\n # return joined words\n\n words = str.split(' ')\n long_words = []\n i = 0\n while i < words.length\n if words[i].length >= 5 #=> words[i] < 5\n # words.delete_at(i) # be careful of delete_at in loops.\n long_words << words[i]\n end\n i += 1\n end\n return long_words.join(' ')\nend",
"def soft_truncate(string, length, soft_limit=nil)\n return '' unless string\n string.strip!\n return string if string.length <= length\n firstpart = string[0..(length-1)]\n afterpart = string[length..-1]\n does_not_start_with_whitespace = afterpart[/^\\S/]\n afterpart.strip!\n return firstpart if afterpart.empty?\n return firstpart << ' ...' unless soft_limit && does_not_start_with_whitespace\n afterword = afterpart[/(\\S+)/][0..(soft_limit-1)]\n afterword << ' ...' if afterpart.length > afterword.length\n firstpart << afterword\n end",
"def reverse_five(str)\n\t(str.split.map { |c| c.length >= 5 ? c.reverse : c } ).join(\" \")\nend",
"def reverse_five(str)\n arr = str.split\n arr.each do |word|\n if word.length >= 5\n word.reverse!\n end\n end\n arr.join(\" \")\nend",
"def get_sandwich(str)\n new_str = \"\"\n (str.size - 4).times do |ingred|\n slice = str[ingred..(ingred + 4)]\n if slice == \"bread\"\n new_str = str[str.index(slice) + 5..str.rindex(slice) - 1]\n end\n end\n return new_str\nend",
"def truncate(string, size)\n string.size > size ? \"#{string[0...size - 3]}...\" : string\n end",
"def fixed_string(string, fixedSize)\n len = string.length\n res = \"\"\n (fixedSize - len).downto(1) do\n res = res + \" \"\n end\n res = res + string\n res \n end",
"def short(str)\n limit = 140\n str = str.gsub(/(\\n|\\r)/, \"\")\n return str if str.size <= limit\n str.strip[0...(limit-3)]\n .concat(\"...\")\n end",
"def truncate( string, maxlength=80 )\n\t\treturn string if maxlength < 8\n\t\treturn string if string.length - maxlength - 5 <= 0\n\n\t\treturn string[0 .. (maxlength / 2) - 3 ] +\n\t\t\t' ... ' +\n\t\t\tstring[ -((maxlength / 2) -3) .. -1 ]\n\tend",
"def longest(string)\n sliced = string.chars.slice_when {|a,b| a > b}.to_a\n longest = sliced.max_by {|sub_arr| sub_arr.length}.join\nend",
"def get_char_summery(string, count)\n string[0..count]\n end",
"def reverse_string(s)\n result = ''\n i = s.length - 1\n\n i.downto(0).each do |idx|\n result << s[idx]\n end\n\n result\nend",
"def truncate_into_single_segment(str)\n return str if single_segment?(str)\n\n extended_chars = str.gsub(GSM_NOT_EXTENDED_REGEX, '').length\n final_length = GSM_SEGMENT_LENGTH - extended_chars - 3\n str[0..final_length].concat('...')\n end",
"def description_from_string(str)\n len = 12\n return str unless str.length > len\n \"#{str[0..len - 1]}...\" # Is this length correct?\n end",
"def length_of_string(string)\n string = \"A string of length 21\".length\nend",
"def shortest_palindrome_3(s)\n idx = 0\n front = 0\n back = 0\n pow = 1\n (0...s.size).each { |i|\n dijit = s[i].ord - 'a'.ord\n front = front * 27 + dijit\n back = back + dijit * pow\n pow *= 27\n idx = [idx, i].max if front == back\n }\n\n (s[idx + 1..-1] || \"\").reverse + s\nend",
"def string_reverse(my_string)\r\n if my_string == nil\r\n return nil\r\n elsif my_string.length == 1\r\n return my_string\r\n else\r\n origin = my_string.length - 1\r\n target = 0\r\n temp = nil\r\n (my_string.length / 2).times do\r\n temp = my_string[target]\r\n my_string[target] = my_string[origin]\r\n my_string[origin] = temp\r\n origin -= 1\r\n target += 1\r\n end\r\n end\r\n return my_string\r\nend",
"def truncate(length = 30)\n return self if self.length < length\n self[0..length].gsub(/\\s\\w+\\s*$/, '...')\n end",
"def truncate(max_length)\n output = deparse(@tree)\n\n # Early exit if we're already below the max length\n return output if output.size <= max_length\n\n truncations = find_possible_truncations\n\n # Truncate the deepest possible truncation that is the longest first\n truncations.sort_by! { |t| [-t.location.size, -t.length] }\n\n tree = deep_dup(@tree)\n truncations.each do |truncation|\n next if truncation.length < 3\n\n find_tree_location(tree, truncation.location) do |expr, k|\n expr[k] = { A_TRUNCATED => nil }\n expr[k] = [expr[k]] if truncation.is_array\n end\n\n output = deparse(tree)\n return output if output.size <= max_length\n end\n\n # We couldn't do a proper smart truncation, so we need a hard cut-off\n output[0..max_length - 4] + '...'\n end",
"def reverse_five(string)\n arr = string.split(' ')\n i = 0\n while i < string.length\n if arr[i].length >= 5\n arr[i] = arr[i].reverse\n else\n arr[i] = arr[i]\n end\n i +=1\n end\n arr.join(' ')\n end",
"def truncate(string, max)\n return string.size > max ? \"#{string[0...max]}...\" : string\nend",
"def string_trunc(string, length=30)\n string.length < length ? string : string[0..length] + '...'\n end",
"def length_of_longest_substring(s)\n # find each substring and compare lengths\n # as i move through the string, have a store that keeps building until it finds a repeated character\nend",
"def get_first_half_of_string(string)\n # Find string length\n # half string length\n # if odd, add one\n string_length = string.size\n string_length += 1 if string_length.odd?\n half_string_length = string_length/2\n string[0..(half_string_length-1)]\n #return string up to half\nend",
"def truncate( length ) File.truncate( expand_tilde, length ) end",
"def unicode_slice(length)\n if size_for_print <= length\n self\n else\n result = unicode_slice_for_len(length - 2)\n if result != self\n result + '..'\n else\n result\n end\n end\n end",
"def find_short(string)\n string.split.map(&:length).min\nend",
"def length_of_longest_substring(str) ## Does not pass LeetCode Test\n max_longest = ''\n current_longest = ''\n str.each_char do |letter|\n current_longest = \"\" if current_longest.index(letter)\n current_longest << letter \n max_longest = current_longest if current_longest.length > max_longest.length \n end\n max_longest.length \nend",
"def truncate(str, max=0)\n return '' if str.blank?\n\n if str.length <= 1\n t_string = str\n else\n t_string = str[0..[str.length, max].min]\n t_string = str.length > t_string.length ? \"#{t_string}...\" : t_string\n end\n\n t_string\n end",
"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 longest_palindrome(str)\n result = [0, \"\"]\n for i in (0..str.length - 1)\n p1 = expand(str, i, i) \n result = result[0] > p1.length ? result : [p1.length, p1]\n p2 = expand(str, i, i + 1) \n result = result[0] > p2.length ? result : [p2.length, p2]\n end\n result[1]\nend",
"def trim(string, size)\n if string\n if string.strip.length > size\n string.strip.slice(0,size)\n else\n string.strip.ljust(size)\n end\n end\n end",
"def level_down(s)\nreturn s.split(\"/\").insert(-2, \"*\").join(\"/\")\nend",
"def shortest_palindrome(string)\n return string if palindrome?(string)\n\n for i in 0...string.length\n rev = string.length - i\n suffix = string[(rev - 1)...string.length]\n rev_suffix = suffix.reverse\n\n new_string = rev_suffix + string\n return new_string if palindrome?(new_string)\n end\nend",
"def ltrunc(max)\n if length > max\n sub(/^.*?(.{#{max - 3}})$/, '...\\1')\n else\n self\n end\n end",
"def reverse_a_string(string)\n reversed_string = []\n string = string.split('')\n string_length = string.length\n\n string_length.times do\n last_element = string.last\n reversed_string << last_element\n string.delete(last_element)\n end\n\n reversed_string.join\nend",
"def unrlen(str, len)\n=begin\n\t\t\t\treturn len if str !~ /(^|[^%])%\\(.+?\\)/\n\t\t\t\ttext = 0\n\t\t\t\ttag = 0\n\t\t\t\tstr.tokenize { |tok|\n\t\t\t\t\tif tok[0] == :text\n\t\t\t\t\t\ttext += tok[1].length\n\t\t\t\t\t\tif text >= len\n\t\t\t\t\t\t\treturn len + tag\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\ttag += tok[1].length + 3 # %()\n\t\t\t\t\tend\n\t\t\t\t}\n=end\n\t\t\t\treturn len if str !~ /(?:\\A|[^%])%\\(.+?\\)/\n\t\t\t\tss = StringScanner.new(str.dup)\n\t\t\t\tpos = 0\n\t\t\t\twhile m = ss.scan_until(/(\\A|[^%])%\\((.+?)\\)/) and\n\t\t\t\t\t\tpos - ss.matched_size + (ss[1] ? ss[1].length : 0) <\n\t\t\t\t\t\tlen do\n\t\t\t\t\tlen += m.length - ss.pre_match.length -\n\t\t\t\t\t\t(ss[1] ? ss[1].length : 0)\n\t\t\t\t\tss.string = ss.post_match\n\t\t\t\tend\n\t\t\t\tlen\n\t\t\tend",
"def unstretch(str)\n return str.squeeze\nend",
"def reverse_string_5(string)\n string = string.to_s\n result = ''\n string.split('').each_index do |i|\n result += if i != 0\n string[-1 * (i + 1)]\n else\n string[i - 1]\n end\n end\n result\nend",
"def test_truncate\n name = \"Broadmark\"\n truncated = truncate name, :length => 5\n assert_equal \"Br...\", truncated, \"truncated Broadmark\"\n\n truncated = truncate name, :length => 9\n assert_equal \"Broadmark\", truncated, \"truncated Broadmark\"\n\n truncated = truncate name, :length => 8\n assert_equal \"Broad...\", truncated, \"truncated Broadmark\"\n end",
"def reverse_five(str)\n result = []\n str = str.split(\" \")\n str.each do |word|\n if word.length > 4\n result << word.reverse\n else\n result << word\n end\n end\n result.join(\" \")\nend",
"def reverse_string(string)\n\treversed_string = ''\n\tcharacters = string.chars.to_a\n\tcharacters.length.times { reversed_string << characters.pop}\n\treversed_string\nend",
"def truncate_paragraph(long_str, num_characters, truncated_indicator=\"...\")\nend",
"def longest_palindrome(str)\r\n pal = \"\"\r\n (0..str.size).each do |x|\r\n i = 1\r\n while (i < (str.size-x)) do\r\n\t if str[x,i].reverse == str[x,i]\r\n\t pal = str[x,i] if pal.size < str[x,i].size\r\n\t end\r\n\t i+= 1\r\n\tend\r\n end\r\n pal\r\nend",
"def trim_to_word( max_length )\n string = self\n if string.length > max_length\n string = string[0..max_length-4]\n while string[-1,1] =~ /[\\w]/ && string.length > 1\n string = string[0..string.length-2]\n end\n string += \"...\"\n end\n string\n end",
"def RunLengthII(str)\n\tstr_copy = str.split(\"\")\n\tlastChar = str_copy.shift\n\tresult = \"\"\n\tcount = 1\n\tstr_copy.each do |char|\n\t\tif char != lastChar\n\t\t\tresult << \"#{count}#{lastChar}\"\n\t\t\tlastChar = char\n\t\t\tcount = 1\n\t\telse\n\t\t\tcount += 1\n\t\tend\n\tend\n\n\tresult += \"#{count}#{str_copy[-1]}\"\n\treturn result\nend",
"def shortest_palindrome(str)\n # find longest palindromic prefix\n n = str.size\n rev = str.reverse\n\n (0...n).each do |i|\n return rev[0...i] + str if str[0...(n - i)] == rev[i...n]\n end\n\n ''\nend",
"def truncate_paragraph(long_str, num_characters, truncated_indicator=\"...\")\n if long_str.length <= num_characters\n return long_str\n else \n return long_str.split(//).first(num_characters).join + \" \" + (truncated_indicator) \n end\n \n\nend",
"def generate_substring_with_length(str, len)\n result_array = []\n start_index = 0\n while start_index <= str.length - len do\n result_array.append(str[start_index, len])\n start_index += 1\n end\n return result_array\nend",
"def reverse(string)\n index = string.lenth - 1\n result = \"\"\n\n while index >= 0\n result += string[index]\n index -= 1\n end\n\n return result\nend",
"def longest_palindrome(string)\n if string.length <= 1\n return string\n end\n\n i = 0\n string.length.downto(1).each do |length|\n # .. is inclusive\n (0..i).each do |start_index|\n if palindrome?(string.slice(start_index, length))\n return string.slice(start_index, length)\n end\n end\n\n i += 1\n end\n\n string[0]\nend",
"def reverse_five(str)\n arr = str.split\n new_str = []\n arr.each do |word|\n if word.length >= 5\n word.reverse!\n end\n new_str.push(word)\n end\n new_str.join(\" \")\nend",
"def reverse_string(s)\n reversed_str = \"\"\n counter = -1\n\n while counter >= (s.length * -1)\n reversed_str << s[counter]\n counter += -1\n end\n\n reversed_str\nend",
"def dynamic_truncation(string)\n log 'string', string\n log 'string as hex', string.unpack('H*')\n\n bytes_in_string = string.bytes.length\n log 'bytes_in_string', bytes_in_string # RFC says this should be 20 bytes\n\n unless bytes_in_string == 20\n raise \"Incorrect string size. Should be 20 bytes but is #{bytes_in_string}.\"\n end\n\n # Let OffsetBits be the low-order 4 bits of String[19]\n last_byte = string.bytes.last\n least_significant_4_bits = last_byte & 0x0f\n offset = least_significant_4_bits\n\n # Offset = StToNum(OffsetBits) // 0 <= OffSet <= 15\n log 'offset byte', offset\n # Let P = String[OffSet]...String[OffSet+3]\n pee_bytes = string.bytes[offset..offset + 3]\n log 'pee_bytes', pee_bytes\n pee = pee_bytes.pack('CCCC')\n log 'offset range', \"#{offset}..#{offset + 3}\"\n log 'pee', pee\n log 'pee as hex', pee.unpack('H*')\n bytes_in_pee = pee.bytes.length\n log 'bytes_in_pee', bytes_in_pee\n\n # Return the Last 31 bits of P\n pee_in_binary = pee.bytes.map { |b| b.to_s(2).rjust(8, '0') }.join\n log 'pee_in_binary', pee_in_binary\n\n last_31_bits_of_pee = pee_in_binary[1..31]\n log 'last_31_bits_of_pee', last_31_bits_of_pee\n last_31_bits_of_pee\n end",
"def longest_string\nend",
"def get_sandwich(str) # needs some work\n (str.size - 4).times do |i|\n slice = str[i..(i + 4)]\n if slice != \"bread\"\n puts slice\n end\n end\n\nend",
"def reverse(string)\n return string if string.length < 2\n \n reversed = reverse(string[1, string.length]) # <-- top bottom\n reversed + string[0] # <-- bottom up\nend"
] |
[
"0.644595",
"0.6294009",
"0.6292511",
"0.6224895",
"0.6214699",
"0.6137282",
"0.6025561",
"0.60216963",
"0.6002136",
"0.59554386",
"0.59424245",
"0.59358233",
"0.5889621",
"0.58332324",
"0.58261377",
"0.5808979",
"0.5808912",
"0.57957745",
"0.57921857",
"0.57905453",
"0.5789401",
"0.5774262",
"0.5765386",
"0.5764451",
"0.57510185",
"0.57510185",
"0.57510185",
"0.57394624",
"0.57293886",
"0.57271117",
"0.57271117",
"0.57203716",
"0.5719043",
"0.5718302",
"0.57095385",
"0.56989455",
"0.56985945",
"0.56931955",
"0.5683139",
"0.5682969",
"0.5671881",
"0.56634855",
"0.56572056",
"0.5652071",
"0.56464005",
"0.56439084",
"0.5636293",
"0.56300443",
"0.56167775",
"0.56054765",
"0.5601996",
"0.55986565",
"0.5595617",
"0.5591677",
"0.5587311",
"0.55816394",
"0.55778563",
"0.55727977",
"0.55727476",
"0.5570952",
"0.55590576",
"0.5555995",
"0.5553487",
"0.5537685",
"0.55366075",
"0.5536273",
"0.5526928",
"0.5526919",
"0.5525761",
"0.5524587",
"0.5523629",
"0.55231833",
"0.55228156",
"0.552109",
"0.5512311",
"0.55115324",
"0.55103004",
"0.5504671",
"0.5502344",
"0.549893",
"0.549843",
"0.54914266",
"0.54906964",
"0.5488561",
"0.54884917",
"0.548519",
"0.54830605",
"0.5468894",
"0.5462029",
"0.54614466",
"0.5460397",
"0.54547894",
"0.5450447",
"0.54498273",
"0.54440856",
"0.5436412",
"0.54339135",
"0.5433641",
"0.5432896",
"0.54327065",
"0.5432293"
] |
0.0
|
-1
|
comments out given string or string array and returns as a string array
|
def get_commented_lines(str)
if str.respond_to? "gsub!"
str.gsub(/^(.+)$/) {|s| "# " + s}
elsif str.respond_to? "map"
str.map {|line| "# " + line}
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def stringify_comment_array(comments); end",
"def prettyify_array(gemspec_ruby, array_name); end",
"def prettyify_array(gemspec_ruby, array_name)\n gemspec_ruby.gsub(/s\\.#{array_name.to_s} = \\[.+?\\]/) do |match|\n leadin, files = match[0..-2].split(\"[\")\n leadin + \"[\\n #{files.split(\",\").join(\",\\n \")}\\n ]\"\n end\n end",
"def prettyify_array(gemspec_ruby, array_name)\n gemspec_ruby.gsub(/s\\.#{array_name.to_s} = \\[.+?\\]/) do |match|\n leadin, files = match[0..-2].split(\"[\")\n leadin + \"[\\n #{files.split(\",\").join(\",\\n \")}\\n ]\"\n end\n end",
"def on_array(*body)\n @last_sexp =\n super(*body).tap do |sexp|\n next unless SPECIAL_LITERALS.include?(body.dig(0, :type))\n\n comments = sexp.dig(:body, 0).delete(:comments)\n sexp.merge!(comments: comments) if comments\n end\n end",
"def comments\n results = []\n return results unless @comments\n\n comment = ''\n @comments.split(\"\\n\").each do |line|\n if line =~ /^\\S/\n results << comment unless comment.empty?\n comment = line\n else\n comment += \"\\n\" + line\n end\n end\n\n results << comment unless comment.empty?\n return results\n end",
"def strip_string_array(arr)\n arr.first.lstrip! if arr.first.is_a?(String)\n arr[-1] = Sass::Util.rstrip_except_escapes(arr[-1]) if arr.last.is_a?(String)\n arr\n end",
"def arrayify(str)\n str.split(\"\\n\")\n end",
"def make_comment( content )\n\t\treturn [\n\t\t\tself.options[:comment_start],\n\t\t\tcontent,\n\t\t\tself.options[:comment_end],\n\t\t].join\n\tend",
"def symbolise_array_strings(source, snake_case_keys=true)\n # returns snake case values\n return %I[#{sanitise_string(source, snake_case_keys)}]\n end",
"def convertObjectsArrToStringArr(arr)\r\n i = 0\r\n stringArr = []\r\n while i < arr.length\r\n holder = arr[i].to_s\r\n if(holder != \"\")\r\n if(holder[0] != \"#\")\r\n if(!holder.include? \"::\")\r\n stringArr.append(holder)\r\n end\r\n end\r\n end\r\n #p holder\r\n # puts stringArr[i]\r\n i += 1\r\n end\r\n return stringArr\r\n end",
"def strip_array(clothed_arr)\n fully_stripped = []\n clothed_arr.each do |onecase|\n fully_stripped.push(onecase.strip)\n end\n return fully_stripped\n end",
"def toptag2array(str)\n sep = \"\\001\"\n str.gsub(/\\n([A-Za-z\\/\\*])/, \"\\n#{sep}\\\\1\").split(sep)\n end",
"def array_method(string)\n string.join(\" \")\nend",
"def include_string(arr)\r\n arr.map{ |s| \"-I#{s}\" }.join(' ')\r\nend",
"def comments=(_arg0); end",
"def comments=(_arg0); end",
"def comments=(_arg0); end",
"def comments=(_arg0); end",
"def comments=(_arg0); end",
"def rake_array_arg(arg, delim = \" \")\n return arg.split(delim) if arg.is_a? String\n return arg\nend",
"def custom_delimiters\r\n\t\toutput = []\r\n\t\toutput << input.split(\"]\\n\").first[3..-1].split(\"][\") if input.start_with?('//')\r\n\t\toutput.flatten\r\n\tend",
"def get_comments\n return unless @list\n comments = \"\"\n cnt = 0\n listn = @list.size\n while cnt < listn\n if @list[cnt].code == 108\n comments += @list[cnt].parameters[0] + 10.chr\n while cnt < listn && @list[cnt + 1].code == 408\n cnt += 1\n comments += @list[cnt].parameters[0] + 10.chr\n end\n end\n cnt += 1\n end\n \n return comments\n end",
"def remove_comments(code_array)\n code_array.select { |line| !(line.match(Parser::COMMENT_REGEXP)) }\n end",
"def quote_array(value)\n \"(#{value.map { |entry| quote_value(entry) }.join(', ')})\"\n end",
"def parse_comments\n @data[4][0]\n end",
"def content_as_array\n begin\n # '[\"a\",\"b\", \"c\"]' -> '\"a\",\"b\",\"c\"'\n no_brackets = content[1...-1]\n\n # '\"a\",\"b\",\"c\"' -> ['\"a\"', '\"b\"', '\"c\"']\n quoted_elements = no_brackets.split(\", \")\n\n # ['\"a\"', '\"b\"', '\"c\"'] -> ['a', 'b', 'c']\n quoted_elements.map { |quoted_elt| quoted_elt[1...-1] }\n rescue\n []\n end\n end",
"def comment(string); end",
"def comment(string); end",
"def comment(string); end",
"def comment(string); end",
"def add_bang(array)\n\tarray.map {|string| string + \"!\"}\nend",
"def parse_comment(raw)\n c = nil\n if raw =~ /\\A\\((.+?)\\)(.+)\\z/\n c, raw = [$2, $1]\n end\n if raw =~ /\\A(.+)\\((.+?)\\)\\z/\n raw, c = [$1, $2]\n end\n [raw, c]\n end",
"def arrayify_and_stringify_elements(arg)\n return false if arg == false\n \n case\n when arg.blank? then []\n when arg.is_a?(Array) then arg\n else arg.to_s.strip.split(/\\s/)\n end.map(&:to_s)\n end",
"def array_to_sentence_string(array, connector = T.unsafe(nil)); end",
"def extract_description(an_array)\n description = \"\"\n while !an_array.shift.empty? do\n # NOOP\n end\n\n until an_array.first.empty? do\n description << an_array.shift.strip + \"\\n\"\n end\n\n return description.chomp\nend",
"def array_to_code(arr)\n code = ''\n arr.each_with_index do |part, i|\n code << ' + ' if i > 0\n case part\n when Symbol\n code << part.to_s\n when String\n code << %{\"#{part}\"}\n else\n raise \"Don't know how to compile array part: #{part.class} [#{i}]\"\n end\n end\n code\n end",
"def c(array = [])\n str = \"\"\n\n for a in array\n str += a + \" \"\n end\n\n str.strip\n end",
"def get_commented_text(str)\n get_commented_lines(str).join(\"\\n\")\n end",
"def comment(str)\n str.split(\"\\n\").collect {|line| \"# #{line}\" }.join(\"\\n\")\n end",
"def destringify_array(str)\n\treturn str.to_s.gsub(\"[\",\"\").gsub(\"]\", \"\").split(\",\");\nend",
"def markup_to_parameter_array(str)\n str.downcase.slice(1,str.size-2).strip.gsub(/[\\s]+/, \" \").split(/:/).map {|s| s.strip}\n end",
"def decommentify input\n output = input.dup\n # Remove multiline comments:\n output.gsub!(/(#{Regexp.quote @block_comment_start}.+?#{Regexp.quote @block_comment_end})/m, \"\")\n # Remove inline comments:\n output.gsub!(/(#{Regexp.quote @inline_comment_delimiter}.+$)/,\"\")\n return output.lines.map(&:strip).join($/)\n end",
"def test_array_arg\n\tarray = Array.new\n\tw = NQXML::Writer.new(array)\n\n\tw.write('data')\n\tassert_equals(['data'], array)\n\n\tw.comment('foo')\n\tassert_equals(['data', '<!--foo-->'], array)\n end",
"def unquote_array(*values)\n values.flatten.map{|v| unquote(v) }.select{|v| v.respond_to?(:to_str)}\n end",
"def array_from_string string\n # takes the string found when params tries to return an array, and reconstruct the array.\n array = string.split(/[^Q1234567890]+/)\n array.delete(\"\")\n array\n end",
"def add_bang(array)\n array.map {|string| string+\"!\"}\nend",
"def extract_comment comment\n case comment\n when Array then\n comment.map do |c|\n extract_comment c\n end\n when nil\n RDoc::Comment.new ''\n when RDoc::Comment then\n if comment.text =~ /^#[ \\t]*:section:.*\\n/ then\n start = $`\n rest = $'\n\n comment.text = if start.empty? then\n rest\n else\n rest.sub(/#{start.chomp}\\Z/, '')\n end\n end\n\n comment\n when RDoc::Markup::Document then\n comment\n else\n raise TypeError, \"unknown comment #{comment.inspect}\"\n end\n end",
"def filter_comment_format(comment, struct_comment)\n sc, cc = struct_comment, comment\n comment = nil unless cc && cc.match(/./)\n sc = nil unless sc && sc.match(/./)\n if cc || sc\n [cc, sc].uniq.compact.join(' / ').gsub(/\"/, '')\n else\n ''\n end\n end",
"def inline_comment(line)\n # For each single quote, if there is an odd number of double quote before\n # we are in a string, but if there is an even number of double quote before\n # we are out of a string so this is an inline comment and we can remove all\n # that comes after.\n double_quote = 0\n i = 0\n line.each_char do |c|\n double_quote += 1 if c == '\"'\n if c == \"'\" && double_quote.even?\n line = line[...i]\n break\n end\n i += 1\n end\n return line\n end",
"def quotelist( *args )\n\t\t\treturn args.flatten.collect {|part| part =~ /\\s/ ? part.inspect : part}\n\t\tend",
"def array_string(array, **opt)\n list_separator = opt[:list_separator] || LIST_SEPARATOR\n normalized_list(array, **opt).join(list_separator)\n end",
"def container_array(c)\n c = c || TagExtractor::words_container\n c = c.split ''\n end",
"def comment _args\n \"comment _args;\" \n end",
"def add_comment(comment)\n comment_array << comment\n end",
"def add_to_array(arr,str)\n if arr == nil\n return [str.to_s]\n end\n if arr == ''\n return [str.to_s]\n end\n if arr.is_a? Array\n return arr + [str.to_s]\n end\n return arr.to_s + ',' + str.to_s\n end",
"def comment_lines(arr)\n output = 0\n begin\n i = 0\n while i < arr.length\n if arr[i] == \"#\\n\"\n output += 1\n else\n j = 0\n temp_holder = arr[i]\n while j < temp_holder.length\n if temp_holder[j] == \"#\"\n output += 1\n break\n elsif temp_holder[j] != \" \"\n break\n end\n j += 1\n end\n end\n i += 1\n end\n rescue NameError\n p \"No variable with this name\"\n rescue TypeError\n p \"String was not converted into integer\"\n rescue IndexError\n p \"Index was not inside the paramaters\"\n ensure\n return output\n end\nend",
"def add_bang(array)\n # TODO: Take an array of strings and return a new array with \"!\" appended to each string.\n # You should use Enumerable#map\n array.map do |element|\n element+\"!\"\n end\nend",
"def process_each_comment comment\n\n\tquote1_markerstring = \"\\r\\n\\r\\n\"\n\tquote2_markerstring = \"\\r\\n\"\n\n\tquote = comment[/#{quote1_markerstring}(.*?)#{quote2_markerstring}/m, 1].strip\n\tbookname_and_page = comment.split(\"|\").first\n\n\ttmp = bookname_and_page.split(\"\\r\\n\")\n\tbookname = tmp.first.strip\n\tpage = tmp.last.strip\n\t[quote,bookname,page]\n\nend",
"def comments\n out = []\n\n out << ''\n out << '#'\n out << \"# Deezy version #{app_version}\"\n out << '#'\n out << ''\n\n @conf['dhcpd']['subnets'].each do |s|\n out << '# %s/%s via %s' % [s['subnet'], s['netmask'], s['routers']]\n s['pools'].each do |p|\n exceptions = []\n p['exceptions'].each do |e|\n exceptions << \", [except: %s-%s (%s)]\" % [e['first'], e['last'], e['notes']]\n end if p['exceptions']\n out << [\n \"# #{p['first']}-#{p['last']}\",\n \"#{\" (#{p['notes']})\" if p['notes']}\",\n exceptions.join\n ].join\n end\n out << '#'\n end\n out << ''\n end",
"def json_with_speedy_arrays(source)\n source.to_json.gsub('\"[[[','[[[').gsub(']]]\"', ']]]').html_safe #.gsub('\\\\', '')\n end",
"def comments_from path\n path = File.expand_path(\"../lib/friendly_id/#{path}\", __FILE__)\n match = File.read(path).match(/\\n=begin(.*)\\n=end/m)[1].to_s\n match.split(\"\\n\").reject {|x| x =~ /^@/}.join(\"\\n\").strip\nend",
"def stringify_array( array )\n\t\t\treturn array.collect do |item|\n\t\t\t\tcase item\n\t\t\t\twhen Symbol\n\t\t\t\t\titem.to_s\n\t\t\t\twhen Array\n\t\t\t\t\tstringify_array( item )\n\t\t\t\telse\n\t\t\t\t\titem\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def stringify_array( array )\n\t\t\treturn array.collect do |item|\n\t\t\t\tcase item\n\t\t\t\twhen Symbol\n\t\t\t\t\titem.to_s\n\t\t\t\twhen Array\n\t\t\t\t\tstringify_array( item )\n\t\t\t\telse\n\t\t\t\t\titem\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def stringify_array( array )\n\t\t\treturn array.collect do |item|\n\t\t\t\tcase item\n\t\t\t\twhen Symbol\n\t\t\t\t\titem.to_s\n\t\t\t\twhen Array\n\t\t\t\t\tstringify_array( item )\n\t\t\t\telse\n\t\t\t\t\titem\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def comments_text\n return self.comments.inject(\"\") do |string, comment| \n string + \n (string.empty? ? \"\" : \"\\n\") +\n comment.email +\n \": \" +\n comment.message\n end\n end",
"def comment_list(list, base_indent='')\n commented_list = \"\"\n ids = list.split(/,/)\n ids.each do |id|\n id.gsub!(/\\s*$/, '')\n id.gsub!(/^\\s*/, '')\n list_id = \"#{id}\"\n list_id += ',' if id != ids.last\n id.gsub!(/\\=.*$/, '') \n id.gsub!(/\\[.*\\]/, '') \n id.gsub!(/\\s*$/, '')\n id.gsub!(/^\\s*/, '') \n id.gsub!(/;/, '') \n id.gsub!(/\\s*\\:\\s*\\d+/,'') \n doc_id = id.split(/\\s/).last\n doc_id.gsub!(/\\*/, '') \n commented_list += \"#{base_indent}\" if id != ids.first \n commented_list += \"#{@indent}\\t#{list_id} /**< <##{doc_id} description#> */\"\n commented_list += \"\\n\" if id != ids.last \n end\n commented_list \n end",
"def comments\n super || wells.try(:collect, &:summary).try(:join, ':')\n end",
"def comments(*args)\n args.push(lambda{|*x| yield(*x) }) if block_given?\n args.push GAP if args.empty?\n args.push \"\\n\"\n comment(\"\\n\", *args)\n end",
"def split_output_of_extracted_comment(output)\n output\n .lines\n .slice_before(/^ =====([^=\\n]+)=====$/)\n .map do |comment|\n Struct::Comment.new(\n comment[0].gsub(/^ =====|=====$/, ''),\n comment[1..-1].join('')\n )\n end\nend",
"def comment_sections\n @comment_sections ||= raw ? raw.split(\"\\n\\n\") : []\n end",
"def parse_comments(comments); end",
"def strify_array( array )\n\t\tarray = [ array ] if !array.is_a?( Array )\n\t\tarray.map do |m|\n\t\t\tm = (Array === m) ? strify_array(m) : m\n\t\t\tm = (Hash === m) ? strify_hash(m) : m\n\t\t\tSymbol === m ? m.to_s : m\n\t\tend\n\tend",
"def sanitize input\n sanitized = []\n blank_or_comment = /^(\\s+$|\\/\\/.+)$/\n input.each do |line|\n next if line.match(blank_or_comment)\n sanitized << strip_comments(line)\n end\n sanitized\n end",
"def decode_status_string code_string, doc_array\n results = []\n code_unwrapper(code_string).each do |bool|\n doco = doc_array.shift\n results.push doco if bool\n end\n return results\n end",
"def arrayorize(value)\n case value\n when nil then return []\n when String then value.to_s.split\n when Symbol then value.to_s.split\n else value\n end\n end",
"def my_array_deletion_method!(source, thing_to_delete)\n\n var_to_delete = thing_to_delete\n\n source.map! {|str| str.to_s}\n p source.delete_if {|str| str.include?(var_to_delete)}\n\nend",
"def prepare_comment_text(comment)\n simple_format comment.body\n # raw comment.body.split(\"\\n\").map(&:squish).reject(&:blank?).map { |s| parse_common_string s }.join\n end",
"def comment_filter(comments)\n # p comments\n comments.each do |info|\n # p info\n # p info[1].values\n info[1].values.each do |item|\n if item.gsub(/\\s+/, \"\") == \"\"\n comments.delete(info[0])\n end\n end\n end\n if comments.empty?\n \"empty\"\n else\n comments\n end\nend",
"def ArrJson(str)\n tmp = \"\"\n tmp += (\"[\" + str + \"]\")\n tmp\n end",
"def ArrJson(str)\n tmp = \"\"\n tmp += (\"[\" + str + \"]\")\n tmp\n end",
"def ArrJson(str)\n tmp = \"\"\n tmp += (\"[\" + str + \"]\")\n tmp\n end",
"def ArrJson(str)\n tmp = \"\"\n tmp += (\"[\" + str + \"]\")\n tmp\n end",
"def model_comments(name)\n buf = []\n unless @parser.synopses[name].nil?\n @parser.synopses[name].each do |line|\n buf << \"# #{line.gsub(\"'\", '\\'').gsub('\"', '\\\"')}\"\n end\n end\n buf\n end",
"def transform_string_array(value)\n (value.is_a?(Array) ? value : [value]).map(&:to_s)\n end",
"def cops\n match = comment.text.match(CommentConfig::COMMENT_DIRECTIVE_REGEXP)\n return unless match\n\n cops_string = match.captures[1]\n cops_string.split(/,\\s*/).uniq.sort\n end",
"def convert_content(content, array_get_first_element = false)\n if content.is_a?(Array)\n if array_get_first_element\n content.first\n else\n content.join(\",\")\n end\n else\n content\n end\n end",
"def comment!(str)\n @comments_buf << str\n end",
"def comments_of_file(file)\n File.readlines(file).map { |s| s[2..-1].rstrip if s.start_with?('# ') }.compact\n end",
"def get_js_url (arr_in)\n\tclean_url_array = Array.new\n\tarr_in.each do |ss|\n\t\ta = ss.split(/\"/)\n\t\ta.each do |line|\n\t\t\tclean_url_array << line if line ['http']\n\t\tend\n\tend\n\treturn clean_url_array\nend",
"def comments_range=(_arg0); end",
"def array_to_lines(array, delimiter = '<br />')\n array.blank? ? nil : array * delimiter\n end",
"def strings_for_select( *_array)\n _array = _array.flatten\n if _array.blank?\n []\n else\n _array.zip _array\n end\n end",
"def return_string_array(array)\n array.collect do |element|\n element.to_s\n end\nend",
"def to_arr(value)\n if value.is_a?(Array)\n value\n else\n # Split by commas, but don't use commas inside double quotes\n # https://stackoverflow.com/questions/21105360/regex-find-comma-not-inside-quotes\n value.to_s.split(/(?!\\B\"[^\"]*),(?![^\"]*\"\\B)/)\n end\n end",
"def my_array_deletion_method(source, thing_to_delete)\n\tsource.each do |word| if word.to_s.split(\"\").include? thing_to_delete\n\t\tsource.delete word\n\tend\nend\n\t source \nend",
"def lines; [to_s]; end",
"def removeComments(text)\n # Currently hardcoded for JS comments and the two-space inline convention\n expr = {:line => /^(\\s+)?[\\/\\*]/, :inline => / \\/.+$/}\n return(\n text.reject{|t| t.match?(expr[:line])}.map{|t| t.gsub(expr[:inline], '')}\n )\nend",
"def build_comment string_data\n if is_multiline string_data\n build_multiline_comment string_data\n else\n build_singleline_comment string_data\n end\n end",
"def resume_to_array(text)\n result = text\n result.gsub!(\",\",\"\")\n result.gsub!(\"(\",\"\")\n result.gsub!(\")\",\"\")\n result.gsub!(\"[\",\"\")\n result.gsub!(\"]\",\"\")\n result.downcase!\n return result.split\nend"
] |
[
"0.7820429",
"0.63665843",
"0.6287018",
"0.6287018",
"0.6170988",
"0.61390966",
"0.6079058",
"0.58411205",
"0.582735",
"0.57843274",
"0.5729192",
"0.57181394",
"0.56674725",
"0.5663996",
"0.565588",
"0.5650214",
"0.5650214",
"0.5650214",
"0.5650214",
"0.5650214",
"0.564853",
"0.5592589",
"0.5564857",
"0.55600935",
"0.5545168",
"0.55432135",
"0.5511281",
"0.55103505",
"0.55103505",
"0.55103505",
"0.55103505",
"0.550863",
"0.54895777",
"0.5479422",
"0.5434001",
"0.54319584",
"0.5429406",
"0.5428226",
"0.54007864",
"0.53989536",
"0.5392238",
"0.53912127",
"0.53697824",
"0.53562135",
"0.5353939",
"0.5351583",
"0.53450924",
"0.5340232",
"0.53331184",
"0.5330241",
"0.53185564",
"0.5310547",
"0.5303452",
"0.5276712",
"0.5258237",
"0.5225089",
"0.52248937",
"0.52245337",
"0.52025443",
"0.51911837",
"0.51892215",
"0.5180721",
"0.51795787",
"0.51795787",
"0.51795787",
"0.51776683",
"0.5176069",
"0.51656806",
"0.515658",
"0.51427287",
"0.5141676",
"0.51413226",
"0.5131393",
"0.5126862",
"0.5124513",
"0.51227635",
"0.5122229",
"0.5120472",
"0.51203376",
"0.51068234",
"0.51068234",
"0.51068234",
"0.51068234",
"0.51066226",
"0.510185",
"0.5101763",
"0.5092546",
"0.50883204",
"0.5086054",
"0.5084133",
"0.5069249",
"0.50609547",
"0.5059023",
"0.5048391",
"0.5035629",
"0.5032228",
"0.50105876",
"0.5009216",
"0.5008455",
"0.5001357"
] |
0.60875744
|
6
|
comments out given string or string array and returns as a multilined string
|
def get_commented_text(str)
get_commented_lines(str).join("\n")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def stringify_comment_array(comments); end",
"def comment(string); end",
"def comment(string); end",
"def comment(string); end",
"def comment(string); end",
"def make_comment( content )\n\t\treturn [\n\t\t\tself.options[:comment_start],\n\t\t\tcontent,\n\t\t\tself.options[:comment_end],\n\t\t].join\n\tend",
"def inline_comment(line)\n # For each single quote, if there is an odd number of double quote before\n # we are in a string, but if there is an even number of double quote before\n # we are out of a string so this is an inline comment and we can remove all\n # that comes after.\n double_quote = 0\n i = 0\n line.each_char do |c|\n double_quote += 1 if c == '\"'\n if c == \"'\" && double_quote.even?\n line = line[...i]\n break\n end\n i += 1\n end\n return line\n end",
"def build_comment string_data\n if is_multiline string_data\n build_multiline_comment string_data\n else\n build_singleline_comment string_data\n end\n end",
"def comments(*args)\n args.push(lambda{|*x| yield(*x) }) if block_given?\n args.push GAP if args.empty?\n args.push \"\\n\"\n comment(\"\\n\", *args)\n end",
"def wrap_commentary_sugar(commentary)\n return \"<W \" + commentary.strip + \" W>\"\n end",
"def comments_text\n return self.comments.inject(\"\") do |string, comment| \n string + \n (string.empty? ? \"\" : \"\\n\") +\n comment.email +\n \": \" +\n comment.message\n end\n end",
"def comment!(str)\n @comments_buf << str\n end",
"def comment(str)\n @out.comment(str)\n end",
"def multiLineComment(comment, header = \"\")\r\n bar = \"\"\r\n hdrBar = \"\"\r\n\r\n # 3: 3 misc chars (/* )\r\n width = (@maxWidth - 3)\r\n\r\n width.times do\r\n bar += \"*\"\r\n end\r\n\r\n if (header.length > 0) # Generate a formatted header if it exists.\r\n hdrWidth = (@maxWidth - 6 - header.length) / 2\r\n\r\n hdrWidth.times do\r\n hdrBar += \" \"\r\n end # times\r\n end # if header\r\n\r\n output = <<EOF\r\n\r\n\r\n\r\n\r\n/* #{bar}\r\n#{hdrBar}-- #{header} --#{hdrBar}\r\n\r\n#{comment}\r\n\r\n#{bar} */\r\n\r\n\r\n\r\n\r\nEOF\r\n\r\n output\r\n\r\n end",
"def comment(str)\n str.split(\"\\n\").collect {|line| \"# #{line}\" }.join(\"\\n\")\n end",
"def comments\n out = []\n\n out << ''\n out << '#'\n out << \"# Deezy version #{app_version}\"\n out << '#'\n out << ''\n\n @conf['dhcpd']['subnets'].each do |s|\n out << '# %s/%s via %s' % [s['subnet'], s['netmask'], s['routers']]\n s['pools'].each do |p|\n exceptions = []\n p['exceptions'].each do |e|\n exceptions << \", [except: %s-%s (%s)]\" % [e['first'], e['last'], e['notes']]\n end if p['exceptions']\n out << [\n \"# #{p['first']}-#{p['last']}\",\n \"#{\" (#{p['notes']})\" if p['notes']}\",\n exceptions.join\n ].join\n end\n out << '#'\n end\n out << ''\n end",
"def comment _args\n \"comment _args;\" \n end",
"def create_comment(string, &block); end",
"def create_comment(string, &block); end",
"def pretty_comment comment\n\tif comment == nil or comment.length == 0\n\t\treturn \"\"\n\tend\n\n\tbegin\n\t\tline_width = 100\n\n\t\twords = comment.scan(/\\w+|\\n/)\n\t\tlines = []\n\t\tline = \"\"\n\t\twords.each do |word|\n\t\t\tif word == \"\\n\"\n\t\t\t\tlines << line\n\t\t\t\tline = \"\"\n\t\t\telse\n\t\t\t\tif line.length + word.length > line_width\n\t\t\t\t\tlines << line\n\t\t\t\t\tline = \"\"\n\t\t\t\tend\n\n\t\t\t\tif line.length == 0\n\t\t\t\t\tline = word\n\t\t\t\telse\n\t\t\t\t\tline = line + \" \" + word\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tif line.length > 0\n\t\t\tlines << line\t\t\t\t\n\t\tend\n\t\tlines.map { |line| \n\t\t\t\"// #{line}\"\n\t\t}.join(\"\\n\")\n\trescue Exception => e\n\t\tcomment\n\tend\nend",
"def get_comment(n, algebraic_structure)\n ret = <<EOS\n/**\n* Combine #{n} #{algebraic_structure}s into a product #{algebraic_structure}\n*/\nEOS\n ret.strip\nend",
"def prettyify_array(gemspec_ruby, array_name)\n gemspec_ruby.gsub(/s\\.#{array_name.to_s} = \\[.+?\\]/) do |match|\n leadin, files = match[0..-2].split(\"[\")\n leadin + \"[\\n #{files.split(\",\").join(\",\\n \")}\\n ]\"\n end\n end",
"def prettyify_array(gemspec_ruby, array_name)\n gemspec_ruby.gsub(/s\\.#{array_name.to_s} = \\[.+?\\]/) do |match|\n leadin, files = match[0..-2].split(\"[\")\n leadin + \"[\\n #{files.split(\",\").join(\",\\n \")}\\n ]\"\n end\n end",
"def add_comment comment\n \"\\n###### #{comment} ######\\n\" \n end",
"def get_commented_lines(str)\n if str.respond_to? \"gsub!\"\n str.gsub(/^(.+)$/) {|s| \"# \" + s}\n elsif str.respond_to? \"map\"\n str.map {|line| \"# \" + line}\n end\n end",
"def get_comments\n return unless @list\n comments = \"\"\n cnt = 0\n listn = @list.size\n while cnt < listn\n if @list[cnt].code == 108\n comments += @list[cnt].parameters[0] + 10.chr\n while cnt < listn && @list[cnt + 1].code == 408\n cnt += 1\n comments += @list[cnt].parameters[0] + 10.chr\n end\n end\n cnt += 1\n end\n \n return comments\n end",
"def comment_string\n @comment_syntax.string_for_method_entity self\n end",
"def c(array = [])\n str = \"\"\n\n for a in array\n str += a + \" \"\n end\n\n str.strip\n end",
"def comment!(str)\n if str.include? \"\\n\"\n text! \"<!--\\n#{str}\\n-->\\n\"\n else\n text! \"<!-- #{str} -->\\n\"\n end\n end",
"def comments\n super || wells.try(:collect, &:summary).try(:join, ':')\n end",
"def comment_list(list, base_indent='')\n commented_list = \"\"\n ids = list.split(/,/)\n ids.each do |id|\n id.gsub!(/\\s*$/, '')\n id.gsub!(/^\\s*/, '')\n list_id = \"#{id}\"\n list_id += ',' if id != ids.last\n id.gsub!(/\\=.*$/, '') \n id.gsub!(/\\[.*\\]/, '') \n id.gsub!(/\\s*$/, '')\n id.gsub!(/^\\s*/, '') \n id.gsub!(/;/, '') \n id.gsub!(/\\s*\\:\\s*\\d+/,'') \n doc_id = id.split(/\\s/).last\n doc_id.gsub!(/\\*/, '') \n commented_list += \"#{base_indent}\" if id != ids.first \n commented_list += \"#{@indent}\\t#{list_id} /**< <##{doc_id} description#> */\"\n commented_list += \"\\n\" if id != ids.last \n end\n commented_list \n end",
"def syntax_color_string_comment(aline,lccs,bccs)\n\n\t\tdqc = '\"'\n\t\tsqc = '\\''\n\t\tdquote = false\n\t\tsquote = false\n\t\tcomment = false\n\t\tbline = \"\"\n\t\tescape = false\n\n\t\tcline = aline.dup\n\t\twhile (cline!=nil)&&(cline.length>0) do\n\n\t\t\t# find first occurance of special character\n\t\t\tall = Regexp.union([lccs,bccs.keys,dqc,sqc,\"\\\\\"].flatten)\n\t\t\tk = cline.index(all)\n\t\t\tif k==nil\n\t\t\t\tbline += cline\n\t\t\t\tbreak\n\t\t\tend\n\t\t\tbline += cline[0..(k-1)] if k > 0\n\t\t\tcline = cline[k..-1]\n\n\t\t\t# if it is an escape, then move down 2 chars\n\t\t\tif cline[0].chr == \"\\\\\"\n\t\t\t\tr = cline[0,2]\n\t\t\t\tif r != nil\n\t\t\t\t\tbline += r\n\t\t\t\tend\n\t\t\t\tcline = cline[2..-1]\n\t\t\t\tnext\n\t\t\tend\n\n\t\t\t# if eol comment, then we are done\n\t\t\tflag = false\n\t\t\tlccs.each{|str|\n\t\t\t\tif cline.index(str)==0\n\t\t\t\t\tbline += $color+$color_comment\n\t\t\t\t\tbline += cline\n\t\t\t\t\tbline += $color+$color_default\n\t\t\t\t\tflag = true\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\t}\n\t\t\tbreak if flag\n\n\t\t\t# block comments\n\t\t\tflag = false\n\t\t\tbccs.each{|sc,ec|\n\t\t\t\tif cline.index(sc)==0\n\t\t\t\t\tflag = true\n\t\t\t\t\tbline += $color+$color_comment\n\t\t\t\t\tbline,cline = syntax_find_match(cline,ec,bline)\n\t\t\t\t\tbline += $color+$color_default\n\t\t\t\tend\n\t\t\t}\n\t\t\tnext if flag\n\n\t\t\t# if quote, then look for match\n\t\t\tif (cline[0].chr == sqc) || (cline[0].chr == dqc)\n\t\t\t\tcqc = cline[0].chr\n\t\t\t\tbline += $color+$color_string\n\t\t\t\tbline,cline = syntax_find_match(cline,cqc,bline)\n\t\t\t\tbline += $color+$color_default\n\t\t\t\tnext\n\t\t\tend\n\n\t\t\tbline += cline[0].chr\n\t\t\tcline = cline[1..-1]\n\t\tend\n\n\t\taline = bline + $color+$color_default\n\t\treturn aline\n\tend",
"def prettyify_array(gemspec_ruby, array_name); end",
"def decommentify input\n output = input.dup\n # Remove multiline comments:\n output.gsub!(/(#{Regexp.quote @block_comment_start}.+?#{Regexp.quote @block_comment_end})/m, \"\")\n # Remove inline comments:\n output.gsub!(/(#{Regexp.quote @inline_comment_delimiter}.+$)/,\"\")\n return output.lines.map(&:strip).join($/)\n end",
"def prepare_comment_text(comment)\n simple_format comment.body\n # raw comment.body.split(\"\\n\").map(&:squish).reject(&:blank?).map { |s| parse_common_string s }.join\n end",
"def filter_comment_format(comment, struct_comment)\n sc, cc = struct_comment, comment\n comment = nil unless cc && cc.match(/./)\n sc = nil unless sc && sc.match(/./)\n if cc || sc\n [cc, sc].uniq.compact.join(' / ').gsub(/\"/, '')\n else\n ''\n end\n end",
"def wrap options = {}\n width = options.fetch(:width, 76)\n commentchar = options.fetch(:commentchar, '')\n self.strip.split(\"\\n\").collect do |line|\n line.length > width ? line.gsub(/(.{1,#{width}})(\\s+|$)/, \"\\\\1\\n#{commentchar}\") : line\n end.map(&:strip).join(\"\\n#{commentchar}\")\n end",
"def comments=(_arg0); end",
"def comments=(_arg0); end",
"def comments=(_arg0); end",
"def comments=(_arg0); end",
"def comments=(_arg0); end",
"def parse_and_join(code, print_tokens = false)\n blocks = self.parse code, print_tokens\n blocks.map do |comment_block|\n comment_block.join \"\\n\"\n end\n end",
"def format_comment(comment)\n comment\n end",
"def comment(text)\n@out << \"<!-- #{text} -->\"\nnil\nend",
"def array_to_sentence_string(array, connector = T.unsafe(nil)); end",
"def on_array(*body)\n @last_sexp =\n super(*body).tap do |sexp|\n next unless SPECIAL_LITERALS.include?(body.dig(0, :type))\n\n comments = sexp.dig(:body, 0).delete(:comments)\n sexp.merge!(comments: comments) if comments\n end\n end",
"def poem &block\n annotate block do |c|\n c.split(\"\\n\").join(\" \\n\")\n end\nend",
"def item_comment_string(item, html_required)\n return \"\" if item.nil?\n \n if item.comment.nil? || item.comment.blank?\n return \"Comment: \" + (html_required ? \"<span class='none_text'>none</span>\" : \"none\")\n else\n return \"Comment: \" + (html_required ? \"<div class='comment_text'>#{white_list(simple_format(item.comment))}</div>\" : (\"\\n | \" + item.comment.gsub(/\\n/, \"\\n | \")))\n end\n end",
"def extract_description(an_array)\n description = \"\"\n while !an_array.shift.empty? do\n # NOOP\n end\n\n until an_array.first.empty? do\n description << an_array.shift.strip + \"\\n\"\n end\n\n return description.chomp\nend",
"def one_line_description(opts={}) ; attributes['comments'] ; end",
"def text hard_break = nil\n @parts.map do |part|\n if RDoc::Markup::HardBreak === part then\n '%1$s%3$*2$s' % [hard_break, @indent, ' '] if hard_break\n else\n part\n end\n end.join\n end",
"def prettyOutput(array)\n if array.length > 1\n array[0..-2].join(\"\") + \" & \" + array[-1]\n elsif array.length == 1\n array[0]\n else\n \"\"\n end\n end",
"def comments\n results = []\n return results unless @comments\n\n comment = ''\n @comments.split(\"\\n\").each do |line|\n if line =~ /^\\S/\n results << comment unless comment.empty?\n comment = line\n else\n comment += \"\\n\" + line\n end\n end\n\n results << comment unless comment.empty?\n return results\n end",
"def parse_comments(comments)\n return '' if !comments || comments.empty?\n meta_match = /^@(\\S+)\\s*(.*)/\n comments = comments.split(/\\r?\\n/) if comments.is_a? String\n docstring = \"\"\n\n indent, last_indent = comments.first[/^\\s*/].length, 0\n orig_indent = 0\n last_line = \"\"\n tag_name, tag_klass, tag_buf, raw_buf = nil, nil, \"\", []\n\n (comments+['']).each_with_index do |line, index|\n indent = line[/^\\s*/].length \n empty = (line =~ /^\\s*$/ ? true : false)\n done = comments.size == index\n\n if tag_name && (((indent < orig_indent && !empty) || done) || \n (indent <= last_indent && line =~ meta_match))\n create_tag(tag_name, tag_buf, raw_buf)\n tag_name, tag_buf, raw_buf = nil, '', []\n orig_indent = 0\n end\n\n # Found a meta tag\n if line =~ meta_match\n orig_indent = indent\n tag_name, tag_buf = $1, $2 \n raw_buf = [tag_buf.dup]\n elsif tag_name && indent >= orig_indent && !empty\n # Extra data added to the tag on the next line\n last_empty = last_line =~ /^[ \\t]*$/ ? true : false\n \n if last_empty\n tag_buf << \"\\n\\n\" \n raw_buf << ''\n end\n \n tag_buf << line.gsub(/^[ \\t]{#{indent}}/, last_empty ? '' : ' ')\n raw_buf << line.gsub(/^[ \\t]{#{orig_indent}}/, '')\n elsif !tag_name\n # Regular docstring text\n docstring << line << \"\\n\" \n end\n\n last_indent = indent\n last_line = line\n end\n\n # Remove trailing/leading whitespace / newlines\n docstring.gsub!(/\\A[\\r\\n\\s]+|[\\r\\n\\s]+\\Z/, '')\n end",
"def getComment(var)\n return \"@* \" << var.text << \" *@\\n\"\n end",
"def stringify(arr)\n arr.map { |s| s.to_s }.join(\"<br>\")\n end",
"def bullet(str)\n @result << ['* ', str, \"\\n\"]\n end",
"def comment name\n\t\tempty = \"//\\n\"\n\n\t\tret = ''\n\t\tret << empty << empty\n\t\tret << \"// #{name}\\n\"\n\t\tret << \"// This is an object created by COBGIN\\n\"\n\t\tret << empty << empty\n\t\tret << \"// by Mickey Barboi\\n\"\n\t\tret << empty << empty << \"\\n\\n\"\n\n\t\tret\n\tend",
"def commentString\n if(comments.length <= 0)\n return 'No hay comentarios'\n else\n return ''\n end\n end",
"def generate_string(options = {})\n \"##{comment}\\n\"\n end",
"def parse_comment(raw)\n c = nil\n if raw =~ /\\A\\((.+?)\\)(.+)\\z/\n c, raw = [$2, $1]\n end\n if raw =~ /\\A(.+)\\((.+?)\\)\\z/\n raw, c = [$1, $2]\n end\n [raw, c]\n end",
"def include_string(arr)\r\n arr.map{ |s| \"-I#{s}\" }.join(' ')\r\nend",
"def compress(string)\n ops = [HTML_COMMENTS, JS_MULTI_COMMENTS, JS_COMMENTS, BLANK_LINES]\n\n ops.reduce(string) do |output, op|\n output.gsub(op, \"\")\n end\n end",
"def comment(text)\n comments << text\n end",
"def check_comments(input, markers)\n lines = input.split(\"\\n\")\n output = ''\n lines.each do |line|\n line_end = line.length\n line.chars.each_with_index do |char, index|\n line_end = index if markers.include?(char)\n end\n new_line = line[0...line_end].rstrip\n output += new_line + (line == lines.last ? '' : \"\\n\")\n end\n output\nend",
"def comment=(_arg0); end",
"def comment=(_arg0); end",
"def comment=(_arg0); end",
"def comment=(_arg0); end",
"def getComment(var)\n return \"/* \" << var.text << \" */\\n\"\n end",
"def with_comments(rule_name, properties, comment_type)\n puts properties.inspect\n props = Array(properties) + [\"$END$\"]\n case comment_type\n when :side # first line gets the comment appended to it\n props[0] += \" /* #{short_comment(rule_name)} */\"\n when :top # comment is added as first line\n props.unshift \"/* #{short_comment(name, rule_name)} */\"\n else # mostly :none\n # noop\n end\n props.join(\"\\n\")\n end",
"def discourse_link comments_id\n link = \"\n\\\\\n\\\\awesomebox[serverless-purple]{1pt}{\\\\faComments}{serverless-purple}{\n\\\\textbf{Help and discussion}\n\nView the \\\\href{#{$config['forum_url']+$config['forum_thread_prefix']}#{comments_id}}{comments for this chapter on our forums}\n}\n\"\nend",
"def line_comments_option; end",
"def comment(value)\n merge(comment: value.to_s)\n end",
"def format_sql_comment(comment)\n \" -- #{comment.to_s.gsub(/\\s+/, ' ')}\\n\"\n end",
"def text hard_break = ''\n @parts.map do |part|\n if RDoc::Markup::HardBreak === part then\n hard_break\n else\n part\n end\n end.join\n end",
"def doc_comment(header: true)\n comps = \"\"\n self.components.each do |comp|\n case comp\n when Eddy::Summary::Segment then comps << \" - #{comp.id.upcase}\\n\"\n when Eddy::Summary::Loop then comps << \" - #{comp.id.upcase} (loop)\\n\"\n end\n end\n parts = []\n parts << \"### Loop Summary:\\n\" if header\n parts << <<~YARD.strip\n - Repeat: #{self.repeat_limit}\n - Components:\n #{comps}\n YARD\n return parts.compact.join(\"\\n\")\n end",
"def comment str\n self.add_comment(\"This is a paragraph comment for the paragraph\", \"OCELOT Commenter\");\n end",
"def comment_keywords\n if self =~ /(select)/i\n foo=$1\n newstr = self.gsub(foo, \"/*#{foo}*/\")\n else\n newstr = self\n end\n if newstr =~ /(update)/i\n foo=$1\n newstr = newstr.gsub!(foo, \"/*#{foo}*/\")\n end\n if newstr =~ /(insert)/i\n foo=$1\n newstr = newstr.gsub!(foo, \"/*#{foo}*/\")\n end\n if newstr =~ /(delete)/i\n foo=$1\n newstr = newstr.gsub!(foo, \"/*#{foo}*/\")\n end\n if newstr =~ /(union)/i\n foo=$1\n newstr = newstr.gsub!(foo, \"/*#{foo}*/\")\n end\n if newstr =~ /[, ](concat)/i\n foo=$1\n newstr = newstr.gsub!(foo, \"/*#{foo}*/\")\n end\n if newstr =~ /(group_concat)/i\n foo=$1\n newstr = newstr.gsub!(foo, \"/*#{foo}*/\")\n end\n if newstr =~ /(information_schema)/i\n foo=$1\n newstr = newstr.gsub!(foo, \"/*#{foo}*/\")\n end\n if newstr =~ /(cast)/i\n foo=$1\n newstr = newstr.gsub!(foo, \"/*#{foo}*/\")\n end\n if newstr =~ /(convert)/i\n foo=$1\n newstr = newstr.gsub!(foo, \"/*#{foo}*/\")\n end\n if newstr =~ /(substring)/i\n foo=$1\n newstr = newstr.gsub!(foo, \"/*#{foo}*/\")\n end\n if newstr =~ /(sleep)/i\n foo=$1\n newstr = newstr.gsub!(foo, \"/*#{foo}*/\")\n end\n if newstr =~ /(benchmark)/i\n foo=$1\n newstr = newstr.gsub!(foo, \"/*#{foo}*/\")\n end\n return newstr\n end",
"def _comment\n\n _save = self.pos\n while true # choice\n _tmp = scan(/\\A(?-mix:--.*?$)/)\n break if _tmp\n self.pos = _save\n _tmp = apply(:_multi_comment)\n break if _tmp\n self.pos = _save\n break\n end # end choice\n\n set_failed_rule :_comment unless _tmp\n return _tmp\n end",
"def comment_lines(arr)\n output = 0\n begin\n i = 0\n while i < arr.length\n if arr[i] == \"#\\n\"\n output += 1\n else\n j = 0\n temp_holder = arr[i]\n while j < temp_holder.length\n if temp_holder[j] == \"#\"\n output += 1\n break\n elsif temp_holder[j] != \" \"\n break\n end\n j += 1\n end\n end\n i += 1\n end\n rescue NameError\n p \"No variable with this name\"\n rescue TypeError\n p \"String was not converted into integer\"\n rescue IndexError\n p \"Index was not inside the paramaters\"\n ensure\n return output\n end\nend",
"def add_comments(item, typed_object)\n if @keep_original_comments\n typed_object.add_comments(item.docstring.all.split(\"\\n\"))\n else\n parser = YARD::Docstring.parser\n parser.parse(item.docstring.all)\n\n docs_array = parser.text.split(\"\\n\")\n\n # Add @param tags if there are any with names and descriptions.\n params = parser.tags.select { |tag| tag.tag_name == 'param' && tag.is_a?(YARD::Tags::Tag) && !tag.name.nil? }\n # Add a blank line if there's anything before the params.\n docs_array << '' if docs_array.length.positive? && params.length.positive?\n params.each do |param|\n docs_array << '' if docs_array.last != '' && docs_array.length.positive?\n # Output params in the form of:\n # _@param_ `foo` — Lorem ipsum.\n # _@param_ `foo`\n if param.text.nil? || param.text == ''\n docs_array << \"_@param_ `#{param.name}`\"\n else\n docs_array << \"_@param_ `#{param.name}` — #{param.text.gsub(\"\\n\", \" \")}\"\n end\n end\n\n # Add @return tags (there could possibly be more than one, despite this not being supported)\n returns = parser.tags.select { |tag| tag.tag_name == 'return' && tag.is_a?(YARD::Tags::Tag) && !tag.text.nil? && tag.text.strip != '' }\n # Add a blank line if there's anything before the returns.\n docs_array << '' if docs_array.length.positive? && returns.length.positive?\n returns.each do |retn|\n docs_array << '' if docs_array.last != '' && docs_array.length.positive?\n # Output returns in the form of:\n # _@return_ — Lorem ipsum.\n docs_array << \"_@return_ — #{retn.text}\"\n end\n\n # Iterate through the @example tags for a given YARD doc and output them in Markdown codeblocks.\n examples = parser.tags.select { |tag| tag.tag_name == 'example' && tag.is_a?(YARD::Tags::Tag) }\n examples.each do |example|\n # Only add a blank line if there's anything before the example.\n docs_array << '' if docs_array.length.positive?\n # Include the example's 'name' if there is one.\n docs_array << example.name unless example.name.nil? || example.name == \"\"\n docs_array << \"```ruby\"\n docs_array.concat(example.text.split(\"\\n\"))\n docs_array << \"```\"\n end if examples.length.positive?\n\n # Add @note and @deprecated tags.\n notice_tags = parser.tags.select { |tag| ['note', 'deprecated'].include?(tag.tag_name) && tag.is_a?(YARD::Tags::Tag) }\n # Add a blank line if there's anything before the params.\n docs_array << '' if docs_array.last != '' && docs_array.length.positive? && notice_tags.length.positive?\n notice_tags.each do |notice_tag|\n docs_array << '' if docs_array.last != ''\n # Output note/deprecated/see in the form of:\n # _@note_ — Lorem ipsum.\n # _@note_\n if notice_tag.text.nil?\n docs_array << \"_@#{notice_tag.tag_name}_\"\n else\n docs_array << \"_@#{notice_tag.tag_name}_ — #{notice_tag.text}\"\n end\n end\n\n # Add @see tags.\n see_tags = parser.tags.select { |tag| tag.tag_name == 'see' && tag.is_a?(YARD::Tags::Tag) }\n # Add a blank line if there's anything before the params.\n docs_array << '' if docs_array.last != '' && docs_array.length.positive? && see_tags.length.positive?\n see_tags.each do |see_tag|\n docs_array << '' if docs_array.last != ''\n # Output note/deprecated/see in the form of:\n # _@see_ `B` — Lorem ipsum.\n # _@see_ `B`\n if see_tag.text.nil?\n docs_array << \"_@see_ `#{see_tag.name}`\"\n else\n docs_array << \"_@see_ `#{see_tag.name}` — #{see_tag.text}\"\n end\n end\n\n # fix: yard text may contains multiple line. should deal \\n.\n # else generate text will be multiple line and only first line is commented\n docs_array = docs_array.flat_map {|line| line.empty? ? [\"\"] : line.split(\"\\n\")}\n typed_object.add_comments(docs_array)\n end\n end",
"def pretty a\n a.reduce \"\" do |s, x|\n s + (s == \"\" ? \"\" : \" * \") +\n if x[1] == 1\n x[0].to_s\n else\n x[0].to_s + \"^\" + x[1].to_s\n end\n end\nend",
"def comment_code\n block_match = /\\{([^\\{\\}]*)\\}/\n matches = @code.scan(block_match)\n return if matches.size != 1\n \n block = matches[0][0].to_s\n @code.gsub!(block_match, \"{\\n#{comment_struct_list(block)}#{@indent}}\")\n end",
"def comment\n multi_line_comment || single_line_comment\n end",
"def comment(text)\n @out << \"<!-- #{text} -->\"\n nil\n end",
"def array_to_code(arr)\n code = ''\n arr.each_with_index do |part, i|\n code << ' + ' if i > 0\n case part\n when Symbol\n code << part.to_s\n when String\n code << %{\"#{part}\"}\n else\n raise \"Don't know how to compile array part: #{part.class} [#{i}]\"\n end\n end\n code\n end",
"def add_comment(comment)\n \"\\n+++++++++++++++++++++++++++++++++++++++++ #{comment} ++++++++++++++++++++++++++++++++++++++++++++++\\n\"\n end",
"def array_method(string)\n string.join(\" \")\nend",
"def human_string(array)\n length = array.length\n \n new_string = array[0...-1].join(\", \")\n new_string << \" and #{array[-1]}\"\n \n return new_string\nend",
"def normalize_comment text\n return text if text.empty?\n\n text = strip_hashes text\n text = expand_tabs text\n text = flush_left text\n strip_newlines text\n end",
"def formatComments(theLines)\n\n\ttheLines.each_with_index do |theLine, theIndex|\n\n\t\tif (theIndex >= 2)\n\t\t\n\t\t\tline0 = theLines[theIndex - 2];\n\t\t\tline1 = theLines[theIndex - 1];\n\t\t\tline2 = theLines[theIndex - 0];\n\t\t\t\n\t\t\tif (line0[:text].empty? &&\n\t\t\t\tline1[:text].empty? &&\n\t\t\t\tline2[:text].empty? &&\n\n\t\t\t\tline0[:comment] =~ /^\\/\\/==========+/ &&\n\t\t\t\tline2[:comment] =~ /^\\/\\/----------+/ &&\n\t\t\t\tline1[:comment] =~ /^\\/\\/\\s*(.*)/ )\n\n\n\t\t\t\t# Fix up standard blocks\n\t\t\t\ttheComment = $1;\n\t\t\t\tcommentKey = $1.chomp('.').downcase;\n\n\t\t\t\tif (COMMENT_STANDARD.has_value?(theComment))\n\t\t\t\t\t# Accept as-is\n\n\t\t\t\telsif (COMMENT_STANDARD.has_key?(commentKey))\n\t\t\t\t\ttheComment = COMMENT_STANDARD[commentKey];\n\n\n\n\t\t\t\t# Fix up function blocks\n\t\t\t\telsif (theComment =~ /^(.*)\\s:\\s(.*)$/)\n\t\t\t\t\ttheName = $1.strip;\n\t\t\t\t\ttheDesc = $2.strip.chomp(\".\");\n\n\n\t\t\t\t\t# Normalise the description\n\t\t\t\t\tif (theName =~ /^(\\w+)::\\1$/)\n\t\t\t\t\t\ttheDesc = \"Constructor.\";\n\t\t\t\t\t\n\t\t\t\t\telsif (theName =~ /^(\\w+)::~\\1$/)\n\t\t\t\t\t\ttheDesc = \"Destructor.\";\n\t\t\t\t\t\n\t\t\t\t\telsif (theDesc.empty?)\n\t\t\t\t\t\ttheDesc = \"MISSING DESCRIPTION.\";\n\t\t\t\t\tend\n\t\t\t\t\n\t\t\t\t\tif (!theDesc.end_with?(\".\", \"?\", \"!\"))\n\t\t\t\t\t\ttheDesc += \".\";\n\t\t\t\t\tend\n\t\t\t\t\t\n\t\t\t\t\ttheComment = theName + \" : \" + theDesc;\n\t\t\t\tend\n\n\n\n\t\t\t\t# Rewrite the the comment\n\t\t\t\ttheLines[theIndex - 2][:comment] = COMMENT_BAR_TOP;\n\t\t\t\ttheLines[theIndex - 1][:comment] = COMMENT_BAR_CONTENT + theComment;\n\t\t\t\ttheLines[theIndex - 0][:comment] = COMMENT_BAR_BOTTOM;\n\t\t\tend\n\t\t\n\t\tend\n\tend\n\n\treturn theLines;\n\nend",
"def formatAnswersToSimple( answerArr )\n resultString = \"\"\n # answerArr.each{ |ansArr|\n# resultString = resultString + ansArr.join( \",\" )\n # resultString = resultString + \"~\"\n # }\n resultString = answerArr.join(\"~\")\nend",
"def mangle_comment(comment)\n comment.sub!(%r{/\\*+}) { \" \" * $&.length }\n comment.sub!(%r{\\*+/}) { \" \" * $&.length }\n comment.gsub!(/^[ \\t]*\\*/m) { \" \" * $&.length }\n comment\n end",
"def lastComment\n separator = \" \"\n result = \"\"\n result = \"#{@comment}\" if @comment\n if @annotation and $enableInstrAnnotations\n result += separator if result != \"\"\n result += \"#{@annotation}\"\n end\n if @internalComment\n result += separator if result != \"\"\n result += \"#{@internalComment}\"\n end\n if @codeOrigin and $enableCodeOriginComments\n result += separator if result != \"\"\n result += \"#{@codeOrigin}\"\n end\n if result != \"\"\n result = $commentPrefix + \" \" + result\n end\n\n # Reset all the components that we've just sent to be dumped.\n @commentState = :none\n @comment = nil\n @annotation = nil\n @codeOrigin = nil\n @internalComment = nil\n result\n end",
"def parse_comments\n @data[4][0]\n end",
"def comment\n cyc.comment(self.to_sym)\n end",
"def normalize_comment text\n return text if text.empty?\n\n case language\n when :ruby\n text = strip_hashes text\n when :c\n text = strip_stars text\n end\n text = expand_tabs text\n text = flush_left text\n text = strip_newlines text\n text\n end",
"def push_comment(text)\n\t text.strip!\n\t @primitives.push Comment.new(text) if text && text.length\n\tend"
] |
[
"0.7203483",
"0.6579914",
"0.6579914",
"0.6579914",
"0.6579914",
"0.62640107",
"0.6136036",
"0.6130273",
"0.6062229",
"0.60561925",
"0.60320175",
"0.59862894",
"0.59648246",
"0.5960865",
"0.5913104",
"0.5907246",
"0.5890026",
"0.5889057",
"0.5889057",
"0.58862275",
"0.58753306",
"0.58626646",
"0.58626646",
"0.58578986",
"0.5823086",
"0.5807138",
"0.5782595",
"0.5771404",
"0.5744079",
"0.5719719",
"0.5714558",
"0.57099634",
"0.5702263",
"0.5699351",
"0.5695034",
"0.5676657",
"0.567088",
"0.56701547",
"0.56701547",
"0.56701547",
"0.56701547",
"0.56701547",
"0.5656774",
"0.56355804",
"0.5621992",
"0.55435824",
"0.55229044",
"0.55195796",
"0.5517778",
"0.5512592",
"0.54946613",
"0.54857",
"0.5474215",
"0.5472742",
"0.5470816",
"0.54677504",
"0.5465616",
"0.5463721",
"0.545122",
"0.54507333",
"0.5446656",
"0.5432304",
"0.5429216",
"0.5417334",
"0.5414881",
"0.5411728",
"0.5389077",
"0.5389077",
"0.5389077",
"0.5389077",
"0.5383101",
"0.538011",
"0.5379302",
"0.53571767",
"0.53354484",
"0.5335128",
"0.53230155",
"0.53223926",
"0.531169",
"0.53103095",
"0.52992463",
"0.52922654",
"0.52912575",
"0.5289766",
"0.5286635",
"0.5281774",
"0.5267456",
"0.5257441",
"0.5255727",
"0.52472985",
"0.52381605",
"0.52237624",
"0.52196896",
"0.52191526",
"0.52161235",
"0.5212534",
"0.5188766",
"0.5176264",
"0.51702076",
"0.51617193"
] |
0.62279874
|
6
|
builds up a template header with given informatations
|
def buildup_template_header(basename, hash)
header = []
type = hash[:type] || :script
header << filename_for(basename, type)
header << ""
description = hash[:description] || "no description"
header << teardown_to_oneline(description)
header << ""
date = hash[:date] || Time.now
header << "created on : %04d.%02d.%02d" % [date.year, date.month, date.day]
header << "last update: %04d.%02d.%02d" % [date.year, date.month, date.day]
header << ""
author = hash[:author] || AUTHOR_NAME
header << teardown_to_oneline("by " + author)
return header.flatten
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def build_header(keys_template)\n header = ''\n names = []\n keys = deep_copy(keys_template)\n\n keys.each { |key|\n begin\n if @config.header_mappings.any? { |k| k.include? key }\n\n header_label = key\n\n @config.header_mappings.each { |k, v|\n if header_label.include? k\n header_label.gsub!(k, v)\n end\n\n }\n names << header_label\n\n elsif @config.header_overrides.split(',').include?(key)\n names << key\n elsif key.include?('coordinates')\n names << key\n elsif key.split('.')[-1].is_i?\n names << key\n else\n #We want to grab the last element and add it to the array.\n name = key.split(\".\")[-1]\n\n if !names.include?(name)\n names << name\n else\n if key.split(\".\")[-2].is_i?\n name = key.split(\".\")[-3..-1].join(\".\")\n else\n name = key.split(\".\")[-2..-1].join(\".\")\n end\n\n if !names.include?(name)\n names << name\n else\n name = key.split(\".\")[-3..-1].join(\".\")\n if !names.include?(name)\n names << name\n else\n #p \"No action taken. #{name} not added to name array. (build_header)\"\n end\n end\n end\n end\n rescue Exception => e\n AppLogger.log.error(\"ERROR in build_header method with #{key}: #{e.message}\")\n end\n }\n\n header = CSV.generate do |csv|\n csv << names\n end\n\n header\n end",
"def build_header_footer( interchange_name )\n\n header = <<-HEADER\n<?xml version=\"1.0\"?>\n<Interchange#{interchange_name} xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://ed-fi.org/0100\"\nxsi:schemaLocation=\"http://ed-fi.org/0100 ../../sli/edfi-schema/src/main/resources/edfiXsd-SLI/SLI-Interchange-#{interchange_name}.xsd\">\nHEADER\n\n footer = \"</Interchange#{interchange_name}>\"\n\n return header, footer\nend",
"def create_header(meta_data)\n station = meta_data.station\n start_date = meta_data.start_date\n @header = I18n.t(\"forecast_text.main.header_start\")\n @header.concat(station.name)\n @header.concat(I18n.t(\"forecast_text.main.header_conn\"))\n @header.concat(start_date.to_s)\n nil\n end",
"def create_header(my_name)\n\t\"<h1>#{my_name}</h1>\"\nend",
"def header_build\n header = \"customer name\" + @delimiter + \"gender\" + @delimiter\n header += \"age\" + @delimiter + \"birthday\" + @delimiter + \"cpf\" + @delimiter + \"id\" + @delimiter\n header += \"state\" + @delimiter + \"city\" + @delimiter + \"street\" + @delimiter + \"zip_code\" + @delimiter\n header += \"company name\" + @delimiter + \"industry\" + @delimiter + \"cnpj\"\n header\nend",
"def build_header \n pdf_writer.margins_in(1)\n \n pad_bottom(10) do\n if allflag\n add_text \"All Tasks\"\n else\n add_text \"Current Tasks\"\n end\n end \n end",
"def build_header \n pdf_writer.margins_in(1)\n \n pad_bottom(10) do\n if allflag\n add_text \"All Goals\"\n else\n add_text \"Current Goals\"\n end\n end \n \n end",
"def get_template_headers\n template_headers = File.read(@template_filename).scan(/\\[\\[([A-Za-z0-9:]+)\\]\\]/).uniq.flatten\n end",
"def owner_to_header(_options = {})\n Origen.compile(\"#{path_to_templates}/headers/default.h.erb\", scope: owner)\n end",
"def generate_header(newer_tag_name, newer_tag_link, newer_tag_time, older_tag_name, project_url)\n header = \"\"\n\n # Generate date string:\n time_string = newer_tag_time.strftime(@options[:date_format])\n\n # Generate tag name and link\n release_url = if @options[:release_url]\n format(@options[:release_url], newer_tag_link)\n else\n \"#{project_url}/tree/#{newer_tag_link}\"\n end\n header += if newer_tag_name.equal?(@options[:unreleased_label])\n \"## [#{newer_tag_name}](#{release_url})\\n\\n\"\n else\n \"## [#{newer_tag_name}](#{release_url}) (#{time_string})\\n\\n\"\n end\n\n if @options[:compare_link] && older_tag_name\n # Generate compare link\n header += \"[Full Changelog](#{project_url}/compare/#{older_tag_name}...#{newer_tag_link})\\n\\n\"\n end\n\n header\n end",
"def build_header \n pdf_writer.margins_in(1)\n if timespan == \"Weekly\"\n add_text \"Status Report for the Week of \" + Time.now.to_formatted_s(:date)\n else\n add_text \"Status Report for \" + Time.now.to_formatted_s(:date)\n end\n end",
"def header(format, ntrks, division)\n end",
"def template(name, params: {})\n source_file = template_path(name)\n header_for(source_file, params.fetch(:header, true)) +\n ERB.new(File.read(source_file), trim_mode: '<>').result(binding).strip +\n \"\\n\"\n end",
"def gen_header(fp)\n fp.puts(\"/*\")\n fp.puts(\" * Copyright (c) 2015, msyksphinz\")\n fp.puts(\" * All rights reserved.\")\n fp.puts(\" *\")\n fp.puts(\" * Redistribution and use in source and binary forms, with or without\")\n fp.puts(\" * modification, are permitted provided that the following conditions are met:\")\n fp.puts(\" * * Redistributions of source code must retain the above copyright\")\n fp.puts(\" * notice, this list of conditions and the following disclaimer.\")\n fp.puts(\" * * Redistributions in binary form must reproduce the above copyright\")\n fp.puts(\" * notice, this list of conditions and the following disclaimer in the\")\n fp.puts(\" * documentation and/or other materials provided with the distribution.\")\n fp.puts(\" * * Neither the name of the msyksphinz nor the\")\n fp.puts(\" * names of its contributors may be used to endorse or promote products\")\n fp.puts(\" * derived from this software without specific prior written permission.\")\n fp.puts(\" *\")\n fp.puts(\" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \\\"AS IS\\\" AND\")\n fp.puts(\" * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\")\n fp.puts(\" * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\")\n fp.puts(\" * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\")\n fp.puts(\" * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\")\n fp.puts(\" * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\")\n fp.puts(\" * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\")\n fp.puts(\" * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\")\n fp.puts(\" * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\")\n fp.puts(\" * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\")\n fp.puts(\" */\")\n fp.puts(\"\")\n fp.puts(\"/* CAUTION! THIS SOURCE CODE IS GENERATED AUTOMATICALLY. DON'T MODIFY BY HAND. */\")\n fp.puts(\"\")\n fp.puts(\"\")\nend",
"def gen_header(fp)\n fp.puts(\"/*\")\n fp.puts(\" * Copyright (c) 2015, Masayuki Kimura\")\n fp.puts(\" * All rights reserved.\")\n fp.puts(\" *\")\n fp.puts(\" * Redistribution and use in source and binary forms, with or without\")\n fp.puts(\" * modification, are permitted provided that the following conditions are met:\")\n fp.puts(\" * * Redistributions of source code must retain the above copyright\")\n fp.puts(\" * notice, this list of conditions and the following disclaimer.\")\n fp.puts(\" * * Redistributions in binary form must reproduce the above copyright\")\n fp.puts(\" * notice, this list of conditions and the following disclaimer in the\")\n fp.puts(\" * documentation and/or other materials provided with the distribution.\")\n fp.puts(\" * * Neither the name of the Masayuki Kimura nor the\")\n fp.puts(\" * names of its contributors may be used to endorse or promote products\")\n fp.puts(\" * derived from this software without specific prior written permission.\")\n fp.puts(\" *\")\n fp.puts(\" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \\\"AS IS\\\" AND\")\n fp.puts(\" * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\")\n fp.puts(\" * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\")\n fp.puts(\" * DISCLAIMED. IN NO EVENT SHALL MASAYUKI KIMURA BE LIABLE FOR ANY\")\n fp.puts(\" * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\")\n fp.puts(\" * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\")\n fp.puts(\" * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\")\n fp.puts(\" * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\")\n fp.puts(\" * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\")\n fp.puts(\" * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\")\n fp.puts(\" */\")\n fp.puts(\"\")\n fp.puts(\"/* CAUTION! THIS SOURCE CODE IS GENERATED AUTOMATICALLY. DON'T MODIFY BY HAND. */\")\n fp.puts(\"\")\n fp.puts(\"\")\nend",
"def gen_header(fp)\n fp.puts(\"/*\")\n fp.puts(\" * Copyright (c) 2015, Masayuki Kimura\")\n fp.puts(\" * All rights reserved.\")\n fp.puts(\" *\")\n fp.puts(\" * Redistribution and use in source and binary forms, with or without\")\n fp.puts(\" * modification, are permitted provided that the following conditions are met:\")\n fp.puts(\" * * Redistributions of source code must retain the above copyright\")\n fp.puts(\" * notice, this list of conditions and the following disclaimer.\")\n fp.puts(\" * * Redistributions in binary form must reproduce the above copyright\")\n fp.puts(\" * notice, this list of conditions and the following disclaimer in the\")\n fp.puts(\" * documentation and/or other materials provided with the distribution.\")\n fp.puts(\" * * Neither the name of the Masayuki Kimura nor the\")\n fp.puts(\" * names of its contributors may be used to endorse or promote products\")\n fp.puts(\" * derived from this software without specific prior written permission.\")\n fp.puts(\" *\")\n fp.puts(\" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \\\"AS IS\\\" AND\")\n fp.puts(\" * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\")\n fp.puts(\" * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\")\n fp.puts(\" * DISCLAIMED. IN NO EVENT SHALL MASAYUKI KIMURA BE LIABLE FOR ANY\")\n fp.puts(\" * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\")\n fp.puts(\" * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\")\n fp.puts(\" * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\")\n fp.puts(\" * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\")\n fp.puts(\" * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\")\n fp.puts(\" * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\")\n fp.puts(\" */\")\n fp.puts(\"\")\n fp.puts(\"/* CAUTION! THIS SOURCE CODE IS GENERATED AUTOMATICALLY. DON'T MODIFY BY HAND. */\")\n fp.puts(\"\")\n fp.puts(\"\")\nend",
"def generate_header(provider = nil)\n cda_header = { identifier: { root: 'CypressRoot', extension: 'CypressExtension' },\n authors: [{ ids: [{ root: 'authorRoot', extension: 'authorExtension' }],\n device: { name: 'deviceName', model: 'deviceModel' },\n addresses: [], telecoms: [], time: nil,\n organization: { ids: [{ root: 'authorsOrganizationRoot', extension: 'authorsOrganizationExt' }], name: '' } }],\n custodian: { ids: [{ root: 'custodianRoot', extension: 'custodianExt' }],\n person: { given: '', family: '' }, organization: { ids: [{ root: 'custodianOrganizationRoot',\n extension: 'custodianOrganizationExt' }], name: '' } },\n legal_authenticator: { ids: [{ root: 'legalAuthenticatorRoot', extension: 'legalAuthenticatorExt' }], addresses: [],\n telecoms: [], time: nil,\n person: { given: nil, family: nil },\n organization: { ids: [{ root: 'legalAuthenticatorOrgRoot', extension: 'legalAuthenticatorOrgExt' }],\n name: '' } } }\n\n header = Qrda::Header.new(cda_header)\n\n header.identifier.root = UUID.generate\n header.authors.each { |a| a.time = Time.current }\n header.legal_authenticator.time = Time.current\n header.performers << provider\n\n header\n end",
"def tex_header(lang, gender, barcode)\n # writes yaml header on texing\n s = \"\\\\head{#{title(lang)}}{#{barcode}}\\n\\n\"\n s << \"#{intro(lang)}\\n\\n\"\n s << \"\\\\vspace{0.8mm}\"\n s << \"\\\\dataline{#{I18n.t(:title)}}\"\n s << \"{#{I18n.t(:lecturer)[gender]}}{#{I18n.t(:term)}}\\n\"\n s << \"\\\\vspace{-2.5mm}\"\n s\n end",
"def build_header\n @pdf.text_box(\n @labels[:name],\n size: 20,\n align: :left,\n at: [0, y(720) - @push_down],\n width: x(300),\n )\n\n if used? @labels[:sublabels][:name]\n @pdf.text_box(\n @labels[:sublabels][:name],\n size: 12,\n at: [0, y(720) - @push_down - 22],\n width: x(300),\n align: :left\n )\n end\n\n @pdf.text_box(\n @document.number,\n size: 20,\n at: [x(240), y(720) - @push_down],\n width: x(300),\n align: :right\n )\n\n @pdf.move_down(250)\n\n if used? @labels[:sublabels][:name]\n @pdf.move_down(12)\n end\n end",
"def generate\n header + dict + footer\n end",
"def make_header(field_string)\r\n return \"<p><b>#{field_string}</b></p>\"\r\n end",
"def build_table_header\n names = column_names(data)\n build_md_row(output, names)\n build_md_row(output, alignment_strings(names))\n end",
"def generate_header\n \n self.reload\n self.headers.reload\n \n layout_path = self.current_layout.relative_path unless self.current_layout.nil?\n \n # Default header values\n yaml_headers = {'title' => self.name, \n 'created_at' => Time.now,\n 'layout' => layout_path}\n \n self.headers.each do |header|\n yaml_headers[header.name] = header.content\n end\n \n update_attributes(:generated_header => YAML::dump(yaml_headers) + \"---\\n\")\n end",
"def build_header_output\n output = []\n\n @header.each do |line|\n _data = []\n line.each do |h|\n _data << {:value => h, :color => @style[:header]}\n end\n output << _data\n end\n output\n end",
"def header_for(source_file, generate_header)\n return '' unless generate_header\n\n root_path = File.expand_path('..', __dir__)\n simplified_path = source_file.sub(/^#{root_path}\\//, '')\n\n <<~HEADER\n\n # -----------------------------------------------\n # #{simplified_path}\n # -----------------------------------------------\n\n HEADER\n end",
"def prepare_project_header_and_footer\n @header_text = @project.templets.find_by_name('PAGE_HEADER').render( @project )\n @footer_text = @project.templets.find_by_name('PAGE_FOOTER').render( @project )\n end",
"def build_pdf_header(pdf)\n pdf.font \"Helvetica\" , :size => 8\n $lcCli = @company.name \n $lcdir1 = @company.address1+@company.address2+@company.city+@company.state\n\n $lcFecha1= Date.today.strftime(\"%d/%m/%Y\").to_s\n $lcHora = Time.now.to_s\n\n max_rows = [client_data_headers.length, invoice_headers.length, 0].max\n rows = []\n (1..max_rows).each do |row|\n rows_index = row - 1\n rows[rows_index] = []\n rows[rows_index] += (client_data_headers.length >= row ? client_data_headers[rows_index] : ['',''])\n rows[rows_index] += (invoice_headers.length >= row ? invoice_headers[rows_index] : ['',''])\n end\n\n if rows.present?\n\n pdf.table(rows, {\n :position => :center,\n :cell_style => {:border_width => 0},\n :width => pdf.bounds.width\n }) do\n columns([0, 2]).font_style = :bold\n\n end\n\n pdf.move_down 10\n\n end\n\n\n pdf.move_down 25\n pdf \n end",
"def generateHeader( files )\n output = \"<html><body><h1>CrowdLogs for...:</h1><ul>\"\n files.each do |file|\n output += \"<li><a href='##{file}'>#{file}</a></li>\"\n end\n output += \"</ul>\"\n return output\nend",
"def fileHeader(fname, curDate, misc=\"\")\r\n fname = File.basename(fname, \".gdl\")\r\n header = <<EOF\r\n/* **************************************************************************\r\n * File: #{fname}.gdl\r\n *\r\n * Guideline source generated #{curDate}\r\n * #{misc}\r\n *\r\n * *************************************************************************/\r\n\r\n\r\nEOF\r\n\r\n return header\r\n end",
"def generate_header_row\n '<tr>' + '<th>' + \"#{(@header.map {|x| generate_header_item(x)}).join('</th><th>')}\" + '</th></tr>' + \"\\n\"\n end",
"def generate_header_row\n (@header.map {|x| generate_header_item(x)}).join\n end",
"def header(text, header_level)\n # clean string from html\n stringHeader = Sanitize.clean(text)\n\n # replace all unwanted characters to space\n stringHeader = stringHeader.downcase.gsub(/[^a-z0-9_-]+/i, \" \")\n\n # strip whitespaces from the beginning and end of a string\n stringHeader = stringHeader.strip\n\n # replace all unwanted characters to -\n stringHeader = stringHeader.downcase.gsub(/[^a-z0-9_-]+/i, \"-\")\n\n # convert number to string\n stringHeaderNum = header_level.to_s\n\n # create header\n result = '<h' + stringHeaderNum + ' id=\"' + stringHeader + '\">' + text + '</h' + stringHeaderNum + '>'\n\n return result\n end",
"def generate_header\n \"<table class='bodyTable'><thead><th>Testing element</th><th>Pass</th><th>Result</th><th>Time</th></thead><tbody>\"\n end",
"def generate_header(options)\n ret = File.read(@path + \"template_typemaps.h\");\n ret.gsub!(/HEADERS/, map_headers(options.headers, options.header_pattern, options.header_replacement))\n ret.gsub!(/NAMESPACE_GUARD/, @namespace_guard)\n ret.gsub!(/NAMESPACE_BEGIN\\n/, @namespace_begin)\n ret.gsub!(/NAMESPACE_END\\n/, @namespace_end)\n\n class_vars = options.topological_class_sortation.map do |klass|\n klass_name = options.datatype_map[klass]\n \"extern MPI_Datatype #{klass_name};\"\n end\n ret.sub!(/.*CLASS_VARS/, class_vars.join(\"\\n\"))\n\n mapgens = options.topological_class_sortation.map do |klass|\n \" static MPI_Datatype generateMap#{simple_name(klass)}();\"\n end\n ret.sub!(/.*MAPGEN_DECLARATIONS/, mapgens.join(\"\\n\"))\n\n lookup_types = Datatype.new.find_all { |k, v| v != :ignore }\n lookup_types = lookup_types.map {|k, v| k }\n lookup_types = (lookup_types.sort + options.topological_class_sortation).uniq\n\n lookups = lookup_types.map do |klass|\n <<EOF\n static inline MPI_Datatype lookup(#{klass}*)\n {\n return #{options.datatype_map[klass]};\n }\nEOF\n end\n ret.sub!(/.*LOOKUP_DEFINITIONS/, lookups.join(\"\\n\"))\n\n return guard(@macro_guard_mpi, ret)\n end",
"def build_pdf_header3(pdf)\n pdf.font \"Helvetica\" , :size => 8\n $lcCli = @company.name \n $lcdir1 = @company.address1+@company.address2+@company.city+@company.state\n\n $lcFecha1= Date.today.strftime(\"%d/%m/%Y\").to_s\n $lcHora = Time.now.to_s\n\n max_rows = [client_data_headers.length, invoice_headers.length, 0].max\n rows = []\n (1..max_rows).each do |row|\n rows_index = row - 1\n rows[rows_index] = []\n rows[rows_index] += (client_data_headers.length >= row ? client_data_headers[rows_index] : ['',''])\n rows[rows_index] += (invoice_headers.length >= row ? invoice_headers[rows_index] : ['',''])\n end\n\n if rows.present?\n\n pdf.table(rows, {\n :position => :center,\n :cell_style => {:border_width => 0},\n :width => pdf.bounds.width\n }) do\n columns([0, 2]).font_style = :bold\n\n end\n\n pdf.move_down 10\n\n end\n\n\n pdf.move_down 25\n pdf \n end",
"def build_pdf_header_rpt16(pdf)\n pdf.font \"Helvetica\" , :size => 6\n \n $lcCli = @company.name \n $lcdir1 = @company.address1+@company.address2+@company.city+@company.state\n\n $lcFecha1= Date.today.strftime(\"%d/%m/%Y\").to_s\n $lcHora = Time.now.to_s\n\n max_rows = [client_data_headers.length, invoice_headers.length, 0].max\n rows = []\n (1..max_rows).each do |row|\n rows_index = row - 1\n rows[rows_index] = []\n rows[rows_index] += (client_data_headers.length >= row ? client_data_headers[rows_index] : ['',''])\n rows[rows_index] += (invoice_headers.length >= row ? invoice_headers[rows_index] : ['',''])\n end\n\n if rows.present?\n pdf.table(rows, {\n :position => :center,\n :cell_style => {:border_width => 0},\n :width => pdf.bounds.width\n }) do\n columns([0, 2]).font_style = :bold\n\n end\n\n pdf.move_down 10\n\n end\n \n pdf \n end",
"def build_pdf_header4(pdf)\n pdf.font \"Helvetica\" , :size => 8\n $lcCli = @company.name \n $lcdir1 = @company.address1+@company.address2+@company.city+@company.state\n\n $lcFecha1= Date.today.strftime(\"%d/%m/%Y\").to_s\n $lcHora = Time.now.to_s\n\n max_rows = [client_data_headers.length, invoice_headers.length, 0].max\n rows = []\n (1..max_rows).each do |row|\n rows_index = row - 1\n rows[rows_index] = []\n rows[rows_index] += (client_data_headers.length >= row ? client_data_headers[rows_index] : ['',''])\n rows[rows_index] += (invoice_headers.length >= row ? invoice_headers[rows_index] : ['',''])\n end\n\n if rows.present?\n\n pdf.table(rows, {\n :position => :center,\n :cell_style => {:border_width => 0},\n :width => pdf.bounds.width\n }) do\n columns([0, 2]).font_style = :bold\n\n end\n\n pdf.move_down 10\n\n end\n\n\n pdf.move_down 25\n pdf \n end",
"def generate_header_item(item)\n item\n end",
"def header_and_footer\n @title = _'Labvirt'\n @footer = _'Something nice should go down here...'\n end",
"def build_pdf_header_rpt16(pdf)\n pdf.font \"Helvetica\" , :size => 6\n \n $lcCli = @company.name \n $lcdir1 = @company.address1+@company.address2+@company.city+@company.state\n\n $lcFecha1= Date.today.strftime(\"%d/%m/%Y\").to_s\n $lcHora = Time.now.to_s\n\n max_rows = [client_data_headers.length, invoice_headers.length, 0].max\n rows = []\n (1..max_rows).each do |row|\n rows_index = row - 1\n rows[rows_index] = []\n rows[rows_index] += (client_data_headers.length >= row ? client_data_headers[rows_index] : ['',''])\n rows[rows_index] += (invoice_headers.length >= row ? invoice_headers[rows_index] : ['',''])\n end\n\n if rows.present?\n pdf.table(rows, {\n :position => :center,\n :cell_style => {:border_width => 0},\n :width => pdf.bounds.width\n }) do\n columns([0, 2]).font_style = :bold\n\n end\n\n pdf.move_down 10\n\n end\n \n pdf \n end",
"def build_pdf_header_rpt16(pdf)\n pdf.font \"Helvetica\" , :size => 6\n \n $lcCli = @company.name \n $lcdir1 = @company.address1+@company.address2+@company.city+@company.state\n\n $lcFecha1= Date.today.strftime(\"%d/%m/%Y\").to_s\n $lcHora = Time.now.to_s\n\n max_rows = [client_data_headers.length, invoice_headers.length, 0].max\n rows = []\n (1..max_rows).each do |row|\n rows_index = row - 1\n rows[rows_index] = []\n rows[rows_index] += (client_data_headers.length >= row ? client_data_headers[rows_index] : ['',''])\n rows[rows_index] += (invoice_headers.length >= row ? invoice_headers[rows_index] : ['',''])\n end\n\n if rows.present?\n pdf.table(rows, {\n :position => :center,\n :cell_style => {:border_width => 0},\n :width => pdf.bounds.width\n }) do\n columns([0, 2]).font_style = :bold\n\n end\n\n pdf.move_down 10\n\n end\n \n pdf \n end",
"def header\n tag! \"h#{options[:level]}\".intern\n end",
"def pattern_header(options = {})\n options = {\n }.merge(options)\n\n @pattern_name = options[:pattern]\n\n unless pattern_only\n microcode 'STIL 1.0;'\n\n microcode ''\n microcode 'Signals {'\n ordered_pins.each do |pin|\n line = ''\n line << \"#{pin.name} \"\n if pin.direction == :input\n line << 'In;'\n elsif pin.direction == :output\n line << 'Out;'\n else\n line << 'InOut;'\n end\n microcode \" #{line}\"\n end\n microcode '}'\n\n microcode ''\n microcode 'SignalGroups {'\n line = \"\\\"#{ordered_pins_name || 'ALL'}\\\" = '\"\n ordered_pins.each_with_index do |pin, i|\n unless i == 0\n line << '+'\n end\n line << pin.name.to_s\n end\n microcode \" #{line}';\"\n microcode '}'\n\n microcode ''\n microcode \"Timing t_#{@pattern_name} {\"\n (@wavesets || []).each_with_index do |w, i|\n microcode '' if i != 0\n microcode \" WaveformTable Waveset#{i + 1} {\"\n microcode \" Period '#{w[:period]}ns';\"\n microcode ' Waveforms {'\n w[:lines].each do |line|\n microcode \" #{line}\"\n end\n microcode ' }'\n microcode ' }'\n end\n microcode '}'\n\n microcode ''\n microcode \"PatternBurst b_#{@pattern_name} {\"\n microcode \" PatList { #{@pattern_name}; }\"\n microcode '}'\n\n microcode ''\n microcode \"PatternExec e_#{@pattern_name} {\"\n microcode \" Timing t_#{@pattern_name};\"\n microcode \" PatternBurst b_#{@pattern_name};\"\n microcode '}'\n microcode ''\n end\n\n microcode \"Pattern \\\"#{@pattern_name}\\\" {\"\n microcode \"#{@pattern_name}:\"\n @header_done = true\n\n if tester.ordered_pins_name.nil? && pattern_only\n Origen.log.warn \"WARN: SigName must be defined for STIL format. Use pin_pattern_order(*pins, name: <sigName>). Defaulting to use 'ALL'\"\n end\n end",
"def add_page_header\n tenant = MnoEnterprise::Tenant.show\n title = Settings.dashboard.payment.enabled ? \"#{t(:monthly_invoice)} - \" : \"#{t(:account_statement)} - \"\n @pdf.repeat :all do\n @pdf.bounding_box([0, @pdf.bounds.top+@format[:header_size]], width: 540, height: @format[:footer_size]) do\n @pdf.float do\n @pdf.image main_logo_white_bg_path(true), fit: [135, (@format[:footer_size])]\n end\n @pdf.text tenant.name, align: :right, inline_format: true\n if tenant.main_address.present?\n tenant_address = \"#{tenant.main_address.dig('street')}\\n#{tenant.main_address.dig('city')}\\n#{ISO3166::Country.new(tenant.main_address.dig('country_code')).name}\"\n @pdf.move_down 5\n @pdf.text \"<color rgb='999999'>#{tenant_address}</color>\", align: :right, inline_format: true, style: :italic, size: 9\n end\n if contact_details = Settings.dashboard&.organization_management&.billing&.invoice_contact_details.presence\n @pdf.move_down 5\n @pdf.font_size(10) { @pdf.text contact_details, align: :right }\n end\n @pdf.move_down 10\n @pdf.font_size(20) { @pdf.text \"#{title} #{@data[:period_month]}\", style: :bold, align: :right }\n end\n end\n end",
"def load_header_template\n path = File.open(\"#{SOAP_TEMPLATE_PATH}/header.xml\")\n Nokogiri::XML(path)\n end",
"def build_header_year\n \"#{begin_date.year}/#{end_date.year}\"\n end",
"def build_pdf_header2(pdf)\n pdf.font \"Helvetica\" , :size => 8\n $lcCli = @company.name \n $lcdir1 = @company.address1+@company.address2+@company.city+@company.state\n\n $lcFecha1= Date.today.strftime(\"%d/%m/%Y\").to_s\n $lcHora = Time.now.to_s\n\n max_rows = [client_data_headers.length, invoice_headers.length, 0].max\n rows = []\n (1..max_rows).each do |row|\n rows_index = row - 1\n rows[rows_index] = []\n rows[rows_index] += (client_data_headers.length >= row ? client_data_headers[rows_index] : ['',''])\n rows[rows_index] += (invoice_headers.length >= row ? invoice_headers[rows_index] : ['',''])\n end\n\n if rows.present?\n\n pdf.table(rows, {\n :position => :center,\n :cell_style => {:border_width => 0},\n :width => pdf.bounds.width\n }) do\n columns([0, 2]).font_style = :bold\n\n end\n\n pdf.move_down 10\n\n end\n\n\n pdf.move_down 15\n pdf \n end",
"def build_pdf_header2(pdf)\n pdf.font \"Helvetica\" , :size => 8\n $lcCli = @company.name \n $lcdir1 = @company.address1+@company.address2+@company.city+@company.state\n\n $lcFecha1= Date.today.strftime(\"%d/%m/%Y\").to_s\n $lcHora = Time.now.to_s\n\n max_rows = [client_data_headers.length, invoice_headers.length, 0].max\n rows = []\n (1..max_rows).each do |row|\n rows_index = row - 1\n rows[rows_index] = []\n rows[rows_index] += (client_data_headers.length >= row ? client_data_headers[rows_index] : ['',''])\n rows[rows_index] += (invoice_headers.length >= row ? invoice_headers[rows_index] : ['',''])\n end\n\n if rows.present?\n\n pdf.table(rows, {\n :position => :center,\n :cell_style => {:border_width => 0},\n :width => pdf.bounds.width\n }) do\n columns([0, 2]).font_style = :bold\n\n end\n\n pdf.move_down 10\n\n end\n\n\n pdf.move_down 15\n pdf \n end",
"def build_pdf_header2(pdf)\n pdf.font \"Helvetica\" , :size => 8\n $lcCli = @company.name \n $lcdir1 = @company.address1+@company.address2+@company.city+@company.state\n\n $lcFecha1= Date.today.strftime(\"%d/%m/%Y\").to_s\n $lcHora = Time.now.to_s\n\n max_rows = [client_data_headers.length, invoice_headers.length, 0].max\n rows = []\n (1..max_rows).each do |row|\n rows_index = row - 1\n rows[rows_index] = []\n rows[rows_index] += (client_data_headers.length >= row ? client_data_headers[rows_index] : ['',''])\n rows[rows_index] += (invoice_headers.length >= row ? invoice_headers[rows_index] : ['',''])\n end\n\n if rows.present?\n\n pdf.table(rows, {\n :position => :center,\n :cell_style => {:border_width => 0},\n :width => pdf.bounds.width\n }) do\n columns([0, 2]).font_style = :bold\n\n end\n\n pdf.move_down 10\n\n end\n\n\n pdf.move_down 25\n pdf \n end",
"def generate_header(provider = nil)\n header = Qrda::Header.new(@@cda_header)\n\n header.identifier.root = UUID.generate\n header.authors.each {|a| a.time = Time.now}\n header.legal_authenticator.time = Time.now\n header.performers << provider\n\n header\n end",
"def build_pdf_header9(pdf)\n pdf.font \"Helvetica\" , :size => 6 \n $lcCli = @company.name \n $lcdir1 = @company.address1+@company.address2+@company.city+@company.state\n\n $lcFecha1= Date.today.strftime(\"%d/%m/%Y\").to_s\n $lcHora = Time.zone.now.to_s\n\n max_rows = [client_data_headers.length, invoice_headers.length, 0].max\n rows = []\n (1..max_rows).each do |row|\n rows_index = row - 1\n rows[rows_index] = []\n rows[rows_index] += (client_data_headers_rpt.length >= row ? client_data_headers_rpt[rows_index] : ['',''])\n rows[rows_index] += (invoice_headers_rpt.length >= row ? invoice_headers_rpt[rows_index] : ['',''])\n end\n\n if rows.present?\n pdf.table(rows, {\n :position => :center,\n :cell_style => {:border_width => 0},\n :width => pdf.bounds.width\n }) do\n columns([0, 2]).font_style = :bold\n\n end\n\n pdf.move_down 10\n\n end\n \n pdf \n end",
"def create_header(my_name)\n # TODO: This profile should provide more information based on the\n # person's name, age, and gender\n puts \"<h1>#{my_name}</h1>\"\nend",
"def write_header() \n @builder.head do\n @builder.title('OmniFocus OPML Export')\n @builder.dateCreated(Time.now.httpdate)\n @builder.dateModified(Time.now.httpdate)\n# TODO @builder.ownerName(\"\")\n# TODO @builder.ownerEmail('example@example.com')\n end\n end",
"def generate_header(array)\n header_array = array.dup\n header_array.unshift('')\n end",
"def generate_header_row\n generate_row(@header)\n end",
"def generate_header_row\n generate_row(@header)\n end",
"def build_pdf_header4(pdf)\n pdf.font \"Helvetica\" , :size => 8\n\n $lcCli = @company.name \n $lcdir1 = @company.address1+@company.address2+@company.city+@company.state\n\n $lcFecha1= Date.today.strftime(\"%d/%m/%Y\").to_s\n $lcHora = Time.now.to_s\n pdf.text \"FORMATO 13.1: REGISTRO DE INVENTARIO PERMANENTE VALORIZADO - DETALLE DEL INVENTARIO VALORIZADO \"\n pdf.text \"PERIODO : \" +@fecha1.to_s+ \" Hasta: \"+@fecha2.to_s , :size => 11 \n pdf.text \"RUC : 20555691263 \" \n pdf.text \"APELLIDOS Y NOMBRES, DENOMINACION O RAZON SOCIAL : GRUPO E & E S.A.C. \"\n pdf.text \"ESTABLECIMIENTO : ALMACEN\"\n\n pdf \n end",
"def build_pdf_header_rpt(pdf)\n pdf.font \"Helvetica\" , :size => 8\n\n $lcFecha1= Time.zone.now.strftime(\"%d/%m/%Y\").to_s\n $lcHora = Time.now.to_s\n\n max_rows = [client_data_headers_rpt.length, invoice_headers_rpt.length, 0].max\n rows = []\n (1..max_rows).each do |row|\n rows_index = row - 1\n rows[rows_index] = []\n rows[rows_index] += (client_data_headers_rpt.length >= row ? client_data_headers_rpt[rows_index] : ['',''])\n rows[rows_index] += (invoice_headers_rpt.length >= row ? invoice_headers_rpt[rows_index] : ['',''])\n end\n\n if rows.present?\n\n pdf.table(rows, {\n :position => :center,\n :cell_style => {:border_width => 0},\n :width => pdf.bounds.width\n }) do\n columns([0, 2]).font_style = :bold\n\n end\n\n pdf.move_down 10\n\n end\n \n pdf \n end",
"def textfileHeader\n raw_header = labels.inject(\"\") { |header, l| header + \" \" + l.text}\n header = \"Classes: \" + raw_header\n end",
"def write_headers(source_doc, output_file)\n items = [\"---\"]\n items << \"layout: #{@options[:layout]}\"\n items << \"title: \\\"#{source_doc.at_css(\"title\").text}\\\"\"\n items << \"description: \\\"#{source_doc.at_css(\"excerpt|encoded\", namespaces).text}\\\"\"\n items << \"date: #{source_doc.at_css(\"pubDate\").text}\"\n items << \"comments: #{@options[:comments]}\"\n items << \"author: #{@options[:author]}\"\n items << \"categories: [#{source_doc.css(\"category[domain='tag']\").collect { |n| n.text }.join(\",\")}]\"\n items << \"---\"\n output_file.write(\"#{items.join(\"\\r\\n\")}\\r\\n\\r\\n\") \n end",
"def get_header() \n erb :header\n end",
"def template(reporttype, reportname, authorlist, emaillist, group, address,\n revdate, revnumber, docdate, description, legal, encoding, toc)\n \n sampledoc = <<-TEMPLATE\n:reporttype: #{reporttype || 'The type of report'}\n:reporttitle: #{reportname || 'The name of the report'}\n:author: #{authorlist || 'Author McList, Authorette OName'}\n:email: #{emaillist || 'someone@somehost.com, someoneelse@anotherhost.net'}\n:group: #{group || 'Marketing? Research? Edit me...'}\n:address: #{address || 'Company Address....'}\n:revdate: #{revdate || 'January 1, 2012'}\n:revnumber: #{revnumber || '0.0.1'}\n:docdate: #{docdate || 'January 1, 2012'}\n:description: #{description || 'Barebones Sample Document'}\n:legal: #{legal || '(C) Copyrighted by who?'}\n:encoding: #{encoding || 'iso-8859-1'}\n:toc: #{toc || 'true'}\n\n<<<\n== Introduction ==\nHi This is an introduction!\nTEMPLATE\n return sampledoc\n end",
"def header\n header = \"%FDF-1.2\\n\\n1 0 obj\\n<<\\n/FDF << /Fields 2 0 R\"\n # /F\n header << \"/F (#{options[:file]})\" if options[:file]\n # /UF\n header << \"/UF (#{options[:ufile]})\" if options[:ufile]\n # /ID\n header << \"/ID[\" << options[:id].join << \"]\" if options[:id]\n header << \">>\\n>>\\nendobj\\n2 0 obj\\n[\"\n return header\n end",
"def make_header_row(column_elements)\n\t\"<tr style=\\\"background-color: #808080;\\\"><td style=\\\"#{CENTER};\\\"><span style=\\\"#{WHITE};\\\"><strong>\n\t\t#{column_elements.join(\"</strong></span></td><td style=\\\"#{CENTER};\\\"><span style=\\\"#{WHITE};\\\"><strong>\")}\n\t\t</strong></span></td></tr>\"\nend",
"def header=(_arg0); end",
"def build_header\n header = [\n :county,\n :vtdname,\n :vtd,\n :fips,\n :area,\n :population,\n :id,\n :geosha,\n :fuzzy_boundary\n ]\n legend.dig(\"races\", \"elections\").each do |election_id, election_name|\n election = Election.find_by(name: election_name)\n election.offices.each do |office|\n race = \"#{election_name} #{office}\"\n header << \"#{race} District\" if office =~ /House|Senate/\n header << headers_for_race(race)\n end\n end\n header.flatten\n end",
"def header(text, header_level)\n\t\t\"h#{header_level}. #{text}\\n\"\n\tend",
"def generate_header(title, path = nil)\n version = Version::VERSION\n\n vars = {\n 'title' => escape_html(title),\n 'favicon' => escape_html(asset_url('favicon.ico')),\n 'style' => escape_html(asset_url('sabredav.css')),\n 'iconstyle' => escape_html(asset_url('openiconic/open-iconic.css')),\n 'logo' => escape_html(asset_url('sabredav.png')),\n 'baseUrl' => @server.base_uri\n }\n\n html = <<HTML\n<!DOCTYPE html>\n<html>\n<head>\n <title>#{vars['title']} - tilia/dav #{version}</title>\n <link rel=\"shortcut icon\" href=\"#{vars['favicon']}\" type=\"image/vnd.microsoft.icon\" />\n <link rel=\"stylesheet\" href=\"#{vars['style']}\" type=\"text/css\" />\n <link rel=\"stylesheet\" href=\"#{vars['iconstyle']}\" type=\"text/css\" />\n</head>\n<body>\n <header>\n <div class=\"logo\">\n <a href=\"#{vars['baseUrl']}\"><img src=\"#{vars['logo']}\" alt=\"tilia/dav\" /> #{vars['title']}</a>\n </div>\n </header>\n <nav>\nHTML\n\n # If the path is empty, there's no parent.\n if !path.blank?\n parent_uri = Http::UrlUtil.split_path(path).first\n full_path = @server.base_uri + Http::UrlUtil.encode_path(parent_uri)\n html << \"<a href=\\\"#{full_path}\\\" class=\\\"btn\\\">⇤ Go to parent</a>\"\n else\n html << '<span class=\"btn disabled\">⇤ Go to parent</span>'\n end\n\n html << ' <a href=\"?sabreAction=plugins\" class=\"btn\"><span class=\"oi\" data-glyph=\"puzzle-piece\"></span> Plugins</a>'\n html << '</nav>'\n\n html\n end",
"def render_latex_header(opts = {})\n opts[:title] ||= \"Questionnaire\"\n s = \"\\\\documentclass[10pt,a4paper, titlepage]{article}\\n\" +\n \"\\\\usepackage[utf8]{inputenc}\\n\" +\n \"\\\\usepackage[german]{babel}\\n\" +\n \"\\\\usepackage{amsmath}\\n\" +\n \"\\\\usepackage{amsfonts}\\n\" +\n \"\\\\usepackage{amssymb}\\n\" +\n \"\\\\usepackage{makeidx}\\n\" +\n \"\\\\usepackage{graphicx}\\n\" +\n \"\\\\usepackage{lmodern}\\n\" +\n \"\\\\usepackage{booktabs}\\n\" +\n \"\\\\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}\\n\"\n s += \"\\\\author{#{l opts[:author]}}\\n\" if opts[:author]\n s += \"\\\\title{#{l opts[:title]}}\\n\" if opts[:title]\n s += \"\\\\date{#{l opts[:date]}}\\n\" if opts[:date]\n s += \"\\\\begin{document}\\n\" +\n \"\\\\maketitle\\n\" +\n \"\\\\tableofcontents\\n\" +\n \"\\\\clearpage\\n\"\n s\n end",
"def toc_ncx_template(escaped_title, uuid, chapter_nav)\n%(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<ncx xmlns=\"http://www.daisy.org/z3986/2005/ncx/\" version=\"2005-1\">\n <head>\n <meta name=\"dtb:uid\" content=\"urn:uuid:#{uuid}\"/>\n <meta name=\"dtb:depth\" content=\"2\"/>\n <meta name=\"dtb:totalPageCount\" content=\"0\"/>\n <meta name=\"dtb:maxPageNumber\" content=\"0\"/>\n </head>\n <docTitle>\n <text>#{escaped_title}</text>\n </docTitle>\n <navMap>\n #{chapter_nav.join(\"\\n\")}\n </navMap>\n</ncx>\n)\n end",
"def info_header_fname\n \"_#{name.downcase}_info.html.erb\"\n end",
"def email_update_header\n col = 18\n hdr = \"------------------------------------------------------------------------\\n\" +\n 'Design : '.rjust(col) + self.oi_instruction.design.directory_name + \"\\n\" +\n 'Category : '.rjust(col) + self.oi_instruction.oi_category_section.oi_category.name + \"\\n\" +\n 'Step : '.rjust(col) + self.oi_instruction.oi_category_section.name + \"\\n\" +\n 'Team Lead : '.rjust(col) + self.oi_instruction.user.name + \"\\n\" +\n 'Designer : '.rjust(col) + self.user.name + \"\\n\" +\n 'Date Assigned : '.rjust(col) + self.created_on.format_dd_mon_yy('timestamp') + \"\\n\" +\n 'Complete : '.rjust(col)\n if self.complete?\n hdr += \"Yes\\n\" +\n 'Completed On : '.rjust(col) + self.completed_on.format_dd_mon_yy('timestamp') + \"\\n\"\n else\n hdr += \"No\\n\"\n end\n\n if self.oi_instruction.oi_category_section.urls.size > 0\n label = true\n self.oi_instruction.oi_category_section.urls.each do |url|\n \n if label\n hdr += 'References : '.rjust(col)\n label = false\n else\n hdr += ' : '.rjust(col)\n end\n \n if url[:text] != ''\n hdr += url[:text] + \"\\n\" + ' : '.rjust(col) + url[:url] + \"\\n\"\n else\n hdr += url[:url] + \"\\n\"\n end\n \n end\n end\n\n hdr += \"------------------------------------------------------------------------\\n\"\n\n \n hdr\n \n end",
"def render_header( notification )\n\t\ttemplate = self.load_template( HEADER_TEMPLATE )\n\t\treturn template.result( binding() )\n\tend",
"def build_pdf_header_rpt2(pdf)\n pdf.font \"Helvetica\" , :size => 8\n $lcCli = @company.name \n $lcdir1 = @company.address1+@company.address2+@company.city+@company.state\n\n $lcFecha1= Date.today.strftime(\"%d/%m/%Y\").to_s\n $lcHora = Time.now.to_s\n\n max_rows = [client_data_headers_rpt.length, invoice_headers_rpt.length, 0].max\n rows = []\n (1..max_rows).each do |row|\n rows_index = row - 1\n rows[rows_index] = []\n rows[rows_index] += (client_data_headers_rpt.length >= row ? client_data_headers_rpt[rows_index] : ['',''])\n rows[rows_index] += (invoice_headers_rpt.length >= row ? invoice_headers_rpt[rows_index] : ['',''])\n end\n\n if rows.present?\n\n pdf.table(rows, {\n :position => :center,\n :cell_style => {:border_width => 0},\n :width => pdf.bounds.width\n }) do\n columns([0, 2]).font_style = :bold\n\n end\n\n pdf.move_down 10\n\n end\n\n\n \n pdf \n end",
"def headers(spec)\n {\n :charge => charge,\n :parent_ion_mass => spec.parent_ion_mass(charge),\n :title => \"#{spec.sequence.gsub(/\\s+/, \"\")} (#{series.join(', ')})\"\n }\n end",
"def to_doxy_header\n r = @remark.dup\n # Change the remark init for Doxygen\n r[0] = \"/*!\"\n r.insert(1,\"@defgroup #{@filename} #{@style} #{@filename}\")\n if @style == :emboss\n r = removeDoubleAt(r)\n end\n\n buf = r.join(\"\\n\")+\"\\n\"\n buf\n end",
"def compute_header_text_latex(header_text, header_footer_rules_present, language_code_3_chars)\n if header_footer_rules_present\n # italic, small caps and large font\n t = emulate_small_caps(\n escape_latex_text(header_text),\n @options[:font_name],\n %w[bold italic]\n )\n \"\\\\textscale{#{ 0.909091 }}{\\\\textbf{\\\\textit{#{ t }}}}\"\n else\n # regular, all caps and small font\n r = \"\\\\textscale{#{ 0.7 }}{#{ escape_latex_text(header_text).unicode_upcase }}\"\n if 'chn' == language_code_3_chars\n r = \"\\\\textbf{#{ r }}\"\n end\n r\n end\n end",
"def big_header(string)\n outstring = \"$ *********************************************************\\n$ ** **\\n$ ** #{string} \\n$ ** **\\n$ *********************************************************\\n\"\n return outstring\n end",
"def header_style(header); end",
"def generate_header_info\n magic = FileMagic.new\n @header_info = magic.file(@file_name)\n magic.close\n\n @header_info\n end",
"def interchange_control_header\n empty_str = ''\n isa_elements = []\n isa_elements << 'ISA'\n isa_elements << '00'\n isa_elements << trim(empty_str,10)\n isa_elements << '00'\n isa_elements << trim(empty_str,10)\n isa_elements << 'ZZ'\n isa_elements << trim(payer_id, 15)\n isa_elements << 'ZZ'\n if facility.name.upcase == \"SOLUTIONS 4 MDS\"\n static_value = \"4108\"\n isa_08 = trim(static_value,15)\n else\n if @facility_config.details[:payee_name] && !@facility_config.details[:payee_name].blank?\n isa_08 = trim(@facility_config.details[:payee_name].upcase,15)\n else\n isa_08 = trim(facility.name.upcase, 15)\n end\n end\n isa_elements << isa_08\n isa_elements << Time.now().strftime(\"%y%m%d\")\n isa_elements << Time.now().strftime(\"%H%M\")\n isa_elements << ((!@output_version || @output_version == '4010') ? 'U' : '^')\n isa_elements << ((!@output_version || @output_version == '4010') ? '00401' : '00501')\n isa_elements << (@isa_record.isa_number.to_s.rjust(9, '0') if @isa_record)\n isa_elements << '0'\n isa_elements << 'P'\n isa_elements << ':'\n isa_elements.join(@element_seperator)\n end",
"def header(level = 1, txt)\n enclose(\"h#{level}\", txt)\n end",
"def get_ordered_headers\n headers = get_headers\n template_headers = get_template_headers\n ordered_headers = ['druid', 'sourceId']\n # Select only headers with values somewhere in the data\n template_headers.each {|th| ordered_headers << th if headers.include?(th)}\n ordered_headers\n end",
"def create_template(test_info)\n File.open(test_info.template_file_path, 'w') do |file|\n case\n when test_info.file_stem == :nothing\n file.puts 'This file includes nothing.'\n else\n # Inspect, in case it's a symbol, and remove double quotes after inspection.\n treatment_for_include = test_info.treatment.inspect.gsub('\"','')\n include_line = \"@[#{treatment_for_include}](#{test_info.include_file_path})\"\n file.puts(include_line)\n end\n end\n end",
"def render_header\n return content_tag(\"div\",(content_tag(\"h1\",@header)))\n end",
"def header_tags(*args, &proc)\n content_for(:header_tags, *args, &proc)\n end",
"def deal_template_1(_param=nil, _template='')\n\t\tsip_header = _param['sip_header']\n\t\tvalue = _param['value']\n\t\tvalue_class = _param['value_class']\n\t\tvalue_process = ValueProcess.new(value);\n\t\tvalue_res = value_process.transValue\n\t\tif _template[/\\{\\?#{sip_header}\\?.*?\\}/]!=nil\n\t\t\t_template[/\\{\\?#{sip_header}\\?.*?\\}/] = value_res\n\t\tend\n\t\t# p _template\n\t\t_template\n\tend",
"def header(fileName)\n string = <<-eos\n//===----------------------------------------------------------------------===//\n//\n// This source file is part of the Swift Logging API open source project\n//\n// Copyright (c) 2018-2019 Apple Inc. and the Swift Logging API project authors\n// Licensed under Apache License v2.0\n//\n// See LICENSE.txt for license information\n// See CONTRIBUTORS.txt for the list of Swift Logging API project authors\n//\n// SPDX-License-Identifier: Apache-2.0\n//\n//===----------------------------------------------------------------------===//\n//\n// <FileName>\n//\nimport XCTest\n\n///\n/// NOTE: This file was generated by generate_linux_tests.rb\n///\n/// Do NOT edit this file directly as it will be regenerated automatically when needed.\n///\n eos\n\n string\n .sub('<FileName>', File.basename(fileName))\n .sub('<Date>', Time.now.to_s)\nend",
"def build_header\n system \"gdal_translate -of GTiff -a_srs EPSG:4326 #{@processed_path} #{@processed_path}_\"\n FileUtils.rm(@processed_path)\n FileUtils.mv(\"#{@processed_path}_\", @processed_path)\n end",
"def create_html_header(diff_file)\n diff_file.puts %{<!DOCTYPE html>}\n diff_file.puts %{<html>}\n diff_file.puts %{<head>}\n diff_file.puts %{<meta charset=\"utf-8\" />}\n diff_file.puts %{<title></title>}\n diff_file.puts %{</head>}\n diff_file.puts %{<body>}\n end",
"def to_prawn_header(header)\n size = { 1 => 16, 2 => 12 }[header.level]\n @pdf.text header.children.join(\"\\n\"), :size => size, :style => :bold\n @pdf.text ' '\n end",
"def GenElementHeader(tx, ty, tdir)\n tscale = GetCnt('refdessize')\n desc = AskStr('desc')\n if (name = AskStr('name')) == ''\n name = $ElementName\n end\n PcbElementHeader(\"\", desc, name, \"\", 0, 0, tx, ty, tdir, tscale, \"\")\nend",
"def header(args = {}, &block)\n build_base_component :header, args, &block\n end",
"def template_name; end",
"def template_name; end",
"def make_head( title='', filename=\"#{ENV['TM_FILEPATH']}\", styles=Array.new, head_adds='' )\n tm_extra_head = \"\"\n styles.each do |style|\n tm_extra_head << \"<link rel=\\\"stylesheet\\\" href=\\\"file://\"+style+\"\\\" type=\\\"text/css\\\" charset=\\\"utf-8\\\" media=\\\"screen\\\">\\n\"\n end\n tm_extra_head += head_adds\n# html_header(title, filename, tm_extra_head)\n puts html_head(:title => title, :sub_title =>filename, :html_head => tm_extra_head)\n end",
"def template_name=(_arg0); end",
"def template_name=(_arg0); end",
"def transform_headers( str, rs )\n\t\t\t@log.debug \" Transforming headers\"\n\n\t\t\t# Setext-style headers:\n\t\t\t#\t Header 1\n\t\t\t#\t ========\n\t\t\t#\n\t\t\t#\t Header 2\n\t\t\t#\t --------\n\t\t\t#\n\n\t\t\tsection_numbers = [nil, nil, nil, nil, nil]\n\n\t\t\tstr.\n\t\t\t\tgsub( HeaderRegexp ) {|m|\n\t\t\t\t\tif $1 then\n\t\t\t\t\t\t@log.debug \"Found setext-style header\"\n\t\t\t\t\t\ttitle, id, hdrchar = $1, $2, $3\n\n\t\t\t\t\t\tcase hdrchar\n\t\t\t\t\t\twhen '='\n\t\t\t\t\t\t\tlevel = 1\n\t\t\t\t\t\twhen '-'\n\t\t\t\t\t\t\tlevel = 2\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\t@log.debug \"Found ATX-style header\"\n\t\t\t\t\t\thdrchars, title, id = $4, $5, $6\n\t\t\t\t\t\tlevel = hdrchars.length\n\n\t\t\t\t\t\tif level >= 7 then\n\t\t\t\t\t\t\trs.warnings << \"illegal header level - h#{level} ('#' symbols are too many)\"\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\n\t\t\t\t\tprefix = ''\n\t\t\t\t\tif rs.numbering? then\n\t\t\t\t\t\tif level >= rs.numbering_start_level and level <= 6 then\n\t\t\t\t\t\t\tdepth = level - rs.numbering_start_level\n\n\t\t\t\t\t\t\tsection_numbers.each_index do |i|\n\t\t\t\t\t\t\t\tif i == depth and section_numbers[depth] then\n\t\t\t\t\t\t\t\t\t# increment a deepest number if current header's level equals last header's\n\t\t\t\t\t\t\t\t\tsection_numbers[i] += 1\n\t\t\t\t\t\t\t\telsif i <= depth then\n\t\t\t\t\t\t\t\t\t# set default number if nil\n\t\t\t\t\t\t\t\t\tsection_numbers[i] ||= 1\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t# clear discardeds\n\t\t\t\t\t\t\t\t\tsection_numbers[i] = nil\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\tno = ''\n\t\t\t\t\t\t\t(0..depth).each do |i|\n\t\t\t\t\t\t\t\tno << \"#{section_numbers[i]}.\"\n\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\tprefix = \"#{no} \"\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\n\t\t\t\t\ttitle_html = apply_span_transforms( title, rs )\n\n\t\t\t\t\tunless id then\n\t\t\t\t\t\tcase rs.header_id_type\n\t\t\t\t\t\twhen HeaderIDType::ESCAPE\n\t\t\t\t\t\t\tid = escape_to_header_id(title_html)\n\t\t\t\t\t\t\tif rs.headers.find{|h| h.id == id} then\n\t\t\t\t\t\t\t\trs.warnings << \"header id collision - #{id}\"\n\t\t\t\t\t\t\t\tid = \"bfheader-#{Digest::MD5.hexdigest(title)}\"\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tid = \"bfheader-#{Digest::MD5.hexdigest(title)}\"\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\n\t\t\t\t\ttitle = \"#{prefix}#{title}\"\n\t\t\t\t\ttitle_html = \"#{prefix}#{title_html}\"\n\n\n\t\t\t\t\tunless id =~ IdRegexp then\n\t\t\t\t\t\trs.warnings << \"illegal header id - #{id} (legal chars: [a-zA-Z0-9_-.] | 1st: [a-zA-Z])\"\n\t\t\t\t\tend\n\n\t\t\t\t\tif rs.block_transform_depth == 1 then\n\t\t\t\t\t\trs.headers << RenderState::Header.new(id, level, title, title_html)\n\t\t\t\t\tend\n\n\t\t\t\t\tif @use_header_id then\n\t\t\t\t\t\t%{<h%d id=\"%s\">%s</h%d>\\n\\n} % [ level, id, title_html, level ]\n\t\t\t\t\telse\n\t\t\t\t\t\t%{<h%d>%s</h%d>\\n\\n} % [ level, title_html, level ]\n\t\t\t\t\tend\n\t\t\t\t}\n\t\tend",
"def create_header\n @sheet.row(0).concat @header_row\n end"
] |
[
"0.7156262",
"0.67640334",
"0.67077214",
"0.6619542",
"0.6611294",
"0.64873326",
"0.6458695",
"0.6441575",
"0.64270765",
"0.64014536",
"0.6365368",
"0.6335823",
"0.63165736",
"0.62995416",
"0.62925225",
"0.62826335",
"0.62714285",
"0.62425524",
"0.6222881",
"0.61947244",
"0.61712635",
"0.61700374",
"0.6144712",
"0.61422735",
"0.6135286",
"0.61320066",
"0.61288303",
"0.6123194",
"0.6089532",
"0.6081851",
"0.6047429",
"0.6041773",
"0.6039165",
"0.6036302",
"0.60193163",
"0.6019054",
"0.60171634",
"0.6016611",
"0.6012696",
"0.6004337",
"0.6004337",
"0.59992564",
"0.5998645",
"0.5982041",
"0.5975215",
"0.5963206",
"0.59609807",
"0.59609807",
"0.595566",
"0.59385866",
"0.5933873",
"0.5924492",
"0.5922623",
"0.5886222",
"0.58782023",
"0.58782023",
"0.58663017",
"0.5865773",
"0.586383",
"0.58455724",
"0.58452547",
"0.58299124",
"0.58260125",
"0.581536",
"0.58143055",
"0.5812084",
"0.5810478",
"0.58061284",
"0.5803355",
"0.57928836",
"0.5771406",
"0.5768438",
"0.57555485",
"0.575521",
"0.5754517",
"0.574354",
"0.57312655",
"0.57301927",
"0.5718375",
"0.57111573",
"0.5708664",
"0.57063454",
"0.57056063",
"0.57024217",
"0.5684429",
"0.567056",
"0.5660713",
"0.56555176",
"0.56537116",
"0.5649124",
"0.56455976",
"0.56365794",
"0.5633366",
"0.563299",
"0.563299",
"0.56229657",
"0.5619681",
"0.5619681",
"0.5609207",
"0.56078196"
] |
0.73268914
|
0
|
builds up a template file with given informations
|
def buildup_template_file(basename, header, hash)
type = hash[:type] || :script
filename = filename_for(basename, type)
if File.exist? filename
exit 0 unless prompt("* '#{filename}' already exists, overwrite it? (y/n): ") =~ /^y$/i
end
File.open(filename, "w") {|file|
file << "#!/usr/bin/env ruby"
file << "\n"
file << "# coding: #{get_encoding}"
file << "\n" * 2
file << get_commented_text(header)
file << "\n" * 2
case type
when :script
file << TEMPLATE_SCRIPT
when :test
file << TEMPLATE_TEST_UNIT
when :rspec
file << TEMPLATE_RSPEC
end
file.chmod SCRIPT_MOD
puts "* Successfully generated: #{filename}"
}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def template_for(file); end",
"def templates_for(file); end",
"def build template\n erb = File.read(File.join(VIEWS_DIR, template + \".erb\"))\n content = ERB.new(erb).result(binding)\n File.open(template, 'w') do |f|\n f.write content.gsub(/\\n\\n\\n+/, \"\\n\\n\")\n end\n end",
"def generate\n Zip::File.open(@template_path) do |template_zip|\n buffer = Zip::OutputStream.write_buffer do |out|\n template_zip.each do |entry|\n out.put_next_entry entry.name\n if @replaceable_files[entry.name]\n source = entry.get_input_stream.read.sub(/(<w:body>)(.*?)(<w:sectPr)/, \"\\\\1#{@replaceable_files[entry.name]}\\\\3\")\n out.write(source)\n else\n out.write(template_zip.read(entry.name))\n end\n end\n end\n buffer.string\n end\n end",
"def generate\n template = Template.new\n template.add('timestamp', Time.now.to_s)\n template.add('lib_dir', @lib_dir)\n template.add('bin_dir', @bin_dir)\n template.parse(TEMPLATE)\n end",
"def create_template(test_info)\n File.open(test_info.template_file_path, 'w') do |file|\n case\n when test_info.file_stem == :nothing\n file.puts 'This file includes nothing.'\n else\n # Inspect, in case it's a symbol, and remove double quotes after inspection.\n treatment_for_include = test_info.treatment.inspect.gsub('\"','')\n include_line = \"@[#{treatment_for_include}](#{test_info.include_file_path})\"\n file.puts(include_line)\n end\n end\n end",
"def generate template, file\n if file.kind_of? String then # one file\n write_template(file, ERB.new(load_template(template)).result(binding))\n else # multiple files\n file.each do |f|\n write_template(f, ERB.new(load_template(template)).result(binding))\n end\n end\n end",
"def generate_template(datestamp, entrytext, starred, uuid)\n ERB.new <<-XMLTEMPLATE\n <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n <plist version=\"1.0\">\n <dict>\n <key>Creation Date</key>\n <date><%= datestamp %></date>\n <key>Entry Text</key>\n <string><%= entrytext %></string>\n <key>Starred</key>\n <<%= starred %>/>\n <key>Tags</key>\n <array>\n <string>daily logs</string>\n </array>\n <key>UUID</key>\n <string><%= uuid %></string>\n </dict>\n </plist>\n XMLTEMPLATE\n end",
"def generate_from_templates\r\n %w{package.json _config.yml}.each do |file|\r\n template file\r\n end\r\n end",
"def build(attrs=nil, filename=nil)\n attrs.each_pair do |key, value|\n send(\"#{key}=\", value)\n end if attrs\n \n @template.filename = filename\n @template.result(binding)\n @_erbout\n end",
"def create_from_task_template\n File.open(file_path, 'w') do |f|\n f.puts build_task_template\n end\n end",
"def convert_template!\n tag! \"template\" do\n convert_s! \"name?\"\n if @version >= 119\n convert_id!\n end\n\n convert_array! \"subtemplates\" do\n convert_subtemplate!\n end\n\n convert_array! \"children\" do\n convert_uientry_gen2!\n end\n\n out_ofs! \"end of template?\"\n end\n end",
"def build\n dir = Dir::pwd + \"/\" + @modname\n if FileTest::directory?(dir)\n abort @options[:modulename] + \" directory already exists.\"\n end\n\n Dir::mkdir(dir)\n @pattern.manitemplates.each do |m|\n target = File.open(dir + \"/\" + m, 'a')\n File.open(@pattern.templatedir + \"/\" + m, 'r').each_line do |s|\n # Write in new parameters on appropriate lines if there are any\n if s.match(/#\\$PARAM/)\n if @options[:parameters]\n @options[:parameters].each do |p|\n temp = s.gsub(/PARAM/, p)\n temp.gsub!(/MODNAME/, @modname)\n temp.sub!(/#/, \"\")\n target.write temp\n end\n else\n ## Does not write template line if no params\n next\n end\n else\n # Otherwise just make sure the module name is correct\n target.write s.gsub(/MODNAME/, @modname)\n end\n end\n target.close\n end\n rescue Errno::EEXIST\n abort @options[:modulename] + \" directory already exists.\"\n end",
"def get_template(file) #this is our template, defined as a single string\n s = \"\"\n File.open(file) do |f|\n f.each_line do |line|\n s.concat(line)\n end\n end\n s\nend",
"def generate_project_file\n template_file = @template_dir + 'hhp_file.hhp.rhtml'\n\n @values = { :title => @options.title, :opname => @outputdir.basename }\n \n static_files = ['index.html', 'classindex.html', 'fileindex.html']\n @values[:html_files] = static_files + (@generated_files+@classes).map{|f| f.path}.uniq\n \n out_file = @outputdir + @project_name\n debug_msg \" rendering #{out_file}\"\n render_template template_file, out_file do |io| binding end\n end",
"def template(reporttype, reportname, authorlist, emaillist, group, address,\n revdate, revnumber, docdate, description, legal, encoding, toc)\n \n sampledoc = <<-TEMPLATE\n:reporttype: #{reporttype || 'The type of report'}\n:reporttitle: #{reportname || 'The name of the report'}\n:author: #{authorlist || 'Author McList, Authorette OName'}\n:email: #{emaillist || 'someone@somehost.com, someoneelse@anotherhost.net'}\n:group: #{group || 'Marketing? Research? Edit me...'}\n:address: #{address || 'Company Address....'}\n:revdate: #{revdate || 'January 1, 2012'}\n:revnumber: #{revnumber || '0.0.1'}\n:docdate: #{docdate || 'January 1, 2012'}\n:description: #{description || 'Barebones Sample Document'}\n:legal: #{legal || '(C) Copyrighted by who?'}\n:encoding: #{encoding || 'iso-8859-1'}\n:toc: #{toc || 'true'}\n\n<<<\n== Introduction ==\nHi This is an introduction!\nTEMPLATE\n return sampledoc\n end",
"def build_task_template\n b = binding\n ERB.new(Woro::TaskHelper.read_template_file).result(b)\n end",
"def generate(file_name,template,map, overwrite = true)\r\n # make sure the package folder exists\r\n pkg_path = (map['package'] || '').gsub('.','/') \r\n FileUtils.makedirs \"#{target}/#{pkg_path}\"\r\n File.open(\"#{target}/#{pkg_path}/#{file_name}\",'w') do |f|\r\n f << self.process_template(template,map)\r\n log \">> writing #{f.path}\"\r\n end #file\r\n end",
"def templated_build(name, opts={})\r\n short = name.downcase\r\n source = File.join(\"wrappers\", short)\r\n dependencies = [\"mustache.js\"] + Dir.glob(\"#{source}/*.tpl.*\")\r\n target_js = opts[:location] ? \"mustache.js\" : \"#{short}.mustache.js\"\r\n\r\n CLEAN.include(opts[:location] ? opts[:location] : target_js)\r\n\r\n desc \"Package for #{name}\"\r\n task short.to_sym => dependencies do\r\n puts \"Packaging for #{name}\"\r\n\r\n mkdir_p opts[:location] if opts[:location]\r\n\r\n files = [\r\n \"#{source}/mustache.js.pre\",\r\n 'mustache.js',\r\n \"#{source}/mustache.js.post\"\r\n ]\r\n\r\n open(\"#{opts[:location] || '.'}/#{target_js}\", 'w') do |f|\r\n files.each {|file| f << File.read(file) }\r\n end\r\n\r\n puts \"Done, see #{opts[:location] || '.'}/#{target_js}\"\r\n end\r\nend",
"def generate(page_setup = {})\n Zip::File.open(@template_path) do |template_zip|\n buffer = Zip::OutputStream.write_buffer do |out|\n template_zip.each do |entry|\n out.put_next_entry entry.name\n if @replaceable_files[entry.name] && entry.name == Document.doc_xml_file\n source = entry.get_input_stream.read\n # the source has only 1 sectPr and we change the doc dimensions based on the page setup\n source = replace_dimensions(source, page_setup)\n # Change only the body of document. TODO: Improve this...\n source = source.sub(/(<w:body>)((.|\\n)*?)(<w:sectPr)/, \"\\\\1#{@replaceable_files[entry.name]}\\\\4\")\n out.write(source)\n elsif @replaceable_files[entry.name] && entry.name == Document.header_xml_file\n source = entry.get_input_stream.read\n # Change only the body of document. TODO: Improve this...\n\n Rails.logger.info(\"header before:#{source}\")\n source = source.sub(/<w:tbl>.*<\\/w:tbl>/, \"#{@replaceable_files[entry.name]}\")\n Rails.logger.info(\"header after:#{source}\")\n\n out.write(source)\n # elsif @replaceable_files[entry.name] && entry.name == Document.footer_xml_file\n # source = entry.get_input_stream.read\n # Change only the body of document. TODO: Improve this...\n # Rails.logger.info(\"footer before:#{source}\")\n # source = source.sub(/<w:tbl>.*<\\/w:tbl>/, \"#{@replaceable_files[entry.name]}\")\n # Rails.logger.info(\"footer after:#{source}\")\n # out.write(source)\n\n elsif @replaceable_files[entry.name]\n out.write(@replaceable_files[entry.name])\n Rails.logger.info(\"footer: #{entry.get_input_stream.read}\") if entry.name == Document.footer_xml_file\n elsif entry.name == Document.content_types_xml_file\n raw_file = entry.get_input_stream.read\n content_types = @image_files.empty? ? raw_file : inject_image_content_types(raw_file)\n\n out.write(content_types)\n else\n out.write(template_zip.read(entry.name))\n end\n end\n unless @image_files.empty?\n #stream the image files into the media folder using open-uri\n @image_files.each do |hash|\n out.put_next_entry(\"word/media/#{hash[:filename]}\")\n URI.open(hash[:url], 'rb') do |f|\n out.write(f.read)\n end\n end\n end\n # add the header rels as its not already in the template docx\n out.put_next_entry(Document.header_relations_xml_file)\n out.write(@replaceable_files[Document.header_relations_xml_file])\n # add the footer rels as its not already in the template docx\n out.put_next_entry(Document.footer_relations_xml_file)\n out.write(@replaceable_files[Document.footer_relations_xml_file])\n\n # test creating for the blank header and footer to see if it fixes the error on open\n #\n # out.put_next_entry('word/_rels/header2.xml.rels')\n # out.write(@replaceable_files[Document.header_relations_xml_file])\n # add the footer rels as its not already in the template docx\n # out.put_next_entry('word/_rels/footer2.xml.rels')\n # out.write(@replaceable_files[Document.footer_relations_xml_file])\n\n end\n buffer.string\n end\n end",
"def template(name); end",
"def templated_build(name, opts={})\n short = name.downcase\n source = File.join(\"wrappers\", short)\n dependencies = [\"mustache.js\"] + Dir.glob(\"#{source}/*.tpl.*\")\n target_js = opts[:location] ? \"mustache.js\" : \"#{short}.mustache.js\"\n\n CLEAN.include(opts[:location] ? opts[:location] : target_js)\n\n desc \"Package for #{name}\"\n task short.to_sym => dependencies do\n puts \"Packaging for #{name}\"\n\n mkdir_p opts[:location] if opts[:location]\n\n files = [\n \"#{source}/mustache.js.pre\",\n 'mustache.js',\n \"#{source}/mustache.js.post\"\n ]\n\n open(\"#{opts[:location] || '.'}/#{target_js}\", 'w') do |f|\n files.each {|file| f << File.read(file) }\n end\n\n puts \"Done, see #{opts[:location] || '.'}/#{target_js}\"\n end\nend",
"def customizeTemplate( \n _displayFormat = \"points\" # specify the type {values, points}\n )\n\n template = File.read(@filename)\n\n\n template.sub!('*****DETAIL*****', @dailyActivity.to_s)\n template.sub!('*****BADGES*****', [].to_s) # empty for now.\n template.sub!('*****FORMAT*****', \"\\\"#{_displayFormat}\\\"\")\n\n template.sub!('*****TOTAL*****', @dailyTotals.to_s)\n template.sub!('*****TARGET*****', @goalTarget.to_s)\n template.sub!('*****START*****', \"\\\"#{@startDate}\\\"\")\n template.sub!('*****END*****', \"\\\"#{@endDate}\\\"\")\n template.sub!('*****NAME*****', \"\\\"#{@name}\\\"\")\n\n return template\n end",
"def create_html_file(filename, template, data)\n File.open(filename, \"w+:utf-8\") do |file|\n file << ERB.new(File.read(template)).result(data.to_binding)\n end\n end",
"def generate\n\t\t\t\tbegin\n\t\t\t\t\ttemplate = @template\n\t\t\t\t\ttemplate_manager = @template_manager\n\n\t\t\t\t\tt = template_manager.find_template_by_name(template)\n\t\t\t\t\tt = t.class.new\n\n\t\t\t\t\tif t.template_info[:renderer] == \"CSV\"\n\t\t\t\t\t\tRisu::Renderers::CSVRenderer.generate(@output_file) do |output|\n\t\t\t\t\t\t\tt = template_manager.find_template_by_name(template)\n\t\t\t\t\t\t\tt = t.class.new\n\t\t\t\t\t\t\tt.output = output\n\t\t\t\t\t\t\tt.render(output) unless t == nil\n\t\t\t\t\t\tend\n\t\t\t\t\telsif t.template_info[:renderer] == \"PDF\"\n\t\t\t\t\t\tPrawn::Document.generate(@output_file, :margin => [75, 50, 75, 50]) do |output|\n\t\t\t\t\t\t\toutput.font_size 10\n\t\t\t\t\t\t\tt = template_manager.find_template_by_name(template)\n\t\t\t\t\t\t\tt = t.class.new\n\t\t\t\t\t\t\tt.output = output\n\t\t\t\t\t\t\tt.render(output) unless t == nil\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\trescue => e\n\t\t\t\t\traise unless Rails.env.production?\n\t\t\t\t\tputs \"Templater Error: #{e.message} \\n #{e.backtrace.join(\"\\n\\t\")}\\n\"\n\t\t\t\tend\n\t\t\tend",
"def build_from_template(template, data = {}, layout = true)\n cont = File.read(template_file(template)).miga_variables(data)\n return cont unless layout\n\n build_from_template(\n 'layout.html',\n data.merge(content: cont, project_name: cli.load_project.name),\n false\n )\n end",
"def template!(path, full_paths = T.unsafe(nil)); end",
"def build_test_template( design_template, file )\n Rails.logger.info 'design_template_test_helper - build_test_template()'\\\n + ' design_template: ' + design_template.to_s\n\n orig_path = design_template.original_file.path.to_s\n Rails.logger.info 'design_template_test_helper - build_test_template()'\\\n + ' orig_path: ' + orig_path\n\n make_output_folder( design_template )\n FileUtils.cp( file.path.to_s, orig_path )\n end",
"def template(*path); end",
"def template(name)\n File.join TemplatePath, \"#{name}.rb\"\nend",
"def view_template(source, *args, &block)\n config = args.last.is_a?(Hash) ? args.pop : {}\n destination = args.first || source.sub(/\\.tt$/, '')\n \n source = File.expand_path(source.to_s)\n context = instance_eval('binding')\n \n create_file destination, nil, config do\n content = ERB.new(::File.binread(source), nil, '-', '@output_buffer').result(context)\n content = block.call(content) if block\n content\n end\n end",
"def template(from, to)\n erb = File.read(File.expand_path(\"../templates/#{from}\", __FILE__))\n put ERB.new(erb).result(binding), to\nend",
"def template(from, to)\n erb = File.read(File.expand_path(\"../templates/#{from}\", __FILE__))\n put ERB.new(erb).result(binding), to\nend",
"def build_with_template\n options[:message] = options[:message].to_s.strip_heredoc.rstrip\n template.call options\n end",
"def create\n file = Tempfile.new(\"onetemplate-#{resource[:name]}\")\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.TEMPLATE do\n xml.NAME resource[:name]\n xml.MEMORY resource[:memory]\n xml.CPU resource[:cpu]\n xml.VCPU resource[:vcpu]\n xml.DESCRIPTION do\n resource[:description]\n end if resource[:description]\n xml.OS do\n resource[:os].each do |k, v|\n xml.send(k.upcase, v)\n end\n end if resource[:os]\n resource[:disks].each do |disk|\n xml.DISK do\n disk.each do |k, v|\n xml.send(k.upcase, v)\n end\n end\n end if resource[:disks]\n resource[:nics].each do |nic|\n xml.NIC do\n nic.each do |k, v|\n xml.send(k.upcase, v)\n end\n end\n end if resource[:nics]\n xml.GRAPHICS do\n resource[:graphics].each do |k, v|\n xml.send(k.upcase, v)\n end\n end if resource[:graphics]\n xml.FEATURES do\n resource[:features].each do |k, v|\n xml.send(k.upcase, v)\n end\n end if resource[:features]\n xml.CONTEXT do\n resource[:context].each do |k, v|\n xml.send(k.upcase, v)\n end\n end if resource[:context]\n end\n end\n tempfile = builder.to_xml\n file.write(tempfile)\n file.close\n self.debug \"Creating template using #{tempfile}\"\n onetemplate('create', file.path)\n file.delete\n @property_hash[:ensure] = :present\n end",
"def generate_template()\n\n file_name = @hostname + '.tf'\n check_file_exists(file_name)\n template_path = determine_role()\n\n template = File.read(template_path)\n renderer = ERB.new(template, nil, '-')\n open(file_name, 'w') { |f|\n \tf.puts renderer.result(self.get_binding)\n f.close\n }\n\n end",
"def template(name, params: {})\n source_file = template_path(name)\n header_for(source_file, params.fetch(:header, true)) +\n ERB.new(File.read(source_file), trim_mode: '<>').result(binding).strip +\n \"\\n\"\n end",
"def create_display_template_file(directory)\n html = %{<!-- Template File -->\\n\n<div class=\"myWidget\">Hello World</div>}\n\n File.open(directory, \"w\") do |f|\n f.write(html)\n end\n end",
"def template; end",
"def template; end",
"def template; end",
"def template; end",
"def template; end",
"def template; end",
"def template; end",
"def assemble_template body_file\n body = body_file.read\n return body if body =~ /<html/\n\n head_file = @template_dir + '_head.rhtml'\n footer_file = @template_dir + '_footer.rhtml'\n\n <<-TEMPLATE\n<!DOCTYPE html>\n\n<html>\n<head>\n#{head_file.read}\n\n#{body}\n\n#{footer_file.read}\n TEMPLATE\n end",
"def file(name, template_name=nil, params=nil)\n @fileutils.touch(name)\n @file.open(name, 'w') do |f|\n f.puts write_contents(@templates.fetch(template_name), params) \n end unless template_name.nil? \n @output.write(\"created #{name}\")\n end",
"def build_template(template_path)\n # FIXME: this is called every time build_template is called.\n # although this is idepodent, it's got room for optimization\n self.build_components!\n\n ERB.new( File.open( template_path ).read, nil, '<>' ).result(self.binding)\n end",
"def generate_file_files\n setup\n\n page_file = @template_dir + 'page.rhtml'\n fileinfo_file = @template_dir + 'fileinfo.rhtml'\n\n # for legacy templates\n filepage_file = @template_dir + 'filepage.rhtml' unless\n page_file.exist? or fileinfo_file.exist?\n\n return unless\n page_file.exist? or fileinfo_file.exist? or filepage_file.exist?\n\n debug_msg \"Generating file documentation in #{@outputdir}\"\n\n out_file = nil\n current = nil\n\n @files.each do |file|\n current = file\n\n if file.text? and page_file.exist? then\n generate_page file\n next\n end\n\n template_file = nil\n out_file = @outputdir + file.path\n debug_msg \" working on %s (%s)\" % [file.full_name, out_file]\n rel_prefix = @outputdir.relative_path_from out_file.dirname\n search_index_rel_prefix = rel_prefix\n search_index_rel_prefix += @asset_rel_path if @file_output\n\n asset_rel_prefix = rel_prefix + @asset_rel_path\n\n unless filepage_file then\n if file.text? then\n next unless page_file.exist?\n template_file = page_file\n @title = file.page_name\n else\n next unless fileinfo_file.exist?\n template_file = fileinfo_file\n @title = \"File: #{file.base_name}\"\n end\n end\n\n @title += \" - #{@options.title}\"\n template_file ||= filepage_file\n\n render_template template_file, out_file do |io|\n here = binding\n # suppress 1.9.3 warning\n here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)\n here.local_variable_set(:current, current)\n here\n end\n end\n rescue => e\n error =\n RDoc::Error.new \"error generating #{out_file}: #{e.message} (#{e.class})\"\n error.set_backtrace e.backtrace\n\n raise error\n end",
"def build_template_xml(template_json, name = nil, plain = nil)\n template_json ||= \"\"\n plain ||= @plain\n plain = plain.to_json if plain && !(plain.is_a? String)\n\n text = \"<TEMPLATE>\"\n\n text << \"<NAME>#{name}</NAME>\" if name\n text << \"<PLAIN><![CDATA[#{plain}]]></PLAIN>\" if plain\n\n text << \"<#{template_tag}>\"\n text << \"<![CDATA[#{template_json}]]>\"\n text << \"</#{template_tag}>\"\n\n text << \"</TEMPLATE>\"\n\n text\n end",
"def determine_template(options); end",
"def template(from, to)\n erb = File.read(from)\n put ERB.new(erb).result(binding), to\nend",
"def template\n @template ||= Template.new name: script_name, out_file: root_ruby_file, type: type\n end",
"def install_template(file_parts, dest, subs = {})\n content = String.new\n file_parts.each do |file_part|\n full_path = File.join(File.dirname(__FILE__), file_part)\n begin\n content += File.open(full_path).read\n rescue\n end\n end\n subs.keys.each do |k|\n content.gsub!(/#{k}/, subs[k])\n end\n File.open(dest, 'w') {|file| file.write(content)}\n end",
"def build()\n \n #check dir exists, if not, make it\n if(!File.exists?(@path))\n Dir.mkdir(@path)\n end\n \n #build directory structure\n puts 'Building directory structure'\n build_skeleton(@template.directory_structure)\n \n #execute build tasks\n puts 'Running build tasks'\n execute_tasks(@template.tasks,@template.path)\n \n puts 'Skeleton built'\n \n end",
"def compile_templates(production)\n dir = File.join(@proj_dir, @dynamic_folder)\n \n Dir[File.join(dir, '**/*')].each do |path|\n if File.file?(path) && !File.basename(path).match(/^(\\.|_)/)\n path = path[ (dir.size + 1)..-1 ]\n ext = File.extname(path)\n new_ext = ext_from_handler(ext) \n name = File.basename(path, ext)\n \n if production == true && \"#{name}.#{new_ext}\" != 'index.html' && new_ext == 'html'\n new_file = File.join(@output_folder, path.sub(/(\\/?[\\w-]+)\\.[\\w-]+$/, \"\\\\1/index.#{new_ext}\"))\n else\n new_file = File.join(@output_folder, path.sub(/\\.[\\w-]+$/, \".#{new_ext}\")) \n end\n \n create_dirs(new_file)\n File.open(new_file, 'w') {|f| f.write render(path) }\n puts \" - \\033[32mCreating\\033[0m '#{new_file}'\"\n end\n end\n end",
"def cli_execute_make_transform_scaffold\n File.open(File.dirname(__FILE__)+'/data/transform_template.rb.tmpl','r') do |f|\n body = f.readlines.join('')\n body.gsub!('%%timestamp%%',Time.now.strftime(\"%a, %d %b %Y\"));\n body.gsub!('%%app name%%',cli_program_name);\n STDOUT.syswrite body\n end\n end",
"def compile_templates\n dir = File.join(Frank.root, Frank.dynamic_folder)\n\n Dir[File.join(dir, '**{,/*/**}/*')].each do |path|\n if File.file?(path) && !File.basename(path).match(/^(\\.|_)/)\n path = path[ (dir.size + 1)..-1 ]\n ext = File.extname(path)\n new_ext = ext_from_handler(ext)\n name = File.basename(path, ext)\n\n # No suitable handler found\n if not new_ext.is_a? String\n next\n end\n\n if Frank.production? && \"#{name}.#{new_ext}\" != 'index.html' && new_ext == 'html'\n new_file = File.join(Frank.export.path, path.sub(/(\\/?[\\w-]+)\\.[\\w-]+$/, \"\\\\1/index.#{new_ext}\"))\n else\n new_file = File.join(Frank.export.path, path.sub(/\\.[\\w-]+$/, \".#{new_ext}\"))\n end\n\n create_dirs(new_file)\n File.open(new_file, 'w') {|f| f.write render(path) }\n puts \" - \\033[32mCreating\\033[0m '#{new_file}'\" unless Frank.silent_export?\n end\n end\n end",
"def build_page_from_template(filename, dir='OEBPS')\n template = load_template(\"#{filename}.haml\")\n Dir.chdir(File.join(working_dir, dir)) do\n File.open(filename, 'w') { |f| f.puts template.render(Object.new, :book => book) }\n end\n end",
"def setup_template_details\n template_extension = @template_path.scan(/\\.(\\w+)\\.?(.*)?/)[0][0]\n get_extension_and_name_from_file(@template_path).merge(\n template_extension: template_extension\n )\n end",
"def init\n File.open(TEMPLATABLE_FILE, 'w') { |f|f.puts TEMPLATABLE_TEMPLATE }\n end",
"def buildup_template_header(basename, hash)\n header = []\n type = hash[:type] || :script\n header << filename_for(basename, type)\n header << \"\"\n description = hash[:description] || \"no description\"\n header << teardown_to_oneline(description)\n header << \"\"\n date = hash[:date] || Time.now\n header << \"created on : %04d.%02d.%02d\" % [date.year, date.month, date.day]\n header << \"last update: %04d.%02d.%02d\" % [date.year, date.month, date.day]\n header << \"\"\n author = hash[:author] || AUTHOR_NAME\n header << teardown_to_oneline(\"by \" + author)\n return header.flatten\n end",
"def template(_template_name)\n \"This is a dummy template! <%= dummy %> \\n \"\\\n 'Here is a global value <%= dummy_global %>'\n end",
"def create_template\n\n add_breadcrumb \"Download Template\"\n\n # Figure out which approach was used to access this method\n file_content_type = nil\n # From the form. This is managed via a TemplateProxy class\n if params[:template_proxy].present?\n # Inflate the proxy\n template_proxy = TemplateProxy.new(params[:template_proxy])\n Rails.logger.debug template_proxy.inspect\n\n # See if an org was set, use the default otherwise\n if template_proxy.organization_id.blank?\n org = nil\n else\n o = Organization.find(template_proxy.organization_id)\n org = Organization.get_typed_organization(o)\n end\n\n # The form defines the FileContentType which identifies the builder to use\n file_content_type = FileContentType.find(template_proxy.file_content_type_id)\n # asset_types are an array of asset types\n\n elsif params[:targets].present?\n # The request came from the audit results page. We have a list of asset\n # object keys\n file_content_type = FileContentType.find(params[:file_content_type_id])\n assets = Rails.application.config.asset_base_class_name.constantize.operational.where(:object_key => params[:targets].split(','))\n org = nil\n end\n\n is_component = params[:is_component]\n fta_asset_class_id = params[:fta_asset_class_id]\n\n # Find out which builder is used to construct the template and create an instance\n builder = file_content_type.builder_name.constantize.new(:organization => org, :asset_class_name => template_proxy.try(:asset_class_name), :asset_seed_class_id => template_proxy.try(:asset_seed_class_id), :organization_list => @organization_list, :is_component => is_component, :fta_asset_class_id => fta_asset_class_id)\n\n # Generate the spreadsheet. This returns a StringIO that has been rewound\n if params[:targets].present?\n builder.assets = assets\n end\n stream = builder.build\n\n # Save the template to a temporary file and render a success/download view\n file = Tempfile.new ['template', '.tmp'], \"#{Rails.root}/tmp\"\n ObjectSpace.undefine_finalizer(file)\n #You can uncomment this line when debugging locally to prevent Tempfile from disappearing before download.\n @filepath = file.path\n @filename = \"#{org.present? ? org.short_name.downcase : 'MultiOrg'}_#{file_content_type.class_name.underscore}_#{Date.today}.xlsx\"\n begin\n file << stream.string\n rescue => ex\n Rails.logger.warn ex\n ensure\n file.close\n end\n # Ensure you're cleaning up appropriately...something wonky happened with\n # Tempfiles not disappearing during testing\n respond_to do |format|\n format.js\n format.html\n end\n\n end",
"def execute!\n config[:print_only] = true\n file = load_template_file\n\n output_content = parameter_scrub!(template_content(file))\n if config[:yaml]\n require \"yaml\"\n output_content = YAML.dump(output_content)\n else\n output_content = format_json(output_content)\n end\n\n if config[:write_to_file]\n unless File.directory?(File.dirname(config[:write_to_file]))\n run_action \"Creating parent directory\" do\n FileUtils.mkdir_p(File.dirname(config[:write_to_file]))\n nil\n end\n end\n run_action \"Writing template to file - #{config[:write_to_file]}\" do\n File.write(config[:write_to_file], output_content)\n nil\n end\n else\n ui.puts output_content\n end\n end",
"def template(filename)\n File.binread(File.join(__dir__, 'templates', filename))\n end",
"def build_docs\n object_map.each do |index, objects|\n objects.each do |object|\n template_context = {\n #:meta => Site\n index => object\n }\n content = converter.render(template_map[index], template_context)\n filename = converter.filename_for(object)\n write_output_file(filename, content)\n end\n end\n end",
"def generate name, file\n require 'erb'\n template = File.read(File.join(File.dirname(__FILE__), \"class_template.erb\"))\n erb = ERB.new(template)\n code = erb.result(binding)\n Dir.mkdir(@basedir) unless File.directory?(@basedir)\n file = File.join(@basedir, name + \".rb\")\n File.open(file, \"w+\") do |f|\n f.puts code\n end\n end",
"def outputFileCreationInfo(file)\n # Add the build information and header to the output file\n ccdd.writeToFileLn(file, \"# Created : \" + ccdd.getDateAndTime() + \"\\n# User : \" + ccdd.getUser() + \"\\n# Project : \" + ccdd.getProject() + \"\\n# Script : \" + ccdd.getScriptName())\n\n # Check if any table is associated with the script\n if ccdd.getTableNumRows() != 0\n ccdd.writeToFileLn(file, \" Table(s): \" + ccdd.getTableNames().sort.to_a.join(\",\\n \"))\n end\n \n # Check if any groups is associated with the script\n if ccdd.getAssociatedGroupNames().length != 0\n ccdd.writeToFileLn(file, \" Group(s): \" + ccdd.getAssociatedGroupNames().sort.to_a.join(\",\\n \"))\n end\n \n ccdd.writeToFileLn(file, \"\")\nend",
"def template(source, *args, &block)\n config = args.last.is_a?(Hash) ? args.pop : {}\n destination = args.first || source.sub(/#{TEMPLATE_EXTNAME}$/, \"\")\n\n source = File.expand_path(find_in_source_paths(source.to_s))\n context = config.delete(:context) || instance_eval(\"binding\")\n\n create_file destination, nil, config do\n content = CapturableERB.new(::File.binread(source), nil, \"-\", \"@output_buffer\").result(context)\n content = yield(content) if block\n content\n end\n end",
"def get_template(filename)\n File.read(filename)\nend",
"def build_view \n \n return if skip_method(__method__)\n \n # build edit _form index new show\n \n ['_form','edit','new','index','show'].each do |file|\n \n \n template = File.read(template(\"rails/views/#{file}.html.erb\"))\n \n # need to use ERB for these templates\n text = ERB.new(template, nil, '-').result(binding)\n\n filename = \"#{file}.html.erb\"\n # #puts \"build Rails view\"\n \n path = namespaced_path(\"app/views\",\"#{plural_table_name}/\"+filename)\n puts \"build Rails #{file} view for #{model_name} in #{path}\"\n write_artifact(path,text)\n \n end\n \n # build the json views\n ['index','show'].each do |file|\n \n template = File.read(template(\"rails/views/#{file}.json.jbuilder\"))\n text = ERB.new(template, nil, '-').result(binding)\n \n filename = \"#{file}.json.jbuilder\"\n # #puts \"build Rails JSON view \"\n \n path = namespaced_path(\"app/views\",\"#{plural_table_name}/\"+filename)\n puts \"build Rails #{file} JSON view for #{model_name} in #{path}\"\n write_artifact(path,text)\n \n end\n \n end",
"def template\n if @client ==\"ORBOGRAPH\" || @client == \"ORB TEST FACILITY\"\n IO.read(File.dirname(__FILE__) + '/templates/' + organization_name.downcase.gsub(' ','_') + '_'+@batch_type+'_template.xml.erb')\n else\n IO.read(File.dirname(__FILE__) + '/templates/' + organization_name.downcase.gsub(' ','_') + '_template.xml.erb')\n end\n end",
"def init\n File.open(ORENONO_FILE, 'w') { |f|f.puts ORENONO_TEMPLATE }\n end",
"def generate_report(filename, template)\n file = File.read(filename)\n data_hash = JSON.parse(file)\n rpt_data = transform(data_hash)\n\n # Re http://stackoverflow.com/questions/1887845/add-method-to-an-instanced-object\n d = TemplateSource.new(rpt_data)\n\n template = File.read(template) if File.exist?(template)\n renderer = ERB.new(template, nil, '<>')\n renderer.result(d.get_binding)\nend",
"def get_template(template); end",
"def template_for file, page = true, klass = ERB\n template = @template_cache[file]\n\n return template if template\n\n if page then\n template = assemble_template file\n erbout = 'io'\n else\n template = file.read\n template = template.encode @options.encoding\n\n file_var = File.basename(file).sub(/\\..*/, '')\n\n erbout = \"_erbout_#{file_var}\"\n end\n\n if RUBY_VERSION >= '2.6'\n template = klass.new template, trim_mode: '-', eoutvar: erbout\n else\n template = klass.new template, nil, '-', erbout\n end\n @template_cache[file] = template\n template\n end",
"def template(template_name = 'template.txt')\n File.read([File.dirname(__FILE__), template_name].join('/'))\n end",
"def templates; end",
"def create_def_file(tlm_def_filename, tlm_def_template_file)\n\n #\n # Create combo packet substitution strings \n #\n HkJsonDefFile::HK_COMBO_PKT_MID_STR.each do |combo_pkt|\n \n @hk_json_def_file.process_combo_pkt(combo_pkt) do |hk_combo_mid_str, src_data_array|\n \n src_data_array.each do |src_data|\n \n src_item = @hk_json_def_file.get_src_tlm_item(src_data) # Index: 0=MID, 1=Name, 2=Offset, 3=Size, 4=Data Type\n \n if (src_item[1] != nil and src_item[2] != 0 and src_item[3] != 0)\n @combo_pkt_str[combo_pkt] << \" APPEND_ITEM #{src_item[1]} #{src_item[3]*8} #{src_item[4]}\\n\" \n else\n raise IndexError.new(\"JSON definition file contains an ivalid entry #{src_item}\\n\")\n end\n \n end # src_data loop\n end # Combo pkt tlm item loop\n \n end # JSON combo pkt loop\n \n tlm_def_str = File.read(tlm_def_template_file)\n \n HkJsonDefFile::HK_COMBO_PKT_MID_STR.each do |combo_pkt|\n tlm_def_str = tlm_def_str.sub(\"@#{combo_pkt}@\",@combo_pkt_str[combo_pkt])\n end\n tlm_def_str = tlm_def_str.sub(\"@src-file@\",@hk_json_def_file.filename)\n \n File.open(tlm_def_filename, 'w') do |tlm_def_file|\n tlm_def_file << tlm_def_str.sub(\"@date-time@\",Time.now.to_s)\n end # tlm_def_file\n \n end",
"def generate(save = false)\n # Code to export into the manifest cache\n export = \"Sereth::TemplateManager::Manifest.register(:raw)\"\n\n Dir.glob(\"app/template/raw/**\") do |file| \n template = Parser.read(file)\n template.raw = file\n\n if save\n # Store the parsed template to server throuch a controller\n template.cache = \"app/template/cache/#{template.name}\"\n File.open(template.cache) do |cached_template|\n cached_template.print(template.code)\n end\n\n # Store the template metadata for serving cached data in production\n File.open(\"app/template/manifest.rb\", \"w\") do |manifest| \n manifest.puts(export % {raw: template.metadata})\n end\n end\n end\n end",
"def outputFileCreationInfo(file)\n # Add the build information and header to the output file\n ccdd.writeToFileLn(file, \"/* Created : \" + ccdd.getDateAndTime() + \"\\n User : \" + ccdd.getUser() + \"\\n Project : \" + ccdd.getProject() + \"\\n Script : \" + ccdd.getScriptName())\n\n # Check if any table is associated with the script\n if ccdd.getTableNumRows() != 0\n ccdd.writeToFileLn(file, \" Table(s): \" + ccdd.getTableNames().sort.to_a.join(\",\\n \"))\n end\n\n # Check if any group is associated with the script\n if ccdd.getAssociatedGroupNames().length != 0\n ccdd.writeToFileLn(file, \" Group(s): \" + ccdd.getAssociatedGroupNames().sort.to_a.join(\",\\n \"))\n end\n\n ccdd.writeToFileLn(file, \"*/\\n\")\nend",
"def build(name)\n output_path = File.join(__dir__, \"#{name}.yml\")\n File.write(output_path, GENERATED_BANNER + template(name, params: { header: false }))\n end",
"def template\n @template.join(\"\\n\")\n end",
"def template\n @template.join(\"\\n\")\n end",
"def outputFileCreationInfo(file)\n # Add the build information and header to the output file\n ccdd.writeToFileLn(file, \"/* Created : \" + ccdd.getDateAndTime() + \"\\n User : \" + ccdd.getUser() + \"\\n Project : \" + ccdd.getProject() + \"\\n Script : \" + ccdd.getScriptName())\n\n # Check if any table is associated with the script\n if ccdd.getTableNumRows() != 0\n ccdd.writeToFileLn(file, \" Table(s): \" + ccdd.getTableNames().sort.to_a.join(\",\\n \"))\n end\n\n # Check if any groups is associated with the script\n if ccdd.getAssociatedGroupNames().length != 0\n ccdd.writeToFileLn(file, \" Group(s): \" + ccdd.getAssociatedGroupNames().sort.to_a.join(\",\\n \"))\n end\n\n ccdd.writeToFileLn(file, \"*/\")\nend",
"def createtemplate\r\n\t\t chars_num = @secretword.length\r\n\t\t line = \"\"\r\n\t\t line_char = \"_\"\r\n\t\t while chars_num > 0 do\r\n\t\t \tline += line_char\r\n\t\t \tchars_num -= 1\r\n\t\t end\r\n\t\t templ = \"[#{line}]\"\r\n\t\t return templ\r\n\t\t end",
"def make_file(tpl_file, dst_file, options, data_files = [], options_processor = nil)\n all_options = make_options(options, data_files)\n options_processor.call(all_options) unless options_processor.nil?\n data = render_file(tpl_file, all_options)\n File.write dst_file, data\n end",
"def build(file_name)\n end",
"def create_source(name, destination)\n template = File.read(\"#{template_path(name)}/easy_type/templates/#{name}\")\n content = ERB.new(template, nil, '-').result(binding)\n write_file(destination, content)\n rescue SyntaxError\n fail \"Error in erb template #{name}\"\n end",
"def create_default_template_file\n unless self.description.redirection_required?\n self.localizations.each do |page_localization|\n file_path = File.join(Rails.root, \"app\", \"views\" , \"pages\" , \"#{self.view}.#{page_localization.locale.slug}.html.haml\" )\n unless File.exists?(file_path)\n file = File.new(file_path, \"w\")\n\n page_localization.contents.each do |content|\n file.puts(\"= @page.easy_contents(:#{content.section_name})\")\n end\n file.close\n end\n end\n end\n end",
"def export_to_template template, file\n renderer = ERB.new(File.read(template))\n output = renderer.result binding\n output_file = File.open file, 'w'\n output_file << output\n output_file.close\n end",
"def generateFile ( parent, node )\n # Usable node?\n atlas_node_id = node.attribute ( \"atlas_node_id\" )\n if ! atlas_node_id then # not a usable node\n return nil # prevent procedure-as-function-(ab)use\n end\n\n node_name = node.elements[\"node_name\"].text\n if ! node_name then # not a usable node\n return nil # prevent procedure-as-function-(ab)use\n end\n\n # Construct filename and try to open it for write.\n htmlFilePath = \"#{@outputDirectory}#{makeHtmlFileName(atlas_node_id)}\"\n begin\n File.open( htmlFilePath, \"w\" ) do | outFile |\n # Write template+substitutions.\n outFile.puts \"#{@template.part1}#{node_name}#{@template.part2}\"\n\n if parent then\n parent_atlas_node_id = parent.attributes[\"atlas_node_id\"]\n parent_node_name = parent.elements[\"node_name\"]\n if parent_atlas_node_id && parent_node_name then\n outFile.puts \"<p>Up to <a href=\\\"#{makeHtmlFileName(parent_atlas_node_id)}\\\">\"\n outFile.puts \"#{parent_node_name.text}</a></p>\"\n end\n end\n\n node.elements.each() {|child|\n child_atlas_node_id = child.attributes[\"atlas_node_id\"]\n child_node_name = child.elements[\"node_name\"]\n if child_atlas_node_id && child_node_name then\n outFile.puts \"<p><a href=\\\"#{makeHtmlFileName(child_atlas_node_id)}\\\">\"\n outFile.puts \"#{child_node_name.text}</a></p>\"\n end\n }\n\n outFile.puts \"#{@template.part3}#{node_name}#{@template.part4}\"\n outFile.puts \"#{@destinationsReader.getDestinationDescription(atlas_node_id)}\"\n outFile.puts @template.part5\n end\n rescue\n raise \"Failed to write html file #{htmlFilePath}\"\n end\n end",
"def create_document kwargs\n title = kwargs.fetch(:title, \"Untitled\")\n template_file = kwargs.fetch(:template_file, \"#{$TEMPLATES_DIRECTORY}/input/document.adoc.erb\")\n path = kwargs.fetch(:path, \"./\")\n template_file = Pathname.new template_file\n\n # Creating the directories of the path\n path = Pathname.new path\n FileUtils.mkpath(path)\n\n file_name = kebab_case title\n path += file_name + \".adoc\"\n\n begin\n template = File.read template_file\n rescue\n template = $DEFAULT_TEMPLATE\n end\n\n # Create a binding object with the current context.\n # All variables in this function will be included.\n b = binding\n erb = ERB.new template, :trim_mode => \"-\"\n output_file = File.new path.to_s, mode = \"w+\"\n output_file.write erb.result b\n\n path\nend",
"def generate!\n info \"GENERATE\"\n\n f = Generator.new @dbi, @settings, @logger\n xslt = XML::XSLT.new\n xslt.xml = f.generate_root.to_s\n\n default_template_dir = File.dirname(__FILE__) + '/../../data/templates'\n template_dir = @settings['templates'] || default_template_dir\n output_dir = @settings['output']\n\n task \"copy static files\" do\n FileUtils.mkdir_p output_dir\n FileUtils.cp_r Dir[File.join( template_dir, 'static', '*' )], output_dir\n end\n\n begin\n Dir.foreach(template_dir) { |template_file|\n next if template_file =~ /^\\./ || template_file == 'static'\n\n task \"process #{template_file}\" do\n xslt.xsl = File.join( template_dir, template_file )\n File::open( File.join( output_dir, template_file ), 'w') { |f| f.write(xslt.serve) }\n end\n }\n rescue Errno::ENOENT\n warn \"Couldn't find templates directory, fallback to default templates!\"\n template_dir = default_template_dir\n retry\n end\n end",
"def init\n File.open(WASHER_FILE, 'w') { |f|f.puts WASHER_TEMPLATE }\n end",
"def render_and_write_templates\n clean_build_dir()\n\n yard_file_hash = {}\n\n Dir.glob(\"#{Dir.pwd}/projects/*\").select { |f| File.directory? f }.each do|project_dir|\n yard_file = \"#{project_dir}/yard.yaml\"\n\n unless yard_file.empty?\n yard = YAML::load_file(yard_file)\n next if yard['disabled']\n\n apps = yard['apps']\n project_name = yard['project']['name']\n project_pipelines = yard['pipelines']\n\n Dir.mkdir \"#{BUILD_DIR}/#{project_name}\"\n puts project_name\n\n apps.each do |app_name, app_config|\n Dir.mkdir(\"#{BUILD_DIR}/#{project_name}/#{app_name}/\")\n app_pipelines = Hash.new({})\n\n project_pipelines.each do |pipeline|\n app_pipelines[pipeline['name']] = app_pipelines[pipeline['name']].merge(pipeline)\n end\n\n unless app_config.nil? || app_config['pipelines'].nil?\n app_config['pipelines'].each do |pipeline|\n app_pipelines[pipeline['name']] = app_pipelines[pipeline['name']].merge(pipeline)\n end\n end\n\n # puts app_pipelines\n\n base_files = Dir[\"#{Dir.pwd}/base/*\"]\n project_base_files = Dir[\"#{project_dir}/base/*\"]\n app_files = Dir[\"#{project_dir}/#{app_name}/*\"]\n\n app_pipelines.each do|pipeline_name, pipeline_config|\n template_name = pipeline_config['templateName'] ? pipeline_config['templateName'] : \"#{pipeline_name}.json\"\n\n app_files.each do|path|\n render_and_write(\n pipeline_config: pipeline_config,\n path: path,\n template_name: template_name,\n app_name: app_name,\n project_name: project_name,\n app_template_vars: app_config['template_vars']\n )\n end\n project_base_files.each do|path|\n render_and_write(\n pipeline_config: pipeline_config,\n path: path,\n template_name: template_name,\n app_name: app_name,\n project_name: project_name,\n app_template_vars: app_config['template_vars']\n )\n end\n\n base_files.each do|path|\n render_and_write(\n pipeline_config: pipeline_config,\n path: path,\n template_name: template_name,\n app_name: app_name,\n project_name: project_name,\n app_template_vars: app_config['template_vars']\n )\n end\n end\n end\n end\n end\n end",
"def relative_template(src, dialect, from=__FILE__)\n template = WLang::template(src, dialect)\n template.source_file = from\n template\n end",
"def create_file_config\n # template \"config/express_translate.yml\", \"config/express_translate.yml\"\n end",
"def write_template(template, target, config)\n\n File.write(\n\n target,\n ERB.new(File.read(template)).result(binding)\n )\nend"
] |
[
"0.74489474",
"0.7246953",
"0.7205909",
"0.7065472",
"0.70124274",
"0.6989121",
"0.6951624",
"0.6889279",
"0.68815917",
"0.67283964",
"0.6722969",
"0.6719903",
"0.66892743",
"0.6642551",
"0.65460753",
"0.6542569",
"0.6531263",
"0.6517955",
"0.65082335",
"0.6504285",
"0.6487996",
"0.6486349",
"0.64529115",
"0.6435238",
"0.6427705",
"0.6413442",
"0.64086807",
"0.6406901",
"0.63963073",
"0.6384703",
"0.637825",
"0.6343796",
"0.6343796",
"0.6335368",
"0.6330499",
"0.6310419",
"0.6298755",
"0.6295236",
"0.62734723",
"0.62734723",
"0.62734723",
"0.62734723",
"0.62734723",
"0.62734723",
"0.62734723",
"0.6267785",
"0.6253818",
"0.62480074",
"0.6234127",
"0.62323475",
"0.6229269",
"0.6223597",
"0.62180144",
"0.6190279",
"0.61881274",
"0.6180827",
"0.6160465",
"0.61461586",
"0.614117",
"0.6140855",
"0.61280054",
"0.6126968",
"0.61157113",
"0.61143136",
"0.6107072",
"0.61053526",
"0.61031073",
"0.6099043",
"0.60969204",
"0.60938317",
"0.60918903",
"0.60864156",
"0.6076934",
"0.60747856",
"0.60717124",
"0.6058604",
"0.60548055",
"0.6054098",
"0.60459936",
"0.60379106",
"0.6036663",
"0.60302955",
"0.6029411",
"0.60267496",
"0.60267496",
"0.60250324",
"0.60181355",
"0.601532",
"0.60141885",
"0.60007703",
"0.59921354",
"0.5990381",
"0.5977289",
"0.5976949",
"0.59744763",
"0.5965138",
"0.59612626",
"0.59612453",
"0.596097",
"0.5959684"
] |
0.70958006
|
3
|
TODO: this is silly, type should be the same
|
def global_entity
contained_object.to_global_id if contained_object.present?
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def nonregular_type; end",
"def type() end",
"def type(type); end",
"def types; end",
"def types; end",
"def types; end",
"def types; end",
"def types; end",
"def private; end",
"def subtype; end",
"def types(types); end",
"def types=(_arg0); end",
"def self_types; end",
"def self_types; end",
"def type_params; end",
"def type_params; end",
"def type_params; end",
"def type_params; end",
"def type_params; end",
"def type; super; end",
"def type\n\tend",
"def type\n\tend",
"def type_name; end",
"def type_name; end",
"def type_name; end",
"def type_name; end",
"def type_name; end",
"def type_name; end",
"def type_name; end",
"def type_name; end",
"def type_name; end",
"def type_name; end",
"def type_name; end",
"def type_name; end",
"def type_name; end",
"def type_name; end",
"def type_name; end"
] |
[
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70781285",
"0.7063725",
"0.6977664",
"0.6819596",
"0.6819596",
"0.6819596",
"0.6819596",
"0.6819596",
"0.67145914",
"0.6542315",
"0.6533749",
"0.6513493",
"0.64567155",
"0.64567155",
"0.644434",
"0.644434",
"0.644434",
"0.644434",
"0.644434",
"0.64315826",
"0.641968",
"0.641968",
"0.64122885",
"0.64122885",
"0.64122885",
"0.64122885",
"0.64122885",
"0.64122885",
"0.64122885",
"0.64122885",
"0.64122885",
"0.64122885",
"0.64122885",
"0.64122885",
"0.64122885",
"0.64122885",
"0.64122885"
] |
0.0
|
-1
|
If the contained_object is a CollectionObject, it must have a parent container reference
|
def contained_object_is_container_when_parent_id_is_blank
if parent_id.blank? && container_id.blank? && container.blank?
errors.add(:parent_id, 'can only be blank if object is a container') if contained_object_type != 'Container'
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def is_collection_object\n return self.resource_type == Resource::COLLECTION_OBJECT;\n end",
"def parent_contained_object_is_container\n unless parent_id.blank? && parent.nil?\n errors.add(:parent_id, \"can only be set if parent's contained object is a container\") if parent.contained_object_type != 'Container'\n end\n end",
"def is_collection?(obj)\n obj && data_object(obj).respond_to?(:map) && data_object(obj).respond_to?(:each) &&\n (KNOWN_OBJECT_CLASSES & obj.class.ancestors.map(&:name)).empty?\n end",
"def parent_collection?\n parent.collection?\n end",
"def collection?\n @object.is_a?(Enumerable) && !@object.is_a?(Struct)\n end",
"def is_collection?\n @is_collection\n end",
"def contain\n c = nil\n if contained_in.is_a?(Container)\n c = contained_in\n else\n c = Container.find(contained_in)\n end\n\n put_in_container(c)\n end",
"def subcollections\n respond_to?(:collectionHasSubcollection) ? collectionHasSubcollection : []\n end",
"def getParentCollection() \n return XMLDB::Base::Collection.getInstance(@obj.getParentCollection())\n end",
"def collection_is_parent(potential_parent_collection, collection)\n retval = false\n \n if (potential_parent_collection == nil or collection == nil)\n return false\n end\n \n #TODO: ancestry\n if collection.collection == potential_parent_collection\n retval = true\n end\n \n retval = (retval or collection_is_parent(potential_parent_collection, collection.collection))\n \n return retval\n end",
"def collection?\n NotImplemented\n end",
"def collection?\n NotImplemented\n end",
"def collection?\n raise NotImplementedError\n end",
"def inherit_collection(parent_collection)\n #collection is a sub-collection, parent has a project\n if (!parent_collection.projects.empty?)\n add_project_col(parent_collection.projects.first, @collection)\n #collection is a sub-collection, parent dose not have a project\n elsif (parent_collection.projects.empty?)\n @collection.projects.each do |project|\n @collection.projects.delete project\n \n @collection.descendants.each do |c|\n if !c.projects.empty?\n c.projects.delete project\n end\n end\n end\n end\n end",
"def child_collections\n members.select {|m| m.kind_of? CuratedCollection }\n end",
"def self_or_parent_collections\n if try(:parent).present?\n Wayfinder.for(parent).try(:collections)\n else\n try(:collections) || []\n end\n end",
"def collection? \n true\n end",
"def object_member_of\n @object_member_of ||= begin\n belongs_to = []\n # get all of work's collection ids from the form\n belongs_to += @object.member_of_collection_ids\n belongs_to << @object.admin_set_id if @object.admin_set_id.present?\n belongs_to\n end\n end",
"def object\n object? ? children[2] : nil\n end",
"def can_have_associated_objects?(obj)\n true\n end",
"def collection?\n true\n end",
"def collection? \n false\n end",
"def sub_object\n splits= @field.split('.')\n object_name = splits.first\n field_names = splits[1..-1] # all but the first\n return unless object_name && obj.respond_to?(object_name)\n object = obj.send(object_name)\n # Its a collection => invoice.items and access is done by ary index:\n # first item => [items.1.name]\n if object.nil?\n # empty relation\n @result.gsub!(@placeholder, '')\n elsif object.is_a?(Array) && ary_index = field_names.first[/\\A\\d*\\z/]\n field_names.delete_at(0) # remove entry from field_names ary\n # replace with empty string if the index does not exist or obj is empty\n @result.gsub!(@placeholder, '') unless object = object[ary_index.to_i-1]\n end\n\n # Recurse and let the referenced object do the expanding\n if object.respond_to?(:expand_placeholders)\n value = object.expand_placeholders(\"[#{field_names.join('.')}]\")\n @result.gsub!(@placeholder, value)\n end\n end",
"def collection?\n false\n end",
"def collection?\n false\n end",
"def collection?\n false\n end",
"def contained?\n !container.nil?\n end",
"def collection?\n false\n end",
"def contained_by?(kontainer)\n enclosing_containers.include?(kontainer)\n end",
"def involved_plan_object?(obj)\n super || obj == parent\n end",
"def cloneable?(ref)\n ref[:type] == :many_to_many || ref[:type] == :one_through_one\n end",
"def parents\n respond_to?(:collectionHasParent) ? collectionHasParent : []\n end",
"def content_collection_for(storable)\n subcontainer_positions if Container === storable\n end",
"def containment(container, contained)\n contained_in(container).each do |l|\n if l.to.to_sym == contained.to_sym\n return l\n end\n end\n return nil\n end",
"def cloneable?(ref)\n ref[:type] == :one_to_many || ref[:type] == :one_to_one\n end",
"def collection include_object_type=false, &block\n ASObj.generate :collection, !include_object_type, &block\n end",
"def children\n (items + collections)\n end",
"def is_collection_like\n return (self.is_collection || self.is_exhibition)\n end",
"def parent_exists!\n return if valid_mixin_parent?(params[:parent])\n render_error :not_found, 'Requested collection could not be found'\n end",
"def cloneable?(ref)\n ref[:type] == :many_through_many || ref[:type] == :one_through_many\n end",
"def is_a_child?(object)\n object.respond_to?(:parent) && object.parent\n end",
"def is_collection\n return self.resource_type == Resource::LEARNING_COLLECTION;\n end",
"def collection_class\n OneToMany::Collection\n end",
"def collection_class\n OneToMany::Collection\n end",
"def parent_assoc_type\n if src_obj.replicable_opts(:replicate_tree) && current_assoc == 'children'\n :tree\n elsif parent.class.reflect_on_association(current_assoc).collection?\n :collection\n else\n :singleton\n end\n end",
"def get_parent_object\n nil\n end",
"def collection_node; end",
"def collection_node; end",
"def collection\n self.class.collection\n end",
"def collection\n self.class.collection\n end",
"def collection?(x)\n self.class.collection?(qualified_name(x))\n end",
"def collection\n klass.collection\n end",
"def check_parent\n\n @pid = get_parent_id\n if not @pid\n error \"Can't determine parent object for pages.\"\n return\n end\n\n if @collections.size > 1\n error \"The #{pretty_class_name} #{@directory_name} belongs to more than one collection - there must be exactly one, a parent object.\"\n return\n end\n\n numFound, parent_model, parent_iid, parent_lang_code = Utils.get_metadata_from_object config, @pid\n\n if numFound == 0\n error \"The object #{@pid} specified in collection does not exist.\"\n return\n end\n\n if parent_model != @content_model\n error \"The parent object #{@pid} specified in collection has unexpected content model #{parent_model}. Please specify an object of content type #{@content_model}.\"\n return\n end\n\n if not @directory_name =~ /^#{parent_iid}$|^#{parent_iid}_[0-9]{8}_[0-9]{6}$/\n error \"The parent object #{@pid} specified in collection has IID identifier #{parent_iid} which does not match the identifier portion of package directory name #{@directory_name}.\"\n return\n end\n\n if @mods_languages.size == 0 && parent_lang_code.length > 0\n warning_message = Utils.langs_unsupported_comment(@config, parent_lang_code)\n if not warning_message.empty?\n warning \"Found unsupported OCR language in parent object metadata: #{warning_message}.\"\n warning \"Will use #{Utils.langs_to_names(@config, parent_lang_code)} for OCR.\"\n end\n\n @mods_languages << parent_lang_code\n end\n\n @page_sequence = Utils.get_next_page_sequence config, @pid, @manifest.content_model\n if not @page_sequence\n error \"There was an error retrieving information about the page sequence.\"\n return\n end\n\n return true\n rescue => exception\n oops exception\n end",
"def inside_association?\n # TODO: see if we can memoize\n self.respond_to?(:proxy_owner)\n end",
"def descended_from?( container )\n return true if self == container\n return false unless parent\n parent.descended_from? container\n end",
"def containers(opts={})\n is_member_array = is_member_of_collection(:response_format=>:id_array)\n \n if !is_member_array.empty?\n logger.warn \"This object has inbound collection member assertions. hasCollectionMember will no longer be used to track file_object relationships after active_fedora 1.3. Use isPartOf assertions in the RELS-EXT of child objects instead.\"\n if opts[:response_format] == :solr || opts[:response_format] == :load_from_solr\n logger.warn \":solr and :load_from_solr response formats for containers search only uses parts relationships (usage of hasCollectionMember is no longer supported)\"\n result = part_of(opts)\n else\n con_result = is_member_of_collection(opts)\n part_of_result = part_of(opts)\n ary = con_result+part_of_result\n result = ary.uniq\n end\n else\n result = part_of(opts)\n end\n return result\n end",
"def child_of?(parent); end",
"def objects_with_references\n end",
"def is_object()\n res = super(context,self)\n return res\n end",
"def convert_object(*object_or_attributes)\n if object_or_attributes.length == 0\n return @contained_class.new\n elsif object_or_attributes.length > 1\n return @contained_class.new(*object_or_attributes)\n else\n object_or_attributes = object_or_attributes.first\n end\n\n if object_or_attributes.is_a?(Hash)\n @contained_class.new(**object_or_attributes)\n\n else\n raise ArgumentError.new(\"Argument provided to Collection.add could not be converted to a #{@contained_class}\") unless object_or_attributes.is_a?(@contained_class)\n object_or_attributes\n end\n end",
"def subfield_x_object_type\n return { code: 'x', value: 'item' } if cocina_object.dro?\n\n { code: 'x', value: 'collection' } if cocina_object.collection?\n end",
"def collection_updated(object, result)\n key = object.key\n if result\n parent_add(key, object)\n object.subscribe(self)\n else\n object.unsubscribe(self)\n parent_delete(object)\n end\n end",
"def referenced_objects=(value)\n @referenced_objects = value\n end",
"def contained?(other); end",
"def contained?(other); end",
"def contained?(other); end",
"def scoped_collection(_parent_records)\n raise NotImplementedError.new 'override #scoped_collection in a subclass'\n end",
"def container(flag=nil)\n\t\talso_foreign = (flag==:also_foreign)\t\t\n\t\tif also_foreign && self.foreign_container\n\t\t\treturn self.foreign_container\n\t\telse\n\t\t\treturn self.eContainer\n\t\tend\n\tend",
"def only_collections?\n true\n end",
"def coerce(value)\n coerced = super\n return coerced unless coerced.respond_to?(:each_with_object)\n coerced.each_with_object(new_collection) do |entry, collection|\n coerce_and_append_member(collection, entry)\n end\n end",
"def collection\n klass.collection\n end",
"def user_must_be_collection_member\n if media_object_id.present? && media_object_exists?\n errors.add(:media_object_id, 'not found') unless Ability.new(user).is_member_of?(media_object.collection)\n end\n end",
"def member_of_collections_attributes\n # A ChildWork will never be a direct member of a Collection\n return if ['ChildWork', 'Page'].include?(metadata[\"Object Type\"]) || !metadata['Parent ARK']\n arks_array = metadata['Parent ARK'].split('|~|')\n collection = []\n\n arks_array.each_with_index do |current_ark, index|\n ark_string = Ark.ensure_prefix(current_ark.strip)\n collection[index] = Collection.find_or_create_by_ark(ark_string)\n\n unless collection[index].recalculate_size == false\n collection[index].recalculate_size = false\n collection[index].save\n end\n end\n\n collection_return = {}\n collection.each_with_index do |current_collection, index|\n collection_return[index] = { id: current_collection.id }\n end\n\n collection_return\n end",
"def update_from_parent(update)\n raise %{\n This method must be implemented in your data object\n class if you plan to pass updates from a\n parent object to the members of its\n collections.\n }\n end",
"def make_collection\n NotImplemented\n end",
"def make_collection\n NotImplemented\n end",
"def compare_sub_types(containing, contained, location)\r\n\r\n resolved_containing = data_for_pointer(containing, @containing_schema)\r\n resolved_contained = data_for_pointer(contained, @contained_schema)\r\n\r\n containing_schema = {\r\n 'definitions' => { 'foo' => resolved_containing},\r\n 'properties' => { 'bar' => { '$ref' => '#/definitions/foo' } }\r\n }\r\n comparator = self.class.new(containing_schema)\r\n comparator.schema_contains?(publish: resolved_containing, consume: resolved_contained)\r\n comparator.errors\r\n end",
"def superset_of?( other_collection )\n other.all? {|e| self.include? e }\n end",
"def assign_nested_attributes_for_collection(env, attributes_collection)\n return true unless attributes_collection\n\n attributes = extract_attributes(attributes_collection)\n cast_concern = !env.curation_concern.is_a?(Valkyrie::Resource)\n resource = cast_concern ? env.curation_concern.valkyrie_resource : env.curation_concern\n inserts, destroys = split_inserts_and_destroys(attributes, resource)\n\n # short circuit to avoid casting unnecessarily\n return true if destroys.empty? && inserts.empty?\n # we fail silently if we can't insert the object; this is for legacy\n # compatibility\n return true unless check_permissions(ability: env.current_ability,\n inserts: inserts,\n destroys: destroys)\n update_members(resource: resource, inserts: inserts, destroys: destroys)\n\n return true unless cast_concern\n env.curation_concern = Hyrax.metadata_adapter\n .resource_factory\n .from_resource(resource: resource)\n\n # # checking for existing works to avoid rewriting/loading works that are\n # # already attached\n # existing_works = env.curation_concern.member_ids\n # attributes_collection.each do |attributes|\n # next if attributes['id'].blank?\n # if existing_works.include?(attributes['id'])\n # remove( env, env.curation_concern, attributes['id']) if has_destroy_flag?(attributes)\n # else\n # add(env, attributes['id'])\n # end\n # end\n end",
"def primitive_is_complex?(primitive)\n return unless primitive_exists? primitive\n primitives[primitive].key? 'parent'\n end",
"def non_polymorphic_collection?(param0 = T.unsafe(nil)); end",
"def object\n if inside_association?\n proxy_owner\n else\n self\n end\n end",
"def update_child(item)\n backing_record = item.backing_record\n # HMT TODO: The following && !association.through_association was commented out, causing wrong class items to be added to\n # associations\n # Why was it commented out.\n if backing_record && @owner && @association && item.attributes[@association.inverse_of] != @owner && !@association.through_association?\n inverse_of = @association.inverse_of\n current_association_value = item.attributes[inverse_of]\n backing_record.virgin = false unless backing_record.data_loading?\n # next line was commented out and following line was active.\n backing_record.update_belongs_to(inverse_of, @owner)\n #backing_record.set_belongs_to_via_has_many(@association, @owner)\n # following is handled by update_belongs_to and is redundant\n # unless current_association_value.nil? # might be a dummy value which responds to nil\n # current_association = @association.inverse.inverse(current_association_value)\n # current_association_attribute = current_association.attribute\n # if current_association.collection? && current_association_value.attributes[current_association_attribute]\n # current_association.attributes[current_association_attribute].delete(item)\n # end\n # end\n @owner.backing_record.sync_has_many(@association.attribute)\n end\n end",
"def parent\n object.try(:loaded)&.[](:parents)&.first || wayfinder.decorated_parent\n end",
"def collection\n @collector.collection\n end",
"def lazy_set_parent_element_in_self( local_index, optional_object = nil, passed_optional_object = false )\n\n object = nil\n if @cascade_controller.requires_lookup?( local_index )\n\n parent_array = @cascade_controller.parent_array( local_index )\n parent_index = @cascade_controller.parent_index( local_index, parent_array )\n\n object = passed_optional_object ? optional_object : parent_array[ parent_index ]\n \n # We call hooks manually so that we can do a direct undecorated set.\n # This is because we already have an object we loaded as a place-holder that we are now updating.\n # So we don't want to sort/test uniqueness/etc. We just want to insert at the actual index.\n\n unless @without_child_hooks\n object = child_pre_set_hook( local_index, object, false, parent_array )\n if ::Array::Compositing::DoNotInherit === object\n delete_at( local_index )\n return lazy_set_parent_element_in_self( local_index, optional_object, passed_optional_object )\n end\n end\n \n object = pre_set_hook( local_index, object, false, 1 ) unless @without_hooks\n\n undecorated_set( local_index, object )\n\n @cascade_controller.looked_up!( local_index )\n \n post_set_hook( local_index, object, false ) unless @without_hooks\n child_post_set_hook( local_index, object, false, parent_array ) unless @without_child_hooks\n\n else\n\n object = undecorated_get( local_index )\n\n end\n \n return object\n \n end",
"def check_collection_loaded!\n raise \"Collection wasn't loaded?\" if @collection.is_a?(ActiveRecord::Relation) && !@collection.loaded?\n end",
"def ocollection\n @@_collection[self.class.name].name\n end",
"def present_collection(collection = resource); nil; end",
"def enclosing_collection_resources\n @enclosing_collection_resources ||= []\n end",
"def ===(other)\n other === collection\n end",
"def verify_parent_is_not_descendant\n unless self[tree_parent_id_field].nil?\n errors.add(:base, I18n.t(:cyclic, :scope => [:mongo_mapper, :errors, :messages, :tree])) if self.descendants.include?(parent)\n end\n end",
"def initialize\n @coll = self.class.collection\n end",
"def array_node?(node)\n node.attributes['type'] == 'collection'\n end",
"def test_collection?\n is_a?(Collection::TestCollection)\n end",
"def parent_association\n @parent_object=parent_object # ResourceController normally sets this\n if params[:id].nil?\n return parent_object.all_parent_relations \n end\n # Gotta find it seperately, will get a recursive stack error elsewise\n o = FeatureRelation.find(params[:id])\n parent_object.id == o.parent_node.id ? parent_object.all_child_relations : parent_object.all_parent_relations\n end",
"def identify(_collection)\n raise NotImplementedError\n end",
"def test_nested_collection_index_associated\n _distractor = Parent.create(name: 'p2', children: [Child.new(name: 'c3', position: 1)])\n\n childcontroller = ChildController.new(params: {\n owner_viewmodel: 'parent',\n association_name: 'children',\n parent_id: @parent.id\n })\n childcontroller.invoke(:index_associated)\n\n assert_equal(200, childcontroller.status)\n\n expected_children = @parent.children\n assert_equal({ 'data' => expected_children.map { |c| ChildView.new(c).serialize_to_hash } },\n childcontroller.hash_response)\n\n assert_all_hooks_nested_inside_parent_hook(childcontroller.hook_trace)\n end",
"def contained_by?(resource, container, catalog)\n container_of = catalog.container_of(resource)\n case container_of\n when nil\n false\n when container\n true\n else\n contained_by?(container_of, container, catalog)\n end\nend",
"def get_parent_collection()\n return XMLDBApi::RedCollection.new(@db_id, @coll_service.get_collection_id, @coll_service.get_collection_name)\n end"
] |
[
"0.6812132",
"0.6766822",
"0.6600402",
"0.65625894",
"0.65428454",
"0.6017317",
"0.5969113",
"0.5962249",
"0.5933265",
"0.5902437",
"0.58872885",
"0.58872885",
"0.5816135",
"0.58038753",
"0.57956773",
"0.57833385",
"0.5768248",
"0.5767724",
"0.5750612",
"0.57403684",
"0.5730928",
"0.56743205",
"0.5656804",
"0.563802",
"0.563802",
"0.563802",
"0.56292915",
"0.5628759",
"0.56044793",
"0.5596322",
"0.55499786",
"0.553198",
"0.55213374",
"0.548409",
"0.5482346",
"0.5472809",
"0.5467427",
"0.54662585",
"0.5454349",
"0.545396",
"0.5447342",
"0.54471195",
"0.54074347",
"0.54074347",
"0.5406444",
"0.5405882",
"0.5405641",
"0.5405641",
"0.5383811",
"0.5383811",
"0.5377469",
"0.53473884",
"0.53473073",
"0.5345152",
"0.5338338",
"0.532986",
"0.5328814",
"0.5316381",
"0.5309221",
"0.5306983",
"0.5294427",
"0.52941096",
"0.52877367",
"0.5285598",
"0.5285598",
"0.5285598",
"0.5274047",
"0.526776",
"0.5261892",
"0.5257995",
"0.52572083",
"0.5243366",
"0.52249813",
"0.5220025",
"0.5214622",
"0.5214622",
"0.52144974",
"0.51952994",
"0.5192316",
"0.5185191",
"0.51805484",
"0.51758295",
"0.5155785",
"0.51523066",
"0.51327294",
"0.51212144",
"0.50965804",
"0.50947547",
"0.50918204",
"0.5090801",
"0.5088186",
"0.50833166",
"0.50813925",
"0.50762373",
"0.5071529",
"0.50693375",
"0.5061894",
"0.50600535",
"0.5059881",
"0.5056604"
] |
0.6538655
|
5
|
parent_id links an object to a container through container_item
|
def parent_contained_object_is_container
unless parent_id.blank? && parent.nil?
errors.add(:parent_id, "can only be set if parent's contained object is a container") if parent.contained_object_type != 'Container'
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def parent_id\n object[\"parent_id\"]\n end",
"def parent_id\r\n return nil unless ar_object\r\n ar_object[ar_p]\r\n end",
"def container_parent\n parent_id = data.at_xpath(\"/c/did/container/@parent\")\n return unless parent_id\n parent = data.at_xpath(\"//c[@id='#{parent_id}']/did/container\")\n \"#{parent.attribute('type').value.capitalize} #{parent.content}\"\n end",
"def relist_parent_id\n item_hash.deep_find(:relist_parent_id)\n end",
"def set_container_item\n @container_item = ContainerItem.find(params[:id])\n end",
"def parent_id\n data[:parent_id]\n end",
"def _parent_id\n send parent_column_name\n end",
"def parent_id\n @values.fetch('ai.operation.parentId') { \n @values['ai.operation.parentId'] = nil\n }\n end",
"def _parent; end",
"def parent\n self.class.find_by_id(self.parent_id) unless self.parent_id.nil?\n end",
"def parent\n @parent\n end",
"def parent\n @parent\n end",
"def parent_id=(value)\n self[self.nested_set_options[:parent_column]] = value\n end",
"def set_parent_object\n if(@order_item.blank? || @order_item.new_record?)\n @parent = [@purchasable, :order_items]\n else\n unless(@order_item.order != nil && @order_item.order.type == 'Basket')\n @parent = find_order_item_parent(@order_item)\n else\n @parent = orders_basket_path\n end\n end\n end",
"def parent_id\n self[self.nested_set_options[:parent_column]]\n end",
"def set_parent_of\n @parent_of = ParentOf.find(params[:id])\n end",
"def parent\n @parent\n end",
"def parent\n @parent\n end",
"def parent\n @parent\n end",
"def parent\n @parent\n end",
"def parent(id)\n if id != @h[id]\n @h[id] = parent(@h[id])\n else\n id\n end\n end",
"def parent\n _parent\n end",
"def parent_object\n # hack by sean to allow permalink parents\n parent? && !parent_singleton? ? parent_model_find(parent_param) : nil\n end",
"def parent\n owner\n end",
"def parent=(obj); end",
"def set_parent\n @parent = Parent.find(params[:id])\n end",
"def set_parent\n @parent = Parent.find(params[:id])\n end",
"def set_parent\n @parent = Parent.find(params[:id])\n end",
"def set_parent\n @parent = Parent.find(params[:id])\n end",
"def set_parent\n @parent = Parent.find(params[:id])\n end",
"def set_parent\n @parent = Parent.find(params[:id])\n end",
"def find_creator_parent_item\n ModelReference.find_where_referenced_from(self).first&.from_record\n end",
"def parent=(value)\n @parent = value\n end",
"def parent_id\n self.parent._id.to_s\n end",
"def find_object_from_link(parent_object, id)\n find_object(parent_object, id)\n end",
"def parent\n tree.parent_for(parent_id).first\n end",
"def set_parent(parent)\n @parent = parent\n end",
"def parent=(newParent)\n return if newParent == @parent\n remove_item if @parent\n @parent = newParent\n @content.each_index do |pos|\n update_sortable(pos, @content[pos]) if @parent\n end\n end",
"def parent_link\n link = {}\n if collection_hierarchy.length > 1\n parent_name = collection_hierarchy[-2].class.name.downcase\n link[parent_name] = {\n href: @controller.polymorphic_url(collection_hierarchy[0..-2])\n }\n end\n link\n end",
"def parent_id\n self.tagvalues[\"is_a\"].first\n end",
"def parent_document\n pi = parent_item\n return if pi == nil\n pi_id = pi.id\n return if pi_id == nil\n DocumentRepository.find(pi_id)\n end",
"def parent_id=(value)\n if value == @defaults['ai.operation.parentId']\n @values.delete 'ai.operation.parentId' if @values.key? 'ai.operation.parentId'\n else\n @values['ai.operation.parentId'] = value\n end\n end",
"def parent_id=(value)\n if value == @defaults['ai.operation.parentId']\n @values.delete 'ai.operation.parentId' if @values.key? 'ai.operation.parentId'\n else\n @values['ai.operation.parentId'] = value\n end\n end",
"def parent_id(target = self)\n target[parent_column_name]\n end",
"def setup_child_parent_links\n # Clear all links\n @items.each do |item|\n item.parent = nil\n item.children = []\n end\n\n @items.each do |item|\n # Get parent\n parent_identifier = item.identifier.sub(/[^\\/]+\\/$/, '')\n parent = @items.find { |p| p.identifier == parent_identifier }\n next if parent.nil? or item.identifier == '/'\n\n # Link\n item.parent = parent\n parent.children << item\n end\n end",
"def setup_child_parent_links\n # Clear all links\n @items.each do |item|\n item.parent = nil\n item.children = []\n end\n\n @items.each do |item|\n # Get parent\n parent_identifier = item.identifier.sub(/[^\\/]+\\/$/, '')\n parent = @items.find { |p| p.identifier == parent_identifier }\n next if parent.nil? or item.identifier == '/'\n\n # Link\n item.parent = parent\n parent.children << item\n end\n end",
"def parent_object\n @parent_object ||= parent? && !parent_singleton? ? parent_model.find(parent_param) : nil\n end",
"def parent\n return @parent\n end",
"def parent; @options[:parent]; end",
"def parent=(parent)\n @parent = parent\n end",
"def parent=(parent)\n @parent = parent\n end",
"def parent\n end",
"def parent\n end",
"def parent\n end",
"def parent\n end",
"def get_parent_object\n nil\n end",
"def parent=(parent)\n @parent = parent\n end",
"def parent\n\t\tself.residue_at_position(@parent_position)\n\tend",
"def parent=(parent_node); end",
"def parent=(parent_node); end",
"def parent\n @parent || NullResource.new\n end",
"def parent(node_id)\n node_id >> 1 # node_id / 2\n end",
"def parent\n @parent ||= new_or_create? ? find_parent_by_id : lookup_parent_from_child\n end",
"def create_container_id(parent)\n if self.class.name == 'ContainedFile'\n \"#{parent}/files/#{noid_service.mint}\"\n else\n \"#{parent}/#{self.class.name.pluralize.downcase}/#{noid_service.mint}\"\n end\n end",
"def add_parent_object(parent, relation, info = nil)\n\t parent.add_child_object(self, relation, info)\n\tend",
"def show\n create_item\n @parent.add_item(self)\n end",
"def parent?(id)\n self.parent_id == id\n end",
"def set_parent(parent)\n @parent = parent\n end",
"def set_parent(parent)\n @parent = parent\n end",
"def id\n container.id\n end",
"def parent\n nil\n end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent\n o = Object.const_get(parent_model) rescue nil\n o && o.get(parent_id)\n end",
"def parent\n @parent ||= resource.decorate.parent\n end",
"def parent\n nil\n end",
"def parent_id\n parent_ids.last\n end",
"def set_parent\n @parent = Parent.find(session[:parent_id])\n end",
"def query_parent_id\n @attributes[:query_parent_id]\n end",
"def parent\n SideJob.find(SideJob.redis.get(\"#{redis_key}:parent\"))\n end",
"def parent_object\n if has_parent?\n actual_class = parent_class_name.camelize.constantize\n actual_class.find(parent_id)\n else\n nil\n end\n end",
"def parent\n self.class.find_in_nested_set(self[parent_col_name]) if self[parent_col_name]\n end",
"def parent\n dataset.nested.filter(self.primary_key => self.parent_id).first if self.parent_id\n end",
"def container_item_params\n params.require(:container_item).permit(:user_id, :parent_id, :name)\n end",
"def parent\n @parent ||= begin\n parent_id = data[\"parentId\"]\n client.categories.find(parent_id) if parent_id\n end\n end",
"def set_parent(parent)\n @parent = parent\n\n self\n end",
"def parent_list\n self.parent_lists[0]\n end",
"def set_parent_info\n @parent_info = ParentInfo.find(params[:id])\n end",
"def update_collection_parent\n old_parent = @collection.parent\n old_parent.delete_member_by_id(@collection.id)\n old_parent.save\n\n new_parent = find_new_parent\n new_parent.member_ids = [@collection.id] + new_parent.member_ids\n new_parent.save\n end",
"def extract_parent_object(params)\n @parent_object = SalesOrder.find_by_id(params[:sales_order_id])\n end"
] |
[
"0.7127039",
"0.675173",
"0.6740257",
"0.6707828",
"0.66208434",
"0.6599278",
"0.6541346",
"0.64778286",
"0.64744747",
"0.645836",
"0.64488983",
"0.64488983",
"0.64286",
"0.64271516",
"0.6420557",
"0.64191",
"0.6408357",
"0.6408357",
"0.6408357",
"0.6408357",
"0.6366782",
"0.63102674",
"0.6305718",
"0.62941426",
"0.62897605",
"0.6267855",
"0.6267855",
"0.6267855",
"0.6267855",
"0.6267855",
"0.6267855",
"0.625861",
"0.6231601",
"0.6230142",
"0.62289",
"0.6228558",
"0.6227685",
"0.6222798",
"0.62217754",
"0.6218896",
"0.6215534",
"0.6209465",
"0.6209465",
"0.62021875",
"0.6187072",
"0.6187072",
"0.61815715",
"0.616789",
"0.61557716",
"0.61541635",
"0.61541635",
"0.6138528",
"0.6138528",
"0.6138528",
"0.6138528",
"0.61252224",
"0.6115945",
"0.61133385",
"0.611225",
"0.611225",
"0.61049044",
"0.6096486",
"0.6085237",
"0.60819894",
"0.6062723",
"0.6060196",
"0.60513246",
"0.6047159",
"0.6047159",
"0.6045906",
"0.6045841",
"0.60438156",
"0.60438156",
"0.60438156",
"0.60438156",
"0.60438156",
"0.60438156",
"0.60438156",
"0.60438156",
"0.60438156",
"0.60438156",
"0.60438156",
"0.60438156",
"0.6042032",
"0.60301906",
"0.6022662",
"0.6017469",
"0.6016428",
"0.6010755",
"0.5979219",
"0.59773386",
"0.5974116",
"0.59584576",
"0.5953379",
"0.5952029",
"0.59511924",
"0.5943707",
"0.5932089",
"0.5915121",
"0.589965"
] |
0.64513725
|
10
|
Loading map from a data
|
def from_data(data)
@map = data["map"]
for driver in data["drivers"]
driver_obj_rep = driver["object"]
driver_obj_real = Driver.new
driver_obj_real.name = driver_obj_rep["name"]
driver_obj_real.plate = driver_obj_rep["plate"]
driver_obj_real.rating = driver_obj_rep["rating"]
driver_obj_real.first_time = driver_obj_rep["first_time"]
x, y = driver["coord"]
@map[y][x] = driver_obj_real
@drivers.push({
"coord" => driver["coord"],
"object" => driver_obj_real
})
end
for restaurant in data["restaurants"]
restaurant_obj_rep = restaurant["object"]
restaurant_obj_real = Restaurant.new
restaurant_obj_real.name = restaurant_obj_rep["name"]
restaurant_obj_real.menu = restaurant_obj_rep["menu"]
x, y = restaurant["coord"]
@map[y][x] = restaurant_obj_real
@restaurants.push({
"coord" => restaurant["coord"],
"object" => restaurant_obj_real
})
end
# If there's more than 1 connected cave rooms
if populate_caves.length > 1
raise "There's can only one cave room!"
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def load_map(data)\n if data['guards']\n data['guards'].each_pair do |name, info|\n load_item('guard', name, info)\n end\n end\n\n if data['scenes']\n data['scenes'].each_pair do |name, info| \n load_item('scene', name, info)\n end\n end\n end",
"def load(existing_map_data, size_x)\n @data = existing_map_data\n @size_x = size_x\n end",
"def map(data_version = nil)\n map = get(resource_path('map'), @version, version: data_version)\n RiotGamesApi::LOL::Model::StaticData::Map.new map\n end",
"def load_map(map_name)\n if File.file?(\"assets/maps/#{map_name}\") == true\n file = File.read(\"assets/maps/#{map_name}\")\n else \n file = File.read(\"assets/save/#{map_name}\")\n end\n\n begin\n return JSON.parse(file)\n rescue \n puts \"Error parsing the map file\"\n end\n end",
"def load_map\n @load_map ||= {}\n end",
"def initialize(map)\n super()\n\n load(map)\n end",
"def loadMap()\n\t\treturn @rankedDB.execute(\"SELECT map FROM ranked WHERE idMap = '#{@idMap}'\").shift.shift\n\tend",
"def load_map_file map_file\n return YAML.load(map_file.read)\nend",
"def load_map_names\n data = load_data('Data/MapInfos.rvdata')\n names = {}\n data.each_pair{|key, value| names[key] = value.name}\n names\n end",
"def load_map(doc)\n\t\t\tdoc = Document.new doc\n\t\t\toriginal_map = Hash.new;\n\t\t\t\n\t\t\tdoc.elements.each(\"map/s\") do |sector|\n\t\t\t\t#Make Sector\n\t\t\t\tl = Location.new(sector.attributes[\"x\"].to_i, sector.attributes[\"y\"].to_i)\n\t\t\t\ts = Sector.new(sector.text, l)\n\t\t\t\t@map[l.to_s] = s\n\t\t\tend\n\t\tend",
"def build_map(map_data)\n map = Hash.new()\n for entry in map_data\n parts = entry.split(\")\")\n center = parts[0]\n satellite = parts[1]\n map[satellite] = center\n end\n map\nend",
"def load_region_data\n { area_data: @atlas_ds.to_hash }\n end",
"def load_map(filename)\n json = File.open(File.join('maps', filename)).read\n\n Gson.new.from_json json, Hash.new.to_java.java_class\n end",
"def get_map;\t@map \t\tend",
"def load_map_chunk_column column_x, column_z; end",
"def map(load_address)\n @maps[load_address]\n end",
"def import\n Map.import(params[:file])\n end",
"def load(data)\n end",
"def load_geo_data\n countries_hash = JSON.parse(File.read(Rails.root.join('lib/countries_data/countries.json')))\n cities_hash = JSON.parse(File.read(Rails.root.join('lib/countries_data/cities.json')))\n countries_hash.each do |country_hash|\n cities_arr = cities_hash[country_hash['name']]\n\n next if cities_arr.nil?\n\n country_model = create_country country_hash\n create_cities(country_model, cities_arr)\n end\nend",
"def map_data\n res = {}\n res[:timestamp] = timestamp\n res[:position] = [xtl, ytl, xbr, ybr]\n res\n end",
"def load_maps(opts, &block)\n # Convert arg\n opts = Hash.new(opts) if native? opts\n\n defaults = {\n maps: [],\n path: nil,\n node_path: \"./maps/\",\n ajax_path: \"maps/\",\n loader: nil,\n processor: proc { |i| i },\n }\n\n opts = defaults.merge opts\n opts[:maps] = Array(opts[:maps])\n\n %x{\n var ajax_loader = function(map) {\n return new Promise(function(ok, fail) {\n var httpRequest = new XMLHttpRequest();\n httpRequest.onreadystatechange = function() {\n if (httpRequest.readyState === XMLHttpRequest.DONE) {\n if (httpRequest.responseText) {\n ok(JSON.parse(httpRequest.responseText));\n }\n else {\n if (is_local) {\n console.log(httpRequest.responseText);\n fail(\"Ajax failed load: \"+map+\". Status: \"+httpRequest.statusText+\". \"+\n \"Are you running this locally? Try adding: \"+\n \"--allow-file-access-from-files to your Chromium command line.\")\n }\n else fail(\"Ajax failed load: \"+map+\". Status: \"+httpRequest.statusText);\n }\n }\n };\n httpRequest.open('GET', #{opts[:path] || opts[:ajax_path]}+map+\".json\", true);\n httpRequest.send();\n });\n };\n\n var fetch_loader = function(map) {\n return fetch(#{opts[:path] || opts[:ajax_path]}+map+\".json\").then(function(response) {\n return response.json();\n });\n };\n\n var node_loader = function(map) {\n var resolve = null, error = null;\n var prom = new Promise(function(ok, fail) {\n resolve = ok;\n error = fail;\n });\n try {\n var node_require = eval(\"require\");\n var data = node_require(#{opts[:path] || opts[:node_path]}+map+'.json');\n resolve(data);\n }\n catch(e) {\n error(\"Node failed load: \"+map+\". Error: \"+e);\n }\n return prom;\n };\n\n var is_local = false;\n if (typeof document !== \"undefined\" &&\n typeof document.location !== \"undefined\" &&\n typeof document.location.protocol !== \"undefined\") {\n is_local = document.location.protocol == \"file:\";\n }\n\n var loader = function(map) {\n if (#{opts[:loader] != nil}) {\n return #{opts[:loader]}(#{opts[:path]}+map+'.json').then(#{opts[:processor]});\n }\n else if (typeof window !== \"undefined\") {\n return ajax_loader(map);\n }\n else if (typeof global !== \"undefined\") {\n return node_loader(map);\n }\n else if (!is_local && typeof fetch === \"function\") {\n return fetch_loader(map);\n }\n else {\n #{raise StandardError, \"We couldn't find a good way to load a map\"}\n }\n };\n }\n\n prom = `new Promise(function(ok, fail) {\n #{\n maps = opts[:maps]\n maps = maps.map { |i| map_resolve i }\n maps = maps.reject { |i| map_loaded? i }\n #p [\"Loading:\", maps]\n maps = maps.map do |i|\n `loader(#{i})`.JS.then do |map|\n load_map_json(nil, map)\n\n m = Native(map)\n inherits = []\n m.each do |mapname, mapvalue|\n inherits += Array(Native(mapvalue)[:map][:inherit])\n inherits += Array(Native(mapvalue)[:chain])\n end\n inherits = inherits.uniq\n inherits = inherits.reject { |i| map_loaded? i }\n\n load_maps(opts.merge({maps: inherits})) unless inherits.empty?\n end.JS.catch do |response|\n `fail(#{response})`\n end\n end\n }\n Promise.all(#{maps}).then(ok).catch(fail);\n })`\n\n if block_given?\n prom.JS.then(block)\n else\n prom\n end\n end",
"def initialize_map\n @locations.set_map\n end",
"def load_data()\n @trainSet.each do |line|\n subline = line.split\n user_id = subline[0].to_i\n movie_id = subline[1].to_i\n rating = subline[2].to_i\n\n if !(@usermap.has_key?(user_id))\n @usermap[user_id] = Hash.new\n end\n #first we fill up usermap\n @usermap[user_id][movie_id] = rating\n\n if !(@moviemap.has_key?(movie_id))\n @moviemap[movie_id] = Hash.new\n end\n #then we fill up moviemap\n @moviemap[movie_id][user_id] = rating\n end\n end",
"def load_locations\n add_location('Bangalore', 'Belgaum', 24)\n add_location('Bangalore', 'Mysore', 71)\n add_location('Belgam', 'Tumkur', 59)\n add_location('Mandya', 'Mangalore', 141)\n add_location('Tumkur', 'Mandya', 65.5)\n add_location('Mandya', 'Mysore', 101)\n add_location('Belgaum', 'Chickmangalur', 103)\n add_location('Mandya', 'Tumkur', 65)\n add_location('Mangalore', 'Mysore', 169)\n add_location('Mysore', 'Tumkur', 134)\n end",
"def attempt_load_world_from_file\n return if state.world # return if the world collection is already populated\n state.world ||= [] # initialized as an empty collection\n exported_world = gtk.read_file(MAP_FILE_PATH) # reads the file using the path mentioned at top of code\n return unless exported_world # return unless the file read was successful\n state.world = exported_world.each_line.map do |l| # perform action on each line of exported_world\n l.split(',').map(&:to_i) # calls split using ',' as a delimiter, and invokes .map on the collection,\n # calling to_i (converts to integers) on each element\n end\n end",
"def load_data\n @regions = Region.find(:all, :order => \"name\")\n end",
"def process_data\r\n $map = Map.new\r\n players = $data.shift.split(\";\") rescue nil\r\n [*players].each do |p|\r\n p = p.split(\",\")\r\n o = Dude.new p[2].split(\".\").map(&:to_i), p[1]\r\n o.id = p[0].to_i\r\n $map << o\r\n end\r\n end",
"def load_locations(comp)\n @complaints_map = Gmaps4rails.build_markers(comp) do |plot, marker| \n marker.lat plot.latitude \n marker.lng plot.longitude \n \n @title = plot.title\n @desc = plot.description\n @date = plot.date\n\n marker.picture({ \n \"width\" => 35, \n \"height\" => 30 \n }) \n \n marker.infowindow render_to_string(:partial => \"/complaints/info\", \n :locals => {:name => plot.name.force_encoding(\"UTF-8\"), :title => @title, :desc => @desc, :date => @date }) \n end \n end",
"def set_map\n @map = Map.find(params[:id])\n end",
"def set_map\n @map = Map.find(params[:id])\n end",
"def set_map\n @map = Map.find(params[:id])\n end",
"def set_map\n @map = Map.find(params[:id])\n end",
"def set_map\n @map = Map.find(params[:id])\n end",
"def set_map\n @map = Map.find(params[:id])\n end",
"def set_map\n @map = Map.find(params[:id])\n end",
"def initialize(map)\n @map_id = extract_property map, Const::MAP_ID\n @display_name = extract_property map, Const::MAP_DISPLAY_NAME\n @width = map.width * map.tilewidth\n @height = map.height * map.tileheight\n @is_main = extract_property(map, Const::MAP_IS_MAIN) == 'true'\n @tilesets = TileSets.new(map.tilesets, '../resources/maps/')\n\n fill_map_objects map.object_groups\n fill_layers map\n end",
"def load_data\n raise NotImplementedError\n end",
"def initialize\n @maps = {}\n end",
"def test_load_map\n json_obj = JSON.parse(File.read(\"map.json\"))\n json_map = Map.load_map(json_obj)\n assert_equal 7, json_map.locations.length\n end",
"def new_map(url)\n Map.new(name: \"1866 Fred\",\n year: \"1866\",\n url: url)\n end",
"def load!\n noaa_data = Station.find_data_by_cccc(@cccc)\n raise \"Station identifier '#{ @cccc }' not found\" if noaa_data.nil?\n @name = noaa_data[:name]\n @state = noaa_data[:state]\n @country = noaa_data[:country]\n @longitude = Station.to_longitude(noaa_data[:longitude])\n @latitude = Station.to_latitude(noaa_data[:latitude])\n @raw = noaa_data[:raw]\n @loaded = true\n self\n end",
"def load_data(data)\n data.symbolize_keys!\n\n @id = data[:id] || nil\n @name = data[:name]\n @color = data[:color]\n @indent = data[:indent]\n @item_order = data[:item_order]\n end",
"def setup(map_id)\n @map_id = map_id\n @map = load_data(sprintf(\"Data/Map%03d.rvdata\", @map_id))\n @display_x = 0\n @display_y = 0\n @passages = $data_system.passages\n referesh_vehicles\n setup_events\n setup_scroll\n setup_parallax\n @need_refresh = false\n end",
"def parse_map(data_hash)\n data = {\n tile_layers: {},\n object_layers: {},\n }\n\n data_hash[\"layers\"].each do |layer|\n case layer[\"type\"]\n when \"tilelayer\"\n data[:tile_layers][layer[\"name\"].to_sym] = process_tile_layer(layer)\n when \"objectgroup\"\n data[:object_layers][layer[\"name\"].to_sym] = process_object_layer(layer)\n end\n end\n\n data\n end",
"def load_map(filename = nil)\n self.map = {}\n return if filename.nil? || filename.empty?\n delim = /\\s*;\\s*/\n File.foreach(filename) do |row|\n row.rstrip!\n emails = row.rpartition(',')[2]\n next if emails.nil? || emails.empty?\n # Get all the emails for this user\n emails = emails.split(delim)\n # No need to map a single email to itself\n next if emails.length < 2\n # Get the primary (institutional) email\n primary_email = email(emails, use_map: false)\n # Map all emails to the primary email\n emails.each { |e| self.map[e] = primary_email unless e == primary_email }\n end\n end",
"def set_map\n # Sets locations on the map\n @map = [\n ['Enumerable Canyon', 'Duck Type Beach', 'Monkey Patch City'],\n ['Duck Type Beach', 'Enumerable Canyon', 'Matzburg'],\n ['Monkey Patch City', 'Nil Town', 'Enumerable Canyon', 'Matzburg'],\n ['Nil Town', 'Monkey Patch City', 'Hash Crossing'],\n ['Matzburg', 'Monkey Patch City', 'Duck Type Beach', 'Hash Crossing', 'Dynamic Palisades'],\n ['Hash Crossing', 'Matzburg', 'Nil Town', 'Dynamic Palisades'],\n ['Dynamic Palisades', 'Matzburg', 'Hash Crossing']\n ]\n end",
"def load_data\n\t\tload_using_arr(train_file,train_hash,0,1)\n\t\tload_using_arr(train_file,movie_hash,1,0)\n\tend",
"def set_map\n @map = NetworkMap.find(params[:id])\n end",
"def map\r\n\t\t\t@maps[@map]\r\n\t\tend",
"def map\n @data = {}\n\n sheet = Sheet.where(:map_id => params[:map_id]).first\n\n if sheet != nil\n @data[:sheet] = sheet\n @data[:layer] = sheet.layer\n polys = sheet.polygons\n @data[:polygons] = polys.count\n @data[:addresses] = Consensuspolygon.find_all_by_flaggable_id_and_flaggable_type_and_task(polys, \"Polygon\", \"address\").count\n @data[:colors] = Consensuspolygon.find_all_by_flaggable_id_and_flaggable_type_and_task(polys, \"Polygon\", \"color\").count\n @data[:fixes] = Consensuspolygon.find_all_by_flaggable_id_and_flaggable_type_and_task(polys, \"Polygon\", \"polygonfix\").count\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json {\n render json: @data\n }\n end\n end",
"def setup(map_id)\r\n # Put map ID in @map_id memory\r\n @map_id = map_id\r\n # Load map from file and set @map\r\n @map = load_data(sprintf(\"Map%03d.rxdata\", @map_id))\r\n \r\n # set tile set information in opening instance variables\r\n $data_tilesets = load_data(\"Tilesets.rxdata\")\r\n tileset = $data_tilesets[@map.tileset_id]\r\n @tileset_name = tileset.tileset_name\r\n @autotile_names = tileset.autotile_names\r\n @passages = tileset.passages\r\n @priorities = tileset.priorities\r\n @terrain_tags = tileset.terrain_tags\r\n # Initialize displayed coordinates\r\n @display_x = 0\r\n @display_y = 0\r\n # Clear refresh request flag\r\n @need_refresh = false\r\n # Set map event data\r\n @events = {}\r\n for i in @map.events.keys\r\n @events[i] = @map.events[i]\r\n end\r\n # Set common event data\r\n end",
"def initialize\n load_data\n end",
"def trial_maps\n [\n Map.new(\n name: 'San Francisco',\n data: 'color_ff7575-00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000004000000000000000000000000000000000000000000000000000000000000000_00000000000004004004000000000000000000000000000000000000000000000000000000000000_00000000000000404040000000000000000000000000000000000000000000000000000000000000_00000000000000040400000000000000000000000000000000000000000000000000000000000000_00000110000044404044400000000000000000000000000000000000000000000000000000000000_00011111100000041400000000000000000000000000000000000000000000000000000000000000_00011111100000401040000000000000000000000000000000000000000000000000000000000000_00011000100004001004000000000000000000000000000000000000000000000000000000000000_00011111100000011100000000000000000000000000000000000000000000000000000000000000_00010010100000011100000000000000000000000000000044000000000000000440000000000000_00011111100000011100000000000000000000000000000011000000000000000110000000000000_00011111100000011100000000000000000000000000000011000000000000000110000000000000_00010011100000111110000000000000000000000000001011010000000000010110100000000000_04011111100000111110000000000000000000000000001011010000000000010110100000000000_44411010110000110010001110000000000000000000101011010100000001010110101000000000_14411111111100111110011111000000000000000010101011010100000001010110101010000000_11111111111101111111011101000000000000001010101011010101000101010110101010100000_11111011110111110011111111000000000000101010101011010101010101010110101010101003_11111111111110111111111111110000000010101010101011010101010101010110101010101011_11111111111111111111010011111444111111111111111111111111111111111111111111111111_11111111111111111111111111011110000001110000000011000000000000000110000000001111_11111111441111000111111111111111000001110000000011000000000000000110000000011111_11000111001101111111111144111111110111111110000011000000000000000110000000111111_11020000000000001111000000011111110111111110000011000000000000000110000001111111_11111111111111000000000011000000000111111110000011000000000000000110000001111111_11111111111111111111111111111111111111111110000111100000000000001111000001111111',\n skill_mean: 1,\n ),\n Map.new(\n name: 'The Bunker',\n data: 'color_8a8a5c-00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000001000000000000000000000000000000000000000000000000000000000000000000000000_02000011000000100000000000000000000000000000000000000000000000000000000000000001_11111111111000110000000000000000000000000000000000000000000000000000000000101111_11111111111111111101000000000000000000000000000000000000000000000010001111111111_11111111111111111111111000000000000000000000000000100000010001111111111111111111_11111111111111111111111110100000001111011110000001100001111111111111111111111111_11111111111111111111111111111000111550005511111111111111111111111111111111111111_11111111111111111111111111111111111550005511111111111111111111111111111111111111_11111111111111111111111111111111111150005111111111111111111111111111111111111111_11111111111111111111111111111111111150005111111111111111111111111111111111111111_11111111111111111111111111111111111150005111111111111111111111111111111111111111_11111111111111111111111111111111111150005111111111110000000111111111111111111111_11111111111111111101111111111111111150005111111111100000000011111111111111111111_11111111111111111111000000011111111150005111111111000111110001111111111111111111_11111111111111111111000000001111111150005111111110001111111000111111111111111111_11111111111111111111001111000111111150005111111100011111111100011111111111111111_11111111111111111111011111100011101150005110111000111111100110001111111111111111_11111111111111111111001111110001111150005111110001111111100011000001111111111111_11111111111111111111011111111000111150005111100011111111100001100001111111111111_11111111111111111111001111111100001150005110000111111111100000111001111111111111_11111111111111111111011111111110001150005110001111111100000000000001111111111111_11111111111111111111001111111111101150005110111111111000000000000001111111111111_11111110111111111101011111111111101100000110111111110001111111111111111111111111_11111111111111111111001111111101101100000110101111100011011111111111111111111111_11111111100000000000011111111111101100000110111111000111111111111111111111111111_11111111100000004000001111111111101100000110111000001100111111111111111111111111_11111111000000044400011111111111101100000110111000011000111111111111111111111111_10111110000000444444001111111111101000000010111000110000111111111111111111111111_11111100100000444444401111111111100000000000111011100000000011111111111111111111_11000001111111111111111111111111111100000111111000000000000001111111111111111111_11000011111111111111111111111111111100000111111111111111111000111111111111111111_11000011111111111110111111111110111100000111101111111111011100011111111111111111_11000001111111111111111111111111111100000111111111111111111110001111111111111111_11111100100000000011100000000011100000000000111000000001110011000001111111111111_10111110000000000011100000000011100000000000111000000001110001100001111111111111_11111111000000000511100000440011100000000000111000000001110000111001111111111111_11111111100003000551000000444001000000000000010000000000100000000001111111111111_11111111100011105555500004444400000000000000000000000000000000000001111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111',\n skill_mean: 2,\n ),\n Map.new(\n name: 'Caravel Ships',\n data: 'color_4d94ff-00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000400000000000000000000000_00000000000000000000000000000000000000000000000000400000100000000000000000000000_00000000000000000000000000000000000000000000000000100000100000000000000000000000_00000000000000000000000000000000000000000000000000100000100000000040000000000000_00000000000000000000000000000000000000000000000001100001100000000010000000000000_00000000000000000000000000000000000000000000000011100011100000000010000000000000_00000000000000000000000000000000000000000000000110100110100000000110000000000000_00000000000000000000000000000000000000000000001110100110100000001110000000000000_00000000000000000000000000000000000000000000001100101110100000001110000000000000_00000000000000000000000000000000000000000000011100101110100000011010000000000000_00000000000000000000000000000000000000000000011100101110100000011010000000000000_00000000000000000000000000000000000000000000011100101110100000011010000000000000_00000000000100000000000000000000000000000000001100100110100000111010000000000000_00000000001110001000000000000000000000000000001110100110100000111010000000000000_00000010000111011100000000000000000000000000001110100110100000111010000000000000_00000111000111001110000000000000000000000000000110100010100001111010000000000000_00000011000111001110000000000000000000000000000111100011100011111111000000000000_00000011000111001110000000000000000000000000000001100001100000000110000000000000_00000011000110001100000000000000000000000000000001100001100000000010000000000000_00000011000110001100000000000000000000000000000000100000100000000011100000000000_00000010000100001000000000000040000000111114444444144444144444444411100000000000_00001110000100001002000000004444000000000111111001111111111111001111110000000000_00001110000100011111100001111444111000000011100011100011100011100511100000000030_00001111111111111110000001111111110000000011100111140011100411110511100000011111_55551111111111111155555555111111155555555551100004444000004444000011155551111111_55555511111111111555555555555555555555555555111111144411144411111111555511111111_55555555555555555555555555555555555555555555551111111111111111111111555511111111_55555555555555555555555555555555555555555555555555555555555555551155555111111111_55555555555555555555555555555555555555555555555555555555555555555555551111111111',\n skill_mean: 3,\n ),\n Map.new(\n name: 'Tower in the Castle',\n data: 'color_c2e0ff-00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00050000000000000000000000000000000000000000000000000000000000000000000000000000_00010000000050000000000000000000000000000000000000000000000000000000000000000000_00010000000010000000000000000000000000000000000000000000000000000000000000000000_00515000000010000000500000000000000000000000000000000000000000000000000000000000_00111000000515000000100000000000000000000000000000000000000000000000000000000000_00111000000111000000100000000000000000000000000000000000000000000000000000000000_05111500000111000005150000000000000000000000000000000000000000000000000000000000_01111100005111500001110000000000000000000000000000000000000000000000000000000000_51111150001111100001110000000000000000000000000000000000000000000000000000000000_11111110051111150051115000000000000000000000000000000000000000000000000000000000_00111000011111110011111000000000000000000000000000000000000000000000000000000000_00111000000111000511111500000000000000000000000000000000000000000000000000000000_00111000000111000111111100000000000000000000000000000000000000000000000000000000_00111000000111000001110000000000000000000000000000000000000000000000000000000000_00111000000111000001110000000000000000000000000000000000000000000000000000000000_00101000000000000000000000000000000000000000000000000000000000000000000000000000_00100011111111000000301000000000000000000000000000000000000000000000000000000000_00100110111111111111111000000000000000000000000000000000000000000000000000000000_00001110111111111111111000000000000000000000000000000000000000000000000000000000_00011010111110000051115000000000000000000000000000000000000000000000000000000000_10001010111100000005150000000000000000000000000000000000000000000000000000000000_11100010111100000000100000000000000000000000000000000000000000000000000000000000_10110010111100000000500000000000000000000000000000000000000000000000000000000000_10011000111100000000000000000000000000000000000000000000000000000000000000000000_10001100111100000000000000000000000000000000000000000000000000000000000000000000_10100001111100000000000000000000000000000000000000000000000000000000000000000000_10100011111100000000000000000000000000000000000000000000000000000000000000000000_10100110111100000000000000000000000000000000000000000000000000000000000000000000_10101110111100000000000000000000000000000000000000000000000000000000000000000000_11100010111100000000000000000000000000000000000000000000000000000000000000000000_11110010111100000000000000000000000000000000000000000000000000000000000000000000_11111000111100000110110110000000001101101100000000000000000000000000000000000000_11111100111100000111111110000000001111111100000000000000000000000000000000000000_10101110111110000111111110000000001111111100000001000010000000000000000000000000_10101000111110000111111110000000001111111100000001000010000000000000000000000000_10100011111100000001111000000000000011110000000011000011000000000000000000000000_10100110111001101101111011011011011011110000000010000001000000000000000000000000_10001100110011111111111111111111111111110000000110000001100000000000000000000000_10011000100111111111111111111111111111110000000100000000100000000000000000000000_10110000001100000401111101111111110111110000001100000000110000000044000004000000_10000000011100000441111101111511110111110000001000000000010000000444000044400000_11110000111100404441111111115551111111110000011000000000011000000440000044000000_10111000111100444441111111115551111111110000010000000000001000000040000004000000_10101100000004444411111111115551111111111100110000000000001100000040000004000020_10101111111111111111111111115551111111111111110000000000001111111111111111111111_11111111111111111111111111111111111111111111110000000000001111111111111111111111_11111111111111111111111111111111111111111111110000000000001111111111111111111111_11111111111111111111111111111111111111111111110000000000001111111111111111111111',\n skill_mean: 5,\n ),\n Map.new(\n name: 'Cat Mountain Climb',\n data: 'color_f1f1fa-00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000003000000000000000000000000000000000000000000000000000000000000_00000000000000000011110000000000000000000000000000000000000000000000000000000000_00000000000000000001111000000000000000000000000000000000000000000000000000000000_00000000000000000000111100000000000000000000000000000000000000000000000000000000_00000000000000000000011114400000000000000000000000000000000000000000000000000000_00000000000000000000011111100000040000000000000000000000000000000000000000000000_00000000000000000000001111100000044000000000000000000000000000000000000000000000_00000000000000000000001111100000011000000000000000000000000000000000000000000000_00000000000000000000001111110000111000000000000000000000000000000000000000000000_00000000000000000000001111110001111100000000000000000000000000000000000000000000_00000000000000000000004111111001111100000000000000000000000000000000000000000000_00000000000000000000000111111101111110000000000000000000000000000000000000000000_00000000000000000000000111111101111110000000000000000000000000000000000000000000_00000000000000000000000411111111111111000000000000000000000000000000000000000000_00000000000000000000000011111111111111100000000000000000000000000000000000000000_00000000000000000000000001111111111111111000000000000000000000000000000000000000_00000000000000000000000001111111111111111100000000000000000000000000000000000000_00000000000000000000000001111111111111111110000000000000000000000000000000000000_00000000000000000000000000000000111111111111100000000000000000000000000000000000_00000000000000000000000001111100111111111111111100000000000000000000000000000000_00000000000000000000000001111100000111111111111111000000000000000000000000000000_00000000000000000000000001111110000111111100000111110000000000000000000000000000_00000000000000000000000011111111000111444400000000111000000000000000000000000000_00000000000000000000000011111111100000000000000000011000000000000000000000000000_00000000000000000000000011111111100000000000000000001100000000000000000000000000_00000000000000000000000011111111110000000000000000000110000000000000000000000000_00000000000000000000000011111111111111111111100111100110000000000000000000000000_00000000000000000000000011111111111111111111000011000110000000000000000000000000_00000000000000000000000011111111111111111111000011000111000000000000000000000000_00000000000000000000000011111111111111111111000015000511000000000000000000000000_00000000000000000000000011111111111111111111500511000511000000000000000000000000_00000000000000000000000011111111111111111111555511000511000000000000000000000000_00000000000000000000000111111111111111111111155515000511000000000000000000000000_00000000000000000000000111111111111111111111155115000511000000000000000000000000_00000000000000000000000111111111111111111111155111000511100000000000000000000000_00000000000000000000000111111111111111111111111111100511100000000000000000000000_00000000000000000000000111111111111111111111111111100001100000000000000000000000_00000000000000000000000111111111111111111111111111111001100000000000000000000000_00000000000000000000000111111111111111111100001101111001110000000000000000000000_00000000000000000000000111111111111111111000000000100000110000000000000000000000_00440000000000000000000111111111111111111000000000000000110000000000000000000000_00414000000000000000000111111111111111110000000000000001110000000000000000005000_00411400000000000000001111111111111111110000000000111111110000000000000000005000_00411140000000000000001111111111111111110005511111111111110000000000000005055500_00411110000000000000001111111111111111100011111111111111110000000000000005550500_00411100000000000000011111111111111111100011000001000000010000000000000000555500_00411000000000000000111111111111111111100000000000000000000000000000000055555500_00410000000000000000111111111111111111110000400000000111100000000000000000055550_00410000000000000011111111111111111111110004440004411111110000000000005000050000_00410000000000001111111111111111111111111044444441111111111000000000005500505550_00410000000000011111111111111111111111111444444411111111111100000000055000005000_00410000000000111111111111111111111111111111111111111111111111000000005000005000_00410000001111111111111111111111111111111111111111111111111111111000005000005000_00410200111111111111111111111111111111111111111111111111111111111111111000005000_11111111111111111111111111111111111111111111111111111111111111111111111111111111',\n skill_mean: 7,\n ),\n Map.new(\n name: 'Welcome',\n data: 'color_85e085-00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000444000000000000000000000000000000000000000000_00000000000000000000000000444000000000000000000000000000000000000000000000000000_00000000000000000444000000000000000000000000000000000000000000000000000100010000_00000000444000000000000000000000000000000000000000000055500000000000001100011000_02000000000000000000000000000001100000000000555000000000000000005555511100011155_11111111111111111111111111111111111111111111111111111111111111111111111100011111_11111111111111111111111111111111111111111111111111111111111111111111111100011111_11111111111111111111111111111111111111111111111111111111111111111111111100011111_11111111111111111111111111111111111111111111111111111111111111111111111100011111_55555555555555555555555555555555555555555555555555555555555555555555555500055555_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_01100100011101100101000011101101100000110101011101001001000110101100100001110110_01110110011101110111000011001101110000100111011101001001100111101110110001100010_01010111010101100010000010001101010000110101010101101101110101101110111011100110_00000000000000000000000000000000000000000000000000000000000000000000000000000100_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000100_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00001000100000000000000000000000000000000000000000000000000000000000000000000000_00011000110000000000000000000000000000000000000000000000000000000000000000000000_55111000111555555555555555555555555555555555555555555555555555555555555555555555_11111000111111111111111111111111111111111111111111111111111111111111111111111111_11111000111111111111111111111111111111111111111111111111111111111111111111111111_11111000111111111111111111111111111111111111111111111111111111111111111111111111_11111000111111111111111111111111111111111111111111111111111111111111111111111111_55555000555555555555555555555555555555555555555555555555555555555555555555555555_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_01001010001001101100110010000011101100010110101110101011101100111011101011011010_01111011001001001101111011000001001100010111101100101001001110111001001011011110_00110011101101101101001011100001001100010101101000101101001010101001001011010110_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000100010000_00000000000000000000000000000000000000000000000000000000000000000000001100011000_55555555555555555555555555555555555555555555555555555555555555555555511100011155_11111111111111111111111111111111111111111111111111111111111111111111111100011111_11111111111111111111111111111111111111111111111111111111111111111111111100011111_11111111111111111111111111111111111111111111111111111111111111111111111103011111_11111111111111111111111111111111111111111111111111111111111111111111111111111111',\n skill_mean: 8,\n ),\n Map.new(\n name: 'Moonlit Woods',\n data: 'color_944d94-00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000440000000000000000000_00000000000000000000000000000000000000000000000000000000044440000000000000000000_00000000000000000000000000000000000000000000000000000000004140000000000000000000_00000000000000000000000000000000000000000000000000004400000110000000000000000000_00000000000000000000000000000000000000000000000000000440000510000440000000000000_00000000000000000000000000000000000000000000000000000444000510000444000000000000_00000000000000000000000000000000000000000000000000000411000010000410000000000000_00000000000000000000000000000000000000000000000000000441100010000114400000000000_00000000000000000000000000000000000000000000000000000000110010001100000000000000_00000000000000000000000000000000000000000000000004440000110011001000000044440000_00000000000000000000000000000000000000000000000000144000011001011000000444440000_00000000000000000000000000000000000000000000000000104000011101110000000014400000_00000000000000000000000000000000000000000000004040114400051155100000001114000000_00000000000000000000000000000000000000000000000111114400005155150001111000000000_00000000000000000000000000000000000000000000000004111000000151151111000004440000_00000000000000000000000000000000000000000000000004011110000001151110000000140000_00000000000000000000000000000000000000000000000000040111000001100000000001140000_00000000000000000000000000000000000000000000000444000011110001110000011111000000_00000000000000000000000000000000000000000000044444000001111000110000111100000000_00000000000000000000000000000000000000000000000011000044011110110111110000004000_00000000000000000000000000000000000000000000000441100000001110110111100000044400_00000000000000000000000000000000000000000000000001111000000110110110000041444140_00000000000000000000000000000000000000000000000000111100000000110000000441011100_00000000000000000000000000000000000000000000000000111100000000110000004011110000_00000000000000000000000000000004440000000000000001100111111101111000001111114440_00000000000000000000000000000044400000000000000011500011111101111011111110011140_00000000000000000000000000000444000000000000000000500005151101111011111150050000_00000000000000000000000000000444000000000000000000500000050001111011550050000000_00000000000000000000000000000444000000000000000000000000000001111000500000000000_00000000000000000000000000000444000000000000000000000000000001111000000000000000_00000000000000000000000000000044400000000000000000000000000001101100000000000000_00000000000000000000000000000004440000000000000000000000000001130000000000000000_00000000000000000000000000000000000000000000000000000000000001111000000000000000_00000000000000000000000000000000000000000000000000000000000001111000000000000000_00000000000000000000000000000000000000000000000000000000000001111000000000000000_00000000000000000000000000000000000000000000000000000000000001111000000000000000_00000000000000000000000000000100000000000000000000000000000001111000000000000000_00000000000000001000000000000110000000000100000000000000010001111100000100101000_00000000000000001100010010101111010001010110000010000100010101111110010110101001_00000000000100011100010111101111010011111110000011001110111151111111111111111011_00000000001100011110110111111111111011111110000011001110111111111111111111111111_00000000011100011110111111111111111111101111000011101111111111111511111111111101_00000000011100111111111111101111111111111111000011111111111111111111111511111111_00000000111110111010110111111101111111110111000111111111115111111111111111111111_00000000101110111110111111111111111111111111100111111111111111111111111111111111_00000000111110001000010010100111010111111111000011110105111111111515511515111010_00000000001000501050010515150101010001010010055551515155515151111515515515151510_02000055551555551555515515155151515551515515555551515155515151111115515515151515_11111111111111111111111111111111111111111111111111111111111111111111111111111111',\n skill_mean: 10,\n ),\n Map.new(\n name: 'Egypt Pyramid',\n data: 'color_ff8844-00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000044400000000000000000000000000000000000000_00000000000000000000000000000000000004444444000000000000000000000000000000000000_00000000000000000000000000000000000044444444400000000000000000000000000000000000_00000000000000000000000000000000000044444444400000000000000000000000000000000000_00000000000000000000000000000000000444444444440000000000000000000000000000000000_00000000000000000000000000000000000444444444440000000000000000000000000000000000_00000000000000000000000000000000000444441444440000000000000000000000000000000000_00000000000000000000000000000000000044411144400000000000000000000000000000000000_00000000000000000000000000000000000044111114400000000000000000000000000000000000_00000000000000000000000000000000000001114111000000000000000000000000000000000000_00000000000000000000000000000000000011144411100000000000000000000000000000000000_00000000000000000000000000000000000111000001110000000000000000000000000000000000_00000050000000000000000000000000001110000000111000000000000000000000000000000000_00000555000000000000000000000000011100000000011100000000000000000000000000000000_00005555500000000000000000000000111000111110001110000000000000000000000000000000_00055000550000000000000000000001111000111110001111000000000000000000000000000000_00550000055000000000500000000011141000015100001411100000000000000000000000000000_05500000005500000005050000000111440000015100000441110000000000000000000000000000_55000000000550000050005000001114400000010100000044111000000000000000000000000000_50000000000055000500000500011144000000010100000004411100000000000000000000000000_00000000000005505000000000111440000000010100000000441110000000000000000000000000_00000000000000550000000001114400001001110111001000044111000000001000000001000000_00000000000000055000000011144000011101000101011100004411100000011100000011100000_00000000000000005500000111140000011111010101111100000411110000011100000011100000_00000000000000000550001111100004411144010104411144000011111000011100000011100000_00000000000000000000011111100004411144010104411144000011111100011100000011100000_00000000000000000000111411100001111111010101111111000011141115511100000011100000_00000000000000000001114411100001111111010101111111000011144111511100000011100000_00000000000000000011144010000004411144010104411144000000104411111100000011100000_00000000000000000111440010100004411144010104411144000010100441111100000011100000_00000000000000001114400010100000011100010100011100000010100044111100000011100000_00000000000000011144000000100000011101110111011100000010000004411100000011100000_00000000000000111140000011100000011101110111011100000011100000411110000011100000_00000000000001111100000011100000011100010000011100000011100000011111555511150000_00000000000011111100000011100000011100010100011100000011100000011111155511155000_00000000000111411111100011100011111101110111011111100011100011111111111111111100_00000000001114411111100011100011111101500051011111100011100011111111111111111100_00000000011144000001100011100011000001500051000001100011100011000000000000001100_00000000111440000000000011100000000001500051000005500011100000000000000000000000_02000001114400011100000011100000000001503051000055500511150000011111111111100000_11111111111111111111111111111111111111111111111111111111111111111111111111111111',\n skill_mean: 12,\n ),\n Map.new(\n name: 'The Cave',\n data: 'color_7a7a94-00000000000000000000000011111111111111111111111111111111111111111111111111111111_00000000000000000000001111111111111111111111111111111111111111111111111111111111_00000000000000000111111111111111111111111111111111111111111111111111111111111111_00000000000000001111111111111111111111111111111111111111111111111111111111111111_00000000000000011111111111555111111111111111111111111111111111111111111111055111_00000000000000011115511155055100000100011111111111111111111100000000000000005511_00000000000000055000500000000000000000000000001000001000011001111111111110000511_00000000000000050000000000000000000000000000001000100000000011111111111111100011_00000000000000000000001000000000500000000000000000100000000111111111111111100111_00000000000000000000011000000005500100000051500000110015000011111111111111100111_00000000000111111111111111111111511111111111111101111111110001111111111111110111_02000011111111111111111111111111111111111111111101111111111000000111111111110111_11111111111111111111111111111111111111111111111101111111111110000000000051110111_11111111111111111111111111111111111111111111111101111111111111111111110555110111_11111111111111111111111111111111111111111111111101111111111111111111111155110111_11111111111111111111111110000001111111111111111101111100011111111111111151110111_11111111111111111111111114000001111111111111111101111001001111110111111111110111_11111111111111111111111114444001111111111111111101111001100001110001111111110111_11111111111111111111111114444400000000000100100000011011111100111110011111110111_11111111111111111111111114444001111111110000000400011011111110011111011111110111_11111111111111111111111114444441111111111444444444411011111110001111100111110111_11111111111111111111111111111111111111111111144414411011111110001111110011100111_11111111111111111111111111111111111111111111111111111011100000000000000000000111_11111111111111111111111111111111111111111111111111111011011111111111111111100111_11111111111111111111111111111111111111111111111111111000111111111111111111001111_11111111111111111111111111111111111111101111111111111101111111111111111100111111_11111111111111111111111111111111111111011111001111111100111111111111100011111111_11300001111111111111111111111111111110011111100111111101111111111155001111111111_11111101111111111111111111111111111111011111110111111101111111115511111111111111_11111100000000000000000000000000000000011111110111111101111111155511111111111111_11111111111110011111111111111111100111000111110111111101111111151111111111111111_11111111501111011111111111111111111111110001110111111101111111155511111111111111_11111155511111000011111111111111111111111000000111111101111111111551111111111111_11111551111111110011111111111111111111111011111111111101111111111111111111111111_11111511111111110511111111111111111111111011111111111101111111111111111111111111_11111111111111105551111111111110000000000000511111111101111111111111111111111111_11111111111111105555111111111000111111111111155011111101111111111111111111111111_11111111111111155555111111111001111111111111111151111101111111111111111111111111_11111111111111111111111111110011111111111111111551111101111111111111111111111111_11111111111111111111111111110111111111111111111151111101111111111111111111111111_11111111111100000110011111110111111111111111111111111101111111111111111111111111_11111111111100000000000011110111115111111111111111111101111111111111111111111111_11111111111044400000000011110111551111111111111111111101111111111111111111111111_11111111111444440000000000000000011111111111111111111501111111111111111111111111_11111111111444444400511111110111111111111111105115115505111151111111111111111111_11111111111111111111111111110111111115555111500150555505555551511115111111111111_11111111111111111111111111110111111115550511000150005500550051551105511111111111_11111111111111111111111111110111111115000051000500000500500051500100515111111111_11111111111111111111111111000111111110000051000500000000500005000000510511111111_11111111111111100000000000000000000000000005000000000000500005000000010511111111_11111111111111110011111111111111111000000005000000000000000000000000050011111111_11111111111111110111111111111111111000000000000000000000000000000000050011111111_11111111111111100111111111111111111000000000000000000000000000000000000011111111_11111111111111101111111115555511111100000000000000000444000000000000000001111111_11111111111111101111111111111551111110000000000000004444400000000000000000111111_11111111111111101111111111111151111111000000000000044444444000000000010005111111_11111111111111110005011111111151111111000000000000044444444440000001010005511111_11111111111111111111050050555551111111111001111104444111144444010001510055111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111',\n skill_mean: 13,\n ),\n Map.new(\n name: 'Cyberpunk Ruins',\n data: 'color_3399aa-00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000111111110000000000000000000000000000_00000000000000000000000000000000000000000000000000100000000000000000000000000000_00000000000000000000000000000000000000111111111111111000000000000000000000000000_00000000000000000000000000000000000000010000000000000000000000000000000000000000_00000000000000000000000000000000000011111111111111111111000000000000000000004000_00000000000000000000000000000000000000010001000000100100000000000000000000044000_00000000000000000000000000000000011111110111111111110111111000000000000000044000_00000000000000000000000000000000000000010000000000000100000000000000000000044000_00000000000000000000000000000000000111110111111111110111000000000000000000044000_00000000000000000000000000000000000001110111000000010100000000000000000000011000_00000000000000000000000000000000000011110111100001110111000000000000000000011000_00000000000000000000000000000000000001500051000000114110000000000000000000011000_00000000000440000000000000000000000011103011100000114110000000000000000000111000_00000000000000000000004400000000000000111110000000114100000000000000000001111000_00000000000000000000000000000000000000044400000000114000000000000000000001111000_00000000000000000000000000000000000000000000000000114010000000000000000001111000_00000002000000000000000000004400000000000000000000104110000000000000000001001000_00000011111111111110000000000000000000000000000000014110000000000000000111111110_00000000111111110010000000000000000000000000000000114110000000000550000111001110_00000001111111111110000000000000000000000000000000114110000001111111111111111110_00000011111111110010000000000000001111111110000001114111000001144444444111001110_00000111111011111110000000000000001001100111000000010100000001100000000111111110_00001111111111110010000000000000001111111111100000010111114411100000000001001100_00011111111111110000000000000000001001111111110000010100000001100000000001001100_00111111111110010000000000000000000001111111111000010111144111100000000001001100_00111111111111110000000000000000000001111110011000010100000001100000000001001100_00110011111111110000000500000000000001111111111000010111441111100000101111111111_00111111111111110000005500000500001001101110011551010100000001100000100001001100_00110011111111111111111111111111111111111111111111011114411111100000110111111111_00111111111110010015555555555555001001111111011001010100000001100000110001001100_00111111111111111110050505555500001111111111111111011111441111100000111011111110_00111111111110010010050000550000001001111111011001010100000000000000111001001100_00111111111111110000000000500000001111111111111111011111144111110000111101111110_00110111101111110000000000500000051001101111111001010100000000000000100101001100_00111111111111110000000000000000051111111111111111010111114411111000111101111110_00111111111111110000000000000005551001100000011001010000000000000000100101001100_00111144444444111111111111111111111111111111111111011111111111111111111101111111_00111111111144111114440000000005551001100000000001000000000001100000100101001111_00111111111144110014400000000000551111100111111141011111114411114400000101111100_00111111110044111114000000000000051441100000011001005100000001100000000001001111_00110011110111110010000000000000051141110011111001005111144111111440000001111100_00111111110111111110000000000000001441100000011001005100000001100000000001001111_00000000000100110010000000000000000441111001111411011111441111111144000000111100_11111011111111111110000000000000000441100000011001000100000001100000000000001111_11111001111111110010000000000000000441111100111001000114411111111114400000011100_00110000000010110000000000000000000441100000011001000100000001100000000001001111_11110000000011110000000000000055000441111110011004000100000001100000000101001100_00110000000010110000000000055550000441100000011001000000000001100000000101001100_11111111110111111011111111111111111111111111011111111111111111111111111111101111_00110000000011000010000005555000001001100000011111000000000001100000011111101111_11110000000000011110000055000000001111104444000001000000000004400000000101001100_00110000000000110010005550000000001001100000011000000055000001100000000000001100_11111111111111111110055000000000001111111111111111111111111111111111111111111100_11111111101000110010000000000000001001111111111001000000000001100000000001001100_00110000000000110000000000000000000001111111111001000000000001100000000001001100',\n skill_mean: 15,\n ),\n Map.new(\n name: 'Steamport Town',\n data: 'color_ffbd7d-00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000110011111111110000000000000440000000000001110000000000000000_00000000000000000001111115555555111000000000000110000000000011111000000000000000_00000000000000000001111111111111111000000000011111100000000111511100000000000000_00000000000000000000110011111111114000000000044114400000000111151100000000000000_00000000000000000000000000000110000400411111114114111111100111151100000000000000_00000000000000000000000000000000000044000000044114400000000111151100000000000000_00000000000000000000000000000000000000000000011111100000000011111000000000000000_00000000000040000000000000000000000000000000044114400000000041110000000000000000_00000000000010000000000000000000011100001111114114111111400400100000000000000000_00000000000014000000000000000000111110000000044114400000044001110000000000000000_00000000000011000000000000000001115111000000011111100000000001110000000000000000_00000000000011000000000000000001111511000000011111100000000000000000000000000000_00000000000011000000000000000001111511000001115115111000000000000000000000000000_00000000000010000000000000000001111511000001111111111000000000000000000000000000_00000000000010000000000000000000111110000000011111100000000000000000000000000000_00000000000010000000000000000000011140000000011111100000000000000000000000000000_00000000000114000000000000000000001004000000044114400000000000000000000000000000_00000000000114400000000000000000011100400411114114111100000000000000000000000000_00000000001111440000000000000000011100044000044114400000000000000000000000000000_00000000011111140000000000000000000000000000011111100000000000000000000000000000_00000000111001110000000000000000000000000000011111100000000000000000000000000000_00000001110000110000000000000000000000000000111111110000000000000000000000000000_00000011140000110000000000000000000000000001111111111000000000000000000000000000_00000111440000110000000000000000000000000001100000000000000000000000000000000000_00001110440000110000000000000000000000000001104440111100000000000000000000000000_00011100440000110000000000000000000000000001104440011000000000000000000000000000_00111000440000110000000000000000000000000001104444011000000000000000000000000000_00110000440000110000000000000000000000000001104444011000000000000000000000000000_02114000440000110000000000000000000000000001104444011000000000000000000000000000_01111100440000110000000000000000000000000001100000011000000000000000000000000000_01111111111100110000000000000000000400000011101111011100000000000000000000000000_00110000000000110000000000000000000100000111100110011110000000000000000000000000_00110000000000110000000000000000004140000111110110111110000000000000000000000000_00110000000000110000000000000000001110000001100110011000000000000000000000000000_00110000000000110000000000000000041114000001100000011000000000000000000000000000_00110000440000110000000000000000411111400001104444011000000000000000000000000000_00110000440000110000000000000004111111140001104444011000000000000000000000000000_00110000440000114000000000000001111111110001104444011000000000000000000000000000_00110000440000114000000000000000000000000001104444011000000000000000000000000000_00110001111111111000000000000000011111000001104444011000000000000000000000000000_00110000000011111000000000000000011111000001104444011000000000000000000000000000_00110000000000110000000000000000011441000001100000011000000000000000000000000000_00110000000000110000000000000000011441000001101111011000000000000000010000000000_00110000440000110000000000000000011441000001101111011000000000000000111000100000_00110000440000110000000000000000011441000001101111011000000000001000011101110000_01111100440000110000000000000000011441000001100000011000000000011100011100111000_01111111111000110000000000000000011441000111101111011110000000001100011100111000_00110000000000110000000000000000011441000111101111011110000000001100011100111000_00110000000000110000000000000000011000000411101111011140000000001100011000110000_00110000440000114404404404404404411000000441100000011440000000001100011000110000_00110000440011111111111111111111111011111111111011111111111100001000010000100000_00110011111111111111111111111111111011111111111011111110000000111000010000100300_00110000000000111111000000000111111400111111100011111100000000111444414441111110_00110000000000111100000000000001111410011111001011111000000000111111111111111000_01111100440000111000000000000000111411001110011011111555555555111111111111115555_01111111111000110000000000000000011411104140111011011555555555551111111111155555_00440000000000000011000000000110000000004440000000011555555555555555555555555555_11111111111111111111000000000111111111111111100000011111111111111111111111111111',\n skill_mean: 16,\n ),\n Map.new(\n name: 'Find the Dragon',\n data: 'color_ccff99-00000000000000000000000000000000000000000111111111111111111111111111111111111111_00000000000000000000001111110000000000000111111000000550000001111111111111111111_00000000000000000000011111100000000000001111111000000550000001111111111111111111_00000000000000000000111111000000010000011111111000000550000001111110111111111111_00000000000000000000111110000001111000111111111000000550000001111100010101111111_00000000000000000000011111000111010001110000000000005555000000000000000000111111_00000000000000000011001111111100000001100111111000000000000001111111000000111111_00000000000000000111111111110000000011001111111000000000000001111111111100001111_00000000000000000111111111000000000110011111111000005555000001111111111111000011_00000000000000000000010111000000000000111111110000000550000000011111111111100051_00000000000000000000000101300111111111111111110111111111111111011111111111110001_00000000000000000000111111111111111111111111110111111111111111011111111111111001_00000000000000000000001111111111111111111400000011111111111110000004111111110001_00000000000000000000000001111111111111111444400411111111111110004044111100010011_00000000000000000000000000000001111111111444444411111111111114444444111101000011_00000000000000000000000000000000011011111111111111111110001111111111111101100011_00000000000000000000000000000000001011111111111111001000000011111111111100150111_00000000000000000000000000000000000010001111111110000000000000111111111110111111_00000000000000000000000000000000000000000111111000000000000000010001111110111111_00000000000000000000000000000000000000000011000000000000000000010001101110011111_00000000000000000000000000000000000000000011000000000000000000000000101111001111_00000000000000000000000000000000000000000010000000000000000000000000000111001111_00000000000000000000000000000000000000000000000000000000000000000000000111000511_00000000000000000000000000000000000000000000000000000000000000000000000011000051_00000000000000000000000000000000000000000000000000000000000000000000000011100001_00000000000000000000000000000000000000000000000000000000000000000000000001100001_00000000000000000000000000000000000000000000000000000000000000000000000001100001_00000000000000000000000000000000000000000000000000000000000000000000000001110001_00000000000000000000000000000000000000000000000000000000000000000000000001110001_00000000000000000000000000000000000000000000000000000000000000000000000000155001_00000000000000000000000000000000000000000000000000000000000000000000000000115001_00000000000000000000000000000000000000000000000000000000000000000000000000015001_00000000000000000000000000000000000000000000000000000000000000000000000000010001_00000000000000000000000000000000000000000000000000000000000000000000000000010001_00000000000000000000000000000000000000000000000000000000000000001010000000010001_00000000000000000000000000000000000000000000000000000000000000011110000000011001_00000000000000000000000000000000000000000000000000000000000000110110000000001001_00000000000000000000000000000000000000000000000000000000000000111110000000001001_00000000000000000000000000000000000000000000000000000000001000000110100000001001_00000000000000000000000000000000000000000000000000000000001100111110110000001001_00000000000000000000000000000000000000011444400000000000000110001100110000011001_00000000000000000000000000000000000001111111140000000000000011111111110000010001_00000000000000000000000000000000000111111111140000000000000001101100110000110011_00000040000000000000000000000000000111111000040000000000000000001100110000110051_10000444000400000000000000000000001111110000040000000000000000011110110001110001_11000444000440000010000000000000011111100000040000000000000000011110000011111001_11100040004444000111000000000000011111100000040000000000000000111111100111110001_11111040000444001111100000000001111111100000040000000000000011111111111111100001_11111140000040011111110000000011111111100000040000000000001111111111111111100111_11111110000040001404100000001111111111100000040000000000001111111111111111100011_11111111100040001020000000111111111111100000040000000000011111111111111111100001_11111111111111111111111111111111111111100000000000000001111111110551151111110001_11111111111111111111111111111111111111100000040000000111111111000051051051111001_11111111111111111111111111111111111111100000000000000011111111050000050001000001_11111111111111111111111111111111111111100000040000000001111110050000000000000011_11111111111111111111111111111111111111100000000000000001111111550000000011100001_11111111111111111111111111111111111111110000040000000001111111155000011111115001_11111111111111111111111111111111111111114444444444444444441144111444111111111111_11111111111111111111111111111111111111111444444444444444444444444411111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111',\n skill_mean: 19,\n ),\n Map.new(\n name: 'Star Hopping',\n data: 'color_a3a3cc-00000000000000000000055500000000044444440000000000000000000000000000000000000000_00000000000000000055511115000004444444440000000000000000100000000000000000000000_00000000000000005511111111110444440044440000000000000000000000000000000000010000_00000300000000051111111111111144000044400000000000000000000000000000000000000000_00001110000000511111011111111110000044400000000000000000000000000000000000000000_00011111000005111111111001111111000444000000000000000000000000000001000000000000_00111111100001111011110000111111100444000000000000000000000000000011100000000000_00111111100051110011111001111111104440000000000000000000000000000001000000000000_00011111000011111111111111110011114440000000000000001000000000000000000000000000_00001110000011111111111111110111144400000000000000011100000000000000000000000000_00101010100011111111011111111111444400000000000000001000000000000000000000000000_00111111100111101111111111111114444000000001000000000000000000000000000010000000_00110001100111111111111111111144441000000000000000000000000000000000000111000000_00100000100111111111111111111144411000000000000000000000000000000000000010000000_00100000100111111111111111111444111000000000000000000000000000000000000000000000_00000000000011111111111111114444110000000000000000000000000000000000000000000000_00000000000011111111111111144441110000000000000000000000000000000000000000000000_00000000000011111111111111444411110000011000000000000000000010000000000000000000_00000000000001111111111114444111100000111100000000000000000111000000010000000000_00000000000041111111111144441111100000111100000000000000000010000000000000000000_00000000000444111111114444411111000000011000000000000000000000000000000000000000_00000100004440011111144444111110000000000000000000000010000000000000000000000000_00001110044400001111444411111100000000000000000000000111000000000000000000000000_00000100044000000144444111110000000000000000000000000010000000000000000000000000_00000000444000004444441110000000000010000000000000000000000000000000000000001000_00000000444004444444400000000000000000000000000000000000000000000100000000000000_00000004444444444440000000000000000000000000000100000000000000001110000000000000_00010004444444440000000000000000000000000000000000000000000000000100000000000000_00111000444400000000000011100000000000000000000000000010000000000000000000000000_00010000000000000000000111110000000000000000000000000000000000000000000000000000_00000000000000000000001110111000000000000000000000000000000000000000001000000000_00000000111000000000001111101000000000000000000000000000000000000000011100000000_00000001110100000000001111111000000000000000000000000000000000000000001000000000_00000001111100000000000111110000000000000000000000000000000000000000000000000000_00000001111100000000100011100000000000000000000000000000000000000000000000000000_00000000111000000001110000000000000000000000001000000000000000100000000000000000_00000000000000000000100000000000000000000000011100000000000001110000000000000000_00000000000000000000000000000000000000000000001000000000000000100000000000000000_00000000000000000000000000000000000000010000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000111000000000000000000000000_00000000000000000000000000000000000000000000000000011111110000000000000000000000_00000000000000000000000000000000000000000000000000111111111000000000000000000000_00000000000000000000000000000000000000000000000001111011111100000000000000000000_00000000000000000000000000000000000000000000000001111111111100000000000000000000_00100000000000000000000000000000000000000000000011101111111110000000000000000000_00000000000000000000000000000000000000000000000011111111111110000000000000000000_00000000000010000000000000000000000000000000000011111111111110000000011000000000_00000000000111000000000000000000000000000000000001111111111100000000111100000000_00000000001111100000000000000000000011000000000001111011111100000000111100000000_00000000000100000000000000000000000110100000000000111111111000000000011000000000_00000000000120111100000000000000000111100000000000011111110000000000000000000000_00000000000111111111100011000000000011000000000000000111000000000000000000000000_00000000011111111111111011111000000000000000000000000000000000000000000000000000_00000000111111111111011101110000000000000000011000000000000000000000000000000000_00000001111110111111111110110000000000000000111100000000000000000000000000000000_00000011111111111111110111100000000000000000111100000000000000000000000000000000_00000011111111111111111111000000000000000000011000000000000000000000000000000000_00000111111111111111111111100000000000000000000000000000000000000000000000000000_00000111111111111110111111100000000000000000000000000000000000000000000000000000',\n skill_mean: 22,\n ),\n Map.new(\n name: 'Shadow of Valus',\n data: 'color_ffeecc-00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000050000000000000000000000000000000000000_00000000000000000000000000000000500000000010000000000000000000000000000000000000_00000000000000000000000000000000100000001010500000000000000000000000000000000000_00000000000000000000000000000010100000011110100000000000000000000000000000000000_00000000000000000000000000000011111111111111100000000000000000000000000000000000_00000000000000000000000000000111111111111111111000000000000000000000000000000000_00000000000000000000000000101111111111111111111111000000000000000000000000000000_00000000000000000000000000111111111111111111111111100000000000000000000000000000_00000000000000000000000000111111111111111111111111111100000000000000000000000000_00000000000000000000000001111111111111111111111111111111100000000000000000000000_00000000000000000000000011111111111111111111111111111111111500000000000000000000_00000000000000000000000011111111111111111111111111111111110000000000000000000000_00000000000000000000000111111111111111111111111111111111110000000000000000000000_00000000000000000000000111111111111111111111111111111111111000000000000000000000_00000000000000000000000111111111111111111111111111111111111000000000000000000000_00000000000000000000000111111111111111111111111111111111111100000000050000000000_00000000001000000000000111111111111111111111111111111111111111000000010500000000_00000000000000000000000011111111111111111111111111111111111111111000010100000000_00000000000000000000000011111111111111111111111111111111111111111110011100000000_00000000000000000000000001111111111111111111111111111111111111111111011110000000_00000000000000000510000001111111111111111111111111111111111111111111111111000000_00000000000000000011000001111111011111101111111111111111111111111111111111100000_00000000000000000010000000111111111111111111111111111111111111111111111111100000_00000000000000000000000000111111111111111111111111111111111111111111111111110000_00000000000000000000000000111111111111111111111111111111111111111111111111110000_00000000000000000000001000111111111111111111111111111111111111111111111111110000_00000000100000000000000000111111111111111111111111111111111111111111111111110000_00000000000000000000000000411111111111111111111111111111111111111111111111115000_00000000000000000000000000411111111111111111111111111111111111111111111111115000_00000000000000000000000000041111111111111111111111111111111144411111111111115000_00000000000000000001000000041111111111111111111111111114444444441111111111110000_00000000000000000001100000004411111111111111111111111114000000004111111111110000_00000000000000000005100050000441111111111111111111111300000000000441111111110000_00110000000000000005100005000411111111111111111111111110000000000041111111100000_00111000000000000005000000000111111111111111111111111111000000000011111111110000_00511000000000000000000000000111111111111111111111111111100000000011111111110000_00015000000010000000000000001111111111111111111111111111100000000001111111100000_00010000000000000000000001111111111111111111111111111111100000000011111111110000_00000000000000000000000000111111111111111111111111111111100000000001111111100000_00000000000000000000000001111111111111111111111111111111100000000011111111100000_00000000000000000000000011111111111111111111111111111111100000000111111111100000_00000000000000000000001111111111111111111111111111111111100000011111111111110000_00000000000000000000000111111111111111111111111111111111110000011111111111110000_00000000000000000000000111111111441111111111111111111111110000111111111111111000_00000000000001111000000111111111444111111111111111111111110000111111111111111000_00000000000005110000001111111110004111111111110111111111110000111100111111111000_00000000000000510000001111111111004111111111000111111111110000111100111111111000_00000000000000010000001111111111004111111110000111111111110000111001111111111000_00000000000000000000001111111111004111111110000111111111110000011111111111110000_00000000000000000000001111111111001111111110000011111111100000000111111111100000_00000000000000000000000111111111001111111100000011111111100000000111111111000000_00000000000000000000000111111111001111111000000011111111100000000001111110000000_00000021100000000011000011111100001111111000000001111111110000000000000000000000_00000111000000000050000000000000011111111000000001111111110000000000000000000000_00000101000005500000050000000000011111111000000000111111111000000000000000000000_11111111111111111111111111111111111111111111111111111111111111111111111111111111',\n skill_mean: 25,\n ),\n Map.new(\n name: 'The Cube',\n data: 'color_d2eed7-11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111110001000111111000000001111110000000011111100000000111111000000021_11111111111111110101010111111000000001111110000000011111100000000111111000000001_11111111111111110101010111111005555001111110055550011111100000000111111004444001_11111111111111114141414111111005555001111110055550011111100000000111111004444001_11111111111111114141414111111005555001111110055550011111100004444111111004444001_11111111111111110101010111111005555001111110055550011111100004444111111004444001_11111111111111110101010111111000000001111110000000011111100004444111111000000001_11111111111111130100010111111000000001111110000000011111100004444444000000000001_11111111111111111111110111111111111111111111111111111111111111114444000011111111_11111111111111100044000111111111111111111111111111111111111111114444000011111111_11111111111111101111111111111111111111111111111111111111111111114444000011111111_11111111111111100044000111111111111111111111111111111111111111110000000011111111_11111111111111111111110111111111111111111111111111111111111111110000000011111111_11111111111111100044000111111111111111111111111111111111111111110000000011111111_14444444411111101111111111111000000001111110000000011111100000000000000000000001_14411114411111100044000111111000000001111110000000011111100000000111111000000001_14111111411111111111110111111005555001111110044440011111100000000111111000000001_14151151411111100044000111111005555001111110044440011111100000000111111000000001_14111111411111101111111111111005555001111110044440011111100005555111111000055551_14114411411111100044000111111005555001111110044440011111100005555111111000055551_14444444411111111111110111111000000001111110000000011111100005555111111000055551_14444444000000000000000111111000000000000000000000011111100005555555000000055551_11111111000000001111111111111111111100000000111111111111111111115555000011111111_11111111000000001111111111111111111100444400111111111111111111115555000011111111_11111111000000001111111111111111111100444400111111111111111111115555000011111111_11111111000000001111111111111111111100444400111111111111111111110000000011111111_11111111000000001111111111111111111100444400111111111111111111110000000011111111_11111111000000001111111111111111111100000000111111111111111111110000000011111111_11111111000000000000000111111000000000000000000000011111111111110000000000055551_11111111111111100000000111111000000001111110000000011111111111111111111000055551_11111111111111100000000111111004444001111110000000011111111111111111111000055551_11111111111111100000000111111004444001111110000000011111111111111111111000055551_11111111111111100005555111111004444001111110000555511111111111111111111000000001_11111111111111100005555111111004444001111110000555511111111111111111111000000001_11111111111111100005555111111000000001111110000555511111111111111111111000000001_11111111000000000005555555000000000001111110000555555500001111110000000000000001_11111111000000001111115555000011111111111111111111555500001111110000000011111111_11111111000000001111115555000011111111111111111111555500001111110000000011111111_11111111000055551111115555000011111111111111111111555500001111110000000011111111_11111111000055551111110000000011111111111111111111000000001111110000555511111111_11111111000055551111110000000011111111111111111111000000001111110000555511111111_11111111000055551111110000000011111111111111111111000000001111110000555511111111_11111111000000000000000000000000000001111110000000000000000000000000555555500001_11111111111111100000000111111000000001111110000000011111100000000111111555500001_11111111111111100555500111111004444001111110044440011111100000000111111555500001_11111111111111100555500111111004444001111110044440011111100000000111111555500001_11111111111111100555500111111004444001111110044440011111155550000111111555500001_11111111111111100555500111111004444001111110044440011111155550000111111000000001_11111111111111100000000111111000000001111110000000011111155550000111111000000001_11111111111111100000000111111000000000000000000000011111155550000000000000000001_11111111111111111111111111111111111100000000111111111111111111110000000011111111_11111111111111111111111111111111111100000000111111111111111111110000000011111111_11111111111111111111111111111111111100000000111111111111111111110000000011111111_11111111111111111111111111111111111100000000111111111111111111110000000011111111',\n skill_mean: 27,\n ),\n Map.new(\n name: 'Temple City',\n data: 'color_cfcfe6-00000000000000000000000000000000000000000000000000000000000000000000000000000002_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000044000000000000000000000000000_00000000000000000000000000000000000000000000111111144000000000000000000000111111_00000055000000000000000000000000000000000005511111111000000000000000011111111111_00000000550000000000000444000000000000055555511111111000000000005555111111111111_00000000055500000000000044400000000000555555551111111000000000000055555555511111_00000000000550000000000000000000000000000000055551111000000000000000000005555111_00000000005555555000001111111111000000000000000000000000000000000000000000000000_00000000000005555555511111111100000000000000000000000000000000000000440000000000_00000000000000055555511111111000000000000000000000000000555111111111440000000000_00000000000000000005551111110000000000000000000000000055555511111111110000000000_55500000000000000000055111000000000000000000000000000000005555111111110000000000_05555511100000000000000000000000000000000000000000000000000055551110000000000000_00051111000000000000000000011100000000000000000000000000000000000000000000000000_00005110000000000000000000551100000005511110000000000000000000050550000000000000_00000000000000000000000000000000000000051100000000000000000005555555000050000000_00000000000000000000000000000000055500000000000000000000000555555555555500000000_00000000000000000055551100555555555555000000000000000000555550005005055550050000_00000000000010100000555555555055101555505550000000000505550050000000005555555005_00000000000110110000555555500001101100555555550550055555550000000000000000555555_00000000000110110055550000000001101100005555555555555555500000000000000000005505_00000000011110111155500000000111101111000000550005555500000000000000000000000555_00000000011500051150000000000115000011000000000005550000000000000000000000000005_00000000011500551150000000000000000511000000000055500000000000000000000000000000_00000555011500051100000000005110000511000000005055000000000000000000000000000000_50555551111100111111100055111111100111110000000550500000000000000000000000000000_55055551150001151441100005114415110000110000005500000000000000000000000000000000_55550551150011551441100000114415511000110000555500000000000000000000000000000000_55555551100110051441100000114415001100110055555000000000000000000000000000000000_55000001100000001441100000114410000000110005550000000000000000000000000000000000_00000001111000001441100000114410000011115555550000000000000000000000000000000000_00000001101100001441100000114410000115115555000000000000000000000000000000000500_00000001100110000001100000110000001155115000000000000000000000000000000000005500_00000001111111011111100000111111011151115000000000000400400400000000000055505000_00000001100400001441100000114410000555150000000000000101110100000000000050550000_00000001100400001441150000114410000555510000000000000111511100000000000000055550_00000001104440001441150000114410005550115000000000040001510004000000000000005550_00000001100400001441100000114410005500115500000000010111511101000000000005505050_00000001100000001441150000114410055000100555000000011155555111000000000555055000_00000001100000001441155000114410050000000005000004000111111100040000005000055000_00000001100000000001100000110000000000110000000001011155555111010000005500005050_00000001111001111111100000111111110011110000000001110000000001110000000000055500_00500001101100051551100055115515000115110000000400011111111111000400000000005500_05500001100110051551100005115515001155110000000101114444444441110100000000000500_05505001111111011111100000111111011111110000000111000000000000011100000000000500_00555001100400000001100000110000000400110000000010040040004004001000000000005500_00500001100400000001100000110000000400115000000010010010001001000000000000055500_00500001104440000001100000110000004440115000000111111111011111111100000000555000_00500001100400000501100000110000000400115500001111111111011111111110000005555500_11111111100000005500000000000000000000111111111111111111011111111111111111111111_11111111111111111111111111111111111111111111111111111111011111111111111111111111_11111111111111111111111111111111111111111111111111111111011111111111111110000011_11111111111111111111111111111111111111111111111111111111011100110011001110030011_11111111111111111111111111111111111111111111111111111111000000000000000000111011_11111111111111111111111111111111111111111111111441144111011111111111111111111111_11111111111111111111111111111111111111111111111440044000011111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111',\n skill_mean: 30,\n ),\n Map.new(\n name: 'Moon Launcher',\n data: 'color_7070ae-00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000050000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000005000000000050000000000000000000000050000000000000005000000000000_00000000000000000000000000000000000050000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000005000_00000000005000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000011100000000000000000000000000_00000000000000000000500000000000000000000000000000111110000000000000000000000000_00000000000000000000000000000000000000000000000001101111000050000000000000000000_00000000000000000000000000050000000000000000000001111011000000000000000000000000_00000000000000000000000000000000000000000000000001101111000000000000044440000000_00000000000000000000000000000000000000000004000000111110000000000000411114400000_00000000000000000000000000000000000000000004000000011100000000000000111111140000_05000000000000000000000000000000000000000004000000000000000000000000000111114000_00000000000000000000000000000050000000000000000000000000000000000000000011111000_00000000000000000000000000000000000000000004000000000050000000000000000011111400_00000000500000000000500000000000000000000000000000000000000000000000000001111100_00000000000000000000000000000000000000000000000000000000000000000000000001111100_00000000000000000000000000000000000000000004000000000000000000000000000001111100_00000000000000000000000000000000000000000000000000000000000000000000000001111100_00000000000000000000000000000000000000000000000000000000000000000000000011111000_00000000000000000000000000000000000000000000000000000000005000000000000011111000_00000000000005000000000000000000005000000004000000000000000000000000030111110000_00000005000000000000000000000000000000000000000000000000000000000000111111100000_00000000000000000000000000000000000000000000000000000000000000000000011110000000_00000000000000000000000000000000000000000010100000000000000000000000000000005000_00000000000000000000000000000000000000000114110000000000000000000000000000000000_00000000000000000000000000005000000000000110110000000000000000000000000000000000_00000000000000000000000000000000000000000110110050000000000000000000000000000000_00000000000000000000000000000000000000000110110000000000000000000000000000000000_00000000000000000000000000000000000000000114110000000000000500000000000000000000_00000000000000000000000000000000000000000110110000000000000000000000000000000000_00000500000000000000000000000000000000000010100000000000000000000000000000000000_00000000000000000000000050000000000000000114110000000000000000000000000000000000_00000000000000000000000000000000000000000010100000000000000000000000000000000000_00000000000000000000000000000000000000000110110000000000000000000000000000000000_00000000000000000000000000000000000000000014100000000000000000000000000000000000_00000000000000000000000000000000000000000110110000000000000000000000000000000000_00000000000000000000000000000000000000000010100000000000000000000000000000000000_00000000000000000000000000000000000000000014100004440000000000000000000000000000_00000000000000000000000000000000000000000010100000000000000000000000000000000000_00000000000500000000000000000005000000000010100000000000000500005000000005000000_00000000000000000000000000000000000000000014100000000000000000505000000000000000_00000000000000000000000000000000000000000010105500000051111111111111111111111101_05000000000000000000000000000000000000055014105500000051115101515101010101010001_00000000000000000000000000000000000000055010105500000051010000005000000000010111_00000000000000000000000000000000000000011014101100000000000000000000000101010001_00000000000000000000000000000000000000011010101100000000000000000000000111011101_00000000000000000000000000000000000444011004001100000000004400000000000001010001_00000000000000000000000000000000000444011111111101111111111100000000000001010111_00001001110101011010110101010001100111011111111100100001001100044000000001000001_00001001110101011110100111011001110111111110111100100411000000011000000001010111_00001101010111010110110101011101010010011510151101110001000011111111100001010001_00000000000000000000000000000000000010011510151101110411000011010000000001011101_11111111111111111111111111111111111111111510151100000001000000010000000001010001_00000000000000000000000000000000000000011511151100000411000000010000000001010111_00000000000000000044400000004440000000111111111110000001000500010000050001010001_00000000000000000000000000000000000000111110111110000411055550010005555551011101_02000000000000000000000000000000000000000000000000000001555555515555555511110001_11111111111111111111111111111111111111111111111111111111111111111111111111111111',\n skill_mean: 32,\n ),\n Map.new(\n name: 'Garden of Giants',\n data: 'color_ecbfc4-00000000000000000000000000000000000000000000000000000000000000000000000444410000_00000000000000000000000000000000000000000000000000000000000000000000000044410000_00000000000000000000000000000000000000000000000000000000000000000000000004410000_00000000000000000000000000000000000000000000000000000000000000000000000000410000_00000000000000000000000000000000000000001000000000000000000000000000000000010000_00000000000000000000000000000000000000001000000000000000000000000000000000010000_00000000000000000000000000000000000000001000000000000000000000000000000000010000_00000000000000000000000000000001000000001000000000000000000000000000000000010000_00000000000000000000000000000001000000000000000000000000010000000000000000000000_00000000000000000000000000000001000000000000000000000000010000000000000000000000_00000000000000000000000000000001000000000000000000000000010000000000000000000000_00000000000000000000000000000001000000000000000000000000010000000000000000000000_00000000000000000000000000000000000000000000000000000000010000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000100000000000000000000000000000004400000000_00000000000000000000000000000000000000100000000000000000000000000000001100000000_00000000000000000000000000000000000000100000000000000000000000001000001101000000_00000000000000000000000000000000000000100000000000000000000000001000001111100000_00000000000000000000000000000000000000100000000000000000000000001000001110110000_00000000000000000000000000000000000000100000000000000000000555000000001100011000_00000000000000000000000000000000000000100000000000000000005505500000011001001100_00000000000000000000000000000000000000100000000000000000055000550000111011101110_00000000000000000000000000000000000000000000000000000000005050050000001011100000_00044440000000000000000000000000000000000001000000000000005550050000001011101000_00444400000000000000000000000000000000000001000000000000000000055000001000001000_00044000000000000040000000000000000000000000000000000000000000055000001000001001_00000000000000000000000000000000000000000000000000000014000000050000001110111001_10000000110000000000000000000000000000000000000000000014000000550000001110111011_10000001100000000000000000000000000000000000000000000014000000550000000010100011_10000011000000000000000000000000000000000000000000000014000055555000000010100011_10000110000440000000000000000000000000000000000000000014000555555000000010100011_11100000000444000000000000005000000000000000000000000014000550005500000010111111_10110000000000000000000000005500000000000000000000000014005550505500000010000001_10011000000000000000000000000500000000000000000000000014005550505500000010000001_10001100000000000000000000000500000000000000000005550014005550555000000011111101_10000000110000000000000000000501111444000000000050050014005550000000000011111101_10000001100000000000000000000500011111440000000050000014000550000000000001110101_10000011000000000000000000000550001011110000000005555014000505000000000000110101_10000110000000000000000000000050000010000000000000500514000555000000000000110001_11100000000000000000000000000055000010000000000005505514000055500005555000010001_10110000000000000000000000000005000000000000000005500010005055500055055555000001_10011000000000000000000000000005000000000000000000550010005005505550005555500001_10001100000000000000000000000005000000000000000000005010050005555500000005500001_10000000110000000000000000000005000000000000000000005515005055555000000005550001_10000001100000000000000000000055000000000000000000000515005555550000000000550001_10000011000000000000000000000050000000000000000000005015505550550000000300550001_10000110000000000000000000000050000000000000000000055015505000550000011100050001_11100000000000000000000000000050000000000000000500050555555000550000110000050001_10110000000000000000000000000055000000000000000500055055555500050001100000550001_10011000000000000000000000000055500000000000000500505555555550550000000005500001_10001100000000000000000000000005500000000000005500555055500505050000005555000001_00000000110000000000000000000000500000000000005000055055555005550000000555000001_00000001100000000000000000000055550000000000055500050555505055050111000000000001_20000011000000000050000000000055550000000050055000550555005555550001100000000001_11111110000005000050000000000055155000000555005500000555555055550000110000000001_10050050000055005550050000005005555005005515005055015555055555555500011000000001_10555055500050555050555005550515015505550501000555555555005005050500001100000001_10555555555050555555055055505555555115055100550510555555015505555505000110000001_15555555555555555555555555515555555555550505505055500155505550055055500011111111',\n skill_mean: 34,\n ),\n Map.new(\n name: 'Pyramid Dimension',\n data: 'color_c17c7a-00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000555555555555555555555555555000000000000000000000000000_00000000000000000000000000055555555555555555555555550000000000000000000000000000_00000000000000000000000000005555555555555555555555500000000000000000000000000000_00000000000000000000000000000555555555555555555555000000000000000000000000000000_00000000000000000000000000000055555555555555555550000000000000000000000000000000_00000000000000000000000000000005555555555555555500000000000000000000000000000000_00000000000000000000000000000000555555555555555000000000000000000000000000000000_00000000000000000000000000000000055555555555550000000000000000000000000000000000_00000000000000000000000000000000005555555555500000000000000000000000000000000000_00000000000000000000000000000000000555555555000000000000000000000000000000000000_00000000000000000000000000000000000055555550000000000000000000000000000000000000_00000000000000000000000000000000000005555500000000000000000000000000000000000000_00000000000000000000000000000000000000555000000000000000000000000000000000000000_00000000000000000555555555555555000000050000055555555555555555550000000000000000_00000000000000000055555555555550000004444400005555555555555555500000000000000000_00000000000000000005555555555500000440050044000555555555555555000000000000000000_00000000000000000000555555555000004400050004400055555555555550000000000000000000_00000000000000000000055555550000004400050004400005555555555500000000000000000000_00000000000000000000005555500000001100050001100000555555555000000000000000000000_00000000000000000000000555000000000100010001000000055555550000000000000000000000_00000000000000000000000050000000000100010001000000005555500000000000000000000000_00000000000000000000000000000000000100010001000000000555000000000000000000000000_00000000000000000000000000000000000144414441000000000050000000000000000000000000_00000000000000000100000000000000000144414441000000000000000004000000000000000000_00000000000000001110000000000000000144414441000000000000000044400000000000000000_00000000000000011111000000000000000144414441000000000000000444440000000000000000_00000000000000111111100000000000000100414001000000000000004444444000000000000000_00000000000005555555550000000000000100414001000000000000011111111100000000000000_00000000000000555555500000000000000100414001000000000000001111111000000000000000_00000000000000055555000000000000000102414001000000000000000111110000000000000000_00000000000000005550000000500000000111111111000000004000000011100000000000000040_00000000000050000500000005550000000000010000000000044400000001000050000000000440_00000000000555000000000055555000000000111000000000444440000000000555000000004440_00000000005555500000000555555500000001111100000004444444000000005555500000044440_00000000055555550000001111111110000011111110000011111111100000055555550000111110_00000000555555555000000111111100000111111111000001111111000000555555555000011110_00000005555555555500000011111000001111111111100000111110000005555555555000001110_00000055555555555550000001110000011111111111110000011100000055555555555000000110_00000555555555555555000000100000111111111111111000001000000555555555555005000010_00005555555555555555500000000001111111111111111100000000005555555555555005500000_00055555555555555555550000000011111111111111111110000000055555555555555005550000_00555555555555555555555000000111111111111111111111000000555555555555555005555000_05555555555555555555555500001111111111111111111111100005555555555555555005555500_55555550555555555555555550011111111111111111111111110055555555555555555005555550_55555500055555555555555555111111111111111111111111111555555555555555555005555555_00000001000000005500000000000000000000000000000000000000000000000000000001000000_00000011100000005500000000000000000000000000000000000000000000000000000001100000_00000113110000005500111111111111100000000000001111111111111000000000000001110000_00110000000110005500011111111111000000000000000111111111110000000000000001111000_04144441444414005500011111111110000000015000000011111111100000001000000001111100_04144411144414005000010111111100000000115500000001111111000000011000000001111110_04144111114414005000010011111000000001115550000000111110000000111000000001111111_04141115111414000000010001110000000011115555000000011100000001111000000001111111_04111151511114000000010000100000000111115555500000001000000011111000000001111111_04111515151114000000010000000000001111115555550000000000000111111000000001111111_01111111111111000000010000000000011111115555555000000000001111111000000001111111_00555555555550000000010000000000000000000000000000000000000000000000000001111111_00055555555500000000010000000000000000000000000000000000000000000000000001111111_00005555555000000000000000000000000000000000000000000000000000000000000000000000',\n skill_mean: 38,\n ),\n Map.new(\n name: 'Diving with Whales',\n data: 'color_6c87d6-00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000555500000000000000000000000000000000000000_00000000000000000000000000000000000055000550000000000000000000000000000000000000_00000000000000000000000000000000000050000550000000055555000000000000000000000000_00000000000000000000000000000000000050005500000000550005500000000000005555500000_00000000000000000000000000000555000055000000000000550000550000000000055555550000_00000000000000000100000000000500500005550000000000550000550000000000555505550000_00200000000000000110000000000000500000005555555000055000550000000055500000055000_00100000000000000111100000000000500000000000000000000000550000505550000000005000_00110000000000001144100000000000500055500000000000000005500000000000000500050000_00011000000000001140110000000005000550050004000055555555000000000000000055500000_00001100000005001400110000005550005500000041000000000000000000000000000000000000_05000110001105511010111055555550005500000411000000000000000000000000000000000000_05550110111115110100111055050500005500004111000000000000000000000000000000000000_00055511100411101100000055005500000550001111000000000000000000000000000000000000_00005511004011101000111055500500000555000001030000000000000000000000000055500005_50050110040111011000115555555550115555501111111000550001110000000000000555000555_05555100401110010000115555115555555555555111115555555511111111110000055055555555_55551104011110100051155555555555555555555555555505501111111111111100000000055055_00011040011101100551155055505550000000055555500050011111111111111111000000000000_55510400111411000511000000000000000000000000000500111111111111111111111000000000_50011001114010000111000500000000000000000000005501111111111000001111111100000000_55501100040000110110500000000000000000000000055011111111100000000001110000000000_00005110400001155100000000000000000000000000055011111111100000000001110000000000_05505110000011551100000000000050000000000000050111111111100000000000111000000000_00501100001115511055550005555005500000000000050111111111110000000000000000000000_55501000011000111550055500000000000005500000501111111101111000000000000000000005_50010000000000000000000000000000005555000000501111111000111000000000000000000555_00115000000001100000000000000055550000000005001111110000000000000000000000055550_01155555000011000000000005505500000000000000001111100000000000000000000000000000_11555555555110000000000000000000000000000000000110000000000000000011110000000000_11111555511100000000000000000000000000000000055500000000000000001111100000000000_00111111110000000000055555555500000000000055500000000000000000011111100000000000_00000000000000000000111111115555500055005550000000000000000011111111000000000000_00100000000000000011111111111155555500555000000000000000001111111111110000000000_01111000000000000111111111111111555555000000000000000001111111111111111000000000_00100000000000000111111111111111100000000000000000000111111111111011111100000000_00000000000000000011111111111111111000110000000001111111111111100000011110000000_00000000000000000001111111111111111111111100000111111111111110000000000000000000_00000000000000000000011111111111111111111111111111111111111000000000000000000000_00000000010000000000001111111111111111111111111111111111110000000000000000000000_01000000111100000000000111111111111111111111111111111111100000000000000000000000_00000000010000000000000011111111111111111111111111111111000000000000000000000000_00000000000000000111000011111111111111111111111111111110000000000000000000001000_00000000000000000011100001111111111111111111111111111100000000000000000000011110_00001100000000000000000000111111111111111111111111110000000000000000000000001000_00000000000000000000000000011111111111111111111111000000000000010000000000000000_00000000000000000000000000011111111111111111111100000000000000000000000000000000_00000000000010000000000000011111111111111111110000000000000000000000000000000000_00000000000111110000000000011110011110000000000000000000000000000000000000000000_00000000000010000000000000011100011110000000000000000000001000000000000000000000_00001000000000000000000000111100011100000000000000000000000000000000000000000000_00011110000000000000000000111100011100000000000000000000000000000001000000000000_00001000000000000000000000111000011110000000000000001000000001000000000000000000_00000000001110000000000000011000001110000000000000011110000000000000000000000000_00000000001000000000000000000000000110000000000000001000000000000000000010000000_00000000000000000000000000000000000000000000000000000000001000000000000111100000_00000001000000000000000000000000000000000000000000000000011110000000000010000000_01000000000000000000000111000000000000011000000000000000001000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000',\n skill_mean: 40,\n ),\n Map.new(\n name: 'The Astral Ascent',\n data: 'color_ff6666-00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000050000000000000000000000000005000000000000000000000000000000_00000000000000000000000000000000004000000000000000000000000000000000000000000000_00000005000000000000000000000000000004000000000000000000000000000000000500000000_00000000000000000000000000000040000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000005000000000000000000000_00050000000000000000000000004000000000000000000500000000000000000000000000000000_00000000000000000040000000000000000000000000000000000000000000000000000000000000_00000000000000000400000000000000000000040000000000000000000000000000050000000000_00000000000000000000000000111100000000040000000000000505000055000000000000000000_00000000050000000000000005511500000000040000000000005555555500000000000000000000_00000000000000000000005555555505000000040000000500055550555555555000000000000000_00000000000000000000055500005055000000000000000505055550000005055500000000050000_00000000000000030000550000000005555000000000555555555500000000005550000000000000_00005000000001111155050000000400055501101100055550000000000000000050000000000000_00000000000001000155000000000000005550101000555500000000000000000050000000000000_00000000000001020150000000000000000550101005555050000000000000000050000000000000_00000000000041000150000000000000000555101005555000000005000000000000000000000000_00000000000011141110000000041114000051101105550000000000000000000000000000000000_00000000000001000100000000000100000555101555550000000000000000000000000000500000_00000005000001141100000000000100000055101555550000000000000000000000000000000000_00000000000001000100000000000100000005101555555500000000000050000000000000000000_00000000000001141100000000004100000055101555550000000000000000000000000000000000_00500000000041000100040000040100000005101555000000000500000000000005000000000000_00000000000011141110110000011111400001101100000000000000000000000000000000000000_00000000000001000000155555511111400555101555550000000000000000000000000000000000_00000000000001111111155555511111400055101555550500000000000000000000000000000000_00000000000005555500040044004400005555101555555050000000050000000000000000000000_00000500000005555500000000000000005555101555555505000000000000000000000000000000_00000000000005555500550055005500555555101555555055550000000000000000000000000000_00000000000005555500551155115511555555101555555555555500000000000000500000000000_00000000005005555500551155115511555555101555555555555550000000000000000000000000_00000000000005555500000044004400000400101555555505555500000000000000000000005000_00000000000005555500000000000000000000101555555505505050000000000000000000000000_00050000000005555511004055005500555000101555555550500055500500005550000000000000_00000000000005555511001155115511555000001555555555505505555055555005550000000000_00000000000005555500001155115511555111111555505500555055050000000000005000000000_00000000000005055500000005555555555555555555555505555555505000000000000000000000_00000000500000050500000005555555055555555555500555505505500000000000000000000000_00000000000000000500000000055555500005555505000000055505055505500000000000000000_00000000000000000500000000000500055500050000000000005055000555000000500000000000_00005000000000000000000000000000000000000000000000000055000000500000000000000000_00000000000000000000005000000000000000000000000000000050000000055500000000000000_00000000000000000000000000000000000000000000000000055500000000000550000000000000_00000000000000500000000000000000000000000000500000055500000000000050000000000000_00000000000000000000000005000000000000000000000000555000000000000055000000050000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000005000000000000000000000000000000000000000000_00000005000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000500000000000000000000_00000000000000000050000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000500000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000500000000000000000500000000_00005000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000050000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_55555555555555555555555555555555555555555555555555555555555555555555555555555555',\n skill_mean: 44,\n ),\n Map.new(\n name: 'Mothership Warp',\n data: 'color_339999-00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000500000000000000_00000000000000000000000000000000000000000000000000000000000000000550000000000000_00000000000000000000000000000000000000000000000000000000000000000555000000000000_00000000000000000000000000000000000000000000000000000000000000000555000000000000_00000000000000000000000000000000000000000000000000000000000000000555000000000000_00000000000000000000000000000000000000000000000000000000000000000555000000000000_00000000000000000000000000000000000000000000000000000000000000000555000000000000_00000000000000000000000000000000000000000000000000000000000000000555000000000000_00000000000000000000000500000000000000000000000000000000000000000555000000000000_00000000000000000000000550000000000000000000000000000000000000000055000000000000_00000000000000000000000555000000000000000000000000000000000000000005000000000000_00000000000000000000000555000000000000000000000000000000000000000005000000000000_00000000000000000000000555000000000000000005000000000000000000000005000000000000_00050000000000000000000555000000000000000055000000000000000000000005000000000000_00055000000000000000000555000000000000000555000000000000000000000005000000000000_00055500000000000000000555000000000000000555000000000000000000000005000000000000_00055500000000000000000055000000000000000555000000000000000000000005000000000000_00055500000000000000000005000000000000000555000000000000000000000005000000000000_00055500000000000000000005000000000000000555000000000000000000000005000000000000_00055500000000000000000005000000000000000555000000000000000000000000000000000000_00055500000000000000000005000000000000000550000000000000000000000000000000000000_00005500000000000000000005000000000000000500000000000000050000000000000000000000_00000500000000000000000005000000000000000500000000000000550000000000000000000000_00000500000000000050000005000000005000000500000000000005550000000000000000000000_00000500000000000050000005500000055000000500000000000005550000000000000000000000_00000500000000000050000005550000555000000500000000000005550000000000000000000000_00000500000000000050000005555005555000000500000000000005550000000000000000000000_00000500000000000010000055555005555500000500000000000005550000000000000000000000_00000500000000000010000055555005555500000100000000000005550000000000000000000000_00000500000000000010300055555005555500020100000000000005550000000000000000000000_00000000000000000011110055555005555500111100000000000005550000000000000000000000_00000000000000000015500055555005555500055100000000000005500000000000000000000000_00000000000000000015500055555005555500055100000000000005000000000000000000000000_00000000000000000015500055555005555500055100000000000005000000000000000000000000_00000000000000000015500055555005555500055100000000000005000000000000000000000000_00000000001111111115555555555005555555555100000000000005000000000000000000000000_00000000001555555555555555555005555555555100000000000005000000000000000000000000_00000000001000000000000055555005555500000100000000000005000000000000000000000000_00000000001000000000000005555005555000000100000000000005000000000000000000000000_00000000001000000000000000555005550000000100000000000005000000000000000000000000_00000000001004400000044000055005500000000100000000000005000000000000000000000000_00000000001001100000011000005005000000000100000000000005000000000000000000000000_00000000001001555555551000005000000000000100000000000005000000000000000000000000_00000000001000500000050000005000000000000100000000000000000000000000000000000000_00000000001000500000050000005000000000000100000000000000000000000000000000000000_00000000001000500000050000005000000000000100000000000000000000000000000000000000_00000000001000500000050000005000000000000100000000000000000000000000000000000000_00000000005000500050000000005000000000000100000000000000000000000000000000000000_00000000005000500050000000015000000000000100000000000000000000000000000000000000_00000000005000500050000000015000000000000100000000000000000000000000000000000000_00000000000000500050000001115000000000000100000000000000000000000000000000000000_00000000000000500055555555555555555500055100000000000000000000000000000000000000_00000000000000500000000000000000000000000100000000000000000000000000000000000000_00000000100000510000000000000000000000000100000000000000000000000000000000000000_00000000100000510044400000000000000000000100000000000000000000000000000000000000_00001111100000511111111000000000000000000100000000000000000000000000000000000000_00001000000000555555551000000000000000000100000000000000000000000000000000000000_00001000000000000000551000000000000000000100000000000000000000000000000000000000_00001000000000000000551000000000000000000100000000000000000000000000000000000000',\n skill_mean: 47,\n )\n ]\nend",
"def load_data(data_hash)\n super\n @url = data_hash['url']\n end",
"def load_map(filename = nil)\n return if filename.nil? || filename.empty?\n delim = /\\s*;\\s*/\n File.foreach(filename) do |line|\n # Get the emails from the rule\n primary, emails = load_map_rule(line, delim)\n next if emails.nil?\n # Map all emails to the primary email\n emails.each { |e| store[e] = primary unless e == primary }\n end\n end",
"def initialize(data) # {{{\n @data = {}\n data.each do |k, v|\n @data.merge! @@mapping[k] ? {@@mapping[k] => v} : {k => v}\n end\n\n true\n end",
"def create\n @map = Map.new(map_params)\n @file = @map.meta_data\n # binding.pry\n\n @meta_data = []\n @kind = @map.kind\n fips_to_hc_key\n @map.meta_data = @meta_data\n respond_to do |format|\n if @map.save\n format.html { redirect_to @map, notice: 'Map was successfully created.' }\n format.json { render :show, status: :created, location: @map }\n else\n format.html { render :new }\n format.json { render json: @map.errors, status: :unprocessable_entity }\n end\n end\n end",
"def load\n with_unzipped_file do |uzf|\n square_side = Math.sqrt(uzf.length / 2).to_i\n\n fail WrongDimensionsError if square_side != SRTM1_SIDE && square_side != SRTM3_SIDE\n\n lon, lat = tile_to_lon_lat(filename)\n TileData.new(filename, lat, lon, square_side, read_data(uzf, square_side))\n end\n end",
"def set_data_model\n @data_model = Georeference::GoogleMap\n end",
"def load_data(c)\n return nil unless c.has_key?(\"data\")\n\n #single resource, but instantiate it and stick it in an Array\n return [mapped_type(c[\"data\"][\"type\"]).new(c[\"data\"], self)] if c[\"data\"].is_a? Hash\n\n # Instantiate Resources for each array element\n return c[\"data\"].map{|d| mapped_type(d[\"type\"]).new(d, self)}\n end",
"def check_map_data\n # stop if not using intelligent passability mode\n return unless BlizzABS::Config::INTELLIGENT_PASSABILITY\n # load tileset data\n $data_tilesets = load_data('Data/Tilesets.rxdata')\n # get current map states\n new_data = load_data('Data/MapInfos.rxdata')\n # if first time intelligent passability is being used\n if !File.exist?('Data/Map_Data.abs')\n # initialize\n data, dates = {}, {}\n # all map IDs\n ids = new_data.keys.sort\n else\n # get passability data and \"modified time\" data from old data file\n data, dates = load_data('Data/Map_Data.abs')\n # get a sorted array of all map IDs\n keys = new_data.keys.sort\n # iterate through all current map IDs\n keys.each_index {|i|\n # if game not encrypted\n if File.exist?(sprintf('Data/Map%03d.rxdata', keys[i]))\n # open map file for reading\n file = File.open(sprintf('Data/Map%03d.rxdata', keys[i]), 'r')\n # if map was edited\n if dates[keys[i]] != file.mtime\n # remove map ID from data\n data.delete(keys[i])\n # remove map ID from dates\n dates.delete(keys[i])\n end\n # close file\n file.close\n end\n # prevent \"Script is hanging\" error\n Graphics.update if i % 20 == 0}\n # iterate through all map IDs that were deleted\n (data.keys - keys).each {|id|\n # remove map ID from data\n data.delete(keys[id])\n # remove map ID from dates\n dates.delete(keys[id])}\n # get all map IDs that need to be updated\n ids = keys - data.keys\n end\n # iterate through all IDs\n ids.each {|id|\n # load map\n map = load_data(sprintf('Data/Map%03d.rxdata', id))\n # create one map data pack\n data[id] = setup_passability(map)\n # if game not encrypted\n if File.exist?(sprintf('Data/Map%03d.rxdata', id))\n # open map file for reading\n f = File.open(sprintf('Data/Map%03d.rxdata', id), 'r')\n # get map file modified time\n dates[id] = f.mtime\n # close file\n f.close\n end\n # prevent \"Script is hanging\" error\n Graphics.update}\n # open new file\n file = File.open('Data/Map_Data.abs', 'wb')\n # save all data to file\n Marshal.dump([data, dates], file)\n # save and close file\n file.close\n # remove variables from memory completely\n $data_tilesets = nil\n end",
"def init_map\n @map = [\n ['Enumerable Canyon', 'Monkey Patch City', 'Duck Type Beach'],\n ['Monkey Patch City', 'Nil Town', 'Matzburg', 'Enumerable Canyon'],\n ['Duck Type Beach', 'Matzburg', 'Enumerable Canyon'],\n ['Matzburg', 'Duck Type Beach', 'Monkey Patch City', 'Hash Crossing', 'Dynamic Palisades'],\n ['Nil Town', 'Moneky Patch City', 'Hash Crossing'],\n ['Hash Crossing', 'Matzburg', 'Dynamic Palisades', 'Nil Town'],\n ['Dynamic Palisades', 'Hash Crossing', 'Matzburg']\n ]\n end",
"def get(data)\n begin\n d = data\n map.split('/').each{|s|d = d[s]}\n return d\n rescue\n nil\n end\n end",
"def load_country_data(code)\n if cache_data?\n return @@cached_data[code] if @@cached_data[code]\n end\n\n json = File.read(path_for_country(code))\n country_data = MultiJson.load(json)\n\n if cache_data?\n @@cached_data[code] = country_data\n end\n\n country_data\n end",
"def load_game_from_map(map_path)\n $LOGGER.info \"Loading map from file. Path: '#{map_path}'\"\n begin\n game_state = Game::GameState.new [Map::GameMap.new(Map.load_map(map_path))], Character::Character.new\n $LOGGER.info \"Map with id: '#{game_state.current_map}' loaded successful.\"\n return game_state\n rescue Map::MapParseException, NoMethodError => e\n $LOGGER.error \"Errors occured while map loading:\"\n $LOGGER.error e.message\n fail e\n end\n end",
"def import(data)\n dat = data['data']\n self[0] = dat[0, 4]\n self[1] = dat[4, 4]\n self[2] = dat[8, 4]\n self[3] = dat[12, 4]\n self\n end",
"def map\n end",
"def import_locale_map\n json = JSON.parse(File.read(path_to_json))\n\n json[\"countries\"].each_pair do |country_code, country_data|\n country_name = country_data[\"name\"]\n languages = country_data[\"locales\"]\n\n associate_country_with_locales(country_name, country_code, languages)\n end\n end",
"def load_graph\n graph_loader = GraphLoader.new(@map_file, @highway_attributes)\n @graph, @visual_graph = graph_loader.load_graph()\n end",
"def load_data(data_set)\n\t\tif data_set != :u\n\t\t\tload_hashes(\"#{data_set}.base\") # training set\n\t\t\tload_test(\"#{data_set}.test\") # test set\n\t\telse\n\t\t\tload_hashes(\"#{data_set}.data\") # training set\n\t\tend\n\tend",
"def create_map\n @map = Sprite.new\n @map.bitmap = Cache.picture(MAP_PICTURE)\n @map.x = M_X\n @map.y = M_Y\n @map.z = 11\n end",
"def initialize\n @map = {}\n end",
"def country_map\n @country_map ||= load_countries\n end",
"def data_map\n @data_map ||= ChefBackup::DataMap.new do |data|\n data.backup_time = backup_time\n data.strategy = strategy\n data.topology = topology\n end\n end",
"def load\n map_classes = ObjectSpace.enum_for(:each_object, class << Map; self; end).to_a\n # remove the base class\n map_classes.delete(Map)\n \n @maps << DrownedRat.new\n self.generate\n end",
"def initialize(filename = nil, map_filename = nil)\n self.load_config(filename)\n self.load_map(map_filename)\n end",
"def generate_map\n end",
"def asigna_pixi_geojson\n file = File.read(Rails.root.join('public', 'topojson', \"#{tipo.estandariza}.geojson\"))\n json = JSON.parse(file)\n json[region_id.to_s]\n end",
"def map\n\n end",
"def load_data\n raise \"Data is temporarily disabled\" unless EolConfig.data?\n EOL.log_call\n # Sad that we need to load all of this for the about and glossary tabs, but\n # TODO - we can cache this, later:\n @taxon_data = []\n @range_data = []\n @data_point_uris = []\n @categories = []\n @include_other_category = @data_point_uris &&\n @data_point_uris.detect { |d| d.predicate_known_uri.nil? ||\n d.predicate_known_uri.toc_items.blank? }\n @units_for_select = []\n end",
"def read_locations_from file\n data_hash = []\n File.readlines(file).each do |line|\n data_hash << JSON.parse(line)\n end\n self.location_hash = data_hash\n self\n end",
"def map\n # expires_in 1.year, public: true\n set_metadata({ 'title' => translate('classes.map_title') })\n\n countries = {\n ru: 'RU',\n cs: 'CZ',\n it: 'IT',\n ko: 'SK',\n }\n\n config = params.permit(:q, :country)\n config[:locale] = I18n.locale unless I18n.locale == :en\n config[:theme] = 'wemeditate'\n config[:country] ||= countries[I18n.locale]\n @atlas_url = \"https://atlas.sydevelopers.com/map/embed.js?key=#{ENV.fetch('ATLAS_KEY')}&#{config.to_query}\"\n @atlas_enabled = ENV['ATLAS_LOCALES'].split(',').include?(I18n.locale.to_s)\n \n render layout: 'minimal'\n end",
"def parse_map(data: \"\", type: \"new\")\r\n if data.empty? then return end\r\n if type == \"level\" || type == \"attract\" then type = \"new\" end\r\n case type\r\n when \"new\"\r\n tiles = data[0..965].split(//).map{ |b| b.hd }.each_slice(COLUMNS).to_a\r\n object_counts = data[966..1045].scan(/../).map{ |s| s.reverse.hd }\r\n objects = data[1046..-1].scan(/.{5}/m).map{ |o| o.chars.map{ |e| e.hd } }\r\n when \"old\"\r\n data = data[8..-1]\r\n tiles = data[0..1931].scan(/../).map{ |b| b.reverse.to_i(16) }.each_slice(COLUMNS).to_a\r\n objs = data[1932..-1]\r\n objects = []\r\n OBJECTS.sort_by{ |id, o| o[:old] }.reject{ |id, o| o[:old] == -1 }.each{ |id, type|\r\n if objs.length < 4 then break end\r\n quantity = objs[0..3].scan(/../).map(&:reverse).join.to_i(16)\r\n objs[4 .. 3 + 2 * quantity * type[:att]].scan(/.{#{2 * type[:att]}}/).each{ |o|\r\n if ![3,6,8].include?(id) # everything else\r\n objects << [id] + o.scan(/../).map{ |att| att.reverse.to_i(16) }.ljust(4,0)\r\n else # door switches\r\n atts = o.scan(/../).map{ |att| att.reverse.to_i(16) }\r\n objects << [id] + atts[0..-3].ljust(4,0) # door\r\n objects << [id + 1] + atts[-2..-1].ljust(4,0) # switch\r\n end\r\n }\r\n objs = objs[4 + 2 * quantity * type[:att]..-1]\r\n }\r\n end\r\n {tiles: tiles, objects: objects.stable_sort_by{ |o| o[0] }}\r\nrescue\r\n #print(\"ERROR: Incorrect map data\\n\")\r\n return nil\r\nend",
"def initialize(map_name, mission_data)\n @avg_damage_taken = mission_data['damagetakenavg'].to_f\n @avg_friendly_fire = mission_data['friendlyfireavg'].to_f\n @avg_kills = mission_data['killsavg'].to_f\n @best_difficulty = mission_data['bestdifficulty']\n @damage_taken = mission_data['damagetaken'].to_i\n @friendly_fire = mission_data['friendlyfire'].to_i\n @games_successful = mission_data['gamessuccess'].to_i\n @img = AlienSwarmStats::BASE_URL + mission_data['image']\n @kills = mission_data['kills'].to_i\n @map_name = map_name\n @name = mission_data['name']\n @total_games = mission_data['gamestotal'].to_i\n @total_games_percentage = mission_data['gamestotalpct'].to_f\n\n @time = {\n :average => mission_data['avgtime'],\n :brutal => mission_data['brutaltime'],\n :easy => mission_data['easytime'],\n :hard => mission_data['hardtime'],\n :insane => mission_data['insanetime'],\n :normal => mission_data['normaltime'],\n :total => mission_data['totaltime']\n }\n end",
"def import_locale_map\n print \"[request_info] importing country-locale map... \"\n\n # read in country locale map file\n CSV.foreach(\n @path\n ) do |row|\n next if row.empty?\n\n # skip the header row\n next if row.first.length > 3\n\n ccode = row[0].strip.downcase.to_sym\n name = row[1].strip\n langs = row[2..-1].reject(&:nil?).map(&:downcase).map(&:strip)\n @cc[ccode] = {\n :name => name,\n :locales => langs\n }\n\n langs.each do |l|\n @ll[l.to_sym] ||= {}\n @ll[l.to_sym][:ccodes] ||= []\n @ll[l.to_sym][:ccodes].push ccode\n end\n end\n\n puts \"Done.\"\n end",
"def initialize_metros(data)\n data.each do |line|\n code = line['code']\n name = line['name']\n country = line['country']\n continent = line['continent']\n timezone = line['timezone']\n coordinates = line['coordinates']\n population = line['population']\n region = line['region']\n metro_node = Metro.new(code, name, country, continent, timezone, coordinates, population, region)\n\n #We refuse to overwrite a certain part of code\n if @metros.has_key?(code)\n puts 'We already have this city'\n else\n @metros[code] = metro_node\n end\n end\n end",
"def show\n @map = Map.find(params[:id], :include => \"tiles\")\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @map }\n end\n end",
"def load (data)\n if data.size != @maze_table.size * @maze_table[0].size\n print \"the string has incorrect lenghth\\n\"\n return\n else\n i = 0\n @maze_table.each do |row|\n (0..row.size-1).each do |index|\n row[index] = data[i]\n i += 1\n end\n end\n end\n if valid\n print \"valid maze\\n\"\n else\n print \"invalid maze\\n\"\n end\n end",
"def maps\n @facilities = Facility.joins(:city).where(city_id: params[:search][:city_id])\n @facilities = @facilities.joins(:category).where(\"categories.id = ?\", params[:search][:category_id]) if params[:search][:category_id].present?\n @markers = []\n @facilities.each do |f|\n @markers << {\n lat: f.latitude,\n lng: f.longitude,\n image_url: helpers.asset_url('placemarker.png')\n }\n end\n # @markers = @facilities.map do |f|\n # {\n # lat: f.latitude,\n # lng: f.longitude,\n # image_url: helpers.asset_url('placemarker.png')\n # }\n authorize :facility, :map?\n # end\n end",
"def load_countries(iso3166_tab_path, zone_tab_path); end",
"def entity_map\n return @map if @map\n\n path = File.dirname(__FILE__) + \"/../../support/entities.txt\"\n @map = {}\n File.read(path).split.each do |line|\n elements = line.split(\":\")\n @map[elements.first] = elements.last\n end\n @map\n end",
"def build_maps\n build_image_maps\n build_flavor_maps\n end",
"def load_tiletypes\n begin\n blocktypes = @doc.root.elements[\"blocktypes\"]\n real_blocktypes = blocktypes\n\n if blocktypes.has_attributes? and blocktypes.attributes['src'] then\n src = get_local_file(blocktypes.attributes['src'])\n real_blocktypes = REXML::Document.new(src).root\n end\n\n\treal_blocktypes.each_element { |blocktype_element|\n\t code = blocktype_element.attributes[\"code\"]\n\t path = blocktype_element.attributes[\"path\"]\n\t @log.debug \"Loading new Tile with code '#{code}' and path '#{path}'\"\n\n make_tile_solid = (blocktype_element.attributes[\"solid\"] == \"solid\")\n\n begin\n new_blocktype = Tile.new(Image.load(path), make_tile_solid)\n rescue Image::ImageFileNotFoundException => ifnfe\n @log.error ifnfe.message\n new_blocktype = Tile.new(nil, make_tile_solid)\n end\n\n\t @blocktypes[code] = new_blocktype\n\t}\n rescue => ex\n\t@log.error \"Cannot read XML node 'map/blocktypes' in datafile #{source_name}. (\" + ex.message + \")\"\n raise\n end\n end",
"def show\n @user = User.find(params[:id])\n @map = @user.map\n end",
"def parse_map(data: \"\", type: \"new\")\n if data.empty? then return end\n if type == \"level\" || type == \"attract\" then type = \"new\" end\n case type\n when \"new\"\n tiles = data[0..965].split(//).map{ |b| b.hd }.each_slice(COLUMNS).to_a\n object_counts = data[966..1045].scan(/../).map{ |s| s.reverse.hd }\n objects = data[1046..-1].scan(/.{5}/m).map{ |o| o.chars.map{ |e| e.hd } }\n when \"old\"\n data = data[8..-1]\n tiles = data[0..1931].scan(/../).map{ |b| b.reverse.to_i(16) }.each_slice(COLUMNS).to_a\n objs = data[1932..-1]\n objects = []\n OBJECTS.sort_by{ |id, o| o[:old] }.reject{ |id, o| o[:old] == -1 }.each{ |id, type|\n if objs.length < 4 then break end\n quantity = objs[0..3].scan(/../).map(&:reverse).join.to_i(16)\n objs[4 .. 3 + 2 * quantity * type[:att]].scan(/.{#{2 * type[:att]}}/).each{ |o|\n if ![3,6,8].include?(id) # everything else\n objects << [id] + o.scan(/../).map{ |att| att.reverse.to_i(16) }.ljust(4,0)\n else # door switches\n atts = o.scan(/../).map{ |att| att.reverse.to_i(16) }\n objects << [id] + atts[0..-3].ljust(4,0) # door\n objects << [id + 1] + atts[-2..-1].ljust(4,0) # switch\n end\n }\n objs = objs[4 + 2 * quantity * type[:att]..-1]\n }\n end\n {tiles: tiles, objects: objects.sort_by{ |o| o[0] }}\nrescue\n print(\"ERROR: Incorrect map data\\n\")\n return {tiles: [], objects: []}\nend",
"def initialize(mapname, map)\n @mapname = mapname\n @map = map\n end",
"def load(tuple)\n mapper.load(tuple)\n end",
"def import(root_path = Rails.root, folders = \"/public/\")\n map_file = File.open(\"#{root_path}#{folders}#{map_source}\", \"r\")\n map_array = map_file.readlines\n map_height = map_array.length\n layers_array = Array.new\n index = 0\n\n import_attributes(map_array)\n import_tileset(map_array)\n\n while index < map_height\n current_line = map_array[index].to_s.strip \n if assert_tag(\"layer\", current_line)\n default_values = [0,0,0,0,0,0]\n values = Map.extract_tag(\"layer\", current_line)\n (0...default_values.length).each do |i|\n unless values[i].nil?\n default_values[i] = values[i].to_i\n end\n end\n current_layer = extract_body(map_array[index...map_height],\"layer\")\n layer_string = \"\"\n current_layer.each do |line|\n layer_string = layer_string + line + \"-\"\n end\n is_scrolling = ((default_values[3] != 0 || default_values[4] != 0))\n new_layer = Layer.create(array: layer_string.chop, is_tile_layer: true, tileset_id: @tilesets[default_values[0]].id, is_static: (default_values[2] == 1), horizontal_speed: default_values[3], vertical_speed: default_values[4], is_tile_scroll: default_values[5], opacity: default_values[1], is_scrolling: is_scrolling )\n layers_array.push(new_layer)\n end\n\n if assert_tag(\"fill\", current_line)\n values = Map.extract_tag(\"fill\", current_line)\n new_layer = Layer.create(background_color: values[0], is_fill_layer: true, opacity: values[1].to_f)\n layers_array.push(new_layer)\n end\n\n if assert_tag(\"background_image\", current_line)\n values = Map.extract_tag(\"background_image\", current_line)\n new_layer = Layer.create(image: values[0], is_x_repeat: values[1], is_y_repeat: values[2], is_x_stretch: values[3], is_y_stretch: values[4], is_static: values[5])\n layers_array.push(new_layer)\n end\n index = index.next\n end\n return layers_array\n end",
"def index\n @maps = Map.all\n # gon.meta_data = @maps.last.meta_data\n end",
"def map\n render :template=>'edgarj/map', :layout=>false\n end"
] |
[
"0.7464339",
"0.69085795",
"0.6726764",
"0.66259557",
"0.6553458",
"0.65366685",
"0.6406172",
"0.63425416",
"0.63390887",
"0.63012236",
"0.62634265",
"0.6253802",
"0.62102437",
"0.6195607",
"0.6188269",
"0.6081631",
"0.6075496",
"0.606865",
"0.59369147",
"0.59351695",
"0.5906791",
"0.5899349",
"0.58976215",
"0.58812666",
"0.5879074",
"0.5875978",
"0.58515394",
"0.5788271",
"0.5783625",
"0.5783625",
"0.5783625",
"0.5783625",
"0.5783625",
"0.5783625",
"0.57722974",
"0.577136",
"0.5769871",
"0.5760461",
"0.5741073",
"0.57368815",
"0.57287383",
"0.5717876",
"0.5664519",
"0.56480616",
"0.56401277",
"0.56338316",
"0.5633416",
"0.56317383",
"0.5606412",
"0.5604866",
"0.560115",
"0.5597364",
"0.55966187",
"0.5596608",
"0.5587861",
"0.5584104",
"0.55719674",
"0.5563256",
"0.5526084",
"0.55243504",
"0.5522269",
"0.55217505",
"0.55158854",
"0.5506382",
"0.5501208",
"0.5492729",
"0.5462036",
"0.5420927",
"0.53984815",
"0.5393409",
"0.53863144",
"0.53736794",
"0.53637385",
"0.535895",
"0.53327",
"0.5321925",
"0.5321462",
"0.531989",
"0.53170204",
"0.53145367",
"0.5313496",
"0.5310354",
"0.53070134",
"0.5300186",
"0.52948016",
"0.528818",
"0.5279403",
"0.527002",
"0.5261317",
"0.5258919",
"0.52570146",
"0.525583",
"0.5250452",
"0.52486426",
"0.5247566",
"0.5245774",
"0.5241241",
"0.5237166",
"0.523069",
"0.5230064"
] |
0.5827481
|
27
|
Generate initial map that only consist of wall
|
def generate_initial_map
for _ in 0...@height
temp = []
for _ in 0...@width
temp.push(@WALL)
end
@map.push(temp)
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def generate_map\n map = make_random_map\n map = add_borders(map)\n map = ensure_adjacent_rooms(map)\nend",
"def generate(north_west_corner,south_east_corner)\n\t\tn_y,n_x=north_west_corner.position\n\t\ts_y,s_x=south_east_corner.position\n\t\tsplit_point=Point.new(rand(n_y+2..s_y-2),rand(n_x+2..s_x-2),'wall')\n\t\tif(split_point.x==nil or split_point.y==nil)\n\t\t\treturn @map\n\t\tend\n\t\tgenerate_walls(split_point,north_west_corner,south_east_corner)\n\t\tpoint_array=middle_points(north_west_corner,south_east_corner,split_point)\t\n\t\tpoint_array.each_slice(2) {|a|\n\t\t\tgenerate(a[0],a[1])\n\t\t}\n\tend",
"def generate\n @map.each_index do |x|\n @map[x].each_index do |y|\n rand(4) > 0 ? @map[x][y] = :empty : @map[x][y] = :full\n end\n end\n end",
"def make_random_map\n entire_map = []\n 20.times do\n single_row = []\n 20.times do \n if rand(2) == 1\n single_row << :room\n else\n single_row << :wall \n end \n end \n entire_map << single_row\n end\n entire_map\nend",
"def set_border()\n for row_i in 0...@height\n @map[row_i][0] = @PERMANENT_WALL\n @map[row_i][@width - 1] = @PERMANENT_WALL\n end\n\n for column_i in 0...@width\n @map[0][column_i] = @PERMANENT_WALL\n @map[@height - 1][column_i] = @PERMANENT_WALL\n end\n end",
"def generateMap difficulty\r\n width = 12\r\n height = 100\r\n map = Array.new(height)\r\n i = 0\r\n previousCutterYPos = 0\r\n noCuttterForFirst10Block = 0\r\n while i < height-1\r\n map[i] = Array.new(width)\r\n if(i%3==0) #if the coloumn consist plank then draws the wooden plank on the random position and fills the left space with 0\r\n posX = rand(1..6) #6 randomply decides the position where to draw the wooden plank\r\n plankWithBomb = rand(30)\r\n width.times do |x| \r\n if(x < posX || (posX+4) < x) # fills the coordinate with space i.e 0\r\n map[i][x] = 0\r\n else # fills the coordinate with wooden plank i.e 1 \r\n if(plankWithBomb % (5-difficulty)==0) \r\n map[i][x] = 3\r\n else\r\n map[i][x] = 1 \r\n end\r\n end\r\n end\r\n else #else then just draw the space i.e 0 or cutters \r\n posX = -1\r\n if(previousCutterYPos!=(i-1) && rand(15) % (10-difficulty)==0 && i < 90) # i > 10 denotes that there are no cutter for first 10 blocks or jumps\r\n posX = [0,11].sample \r\n previousCutterYPos = i\r\n end\r\n \r\n 12.times do |x|\r\n if(posX==x)\r\n map[i][posX] = 2\r\n else\r\n map[i][x] = 0\r\n end\r\n end\r\n end\r\n i+=1\r\n end\r\n\r\n # map[height-1] = Array.new()\r\n map[height-1] = [1,1,1,1,1,1,1,1,1,1,1,1] # just making the last block as platform for player to move around\r\n\r\n map # return the map to the calling function\r\nend",
"def generate_map\n end",
"def index\n @map_bounds = [20, 20]\n @current_position = [0,0]\n @map = []\n @spots_around = [[-1, 0], [1, 0], [0, -1], [0, 1]]\n create_initial_map\n generate_map\n end",
"def draw_map_cells(x, y)\n for i in (0..x-1)\n for j in (0..y-1)\n MapCellEmpty.create(:x => $node_size*5 * i + $node_size *5/2.0, :y => $node_size * 5 * j + $node_size * 5/2.0)\n end\n end\n end",
"def draw_map_obj\n MapCellWall.destroy_all\n MapCellGen.destroy_all\n HPBar.destroy_all\n clear_towers\n $map.occupied_spaces.each do |cell|\n x = cell.x\n y = cell.y\n case cell.object\n when MapAbxn::Wall\n MapCellWall.create(:x => $node_size * 5 * x + $node_size * 5 / 2.0, :y => $node_size * 5 * y + $node_size * 5/2.0)\n when MapAbxn::Tower\n draw_tower(cell.object, $node_size * 5 * x, $node_size * 5 * y, 0.1)\n when MapAbxn::Generator\n MapCellGen.create(:x => $node_size * 5 * x + $node_size * 5 / 2.0, :y => $node_size * 5 * y + $node_size * 5/2.0)\n end\n end\n end",
"def draw_map game_map\r\n tiles = game_map.tiles # 2d array of the tiles set!\r\n wooden_plank_image = game_map.wooden_plank # image of the wooden plank \r\n i = 0\r\n j = 0\r\n unit_width = 20\r\n unit_height = 20\r\n\r\n # drawing the background image of the game map\r\n #game_map.background.draw(0,0,0) # 0: for x position, 0: for y position, 0: for ZOrder\r\n\r\n height = tiles.length\r\n width = tiles[0].length\r\n\r\n while i < height\r\n j = 0\r\n while j < width\r\n if(tiles[i][j]==1 || tiles[i][j]==3)\r\n x = j * unit_width\r\n y = i * unit_height\r\n draw_plank(x, y, wooden_plank_image)\r\n j+=4 # increment the value of the j by 4 to skip the next 4 blocks\r\n end\r\n j+=1\r\n end\r\n i+=1\r\n end\r\n\r\nend",
"def add_maze_walls\n # add the left and right sides\n for wall_y in 0..@height-1 do\n @vertical_walls[wall_y].unshift :unhit\n @vertical_walls[wall_y].push :hit\n end\n # add the top\n @horizontal_walls.unshift Array.new(@width, :unhit)\n # open a hole for the start\n # starts on the top or bottom\n if(@start_y == 0 || @start_y == @height-1) then\n @horizontal_walls[@start_y == @height-1 ? @height : 0][@start_x] = :start\n end\n # starts on the left or right\n if(@start_x == 0 || @start_x == @width-1) then\n @vertical_walls[@start_y][@start_x == @width-1 ? @width : 0] = :start\n end\n # open a hole for the end\n # ends on the top or bottom\n if(@end_y == 0 || @end_y == @height-1) then\n @horizontal_walls[@end_y == @height-1 ? @height : 0][@end_x] = :end\n end\n # ends on the left or right\n if(@end_x == 0 || @end_x == @width-1) then\n @vertical_walls[@end_y][@end_x == @width-1 ? @width : 0] = :end\n end\n end",
"def initialize(mX, mY, mT, mW)\n @MapX = mX\n @MapY = mY\n @MapTerrain = mT\n @MapWeather = mW\n \n rt = Random.new()\n @@mapContent = Array.new(2) {Array.new(3) {|index| index = rt.rand(4)}}\n #(0..5).each {|x| @@mapContent[x] = (0..5).each {|y| @@mapContent[x][y] = rt.rand(4)}}\n end",
"def create_world_map\n @world_map = World_Minimap.new(@viewport2)\n open_world_map\n end",
"def clear_small_wall\n for row_i in 1...@height - 1\n for column_i in 1...@width - 1\n total_wall = count_adjacent_wall(row_i, column_i)\n\n if @map[row_i][column_i] == @WALL\n if total_wall < 2\n @map[row_i][column_i] = @FLOOR\n next\n end\n end\n end\n end\n end",
"def make_blank_graph\n ISSUE_NAMES.each_with_index {|name, i| @nodes[i] = Graph::Node.new(i, name, \"\") unless name.blank? }\n\n #testing\n #@edges[1] = Graph::Edge.new(1, @nodes[0], @nodes[3], MapvisualizationsHelper::INCREASES)\n\n @nodes[START].location = Vector[(@width-200)/2, @height/2] #pull out Menhaden Population and center\n grid_nodes_in_box(@nodes.reject{|k,v| k==START},Vector[@width-200+50, 130],Vector[200, @height-130+50]) #hard-coded starting box\n end",
"def create_map\n @map = Sprite.new\n @map.bitmap = Cache.picture(MAP_PICTURE)\n @map.x = M_X\n @map.y = M_Y\n @map.z = 11\n end",
"def map_tile_nocavern(tile)\n (-1..1).all? { |dx| (-1..1).all? { |dy|\n next if not t = tile.offset(dx, dy)\n tm = t.tilemat\n if !t.designation.hidden\n t.designation.flow_size < 4 and tm != :FROZEN_LIQUID\n else\n t.shape_basic == :Wall and (tm == :STONE or tm == :MINERAL or tm == :SOIL or tm == :ROOT)\n end\n } }\n end",
"def generate_map(tiles: [], objects: [], type: \"new\")\r\n case type\r\n when \"new\"\r\n tile_data = tiles.flatten.map{ |b| [b.to_s(16).rjust(2,\"0\")].pack('H*')[0] }.join\r\n object_counts = \"\"\r\n object_data = \"\"\r\n OBJECTS.sort_by{ |id, entity| id }.each{ |id, entity|\r\n if ![7,9].include?(id) # ignore door switches for counting\r\n object_counts << objects.select{ |o| o[0] == id }.size.to_s(16).rjust(4,\"0\").scan(/../).reverse.map{ |b| [b].pack('H*')[0] }.join\r\n else\r\n object_counts << \"\\x00\\x00\"\r\n end\r\n if ![6,7,8,9].include?(id) # doors must once again be treated differently\r\n object_data << objects.select{ |o| o[0] == id }.map{ |o| o.map{ |b| [b.to_s(16).rjust(2,\"0\")].pack('H*')[0] }.join }.join\r\n elsif [6,8].include?(id)\r\n doors = objects.select{ |o| o[0] == id }.map{ |o| o.map{ |b| [b.to_s(16).rjust(2,\"0\")].pack('H*')[0] }.join }\r\n switches = objects.select{ |o| o[0] == id + 1 }.map{ |o| o.map{ |b| [b.to_s(16).rjust(2,\"0\")].pack('H*')[0] }.join }\r\n object_data << doors.zip(switches).flatten.join\r\n end\r\n }\r\n map_data = tile_data + object_counts.ljust(80, \"\\x00\") + object_data\r\n when \"old\"\r\n header = \"00000000\"\r\n tile_data = tiles.flatten.map{ |t| t.to_s(16).rjust(2,\"0\").reverse }.join\r\n objs = objects.reject{ |o| !OBJECTS.key?(o[0]) }.map{ |o| o.dup }\r\n doors_exit = objs.select{ |o| o[0] == 3 }.zip(objs.select{ |o| o[0] == 4 }).map{ |p| [3, p[0][1], p[0][2], p[1][1], p[1][2]] }\r\n doors_lock = objs.select{ |o| o[0] == 6 }.zip(objs.select{ |o| o[0] == 7 }).map{ |p| [6, p[0][1], p[0][2], p[0][3], p[1][1], p[1][2]] }\r\n doors_trap = objs.select{ |o| o[0] == 8 }.zip(objs.select{ |o| o[0] == 9 }).map{ |p| [8, p[0][1], p[0][2], p[0][3], p[1][1], p[1][2]] }\r\n objs = objs.select{ |o| ![3,4,6,7,8,9].include?(o[0]) }.+(doors_exit).+(doors_lock).+(doors_trap).stable_sort_by{ |o| o[0] }\r\n entities = (0..25).to_a.map{ |id| [id, []] }.to_h\r\n objs.each{ |o|\r\n next if !entities.key?(OBJECTS[o[0]][:old])\r\n s = o[1..OBJECTS[o[0]][:att]].map{ |a| a.to_s(16).rjust(2, \"0\").reverse }.join\r\n entities[OBJECTS[o[0]][:old]].push(s)\r\n }\r\n object_data = entities.map{ |k, v| v.size.to_s(16).rjust(4, \"0\").scan(/../m).map(&:reverse).join + v.join }.join\r\n footer = \"00000000\"\r\n map_data = header + tile_data + object_data + footer\r\n else\r\n print(\"ERROR: Incorrect type (new, old).\")\r\n return 0\r\n end\r\n map_data\r\nend",
"def generate_map(tiles: [], objects: [], type: \"new\")\n case type\n when \"new\"\n tile_data = tiles.flatten.map{ |b| [b.to_s(16).rjust(2,\"0\")].pack('H*')[0] }.join\n object_counts = \"\"\n object_data = \"\"\n OBJECTS.sort_by{ |id, entity| id }.each{ |id, entity|\n if ![7,9].include?(id) # ignore door switches for counting\n object_counts << objects.select{ |o| o[0] == id }.size.to_s(16).rjust(4,\"0\").scan(/../).reverse.map{ |b| [b].pack('H*')[0] }.join\n else\n object_counts << \"\\x00\\x00\"\n end\n if ![6,7,8,9].include?(id) # doors must once again be treated differently\n object_data << objects.select{ |o| o[0] == id }.map{ |o| o.map{ |b| [b.to_s(16).rjust(2,\"0\")].pack('H*')[0] }.join }.join\n elsif [6,8].include?(id)\n doors = objects.select{ |o| o[0] == id }.map{ |o| o.map{ |b| [b.to_s(16).rjust(2,\"0\")].pack('H*')[0] }.join }\n switches = objects.select{ |o| o[0] == id + 1 }.map{ |o| o.map{ |b| [b.to_s(16).rjust(2,\"0\")].pack('H*')[0] }.join }\n object_data << doors.zip(switches).flatten.join\n end\n }\n map_data = tile_data + object_counts.ljust(80, \"\\x00\") + object_data\n when \"old\"\n header = \"00000000\"\n tile_data = tiles.flatten.map{ |t| t.to_s(16).rjust(2,\"0\").reverse }.join\n objs = objects.map{ |o| o.dup }\n doors_exit = objs.select{ |o| o[0] == 3 }.zip(objs.select{ |o| o[0] == 4 }).map{ |p| [3, p[0][1], p[0][2], p[1][1], p[1][2]] }\n doors_lock = objs.select{ |o| o[0] == 6 }.zip(objs.select{ |o| o[0] == 7 }).map{ |p| [6, p[0][1], p[0][2], p[0][3], p[1][1], p[1][2]] }\n doors_trap = objs.select{ |o| o[0] == 8 }.zip(objs.select{ |o| o[0] == 9 }).map{ |p| [8, p[0][1], p[0][2], p[0][3], p[1][1], p[1][2]] }\n objs = objs.select{ |o| ![3,4,6,7,8,9].include?(o[0]) }.+(doors_exit).+(doors_lock).+(doors_trap).sort_by{ |o| o[0] }\n entities = (0..25).to_a.map{ |id| [id, []] }.to_h\n objs.each{ |o|\n s = o[1..OBJECTS[o[0]][:att]].map{ |a| a.to_s(16).rjust(2, \"0\").reverse }.join\n entities[OBJECTS[o[0]][:old]].push(s)\n }\n object_data = entities.map{ |k, v| v.size.to_s(16).rjust(4, \"0\").scan(/../m).map(&:reverse).join + v.join }.join\n footer = \"00000000\"\n map_data = header + tile_data + object_data + footer\n else\n print(\"ERROR: Incorrect type (new, old).\")\n return 0\n end\n map_data\nend",
"def initialize\n @map = []\n 8.times do |x|\n row = []\n 8.times { |y| row << nil }\n @map << row\n end\n end",
"def populate_map(map, n)\n ret = Array.new\n\n n.times do\n begin\n x, y = [rand(map.width), rand(map.height)]\n end while(not empty?(x,y,map)) \n \n creat = CreatureGenerator.create_random(self, x, y)\n ret << creat\n end\n \n return ret\n end",
"def create_tilemap\n @tilemap = Tilemap.new(@viewport1)\n @tilemap2 = Tilemap.new(@viewport4)\n @tilemap.map_data = $game_map.data.clone\n @tilemap2.map_data = $game_map.data.clone\n result = []\n for i in 0..@tilemap2.map_data.xsize\n for j in 0..@tilemap2.map_data.ysize\n for k in 0..@tilemap2.map_data.zsize\n if ($game_map.region_id(i,j) - @etage) <= 1\n @tilemap2.map_data[i,j,k] = 0\n else\n unless Etage::MAP.include?($game_map.map_id)\n @tilemap2.map_data[i,j,k] = 0\n end\n end\n end\n end\n end\n load_tileset\n end",
"def map_board\n\t\t@cell_at = []\n\t\t@height.times do |row|\n\t\t\t@cell_at[row] = []\n\t\t\t@width.times do |col|\n\t\t\t\t@cell_at[row][col] = Cell.new\n\t\t\tend\n\t\tend\n\tend",
"def setup_region_tile_mapping\n @region_tile_mapping = {}\n (0..63).each {|i| @region_tile_mapping[i] = []}\n for x in 0..data.xsize\n for y in 0..data.ysize\n @region_tile_mapping[region_id(x, y)] << [x,y]\n end\n end\n end",
"def create_static_map\n path_array = coordinates_string.split(\"|\")\n\n while path_array.length > 70\n path_array = reductionPath(path_array)\n end\n coordinates_string_temp = \"\"\n path_array.each do |pos|\n # pos_array = pos.split(\",\")\n # lat = pos_array[0].to_f.round(6).to_s\n # lng = pos_array[1].to_f.round(6).to_s\n\n # coordinates_string_temp += \"|#{lat},#{lng}\"\n coordinates_string_temp += \"|#{pos}\"\n end\n \"http://maps.googleapis.com/maps/api/staticmap?path=color:0xc84446ff|weight:2#{coordinates_string_temp}&size=79x79&sensor=false\"\n end",
"def create_world\r\n count = 1\r\n @height.times do |j|\r\n @width.times do |i|\r\n\t #this creates half water and half earth positions\r\n\t create_position(\"water\", i + 1, j + 1) if (count <= ((@width*@height) / 2))\r\n\t\tcreate_position(\"earth\", i + 1, j + 1) if (count > ((@width*@height) / 2))\r\n\t\t#create_position(\"earth\", i + 1, j + 1)\r\n\t\tcount += 1\r\n end\r\n end\r\n\tif @log == true\r\n\t @logger.write \"created world\"\r\n\tend\r\n end",
"def render_walls\n outputs.solids << grid.walls.map do |key, value|\n scale_up(key).merge(wall_color)\n end\n end",
"def generate\n (0..@horizontal_size-1).each do |column|\n (0..@vertical_size-1).each do |row|\n val = Settings.get_random.rand(0..10)\n @map[column][row] = val > 3 ? 1 : 2\n end\n end\n end",
"def generate\n cells.destroy_all\n \n x = 0\n while x < width do\n y = 0\n while y < height do\n cells.create(:x => x, :y => y)\n y += 1\n end\n x += 1\n end\n \n # A wall is like this: [cell1,cell2]\n walls = []\n \n cells.each do |cell|\n walls += ([cell]*4).zip(cell.neighbours)\n end\n \n walls.shuffle!\n \n walls.each do |cell, neighbour|\n cell.create_edge_to_and_from(neighbour) unless neighbour.nil? || cell.reachable?(neighbour)\n end\n \n @solution ||= cells.first.shortest_path_to(cells.last)\n end",
"def initWall\n startPoint = @@brickLength / 4\n height = 0\n for j in 0..14 do\n for i in 0..5 do\n vt = Vector3f.new(i * @@brickLength * 2 + startPoint, @@brickHeight + height, 0)\n makeBrick(vt)\n end\n startPoint = -startPoint\n height += 2 * @@brickHeight\n end\n end",
"def create_connection tile\n walls = @maze.get_adjacent_walls tile\n if walls.length>0\n @maze.size+=1\n walls.sample.type = 0\n end\n end",
"def setup_passability(map)\n # set map for further use and initialize\n @map, result = map, Table.new(map.width, map.height)\n # iterate through all each horizontal element\n (0...@map.height).each {|y|\n # prevent \"Script is hanging\" error if large map\n Graphics.update if @map.height * @map.width >= 19200 && y % 10 == 0\n # iterate through all each vertical element\n (0...@map.width).each {|x|\n # initialize value\n val = 0x00\n # add to value if virtually passable in each direction\n val |= 0x01 if passable?(x, y, 2) && passable?(x, y+1, 8)\n val |= 0x02 if passable?(x, y, 4) && passable?(x-1, y, 6)\n val |= 0x04 if passable?(x, y, 6) && passable?(x+1, y, 4)\n val |= 0x08 if passable?(x, y, 8) && passable?(x, y-1, 2)\n # add coordinate if passable anyhow\n result[x, y] = val if val != 0x00}}\n # remove map from memory\n @map = nil\n # return passable coordinates\n return result\n end",
"def _minimap_autotile\n b = Bitmap.new(24, 32)\n c1 = Color.new(191, 191, 191)\n c2 = Color.new(255, 255, 255)\n b.fill_rect(2, 0, 4, 1, c2)\n b.set_pixel(1, 1, c2)\n b.fill_rect(2, 1, 4, 6, c1)\n b.set_pixel(6, 1, c2)\n b.fill_rect(0, 2, 1, 4, c2)\n b.fill_rect(1, 2, 1, 4, c1)\n b.fill_rect(6, 2, 1, 4, c1)\n b.fill_rect(7, 2, 1, 4, c2)\n b.set_pixel(1, 6, c2)\n b.set_pixel(6, 6, c2)\n b.fill_rect(2, 7, 4, 1, c2)\n b.fill_rect(7, 8, 10, 1, c2)\n b.set_pixel(6, 9, c2)\n b.fill_rect(7, 9, 10, 22, c1)\n b.set_pixel(17, 9, c2)\n b.set_pixel(5, 10, c2)\n b.fill_rect(6, 10, 1, 20, c1)\n b.fill_rect(17, 10, 1, 20, c1)\n b.set_pixel(18, 10, c2)\n b.set_pixel(4, 11, c2)\n b.fill_rect(5, 11, 1, 18, c1)\n b.fill_rect(18, 11, 1, 18, c1)\n b.set_pixel(19, 11, c2)\n b.set_pixel(3, 12, c2)\n b.fill_rect(4, 12, 1, 16, c1)\n b.fill_rect(19, 12, 1, 16, c1)\n b.set_pixel(20, 12, c2)\n b.set_pixel(2, 13, c2)\n b.fill_rect(3, 13, 1, 14, c1)\n b.fill_rect(20, 13, 1, 14, c1)\n b.set_pixel(21, 13, c2)\n b.set_pixel(1, 14, c2)\n b.fill_rect(2, 14, 1, 12, c1)\n b.fill_rect(21, 14, 1, 12, c1)\n b.set_pixel(22, 14, c2)\n b.fill_rect(0, 15, 1, 10, c2)\n b.fill_rect(1, 15, 1, 10, c1)\n b.fill_rect(22, 15, 1, 10, c1)\n b.fill_rect(23, 15, 1, 10, c2)\n b.set_pixel(1, 25, c2)\n b.set_pixel(22, 25, c2)\n b.set_pixel(2, 26, c2)\n b.set_pixel(21, 26, c2)\n b.set_pixel(3, 27, c2)\n b.set_pixel(20, 27, c2)\n b.set_pixel(4, 28, c2)\n b.set_pixel(19, 28, c2)\n b.set_pixel(5, 29, c2)\n b.set_pixel(18, 29, c2)\n b.set_pixel(6, 30, c2)\n b.set_pixel(17, 30, c2)\n b.fill_rect(7, 31, 10, 1, c2)\n return b\n end",
"def establish_world(cell_width, cell_height)\n puts \"World is #{cell_width}x#{cell_height} cells\"\n @cell_width, @cell_height = cell_width, cell_height\n\n # Outer array is X-indexed; inner arrays are Y-indexed\n # Therefore you can look up @grid[cell_x][cell_y] ...\n # However, for convenience, we make the grid two cells wider, two cells\n # taller. Then we can populate the edge with Wall instances, and treat (0,\n # 0) as a usable coordinate. (-1, -1) contains a Wall, for example. The\n # at(), put(), and cut() methods do the translation, so only they should\n # access @grid directly\n @grid = Array.new(cell_width + 2) do |cy|\n Array.new(cell_height + 2) do |cx|\n Cell.new(cx-1, cy-1)\n end\n end\n\n # Top and bottom, including corners\n (-1 .. cell_width).each do |cell_x|\n put(cell_x, -1, Wall.new(self, cell_x, -1)) # top\n put(cell_x, cell_height, Wall.new(self, cell_x, cell_height)) # bottom\n end\n\n # Left and right, skipping corners\n (0 .. cell_height - 1).each do |cell_y|\n put(-1, cell_y, Wall.new(self, -1, cell_y)) # left\n put(cell_width, cell_y, Wall.new(self, cell_width, cell_y)) # right\n end\n\n self\n end",
"def make_room max_w,max_h\n\t{\n\t\tx: rand(@grid_w - max_w - 1) + 1,\n\t\ty: rand(@grid_h - max_h - 1) + 1,\n\t\tw: rand(max_w) + 1,\n\t\th: rand(max_h) + 1,\n\t}\n\tend",
"def trial_maps\n [\n Map.new(\n name: 'San Francisco',\n data: 'color_ff7575-00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000004000000000000000000000000000000000000000000000000000000000000000_00000000000004004004000000000000000000000000000000000000000000000000000000000000_00000000000000404040000000000000000000000000000000000000000000000000000000000000_00000000000000040400000000000000000000000000000000000000000000000000000000000000_00000110000044404044400000000000000000000000000000000000000000000000000000000000_00011111100000041400000000000000000000000000000000000000000000000000000000000000_00011111100000401040000000000000000000000000000000000000000000000000000000000000_00011000100004001004000000000000000000000000000000000000000000000000000000000000_00011111100000011100000000000000000000000000000000000000000000000000000000000000_00010010100000011100000000000000000000000000000044000000000000000440000000000000_00011111100000011100000000000000000000000000000011000000000000000110000000000000_00011111100000011100000000000000000000000000000011000000000000000110000000000000_00010011100000111110000000000000000000000000001011010000000000010110100000000000_04011111100000111110000000000000000000000000001011010000000000010110100000000000_44411010110000110010001110000000000000000000101011010100000001010110101000000000_14411111111100111110011111000000000000000010101011010100000001010110101010000000_11111111111101111111011101000000000000001010101011010101000101010110101010100000_11111011110111110011111111000000000000101010101011010101010101010110101010101003_11111111111110111111111111110000000010101010101011010101010101010110101010101011_11111111111111111111010011111444111111111111111111111111111111111111111111111111_11111111111111111111111111011110000001110000000011000000000000000110000000001111_11111111441111000111111111111111000001110000000011000000000000000110000000011111_11000111001101111111111144111111110111111110000011000000000000000110000000111111_11020000000000001111000000011111110111111110000011000000000000000110000001111111_11111111111111000000000011000000000111111110000011000000000000000110000001111111_11111111111111111111111111111111111111111110000111100000000000001111000001111111',\n skill_mean: 1,\n ),\n Map.new(\n name: 'The Bunker',\n data: 'color_8a8a5c-00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000001000000000000000000000000000000000000000000000000000000000000000000000000_02000011000000100000000000000000000000000000000000000000000000000000000000000001_11111111111000110000000000000000000000000000000000000000000000000000000000101111_11111111111111111101000000000000000000000000000000000000000000000010001111111111_11111111111111111111111000000000000000000000000000100000010001111111111111111111_11111111111111111111111110100000001111011110000001100001111111111111111111111111_11111111111111111111111111111000111550005511111111111111111111111111111111111111_11111111111111111111111111111111111550005511111111111111111111111111111111111111_11111111111111111111111111111111111150005111111111111111111111111111111111111111_11111111111111111111111111111111111150005111111111111111111111111111111111111111_11111111111111111111111111111111111150005111111111111111111111111111111111111111_11111111111111111111111111111111111150005111111111110000000111111111111111111111_11111111111111111101111111111111111150005111111111100000000011111111111111111111_11111111111111111111000000011111111150005111111111000111110001111111111111111111_11111111111111111111000000001111111150005111111110001111111000111111111111111111_11111111111111111111001111000111111150005111111100011111111100011111111111111111_11111111111111111111011111100011101150005110111000111111100110001111111111111111_11111111111111111111001111110001111150005111110001111111100011000001111111111111_11111111111111111111011111111000111150005111100011111111100001100001111111111111_11111111111111111111001111111100001150005110000111111111100000111001111111111111_11111111111111111111011111111110001150005110001111111100000000000001111111111111_11111111111111111111001111111111101150005110111111111000000000000001111111111111_11111110111111111101011111111111101100000110111111110001111111111111111111111111_11111111111111111111001111111101101100000110101111100011011111111111111111111111_11111111100000000000011111111111101100000110111111000111111111111111111111111111_11111111100000004000001111111111101100000110111000001100111111111111111111111111_11111111000000044400011111111111101100000110111000011000111111111111111111111111_10111110000000444444001111111111101000000010111000110000111111111111111111111111_11111100100000444444401111111111100000000000111011100000000011111111111111111111_11000001111111111111111111111111111100000111111000000000000001111111111111111111_11000011111111111111111111111111111100000111111111111111111000111111111111111111_11000011111111111110111111111110111100000111101111111111011100011111111111111111_11000001111111111111111111111111111100000111111111111111111110001111111111111111_11111100100000000011100000000011100000000000111000000001110011000001111111111111_10111110000000000011100000000011100000000000111000000001110001100001111111111111_11111111000000000511100000440011100000000000111000000001110000111001111111111111_11111111100003000551000000444001000000000000010000000000100000000001111111111111_11111111100011105555500004444400000000000000000000000000000000000001111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111',\n skill_mean: 2,\n ),\n Map.new(\n name: 'Caravel Ships',\n data: 'color_4d94ff-00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000400000000000000000000000_00000000000000000000000000000000000000000000000000400000100000000000000000000000_00000000000000000000000000000000000000000000000000100000100000000000000000000000_00000000000000000000000000000000000000000000000000100000100000000040000000000000_00000000000000000000000000000000000000000000000001100001100000000010000000000000_00000000000000000000000000000000000000000000000011100011100000000010000000000000_00000000000000000000000000000000000000000000000110100110100000000110000000000000_00000000000000000000000000000000000000000000001110100110100000001110000000000000_00000000000000000000000000000000000000000000001100101110100000001110000000000000_00000000000000000000000000000000000000000000011100101110100000011010000000000000_00000000000000000000000000000000000000000000011100101110100000011010000000000000_00000000000000000000000000000000000000000000011100101110100000011010000000000000_00000000000100000000000000000000000000000000001100100110100000111010000000000000_00000000001110001000000000000000000000000000001110100110100000111010000000000000_00000010000111011100000000000000000000000000001110100110100000111010000000000000_00000111000111001110000000000000000000000000000110100010100001111010000000000000_00000011000111001110000000000000000000000000000111100011100011111111000000000000_00000011000111001110000000000000000000000000000001100001100000000110000000000000_00000011000110001100000000000000000000000000000001100001100000000010000000000000_00000011000110001100000000000000000000000000000000100000100000000011100000000000_00000010000100001000000000000040000000111114444444144444144444444411100000000000_00001110000100001002000000004444000000000111111001111111111111001111110000000000_00001110000100011111100001111444111000000011100011100011100011100511100000000030_00001111111111111110000001111111110000000011100111140011100411110511100000011111_55551111111111111155555555111111155555555551100004444000004444000011155551111111_55555511111111111555555555555555555555555555111111144411144411111111555511111111_55555555555555555555555555555555555555555555551111111111111111111111555511111111_55555555555555555555555555555555555555555555555555555555555555551155555111111111_55555555555555555555555555555555555555555555555555555555555555555555551111111111',\n skill_mean: 3,\n ),\n Map.new(\n name: 'Tower in the Castle',\n data: 'color_c2e0ff-00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00050000000000000000000000000000000000000000000000000000000000000000000000000000_00010000000050000000000000000000000000000000000000000000000000000000000000000000_00010000000010000000000000000000000000000000000000000000000000000000000000000000_00515000000010000000500000000000000000000000000000000000000000000000000000000000_00111000000515000000100000000000000000000000000000000000000000000000000000000000_00111000000111000000100000000000000000000000000000000000000000000000000000000000_05111500000111000005150000000000000000000000000000000000000000000000000000000000_01111100005111500001110000000000000000000000000000000000000000000000000000000000_51111150001111100001110000000000000000000000000000000000000000000000000000000000_11111110051111150051115000000000000000000000000000000000000000000000000000000000_00111000011111110011111000000000000000000000000000000000000000000000000000000000_00111000000111000511111500000000000000000000000000000000000000000000000000000000_00111000000111000111111100000000000000000000000000000000000000000000000000000000_00111000000111000001110000000000000000000000000000000000000000000000000000000000_00111000000111000001110000000000000000000000000000000000000000000000000000000000_00101000000000000000000000000000000000000000000000000000000000000000000000000000_00100011111111000000301000000000000000000000000000000000000000000000000000000000_00100110111111111111111000000000000000000000000000000000000000000000000000000000_00001110111111111111111000000000000000000000000000000000000000000000000000000000_00011010111110000051115000000000000000000000000000000000000000000000000000000000_10001010111100000005150000000000000000000000000000000000000000000000000000000000_11100010111100000000100000000000000000000000000000000000000000000000000000000000_10110010111100000000500000000000000000000000000000000000000000000000000000000000_10011000111100000000000000000000000000000000000000000000000000000000000000000000_10001100111100000000000000000000000000000000000000000000000000000000000000000000_10100001111100000000000000000000000000000000000000000000000000000000000000000000_10100011111100000000000000000000000000000000000000000000000000000000000000000000_10100110111100000000000000000000000000000000000000000000000000000000000000000000_10101110111100000000000000000000000000000000000000000000000000000000000000000000_11100010111100000000000000000000000000000000000000000000000000000000000000000000_11110010111100000000000000000000000000000000000000000000000000000000000000000000_11111000111100000110110110000000001101101100000000000000000000000000000000000000_11111100111100000111111110000000001111111100000000000000000000000000000000000000_10101110111110000111111110000000001111111100000001000010000000000000000000000000_10101000111110000111111110000000001111111100000001000010000000000000000000000000_10100011111100000001111000000000000011110000000011000011000000000000000000000000_10100110111001101101111011011011011011110000000010000001000000000000000000000000_10001100110011111111111111111111111111110000000110000001100000000000000000000000_10011000100111111111111111111111111111110000000100000000100000000000000000000000_10110000001100000401111101111111110111110000001100000000110000000044000004000000_10000000011100000441111101111511110111110000001000000000010000000444000044400000_11110000111100404441111111115551111111110000011000000000011000000440000044000000_10111000111100444441111111115551111111110000010000000000001000000040000004000000_10101100000004444411111111115551111111111100110000000000001100000040000004000020_10101111111111111111111111115551111111111111110000000000001111111111111111111111_11111111111111111111111111111111111111111111110000000000001111111111111111111111_11111111111111111111111111111111111111111111110000000000001111111111111111111111_11111111111111111111111111111111111111111111110000000000001111111111111111111111',\n skill_mean: 5,\n ),\n Map.new(\n name: 'Cat Mountain Climb',\n data: 'color_f1f1fa-00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000003000000000000000000000000000000000000000000000000000000000000_00000000000000000011110000000000000000000000000000000000000000000000000000000000_00000000000000000001111000000000000000000000000000000000000000000000000000000000_00000000000000000000111100000000000000000000000000000000000000000000000000000000_00000000000000000000011114400000000000000000000000000000000000000000000000000000_00000000000000000000011111100000040000000000000000000000000000000000000000000000_00000000000000000000001111100000044000000000000000000000000000000000000000000000_00000000000000000000001111100000011000000000000000000000000000000000000000000000_00000000000000000000001111110000111000000000000000000000000000000000000000000000_00000000000000000000001111110001111100000000000000000000000000000000000000000000_00000000000000000000004111111001111100000000000000000000000000000000000000000000_00000000000000000000000111111101111110000000000000000000000000000000000000000000_00000000000000000000000111111101111110000000000000000000000000000000000000000000_00000000000000000000000411111111111111000000000000000000000000000000000000000000_00000000000000000000000011111111111111100000000000000000000000000000000000000000_00000000000000000000000001111111111111111000000000000000000000000000000000000000_00000000000000000000000001111111111111111100000000000000000000000000000000000000_00000000000000000000000001111111111111111110000000000000000000000000000000000000_00000000000000000000000000000000111111111111100000000000000000000000000000000000_00000000000000000000000001111100111111111111111100000000000000000000000000000000_00000000000000000000000001111100000111111111111111000000000000000000000000000000_00000000000000000000000001111110000111111100000111110000000000000000000000000000_00000000000000000000000011111111000111444400000000111000000000000000000000000000_00000000000000000000000011111111100000000000000000011000000000000000000000000000_00000000000000000000000011111111100000000000000000001100000000000000000000000000_00000000000000000000000011111111110000000000000000000110000000000000000000000000_00000000000000000000000011111111111111111111100111100110000000000000000000000000_00000000000000000000000011111111111111111111000011000110000000000000000000000000_00000000000000000000000011111111111111111111000011000111000000000000000000000000_00000000000000000000000011111111111111111111000015000511000000000000000000000000_00000000000000000000000011111111111111111111500511000511000000000000000000000000_00000000000000000000000011111111111111111111555511000511000000000000000000000000_00000000000000000000000111111111111111111111155515000511000000000000000000000000_00000000000000000000000111111111111111111111155115000511000000000000000000000000_00000000000000000000000111111111111111111111155111000511100000000000000000000000_00000000000000000000000111111111111111111111111111100511100000000000000000000000_00000000000000000000000111111111111111111111111111100001100000000000000000000000_00000000000000000000000111111111111111111111111111111001100000000000000000000000_00000000000000000000000111111111111111111100001101111001110000000000000000000000_00000000000000000000000111111111111111111000000000100000110000000000000000000000_00440000000000000000000111111111111111111000000000000000110000000000000000000000_00414000000000000000000111111111111111110000000000000001110000000000000000005000_00411400000000000000001111111111111111110000000000111111110000000000000000005000_00411140000000000000001111111111111111110005511111111111110000000000000005055500_00411110000000000000001111111111111111100011111111111111110000000000000005550500_00411100000000000000011111111111111111100011000001000000010000000000000000555500_00411000000000000000111111111111111111100000000000000000000000000000000055555500_00410000000000000000111111111111111111110000400000000111100000000000000000055550_00410000000000000011111111111111111111110004440004411111110000000000005000050000_00410000000000001111111111111111111111111044444441111111111000000000005500505550_00410000000000011111111111111111111111111444444411111111111100000000055000005000_00410000000000111111111111111111111111111111111111111111111111000000005000005000_00410000001111111111111111111111111111111111111111111111111111111000005000005000_00410200111111111111111111111111111111111111111111111111111111111111111000005000_11111111111111111111111111111111111111111111111111111111111111111111111111111111',\n skill_mean: 7,\n ),\n Map.new(\n name: 'Welcome',\n data: 'color_85e085-00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000444000000000000000000000000000000000000000000_00000000000000000000000000444000000000000000000000000000000000000000000000000000_00000000000000000444000000000000000000000000000000000000000000000000000100010000_00000000444000000000000000000000000000000000000000000055500000000000001100011000_02000000000000000000000000000001100000000000555000000000000000005555511100011155_11111111111111111111111111111111111111111111111111111111111111111111111100011111_11111111111111111111111111111111111111111111111111111111111111111111111100011111_11111111111111111111111111111111111111111111111111111111111111111111111100011111_11111111111111111111111111111111111111111111111111111111111111111111111100011111_55555555555555555555555555555555555555555555555555555555555555555555555500055555_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_01100100011101100101000011101101100000110101011101001001000110101100100001110110_01110110011101110111000011001101110000100111011101001001100111101110110001100010_01010111010101100010000010001101010000110101010101101101110101101110111011100110_00000000000000000000000000000000000000000000000000000000000000000000000000000100_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000100_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00001000100000000000000000000000000000000000000000000000000000000000000000000000_00011000110000000000000000000000000000000000000000000000000000000000000000000000_55111000111555555555555555555555555555555555555555555555555555555555555555555555_11111000111111111111111111111111111111111111111111111111111111111111111111111111_11111000111111111111111111111111111111111111111111111111111111111111111111111111_11111000111111111111111111111111111111111111111111111111111111111111111111111111_11111000111111111111111111111111111111111111111111111111111111111111111111111111_55555000555555555555555555555555555555555555555555555555555555555555555555555555_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_01001010001001101100110010000011101100010110101110101011101100111011101011011010_01111011001001001101111011000001001100010111101100101001001110111001001011011110_00110011101101101101001011100001001100010101101000101101001010101001001011010110_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000100010000_00000000000000000000000000000000000000000000000000000000000000000000001100011000_55555555555555555555555555555555555555555555555555555555555555555555511100011155_11111111111111111111111111111111111111111111111111111111111111111111111100011111_11111111111111111111111111111111111111111111111111111111111111111111111100011111_11111111111111111111111111111111111111111111111111111111111111111111111103011111_11111111111111111111111111111111111111111111111111111111111111111111111111111111',\n skill_mean: 8,\n ),\n Map.new(\n name: 'Moonlit Woods',\n data: 'color_944d94-00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000440000000000000000000_00000000000000000000000000000000000000000000000000000000044440000000000000000000_00000000000000000000000000000000000000000000000000000000004140000000000000000000_00000000000000000000000000000000000000000000000000004400000110000000000000000000_00000000000000000000000000000000000000000000000000000440000510000440000000000000_00000000000000000000000000000000000000000000000000000444000510000444000000000000_00000000000000000000000000000000000000000000000000000411000010000410000000000000_00000000000000000000000000000000000000000000000000000441100010000114400000000000_00000000000000000000000000000000000000000000000000000000110010001100000000000000_00000000000000000000000000000000000000000000000004440000110011001000000044440000_00000000000000000000000000000000000000000000000000144000011001011000000444440000_00000000000000000000000000000000000000000000000000104000011101110000000014400000_00000000000000000000000000000000000000000000004040114400051155100000001114000000_00000000000000000000000000000000000000000000000111114400005155150001111000000000_00000000000000000000000000000000000000000000000004111000000151151111000004440000_00000000000000000000000000000000000000000000000004011110000001151110000000140000_00000000000000000000000000000000000000000000000000040111000001100000000001140000_00000000000000000000000000000000000000000000000444000011110001110000011111000000_00000000000000000000000000000000000000000000044444000001111000110000111100000000_00000000000000000000000000000000000000000000000011000044011110110111110000004000_00000000000000000000000000000000000000000000000441100000001110110111100000044400_00000000000000000000000000000000000000000000000001111000000110110110000041444140_00000000000000000000000000000000000000000000000000111100000000110000000441011100_00000000000000000000000000000000000000000000000000111100000000110000004011110000_00000000000000000000000000000004440000000000000001100111111101111000001111114440_00000000000000000000000000000044400000000000000011500011111101111011111110011140_00000000000000000000000000000444000000000000000000500005151101111011111150050000_00000000000000000000000000000444000000000000000000500000050001111011550050000000_00000000000000000000000000000444000000000000000000000000000001111000500000000000_00000000000000000000000000000444000000000000000000000000000001111000000000000000_00000000000000000000000000000044400000000000000000000000000001101100000000000000_00000000000000000000000000000004440000000000000000000000000001130000000000000000_00000000000000000000000000000000000000000000000000000000000001111000000000000000_00000000000000000000000000000000000000000000000000000000000001111000000000000000_00000000000000000000000000000000000000000000000000000000000001111000000000000000_00000000000000000000000000000000000000000000000000000000000001111000000000000000_00000000000000000000000000000100000000000000000000000000000001111000000000000000_00000000000000001000000000000110000000000100000000000000010001111100000100101000_00000000000000001100010010101111010001010110000010000100010101111110010110101001_00000000000100011100010111101111010011111110000011001110111151111111111111111011_00000000001100011110110111111111111011111110000011001110111111111111111111111111_00000000011100011110111111111111111111101111000011101111111111111511111111111101_00000000011100111111111111101111111111111111000011111111111111111111111511111111_00000000111110111010110111111101111111110111000111111111115111111111111111111111_00000000101110111110111111111111111111111111100111111111111111111111111111111111_00000000111110001000010010100111010111111111000011110105111111111515511515111010_00000000001000501050010515150101010001010010055551515155515151111515515515151510_02000055551555551555515515155151515551515515555551515155515151111115515515151515_11111111111111111111111111111111111111111111111111111111111111111111111111111111',\n skill_mean: 10,\n ),\n Map.new(\n name: 'Egypt Pyramid',\n data: 'color_ff8844-00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000044400000000000000000000000000000000000000_00000000000000000000000000000000000004444444000000000000000000000000000000000000_00000000000000000000000000000000000044444444400000000000000000000000000000000000_00000000000000000000000000000000000044444444400000000000000000000000000000000000_00000000000000000000000000000000000444444444440000000000000000000000000000000000_00000000000000000000000000000000000444444444440000000000000000000000000000000000_00000000000000000000000000000000000444441444440000000000000000000000000000000000_00000000000000000000000000000000000044411144400000000000000000000000000000000000_00000000000000000000000000000000000044111114400000000000000000000000000000000000_00000000000000000000000000000000000001114111000000000000000000000000000000000000_00000000000000000000000000000000000011144411100000000000000000000000000000000000_00000000000000000000000000000000000111000001110000000000000000000000000000000000_00000050000000000000000000000000001110000000111000000000000000000000000000000000_00000555000000000000000000000000011100000000011100000000000000000000000000000000_00005555500000000000000000000000111000111110001110000000000000000000000000000000_00055000550000000000000000000001111000111110001111000000000000000000000000000000_00550000055000000000500000000011141000015100001411100000000000000000000000000000_05500000005500000005050000000111440000015100000441110000000000000000000000000000_55000000000550000050005000001114400000010100000044111000000000000000000000000000_50000000000055000500000500011144000000010100000004411100000000000000000000000000_00000000000005505000000000111440000000010100000000441110000000000000000000000000_00000000000000550000000001114400001001110111001000044111000000001000000001000000_00000000000000055000000011144000011101000101011100004411100000011100000011100000_00000000000000005500000111140000011111010101111100000411110000011100000011100000_00000000000000000550001111100004411144010104411144000011111000011100000011100000_00000000000000000000011111100004411144010104411144000011111100011100000011100000_00000000000000000000111411100001111111010101111111000011141115511100000011100000_00000000000000000001114411100001111111010101111111000011144111511100000011100000_00000000000000000011144010000004411144010104411144000000104411111100000011100000_00000000000000000111440010100004411144010104411144000010100441111100000011100000_00000000000000001114400010100000011100010100011100000010100044111100000011100000_00000000000000011144000000100000011101110111011100000010000004411100000011100000_00000000000000111140000011100000011101110111011100000011100000411110000011100000_00000000000001111100000011100000011100010000011100000011100000011111555511150000_00000000000011111100000011100000011100010100011100000011100000011111155511155000_00000000000111411111100011100011111101110111011111100011100011111111111111111100_00000000001114411111100011100011111101500051011111100011100011111111111111111100_00000000011144000001100011100011000001500051000001100011100011000000000000001100_00000000111440000000000011100000000001500051000005500011100000000000000000000000_02000001114400011100000011100000000001503051000055500511150000011111111111100000_11111111111111111111111111111111111111111111111111111111111111111111111111111111',\n skill_mean: 12,\n ),\n Map.new(\n name: 'The Cave',\n data: 'color_7a7a94-00000000000000000000000011111111111111111111111111111111111111111111111111111111_00000000000000000000001111111111111111111111111111111111111111111111111111111111_00000000000000000111111111111111111111111111111111111111111111111111111111111111_00000000000000001111111111111111111111111111111111111111111111111111111111111111_00000000000000011111111111555111111111111111111111111111111111111111111111055111_00000000000000011115511155055100000100011111111111111111111100000000000000005511_00000000000000055000500000000000000000000000001000001000011001111111111110000511_00000000000000050000000000000000000000000000001000100000000011111111111111100011_00000000000000000000001000000000500000000000000000100000000111111111111111100111_00000000000000000000011000000005500100000051500000110015000011111111111111100111_00000000000111111111111111111111511111111111111101111111110001111111111111110111_02000011111111111111111111111111111111111111111101111111111000000111111111110111_11111111111111111111111111111111111111111111111101111111111110000000000051110111_11111111111111111111111111111111111111111111111101111111111111111111110555110111_11111111111111111111111111111111111111111111111101111111111111111111111155110111_11111111111111111111111110000001111111111111111101111100011111111111111151110111_11111111111111111111111114000001111111111111111101111001001111110111111111110111_11111111111111111111111114444001111111111111111101111001100001110001111111110111_11111111111111111111111114444400000000000100100000011011111100111110011111110111_11111111111111111111111114444001111111110000000400011011111110011111011111110111_11111111111111111111111114444441111111111444444444411011111110001111100111110111_11111111111111111111111111111111111111111111144414411011111110001111110011100111_11111111111111111111111111111111111111111111111111111011100000000000000000000111_11111111111111111111111111111111111111111111111111111011011111111111111111100111_11111111111111111111111111111111111111111111111111111000111111111111111111001111_11111111111111111111111111111111111111101111111111111101111111111111111100111111_11111111111111111111111111111111111111011111001111111100111111111111100011111111_11300001111111111111111111111111111110011111100111111101111111111155001111111111_11111101111111111111111111111111111111011111110111111101111111115511111111111111_11111100000000000000000000000000000000011111110111111101111111155511111111111111_11111111111110011111111111111111100111000111110111111101111111151111111111111111_11111111501111011111111111111111111111110001110111111101111111155511111111111111_11111155511111000011111111111111111111111000000111111101111111111551111111111111_11111551111111110011111111111111111111111011111111111101111111111111111111111111_11111511111111110511111111111111111111111011111111111101111111111111111111111111_11111111111111105551111111111110000000000000511111111101111111111111111111111111_11111111111111105555111111111000111111111111155011111101111111111111111111111111_11111111111111155555111111111001111111111111111151111101111111111111111111111111_11111111111111111111111111110011111111111111111551111101111111111111111111111111_11111111111111111111111111110111111111111111111151111101111111111111111111111111_11111111111100000110011111110111111111111111111111111101111111111111111111111111_11111111111100000000000011110111115111111111111111111101111111111111111111111111_11111111111044400000000011110111551111111111111111111101111111111111111111111111_11111111111444440000000000000000011111111111111111111501111111111111111111111111_11111111111444444400511111110111111111111111105115115505111151111111111111111111_11111111111111111111111111110111111115555111500150555505555551511115111111111111_11111111111111111111111111110111111115550511000150005500550051551105511111111111_11111111111111111111111111110111111115000051000500000500500051500100515111111111_11111111111111111111111111000111111110000051000500000000500005000000510511111111_11111111111111100000000000000000000000000005000000000000500005000000010511111111_11111111111111110011111111111111111000000005000000000000000000000000050011111111_11111111111111110111111111111111111000000000000000000000000000000000050011111111_11111111111111100111111111111111111000000000000000000000000000000000000011111111_11111111111111101111111115555511111100000000000000000444000000000000000001111111_11111111111111101111111111111551111110000000000000004444400000000000000000111111_11111111111111101111111111111151111111000000000000044444444000000000010005111111_11111111111111110005011111111151111111000000000000044444444440000001010005511111_11111111111111111111050050555551111111111001111104444111144444010001510055111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111',\n skill_mean: 13,\n ),\n Map.new(\n name: 'Cyberpunk Ruins',\n data: 'color_3399aa-00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000111111110000000000000000000000000000_00000000000000000000000000000000000000000000000000100000000000000000000000000000_00000000000000000000000000000000000000111111111111111000000000000000000000000000_00000000000000000000000000000000000000010000000000000000000000000000000000000000_00000000000000000000000000000000000011111111111111111111000000000000000000004000_00000000000000000000000000000000000000010001000000100100000000000000000000044000_00000000000000000000000000000000011111110111111111110111111000000000000000044000_00000000000000000000000000000000000000010000000000000100000000000000000000044000_00000000000000000000000000000000000111110111111111110111000000000000000000044000_00000000000000000000000000000000000001110111000000010100000000000000000000011000_00000000000000000000000000000000000011110111100001110111000000000000000000011000_00000000000000000000000000000000000001500051000000114110000000000000000000011000_00000000000440000000000000000000000011103011100000114110000000000000000000111000_00000000000000000000004400000000000000111110000000114100000000000000000001111000_00000000000000000000000000000000000000044400000000114000000000000000000001111000_00000000000000000000000000000000000000000000000000114010000000000000000001111000_00000002000000000000000000004400000000000000000000104110000000000000000001001000_00000011111111111110000000000000000000000000000000014110000000000000000111111110_00000000111111110010000000000000000000000000000000114110000000000550000111001110_00000001111111111110000000000000000000000000000000114110000001111111111111111110_00000011111111110010000000000000001111111110000001114111000001144444444111001110_00000111111011111110000000000000001001100111000000010100000001100000000111111110_00001111111111110010000000000000001111111111100000010111114411100000000001001100_00011111111111110000000000000000001001111111110000010100000001100000000001001100_00111111111110010000000000000000000001111111111000010111144111100000000001001100_00111111111111110000000000000000000001111110011000010100000001100000000001001100_00110011111111110000000500000000000001111111111000010111441111100000101111111111_00111111111111110000005500000500001001101110011551010100000001100000100001001100_00110011111111111111111111111111111111111111111111011114411111100000110111111111_00111111111110010015555555555555001001111111011001010100000001100000110001001100_00111111111111111110050505555500001111111111111111011111441111100000111011111110_00111111111110010010050000550000001001111111011001010100000000000000111001001100_00111111111111110000000000500000001111111111111111011111144111110000111101111110_00110111101111110000000000500000051001101111111001010100000000000000100101001100_00111111111111110000000000000000051111111111111111010111114411111000111101111110_00111111111111110000000000000005551001100000011001010000000000000000100101001100_00111144444444111111111111111111111111111111111111011111111111111111111101111111_00111111111144111114440000000005551001100000000001000000000001100000100101001111_00111111111144110014400000000000551111100111111141011111114411114400000101111100_00111111110044111114000000000000051441100000011001005100000001100000000001001111_00110011110111110010000000000000051141110011111001005111144111111440000001111100_00111111110111111110000000000000001441100000011001005100000001100000000001001111_00000000000100110010000000000000000441111001111411011111441111111144000000111100_11111011111111111110000000000000000441100000011001000100000001100000000000001111_11111001111111110010000000000000000441111100111001000114411111111114400000011100_00110000000010110000000000000000000441100000011001000100000001100000000001001111_11110000000011110000000000000055000441111110011004000100000001100000000101001100_00110000000010110000000000055550000441100000011001000000000001100000000101001100_11111111110111111011111111111111111111111111011111111111111111111111111111101111_00110000000011000010000005555000001001100000011111000000000001100000011111101111_11110000000000011110000055000000001111104444000001000000000004400000000101001100_00110000000000110010005550000000001001100000011000000055000001100000000000001100_11111111111111111110055000000000001111111111111111111111111111111111111111111100_11111111101000110010000000000000001001111111111001000000000001100000000001001100_00110000000000110000000000000000000001111111111001000000000001100000000001001100',\n skill_mean: 15,\n ),\n Map.new(\n name: 'Steamport Town',\n data: 'color_ffbd7d-00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000110011111111110000000000000440000000000001110000000000000000_00000000000000000001111115555555111000000000000110000000000011111000000000000000_00000000000000000001111111111111111000000000011111100000000111511100000000000000_00000000000000000000110011111111114000000000044114400000000111151100000000000000_00000000000000000000000000000110000400411111114114111111100111151100000000000000_00000000000000000000000000000000000044000000044114400000000111151100000000000000_00000000000000000000000000000000000000000000011111100000000011111000000000000000_00000000000040000000000000000000000000000000044114400000000041110000000000000000_00000000000010000000000000000000011100001111114114111111400400100000000000000000_00000000000014000000000000000000111110000000044114400000044001110000000000000000_00000000000011000000000000000001115111000000011111100000000001110000000000000000_00000000000011000000000000000001111511000000011111100000000000000000000000000000_00000000000011000000000000000001111511000001115115111000000000000000000000000000_00000000000010000000000000000001111511000001111111111000000000000000000000000000_00000000000010000000000000000000111110000000011111100000000000000000000000000000_00000000000010000000000000000000011140000000011111100000000000000000000000000000_00000000000114000000000000000000001004000000044114400000000000000000000000000000_00000000000114400000000000000000011100400411114114111100000000000000000000000000_00000000001111440000000000000000011100044000044114400000000000000000000000000000_00000000011111140000000000000000000000000000011111100000000000000000000000000000_00000000111001110000000000000000000000000000011111100000000000000000000000000000_00000001110000110000000000000000000000000000111111110000000000000000000000000000_00000011140000110000000000000000000000000001111111111000000000000000000000000000_00000111440000110000000000000000000000000001100000000000000000000000000000000000_00001110440000110000000000000000000000000001104440111100000000000000000000000000_00011100440000110000000000000000000000000001104440011000000000000000000000000000_00111000440000110000000000000000000000000001104444011000000000000000000000000000_00110000440000110000000000000000000000000001104444011000000000000000000000000000_02114000440000110000000000000000000000000001104444011000000000000000000000000000_01111100440000110000000000000000000000000001100000011000000000000000000000000000_01111111111100110000000000000000000400000011101111011100000000000000000000000000_00110000000000110000000000000000000100000111100110011110000000000000000000000000_00110000000000110000000000000000004140000111110110111110000000000000000000000000_00110000000000110000000000000000001110000001100110011000000000000000000000000000_00110000000000110000000000000000041114000001100000011000000000000000000000000000_00110000440000110000000000000000411111400001104444011000000000000000000000000000_00110000440000110000000000000004111111140001104444011000000000000000000000000000_00110000440000114000000000000001111111110001104444011000000000000000000000000000_00110000440000114000000000000000000000000001104444011000000000000000000000000000_00110001111111111000000000000000011111000001104444011000000000000000000000000000_00110000000011111000000000000000011111000001104444011000000000000000000000000000_00110000000000110000000000000000011441000001100000011000000000000000000000000000_00110000000000110000000000000000011441000001101111011000000000000000010000000000_00110000440000110000000000000000011441000001101111011000000000000000111000100000_00110000440000110000000000000000011441000001101111011000000000001000011101110000_01111100440000110000000000000000011441000001100000011000000000011100011100111000_01111111111000110000000000000000011441000111101111011110000000001100011100111000_00110000000000110000000000000000011441000111101111011110000000001100011100111000_00110000000000110000000000000000011000000411101111011140000000001100011000110000_00110000440000114404404404404404411000000441100000011440000000001100011000110000_00110000440011111111111111111111111011111111111011111111111100001000010000100000_00110011111111111111111111111111111011111111111011111110000000111000010000100300_00110000000000111111000000000111111400111111100011111100000000111444414441111110_00110000000000111100000000000001111410011111001011111000000000111111111111111000_01111100440000111000000000000000111411001110011011111555555555111111111111115555_01111111111000110000000000000000011411104140111011011555555555551111111111155555_00440000000000000011000000000110000000004440000000011555555555555555555555555555_11111111111111111111000000000111111111111111100000011111111111111111111111111111',\n skill_mean: 16,\n ),\n Map.new(\n name: 'Find the Dragon',\n data: 'color_ccff99-00000000000000000000000000000000000000000111111111111111111111111111111111111111_00000000000000000000001111110000000000000111111000000550000001111111111111111111_00000000000000000000011111100000000000001111111000000550000001111111111111111111_00000000000000000000111111000000010000011111111000000550000001111110111111111111_00000000000000000000111110000001111000111111111000000550000001111100010101111111_00000000000000000000011111000111010001110000000000005555000000000000000000111111_00000000000000000011001111111100000001100111111000000000000001111111000000111111_00000000000000000111111111110000000011001111111000000000000001111111111100001111_00000000000000000111111111000000000110011111111000005555000001111111111111000011_00000000000000000000010111000000000000111111110000000550000000011111111111100051_00000000000000000000000101300111111111111111110111111111111111011111111111110001_00000000000000000000111111111111111111111111110111111111111111011111111111111001_00000000000000000000001111111111111111111400000011111111111110000004111111110001_00000000000000000000000001111111111111111444400411111111111110004044111100010011_00000000000000000000000000000001111111111444444411111111111114444444111101000011_00000000000000000000000000000000011011111111111111111110001111111111111101100011_00000000000000000000000000000000001011111111111111001000000011111111111100150111_00000000000000000000000000000000000010001111111110000000000000111111111110111111_00000000000000000000000000000000000000000111111000000000000000010001111110111111_00000000000000000000000000000000000000000011000000000000000000010001101110011111_00000000000000000000000000000000000000000011000000000000000000000000101111001111_00000000000000000000000000000000000000000010000000000000000000000000000111001111_00000000000000000000000000000000000000000000000000000000000000000000000111000511_00000000000000000000000000000000000000000000000000000000000000000000000011000051_00000000000000000000000000000000000000000000000000000000000000000000000011100001_00000000000000000000000000000000000000000000000000000000000000000000000001100001_00000000000000000000000000000000000000000000000000000000000000000000000001100001_00000000000000000000000000000000000000000000000000000000000000000000000001110001_00000000000000000000000000000000000000000000000000000000000000000000000001110001_00000000000000000000000000000000000000000000000000000000000000000000000000155001_00000000000000000000000000000000000000000000000000000000000000000000000000115001_00000000000000000000000000000000000000000000000000000000000000000000000000015001_00000000000000000000000000000000000000000000000000000000000000000000000000010001_00000000000000000000000000000000000000000000000000000000000000000000000000010001_00000000000000000000000000000000000000000000000000000000000000001010000000010001_00000000000000000000000000000000000000000000000000000000000000011110000000011001_00000000000000000000000000000000000000000000000000000000000000110110000000001001_00000000000000000000000000000000000000000000000000000000000000111110000000001001_00000000000000000000000000000000000000000000000000000000001000000110100000001001_00000000000000000000000000000000000000000000000000000000001100111110110000001001_00000000000000000000000000000000000000011444400000000000000110001100110000011001_00000000000000000000000000000000000001111111140000000000000011111111110000010001_00000000000000000000000000000000000111111111140000000000000001101100110000110011_00000040000000000000000000000000000111111000040000000000000000001100110000110051_10000444000400000000000000000000001111110000040000000000000000011110110001110001_11000444000440000010000000000000011111100000040000000000000000011110000011111001_11100040004444000111000000000000011111100000040000000000000000111111100111110001_11111040000444001111100000000001111111100000040000000000000011111111111111100001_11111140000040011111110000000011111111100000040000000000001111111111111111100111_11111110000040001404100000001111111111100000040000000000001111111111111111100011_11111111100040001020000000111111111111100000040000000000011111111111111111100001_11111111111111111111111111111111111111100000000000000001111111110551151111110001_11111111111111111111111111111111111111100000040000000111111111000051051051111001_11111111111111111111111111111111111111100000000000000011111111050000050001000001_11111111111111111111111111111111111111100000040000000001111110050000000000000011_11111111111111111111111111111111111111100000000000000001111111550000000011100001_11111111111111111111111111111111111111110000040000000001111111155000011111115001_11111111111111111111111111111111111111114444444444444444441144111444111111111111_11111111111111111111111111111111111111111444444444444444444444444411111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111',\n skill_mean: 19,\n ),\n Map.new(\n name: 'Star Hopping',\n data: 'color_a3a3cc-00000000000000000000055500000000044444440000000000000000000000000000000000000000_00000000000000000055511115000004444444440000000000000000100000000000000000000000_00000000000000005511111111110444440044440000000000000000000000000000000000010000_00000300000000051111111111111144000044400000000000000000000000000000000000000000_00001110000000511111011111111110000044400000000000000000000000000000000000000000_00011111000005111111111001111111000444000000000000000000000000000001000000000000_00111111100001111011110000111111100444000000000000000000000000000011100000000000_00111111100051110011111001111111104440000000000000000000000000000001000000000000_00011111000011111111111111110011114440000000000000001000000000000000000000000000_00001110000011111111111111110111144400000000000000011100000000000000000000000000_00101010100011111111011111111111444400000000000000001000000000000000000000000000_00111111100111101111111111111114444000000001000000000000000000000000000010000000_00110001100111111111111111111144441000000000000000000000000000000000000111000000_00100000100111111111111111111144411000000000000000000000000000000000000010000000_00100000100111111111111111111444111000000000000000000000000000000000000000000000_00000000000011111111111111114444110000000000000000000000000000000000000000000000_00000000000011111111111111144441110000000000000000000000000000000000000000000000_00000000000011111111111111444411110000011000000000000000000010000000000000000000_00000000000001111111111114444111100000111100000000000000000111000000010000000000_00000000000041111111111144441111100000111100000000000000000010000000000000000000_00000000000444111111114444411111000000011000000000000000000000000000000000000000_00000100004440011111144444111110000000000000000000000010000000000000000000000000_00001110044400001111444411111100000000000000000000000111000000000000000000000000_00000100044000000144444111110000000000000000000000000010000000000000000000000000_00000000444000004444441110000000000010000000000000000000000000000000000000001000_00000000444004444444400000000000000000000000000000000000000000000100000000000000_00000004444444444440000000000000000000000000000100000000000000001110000000000000_00010004444444440000000000000000000000000000000000000000000000000100000000000000_00111000444400000000000011100000000000000000000000000010000000000000000000000000_00010000000000000000000111110000000000000000000000000000000000000000000000000000_00000000000000000000001110111000000000000000000000000000000000000000001000000000_00000000111000000000001111101000000000000000000000000000000000000000011100000000_00000001110100000000001111111000000000000000000000000000000000000000001000000000_00000001111100000000000111110000000000000000000000000000000000000000000000000000_00000001111100000000100011100000000000000000000000000000000000000000000000000000_00000000111000000001110000000000000000000000001000000000000000100000000000000000_00000000000000000000100000000000000000000000011100000000000001110000000000000000_00000000000000000000000000000000000000000000001000000000000000100000000000000000_00000000000000000000000000000000000000010000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000111000000000000000000000000_00000000000000000000000000000000000000000000000000011111110000000000000000000000_00000000000000000000000000000000000000000000000000111111111000000000000000000000_00000000000000000000000000000000000000000000000001111011111100000000000000000000_00000000000000000000000000000000000000000000000001111111111100000000000000000000_00100000000000000000000000000000000000000000000011101111111110000000000000000000_00000000000000000000000000000000000000000000000011111111111110000000000000000000_00000000000010000000000000000000000000000000000011111111111110000000011000000000_00000000000111000000000000000000000000000000000001111111111100000000111100000000_00000000001111100000000000000000000011000000000001111011111100000000111100000000_00000000000100000000000000000000000110100000000000111111111000000000011000000000_00000000000120111100000000000000000111100000000000011111110000000000000000000000_00000000000111111111100011000000000011000000000000000111000000000000000000000000_00000000011111111111111011111000000000000000000000000000000000000000000000000000_00000000111111111111011101110000000000000000011000000000000000000000000000000000_00000001111110111111111110110000000000000000111100000000000000000000000000000000_00000011111111111111110111100000000000000000111100000000000000000000000000000000_00000011111111111111111111000000000000000000011000000000000000000000000000000000_00000111111111111111111111100000000000000000000000000000000000000000000000000000_00000111111111111110111111100000000000000000000000000000000000000000000000000000',\n skill_mean: 22,\n ),\n Map.new(\n name: 'Shadow of Valus',\n data: 'color_ffeecc-00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000050000000000000000000000000000000000000_00000000000000000000000000000000500000000010000000000000000000000000000000000000_00000000000000000000000000000000100000001010500000000000000000000000000000000000_00000000000000000000000000000010100000011110100000000000000000000000000000000000_00000000000000000000000000000011111111111111100000000000000000000000000000000000_00000000000000000000000000000111111111111111111000000000000000000000000000000000_00000000000000000000000000101111111111111111111111000000000000000000000000000000_00000000000000000000000000111111111111111111111111100000000000000000000000000000_00000000000000000000000000111111111111111111111111111100000000000000000000000000_00000000000000000000000001111111111111111111111111111111100000000000000000000000_00000000000000000000000011111111111111111111111111111111111500000000000000000000_00000000000000000000000011111111111111111111111111111111110000000000000000000000_00000000000000000000000111111111111111111111111111111111110000000000000000000000_00000000000000000000000111111111111111111111111111111111111000000000000000000000_00000000000000000000000111111111111111111111111111111111111000000000000000000000_00000000000000000000000111111111111111111111111111111111111100000000050000000000_00000000001000000000000111111111111111111111111111111111111111000000010500000000_00000000000000000000000011111111111111111111111111111111111111111000010100000000_00000000000000000000000011111111111111111111111111111111111111111110011100000000_00000000000000000000000001111111111111111111111111111111111111111111011110000000_00000000000000000510000001111111111111111111111111111111111111111111111111000000_00000000000000000011000001111111011111101111111111111111111111111111111111100000_00000000000000000010000000111111111111111111111111111111111111111111111111100000_00000000000000000000000000111111111111111111111111111111111111111111111111110000_00000000000000000000000000111111111111111111111111111111111111111111111111110000_00000000000000000000001000111111111111111111111111111111111111111111111111110000_00000000100000000000000000111111111111111111111111111111111111111111111111110000_00000000000000000000000000411111111111111111111111111111111111111111111111115000_00000000000000000000000000411111111111111111111111111111111111111111111111115000_00000000000000000000000000041111111111111111111111111111111144411111111111115000_00000000000000000001000000041111111111111111111111111114444444441111111111110000_00000000000000000001100000004411111111111111111111111114000000004111111111110000_00000000000000000005100050000441111111111111111111111300000000000441111111110000_00110000000000000005100005000411111111111111111111111110000000000041111111100000_00111000000000000005000000000111111111111111111111111111000000000011111111110000_00511000000000000000000000000111111111111111111111111111100000000011111111110000_00015000000010000000000000001111111111111111111111111111100000000001111111100000_00010000000000000000000001111111111111111111111111111111100000000011111111110000_00000000000000000000000000111111111111111111111111111111100000000001111111100000_00000000000000000000000001111111111111111111111111111111100000000011111111100000_00000000000000000000000011111111111111111111111111111111100000000111111111100000_00000000000000000000001111111111111111111111111111111111100000011111111111110000_00000000000000000000000111111111111111111111111111111111110000011111111111110000_00000000000000000000000111111111441111111111111111111111110000111111111111111000_00000000000001111000000111111111444111111111111111111111110000111111111111111000_00000000000005110000001111111110004111111111110111111111110000111100111111111000_00000000000000510000001111111111004111111111000111111111110000111100111111111000_00000000000000010000001111111111004111111110000111111111110000111001111111111000_00000000000000000000001111111111004111111110000111111111110000011111111111110000_00000000000000000000001111111111001111111110000011111111100000000111111111100000_00000000000000000000000111111111001111111100000011111111100000000111111111000000_00000000000000000000000111111111001111111000000011111111100000000001111110000000_00000021100000000011000011111100001111111000000001111111110000000000000000000000_00000111000000000050000000000000011111111000000001111111110000000000000000000000_00000101000005500000050000000000011111111000000000111111111000000000000000000000_11111111111111111111111111111111111111111111111111111111111111111111111111111111',\n skill_mean: 25,\n ),\n Map.new(\n name: 'The Cube',\n data: 'color_d2eed7-11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111_11111111111111110001000111111000000001111110000000011111100000000111111000000021_11111111111111110101010111111000000001111110000000011111100000000111111000000001_11111111111111110101010111111005555001111110055550011111100000000111111004444001_11111111111111114141414111111005555001111110055550011111100000000111111004444001_11111111111111114141414111111005555001111110055550011111100004444111111004444001_11111111111111110101010111111005555001111110055550011111100004444111111004444001_11111111111111110101010111111000000001111110000000011111100004444111111000000001_11111111111111130100010111111000000001111110000000011111100004444444000000000001_11111111111111111111110111111111111111111111111111111111111111114444000011111111_11111111111111100044000111111111111111111111111111111111111111114444000011111111_11111111111111101111111111111111111111111111111111111111111111114444000011111111_11111111111111100044000111111111111111111111111111111111111111110000000011111111_11111111111111111111110111111111111111111111111111111111111111110000000011111111_11111111111111100044000111111111111111111111111111111111111111110000000011111111_14444444411111101111111111111000000001111110000000011111100000000000000000000001_14411114411111100044000111111000000001111110000000011111100000000111111000000001_14111111411111111111110111111005555001111110044440011111100000000111111000000001_14151151411111100044000111111005555001111110044440011111100000000111111000000001_14111111411111101111111111111005555001111110044440011111100005555111111000055551_14114411411111100044000111111005555001111110044440011111100005555111111000055551_14444444411111111111110111111000000001111110000000011111100005555111111000055551_14444444000000000000000111111000000000000000000000011111100005555555000000055551_11111111000000001111111111111111111100000000111111111111111111115555000011111111_11111111000000001111111111111111111100444400111111111111111111115555000011111111_11111111000000001111111111111111111100444400111111111111111111115555000011111111_11111111000000001111111111111111111100444400111111111111111111110000000011111111_11111111000000001111111111111111111100444400111111111111111111110000000011111111_11111111000000001111111111111111111100000000111111111111111111110000000011111111_11111111000000000000000111111000000000000000000000011111111111110000000000055551_11111111111111100000000111111000000001111110000000011111111111111111111000055551_11111111111111100000000111111004444001111110000000011111111111111111111000055551_11111111111111100000000111111004444001111110000000011111111111111111111000055551_11111111111111100005555111111004444001111110000555511111111111111111111000000001_11111111111111100005555111111004444001111110000555511111111111111111111000000001_11111111111111100005555111111000000001111110000555511111111111111111111000000001_11111111000000000005555555000000000001111110000555555500001111110000000000000001_11111111000000001111115555000011111111111111111111555500001111110000000011111111_11111111000000001111115555000011111111111111111111555500001111110000000011111111_11111111000055551111115555000011111111111111111111555500001111110000000011111111_11111111000055551111110000000011111111111111111111000000001111110000555511111111_11111111000055551111110000000011111111111111111111000000001111110000555511111111_11111111000055551111110000000011111111111111111111000000001111110000555511111111_11111111000000000000000000000000000001111110000000000000000000000000555555500001_11111111111111100000000111111000000001111110000000011111100000000111111555500001_11111111111111100555500111111004444001111110044440011111100000000111111555500001_11111111111111100555500111111004444001111110044440011111100000000111111555500001_11111111111111100555500111111004444001111110044440011111155550000111111555500001_11111111111111100555500111111004444001111110044440011111155550000111111000000001_11111111111111100000000111111000000001111110000000011111155550000111111000000001_11111111111111100000000111111000000000000000000000011111155550000000000000000001_11111111111111111111111111111111111100000000111111111111111111110000000011111111_11111111111111111111111111111111111100000000111111111111111111110000000011111111_11111111111111111111111111111111111100000000111111111111111111110000000011111111_11111111111111111111111111111111111100000000111111111111111111110000000011111111',\n skill_mean: 27,\n ),\n Map.new(\n name: 'Temple City',\n data: 'color_cfcfe6-00000000000000000000000000000000000000000000000000000000000000000000000000000002_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000044000000000000000000000000000_00000000000000000000000000000000000000000000111111144000000000000000000000111111_00000055000000000000000000000000000000000005511111111000000000000000011111111111_00000000550000000000000444000000000000055555511111111000000000005555111111111111_00000000055500000000000044400000000000555555551111111000000000000055555555511111_00000000000550000000000000000000000000000000055551111000000000000000000005555111_00000000005555555000001111111111000000000000000000000000000000000000000000000000_00000000000005555555511111111100000000000000000000000000000000000000440000000000_00000000000000055555511111111000000000000000000000000000555111111111440000000000_00000000000000000005551111110000000000000000000000000055555511111111110000000000_55500000000000000000055111000000000000000000000000000000005555111111110000000000_05555511100000000000000000000000000000000000000000000000000055551110000000000000_00051111000000000000000000011100000000000000000000000000000000000000000000000000_00005110000000000000000000551100000005511110000000000000000000050550000000000000_00000000000000000000000000000000000000051100000000000000000005555555000050000000_00000000000000000000000000000000055500000000000000000000000555555555555500000000_00000000000000000055551100555555555555000000000000000000555550005005055550050000_00000000000010100000555555555055101555505550000000000505550050000000005555555005_00000000000110110000555555500001101100555555550550055555550000000000000000555555_00000000000110110055550000000001101100005555555555555555500000000000000000005505_00000000011110111155500000000111101111000000550005555500000000000000000000000555_00000000011500051150000000000115000011000000000005550000000000000000000000000005_00000000011500551150000000000000000511000000000055500000000000000000000000000000_00000555011500051100000000005110000511000000005055000000000000000000000000000000_50555551111100111111100055111111100111110000000550500000000000000000000000000000_55055551150001151441100005114415110000110000005500000000000000000000000000000000_55550551150011551441100000114415511000110000555500000000000000000000000000000000_55555551100110051441100000114415001100110055555000000000000000000000000000000000_55000001100000001441100000114410000000110005550000000000000000000000000000000000_00000001111000001441100000114410000011115555550000000000000000000000000000000000_00000001101100001441100000114410000115115555000000000000000000000000000000000500_00000001100110000001100000110000001155115000000000000000000000000000000000005500_00000001111111011111100000111111011151115000000000000400400400000000000055505000_00000001100400001441100000114410000555150000000000000101110100000000000050550000_00000001100400001441150000114410000555510000000000000111511100000000000000055550_00000001104440001441150000114410005550115000000000040001510004000000000000005550_00000001100400001441100000114410005500115500000000010111511101000000000005505050_00000001100000001441150000114410055000100555000000011155555111000000000555055000_00000001100000001441155000114410050000000005000004000111111100040000005000055000_00000001100000000001100000110000000000110000000001011155555111010000005500005050_00000001111001111111100000111111110011110000000001110000000001110000000000055500_00500001101100051551100055115515000115110000000400011111111111000400000000005500_05500001100110051551100005115515001155110000000101114444444441110100000000000500_05505001111111011111100000111111011111110000000111000000000000011100000000000500_00555001100400000001100000110000000400110000000010040040004004001000000000005500_00500001100400000001100000110000000400115000000010010010001001000000000000055500_00500001104440000001100000110000004440115000000111111111011111111100000000555000_00500001100400000501100000110000000400115500001111111111011111111110000005555500_11111111100000005500000000000000000000111111111111111111011111111111111111111111_11111111111111111111111111111111111111111111111111111111011111111111111111111111_11111111111111111111111111111111111111111111111111111111011111111111111110000011_11111111111111111111111111111111111111111111111111111111011100110011001110030011_11111111111111111111111111111111111111111111111111111111000000000000000000111011_11111111111111111111111111111111111111111111111441144111011111111111111111111111_11111111111111111111111111111111111111111111111440044000011111111111111111111111_11111111111111111111111111111111111111111111111111111111111111111111111111111111',\n skill_mean: 30,\n ),\n Map.new(\n name: 'Moon Launcher',\n data: 'color_7070ae-00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000050000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000005000000000050000000000000000000000050000000000000005000000000000_00000000000000000000000000000000000050000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000005000_00000000005000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000011100000000000000000000000000_00000000000000000000500000000000000000000000000000111110000000000000000000000000_00000000000000000000000000000000000000000000000001101111000050000000000000000000_00000000000000000000000000050000000000000000000001111011000000000000000000000000_00000000000000000000000000000000000000000000000001101111000000000000044440000000_00000000000000000000000000000000000000000004000000111110000000000000411114400000_00000000000000000000000000000000000000000004000000011100000000000000111111140000_05000000000000000000000000000000000000000004000000000000000000000000000111114000_00000000000000000000000000000050000000000000000000000000000000000000000011111000_00000000000000000000000000000000000000000004000000000050000000000000000011111400_00000000500000000000500000000000000000000000000000000000000000000000000001111100_00000000000000000000000000000000000000000000000000000000000000000000000001111100_00000000000000000000000000000000000000000004000000000000000000000000000001111100_00000000000000000000000000000000000000000000000000000000000000000000000001111100_00000000000000000000000000000000000000000000000000000000000000000000000011111000_00000000000000000000000000000000000000000000000000000000005000000000000011111000_00000000000005000000000000000000005000000004000000000000000000000000030111110000_00000005000000000000000000000000000000000000000000000000000000000000111111100000_00000000000000000000000000000000000000000000000000000000000000000000011110000000_00000000000000000000000000000000000000000010100000000000000000000000000000005000_00000000000000000000000000000000000000000114110000000000000000000000000000000000_00000000000000000000000000005000000000000110110000000000000000000000000000000000_00000000000000000000000000000000000000000110110050000000000000000000000000000000_00000000000000000000000000000000000000000110110000000000000000000000000000000000_00000000000000000000000000000000000000000114110000000000000500000000000000000000_00000000000000000000000000000000000000000110110000000000000000000000000000000000_00000500000000000000000000000000000000000010100000000000000000000000000000000000_00000000000000000000000050000000000000000114110000000000000000000000000000000000_00000000000000000000000000000000000000000010100000000000000000000000000000000000_00000000000000000000000000000000000000000110110000000000000000000000000000000000_00000000000000000000000000000000000000000014100000000000000000000000000000000000_00000000000000000000000000000000000000000110110000000000000000000000000000000000_00000000000000000000000000000000000000000010100000000000000000000000000000000000_00000000000000000000000000000000000000000014100004440000000000000000000000000000_00000000000000000000000000000000000000000010100000000000000000000000000000000000_00000000000500000000000000000005000000000010100000000000000500005000000005000000_00000000000000000000000000000000000000000014100000000000000000505000000000000000_00000000000000000000000000000000000000000010105500000051111111111111111111111101_05000000000000000000000000000000000000055014105500000051115101515101010101010001_00000000000000000000000000000000000000055010105500000051010000005000000000010111_00000000000000000000000000000000000000011014101100000000000000000000000101010001_00000000000000000000000000000000000000011010101100000000000000000000000111011101_00000000000000000000000000000000000444011004001100000000004400000000000001010001_00000000000000000000000000000000000444011111111101111111111100000000000001010111_00001001110101011010110101010001100111011111111100100001001100044000000001000001_00001001110101011110100111011001110111111110111100100411000000011000000001010111_00001101010111010110110101011101010010011510151101110001000011111111100001010001_00000000000000000000000000000000000010011510151101110411000011010000000001011101_11111111111111111111111111111111111111111510151100000001000000010000000001010001_00000000000000000000000000000000000000011511151100000411000000010000000001010111_00000000000000000044400000004440000000111111111110000001000500010000050001010001_00000000000000000000000000000000000000111110111110000411055550010005555551011101_02000000000000000000000000000000000000000000000000000001555555515555555511110001_11111111111111111111111111111111111111111111111111111111111111111111111111111111',\n skill_mean: 32,\n ),\n Map.new(\n name: 'Garden of Giants',\n data: 'color_ecbfc4-00000000000000000000000000000000000000000000000000000000000000000000000444410000_00000000000000000000000000000000000000000000000000000000000000000000000044410000_00000000000000000000000000000000000000000000000000000000000000000000000004410000_00000000000000000000000000000000000000000000000000000000000000000000000000410000_00000000000000000000000000000000000000001000000000000000000000000000000000010000_00000000000000000000000000000000000000001000000000000000000000000000000000010000_00000000000000000000000000000000000000001000000000000000000000000000000000010000_00000000000000000000000000000001000000001000000000000000000000000000000000010000_00000000000000000000000000000001000000000000000000000000010000000000000000000000_00000000000000000000000000000001000000000000000000000000010000000000000000000000_00000000000000000000000000000001000000000000000000000000010000000000000000000000_00000000000000000000000000000001000000000000000000000000010000000000000000000000_00000000000000000000000000000000000000000000000000000000010000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000100000000000000000000000000000004400000000_00000000000000000000000000000000000000100000000000000000000000000000001100000000_00000000000000000000000000000000000000100000000000000000000000001000001101000000_00000000000000000000000000000000000000100000000000000000000000001000001111100000_00000000000000000000000000000000000000100000000000000000000000001000001110110000_00000000000000000000000000000000000000100000000000000000000555000000001100011000_00000000000000000000000000000000000000100000000000000000005505500000011001001100_00000000000000000000000000000000000000100000000000000000055000550000111011101110_00000000000000000000000000000000000000000000000000000000005050050000001011100000_00044440000000000000000000000000000000000001000000000000005550050000001011101000_00444400000000000000000000000000000000000001000000000000000000055000001000001000_00044000000000000040000000000000000000000000000000000000000000055000001000001001_00000000000000000000000000000000000000000000000000000014000000050000001110111001_10000000110000000000000000000000000000000000000000000014000000550000001110111011_10000001100000000000000000000000000000000000000000000014000000550000000010100011_10000011000000000000000000000000000000000000000000000014000055555000000010100011_10000110000440000000000000000000000000000000000000000014000555555000000010100011_11100000000444000000000000005000000000000000000000000014000550005500000010111111_10110000000000000000000000005500000000000000000000000014005550505500000010000001_10011000000000000000000000000500000000000000000000000014005550505500000010000001_10001100000000000000000000000500000000000000000005550014005550555000000011111101_10000000110000000000000000000501111444000000000050050014005550000000000011111101_10000001100000000000000000000500011111440000000050000014000550000000000001110101_10000011000000000000000000000550001011110000000005555014000505000000000000110101_10000110000000000000000000000050000010000000000000500514000555000000000000110001_11100000000000000000000000000055000010000000000005505514000055500005555000010001_10110000000000000000000000000005000000000000000005500010005055500055055555000001_10011000000000000000000000000005000000000000000000550010005005505550005555500001_10001100000000000000000000000005000000000000000000005010050005555500000005500001_10000000110000000000000000000005000000000000000000005515005055555000000005550001_10000001100000000000000000000055000000000000000000000515005555550000000000550001_10000011000000000000000000000050000000000000000000005015505550550000000300550001_10000110000000000000000000000050000000000000000000055015505000550000011100050001_11100000000000000000000000000050000000000000000500050555555000550000110000050001_10110000000000000000000000000055000000000000000500055055555500050001100000550001_10011000000000000000000000000055500000000000000500505555555550550000000005500001_10001100000000000000000000000005500000000000005500555055500505050000005555000001_00000000110000000000000000000000500000000000005000055055555005550000000555000001_00000001100000000000000000000055550000000000055500050555505055050111000000000001_20000011000000000050000000000055550000000050055000550555005555550001100000000001_11111110000005000050000000000055155000000555005500000555555055550000110000000001_10050050000055005550050000005005555005005515005055015555055555555500011000000001_10555055500050555050555005550515015505550501000555555555005005050500001100000001_10555555555050555555055055505555555115055100550510555555015505555505000110000001_15555555555555555555555555515555555555550505505055500155505550055055500011111111',\n skill_mean: 34,\n ),\n Map.new(\n name: 'Pyramid Dimension',\n data: 'color_c17c7a-00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000555555555555555555555555555000000000000000000000000000_00000000000000000000000000055555555555555555555555550000000000000000000000000000_00000000000000000000000000005555555555555555555555500000000000000000000000000000_00000000000000000000000000000555555555555555555555000000000000000000000000000000_00000000000000000000000000000055555555555555555550000000000000000000000000000000_00000000000000000000000000000005555555555555555500000000000000000000000000000000_00000000000000000000000000000000555555555555555000000000000000000000000000000000_00000000000000000000000000000000055555555555550000000000000000000000000000000000_00000000000000000000000000000000005555555555500000000000000000000000000000000000_00000000000000000000000000000000000555555555000000000000000000000000000000000000_00000000000000000000000000000000000055555550000000000000000000000000000000000000_00000000000000000000000000000000000005555500000000000000000000000000000000000000_00000000000000000000000000000000000000555000000000000000000000000000000000000000_00000000000000000555555555555555000000050000055555555555555555550000000000000000_00000000000000000055555555555550000004444400005555555555555555500000000000000000_00000000000000000005555555555500000440050044000555555555555555000000000000000000_00000000000000000000555555555000004400050004400055555555555550000000000000000000_00000000000000000000055555550000004400050004400005555555555500000000000000000000_00000000000000000000005555500000001100050001100000555555555000000000000000000000_00000000000000000000000555000000000100010001000000055555550000000000000000000000_00000000000000000000000050000000000100010001000000005555500000000000000000000000_00000000000000000000000000000000000100010001000000000555000000000000000000000000_00000000000000000000000000000000000144414441000000000050000000000000000000000000_00000000000000000100000000000000000144414441000000000000000004000000000000000000_00000000000000001110000000000000000144414441000000000000000044400000000000000000_00000000000000011111000000000000000144414441000000000000000444440000000000000000_00000000000000111111100000000000000100414001000000000000004444444000000000000000_00000000000005555555550000000000000100414001000000000000011111111100000000000000_00000000000000555555500000000000000100414001000000000000001111111000000000000000_00000000000000055555000000000000000102414001000000000000000111110000000000000000_00000000000000005550000000500000000111111111000000004000000011100000000000000040_00000000000050000500000005550000000000010000000000044400000001000050000000000440_00000000000555000000000055555000000000111000000000444440000000000555000000004440_00000000005555500000000555555500000001111100000004444444000000005555500000044440_00000000055555550000001111111110000011111110000011111111100000055555550000111110_00000000555555555000000111111100000111111111000001111111000000555555555000011110_00000005555555555500000011111000001111111111100000111110000005555555555000001110_00000055555555555550000001110000011111111111110000011100000055555555555000000110_00000555555555555555000000100000111111111111111000001000000555555555555005000010_00005555555555555555500000000001111111111111111100000000005555555555555005500000_00055555555555555555550000000011111111111111111110000000055555555555555005550000_00555555555555555555555000000111111111111111111111000000555555555555555005555000_05555555555555555555555500001111111111111111111111100005555555555555555005555500_55555550555555555555555550011111111111111111111111110055555555555555555005555550_55555500055555555555555555111111111111111111111111111555555555555555555005555555_00000001000000005500000000000000000000000000000000000000000000000000000001000000_00000011100000005500000000000000000000000000000000000000000000000000000001100000_00000113110000005500111111111111100000000000001111111111111000000000000001110000_00110000000110005500011111111111000000000000000111111111110000000000000001111000_04144441444414005500011111111110000000015000000011111111100000001000000001111100_04144411144414005000010111111100000000115500000001111111000000011000000001111110_04144111114414005000010011111000000001115550000000111110000000111000000001111111_04141115111414000000010001110000000011115555000000011100000001111000000001111111_04111151511114000000010000100000000111115555500000001000000011111000000001111111_04111515151114000000010000000000001111115555550000000000000111111000000001111111_01111111111111000000010000000000011111115555555000000000001111111000000001111111_00555555555550000000010000000000000000000000000000000000000000000000000001111111_00055555555500000000010000000000000000000000000000000000000000000000000001111111_00005555555000000000000000000000000000000000000000000000000000000000000000000000',\n skill_mean: 38,\n ),\n Map.new(\n name: 'Diving with Whales',\n data: 'color_6c87d6-00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000555500000000000000000000000000000000000000_00000000000000000000000000000000000055000550000000000000000000000000000000000000_00000000000000000000000000000000000050000550000000055555000000000000000000000000_00000000000000000000000000000000000050005500000000550005500000000000005555500000_00000000000000000000000000000555000055000000000000550000550000000000055555550000_00000000000000000100000000000500500005550000000000550000550000000000555505550000_00200000000000000110000000000000500000005555555000055000550000000055500000055000_00100000000000000111100000000000500000000000000000000000550000505550000000005000_00110000000000001144100000000000500055500000000000000005500000000000000500050000_00011000000000001140110000000005000550050004000055555555000000000000000055500000_00001100000005001400110000005550005500000041000000000000000000000000000000000000_05000110001105511010111055555550005500000411000000000000000000000000000000000000_05550110111115110100111055050500005500004111000000000000000000000000000000000000_00055511100411101100000055005500000550001111000000000000000000000000000000000000_00005511004011101000111055500500000555000001030000000000000000000000000055500005_50050110040111011000115555555550115555501111111000550001110000000000000555000555_05555100401110010000115555115555555555555111115555555511111111110000055055555555_55551104011110100051155555555555555555555555555505501111111111111100000000055055_00011040011101100551155055505550000000055555500050011111111111111111000000000000_55510400111411000511000000000000000000000000000500111111111111111111111000000000_50011001114010000111000500000000000000000000005501111111111000001111111100000000_55501100040000110110500000000000000000000000055011111111100000000001110000000000_00005110400001155100000000000000000000000000055011111111100000000001110000000000_05505110000011551100000000000050000000000000050111111111100000000000111000000000_00501100001115511055550005555005500000000000050111111111110000000000000000000000_55501000011000111550055500000000000005500000501111111101111000000000000000000005_50010000000000000000000000000000005555000000501111111000111000000000000000000555_00115000000001100000000000000055550000000005001111110000000000000000000000055550_01155555000011000000000005505500000000000000001111100000000000000000000000000000_11555555555110000000000000000000000000000000000110000000000000000011110000000000_11111555511100000000000000000000000000000000055500000000000000001111100000000000_00111111110000000000055555555500000000000055500000000000000000011111100000000000_00000000000000000000111111115555500055005550000000000000000011111111000000000000_00100000000000000011111111111155555500555000000000000000001111111111110000000000_01111000000000000111111111111111555555000000000000000001111111111111111000000000_00100000000000000111111111111111100000000000000000000111111111111011111100000000_00000000000000000011111111111111111000110000000001111111111111100000011110000000_00000000000000000001111111111111111111111100000111111111111110000000000000000000_00000000000000000000011111111111111111111111111111111111111000000000000000000000_00000000010000000000001111111111111111111111111111111111110000000000000000000000_01000000111100000000000111111111111111111111111111111111100000000000000000000000_00000000010000000000000011111111111111111111111111111111000000000000000000000000_00000000000000000111000011111111111111111111111111111110000000000000000000001000_00000000000000000011100001111111111111111111111111111100000000000000000000011110_00001100000000000000000000111111111111111111111111110000000000000000000000001000_00000000000000000000000000011111111111111111111111000000000000010000000000000000_00000000000000000000000000011111111111111111111100000000000000000000000000000000_00000000000010000000000000011111111111111111110000000000000000000000000000000000_00000000000111110000000000011110011110000000000000000000000000000000000000000000_00000000000010000000000000011100011110000000000000000000001000000000000000000000_00001000000000000000000000111100011100000000000000000000000000000000000000000000_00011110000000000000000000111100011100000000000000000000000000000001000000000000_00001000000000000000000000111000011110000000000000001000000001000000000000000000_00000000001110000000000000011000001110000000000000011110000000000000000000000000_00000000001000000000000000000000000110000000000000001000000000000000000010000000_00000000000000000000000000000000000000000000000000000000001000000000000111100000_00000001000000000000000000000000000000000000000000000000011110000000000010000000_01000000000000000000000111000000000000011000000000000000001000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000',\n skill_mean: 40,\n ),\n Map.new(\n name: 'The Astral Ascent',\n data: 'color_ff6666-00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000050000000000000000000000000005000000000000000000000000000000_00000000000000000000000000000000004000000000000000000000000000000000000000000000_00000005000000000000000000000000000004000000000000000000000000000000000500000000_00000000000000000000000000000040000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000005000000000000000000000_00050000000000000000000000004000000000000000000500000000000000000000000000000000_00000000000000000040000000000000000000000000000000000000000000000000000000000000_00000000000000000400000000000000000000040000000000000000000000000000050000000000_00000000000000000000000000111100000000040000000000000505000055000000000000000000_00000000050000000000000005511500000000040000000000005555555500000000000000000000_00000000000000000000005555555505000000040000000500055550555555555000000000000000_00000000000000000000055500005055000000000000000505055550000005055500000000050000_00000000000000030000550000000005555000000000555555555500000000005550000000000000_00005000000001111155050000000400055501101100055550000000000000000050000000000000_00000000000001000155000000000000005550101000555500000000000000000050000000000000_00000000000001020150000000000000000550101005555050000000000000000050000000000000_00000000000041000150000000000000000555101005555000000005000000000000000000000000_00000000000011141110000000041114000051101105550000000000000000000000000000000000_00000000000001000100000000000100000555101555550000000000000000000000000000500000_00000005000001141100000000000100000055101555550000000000000000000000000000000000_00000000000001000100000000000100000005101555555500000000000050000000000000000000_00000000000001141100000000004100000055101555550000000000000000000000000000000000_00500000000041000100040000040100000005101555000000000500000000000005000000000000_00000000000011141110110000011111400001101100000000000000000000000000000000000000_00000000000001000000155555511111400555101555550000000000000000000000000000000000_00000000000001111111155555511111400055101555550500000000000000000000000000000000_00000000000005555500040044004400005555101555555050000000050000000000000000000000_00000500000005555500000000000000005555101555555505000000000000000000000000000000_00000000000005555500550055005500555555101555555055550000000000000000000000000000_00000000000005555500551155115511555555101555555555555500000000000000500000000000_00000000005005555500551155115511555555101555555555555550000000000000000000000000_00000000000005555500000044004400000400101555555505555500000000000000000000005000_00000000000005555500000000000000000000101555555505505050000000000000000000000000_00050000000005555511004055005500555000101555555550500055500500005550000000000000_00000000000005555511001155115511555000001555555555505505555055555005550000000000_00000000000005555500001155115511555111111555505500555055050000000000005000000000_00000000000005055500000005555555555555555555555505555555505000000000000000000000_00000000500000050500000005555555055555555555500555505505500000000000000000000000_00000000000000000500000000055555500005555505000000055505055505500000000000000000_00000000000000000500000000000500055500050000000000005055000555000000500000000000_00005000000000000000000000000000000000000000000000000055000000500000000000000000_00000000000000000000005000000000000000000000000000000050000000055500000000000000_00000000000000000000000000000000000000000000000000055500000000000550000000000000_00000000000000500000000000000000000000000000500000055500000000000050000000000000_00000000000000000000000005000000000000000000000000555000000000000055000000050000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000005000000000000000000000000000000000000000000_00000005000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000500000000000000000000_00000000000000000050000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000500000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000500000000000000000500000000_00005000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000050000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000000000000000000_55555555555555555555555555555555555555555555555555555555555555555555555555555555',\n skill_mean: 44,\n ),\n Map.new(\n name: 'Mothership Warp',\n data: 'color_339999-00000000000000000000000000000000000000000000000000000000000000000000000000000000_00000000000000000000000000000000000000000000000000000000000000000500000000000000_00000000000000000000000000000000000000000000000000000000000000000550000000000000_00000000000000000000000000000000000000000000000000000000000000000555000000000000_00000000000000000000000000000000000000000000000000000000000000000555000000000000_00000000000000000000000000000000000000000000000000000000000000000555000000000000_00000000000000000000000000000000000000000000000000000000000000000555000000000000_00000000000000000000000000000000000000000000000000000000000000000555000000000000_00000000000000000000000000000000000000000000000000000000000000000555000000000000_00000000000000000000000500000000000000000000000000000000000000000555000000000000_00000000000000000000000550000000000000000000000000000000000000000055000000000000_00000000000000000000000555000000000000000000000000000000000000000005000000000000_00000000000000000000000555000000000000000000000000000000000000000005000000000000_00000000000000000000000555000000000000000005000000000000000000000005000000000000_00050000000000000000000555000000000000000055000000000000000000000005000000000000_00055000000000000000000555000000000000000555000000000000000000000005000000000000_00055500000000000000000555000000000000000555000000000000000000000005000000000000_00055500000000000000000055000000000000000555000000000000000000000005000000000000_00055500000000000000000005000000000000000555000000000000000000000005000000000000_00055500000000000000000005000000000000000555000000000000000000000005000000000000_00055500000000000000000005000000000000000555000000000000000000000000000000000000_00055500000000000000000005000000000000000550000000000000000000000000000000000000_00005500000000000000000005000000000000000500000000000000050000000000000000000000_00000500000000000000000005000000000000000500000000000000550000000000000000000000_00000500000000000050000005000000005000000500000000000005550000000000000000000000_00000500000000000050000005500000055000000500000000000005550000000000000000000000_00000500000000000050000005550000555000000500000000000005550000000000000000000000_00000500000000000050000005555005555000000500000000000005550000000000000000000000_00000500000000000010000055555005555500000500000000000005550000000000000000000000_00000500000000000010000055555005555500000100000000000005550000000000000000000000_00000500000000000010300055555005555500020100000000000005550000000000000000000000_00000000000000000011110055555005555500111100000000000005550000000000000000000000_00000000000000000015500055555005555500055100000000000005500000000000000000000000_00000000000000000015500055555005555500055100000000000005000000000000000000000000_00000000000000000015500055555005555500055100000000000005000000000000000000000000_00000000000000000015500055555005555500055100000000000005000000000000000000000000_00000000001111111115555555555005555555555100000000000005000000000000000000000000_00000000001555555555555555555005555555555100000000000005000000000000000000000000_00000000001000000000000055555005555500000100000000000005000000000000000000000000_00000000001000000000000005555005555000000100000000000005000000000000000000000000_00000000001000000000000000555005550000000100000000000005000000000000000000000000_00000000001004400000044000055005500000000100000000000005000000000000000000000000_00000000001001100000011000005005000000000100000000000005000000000000000000000000_00000000001001555555551000005000000000000100000000000005000000000000000000000000_00000000001000500000050000005000000000000100000000000000000000000000000000000000_00000000001000500000050000005000000000000100000000000000000000000000000000000000_00000000001000500000050000005000000000000100000000000000000000000000000000000000_00000000001000500000050000005000000000000100000000000000000000000000000000000000_00000000005000500050000000005000000000000100000000000000000000000000000000000000_00000000005000500050000000015000000000000100000000000000000000000000000000000000_00000000005000500050000000015000000000000100000000000000000000000000000000000000_00000000000000500050000001115000000000000100000000000000000000000000000000000000_00000000000000500055555555555555555500055100000000000000000000000000000000000000_00000000000000500000000000000000000000000100000000000000000000000000000000000000_00000000100000510000000000000000000000000100000000000000000000000000000000000000_00000000100000510044400000000000000000000100000000000000000000000000000000000000_00001111100000511111111000000000000000000100000000000000000000000000000000000000_00001000000000555555551000000000000000000100000000000000000000000000000000000000_00001000000000000000551000000000000000000100000000000000000000000000000000000000_00001000000000000000551000000000000000000100000000000000000000000000000000000000',\n skill_mean: 47,\n )\n ]\nend",
"def create_worldmap\n @pokemon_worldmap = GamePlay::WorldMap.new(:pokedex, $env.get_worldmap)\n @pokemon_worldmap.create_graphics\n end",
"def create_static_map\n legs = @itinerary.legs\n markers = create_markers\n polylines = create_polylines\n\n params = {\n 'size' => '700x435',\n 'maptype' => 'roadmap',\n }\n\n iconUrls = {\n 'blueMiniIcon' => 'https://maps.gstatic.com/intl/en_us/mapfiles/markers2/measle_blue.png',\n 'startIcon' => 'http://maps.google.com/mapfiles/dd-start.png',\n 'stopIcon' => 'http://maps.google.com/mapfiles/dd-end.png'\n }\n\n markersByIcon = markers.group_by { |m| m[\"iconClass\"] }\n\n url = \"https://maps.googleapis.com/maps/api/staticmap?\" + params.to_query\n markersByIcon.keys.each do |iconClass|\n marker = '&markers=icon:' + iconUrls[iconClass]\n markersByIcon[iconClass].each do |icon|\n marker += '|' + icon[\"lat\"].to_s + \",\" + icon[\"lng\"].to_s\n end\n url += URI::encode(marker)\n end\n\n polylines.each do |polyline|\n color = polyline['options']['color'].nil? ? \"0000ff\" : polyline['options']['color']\n url += URI::encode(\"&path=color:0x#{color}|weight:5|enc:\" + polyline['geom']['points'])\n end\n url += \"&key=#{ENV['GOOGLE_API_KEY']}\"\n return url\n end",
"def initialize\r\n @map_id = 0\r\n @display_x = 0\r\n @display_y = 0\r\n end",
"def create_map\n Array.new(32) do |x|\n Array.new(32) do |y|\n yield(x, y)\n end\n end\n end",
"def initialize(tiles = [], player)\n tiles.reject!{|p| p.x.nil? || p.y.nil? }\n\n @map = []\n @explored_area = []\n\n @known_floors = {}\n @last_seen_floors = {}\n @known_walls = {}\n @known_stashes = {}\n @seen_floors = {}\n @player = player\n\n x_dimension = tiles.map(&:x).sort.last\n y_dimension = tiles.map(&:y).sort.last\n\n if @@point_navigate_path.any? && !@@point_navigate_path.include?(@player.position)\n find_path_to_point(@@destination) # Our path has become corrupted - recalculate it!\n end\n @@free_space_path.delete(@player.position)\n @@point_navigate_path.delete(@player.position)\n\n tiles.each do |tile_point|\n coord = [tile_point.x, tile_point.y]\n case tile_point.type\n when 'floor'\n @known_floors[coord] = tile_point\n @last_seen_floors[coord] = -1\n when 'wall'\n @known_walls[coord] = tile_point\n when 'stash'\n @known_stashes[coord] = tile_point\n else\n raise \"Unknown type : #{tile_point.type}\" if tile_point.type\n end\n end\n\n for key in @last_seen_floors.keys\n @last_seen_floors[key] = @last_seen_floors[key] + 1\n end\n\n @pathfinder = Pathfinder.new(x_dimension, y_dimension)\n update_path_blocks(@known_walls.keys)\n\n create_map(x_dimension, y_dimension)\n end",
"def populate_caves\n for row_i in 1...@height - 1\n for column_i in 1...@width - 1\n if @map[row_i][column_i] == @FLOOR\n union_adjacent_square(row_i, column_i)\n end\n end\n end\n\n @disjoinset.split_sets()\n end",
"def initialize(hash)\n @graph = hash\n nodes = {}\n\n # initial values for min/max. note: these are the highest/lowest values of\n # lat/long possible, such that min is initially set to the highest\n # possible value, etc.\n @lat_min = 90\n @lat_max = -90\n @long_min = 180\n @long_max = -180\n\n # determine the extreme values\n @graph.each do |k,v|\n @lat_min = v[0] if v[0] < @lat_min\n @lat_max = v[0] if v[0] > @lat_max\n @long_min = v[1] if v[1] < @long_min\n @long_max = v[1] if v[1] > @long_max\n end\n\n # store the the highest and lowest (x,y) coordinates of the map\n @world_max = latlong_to_world Point.new(lat_max, long_max)\n @world_min = Point.new(0,0)\n\n # create a new node with world coordinates\n @graph.each do |k,v|\n world = latlong_to_world Point.new(v[0], v[1])\n nodes[k] = Node.new(world)\n end\n \n # now that all of the nodes have been created, we do a second\n # pass to get all of the references\n @graph.each do |k,v|\n v[2].each do |neighbor_k|\n nodes[k].neighbors << nodes[neighbor_k]\n end\n end\n\n @nodes = Set.new(nodes.values)\n @nodes.freeze\n\n # create a two-layered hash storing roads\n @road_hash = create_roads\n @road_set = road_set_from_hash @road_hash\n\n # clip all the walls\n clip_map\n end",
"def render_walls\n state.walls.each_key do |wall|\n outputs.solids << scale_up(wall).merge(wall_color)\n outputs.solids << move_and_scale_up(wall).merge(wall_color)\n end\n end",
"def check_map(map)\n\t\tways = Array2D.new(@width, @height, -1)\n\t\t@width.times do |x|\n\t\t\t@height.times do |y|\n\t\t\t\tpoint = Point.new(x, y)\n\t\t\t\tways[point] = 0 if ! map[point]\n\t\t\tend\n\t\tend\n\t\tways[@center] = 1\n\n\t\tnew_cells = true\n\t\tstep = 2\n\t\twhile new_cells\n\t\t\tnew_cells = false\n\t\t\t@width.times do |x|\n\t\t\t\t@height.times do |y|\n\t\t\t\t\tpoint = Point.new(x, y)\n\t\t\t\t\tif map[point]\n\t\t\t\t\t\tways[point] = -1\n\t\t\t\t\telsif ways[point] == 0\n\t\t\t\t\t\tif ways[point.up] == step - 1\n\t\t\t\t\t\t\tways[point] = step\n\t\t\t\t\t\t\tnew_cells = true\n\t\t\t\t\t\tend\n\t\t\t\t\t\tif ways[point.down] == step - 1\n\t\t\t\t\t\t\tways[point] = step\n\t\t\t\t\t\t\tnew_cells = true\n\t\t\t\t\t\tend\n\t\t\t\t\t\tif ways[point.left] == step - 1\n\t\t\t\t\t\t\tways[point] = step\n\t\t\t\t\t\t\tnew_cells = true\n\t\t\t\t\t\tend\n\t\t\t\t\t\tif ways[point.right] == step - 1\n\t\t\t\t\t\t\tways[point] = step\n\t\t\t\t\t\t\tnew_cells = true\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\t\tstep += 1\n\t\tend\n\n\t\t@width.times do |x|\n\t\t\t@height.times do |y|\n\t\t\t\tpoint = Point.new(x, y)\n\t\t\t\treturn false if ways[point] == 0\n\t\t\tend\n\t\tend\n\t\ttrue\n\tend",
"def idland\n render \"maps/idland\", :layout => false\n end",
"def build_resources\n delta = (MAP_ROWS + MAP_COLS) / (FOOD_NODE_COUNT + 1)\n distance = delta \n nodes = 0\n \n until nodes == FOOD_NODE_COUNT do\n r = rand( [MAP_ROWS, distance].min )\n c = distance - r\n\n next if c >= MAP_COLS or !@tiles[r][c].empty?\n\n @tiles[r][c].build_resource\n distance += delta\n nodes += 1\n end\n end",
"def generate\n carve maze.cell_at(0,0)\n maze\n end",
"def print_map\n (@height).times do |y|\n (@width).times do |x|\n if(is_solid?(x, y))\n print(\"#\")\n else\n print(\".\")\n end\n end\n print(\"\\n\")\n end\n end",
"def create_spaces\n ((@tiles, @tile_map),\n (@up_vtexs, @up_vtex_map),\n (@down_vtexs, @down_vtex_map),\n (@asc_edges, @asc_edge_map),\n (@desc_edges, @desc_edge_map),\n (@vert_edges, @vert_edge_map)) =\n [[Tile, nil, 1..5, [3,4,5,4,3], [1..3, 1..4, 1..5, 2..5, 3..5]],\n [Vtex, :up, 1..6, [3,4,5,6,5,4], [1..3, 1..4, 1..5, 1..6, 2..6, 3..6]],\n [Vtex, :down, 0..5, [4,5,6,5,4,3], [0..3, 0..4, 0..5, 1..5, 2..5, 3..5]],\n [Edge, :asc, 1..6, [3,4,5,5,4,3], [1..3, 1..4, 1..5, 2..6, 3..6, 4..6]],\n [Edge, :desc, 1..6, [3,4,5,5,4,3], [1..3, 1..4, 1..5, 1..5, 2..5, 3..5]],\n [Edge, :vert, 1..5, [4,5,6,5,4], [1..4, 1..5, 1..6, 2..6, 3..6]]\n ].map {|cls, align, row_interval, row_counts, col_intervals|\n rows = row_counts.zip(row_interval.to_a).map {|c, r| [r]*c}.flatten\n cols = col_intervals.map {|ival| ival.to_a}.flatten\n count = rows.length\n list = (0...count).to_a.map {|i| cls.new}\n list.each {|obj| obj.alignment = align} unless align.nil?\n list.zip(rows, cols).each {|obj, row, col| obj.row, obj.col = row, col}\n map = Hash[list.map {|obj| [[obj.row, obj.col], obj]}]\n [list, map]\n }\n\n @vtexs = @up_vtexs + @down_vtexs\n @edges = @asc_edges + @desc_edges + @vert_edges\n @all_spaces = @tiles + @vtexs + @edges\n\n @vtex_map = Hash[@vtexs.map {|v| [v.coords, v]}]\n @edge_map = Hash[@edges.map {|e| [e.coords, e]}]\n\n @all_spaces.zip((0...(@all_spaces.length)).to_a).each do |obj, id|\n obj.id = id\n end\n end",
"def randomize_terrain\n valid_terrains = @@data[:terrain].values.map { |i| i[:symbol] }\n\n (0...@width).each do |x|\n (0...@height).each do |y|\n @terrain_map[x][y] = valid_terrains[rand valid_terrains.length]\n end\n end\n end",
"def generate_rooms\n\n allocated_cells = get_allocated_cells\n taken_cells = 0\n room_id = 1\n\n max_room_w = @width * Dungeon::ROOM_SIZE_WEIGHT - 1\n max_room_h = @height * Dungeon::ROOM_SIZE_WEIGHT - 1\n\n # Make rooms until all the allocation has dried out\n while taken_cells < allocated_cells\n\n r_w = (rand*max_room_w).ceil + 1\n r_h = (rand*max_room_h).ceil + 1\n if r_w.odd? && r_h.odd?\n place_room(r_w, r_h, room_id)\n taken_cells += r_w*r_h\n room_id += 1\n end\n end\n end",
"def build_zone(roughness, windyness)\n #length = (@zone_height / @tile_size) - 1 # how long the cave should be in tiles (fixed or not fixed)\n\n # start with layers of grass and trees\n fill_with_grass\n fill_with_trees\n\n # entrance / init\n starting_x = snap_to_tile entrance_coordinates[:x]\n starting_y = entrance_coordinates[:y]\n starting_width = entrance_coordinates[:width]\n fill(starting_x, starting_y, starting_width, @tile_size, Grass)\n fill(starting_x, @tile_size, starting_width, @tile_size, Grass)\n\n x = starting_x\n y = starting_y\n width = starting_width\n\n while (y - starting_y < @zone_height)\n y += @tile_size\n\n if rand(1..100) <= roughness\n width += @tile_size * [-2, -1, 1, 2].sample\n width = 3 * @tile_size if width < (3 * @tile_size)\n width = @zone_width if width > @zone_width\n end\n\n if rand(1..100) <= windyness\n x += @tile_size * [-2, -1, 1, 2].sample\n x = 0 if x < 0\n x = @zone_width - (3 * @tile_size) if x > (@zone_width - (3 * @tile_size))\n end\n\n fill(x, y, width, @tile_size, Grass)\n end\n end",
"def set_map\n # Sets locations on the map\n @map = [\n ['Enumerable Canyon', 'Duck Type Beach', 'Monkey Patch City'],\n ['Duck Type Beach', 'Enumerable Canyon', 'Matzburg'],\n ['Monkey Patch City', 'Nil Town', 'Enumerable Canyon', 'Matzburg'],\n ['Nil Town', 'Monkey Patch City', 'Hash Crossing'],\n ['Matzburg', 'Monkey Patch City', 'Duck Type Beach', 'Hash Crossing', 'Dynamic Palisades'],\n ['Hash Crossing', 'Matzburg', 'Nil Town', 'Dynamic Palisades'],\n ['Dynamic Palisades', 'Matzburg', 'Hash Crossing']\n ]\n end",
"def empty_map\n @game = Game.find( params[:id] )\n \n # if flag random is active load 10 Cities radomly\n if params[:random]\n @cities = @game.cities.random\n \n # else: just get the biggest 10 Cities \n else\n @cities = @game.cities.biggest\n end \n @map = @game.map \n end",
"def map\n render :template=>'edgarj/map', :layout=>false\n end",
"def rams_to_destroy_wall\n wall = (buildings.wall || '0').to_i\n\n results = {}\n results[0] = 0\n results[1] = 2\n results[2] = 7\n results[3] = 13\n results[4] = 20\n results[5] = 28\n results[6] = 37\n results[7] = 48\n results[8] = 60\n results[9] = 74\n results[10] = 90\n results[11] = 108\n results[12] = 129\n results[13] = 153\n results[14] = 180\n results[15] = 211\n results[16] = 246\n results[17] = 286\n results[18] = 330\n results[19] = 380\n results[20] = 437\n\n results[wall]\n end",
"def initialize\r\n @map = Array.new(MAP_SIZE).\r\n map{Array.new(MAP_SIZE)}.\r\n map{|x| x.map{[]}}\r\n @map[0].map!{|x|[1]}\r\n @map[-1].map!{|x|[1]}\r\n @map[1..-2].each{|x|x[0]=[1];x[-1]=[1]}\r\n # @nodes = Array.new(MAP_SIZE/NODE_SCALE).\r\n # map{Array.new(MAP_SIZE/NODE_SCALE)}.\r\n # map{|x| x.map{[]}}\r\n end",
"def init_map\n @map = [\n ['Enumerable Canyon', 'Monkey Patch City', 'Duck Type Beach'],\n ['Monkey Patch City', 'Nil Town', 'Matzburg', 'Enumerable Canyon'],\n ['Duck Type Beach', 'Matzburg', 'Enumerable Canyon'],\n ['Matzburg', 'Duck Type Beach', 'Monkey Patch City', 'Hash Crossing', 'Dynamic Palisades'],\n ['Nil Town', 'Moneky Patch City', 'Hash Crossing'],\n ['Hash Crossing', 'Matzburg', 'Dynamic Palisades', 'Nil Town'],\n ['Dynamic Palisades', 'Hash Crossing', 'Matzburg']\n ]\n end",
"def clip_map\n @nodes.each{|n| clip_intersection(n)}\n end",
"def create_storm_bitmap\r\n @storm_bitmap = Bitmap.new(34, 64)\r\n 32.times do |i|\r\n @storm_bitmap.fill_rect(33-i, i*2, 1, 2, particle_color2)\r\n @storm_bitmap.fill_rect(32-i, i*2, 1, 2, particle_color1)\r\n @storm_bitmap.fill_rect(31-i, i*2, 1, 2, particle_color2)\r\n end\r\n end",
"def carve_walls_from_point(x, y, grid)\n \nend",
"def next_map!\n @speedup_countdown = GAME_SPEEDUP_INTERVAL\n @balls.clear\n @bonuses.clear\n @paddles.each do |paddle|\n # center the paddle\n paddle.pos_y = @height / 2 - paddle.height / 2\n @balls << paddle.create_new_ball\n end\n @map = @map_database.next_map\n end",
"def generate_grid\n grid = []\n @y.times do\n row = []\n @x.times do\n row << nil\n end\n grid << row\n end\n grid\n end",
"def cells_grid_1by1\n [\n [\n MazeMagic::Maze::Edge.instance,\n MazeMagic::Maze::HorizontalWall.instance,\n MazeMagic::Maze::Edge.instance\n ],\n [\n MazeMagic::Maze::VerticalWall.instance,\n MazeMagic::Maze::HorizontalWall.instance,\n MazeMagic::Maze::VerticalWall.instance\n ]\n ]\n end",
"def generate_tectonic_plates\n max_radius = (width / 10) * 2.0\n\n hill_resources = [ :coal, :iron, :uranium ]\n mountain_resources = [ :coal, :iron, :uranium ]\n\n (width/4).times do\n candidates = { }\n\n radius = (width / 10) * (1.0 + Kernel::rand)\n pos = [ Kernel::rand(@maxx), Kernel::rand(@maxy) ]\n cx,cy = pos\n\n tiles = { }\n\n 1.upto(radius) do |r|\n (cx-r).upto(cx+r) do |x|\n (cy-r).upto(cy+r) do |y|\n pos = [x,y]\n next if tiles[pos]\n next unless in_range?(pos)\n\n if Kernel::rand >= r.to_f/max_radius\n tiles[pos] = true\n tile = self[pos]\n if tile[:terrain] == :grass then\n tile[:terrain] = :hills\n tile[:resource] = nil\n tile[:resource] = hill_resources[Kernel::rand(hill_resources.length - 1)] if Kernel::rand < 0.20\n tile[:resource] = :arable if tile[:resource].nil? && Kernel::rand < 0.40\n elsif tile[:terrain] == :hills then\n tile[:terrain] = :mountains\n tile[:resource] = nil\n tile[:resource] = mountain_resources[Kernel::rand(mountain_resources.length - 1)] if Kernel::rand < 0.40\n else\n tile[:terrain] = :grass\n tile[:resource] = nil\n tile[:resource] = :arable if Kernel::rand < 0.10\n tile[:resource] = :oil if Kernel::rand < 0.03\n tile[:resource] = hill_resources[Kernel::rand(hill_resources.length - 1)] if tile[:resource].nil? && Kernel::rand < 0.05\n end\n end\n end\n end\n end\n end\n end",
"def setup_blueprint_outdoor_farms(want)\n @fort_entrance.maptile.spiral_search([df.world.map.x_count, df.world.map.y_count].max, 9, 3) { |_t|\n next unless sf = surface_tile_at(_t)\n sd = sf.designation\n if (-1..1).all? { |dx| (-1..1).all? { |dy|\n tt = sf.offset(dx, dy) and\n td = tt.designation and\n ((sd.subterranean and td.subterranean) or\n (not sd.subterranean and not td.subterranean and\n sd.biome == td.biome)) and\n tt.shape_basic == :Floor and\n tt.designation.flow_size == 0 and\n [:GRASS_DARK, :GRASS_LIGHT, :SOIL].include?(tt.tilemat)\n } }\n @rooms << Room.new(:farmplot, [:food, :cloth][want % 2], sf.x-1, sf.x+1, sf.y-1, sf.y+1, sf.z)\n @rooms.last.misc[:users] = []\n @rooms.last.misc[:outdoor] = true\n want -= 1\n true if want == 0\n end\n }\n end",
"def markOrigin(ox, oy, oz)\n t = df.map_tile_at(ox, oy, oz)\n if t then\n s = t.shape_basic\n #TODO: preseve designation:\n #$originTile = t.designation # a global to store the original origin state\n #puts \"origin: #{$originTile}\"\n t.dig(:Default) if s == :Wall\n end\nend",
"def walls\n @walls ||= self[:walls].split(//).\n zip(WALL_DIRECTIONS).\n select{ |flag,dir| flag == '1' }.\n map{ |flag,dir| dir }\n end",
"def initialize\n @maps = {}\n @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)\n @map_renderer = MapRenderer.new\n end",
"def make_board\n @grid = Array.new(9) { | row | Array.new(9) { | col | Tile.new(self, [row, col]) } }\n self.place_bombs\n @grid.map.with_index do | row, rowIndx |\n row.map.with_index { | tile, colIndx | tile.neighbors_bomb_count if !(self.is_a_bomb?([rowIndx, colIndx])) }\n end\n end",
"def infinite_areas\n infs = []\n (0..max_x).each do |x|\n infs << @grid[x][0]\n infs << @grid[x][max_y]\n end\n\n (0..max_y).each do |y|\n infs << @grid[0][y]\n infs << @grid[max_x][y]\n end\n\n infs.uniq.reject {|x| x == \".\" }.sort\n end",
"def make_Fake_Map(num_rows, num_columns) \n random_row_index = (rand() * num_rows).to_i\n puts random_row_index\n random_column_index = (rand() * num_columns).to_i\n puts random_column_index\n \n fake_map_array = []\n\n count_row = 0\n\n while count_row < num_rows do \n row_array = []\n count_col = 0\n while count_col < num_columns do\n if (count_col == random_column_index && count_row == random_row_index) \n row_array.push(\"X\")\n else row_array.push(\"A\")\n end\n count_col +=1\n end\n count_row +=1\n fake_map_array.push(row_array)\n end\n\n p fake_map_array\nend",
"def draw_map\n draw_map_cells($map.x, $map.y)\n end",
"def generate_ocean\n @ships.each do |ship|\n @ocean[ship.coords[0]][ship.coords[1]] = \"S\" \n end\n end",
"def index\n f = File.open(Rails.root.join(\"datas\",\"map2.yml\"))\n globalMap = Array.new\n f.each_line {|line| globalMap << line.split(' ')}\n\n\n x0 = Integer(params[\"x0\"])\n y0 = Integer(params[\"y0\"])\n width = Integer(params[\"width\"])\n height = Integer(params[\"height\"])\n\n x1 = x0 + width\n y1 = y0 + height\n\n @map = Array.new\n @poisMap = Array.new\n globalMap[y0...y1].each do |line|\n lineZE = Array.new\n width.times do\n lineZE << 0\n end\n @poisMap << lineZE\n @map << line[x0...x1]\n end\n\n @pois = Array.new\n Poi.all.each do |poi|\n if poi.x == nil\n continue\n end\n if poi.y == nil\n continue\n end\n if poi.x > (x0+1) && poi.x < (x1-3) && poi.y < y1 && poi.y > (y0+3)\n level = Integer((poi.lvl)/5)\n puts level\n\n begin\n\n arbres = Array.new\n arbres[0] = [[202,203],[210,211],[218,219]]\n arbres[1] = [[204,205],[212,213],[220,221]]\n arbres[2] = [[206,207],[214,215],[222,223]]\n arbres[3] = [[208,209],[216,217],[224,225]]\n\n #@poisMap[poi.y][poi.x] = 1 + level*5\n #@poisMap[poi.y][poi.x+1] = 2 + level*5\n #@poisMap[poi.y-1][poi.x] = 3 + level*5\n #@poisMap[poi.y-1][poi.x+1] = 4 + level*5\n #@poisMap[poi.y-2][poi.x] = 5 + level*5\n #@poisMap[poi.y-2][poi.x+1] = 6 + level*5\n\n @poisMap[poi.y-1][poi.x+1] = arbres[level][0][1]\n\n @poisMap[poi.y][poi.x] = arbres[level][0][0]\n @poisMap[poi.y][poi.x+2] = arbres[level][1][1]\n @poisMap[poi.y+1][poi.x+1] = arbres[level][1][0]\n @poisMap[poi.y+1][poi.x+3] = arbres[level][2][1]\n @poisMap[poi.y+2][poi.x+2] = arbres[level][2][0]\n rescue\n end\n #@pois << poi\n end\n end\n\n\n\n\n respond_to do |format|\n format.json { render :json => @map }\n format.xml {}\n format.html {}\n end\n end",
"def set_map\n @map_canvas = GameCanvas.new\n @map = Map.new(self)\n @map_canvas.place(@map.map_size, @map.map_size, 10, @board.block_size * @board.num_rows + 10)\n end",
"def initialize(generate = false, file_name = 'map')\n @file_name = file_name\n @data_path = \"./data/#{file_name}.dat\"\n @blocks = {}\n @tiles = {}\n @tiles_info = {\n 1 => {\n :path => \"./\" + Config.get('img_path') + \"grass.png\",\n :type => :grass\n },\n 2 => {\n :path => \"./\" + Config.get('img_path') + \"grass.png\",\n :type => :grass\n },\n 3 => {\n :path => \"./\" + Config.get('img_path') + \"grass.png\",\n :type => :grass\n },\n 4 => {\n :path => \"./\" + Config.get('img_path') + \"grass.png\",\n :type => :grass\n },\n 5 => {\n :path => \"./\" + Config.get('img_path') + \"oak.png\",\n :type => :tree\n },\n 6 => {\n :path => \"./\" + Config.get('img_path') + \"betula.png\",\n :type => :tree\n },\n 7 => {\n :path => \"./\" + Config.get('img_path') + \"picea.png\",\n :type => :tree\n },\n 8 => {\n :path => \"./\" + Config.get('img_path') + \"mountain.png\",\n :type => :mountain\n }\n }\n JSON.dump_default_options[:max_nesting] = 10\n JSON.load_default_options[:max_nesting] = 10\n init_from_config Config['BLOCKS_IN_MAP_DIM'], Config['BLOCK_DIM']\n if generate || !File.exist?(@data_path)\n generate_map\n else\n file = File.open(@data_path, \"r\")\n data = Marshal.load(file)\n @tiles = data[:tiles]\n @blocks = data[:blocks]\n check_map\n end\n end",
"def initialize(map)\n @map_id = extract_property map, Const::MAP_ID\n @display_name = extract_property map, Const::MAP_DISPLAY_NAME\n @width = map.width * map.tilewidth\n @height = map.height * map.tileheight\n @is_main = extract_property(map, Const::MAP_IS_MAIN) == 'true'\n @tilesets = TileSets.new(map.tilesets, '../resources/maps/')\n\n fill_map_objects map.object_groups\n fill_layers map\n end",
"def create_map_picture\n @picture = Sprite.new(@viewport)\n @picture.bitmap = Cache.picture(MINIMAP_PICTURE)\n @picture.x = P_X; @picture.y = P_Y\n @picture.opacity = 0\n end",
"def create_board\n b = Hash.new\n for i in 1..7\n for j in 1..6\n b[[i,j]] = @empty_sign\n end\n end\n return b\n end",
"def create_game_board\n\t\tnew_board = {}\n\t\ti = 1\n\t\t6.times do \n\t\t\tj = 1\n\t\t\t7.times do\n\t\t\t\tcurrent_key = \"#{j}-#{i}\"\n\t\t\t\tnew_board[current_key] = ConnectFourLocation.new\n\t\t\t\tj += 1\n\t\t\tend\n\t\t\ti += 1\n\t\tend\n\t\treturn new_board\n\tend",
"def setMap(level)\n\tcase level\n\twhen 1\n\t\treturn [[[0,0],[1,1],[0,0],[1,0],[-1,0],[0,1],[-1,0],[0,1],[2,0],[2,0]], 3, 0, false, 8]\n\twhen 2\n\t\treturn [[[4,0],[0,0],[0,0],[0,0],[0,0],[-1,0],[-2,0],[0,0],[1,1],[0,0],[2,2],[0,0],[1,1],[0,0],[3,3]],7,0,false,0]\n\twhen 3\n\t\treturn [[[0,0],[0,0],[0,0],[1,1],[2,2],[3,3],[-3,0],[0,0],[-3,0],[-3,0],[0,0]],2,0,false,10]\n\tend\nend",
"def get_background_map\n background_map = Array.new(@map_in_lines.size, '')\n @maps ||= {}\n\n iterate_over_each_character_in_array_of_lines(@map_in_lines) do |y, x|\n if x.even?\n background_map[y] += @map_in_lines[y][x]\n end\n end\n\n @maps[:background] = background_map\n end",
"def initialise_cell_array\n @cells = []\n @room_map = {}\n @corridor_map = {}\n @corridor_seeds = []\n (0..width).each do |i|\n @cells[i] = []\n (0..height).each do |j|\n @cells[i][j] = Cell.new(i, j, Cell::UNALLOCATED)\n end\n end\n end",
"def generate_rooms\n\n allocated_cells = get_allocated_cells\n taken_cells = 0\n room_id = 1\n\n max_room_w = @width * Dungeon::ROOM_SIZE_WEIGHT - 1\n max_room_h = @height * Dungeon::ROOM_SIZE_WEIGHT - 1\n\n # Make rooms until all the allocation has dried out\n while taken_cells < allocated_cells\n \n r_w = (rand*max_room_w).ceil + 1\n r_h = (rand*max_room_h).ceil + 1\n if r_w.odd? && r_h.odd? \n place_room(r_w, r_h, room_id) \n taken_cells += r_w*r_h\n room_id += 1\n end\n end\n \n puts \"Alloc: #{allocated_cells} Placed:#{taken_cells}\"\n\n end",
"def initialize\n \t@grid_w = 50\n \t@grid_h = 40\n \t@grid = []\n\t\n\t\t@player_x = 0\n\t\t@player_y = 0\n\t\t@has_enviroment_rendered=false\n\t\t#setup and fill grid with walls\n \t@grid_w.times.with_index do |x|\n \t\t@grid[x] = []\n\t\t\t@grid_h.times.with_index do |y|\n \t\t\t@grid[x][y]= 1\n \t \tend\n \tend\n\t\tmin_rooms = 2\n\t\tmax_rooms = 10\n\t\t#setup number of rooms that will exist\n\t\t@n_rooms = rand(max_rooms - min_rooms) + min_rooms\n\t\tputs \"n rooms #{@n_rooms}\"\n\t\trooms = []\n\t\t#define the size of each room\n\t\t@n_rooms.times.with_index do |room|\n\t\t\trooms[room] = make_room 8,10\n\t\tend\n\t\n\t\t#clears the walls from where rooms will be \n\t\trooms.each_with_index do |r,i| \n\t\t\t(r[:x]..r[:x] + r[:w]).each do |x|\n\t\t\t\t(r[:y]..r[:y] + r[:h]).each do |y|\n\t\t\t\t\t@grid[x][y]= 0\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t#create pathways towards the next room\n\t\trooms.each_cons(2) do |(cur_room, next_room)|\n\t\t\t#find the center of each room \n\t\t\tcenter_x = cur_room[:x] + cur_room[:w].idiv(2)\n\t\t\tcenter_y = cur_room[:y] + cur_room[:h].idiv(2)\n\n\t\t\tnext_center_x = next_room[:x] + next_room[:w].idiv(2)\n\t\t\tnext_center_y = next_room[:y] + next_room[:h].idiv(2)\n\n\t\t\t#loops between each rooms X and Y positions \n\t\t\t#this can be approached differently\n\t\t\t(min(center_x,next_center_x)..max(center_x,next_center_x)).each do |x|\n\t\t\t\t(min(center_y,next_center_y)..max(center_y,next_center_y)).each do |y|\n\t\t\t\t\t#checking if this position is in-line with either rooms x or y centres\n\t\t\t\t\t@grid[x][y] = 0 if y == center_y || y == next_center_y || x == center_x || x == next_center_x\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t@new_grid = []\n\t\t#set new grid to prune unneeded walls to improve performance\n\t\t@grid_w.times.with_index do |x|\n\t \t@new_grid[x] = []\n\t \t@grid_h.times.with_index do |y|\n \t\t\t@new_grid[x][y]= @grid[x][y]\n\t\t\tend\n\t end\n\t\t#set up values\n\t\t@grid_w.times.with_index do |x|\n \t\t@grid_h.times.with_index do |y|\n\t\t\t\t#if surrounded it should not be filled in\n\t\t\t\tif check_surrounding_tiles x,y\n\t\t\t\t\t@grid[x][y] = 0\n\t\t\t\tend\n \t\tend\n \tend\n\t\t#this will set the players starting position to a known safe area\n\t\t@player_x = rooms[0][:x] + rooms[0][:w].idiv(2)\n\t\t@player_y = rooms[0][:y] + rooms[0][:h].idiv(2)\n\t\t@grid[@player_x][@player_y] = 2\n\tend",
"def generate_corridors()\n\t\t(0..width).each do |i|\n\t\t\t(0..height).each do |j|\n\t\t\t\tif i.odd? && j.odd? && @cells[i][j].type == Cell::UNALLOCATED\n\t\t\t\t\tcarve_corridors(i,j,nil)\n @corridor_seeds << @cells[i][j]\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def drawmap(map,z=0)\r\nend",
"def create_shifts\n\tself.shifts=[]\n\tif self.locations.size==0\n\t self.locations=self.area.locations\n\tend\n\tst=self.shifttimes \n \tst.each do |t|\n\t\tself.locations.each do |l|\n\t\t\n\t\t\tshift=Shift.new\n\t\t\tshift.location=l\n\t\t\tshift.start=t\n\t\t\tself.shifts << shift\n\t\tend\n \tend\n end",
"def create_minimum\n for y in 0...@maze.height\n for x in 0...@maze.width\n tile = @maze.get_tile(x,y)\n if tile.is_room\n @rooms.push tile\n tile.type = 0\n @maze.size+=1\n self.create_connection tile\n end\n end\n end\n\n #populates the maze until it reaches the given maze's size\n while @maze.size<@size\n self.create_connection @rooms.sample\n end\n\n #if it somehow goes over the given maze size just redesign it again, I don't think this gets hit but it's here incase my algorithm is screwy\n if @maze.size>@size\n @maze = Maze.new\n @maze.load @old_string, (@old_maze.width-1)/2, (@old_maze.height-1)/2, true\n end\n\n @maze\n end",
"def make_heat_map allowed_squares, heat_map = {}\n\n score_point = lambda do |point|\n case @opponent.grid.value_for_point point\n when :unknown \n 1.0\n when :empty \n 0.0\n when :recent_hit \n 4.0\n when :hit \n 0.2\n end\n end\n\n increment_heat_map_points = lambda do |points|\n inc = points.map(&score_point).reduce(:+) / points.size.to_f\n points.each do |point|\n p = point.to_hash\n if heat_map.has_key? p\n heat_map[p] += inc\n elsif @opponent.grid.is_unknown? point\n heat_map[p] = inc\n end\n end\n end\n\n #Produces a list of possible starting points for a ship\n possible_starting_points = []\n GRID_SIZE.times do |i|\n GRID_SIZE.times do |j|\n p = Point.new i, j\n possible_starting_points << p if allowed_squares.include? @opponent.grid.value_for_point p\n end\n end\n\n count_possible_placements = lambda do |ship_type, direction|\n #now iterate through starting points and see if ships can be placed\n possible_starting_points.each do |ship_start|\n continue = true\n begin\n temp_ship = Ship.ship_factory ship_type, ship_start, direction\n if @opponent.grid.can_place_ship? temp_ship, allowed_squares\n increment_heat_map_points.call temp_ship.points\n end\n rescue ArgumentError\n end\n end\n end\n\n @opponent.possible_ships.keys.each do |ship_type| \n @opponent.possible_ships[ship_type].times do \n count_possible_placements.call ship_type, :east\n count_possible_placements.call ship_type, :south\n end\n end\n\n # puts @opponent.grid.to_s\n # puts \"\"\n # puts (project_heat_map heat_map)\n\n #puts @opponent.remaining_ships.length.to_s\n\n return heat_map\n end",
"def display(world,i)\n puts \"Generation #{i+1}:\"\n x_list = []\n y_list = []\n world.each do |item|\n x_list.push(item[0])\n y_list.push(item[1])\n end\n ###############print the map###################\n for y in (y_list.min-3..y_list.max+3) do\n for x in (x_list.min-3..x_list.max+3) do\n if world.include?([x,y])\n print \"1\"\n else\n print \"0\"\n end\n end\n puts\n end\nend",
"def generate_corridors\n (0..width).each do |i|\n (0..height).each do |j|\n if i.odd? && j.odd? && @cells[i][j].type == Cell::UNALLOCATED\n carve_corridors(i, j, nil)\n @corridor_seeds << @cells[i][j]\n end\n end\n end\n end",
"def create_full_graph(spec_edges)\n create_sub_graph(spec_edges, $game_map.width+$game_map.height)\n end",
"def init_map(input)\n @position_x = 0\n @position_y = 0\n @pokemon_map = Set.new []\n @pokemon_map << (\"#{@position_x};#{@position_y}\") \n input_validation(input) \n end",
"def create_background_image\n split_tile_set_into_tiles\n create_image_list\n\n montage_cmd = \"montage #{@image_list.join(' ')} \"\n montage_cmd += \"-tile #{@maps[:background][0].size}x \"\n montage_cmd += \"-geometry 32x32+0+0 media/grid_one/full_map_image.png\"\n\n system(\"#{montage_cmd}\")\n\n @background_image = Gosu::Image.new(@window,\n 'media/grid_one/full_map_image.png',\n false)\n\n FileUtils.rm_r Dir.glob('media/tmp/*')\n end",
"def island; end",
"def initialize (width=5, height=5, obstacles=[])\n @width = width\n @height = height\n @obstacle_map = Array.new(width) { Array.new(height) }\n obstacles.each do |obstacle|\n x, y = obstacle[:x], obstacle[:y]\n @obstacle_map[x][y] = true\n end\n end"
] |
[
"0.76886547",
"0.6959513",
"0.69321233",
"0.6839378",
"0.6772527",
"0.67149854",
"0.6600952",
"0.6551186",
"0.6462697",
"0.6415269",
"0.63727856",
"0.63697803",
"0.6306374",
"0.6298288",
"0.6279866",
"0.627709",
"0.6257782",
"0.6238615",
"0.6180258",
"0.6159204",
"0.6156977",
"0.61561215",
"0.61241776",
"0.6117552",
"0.6073695",
"0.6045421",
"0.60426044",
"0.6031942",
"0.60222006",
"0.60168964",
"0.5963923",
"0.59515345",
"0.59444124",
"0.59108394",
"0.5909401",
"0.58872825",
"0.58648026",
"0.58257556",
"0.5797313",
"0.57348573",
"0.5730457",
"0.5727337",
"0.5716049",
"0.5715902",
"0.571559",
"0.5714182",
"0.57060194",
"0.5699067",
"0.5685794",
"0.5683165",
"0.5682429",
"0.5681909",
"0.56693375",
"0.566536",
"0.56641406",
"0.5653946",
"0.5644095",
"0.56424946",
"0.5640538",
"0.5639312",
"0.5636823",
"0.5632548",
"0.5622486",
"0.5619989",
"0.5597688",
"0.5595941",
"0.55955666",
"0.5586206",
"0.557105",
"0.5570243",
"0.5565",
"0.5555559",
"0.5555137",
"0.55529624",
"0.55489486",
"0.5539855",
"0.5529017",
"0.55180675",
"0.55174935",
"0.55155545",
"0.551385",
"0.55057883",
"0.54911786",
"0.548779",
"0.54860026",
"0.5470787",
"0.5469958",
"0.5469398",
"0.5452344",
"0.54480845",
"0.5435962",
"0.54287595",
"0.5427946",
"0.54259413",
"0.54205376",
"0.54174054",
"0.54173094",
"0.5415081",
"0.54099345",
"0.54087466"
] |
0.8666017
|
0
|
Set up the border to be "unbreakable"
|
def set_border()
for row_i in 0...@height
@map[row_i][0] = @PERMANENT_WALL
@map[row_i][@width - 1] = @PERMANENT_WALL
end
for column_i in 0...@width
@map[0][column_i] = @PERMANENT_WALL
@map[@height - 1][column_i] = @PERMANENT_WALL
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def bordered; self.border = true; self; end",
"def border; end",
"def border!\n border do\n # adds default border\n end\n end",
"def remove_border_mark(sexp)\n def sexp.inline_border?\n false\n end \n end",
"def outside_border_size\n renderer.border_class == TTY::Table::Border::Null ? 0 : 2\n end",
"def border=(_arg0); end",
"def setborderwidth(*)\n super\n end",
"def kill_cells_in_borders\n (0..@long - 1).each do |long|\n (0..@width - 1).each do |width|\n @matriz[long][width] = ' . ' if long.zero? || (long == @long - 1) || width.zero? || (width == @width - 1)\n end\n end\n end",
"def border!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 37 )\n\n type = BORDER\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 367:9: 'border'\n match( \"border\" )\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__, 37 )\n\n end",
"def start_border(info = '')\n draw_border(:top, info)\n end",
"def border\n \"#{BORDER}\\n #{self.align_center} \\n#{BORDER}\"\n end",
"def setbordercolorind(*)\n super\n end",
"def Pager_SetBorder(hwnd, iBorder) send_pager_message(hwnd, :SETBORDER, lparam: iBorder) end",
"def border(options={})\n set RGhost::Border.new(options)\n end",
"def print_border_mb row, col, height, width, color, attr\n mvwaddch row, col, ACS_ULCORNER\n mvwhline( row, col+1, ACS_HLINE, width-6)\n mvwaddch row, col+width-5, Ncurses::ACS_URCORNER\n mvwvline( row+1, col, ACS_VLINE, height-4)\n\n mvwaddch row+height-3, col, Ncurses::ACS_LLCORNER\n mvwhline(row+height-3, col+1, ACS_HLINE, width-6)\n mvwaddch row+height-3, col+width-5, Ncurses::ACS_LRCORNER\n mvwvline( row+1, col+width-5, ACS_VLINE, height-4)\n end",
"def reset!\n @borders = register(Vedeu::Border)\n end",
"def prv_print_border_only row, col, height, width, color, att=Ncurses::A_NORMAL\n att ||= Ncurses::A_NORMAL\n case att.to_s.downcase\n when 'normal'\n att = Ncurses::A_NORMAL\n when 'underline'\n att = Ncurses::A_UNDERLINE\n when 'bold'\n att = Ncurses::A_BOLD\n when 'blink'\n att = Ncurses::A_BLINK # unlikely to work\n when 'reverse'\n att = Ncurses::A_REVERSE \n end\n attron(Ncurses.COLOR_PAIR(color) | att)\n mvwaddch row, col, ACS_ULCORNER\n mvwhline( row, col+1, ACS_HLINE, width-2)\n mvwaddch row, col+width-1, Ncurses::ACS_URCORNER\n mvwvline( row+1, col, ACS_VLINE, height-1)\n\n mvwaddch row+height-0, col, Ncurses::ACS_LLCORNER\n mvwhline(row+height-0, col+1, ACS_HLINE, width-2)\n mvwaddch row+height-0, col+width-1, Ncurses::ACS_LRCORNER\n mvwvline( row+1, col+width-1, ACS_VLINE, height-1)\n attroff(Ncurses.COLOR_PAIR(color) | att)\n end",
"def end_border(info = '')\n draw_border(:bottom, info)\n end",
"def render_border(screen)\n border ? screen.box(abs_x, abs_y, abs_width, abs_height, border.style, border_style) : ''\n end",
"def border\n '+' + ('-' * @max_y) + '+'\n end",
"def print_border_only row, col, height, width, color, att=Ncurses::A_NORMAL\n if att.nil? \n att = Ncurses::A_NORMAL\n else\n att = get_attrib att\n end\n wattron(Ncurses.COLOR_PAIR(color) | att)\n mvwaddch row, col, Ncurses::ACS_ULCORNER\n mvwhline( row, col+1, Ncurses::ACS_HLINE, width-2)\n mvwaddch row, col+width-1, Ncurses::ACS_URCORNER\n mvwvline( row+1, col, Ncurses::ACS_VLINE, height-1)\n\n mvwaddch row+height-0, col, Ncurses::ACS_LLCORNER\n mvwhline(row+height-0, col+1, Ncurses::ACS_HLINE, width-2)\n mvwaddch row+height-0, col+width-1, Ncurses::ACS_LRCORNER\n mvwvline( row+1, col+width-1, Ncurses::ACS_VLINE, height-1)\n wattroff(Ncurses.COLOR_PAIR(color) | att)\n end",
"def remove_empty_border\n stack = []\n for row in 0...height\n stack.push [row, 0] unless self[row, 0].empty\n stack.push [row, width-1] unless self[row, width-1].empty\n end\n for col in 0...width\n stack.push [0, col] unless self[0, col].empty\n stack.push [height-1, col] unless self[height-1, col].empty\n end\n\n while cell = stack.pop\n self[*cell].visible = false\n DIRS.each do | dir |\n neighbor = cell.zip(dir).map{|i,j| i + j}\n stack.push neighbor if self[*neighbor] and !self[*neighbor].empty and self[*neighbor].visible\n end\n end\n end",
"def setRemoveBorders(value)\n @fields['remove_borders'] = value\n self\n end",
"def setRemoveBorders(value)\n @fields['remove_borders'] = value\n self\n end",
"def TreeView_SetBorder(hwnd, dwFlags, xBorder, yBorder)\r\n send_treeview_message(hwnd, :SETBORDER, wparam: dwFlags, lparam: MAKELPARAM(xBorder, yBorder))\r\n end",
"def print_border_mb row, col, height, width, color, attr\n # the next is for xterm-256 \n att = get_attrib attr\n len = width\n len = Ncurses.COLS-0 if len == 0\n # print a bar across the screen \n #attron(Ncurses.COLOR_PAIR(color) | att)\n # this works for newmessagebox but not for old one.\n # Even now in some cases some black shows through, if the widget is printing spaces\n # such as field or textview on a messagebox.\n # 2016-01-14 - replacing 1 with space since junk is showing up in some cases.\n space_char = \" \".codepoints.first\n (row-1).upto(row+height-1) do |r|\n # this loop clears the screen, printing spaces does not work since ncurses does not do anything\n mvwhline(r, col, space_char, len)\n end\n #attroff(Ncurses.COLOR_PAIR(color) | att)\n\n mvwaddch row, col, Ncurses::ACS_ULCORNER\n mvwhline( row, col+1, Ncurses::ACS_HLINE, width-6)\n mvwaddch row, col+width-5, Ncurses::ACS_URCORNER\n mvwvline( row+1, col, Ncurses::ACS_VLINE, height-4)\n\n mvwaddch row+height-3, col, Ncurses::ACS_LLCORNER\n mvwhline(row+height-3, col+1, Ncurses::ACS_HLINE, width-6)\n mvwaddch row+height-3, col+width-5, Ncurses::ACS_LRCORNER\n mvwvline( row+1, col+width-5, Ncurses::ACS_VLINE, height-4)\n end",
"def draw_borders\n if borders.top > 0 # TODO: :none\n options = translate( x: margins.left, y: margins.top ).merge( width: width + margins.width, height: borders.top, foreground: borders.foreground, background: Termbox::RED )\n \n pencil.draw_rectangle( options )\n end\n \n if borders.bottom > 0 # TODO: :none\n options = translate( x: margins.left, y: offsets.top + padding.bottom ).merge( width: width + margins.width, height: borders.bottom, foreground: borders.foreground, background: Termbox::RED )\n \n pencil.draw_rectangle( options )\n end\n end",
"def borders_tech_demo\n outputs.labels << [ 5, 260, \"Borders (x, y, w, h, r, g, b, a)\"]\n outputs.borders << [ 10, 180, 50, 50]\n outputs.borders << [ 70, 180, 50, 50, 0, 0, 0]\n outputs.borders << [130, 180, 50, 50, 255, 0, 0]\n outputs.borders << [190, 180, 50, 50, 255, 0, 0, 128]\n outputs.borders << [250, 180, 50, 50, 0, 0, 0, 128 + state.tick_count % 128] # transparency changes\n end",
"def trim(border = pixels.first)\n dup.trim!\n end",
"def inqborderwidth\n inquiry_double { |pt| super(pt) }\n end",
"def border(borderStyle)\n @border = borderStyle.nil? ? nil : borderStyle.to_s.downcase\n end",
"def print_border\n $log.debug \" SCROLL print_border ...\"\n #@window.print_border_only(@top-@rows_panned, @left+@cols_panned, @display_h, @display_w, $datacolor)\n @target_window.print_border_only(@top, @left, @display_h, @display_w+1, $datacolor)\n end",
"def setup_border_windows(name, window)\n # Set black and white color pair\n window.attron(Curses.color_pair(8))\n name = name.to_s\n\n # Apply box border to window with pipe and dash symbols\n window.box('|', '-')\n\n # Set curser position to the middle of the top border and add name of box\n window.setpos(0, (window.maxx / 2.0).ceil - (name.length / 2.0).ceil)\n window.addstr(name.upcase)\n\n window.noutrefresh\nend",
"def borders=(value)\n @borders = value\n end",
"def outer_width; rect.width + @border_thickness * 2; end",
"def bottom_border\n \"#{self.align_center} \\n#{BORDER}\"\n end",
"def top_border\n \"#{BORDER}\\n #{self.align_center}\"\n end",
"def add_border_mark(sexp)\n def sexp.inline_border?\n true\n end \n end",
"def border_width=(width)\n self.each {|cell| cell.border_width = width}\n end",
"def is_border?(); @type == GRT_BORDER; end",
"def setlinewidth(*)\n super\n end",
"def border\n buffer = screen_width % @border_character.length\n border_length = (screen_width / @border_character.length)\n @border_character * (border_length + buffer)\n end",
"def print_borders #:nodoc:\n width = @width\n height = @height-1 # 2010-01-04 15:30 BUFFERED HEIGHT\n window = @graphic # 2010-01-04 12:37 BUFFERED\n startcol = @col \n startrow = @row \n #@color_pair = get_color($datacolor)\n bordercolor = @border_color || $datacolor\n borderatt = @border_attrib || Ncurses::A_NORMAL\n\n window.print_border startrow, startcol, height, width, bordercolor, borderatt\n print_title\n end",
"def remove_border\n system \"gdalwarp -srcnodata 0 -dstalpha #{@processed_path} #{@processed_path}\"\n end",
"def border_style ; view.borderStyle ; end",
"def print_border row, col, height, width, color, att=Ncurses::A_NORMAL\n $log.debug \" pad printborder #{row} - #{@top} , #{col} - #{@left}, #{height} , #{width} \"\n raise \"print_border: row < top, pls correct code #{row} #{@top}, #{col} #{@left} \" if row < @top or col < @left\n #$log.warn \"print_border: row < top, pls correct code #{row} #{@top} \" if row < @top\n super(row - @top, col - @left, height, width, color, att)\n end",
"def draw_canvas_border(grid)\n grid[0].each do |grid_cell|\n grid_cell.top_wall = true\n end\n grid[grid.length - 1].each do |grid_cell|\n grid_cell.bottom_wall = true\n end\n\n (0..grid.length - 1).each do |j|\n grid[j][0].left_wall = true\n grid[j][grid[j].length - 1].right_wall = true\n end\nend",
"def border?\n !!@border_character\n end",
"def border(buffer_size=nil, o = {})\n return @borders[0] unless buffer_size\n if @borders.size == 1\n w,h = game_area[0],game_area[1]\n body = CP::Body.new(Float::INFINITY, Float::INFINITY)\n @borders = [\n buffer_size,\n body, # border body obj\n [ #x, y, x, y\n [0, 0, w, 0 ], [w, 0, w, h ],\n [w, h, 0, h ], [0, h, 0, 0 ],\n ].map { |seg|\n # border segments :>\n CP::Shape::Segment.new body, vec2(*seg[0,2]), vec2(*seg[2,2]), 1\n }\n ].flatten 1\n @space.add_body @borders[1]\n @borders[2..-1].each { |s|\n s.e = o[:elasticity] || 0.96 #elasticity\n s.collision_type = :border\n @space.add_shape s\n }\n o[:no_collide].each { |ct|\n @space.add_collision_func(:border, ct) do |border, obj|\n if obj.object.has_attached?\n true #bounce off the border\n else false end #dont bounce\n end\n } if o[:no_collide]\n \n @whole_area = [\n w + @borders[0].*(2),\n h + @borders[0].*(2),\n ]\n end\n @borders[0]\n end",
"def wrap_in_border\n puts border if border?\n yield\n print border if border?\n end",
"def border(&block)\n return '' unless block_given?\n\n border_on + yield + border_off\n end",
"def highlight(set_or_clear )\r\n\r\n if set_or_clear == :set\r\n begin\r\n @original_border = @o.border.to_i\r\n if @o.border.to_i==1\r\n @o.border = 2\r\n else\r\n @o.border=1\r\n end\r\n rescue\r\n @original_border = nil\r\n end\r\n else\r\n begin \r\n @o.border= @original_border unless @original_border == nil\r\n @original_border = nil\r\n rescue\r\n # we could be here for a number of reasons...\r\n ensure\r\n @original_border = nil\r\n end\r\n end\r\n super \r\n end",
"def setBorder\n return if @border.nil? # default\n if @accessory.class == NSBox\n @accessory.boxType = NSBoxCustom\n @accessory.cornerRadius = 5.0\n case @border\n when 'none' # no border or fill color\n @accessory.borderType = NSNoBorder\n when 'line', 'color' # line border with gray fill\n @accessory.borderType = NSLineBorder\n @accessory.fillColor = MEalert.getColor 'box'\n setBorderColor if @border == 'color'\n end\n else # NSTextField or NSComboBox\n textField = (@accessory.class == NSTextField)\n case @border\n when 'none'\n textField ? @accessory.bordered = false : @accessory.buttonBordered = false\n @accessory.bezeled = false\n when 'line', 'color'\n textField ? @accessory.bordered = false : @accessory.buttonBordered = false\n setBorderColor if @border == 'color'\n end\n end\n end",
"def print_border row, col, height, width, color, att=Ncurses::A_NORMAL\n raise \"height needs to be supplied.\" if height.nil?\n raise \"width needs to be supplied.\" if width.nil?\n att ||= Ncurses::A_NORMAL\n\n #$log.debug \" inside window print_border r #{row} c #{col} h #{height} w #{width} \"\n\n # 2009-11-02 00:45 made att nil for blanking out\n # FIXME - in tabbedpanes this clears one previous line ??? XXX when using a textarea/view\n # when using a pad this calls pads printstring which again reduces top and left !!! 2010-01-26 23:53 \n ww=width-2\n clr = \" \"*ww\n (row+1).upto(row+height-1) do |r|\n printstring( r, col+1, clr, color, att)\n end\n print_border_only row, col, height, width, color, att\n end",
"def print_border row, col, height, width, color, att=Ncurses::A_NORMAL\n raise \"height needs to be supplied.\" if height.nil?\n raise \"width needs to be supplied.\" if width.nil?\n att ||= Ncurses::A_NORMAL\n\n $log.debug \" inside window print_border r #{row} c #{col} h #{height} w #{width} \"\n\n # 2009-11-02 00:45 made att nil for blanking out\n # FIXME - in tabbedpanes this clears one previous line ??? XXX when using a textarea/view\n # when using a pad this calls pads printstring which again reduces top and left !!! 2010-01-26 23:53 \n (row+1).upto(row+height-1) do |r|\n #printstring( r, col+1,\" \"*(width-2) , $datacolor, nil)\n prv_printstring( r, col+1,\" \"*(width-2) , $datacolor, nil)\n end\n prv_print_border_only row, col, height, width, color, att\n end",
"def paint_border!(style, d)\n case style\n when :round_rect then d.roundrectangle(0, 0, width, height, 10, 10)\n # default is :round_rect, but treat anything unrecognized as :rectangle (use entire image)\n else d.rectangle(0, 0, width, height)\n end\n end",
"def top_border_stroke\n line_stroke(\n settings.border.style.top_left,\n settings.border.style.top_junc,\n settings.border.style.top_right\n ) do\n settings.border.style.top_horiz * (dimensions.inner_grid_width + (settings.scrollbar.vert? ? 1 : 0))\n end\n end",
"def set_textborderwidth(width)\n @text.borderwidth(width)\n end",
"def vertical_blank_space\n border_penalty = border? ? 2 : 4\n border_penalty += 2 if @display_seconds.nil? # this is for display and stop running\n vbs = height - border_penalty - @message.length\n vbs > 0 ? vbs : 0\n end",
"def bottom_border_stroke\n line_stroke(\n settings.border.style.bottom_left,\n settings.border.style.bottom_junc,\n settings.border.style.bottom_right\n ) do\n settings.border.style.bottom_horiz * (dimensions.inner_grid_width + (settings.scrollbar.vert? ? 1 : 0))\n end\n end",
"def how_to_render_borders args\n # Render a square at 0, 0 with a width and height of 3\n args.nokia.borders << { x: 0, y: 0, w: 3, h: 3, a: 255 }\n\n # Render a square at 3, 3 with a width and height of 3\n args.nokia.borders << { x: 3, y: 3, w: 4, h: 4, a: 255 }\n\n # Render a square at 5, 5 with a width and height of 4\n args.nokia.borders << { x: 7, y: 7, w: 5, h: 5, a: 255 }\nend",
"def inqbordercolorind\n inquiry_int { |pt| super(pt) }\n end",
"def border\n @border ||= Vedeu.borders.by_name(name)\n end",
"def border\n @border ||= Vedeu.borders.by_name(name)\n end",
"def bottom_line\n border_options ? super : nil\n end",
"def trim!(border = pixels.first)\n x1 = [*0...width].index { |c| column(c).uniq != [border] }\n x2 = [*0...width].rindex { |c| column(c).uniq != [border] }\n y1 = [*0...height].index { |r| row(r).uniq != [border] }\n y2 = [*0...height].rindex { |r| row(r).uniq != [border] }\n\n crop! x1, y1, x2 - x1 + 1, y2 - y1 + 1\n end",
"def print_borders\n bordertitle_init unless @_bordertitle_init_called\n raise ArgumentError, \"Graphic not set\" unless @graphic\n raise \"#{self} needs width\" unless @width\n raise \"#{self} needs height\" unless @height\n width = @width\n height = @height-1\n window = @graphic\n startcol = @col \n startrow = @row \n @color_pair = get_color($datacolor)\n bordercolor = @border_color || @color_pair\n borderatt = @border_attrib || Ncurses::A_NORMAL\n window.print_border startrow, startcol, height, width, bordercolor, borderatt\n print_title\n end",
"def border(top_or_bottom)\n if top_or_bottom == \"top\"\n puts \"\\n ╔═══ ☆ .·:·. ☽ ✧ † ✧ ☾ .·:·. ☆ ═══╗ \\n\"\n else\n puts \"\\n ╚═══ ☆ .·:·. ☽ ✧ † ✧ ☾ .·:·. ☆ ═══╝ \\n\"\n end\n end",
"def border\n puts \"--------------------------------\".center(75)\nend",
"def border?\n name == 'border'\n end",
"def draw_blank\n puts \"[ o ] [ o ] [ o ] [ o ]\\n\\n\"\n end",
"def draw_border(x, y, border_colour)\n original_colour = @image.content[x-1][y-1]\n temp_colour = '.'\n\n fill_region(x, y, temp_colour, nil, border_colour)\n\n @image.content.map { |column| column.map! { |colour| colour == temp_colour ? original_colour : colour } }\n @image\n end",
"def add_border(cell_ref, edges = :all)\n cells = self[cell_ref]\n BorderCreator.new(self, cells, edges).draw\n end",
"def change_border_diagonal(weight='thin')\n change_border(:diagonal, weight)\n end",
"def add_border! (width, html_color=\"\\#000000\")\n color = Color::RGB.from_html(html_color)\n cmd = \"BO#{width},\" \n cmd << [color.r, color.g, color.b].map {|c| (c*255).to_i }.join(\",\")\n @transforms << cmd\n self\n end",
"def add_border(size=3,r=0,g=0,b=0)\n width = @x_size+2*size\n height = @y_size+2*size\n resampled = image_create_true_color(width,height)\n image_filled_rectangle(resampled,0,0,width,height, r, g, b)\n image_copy(@picture,resampled,size,size,0,0,@x_size,@y_size)\n image_destroy(@picture)\n @x_size = width\n @y_size = height\n @picture = image_create_true_color(@x_size,@y_size)\n image_filled_rectangle(@picture,0,0,@x_size,@y_size,255,255,255)\n image_color_transparent(@picture,255,255,255)\n image_copy(resampled,@picture,0,0,0,0,@x_size,@y_size)\n end",
"def border(n)\r\n puts \"-\" * n\r\n end",
"def outer_height; rect.height + @border_thickness * 2; end",
"def borders\n world.constrain_mover(self)\n end",
"def border(size, color = ChunkyPNG::Color::BLACK)\n dup.border!(size, color)\n end",
"def line_stroke(left_border, junc_border, right_border, &block)\n stroke = ''\n stroke += left_border if settings.border.left?\n dimensions.num_cols.times do |col_num|\n stroke += junc_border if col_num > 0 && settings.border.inner_vert?\n stroke += yield\n end\n stroke += right_border if settings.border.right?\n stroke\n end",
"def draw_border(x1, y)\r\n if @function_UI.mouse_over_button(mouse_x, mouse_y)\r\n draw_line(x1, y, Gosu::Color::BLUE, x1+60, y, Gosu::Color::BLUE, ZOrder::TOP, mode=:default)\r\n draw_line(x1, y+35, Gosu::Color::BLUE, x1+60, y+35, Gosu::Color::BLUE, ZOrder::TOP, mode=:default)\r\n draw_line(x1, y,Gosu::Color::BLUE, x1, y+35, Gosu::Color::BLUE, ZOrder::TOP, mode=:default)\r\n draw_line(x1+60, y,Gosu::Color::BLUE, x1+60, y+35, Gosu::Color::BLUE, ZOrder::TOP, mode=:default)\r\n end \r\n end",
"def setBorderColor\n return if @coloration[:border].nil?\n ciColor = CIColor.alloc.initWithColor(MEalert.getColor(@coloration[:border]))\n cgColor = CGColorCreate(ciColor.colorSpace, ciColor.components)\n @accessory.wantsLayer = true\n @accessory.layer.borderColor = cgColor\n @accessory.layer.borderWidth = 1\n end",
"def borderColor(theColor)\n return if theColor.nil?\n @coloration[:border] = theColor\n end",
"def test_inactiveBorder\n [@window, @sprite, @bitmap].each{|container|\n uc = UCGraph.new(container, 500, 300, 50, @elements, nil, 100, -100, Font.normal_font,\n Color.hp_gauge_color1, Color.hp_gauge_color2,\n Color.mp_gauge_color1, Color.mp_gauge_color2, nil,\n 1, Color.normal_color)\n uc.active = false\n uc.draw()\n }\n return true\n end",
"def border_class\n orderable.border_class\n end",
"def middle_line\n border_options.separator ? \"\" : super\n end",
"def paint_border(options = HashWithIndifferentAccess.new)\n options.reverse_merge! theme[:border] if theme[:border]\n options[:style] = :none if options[:style].nil?\n return if options[:style] == :none\n\n # first we need a stencil\n d = Magick::Draw.new\n theme.apply_to(d)\n d.fill(\"white\")\n d.stroke(\"transparent\")\n paint_border!(options[:style], d)\n stencil = Magick::Image.new(width, height)\n stencil.matte_reset!\n d.draw(stencil)\n\n # now we place the graphics context over the stencil, causing any areas blocked (transparent pixels) by the stencil\n # to be blocked in the graphics context\n stencil.composite!(graphics_context, 0, 0, AtopCompositeOp)\n\n # then we need to retrace the border, this time using the colors we want\n d = Magick::Draw.new\n theme.apply_to(d)\n d.fill(theme[:background][:color]) if theme[:background] and theme[:background][:color]\n d.stroke(options[:color] || theme[:stroke][:color]) if options[:color] || (theme[:stroke] && theme[:stroke][:color])\n paint_border!(options[:style], d)\n\n # finally, we can composite the stencil (which is now the actual image) back into the graphics context (which is\n # useless), and then commit the border to the finished product.\n graphics_context.composite!(stencil, 0, 0, CopyCompositeOp)\n d.draw(graphics_context)\n end",
"def clear_witch(x)\n move_to_top\n @witch_height.times do\n line_at x, \" \"\n end\n end",
"def draw_border(x1, y, mouse_x, mouse_y)\r\n if @function_UI.mouse_over_button(mouse_x, mouse_y)\r\n draw_line(x1, y, Gosu::Color::BLUE, x1+60, y, Gosu::Color::BLUE, ZOrder::TOP, mode=:default)\r\n draw_line(x1, y+35, Gosu::Color::BLUE, x1+60, y+35, Gosu::Color::BLUE, ZOrder::TOP, mode=:default)\r\n draw_line(x1, y,Gosu::Color::BLUE, x1, y+35, Gosu::Color::BLUE, ZOrder::TOP, mode=:default)\r\n draw_line(x1+60, y,Gosu::Color::BLUE, x1+60, y+35, Gosu::Color::BLUE, ZOrder::TOP, mode=:default)\r\n end \r\n end",
"def fill\n fit\n rounding_error\n border_x = (@x - rmagick_img.columns)/2\n border_y = (@y - rmagick_img.rows)/2\n\n rmagick_img.border!(border_x,border_y,\"white\")\n end",
"def middle_border_stroke\n line_stroke(\n settings.border.style.left_junc,\n settings.border.style.cross_junc,\n settings.border.style.right_junc\n ) do\n settings.border.style.middle_horiz * (dimensions.inner_grid_width + (settings.scrollbar.vert? ? 1 : 0))\n end\n end",
"def no_underline\n reset_prev_formatting self, :underline\n end",
"def set_border(area1, area2 = nil)\n\t\t@borders.push(area1)\n\t\tarea1.borders.push(self)\n\t\tif area2 != nil\n\t\t\t@borders << area2\n\t\t\tarea2.borders << self\n\t\tend\n\tend",
"def change_border_left(weight='thin')\n change_border(:left, weight)\n end",
"def replace_table_border_styles(env)\n node = env[:node]\n return unless node.element? && node.name == 'table'\n node.xpath('tbody/tr/td').each do |el|\n next unless el[:style] =~ /border-\\w+-width:\\s*0\\w+;?/\n %w(bottom left right top).each do |b|\n el[:style] = el[:style].gsub(/border-#{b}-width:\\s*0\\w+;?\\s*/i,\n \"border-#{b}:0;\")\n end\n end\n end",
"def add_border(options = {})\n border_width = options[:width].to_i || 2\n color = hex_to_color(options[:color]) || hex_to_color(\"000000\")\n style = options[:style]\n style = nil if style.to_sym == :plain\n new_width, new_height = width + 2*border_width, height + 2*border_width\n target = paint(BufferedImage.new(new_width, new_height, color_type)) do |g|\n g.color = color\n if style\n raised = style.to_sym == :raised ? true : false\n g.fill3DRect(0, 0, new_width, new_height, raised)\n else\n g.fill_rect(0, 0, new_width, new_height)\n end\n g.draw_image(@src, nil, border_width, border_width)\n end\n block_given? ? yield(target) : target\n end",
"def update_borders\n @borders.each { |b| b.update }\n end",
"def top_line\n border_options ? super : nil\n end",
"def Pager_GetBorder(hwnd) send_pager_message(hwnd, :GETBORDER) end"
] |
[
"0.81409335",
"0.7536753",
"0.70074016",
"0.69198376",
"0.6810654",
"0.68106437",
"0.6764014",
"0.67237633",
"0.6670649",
"0.66500187",
"0.6558449",
"0.6514817",
"0.6467299",
"0.6443359",
"0.6437143",
"0.64086175",
"0.63793784",
"0.63750714",
"0.63693553",
"0.6362645",
"0.63129795",
"0.6295574",
"0.62721205",
"0.62721205",
"0.6248302",
"0.62243986",
"0.6223961",
"0.6222988",
"0.62137055",
"0.617223",
"0.61581707",
"0.61200815",
"0.6113275",
"0.61108214",
"0.6105001",
"0.60941035",
"0.60612816",
"0.6059576",
"0.60530555",
"0.6051437",
"0.60137856",
"0.60115266",
"0.6003045",
"0.5999636",
"0.5996035",
"0.59871995",
"0.59679884",
"0.5958099",
"0.5957568",
"0.5928806",
"0.5903364",
"0.58976",
"0.58897465",
"0.5883769",
"0.5864082",
"0.5851358",
"0.5847054",
"0.5840179",
"0.58225405",
"0.5803745",
"0.5801833",
"0.57931626",
"0.57821786",
"0.57821786",
"0.5779946",
"0.57728034",
"0.57551795",
"0.5742587",
"0.57410145",
"0.573687",
"0.57313555",
"0.572144",
"0.56912476",
"0.56818956",
"0.5670155",
"0.56656504",
"0.5662172",
"0.5647366",
"0.56345886",
"0.5628951",
"0.5627129",
"0.5620564",
"0.55957687",
"0.5585003",
"0.55781347",
"0.5569323",
"0.5562846",
"0.55568695",
"0.5552679",
"0.5545752",
"0.55236083",
"0.55224615",
"0.55197585",
"0.55180985",
"0.55005443",
"0.54844975",
"0.54838115",
"0.5464168",
"0.5445001",
"0.5435224"
] |
0.6206169
|
29
|
Clear unnecessary wall tht only have < 2 surrounding wall
|
def clear_small_wall
for row_i in 1...@height - 1
for column_i in 1...@width - 1
total_wall = count_adjacent_wall(row_i, column_i)
if @map[row_i][column_i] == @WALL
if total_wall < 2
@map[row_i][column_i] = @FLOOR
next
end
end
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def remove_extra_walls\n a_count_number = $cells.length/2/5\n while a_count_number > 0 do\n cell_index = rand(0..$cells.length/2)\n remove_walls($cells[cell_index], $cells[cell_index+1])\n a_count_number -= 1\n end\n end",
"def input_remove_wall2\n # The mouse needs to be inside the grid, because we only want to remove walls\n # the cursor is directly over\n # Recalculations should only occur when a wall is actually deleted\n if mouse_over_grid2?\n if state.walls.key?(cell_closest_to_mouse2) or state.hills.key?(cell_closest_to_mouse2)\n state.walls.delete(cell_closest_to_mouse2)\n state.hills.delete(cell_closest_to_mouse2)\n reset_search\n end\n end\n end",
"def input_remove_wall\n # The mouse needs to be inside the grid, because we only want to remove walls\n # the cursor is directly over\n # Recalculations should only occur when a wall is actually deleted\n if mouse_over_grid?\n if state.walls.key?(cell_closest_to_mouse) or state.hills.key?(cell_closest_to_mouse)\n state.walls.delete(cell_closest_to_mouse)\n state.hills.delete(cell_closest_to_mouse)\n reset_search\n end\n end\n end",
"def input_remove_wall\n # The mouse needs to be inside the grid, because we only want to remove walls\n # the cursor is directly over\n # Recalculations should only occur when a wall is actually deleted\n if mouse_inside_grid?\n if grid.walls.key?(cell_closest_to_mouse)\n grid.walls.delete(cell_closest_to_mouse)\n reset_search\n end\n end\n end",
"def clip_off_wall\n if wall = clip then\n normal = NORMAL[wall]\n self.ga = (normal + random_turn(90)).degrees unless (normal - ga).abs < 45\n end\n end",
"def remove_marked\n for i in (0..@width-1)\n for j in (0..@height-1)\n if @board[i][j] and @board[i][j].marked\n @board[i][j] = nil\n @pieces_removed += 1\n end\n end\n end\n end",
"def remove_empty_border\n stack = []\n for row in 0...height\n stack.push [row, 0] unless self[row, 0].empty\n stack.push [row, width-1] unless self[row, width-1].empty\n end\n for col in 0...width\n stack.push [0, col] unless self[0, col].empty\n stack.push [height-1, col] unless self[height-1, col].empty\n end\n\n while cell = stack.pop\n self[*cell].visible = false\n DIRS.each do | dir |\n neighbor = cell.zip(dir).map{|i,j| i + j}\n stack.push neighbor if self[*neighbor] and !self[*neighbor].empty and self[*neighbor].visible\n end\n end\n end",
"def can_clear? ( x, y )\n !self[x][y].visible && \n !self[x][y].mine && \n self[x][y].nearby_mines == 0\n end",
"def remove_pieces\n CHECKERS_HEIGHT.times do |x|\n CHECKERS_WIDTH.times do |y|\n @pieces[x][y].remove unless @pieces[x][y].nil?\n end\n end\nend",
"def rams_to_destroy_wall\n wall = (buildings.wall || '0').to_i\n\n results = {}\n results[0] = 0\n results[1] = 2\n results[2] = 7\n results[3] = 13\n results[4] = 20\n results[5] = 28\n results[6] = 37\n results[7] = 48\n results[8] = 60\n results[9] = 74\n results[10] = 90\n results[11] = 108\n results[12] = 129\n results[13] = 153\n results[14] = 180\n results[15] = 211\n results[16] = 246\n results[17] = 286\n results[18] = 330\n results[19] = 380\n results[20] = 437\n\n results[wall]\n end",
"def remove_filled_rows\n (0...@board_height).each do |row|\n index_range = row * @board_width...(row + 1) * @board_width\n if @board[index_range].reduce(:+) == @board_width\n @board[index_range] = Array.new(10, 0)\n end\n end\n end",
"def remove_wall!(id)\n\t\twall = @walls.select{|w| w.id == id}.first\n\t\tif wall\n\t\t\twall.all_points.each{|point| @board[point[:y]][point[:x]] = :empty }\n\t\t\t@walls.delete(wall)\n\t\t\ttrue\n\t\telse\n\t\t\tfalse\n\t\tend\n\tend",
"def clear(row, col)\n cell = @field[row][col]\n cell.uncover\n @mines_detonated = true if cell.mined\n\n left = @field[row][col - 1] unless col - 1 < 0\n top_left = @field[row -1][col -1] unless row -1 < 0 || col -1 < 0\n bot_left = @field[row +1][col -1] unless row + 1 > @row_count - 1 || col -1 < 0\n right = @field[row][col + 1] unless col + 1 > @column_count - 1\n top_right = @field[row -1][col +1] unless row -1 < 0 || col + 1 > @column_count - 1\n bot_right = @field[row +1][col +1] unless row + 1 > @row_count - 1 || col + 1 > @column_count - 1\n top = @field[row -1][col] unless row - 1 < 0\n bottom = @field[row +1][col] unless row + 1 > @row_count - 1\n\n if adjacent_mines(row, col) == 0\n left.uncover if !left.nil?\n top_left.uncover if !top_left.nil?\n bot_left.uncover if !bot_left.nil?\n right.uncover if !right.nil?\n top_right.uncover if !top_right.nil?\n bot_right.uncover if !bot_right.nil?\n top.uncover if !top.nil?\n bottom.uncover if !bottom.nil?\n end\n end",
"def wipe_3x3_squares(board)\n for y in [0, 3, 6]\n for x in [0, 3, 6]\n for yy in(y...y+3)\n for xx in (x...x+3)\n if board[yy][xx][0] != 0\n wipe = board[yy][xx][0]\n for yyy in (y...y+3)\n for xxx in(x...x+3)\n board[yyy][xxx][wipe] = 0\n end\n end\n end\n end\n end\n end\n end\n return\n end",
"def connect_cells(x1, y1, x2, y2)\n if x1 == x2\n # Cells must be above each other, remove a horizontal wall.\n @horizontal_walls[x1][ [y1, y2].min ] = false\n else\n # Cells must be next to each other, remove a vertical wall.\n @vertical_walls[ [x1, x2].min ][y1] = false\n end\n end",
"def add_maze_walls\n # add the left and right sides\n for wall_y in 0..@height-1 do\n @vertical_walls[wall_y].unshift :unhit\n @vertical_walls[wall_y].push :hit\n end\n # add the top\n @horizontal_walls.unshift Array.new(@width, :unhit)\n # open a hole for the start\n # starts on the top or bottom\n if(@start_y == 0 || @start_y == @height-1) then\n @horizontal_walls[@start_y == @height-1 ? @height : 0][@start_x] = :start\n end\n # starts on the left or right\n if(@start_x == 0 || @start_x == @width-1) then\n @vertical_walls[@start_y][@start_x == @width-1 ? @width : 0] = :start\n end\n # open a hole for the end\n # ends on the top or bottom\n if(@end_y == 0 || @end_y == @height-1) then\n @horizontal_walls[@end_y == @height-1 ? @height : 0][@end_x] = :end\n end\n # ends on the left or right\n if(@end_x == 0 || @end_x == @width-1) then\n @vertical_walls[@end_y][@end_x == @width-1 ? @width : 0] = :end\n end\n end",
"def clearAll\n for y in 0...10\n for x in 0...8\n if( @gridBoard[[x,y]] != nil )\n @gridBoard[[x,y]].clear_icon()\n end\n end\n end\n end",
"def clear_hits\r\n (0..h).each do |y|\r\n (0..w).each do |x|\r\n @map[x][y].clear()\r\n end\r\n end\r\n end",
"def connect_cells(x1, y1, x2, y2)\n if x1 == x2\n # Cells must be above each other, remove a horizontal\n # wall.\n @horizontal_walls[ [y1, y2].min ][x1] = false\n else\n # Cells must be next to each other, remove a vertical\n # wall.\n @vertical_walls[y1][ [x1, x2].min ] = false\n end\n end",
"def clear_full_rows\n\n\t\t# Clear all rows that are full\n\t\t@collision_map.each_with_index do |row, index|\n\t\t\t@collision_map.delete_at(index) if is_row_full?(row)\n\t\tend\n\n\t\tcleared_rows = @size_y - @collision_map.size\n\n\t\t# Create empty rows until the field is back to its original size\n\t\twhile @collision_map.size < @size_y\n\t\t\t@collision_map.unshift( Array.new(@size_x) { |i| { value: false, color: nil }})\n\t\tend\t\t\n\n\t\treturn cleared_rows\n\tend",
"def clear(row, col)\n unless cell_cleared?(row,col)\n @grid[row][col].uncovered = true\n if adjacent_mines(row,col) == 0\n clear(row, col+1) if col < @column_count-1\n clear(row, col-1) if col > 0\n clear(row+1, col) if row < @row_count-1\n clear(row-1, col) if row > 0\n clear(row+1, col+1) if row < @row_count-1 && col < @column_count-1\n clear(row-1, col-1) if row > 0 && col > 0\n clear(row-1, col+1) if row > 0 && col < @column_count-1\n clear(row+1, col-1) if row < @row_count-1 && col > 0\n end\n end\n end",
"def remove_inaccessible_cells(map, goal)\n # Use a flood fill to keep cells; everything not flooded gets a 99.\n basin = Set.new\n flood_fill(map, basin, goal[0], goal[1])\n map.height.times do |row|\n map.width.times do |col|\n map.set(row, col, 99) unless basin.include?([row, col])\n end\n end\n end",
"def kill_cells_in_borders\n (0..@long - 1).each do |long|\n (0..@width - 1).each do |width|\n @matriz[long][width] = ' . ' if long.zero? || (long == @long - 1) || width.zero? || (width == @width - 1)\n end\n end\n end",
"def connect_cells(x1, y1, x2, y2)\n if x1 == x2\n # Cells must be above each other, remove a horizontal wall.\n @horizontal_walls[x1][ [y1, y2].min ] = false\n else\n # Cells must be next to each other, remove a vertical wall.\n @vertical_walls[ [x1, x2].min ][y1] = false\n end\n end",
"def move_neighbours()\n # Make sure to check for doorways that can't be passed through diagonally!\n # Start with the current list from neighbours()\n # foreach cell in that list, remove that cell if either of the conditions are met:\n # it is not passable\n # it is diagonal, and either it or this square is a doorway\n end",
"def clear(row, col)\n while cell_cleared?(row, col) == false\n cleared_locations << [row, col]\n if adjacent_mines(row, col) == 0\n (-1..1).each do |i|\n (-1..1).each do |j|\n r = row + i\n c = col + j\n if r >= 0 || c >= 0 || r <= 19 || c <= 19 || (r != row && c != col)\n clear(r, c)\n end\n end\n end\n end\n end\n end",
"def update_clear_neighbours(cell)\n all_directions = [\n [-1, 1], [0, 1], [1, 1],\n [-1, 0], [1, 0],\n [-1, -1], [0, -1], [1, -1]\n ]\n\n all_directions.each do |adj_cell|\n neighbour = [adj_cell[0] + cell[0], adj_cell[1] + cell[1]]\n\n puts \"#{neighbour}\"\n next unless (0..9).include?(neighbour[0]) && (0..9).include?(neighbour[1])\n\n add_to_board(neighbour, \"C\")\n end\n end",
"def main_area_off\n\t\tif @main_array.length > 0 then\n\t\t\tfor i in 0..(@main_array.length - 1) do\n\t\t\t\t@layer_general.remove( @main_array[i] )\n\t\t\tend\n\t\t\t@main_array.clear\n\t\tend\n\t\tself.remove( @layer_general )\n\tend",
"def prune_free_list\n i = 0\n while i < @free_rectangles.size\n j = i + 1\n while j < @free_rectangles.size\n if is_contained_in?(@free_rectangles[i], @free_rectangles[j])\n @free_rectangles.delete_at(i)\n i -= 1\n break\n end\n if is_contained_in?(@free_rectangles[j], @free_rectangles[i])\n @free_rectangles.delete_at(j)\n else\n j += 1\n end\n end\n i += 1\n end\n end",
"def empty_squares(brd)\n brd.position_values.keys.select { |num| brd.position_values[num] == Board::INITIAL_MARKER }\n end",
"def input_add_wall2\n if mouse_over_grid2?\n unless state.walls.key?(cell_closest_to_mouse2)\n state.hills.delete(cell_closest_to_mouse2)\n state.walls[cell_closest_to_mouse2] = true\n reset_search\n end\n end\n end",
"def clear\n grid.map do |row|\n row.map! do |pixel|\n pixel = DEFAULT_FILL\n end\n end\n end",
"def unclip\n loop do\n must_do = false\n $WINDOW.current_map.solid_game_objects.each do |ob|\n next if ob.id == 1 || ob.id == self.id\n if ob.hb.check_brute_collision(@hb)\n must_do = true\n clipping = true\n while (clipping)\n angle = Gosu.angle(ob.hb.x, ob.hb.y, @hb.x, @hb.y)\n add_x = Gosu.offset_x(angle, 1)\n add_y = Gosu.offset_y(angle, 1)\n place(@hb.x+add_x, @hb.y+add_y)\n if !ob.hb.check_brute_collision(@hb)\n clipping = false\n end\n end\n end\n end\n break if !must_do\n end\n end",
"def bounce_off_walls\n change_direction(:x) if hit_wall?(:left) || hit_wall?(:right)\n change_direction(:y) if hit_wall?(:top) #|| hit_wall?(:bottom)\n end",
"def clear(x,y)\n if getsq(x,y)[:mine]\n @game_over=true\n else\n reveal(x,y)\n end\n end",
"def trim_box(x0, y0, x1, y1)\n @pages.trim_box = [ x0, y0, x1, y1 ]\n end",
"def clear(row, col)\n if @cleared[row][col] == false\n @cleared[row][col]=true\n if adjacent_mines(row,col) == 0 && @mines[row][col] == false\n #check up\n if row > 0\n clear(row-1,col)\n end\n #check down\n if row < row_count - 1\n clear(row+1,col)\n end\n #check left\n if col > 0\n clear(row,col-1)\n end\n #check right\n if col < column_count - 1\n clear(row,col+1)\n end\n end\n end\n end",
"def reset\n @max_color_distance = @color_distance_limit ? 0 : nil\n @left = @top = @right = @bottom = nil\n end",
"def removewalls \n\t\t@drawnmaze.chars.each_index do |index|\n\t\t\tif @arg[index] == \"0\" \n\t\t\t\t@drawnmaze[index] = \" \"\n\t\t\tend\n\t\tend\n\tend",
"def clear(row, col)\n @board[row][col].cleared = true\n if !contains_mine?(row, col)\n if adjacent_mines(row, col) == 0\n range = [-1, 0, 1]\n range.each do |range_x|\n range.each do |range_y|\n x_adj = row + range_x\n y_adj = col + range_y\n if cell_exists?(x_adj,y_adj) && !cell_cleared?(x_adj,y_adj)\n clear_cell(x_adj,y_adj)\n clear(x_adj, y_adj)\n end\n end\n end\n end\n end\n end",
"def update_canvas()\n for x in 0...$width\n for y in 0...$height\n \n neighbor_count = count_neighbors(x, y)\n\n if $canvas[x][y] == 1\n if neighbor_count < 2 or neighbor_count > 3\n $canvas[x][y] = 0\n end\n else\n if neighbor_count == 3\n $canvas[x][y] = 1\n end\n end\n end\n end\nend",
"def empty_spots(board)\n empties = []\n (0..2).each do |row|\n (0..2).each do |col| \n empties << [row,col] if @board.empty?([row,col])\n end\n end\n empties\n end",
"def clear(row, col)\n unless cell_cleared?(row, col)\n cleared_locations << [row, col]\n if adjacent_mines(row, col) == 0\n (-1..1).each do |i|\n (-1..1).each do |j|\n r = row + i\n c = col + j\n if r < 0 || c < 0\n next\n elsif r > 19 || c > 19\n next\n elsif r == row && c == col\n next\n else\n clear(r, c)\n end\n end\n end\n end\n end\n end",
"def remove_en_passant(x, y)\n\t\topposite_team_color = (@board[x][y].piece.color == :white ? :black : :white)\n\t\tpawns = collect_pawns(opposite_team_color)\n\t\tpawns.each do |pawn|\n\t\t\tif @board[x][y].piece.color == :white\n\t\t\t\tpawn.piece = nil if pawn.piece.en_passant == true && @board[x][y - 1] == pawn\n\t\t\telse\n\t\t\t\tpawn.piece = nil if pawn.piece.en_passant == true && @board[x][y + 1] == pawn\n\t\t\tend\n\t\tend\n\tend",
"def simple_water_fill(cave, count, row, col)\n\n return cave if count == 1 # I had it set up to terminate at count == 0, but this \n # produced the dreaded \"Off By One\" problem in my fill.\n \n if cave[row+1][col] == ' ' then # Flows down if cell below is empty.\n cave[row+1][col] = '~'\n simple_water_fill(cave, count-1, row+1, col)\n\n elsif cave[row][col+1] == ' ' then # below filled, forward empty\n cave[row][col+1] = '~'\n simple_water_fill(cave, count-1, row, col+1)\n\n elsif cave[row-1][col] == ' ' #below and forward BOTH filled -- checks up.\n col = col-1 while cave[row-1][col] == ' ' #should go all the way to the back\n simple_water_fill(cave, count, row-1, col)\n\n else # If both above and forward are walls, we've reached the upper right corner.\n if cave[row-1][col] == '#' && cave[row][col+1] == '#'\n count = 0\n end\n end\n \n cave\nend",
"def remove_border\n system \"gdalwarp -srcnodata 0 -dstalpha #{@processed_path} #{@processed_path}\"\n end",
"def clear_board\n @board.each { |_location, slot| slot.clear }\n @free_slots = 9\n end",
"def wipe_rows(board)\n for y in (0...9)\n for x in (0...9)\n if board[y][x][0] != 0\n wipe = board[y][x][0]\n for x in (0...9)\n board[y][x][wipe] = 0\n end\n end\n end\n end\n return\n end",
"def connect_cells(x1, y1, x2, y2)\n if x1 == x2\n # Cells must be above each other, remove a horizontal\n # wall.\n @horizontal_walls[ [y1, y2].min ][x1] = :open\n else\n # Cells must be next to each other, remove a vertical\n # wall.\n @vertical_walls[y1][ [x1, x2].min ] = :open\n end\n end",
"def is_wall(coords)\n !is_space(coords)\n end",
"def cut_white_space_edges\n x1_array = Array.new\n x2_array = Array.new\n y1_array = Array.new\n y2_array = Array.new\n \n @groups.each do |g|\n x1_array << g.x_pos\n x2_array << g.x_pos + g.width\n y1_array << g.y_pos\n y2_array << g.y_pos + g.height\n end\n \n if @vertical\n #Normal position of the image (up)\n if values_bits[Constants::V_Image_position]< 4.5 \n @height = y2_array.max + @upper_margin\n #Alternative position(down)\n else \n new_height = @height - (y1_array.min-@upper_margin)\n \n @groups.each do |g|\n g.y_pos -= (@height - new_height)\n end\n @main_image.y_pos -= (@height - new_height)\n \n @height = new_height\n end\n else\n #Normal position of the image (left)\n if values_bits[Constants::V_Image_position]< 4.5\n @width = x2_array.max + @sides_margin\n #Alternative position of the image (right)\n else \n new_width = @width - (x1_array.min-@sides_margin)\n \n @groups.each do |g|\n g.x_pos -= (@width - new_width)\n end\n @main_image.x_pos -= (@width - new_width)\n \n @width = new_width\n end\n end\n end",
"def eliminate_coliding_areas all_possible_areas\n puts 'All areas initial: ' + all_possible_areas.values.map{|areas| areas.count }.inspect\n\n all_possible_areas_reduced = {}\n\n # Reduce areas by eliminiting the ones which touch on another\n # numbered tile\n all_possible_areas.keys.each do |numbered_tile|\n x,y = numbered_tile.split('-').map(&:to_i)\n # Create board with compased tiles on all numbered tiles minus the\n # numbered tile\n restricted_board = create_restricted_board([x,y]).to_a\n all_compased_numbered_tiles = []\n (0..(@row_count-1)).to_a.each do |i|\n (0..(@col_count-1)).to_a.each do |j|\n all_compased_numbered_tiles << [i,j] if restricted_board[i][j] == 1\n end\n end\n\n all_areas_for_numbered_tile = all_possible_areas[numbered_tile].dup\n\n all_possible_areas_reduced[numbered_tile] = all_areas_for_numbered_tile.delete_if do |area|\n next if area.count == 1\n # Skip area, hmm do I need this bellow\n # next if (@b_nl[x,y] == 1)\n # Remove area if colinding\n area & all_compased_numbered_tiles != []\n end\n end #for each numbered_tile,area_span\n\n puts 'All numbered tile areas reduced(not coliding other numbered tiles)' + all_possible_areas_reduced.values.map{|areas| areas.count }.inspect\n all_possible_areas_reduced\n end",
"def filter_out_board_edges(possible_moves)\n inbound_moves = possible_moves.map do |move_stretch|\n move_stretch.select do |move|\n move.first.between?(0,7) && move.last.between?(0,7)\n end\n end\n\n inbound_moves.delete([])\n inbound_moves\n end",
"def zero_out_board\n @p.each { |k, v| @p[k] = ' '}\n draw_board(true)\n end",
"def clear_at(x, y)\r\n lookup_x = (x / @grid[0]).to_i\r\n lookup_y = (y / @grid[1]).to_i\r\n @map[lookup_x][lookup_y] = nil\r\n end",
"def clear(row, col)\n squares = adjacent_clear(row,col)\n squares.each { |position| uncover(position[0],position[1]) }\n end",
"def create_connection tile\n walls = @maze.get_adjacent_walls tile\n if walls.length>0\n @maze.size+=1\n walls.sample.type = 0\n end\n end",
"def draw_canvas_border(grid)\n grid[0].each do |grid_cell|\n grid_cell.top_wall = true\n end\n grid[grid.length - 1].each do |grid_cell|\n grid_cell.bottom_wall = true\n end\n\n (0..grid.length - 1).each do |j|\n grid[j][0].left_wall = true\n grid[j][grid[j].length - 1].right_wall = true\n end\nend",
"def input_add_wall\n if mouse_over_grid?\n unless state.walls.key?(cell_closest_to_mouse)\n state.hills.delete(cell_closest_to_mouse)\n state.walls[cell_closest_to_mouse] = true\n reset_search\n end\n end\n end",
"def render_walls\n outputs.solids << grid.walls.map do |key, value|\n scale_up(key).merge(wall_color)\n end\n end",
"def clear(row, col)\n if !@field[row][col].contains_mine?\n @field[row][col].reveal!\n if row == 0 && col == 0\n if !@field[row][col + 1].contains_mine? && !@field[row + 1][col].contains_mine? && !@field[row + 1][col + 1].contains_mine?\n @field[row][col + 1].reveal!\n @field[row + 1][col].reveal!\n @field[row + 1][col + 1].reveal!\n end\n elsif row == 0 && col == @column_count - 1\n if !@field[row][col - 1].contains_mine? && !@field[row + 1][col - 1].contains_mine? && !@field[row + 1][col].contains_mine? &&\n @field[row][col - 1].reveal!\n @field[row + 1][col - 1].reveal!\n @field[row + 1][col].reveal!\n end\n elsif row == @row_count - 1 && col == 0\n if !@field[row][col + 1].contains_mine? && !@field[row - 1][col + 1].contains_mine? && !@field[row - 1][col].contains_mine? &&\n @field[row][col + 1].reveal!\n @field[row - 1][col + 1].reveal!\n @field[row - 1][col].reveal!\n end\n elsif row == @row_count - 1 && col == @column_count - 1\n if !@field[row][col - 1].contains_mine? && !@field[row - 1][col - 1].contains_mine? && !@field[row - 1][col].contains_mine? &&\n @field[row][col - 1].reveal!\n @field[row - 1][col - 1].reveal!\n @field[row - 1][col].reveal!\n end\n elsif row == 0\n if !@field[row][col - 1].contains_mine? && !@field[row][col + 1].contains_mine? && !@field[row + 1][col - 1].contains_mine? && !@field[row + 1][col].contains_mine? && !@field[row + 1][col + 1].contains_mine? &&\n @field[row][col - 1].reveal!\n @field[row][col + 1].reveal!\n @field[row + 1][col - 1].reveal!\n @field[row + 1][col].reveal!\n @field[row + 1][col + 1].reveal!\n end\n elsif col == 0\n if !@field[row - 1][col].contains_mine? && !@field[row - 1][col + 1].contains_mine? && !@field[row][col + 1].contains_mine? && !@field[row - 1][col].contains_mine? && !@field[row - 1][col + 1].contains_mine? &&\n @field[row - 1][col].reveal!\n @field[row - 1][col + 1].reveal!\n @field[row][col + 1].reveal!\n @field[row - 1][col].reveal!\n @field[row - 1][col + 1].reveal!\n end\n elsif row == @row_count - 1\n if !@field[row][col - 1].contains_mine? && !@field[row][col + 1].contains_mine? && !@field[row - 1][col - 1].contains_mine? && !@field[row - 1][col].contains_mine? && !@field[row - 1][col + 1].contains_mine? &&\n @field[row][col - 1].reveal!\n @field[row][col + 1].reveal!\n @field[row - 1][col - 1].reveal!\n @field[row - 1][col].reveal!\n @field[row - 1][col + 1].reveal!\n end\n elsif col == @column_count - 1\n if !@field[row - 1][col].contains_mine? && !@field[row - 1][col - 1].contains_mine? && !@field[row][col - 1].contains_mine? && !@field[row - 1][col].contains_mine? && !@field[row - 1][col - 1].contains_mine? &&\n @field[row - 1][col].reveal!\n @field[row - 1][col - 1].reveal!\n @field[row][col - 1].reveal!\n @field[row - 1][col].reveal!\n @field[row - 1][col - 1].reveal!\n end\n elsif row > 0 && row < @row_count && col > 0 && col < @column_count\n adjacent_cells(row, col).each do |cell|\n if !cell.contains_mine?\n cell.reveal!\n end\n end\n end\n else @field[row][col].reveal!\n end\n end",
"def clean\n (1..@rows).each do |x|\n (1..@cols).each do |y|\n self.cleanCell(x, y)\n end\n end\n end",
"def clear_game_board\r\n \r\n #Assign a blank space to each game board square \r\n $A1 = \" \"\r\n $A2 = \" \"\r\n $A3 = \" \"\r\n $B1 = \" \"\r\n $B2 = \" \"\r\n $B3 = \" \"\r\n $C1 = \" \"\r\n $C2 = \" \"\r\n $C3 = \" \"\r\n \r\n end",
"def walls\n @walls ||= self[:walls].split(//).\n zip(WALL_DIRECTIONS).\n select{ |flag,dir| flag == '1' }.\n map{ |flag,dir| dir }\n end",
"def clear_puzzle\n @puzzle = [0] * 81\n @rows = [[], [], [], [], [], [], [], [], []]\n @columns = [[], [], [], [], [], [], [], [], []] \n @boxes = [[], [], [], [], [], [], [], [], []]\n end",
"def trim_tree\n\t\t@corridor_seeds.each { |seed| check_branch(corridor_map[seed]) }\n\tend",
"def rm_cddts_outof_blk\n axes = [@ref_rows, @ref_cols]\n axes.each{|axis|\n axis.each{|ref|\n intrsct_cddts = []\n (self.to_a.flatten & ref).each{|elm|\n intrsct_cddts.push(elm.cddts).flatten!.uniq!\n }\n six_cells_cddts = []\n (self.to_a.flatten - ref).each{|elm|\n six_cells_cddts.push(elm.cddts).flatten!.uniq!\n }\n intrsct_cddts.each{|cddt|\n unless six_cells_cddts.include?(cddt)\n (ref - self.to_a.flatten).each{|elm|\n elm.cddts.delete(cddt)\n# if ProgramConfig[:debug]\n# if elm.fixed == false and elm.cddts.length == 1\n# print \"DEBUG: [#{elm.i}, #{elm.j}] = #{elm.cddts.first}\\n\"\n# end\n# end\n elm.fixed = true if(elm.cddts.length == 1)\n }\n end\n }\n }\n }\n end",
"def applyOpposite\n #puts(\"Opposite creer pont \" + @x1.to_s + @y1.to_s + \" \" + @x2.to_s + @y2.to_s)\n return @grid.removeBridge(@x1, @y1, @x2, @y2)\n end",
"def trim_tree\n @corridor_seeds.each { |seed| check_branch(corridor_map[seed]) }\n end",
"def restrict_neighbours()\n\t# The grid starts out with values already. \n\t# Need to change the domain_grid to reflect the neighbours that can't \n\t# be certain values due to starting values\n\n\t$domain_grid.each_with_index do |row, index_r|\n\t\trow.each_with_index do |col, index_c|\n\t\t\tval = $value_grid[index_r][index_c]\n\t\t\t\n\t\t\tif val != 0 \n\t\t\t\tremove_from_neighbours(index_r,index_c,val)\n\t\t\tend\n\t\tend\n\tend\nend",
"def clear_board\n @board_spaces = ((1..9).to_a).product([\" \"]).to_h\n end",
"def compact_pieces\n @recheck = false\n for i in (0..@width-1)\n for j in (0..@height-1)\n if @board[i][j] and @board[i][j+1].nil? #drop pieces down\n @recheck = true\n @board[i][j+1] = @board[i][j]\n @board[i][j] = nil \n elsif j == 0 and @board[i][j].nil? #replace pieces at top\n @recheck = true\n @board[i][j] = Piece.new\n end\n end\n end\n if @startup and @recheck #fast setup of board before update + anim loops start\n compact_pieces\n clear_matches\n end \n end",
"def clear(row, col)\n\n # will not clear a cell that has already been cleared in recursive call\n if cell_cleared?(row, col) == false\n grid[row][col].uncovered = true\n\n if adjacent_mines(row, col) == 0 && grid[row][col].fill == 0\n clear(row+1, col) if (row + 1) < row_count\n clear(row-1,col) if (row - 1) >= 0\n clear(row,col+1) if (col + 1) < column_count\n clear(row,col-1) if (col -1) >= 0\n clear(row+1,col+1) if (row + 1) < row_count && (col + 1) < column_count\n clear(row+1,col-1) if (row + 1) < row_count && (col -1) >= 0\n clear(row-1,col+1) if (row - 1) >= 0 && (col + 1) < column_count\n clear(row-1,col-1) if (row - 1) >= 0 && (col -1) >= 0\n end\n end\n end",
"def clear_witch(x)\n move_to_top\n @witch_height.times do\n line_at x, \" \"\n end\n end",
"def clear\n remove_instance_variable(:@left)\n remove_instance_variable(:@middle)\n remove_instance_variable(:@right)\n end",
"def adjacent_wall(zone)\n \n end",
"def draw_pieces\n CHECKERS_HEIGHT.times do |x|\n CHECKERS_WIDTH.times do |y|\n @pieces[x][y].remove unless @pieces[x][y].nil?\n @pieces[x][y] = draw_piece(x,y,@board.state[x][y]) unless @board.state[x][y].nil?\n end\n end\nend",
"def border_points_minus_removed\n points = []\n border_points.each do |point|\n points << point if !point.marked_for_destruction?\n end\n points\n end",
"def add_surrounding_mines\n\t\t@board.flatten.each do |square|\n\t\t\tmine_count = 0\n\t\t\tsquare.adjacent_squares.each do |adj_square|\n\t\t\t\tmine_count += 1 if get_square(adj_square).mine == true\n\t\t\tend\n\t\t\tsquare.surrounding_mines=(mine_count)\n\t\tend\n\tend",
"def clear\n @x = 0.0\n @y = 0.0\n end",
"def unmark_circles_part_of_bingo\n @circles.each do |circle|\n circle.update(part_of_bingo: false)\n end\n end",
"def remove_piece(piece)\n piece.piece_cells.each_with_index do |row, j|\n row.each_with_index do |cell, i|\n @cells[piece.y + j][piece.x + i] = 0 if cell == 1\n end\n end\n end",
"def adjacent_clear(row,col)\n square = 1\n breaker = 0\n rowscols = []\n possibilities = [[row + square,col],[row,col + square],[row + square,col + square],[row - square,col],[row,col - square],[row - square,col - square],[row + square, col - square], [row - square, col + square]]\n if adjacent_mines(row,col) == 0 && row + square <= @row_count && row - square >= 0 && col + square <= @column_count && col - square >= 0\n possibilities.each do |position|\n rowscols << position\n end\n while row + square <= @row_count && row - square >= 0 && col + square <= @column_count && col - square >= 0\n square += 1\n possibilities.each do |check|\n breaker += adjacent_mines(check[0],check[1])\n end\n if breaker == 0\n possibilities.each do |check|\n rowscols << check\n end\n else\n break\n end\n possibilities = [[row + square,col],[row,col + square],[row + square,col + square],[row - square,col],[row,col - square],[row - square,col - square],[row + square, col - square], [row - square, col + square]]\n end\n end\n rowscols << [row,col]\n rowscols\n end",
"def clear c = :black\n fast_rect 0, 0, w, h, c\n end",
"def clear c = :black\n fast_rect 0, 0, w, h, c\n end",
"def filterMoves (board)\n\t\t@legalMoves.each do |i|\n\t\t\ti.each do |j|\n\t\t\t\tx = j / 8\n\t\t\t\ty = j % 8\n\t\t\t\tif (board[x][y] != nil)\n\t\t\t\t\tif (board[x][y].color == self.color)\n\t\t\t\t\t\ti.delete(j)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t# remove empty arrays as a result of the filtering\n\t\t@legalMoves.delete([])\n\tend",
"def clear_lines()\n count = 0\n @cells.each_with_index do |row, j|\n if !row.include?(0)\n @cells.delete_at(j)\n @cells.unshift([0] * board_size[:x])\n count += 1\n end\n end\n return count\n end",
"def check_out_of_world # swap size\n # y\n if @y < 0\n die\n elsif @y > WINDOW_SIZE_Y\n die\n end\n # x ( comment me out to add the glitch feature agian )\n if @x < 0\n @x = WINDOW_SIZE_X - TILE_SIZE - 2\n elsif @x > WINDOW_SIZE_X - TILE_SIZE - 1\n @x = 0\n end\n end",
"def clear(row, col)\n if within_field?(row, col) && !cell_cleared?(row, col)\n @field[row][col].clear\n if contains_mine?(row, col)\n @field[row][col].detonate\n else\n if adjacent_mines(row, col) == 0\n clear(row - 1, col - 1)\n clear(row - 1, col)\n clear(row - 1, col + 1)\n clear(row, col - 1)\n clear(row, col + 1)\n clear(row + 1, col - 1)\n clear(row + 1, col)\n clear(row + 1, col + 1)\n end\n end\n end\n end",
"def clear_tsbs\n super\n @ori_x = 0\n @ori_y = 0\n end",
"def cleanup_board(board)\n for y in (0...9)\n for x in (0...9)\n assign = 0\n for p in (1...10)\n if board[y][x][p] != 0 \n if assign == 0\n assign = board[y][x][p]\n else\n assign = 0\n break\n end\n end\n end\n if assign != 0 and board[y][x][0] == 0\n board[y][x][0] = assign\n for p in (1...10)\n board[y][x][p] = 0\n end\n end\n end\n end\n return\n end",
"def populate_caves\n for row_i in 1...@height - 1\n for column_i in 1...@width - 1\n if @map[row_i][column_i] == @FLOOR\n union_adjacent_square(row_i, column_i)\n end\n end\n end\n\n @disjoinset.split_sets()\n end",
"def check_off_screen\n pos = @body.p\n if pos.y > HEIGHT + EDGE_SIZE or pos.x > WIDTH + EDGE_SIZE or pos.x < -EDGE_SIZE\n @body.p = CP::Vec2.new(rand * WIDTH, 0)\n end\n end",
"def set_border()\n for row_i in 0...@height\n @map[row_i][0] = @PERMANENT_WALL\n @map[row_i][@width - 1] = @PERMANENT_WALL\n end\n\n for column_i in 0...@width\n @map[0][column_i] = @PERMANENT_WALL\n @map[@height - 1][column_i] = @PERMANENT_WALL\n end\n end",
"def find_cut(map)\n while map.length > 2\n # This is ok\n v1,v2 = get_vertices(map)\n # Merge \n map[v1] = merge_edges(map,v1,v2)\n # Delete\n remove_vertex(map,v2)\n # Remove occurences\n convert_vertex(map,v2,v1)\n # Remove loops\n remove_loops(map,v1)\n\n end\nend",
"def map_tile_nocavern(tile)\n (-1..1).all? { |dx| (-1..1).all? { |dy|\n next if not t = tile.offset(dx, dy)\n tm = t.tilemat\n if !t.designation.hidden\n t.designation.flow_size < 4 and tm != :FROZEN_LIQUID\n else\n t.shape_basic == :Wall and (tm == :STONE or tm == :MINERAL or tm == :SOIL or tm == :ROOT)\n end\n } }\n end",
"def clear(row, col)\n return if @board[row][col].is_open\n @board[row][col].is_open = true\n adjacent_list = adjacent_cells(row, col)\n list = adjacent_list.select { |cell| cell.has_bomb }\n if list.size == 0\n adjacent_list.each do |cell|\n clear(cell.row, cell.col)\n end\n end\n end",
"def bounce wall\n self.x = - self.x if self.x < 0\n self.x = wall.x - (self.x - wall.x) if self.x > wall.x\n self.y = -self.y if self.y < 0\n self.y = wall.y - (self.y - wall.y) if self.y > wall.y\n end",
"def avoid_roads(width, height, bad)\n\n routes = Array.new(height + 1) { Array.new(width + 1) { 0 } } # how many routes to a block?\n\n routes.each_with_index do |row, i|\n row.each_index do |j|\n if (i == 0 && j == 0)\n routes[0][0] = 1\n elsif i == 0\n routes[i][j] = routes[0][j - 1] unless is_obstructed?(i, j, i, j - 1, bad)\n elsif j == 0\n routes[i][j] = routes[i - 1][0] unless is_obstructed?(i, j, i - 1, j, bad)\n else\n top = (is_obstructed?(i, j, i - 1, j, bad) ? 0 : routes[i - 1][j])\n left = (is_obstructed?(i, j, i, j - 1, bad) ? 0 : routes[i][j - 1])\n routes[i][j] = top + left\n end\n end\n end\n\n return routes[height][width]\nend",
"def clear_world\n @all_persons.clear\n @all_monsters.clear\n @all_strawberries.clear\n @all_mushrooms.clear\n\n @iteration = 0\n end"
] |
[
"0.732075",
"0.69721377",
"0.69222367",
"0.68305147",
"0.6526889",
"0.64435136",
"0.6385868",
"0.6376257",
"0.63558066",
"0.63275766",
"0.6321259",
"0.62610716",
"0.6236823",
"0.6193693",
"0.6174106",
"0.61476016",
"0.6131723",
"0.6089886",
"0.6089272",
"0.60892004",
"0.60845655",
"0.6080826",
"0.60669416",
"0.6058462",
"0.6037098",
"0.60350907",
"0.60048705",
"0.5995035",
"0.59916997",
"0.5989965",
"0.5977213",
"0.5975862",
"0.59721845",
"0.595272",
"0.5950276",
"0.5938311",
"0.59356457",
"0.5931984",
"0.5929051",
"0.59090155",
"0.5904174",
"0.5895837",
"0.5893035",
"0.58923864",
"0.58696216",
"0.58694315",
"0.5851834",
"0.5850541",
"0.5833188",
"0.5829306",
"0.5825941",
"0.58008796",
"0.57956254",
"0.57955647",
"0.5781556",
"0.57792634",
"0.57684577",
"0.5758061",
"0.5742383",
"0.5735994",
"0.5734169",
"0.57326967",
"0.57297707",
"0.5722562",
"0.5719169",
"0.56950074",
"0.5687905",
"0.5679001",
"0.56770533",
"0.5672332",
"0.5665988",
"0.56629986",
"0.5661506",
"0.56570387",
"0.56562",
"0.5655343",
"0.56531924",
"0.5642905",
"0.5635368",
"0.5633225",
"0.56199473",
"0.56187534",
"0.5618515",
"0.56098926",
"0.56098926",
"0.560712",
"0.56044495",
"0.5601351",
"0.56006277",
"0.55933875",
"0.5584943",
"0.5583278",
"0.5578889",
"0.55765855",
"0.5568377",
"0.555598",
"0.5550983",
"0.55410653",
"0.5527081",
"0.5527042"
] |
0.80407876
|
0
|
Put user on given coordinate
|
def put_user(coord)
x_position = coord[0]
y_position = coord[1]
if !((0 < x_position && x_position < @width - 1) && (0 < y_position && y_position < @height - 1))
raise RangeError.new("User coordinate out of map size bound")
end
for row in [-1, 0, 1]
for column in [-1, 0, 1]
if !(row == 0 && column == 0) && @map[y_position + row][x_position + column] == @WALL
@map[y_position + row][x_position + column] = @FLOOR
end
end
end
@map[y_position][x_position] = @USER
join_rooms
clear_small_wall
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def user_location(user)\n geo = user.geolocation\n geo.latitude = 32.7157\n geo.longitude = -117.1611\n geo.fetch_address\n geo.save\n end",
"def place_at(x, y)\n\t\t@x = x\n\t\t@y = y\n\t\tcoords\n\tend",
"def at(*coordinates)\n position.coordinates = coordinates\n end",
"def update\n super\n\n @user = current_user\n @user.latitude = params[:user][:latitude]\n @user.longitude = params[:user][:longitude]\n @user.save\n end",
"def place(x, y)\n self.robot_position = {\n x: x,\n y: y\n } if valid_coordinates?(x, y)\n end",
"def update_my_location\n current_user.update(latitude: params[:latitude], longitude: params[:longitude])\n end",
"def at(x, y)\n self.coordinates = [x, y]\n end",
"def user_coordinate\r\n\t\tconvert_coordinate(1)\r\n\tend",
"def set_location(latitude, longitude, user_id)\n @latitude[user_id] = latitude\n @longitude[user_id] = longitude\n\n message = [user_id, @latitude[user_id], @longitude[user_id]].join(\",\")\n @pubnub.publish(\n channel: \"#{@event_id}_location\",\n message: message,\n http_sync: true\n ) { |env| log_event(env) }\n\n # Update parse\n location = get_user_event_location(user_id)\n location[\"latitude\"] = @latitude[user_id]\n location[\"longitude\"] = @longitude[user_id]\n PARSE_MUTEX.synchronize { location.save }\n end",
"def create\n super\n location = request.location\n @user.latitude = location.latitude\n @user.longitude = location.longitude\n @user.save\n end",
"def update\n @coordinate = coordinate_for_current_user params[:id]\n @coordinate.user_id = current_user.id\n\n respond_to do |format|\n if @coordinate.update_attributes(params[:coordinate])\n format.html { redirect_to [@track, @coordinate], notice: 'Coordinate was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @coordinate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_at(coords, piece)\n @board[coords[0]][coords[1]] = piece\n end",
"def coordinate=(coordinate)\n raise 'not on table yet' unless @table\n raise 'out of table' unless table.is_on_table(coordinate)\n @coordinate = coordinate\n end",
"def set_coordinate\n @coordinate = Coordinate.find(params[:id])\n end",
"def place(x, y, buddy)\n # Skip invalid states, when the buddy may fall down from the table\n if validate_pos(x, y)\n buddy.x = x\n buddy.y = y\n end\n end",
"def place_user_ship(ship, coordinates)\n # Check for valid coordinates and placements. If all are valid, place ship.\n if !coordinates.all? { |coord| @user_board.valid_coordinate?(coord) }\n return false\n elsif !@user_board.valid_placement?(ship, coordinates)\n return false\n else\n @user_board.place(ship, coordinates)\n return true\n end\n end",
"def move_to who, ox, oy, nx, ny\n @current_level.move_to who, ox, oy, nx, ny\n end",
"def placeShip (shipID, coords, who)\n which_squares = (who == \"me\") ? \"squares\" : \"enemy_squares\"\n transaction do\n coords.each do |i|\n square = self.send(which_squares).find_by_index(i)\n square.ship_id = shipID\n square.save\n end\n end\n end",
"def place!(x, y, f)\n raise ArgumentError, 'invalid coordinate' unless @playground.valid_coordinate?(x, y)\n raise ArgumentError, 'invalid position' unless @robot.set_position(x, y, f)\n end",
"def setcoord(type, value)\n @point_xy[type.to_sym] = value if ('x'..'y').cover?(type.to_s.downcase)\n chxyattr\n end",
"def setxy(x, y)\n setpos y, x\n end",
"def position=(point); end",
"def move_to(x, y)\n object.x = x\n object.y = y\n end",
"def place(args)\n x, y, orientation = args\n validate_orientation(orientation)\n validate_coordinates({ 'x' => x.to_i, 'y' => y.to_i })\n self.x_coordinate = x.to_i\n self.y_coordinate = y.to_i\n self.orientation = orientation\n end",
"def place(x, y, f)\n return unless valid_position?(x, y)\n set_position(x, y)\n set_direction(f.downcase.to_sym)\n end",
"def teleport( x, y )\n @x, @y = x, y\n end",
"def set_coord\n @coord = Coord.find(params[:id])\n end",
"def place!(x, y, facing = nil)\n raise 'x or y coordinate out of bounds' if out_of_bounds? x, y\n\n @facing = facing if facing\n @loc = {x: x, y: y}\n end",
"def put_on_table(table, coordinate, direction)\n raise 'nil validation error' if table.nil? || coordinate.nil? || direction.nil?\n @table = table\n self.coordinate=coordinate\n self.direction=direction\n end",
"def call(x, y)\n @position_x += x\n @position_y += y\n end",
"def set_coordinate\n @coordinate = Coordinate.find(params[:id])\n end",
"def play(user_id, location)\n x, y = get_move(location)\n move = self.player_1_id == user_id ? 'x' : 'o'\n board.set_cell(x, y, move)\n end",
"def set_loc(x, y)\n @curr_x = x\n @curr_y = y\n end",
"def set_mouse_position(x, y); end",
"def moveTo x, y\n\n\tend",
"def set_location\n\t current_user.update_location(params[:longitude], params[:latitude])\n respond_to do |format|\n format.js {render :nothing => true }\n end\n end",
"def moveto(x, y)\n #@ox = x; @oy = y\n @x = x % $game_map.width\n @y = y % $game_map.height\n #kk20\n @real_x = @x * 128 + 64\n @real_y = @y * 128 + 64\n end",
"def set_location(lon, lat)\n\t\tfactory = Driver.rgeo_factory_for_column(:location)\n\t\t# update(location: factory.point(lon,lat))\n\t\tself.location = factory.point(lon,lat)\n\tend",
"def setposition(x,y)\n\t\t@x = x\n\t\t@y = y\n\tend",
"def user_loc=(loc)\n self['user_loc'] = loc\n end",
"def set_coordinate_piece(coordinate, piece)\n @board[coordinate] = piece\n end",
"def set_user_position\n @user_position = UserPosition.find(params[:id])\n end",
"def press(point)\n\t\t@origin = point\n\tend",
"def set_location(map_id, x, y)\n @map_id = map_id\n @x = x\n @y = y\n refresh\n end",
"def place_pos(queen, x, y)\r\n @map[x][y].leave()\r\n queen.goto( @map[x][y], @map[x][y] )\r\n end",
"def proxy_place(x, y)\n execute(:proxy, :place, x, y)\n end",
"def sash_place(index, x, y)\n execute(:sash, :place, index, x, y)\n end",
"def set_user_location\n return unless (search_params[:lat] && search_params[:long]) ||\n search_params[:zip_code]\n\n user_location_object(search_params[:lat], search_params[:long],\n search_params[:zip_code])\n end",
"def place_marker(x, y)\n val = x.to_i - 1\n key = y\n row_arry = @grid_hash[key]\n if row_arry[val] == ' '\n if @@counter.odd?\n # player 1 #\n row_arry[val] = 'x'\n end_turn\n else\n # player 2 #\n row_arry[val] = 'o'\n end_turn\n end\n else\n p 'location taken'\n end\n end",
"def place(x, y, direction_to_face)\n # Check if we're working with a valid destination\n if @table.valid_destination x, y \n # Set our new position instance variable values\n @current_position[:x] = x\n @current_position[:y] = y\n @current_position[:direction] = direction_to_face\n\n puts \"Toy Robot placed at (#{@current_position[:x]}, #{@current_position[:y]}) facing #{@current_position[:direction]}\"\n\n return true\n else\n puts \"Invalid placement given, please specify a valid place within the range of the table in the format X, Y e.g. PLACE 1, 2\" \n return false\n end\n end",
"def place(x, y, direction)\n raise TypeError, 'Invalid coordinates' unless x.is_a? Integer and y.is_a? Integer\n raise TypeError, 'Invalid direction' unless DIRECTIONS.include?(direction)\n\n return false unless valid_position?(x, y)\n @position = { x: x, y: y }\n @direction = direction\n true\n end",
"def place(x, y, direction)\n raise TypeError, 'Invalid coordinates' unless x.is_a?(Integer) && y.is_a?(Integer)\n raise TypeError, 'Invalid direction' unless Constant::DIRECTIONS.include?(direction)\n\n if valid_position?(x, y)\n @position = { x: x, y: y }\n @direction = direction\n true\n else\n false\n end\n end",
"def origin=(point)\n end",
"def set_Latitude(value)\n set_input(\"Latitude\", value)\n end",
"def set_Latitude(value)\n set_input(\"Latitude\", value)\n end",
"def place(x, y, direction)\n raise TypeError, 'Invalid coordinates' unless x.is_a? Integer and y.is_a? Integer\n raise TypeError, 'Invalid direction' unless DIRECTIONS.include?(direction)\n\n if valid_position?(x, y)\n @position = { x: x, y: y }\n @direction = direction\n true\n else\n false\n end\n\n end",
"def move_to (x, y)\n @x, @y = x, y\n end",
"def move_to who, ox, oy, nx, ny\n if oy != nil and ox != nil\n @monster[oy][ox] = nil\n end\n @monster[ny][nx] = who\n return 10, nx, ny\n end",
"def move_to(x, y); end",
"def edit\n @user=current_user\n #Make sure the user exists\n if(@user)\n #Set the values\n @user.lat = params[:lat]\n @user.long = params[:long]\n @user.message = params[:message]\n @user.save\n #Let them know everything went FINE\n render json: {lat: @user.lat, long: @user.long, message: @user.message}\n else\n render json: {error: 'No User Found'}\n end\n end",
"def add(coordinate)\n new_x = @x + coordinate.x\n new_y = @y + coordinate.y\n new_coordinate = Coordinate.new(new_x,new_y)\n end",
"def set_position(x,y,z)\n @api.send(\"player.setPos(#{x},#{y},#{z})\")\n end",
"def moveto(x, y)\n @ox = @x = x\n @oy = @y = y \n @real_x = @x * 128\n @real_y = @y * 128 \n end",
"def set_object_other_position(obj, value)\n obj.x = value if obj\n end",
"def set_Latitude(value)\n set_input(\"Latitude\", value)\n end",
"def set_Latitude(value)\n set_input(\"Latitude\", value)\n end",
"def set_Latitude(value)\n set_input(\"Latitude\", value)\n end",
"def set_Latitude(value)\n set_input(\"Latitude\", value)\n end",
"def set_Latitude(value)\n set_input(\"Latitude\", value)\n end",
"def set_Latitude(value)\n set_input(\"Latitude\", value)\n end",
"def set_Latitude(value)\n set_input(\"Latitude\", value)\n end",
"def set_Latitude(value)\n set_input(\"Latitude\", value)\n end",
"def set_Latitude(value)\n set_input(\"Latitude\", value)\n end",
"def set_Latitude(value)\n set_input(\"Latitude\", value)\n end",
"def set_Latitude(value)\n set_input(\"Latitude\", value)\n end",
"def set_Latitude(value)\n set_input(\"Latitude\", value)\n end",
"def set_Latitude(value)\n set_input(\"Latitude\", value)\n end",
"def set_Latitude(value)\n set_input(\"Latitude\", value)\n end",
"def set_Latitude(value)\n set_input(\"Latitude\", value)\n end",
"def move_to!(x, y, z)\n @origin = Point.new({x: x, y: y, z: z})\n set_vertices\n @origin\n end",
"def set_point(x,y,z)\n @screen_point.x = x\n @screen_point.y = y\n self.x = @screen_point.screen_x\n self.y = @screen_point.screen_y\n self.z = z\n end",
"def assign_user\n if !Window.find(params[:id]).filled_up && Window.find(params[:id]).get_slot.update_attributes(user_id: current_user.id)\n redirect_to events_url, notice: 'You got yourself a slot.'\n else\n redirect_to events_url, notice: 'You done fucked up.'\n end\n end",
"def place_player(loc)\n puts \"Map thinks player was at #{@player_location}\" if Settings.debug_mode()\n place_object(1, @player_location)\n place_object(4, loc)\n @player_location = loc\n puts \"Map thinks player is now at #{@player_location}\" if Settings.debug_mode()\n end",
"def add_piece(coords, piece)\n @grid[coords[0]][coords[1]] = piece\n end",
"def set_object_position(obj, value)\n obj.x = value\n end",
"def set_player_positions\n self.print_grid\n\n xy = self.ask_for_x_y do\n \"Player 1: Where would you like to place your flag?\"\n end\n\n @player1_x = xy[0]\n @player1_y = xy[1]\n \n xy = self.ask_for_x_y do\n \"Player 2: Where would you like to place your flag?\"\n end\n\n @player2_x = xy[0]\n @player2_y = xy[1]\n end",
"def set_place\n @place = Place.find(current_user.place_id)\n end",
"def place_at(x, y, direction)\n @position = [x.to_i, y.to_i]\n @front = case direction.downcase \n when \"north\" then :north\n when \"south\" then :east\n when \"east\" then :south\n when \"west\" then :west\n end\n puts \"position is: #{@position} direction is #{@front}\"\n end",
"def place_ship(ship, grid)\n print \"\\n\\nPlace your #{ship.name}:\\n\"\n show_grid(grid, true)\n print_ship(ship)\n print \"\\n\"\n ship.orientation = get_orientation(ship, grid)\n get_and_set_coordinates(ship, grid)\n end",
"def add_point\n @point = Point.new\n @point.user_id = self.find_id\n @point.save\n end",
"def kick_wall(wall)\n wall.moveTo(@new_x, @new_y)\n #or wall.moveTo(:direction)\n end",
"def set_user_place\n @user_place = UserPlace.find(params[:id])\n end",
"def set_object_position(obj, value)\n obj.x = value if obj\n end",
"def update(point)\n\t\t\n\tend",
"def update(point)\n\t\t\n\tend",
"def mvtb_cursor(x,y)\n (p=$game_player).x = x; p.y = y\n end",
"def xy=(value)\n set(:xy => value)\n end",
"def moveto(x, y)\n @ox = @x = x\n @oy = @y = y\n @real_x = @x * 128\n @real_y = @y * 128\n end",
"def place(ship, coordinates)\n coordinates.each do |sel_coord|\n @board_hash[sel_coord].place_ship(ship)\n end\n end",
"def place(x, y, facing)\n tentative_postion = Position.new(x, y)\n check_position(tentative_postion)\n @position = tentative_postion\n @facing = facing\n end"
] |
[
"0.65855575",
"0.6493982",
"0.6444826",
"0.639282",
"0.63071984",
"0.62104",
"0.6171253",
"0.6163389",
"0.61334705",
"0.61031675",
"0.6080396",
"0.6057807",
"0.6008821",
"0.59542906",
"0.593535",
"0.589696",
"0.58684963",
"0.5863087",
"0.5862918",
"0.58574045",
"0.58562094",
"0.585021",
"0.5836432",
"0.58253956",
"0.58228153",
"0.5816779",
"0.579735",
"0.5776348",
"0.57628435",
"0.5760216",
"0.5757723",
"0.574895",
"0.5740038",
"0.5725834",
"0.571775",
"0.57163525",
"0.5713577",
"0.5706993",
"0.5704322",
"0.56857497",
"0.56789863",
"0.56608033",
"0.56527084",
"0.565199",
"0.5644024",
"0.56348836",
"0.5616074",
"0.56072605",
"0.56055385",
"0.55983084",
"0.5580844",
"0.55770725",
"0.5575993",
"0.5574012",
"0.5574012",
"0.55622995",
"0.5547016",
"0.5545813",
"0.5542996",
"0.55392003",
"0.55132",
"0.5499511",
"0.5496296",
"0.5493395",
"0.5493179",
"0.5493179",
"0.5493179",
"0.549295",
"0.54918826",
"0.54918826",
"0.54918826",
"0.54918826",
"0.54918826",
"0.54918826",
"0.54918826",
"0.54918826",
"0.54918826",
"0.54918826",
"0.54918826",
"0.5489002",
"0.5475052",
"0.54656476",
"0.54635197",
"0.5461967",
"0.5454256",
"0.5449817",
"0.54478204",
"0.54452646",
"0.5444966",
"0.54416466",
"0.5440995",
"0.54340374",
"0.54300946",
"0.54300004",
"0.54300004",
"0.5415666",
"0.5411396",
"0.54110485",
"0.54060656",
"0.5398661"
] |
0.75476843
|
0
|
Counting the caves It will return a list of cave rooms coordinate
|
def populate_caves
for row_i in 1...@height - 1
for column_i in 1...@width - 1
if @map[row_i][column_i] == @FLOOR
union_adjacent_square(row_i, column_i)
end
end
end
@disjoinset.split_sets()
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def door_count; end",
"def count_rooms\n room_count = 0\n rooms = Array.new(@width)\n rooms.each_index() do |index|\n rooms[index] = Array.new(@height, 0)\n end\n @map.each_index() do |x|\n @map[x].each_index() do |y|\n if(!is_solid?(x, y) && rooms[x][y] == 0)\n room_count += 1\n flood_fill(x, y, rooms, room_count)\n end\n end\n end\n return {:rooms => rooms, :room_count => room_count}\n end",
"def room_draws\n return og + oo + cg + co;\n end",
"def painting_count\n self.paintings.length\n end",
"def total_guests_in_rooms()\n guests_in_bar = 0\n for room in @rooms\n guests_in_bar += room.guests_in_room()\n end\n return guests_in_bar\n end",
"def joinees_count\n self.joinees.count\n end",
"def joke_count # {{{\n\n @log.message :debug, \"Entering count function\"\n\n jokes = Joke.all\n sources = Hash.new\n\n sources[ \"Total\" ] = jokes.length\n sources[ \"Manually Entered\" ] = 0\n\n jokes.each do |j|\n source = j.source\n\n if( source == nil )\n sources[ \"Manually Entered\" ] += 1\n else\n sources[ source ] = 0 if sources[ source ].nil?\n sources[ source ] += 1\n end\n end\n\n sources\n end",
"def join_rooms\n all_caves = populate_caves\n for cave in all_caves.keys()\n join_points(all_caves[cave][0])\n end\n end",
"def find_open_rooms(x, y, course) \n temp = 0\n if (course[x][y] != \"Yes\")\n return 0\n else \n #Makes sure it marks as Counted\n course[x][y] = \"Counted\"\n temp+=1\n if x != 0\n temp += find_open_rooms(x-1, y, course)\n end\n if x != course.size-1\n temp += find_open_rooms(x+1, y, course)\n end\n if y != 0\n temp += find_open_rooms(x, y-1, course)\n end\n if y != course.size-1\n temp += find_open_rooms(x, y+1, course)\n end\n return temp\n end \nend",
"def exits\n extractNums= []\n for eIndex in 0...roomAdj.length\n extractNums.append(roomAdj.to_a[eIndex].number)\n end\n return extractNums\n end",
"def count\n merchants.count\n end",
"def hole_count\n holes.count\n end",
"def current_occupancy\n self.dinosaurs.size\n end",
"def find_land world\n count = []\n\n world.each_with_index do |y, y_ind|\n #puts y.index(y_ind)\n world[y_ind].each_with_index do |x, x_ind|\n if world[y_ind][x_ind] == 'land'\n count.push continent_size(world, x_ind, y_ind)\n end\n end\n end\n count\nend",
"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 walks_for_game(game)\n atbats = game.atbats.select {|atbat| atbat.pitcher_id == gameday_id.to_i}\n w_atbats = atbats.select {|atbat| atbat.ball == 4} \n w_atbats.size\n end",
"def count_places\n COUNT_PLACES\n end",
"def mine_count\n grid.flatten.count { |space| space.mine }\n end",
"def count_enemies\n @close_enemies = 0\n Directions.each do |dir|\n @close_enemies += 1 if Enemies.include? warrior.look(dir)[0].to_s.to_sym\n end\n end",
"def compute_occupied_places\n application_letters.where(status: true).count\n end",
"def river_count\n return @fishes.count\nend",
"def shoe_count\n count = @shoe.count\n positive = count >= 0\n \"Current Deck Count: #{positive ? \"+\" : \"-\"}#{count.abs}\"\n end",
"def zone_count\n da_zones=zones\n count = da_zones.count\n da_zones.each{ |z| count += z.zone_count }\n count\n end",
"def count\n @map.count\n end",
"def count_positions(wins, forker, forkee)\n potential_wins = get_potential_wins(wins, forker, forkee)\n position_counts = {}\n potential_wins.each do |potential_win|\n potential_win.each do |position|\n position_counts[position] = 0 if position_counts[position] == nil\n position_counts[position] += 1\n end\n end\n return position_counts\n end",
"def photos_count(photos_rovers)\n\n info_cam = {} \n camera_name = []\n\n photos_rovers.each do |cam|\n info_cam = cam\n camera_name.push(info_cam['camera'])\n end\n \n camera_count = Hash.new(0)\n\n camera_name.each do |num|\n camera_count[num] += 1\n end\n\n photos_div = '\n <div class=\"container p-5\" style=\"margin-top: 100px;\">\n <div class=\"container border border-dark rounded p-2\" style=\"background-color: #D5D8DC;\">\n <div class=\"row col-md-10\">\n <div class=\"col\"><h5>Cámara</h5></div>\n <div class=\"col\"><h5>Cantidad de Fotos</h5></div>\n '\n\n camera_count.each do |name, num, full_name|\n name = name['full_name'] +' (' +name['name'] +')'\n photos_div += \"\n <div class='w-100'></div>\n <div class='col'>#{name}</div>\n <div class='col'>#{num.to_s}</div>\"\n end\n\n photos_div += \"\n <div class='w-100'></div>\n <div class='col mt-2'><h5>Total de Fotos</h5></div>\n <div class='col mt-2'><h5>#{photos_rovers.count}</h5></div>\n </div>\n </div>\n </div>\n \"\n\n return photos_div\n\nend",
"def get_dorm_index\n count = 1\n Dorm.all.each do |d|\n if d == @dorm\n return count\n end\n count += d.rooms.count\n end\n end",
"def walk_through\n count = 0\n for i in 0..@n-1\n for j in 0..@m-1\n if @garden[i][j] == 'W'\n @garden[i][j] = 'C'\n count += 1\n check_around(i,j)\n end\n end\n end\n puts count\n end",
"def number_of_tickets_bought() # working in terminal - console (eg.: customer1.number_of_tickets_bought)\n return films.count\n end",
"def list_buildings\r\n buildings = Building.all\r\n buildings.each do |building|\r\n puts \"#{building} (#{building.machines.count} machines)\"\r\n end\r\nend",
"def return_beds(population, beds)\n beds.each do |from_location|\n @beds[from_location][:available] += 1\n if from_location==population.name\n @beds[from_location][:used_locally] += 1\n end\n raise \"Too many beds returned\" if @beds[from_location][:available]>@beds[from_location][:max]\n end\n beds.count\n end",
"def ship_count\n count = []\n @rows.each do |row|\n count << row.count('s')\n end\n count.reduce(:+)\n end",
"def room(file)\n line = file.gets\n rooms = 0\n if line == nil then return end\n sz, sx, sy, ex, ey = line.split(/\\s/)\n size = sz.to_i\n #Course will represents cells\n #These cells will repsents if it's open or not\n course = Array.new(size)\n course.map!{Array.new(size, \"No\")}\n \n #find_open_rooms will be a recursive method that counts\n #each open room connected each other\n def find_open_rooms(x, y, course) \n temp = 0\n if (course[x][y] != \"Yes\")\n return 0\n else \n #Makes sure it marks as Counted\n course[x][y] = \"Counted\"\n temp+=1\n if x != 0\n temp += find_open_rooms(x-1, y, course)\n end\n if x != course.size-1\n temp += find_open_rooms(x+1, y, course)\n end\n if y != 0\n temp += find_open_rooms(x, y-1, course)\n end\n if y != course.size-1\n temp += find_open_rooms(x, y+1, course)\n end\n return temp\n end \nend\n \n while line = file.gets do\n #Only looks at cell specifications\n if line[0...4] != \"path\"\n x, y, directions, w = line.split(/\\s/,4)\n # checks if all below is true\nif (directions !~ /[A-Za-ce-km-qstv-z]/ && directions.size == 4)\n if (x.to_i != 0 && y.to_i != 0 && y.to_i != size-1 && x.to_i != size-1)\n if directions =~ /l/\n if directions =~ /u/\n if directions =~ /r/\n if directions =~ /d/\n course[x.to_i][y.to_i] = \"Yes\"\n end\n end\n end\n end\n end\n end\n end\n end\n #Will go through each room and counts near open cells\n (1...size-2).each{|x|\n (1...size-2).each{ |y|\n sum = find_open_rooms(x,y,course)\n if sum > rooms\n rooms = sum\n end\n }\n }\n puts rooms\nend",
"def espacios_disponibles_carros\n Space.where(sp_state: false, sp_type: 'CARRO').count\n end",
"def count()\n @list_of_positions.length\n end",
"def num_scenes\n\t\t\t@scenes.length\n\t\tend",
"def count_occurrences(vehicles)\n occurences = {}\n\n vehicles.each do |vehicle|\n occurences[vehicle] = vehicles.count(vehicle)\n end\n\n occurences.each do |vehicle, count|\n puts \"#{vehicle} => #{count}\"\n end\nend",
"def total_orbit_count(orbit_map)\n count = 0\n orbit_map.each{|satellite, _|\n central_objects = orbit_count(orbit_map, satellite)\n # puts \"Satellite %s orbits %d objects\" % [satellite, central_objects]\n count += central_objects\n }\n count\nend",
"def count\n @atlas.count\n end",
"def get_all_dismantle_count\n count = 0\n groups = [$data_items, $data_armors, $data_weapons]\n for group in groups\n for obj in group\n next if obj.nil?\n count += obj.dismantle_counter\n end # for\n end # for\n return count\n end",
"def rooms_count user_id\n count = self.rooms.where(\"user_id = ?\", user_id).count\n free_los = free_los(nil, user_id).count\n count + (free_los / Room::NUMBER_LOS_IN_ROOM.to_f).ceil\n end",
"def count\n @monkeys.count\n end",
"def count\n\n Sizetype.find_all_by_godown_id_and_company_id(1,1).each do |h|\n unless h.quantity.nil?\n @count += h.quantity\n end\n end \n end",
"def counties\n @retailer = Retailer.find(params[:retailer_id])\n @counties = Spree::County.find_all_by_state_id(@retailer.physical_address.state_id)\n end",
"def how_many_on_bus\n return @passengers.length\n end",
"def list_buildings\n buildings = Building.all\n buildings.each do |building|\n puts \"#{building.name} (#{building.machines.count} machines)\"\n end\nend",
"def count \n trips.length\n end",
"def ks_for_game(game)\n atbats = game.atbats.select {|atbat| atbat.pitcher_id == gameday_id.to_i}\n k_atbats = atbats.select {|atbat| atbat.strike == 3} \n k_atbats.size\n end",
"def num_cookmarks\n Rcpref.where([\"recipe_id = ? AND in_collection = ?\", self.id, true]).count\n end",
"def lots_count\t\t\n lots.count\n end",
"def joinees_count_by_type(type)\n self.joinees.by_type(type).count\n end",
"def folders_count\n wayfinder.ephemera_folders_count\n end",
"def game_objects_count\n @game_objects.count\n end",
"def show\n @rooms = Room.all.where(floor_id: @floor.id)\n\n # преобразование массива точек в строку для SVG.js (для полигонов этажей):\n # @showPointsOfFloor = []\n # polygons_ids = Polygon.all.where(imageable_id: @floor.id).map{ |i| i.id }\n # polygons_ids.each do |i|\n # @showPointsOfFloor << Point.all.where(polygon_id: i)\n # .sort_by{ |j| j[:priority] }\n # .map{ |j| \"#{j.ox}, #{j.oy}\" }\n # .join(\" \")\n # end\n\n # преобразование массива точек в строку для SVG.js (для полигонов аудиторий):\n @showPointsOfRooms = []\n @showNamesOfRooms = []\n polygons_ids = Polygon.all.where(imageable_id: Room.all.where(floor_id: @floor.id))\n polygons_ids.each do |i|\n @showPointsOfRooms << Point.all.where(polygon_id: i.id )\n .sort_by{ |j| j[:priority] }\n .map{ |j| \"#{j.ox}, #{j.oy}\" }\n .join(\" \")\n @showNamesOfRooms << Room.all.where(id: i.imageable_id)[0].name\n end\n end",
"def edit\n if current_user.access == 2\n redirect_to \"/users/indexU\"\n end\n @count = Conference.where(id: @booking.conference_id).uniq.pluck(:days).first\n # (1..@count).each do\n puts @count\n end",
"def draws()\n\t\tself.as_regular_contestants.select{|c| c.draw()}.size()\n\tend",
"def turn_count\n count = 0\n cells.each {|pos| count += 1 if pos == \"X\" || pos == \"O\"}\n count\n end",
"def bike_count\n bikes.count\n end",
"def food_count()\nreturn @stomach.count()\nend",
"def numbers_of_planes\n\t\t@landed_planes.count \n\tend",
"def appearances\n positions.size\n end",
"def turn_count\n\t\tcells.count {|cell| cell == \"X\" || cell == \"O\"}\t\n\tend",
"def num_doctors\n doctors.count\n end",
"def cult_population\n by_cult.count\n end",
"def count\n @store.count\n end",
"def disc_count\n @ole.DiscCount\n end",
"def count\n @collector.count\n end",
"def number_of_rides(drivers)\n driver_list = []\n drivers.each do |driver|\n result = 0\n driver[:trips].each do |trip|\n details = trip[:details]\n result += details.length\n end\n driver_list << { driver_id: driver[:driver_id], count: result }\n end\n return driver_list\nend",
"def turn_count\n #@cells.select {|cell| cell == \"X\" || cell == \"O\"}.size\n counter = 0\n @cells.each do |cell|\n if cell != \" \" && cell != \"\"\n counter += 1\n end\n end\n counter\n end",
"def count\n count = 0\n each do |data|\n count += 1\n end\n count\n end",
"def dinosaur_count\n @@count += 1\n end",
"def count(builder)\n m = Either.success(builder.machine)\n\n while m.defined?\n if m.flatmap(&:segment).map{|s| s.node.id == :ST }.fetch(false)\n return m.flatmap{|n| n.distance(builder.machine) }.fetch(0) + 2\n else\n m = m.flatmap(&:parent)\n end\n end\n end",
"def count_new_contracts(month)\n Leaf.\n where(start_date: month.beginning_of_month..month.end_of_month).\n group(:vhiecle_type, :student_flag, :largebike_flag).\n count\n end",
"def same_model_count(reservations)\n count = 0\n reservations.each { |res| count += 1 if (res.equipment_model == self.equipment_model) }\n count\n end",
"def num_gears\n num = 0\n group_instances.each { |g| num += g.gears.count}\n num\n end",
"def count; end",
"def count; end",
"def count; end",
"def count\n @deck.count\n end",
"def dinosaurii_count\n @@count += 1\n end",
"def count\n collection.count\n end",
"def count\r\n @pitches.size\r\n end",
"def count_members\n @band.count\n end",
"def showPiles\n 3.times { |i| puts i.to_s + \" : \" + $piles[i].count().to_s}\nend",
"def get_colony_numbers\n show do\n title \"Count colonies with CFU software\"\n note \"In the gel room, load up the CFU software and prepare the camera.\"\n note \"For each plate: take a picture of the plate, drag the image into the CFU, and record the number of colonies\"\n \n operations.each do |op|\n if op.temporary[:valid_params?]\n plate = op.input(\"Plate\").item\n get \"number\", var: \"n#{plate.id}\", label: \"Number of colonies on #{plate}\", default: 5\n select [\"normal\", \"contamination\", \"lawn\"], var: \"s#{plate}\", label: \"Choose whether there is contamination, a lawn, or whether it's normal.\", default: 0\n end\n end\n end \n end",
"def count\n each.count\n end",
"def number_of_calories\n self.ingredients.sum(\"calories\")\n end",
"def photos_count (rober_data)\n camera_count = {}\n \n rober_data[\"photos\"].each do |photo|\n photo[\"camera\"].each do |k, v|\n if k == \"name\"\n if camera_count.include? v\n camera_count[v] += 1\n else\n camera_count[v] = 1\n end\n end\n end\n end\n camera_count\nend",
"def count_listings\n listings.count\n end",
"def spicy_count\n self.spicies.size\n end",
"def cult_population\n BloodOath.all.select { |oath| self == oath.cult }.count\n end",
"def turn_count\r\n cells.count {|cell| cell == \"X\" || cell == \"O\"}\r\n end",
"def calorie_count\n @sugar_amount * CALORIES_PER_SUGAR_GRAM +\n @flour_amount * CALORIES_PER_FLOUR_GRAM\n end",
"def mine_count\n locations_within_proximity.having_mines.count\n end"
] |
[
"0.6169896",
"0.6118285",
"0.60921013",
"0.60147",
"0.5817462",
"0.5817323",
"0.5746232",
"0.56724656",
"0.56181216",
"0.557766",
"0.5536837",
"0.55094105",
"0.54802287",
"0.54706615",
"0.5459505",
"0.5459505",
"0.5459505",
"0.5459505",
"0.5459505",
"0.5459505",
"0.5459505",
"0.5459505",
"0.5458776",
"0.5455054",
"0.54517376",
"0.54439574",
"0.5439654",
"0.54343885",
"0.54256415",
"0.54204595",
"0.54138255",
"0.5408824",
"0.5404517",
"0.538639",
"0.53446716",
"0.53383553",
"0.5325547",
"0.53240156",
"0.53176534",
"0.531228",
"0.5310704",
"0.53074884",
"0.52977914",
"0.52914417",
"0.5288679",
"0.52743375",
"0.5273573",
"0.5265765",
"0.5262685",
"0.52548736",
"0.525265",
"0.5249493",
"0.52471405",
"0.52418",
"0.52406687",
"0.5235905",
"0.52339077",
"0.52245617",
"0.5199507",
"0.51994425",
"0.51991445",
"0.5187875",
"0.51822937",
"0.51802087",
"0.5172243",
"0.5171909",
"0.51556885",
"0.5154372",
"0.51441324",
"0.5142648",
"0.5139018",
"0.5138922",
"0.5134935",
"0.51348305",
"0.5129928",
"0.51261693",
"0.51174545",
"0.5117316",
"0.51119286",
"0.5109329",
"0.51081955",
"0.5102368",
"0.5094122",
"0.5094122",
"0.5094122",
"0.5083884",
"0.50813115",
"0.50813013",
"0.508115",
"0.50710505",
"0.50685126",
"0.50648445",
"0.5063813",
"0.5059553",
"0.5055121",
"0.505493",
"0.50545764",
"0.5053958",
"0.50519437",
"0.5051891",
"0.50473416"
] |
0.0
|
-1
|
Joining the cave rooms
|
def join_rooms
all_caves = populate_caves
for cave in all_caves.keys()
join_points(all_caves[cave][0])
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def join_room(id)\n @rooms.join id\n end",
"def join\n payload = { \"id\" => id }.to_json\n data = client.post \"#{api_prefix}/user/#{client.user.id}/rooms\", payload\n\n self\n end",
"def room\n end",
"def join\n @room = OnlineMeetingRoom.find_by_id(params[:id])\n role = @room.user_role(current_user)\n unless role == :denied\n join_internal(current_user.full_name, role, :join)\n else\n flash[:notice] = \"#{t('access_denied')}\"\n redirect_to :index and return\n end\n end",
"def room; end",
"def add_room room_name\n @@available_rooms.push room_name unless @@available_rooms.include? room_name\n @rooms_list.append do\n flow :margin => 5 do\n # _why assures me the :checked style will work in the next release\n joined = check :checked => @@joined_rooms.include?(room_name) do |chk|\n @@joined_rooms.push(room_name) and @@room_data[room_name].merge! Chat.join(room_name) if chk.checked?\n Chat.leave(room_name) and @@joined_rooms.delete(room_name) unless chk.checked?\n end\n \n para room_name, :underline => (@room == room_name ? :one : false)\n \n click do\n visit(\"/room/#{room_name}\")\n end unless @room == room_name\n end\n end\n end",
"def server_join(client, body)\n @rooms[body] ||= []\n return nil if @rooms[body].include?(client.name) or body.length != 8\n select_send(MSG_SERVER, EMPTY_ROOM, @keyring.default.iv,\n server_encrypt(\"presence join #{client.name}#{body}\")\n ) { |x| @rooms[body].include?(x.name) }\n if @motd[body]\n select_send(MSG_SERVER, EMPTY_ROOM, @keyring.default.iv,\n server_encrypt(\"motd #{body}#{@motd[body]}\")\n ) { |x| x == client }\n end\n @rooms[body] << client.name\nend",
"def join\n @room = Room.find(params.require(:room_id))\n if @room&.add_user(current_user)\n success\n else\n not_found\n end\n end",
"def rooms_around(room)\n # Get the person's rooms in alphabetical order\n rooms = memberships.unarchived.alpha\n\n # If there are 5 or fewer we don't need to do anything fancy\n return rooms if rooms.length <= 5\n\n # Get the index for the current room\n room_idx = rooms.index(Membership.joining(self,room).first)\n\n # By default, show two rooms on either side\n lower = room_idx-2 < 0 ? 0 : room_idx-2\n upper = room_idx+2 > rooms.length-1 ? rooms.length-1 : room_idx+2\n\n # If this room is near the bottom of the list, fill in from the top\n if lower < 2\n upper += 2-lower\n rooms = rooms[lower..upper][0,5]\n\n # If this room is near the top of the list, fill in from the bottom\n elsif rooms.length-upper < 2\n lower -= rooms.length-upper+1\n logger.debug(\"__NOW__ LENGTH: #{rooms.length}, LOWER: #{lower}, UPPER: #{upper}, IDX: #{room_idx}\")\n rooms = rooms[lower..upper][-5,5]\n\n # No need to fill, just show that subset\n else\n rooms = rooms[lower..upper]\n end\n\n rooms\n end",
"def local_join(body)\n room = body.dup\n room[0,1] = '' until room[0,1] != '@'\n return nil unless room.length >= 1\n unless @var[:special_rooms].include?(room)\n room_hash = MD5::digest(room)[0,8]\n room_hash = EMPTY_ROOM if room == 'chat'\n @connection.room_names[room_hash] = room\n @connection.room_ids[room] = room_hash\n _remote_control(@var[:our_name], :invite, body, true)\n _server_control('join', room_hash)\n end\n local_switch(room.dup)\nend",
"def joinRoom(roomname, username)\n room = @chats.fetch roomname #get record of \"chats\"\n #puts(room)\n userID = @users.fetch username\n puts(\"joinroom userID #{userID}\")\n puts(userID)\n room.addUser(userID, username) #add user to that chat\n puts room.printMe\n end",
"def update_rooms\n Room.find_or_create_by(name: @moving_item.room)\n end",
"def join\n end",
"def assign_room\n total_rooms, available_rooms = [], []\n room_type = RoomType.find(self.room_type_id)\n total_rooms = room_type.rooms.pluck(:id)\n booked_rooms = Booking.where('(start_date >= ? and start_date <= ?) or (end_date >= ? and end_date <= ?)', self.start_date, self.end_date, self.start_date, self.end_date).pluck(:room_id)\n available_rooms = total_rooms - booked_rooms\n self.update_column(:room_id, available_rooms.first)\n end",
"def find_adjacent_rooms(from)\r\n return from.return_adjacent_rooms\r\n end",
"def join\n @reservation = Reservation.find(params[:reservation_id])\n Dining.create(reservation: @reservation, member: current_member)\n Reservationrequest.where(reservation_id: @reservation.id, member_id: @reservation.members.last.id).destroy_all\n flash[:notice] = \"You joined #{@reservation.members.first.first_name} #{@reservation.members.first.last_name}'s reservation.\"\n redirect_to member_reservations_path\n end",
"def groom\n end",
"def join\n # Check status first to see if the user can join.\n # Check if the number of users exceed the the size of the room.\n @room = Room.find(params[:id])\n\n # Room is oversize\n if @room.is_full?\n message = \"#{current_user.name} cannot joined the room because the room is full.\"\n result = false\n elsif @room.status != ROOM_STATUS[:open]\n message = \"The room #{params[:id]} is not open!\"\n elsif @room.join?(current_user)\n message = \"#{current_user.name} is already joinned the room\"\n else\n\n result = @room.join(current_user)\n if result\n message = \"#{current_user.name} has joined the room\"\n else\n message = \"#{current_user.name} cannot join the room. Server side error\"\n end\n end\n\n if result\n channel = params[:id].to_s\n respond_message = {\n message: message,\n current_user: current_user,\n room_id: @room.id,\n status: USER_STATUS[:join]\n }\n self.broadcast_message_to_channel(channel, :user_status, respond_message)\n else\n channel = \"server_channel\"\n self.broadcast_message_to_channel(channel, :user_status, respond_message)\n end\n\n respond_to do |format|\n if result\n format.html { redirect_to @room, notice: message }\n format.json { render json: @room.to_hash_with_users(current_user).to_json, status: :created, location: @room }\n else\n format.html { render notice: \"Cannot join the room.\" }\n format.json { render json: {message: message}, status: :unprocessable_entity }\n end\n end\n end",
"def add_rooms_to_dungeon(dungeon)\n dungeon.add_room(:largecave,\n \"Large Cave\",\n \"a large cavernous cave\",\n { :west => :smallcave })\n\n dungeon.add_room(:smallcave,\n \"Small Cave\",\n \"a small, claustrophobic cave\",\n { :east => :largecave })\n\nend",
"def allocate_rooms(sorted_teams_and_adjs, round, format)\n\t\t \tsorted_teams = sorted_teams_and_adjs[0].to_a;\n\t\t sorted_wings = sorted_teams_and_adjs[1].to_a;\n\t\t \n\t\t #seperate the chair judges\n\t\t num_rooms = sorted_teams.count / GlobalConstants::FORMAT[format][:num_teams_per_room];\n\t\t sorted_chairs = sorted_wings.pop(num_rooms);\n\n\t\t #shuffle adjs?\n\n\t\t #get list of rooms that are left\n\t\t rooms = round.tournament.rooms.shuffle;\n\n\t\t while(!sorted_teams.empty?) #assumes multiple of 4 num elts\n\t\t assign_top_bracket(num_rooms, sorted_teams, sorted_chairs, sorted_wings, rooms, round, format); #assign the top brack rooms\n\t\t end\n\t\t end",
"def assign_rooms(guests)\n guests.map{|guest| \"Hello, #{guest}! You'll be assigned to room #{guests.index(guest) + 1}!\"}\nend",
"def occupy_room(room)\n room.occupied = 1\n end",
"def search_rooms\n end",
"def join\n\t\t@classroom = Classroom.find(params[:id])\n\n\t\tparams[:user_id] = current_user.id unless admin? && params[:user_id]\n\n\t\t@membership = Membership.new\n\t\t@membership.classroom_id = @classroom.id\n\t\t@membership.user_id = params[:user_id]\n\t\tif @membership.save\n\t\t\tredirect_to params[:redirect_url] || @classroom, notice: \"Joined!\"\n\t\telse\n\t\t\tredirect_to @classroom, alert: \"You are already a member of this class!\"\n\t\tend\n\tend",
"def book_rooms\n @room_category= RoomCategory.all\n end",
"def room_list\n\t\t@room = Accommodation.find_all_by_host_id(@current_user.id)\n\t\t@date = RoomBooking.find_all_by_room_id(@room)\n \tend",
"def new_rooms\n min_rooms = MIN_NEXT_ROOMS\n max_rooms = MAX_NEXT_ROOMS\n rand(min_rooms..max_rooms).times do\n @next_rooms << Zarta::Room.new(@dungeon)\n end\n end",
"def rooms\n Hpricot(get.body).search(\"//h2/a\").collect do |a|\n Room.new(self, room_id_from_url(a.attributes['href']), a.inner_html)\n end\n end",
"def show\n gon.current_user = current_user\n gon.users = @room.users\n @new_room = Room.new\n @rooms = Room.all\n end",
"def join_path(room, name, options = {}, uid = nil)\n\n # Destroy otp current_session\n current_user.destroy_otp if current_user&.room_otp.present?\n session.delete(:otp_name)\n\n # Create the meeting, even if it's running\n start_session(room, options)\n\n # Determine the password to use when joining.\n password = options[:user_is_moderator] ? room.moderator_pw : room.attendee_pw\n\n # Generate the join URL.\n join_opts = {}\n join_opts[:userID] = uid if uid\n join_opts[:join_via_html5] = true\n\n bbb_server.join_meeting_url(room.bbb_id, name, password, join_opts)\n end",
"def join_room uri\n has_room = rooms.detect { |room| room.uri == uri }\n\n return has_room if has_room\n\n @rooms = nil # clear rooms cache\n self.class.find_room(uri).join\n end",
"def checkroom(r)\n case r.status\n when :plan\n # moot\n when :dig\n # designation cancelled: damp stone etc\n r.dig\n when :dug, :finished\n # cavein / tree\n r.dig\n # tantrumed furniture\n r.layout.each { |f|\n next if f[:ignore]\n if f[:bld_id] and not df.building_find(f[:bld_id])\n df.add_announcement(\"AI: fix furniture #{f[:item]} in #{r.type} #{r.subtype}\", 7, false) { |ann| ann.pos = [r.x1+f[:x].to_i, r.y1+f[:y].to_i, r.z1+f[:z].to_i] }\n f.delete :bld_id\n @tasks << [:furnish, r, f]\n end\n }\n # tantrumed building\n if r.misc[:bld_id] and not r.dfbuilding\n df.add_announcement(\"AI: rebuild #{r.type} #{r.subtype}\", 7, false) { |ann| ann.pos = r }\n r.misc.delete :bld_id\n construct_room(r)\n end\n end\n end",
"def checkroom(r)\n case r.status\n when :plan\n # moot\n when :dig\n # designation cancelled: damp stone etc\n r.dig\n when :dug, :finished\n # cavein / tree\n r.dig\n # tantrumed furniture\n r.layout.each { |f|\n next if f[:ignore]\n t = df.map_tile_at(r.x1+f[:x].to_i, r.y1+f[:y].to_i, r.z1+f[:z].to_i)\n if (f[:bld_id] and not df.building_find(f[:bld_id]))\n df.add_announcement(\"AI: fix furniture #{f[:item]} in #{r.type} #{r.subtype}\", 7, false) { |ann| ann.pos = t }\n f.delete :bld_id\n @tasks << [:furnish, r, f]\n end\n if f[:construction]\n try_furnish_construction(r, f, t)\n end\n }\n # tantrumed building\n if r.misc[:bld_id] and not r.dfbuilding\n df.add_announcement(\"AI: rebuild #{r.type} #{r.subtype}\", 7, false) { |ann| ann.pos = r }\n r.misc.delete :bld_id\n construct_room(r)\n end\n end\n end",
"def index\n @rooms = Room.all\n @rooms = @venue.rooms.all\n end",
"def connect(room)\n \n temp=Set.new([room])\n \n #Nil arr = false\n if !@@adjToRoom[self.number-1]\n @@adjToRoom[self.number-1]=temp\n #Add connectivity to reciprocal list \n connectBiDirectional(self,room)\n else \n @@adjToRoom[self.number-1].add(room) \n connectBiDirectional(self,room)\n end \n end",
"def connected_rooms\n return (self.exits.map(&:destination) + @entrances.to_a).reject{ |room| room == self }\n end",
"def create_default_rooms\n wish_list_name = 'Wish List'\n self.dressing_rooms.create label: wish_list_name unless self.dressing_rooms.any? {|room| room.label == wish_list_name}\n\n closet_name = 'My Closet'\n self.dressing_rooms.create label: closet_name unless self.dressing_rooms.any? {|room| room.label == closet_name}\n\n session_name = \"My Cart\"\n session_room = self.dressing_rooms.create label: session_name unless self.dressing_rooms.any? {|room| room.label == session_name}\n self.recent_dressing_room = session_room if self.recent_dressing_room.nil?\n self.save!\n end",
"def create\n @room = Room.new(room_params)\n @room = @venue.rooms.new(room_params)\n\n if @room.save\n redirect_to venue_rooms_path\n else\n render :action => 'new'\n end\n end",
"def join(subdomain = nil, room_name = nil, &block)\n #raise \"#{su}: #{caller[0]}\"\n\n if subdomain && room_name && !subdomain.kind_of?(Firetower::Session) && !room_name.kind_of?(Firetower::Room)\n warn \"WARNING: `join` is deprecated. use `join_room` instead: #{Kernel.caller.first.gsub(/:in .*$/, '')}\"\n join_room(subdomain, room_name)\n else\n # gross, copy pasta from hookr\n add_callback(:join, subdomain, &block)\n end\n end",
"def show\n @rooms = @blueprint.rooms\n end",
"def test_mates\n enter_the_room \"Not me\"\n #change test room\n @room_name=\"zz\"\n # add dude that will left by timeout\n enter_the_room \"a\"\n sleep Active_session::WAIT_TIMEOUT*4\n # enter and the leave\n session=enter_the_room(\"leaver\")[\"session\"]\n leave session\n # add couple of dudes\n enter_the_room \"b\"\n session=enter_the_room(\"c\")[\"session\"]\n # check that everything ok\n result=get_mates(session)[\"mates\"]\n assert result == [\"b\",\"c\"] || result == [\"c\",\"b\"], \"result:\"+\n result.join(\",\")\n end",
"def room\n Room.all.find { |room| room.id == room_id }\n end",
"def onomatopoeic_join(phonemes)\n phonemes.join unless phonemes.empty?\n end",
"def show\n @companies = Company.where('floor_id = ?', @floor.id)\n @spaces = MeetingRoom.where('floor_id = ?', @floor.id)\n end",
"def use(current_room, command_params)\n if command_params.empty?\n puts \"Use what?\"\n elsif command_params.length > 3\n puts \"What are you trying to do, make a coctail? Combining two items should be sufficient.\"\n elsif command_params[1] != \"on\"\n puts \"That's not the right way to combine stuff\"\n else\n command_params.delete(\"on\")\n object1 = command_params[0].intern\n object2 = command_params[1].intern\n\n # first check of the two objects are in the inventory\n if $inventory.key?(object1) && $inventory.key?(object2)\n # then create an instance of the first object\n object1_instance = $inventory[object1]\n # check if it can be combined with the second object\n if object1_instance.action[:use_with] != object2.to_s\n puts \"You can't do that, at least not now.\"\n else\n # print out the result of the combination\n puts object1_instance.action[:text]\n new_object_key = object1_instance.action[:result]\n object1_instance.action[:deleted_objects].each do |d|\n $inventory.delete(d)\n end\n object1_instance.action[:created_objects].each do |c|\n $inventory[new_object_key] = c\n end\n end\n # now check if the first object is in the inventory and the second is in the current room\n elsif $inventory.key?(object1) && current_room.game_objects.key?(object2)\n # then create an instance of the first object\n object1_instance = $inventory[object1]\n # check if the first object can be combined with the second object\n if object1_instance.action[:combine_with] != object2.to_s\n puts \"You can't do that, at least not now.\"\n else\n # print out the result of the combination\n puts object1_instance.action[:text]\n end\n else\n puts \"That doesn't make sense\"\n end\n end\n end",
"def join\n @beer_club = BeerClub.find(params[:id])\n if Membership.where(:beer_club_id => @beer_club.id, :user_id => current_user.id).exists?\n respond_to do |format|\n format.html { redirect_to :back, notice: \"You are already a member of this club!\" }\n end\n else\n @membership = Membership.create\n @membership.beer_club_id = @beer_club.id\n @membership.user_id = current_user.id\n if @beer_club.memberships.count < 1\n @membership.confirmed = true\n else\n @membership.confirmed = false\n end\n respond_to do |format|\n if @membership.save\n format.html { redirect_to :back, notice: \"You joined #{@beer_club.name}\" }\n else\n format.html { redirect_to :back, notice: \"Something went awry! D:\" }\n end\n end\n end\n end",
"def set_current_room\n if cr.defeated\n $map.level_rooms.each do |r|\n if self.bounding_box_collision?(r)\n @cr = r\n end\n end\n $map.hallways.each do |h|\n if self.bounding_box_collision?(h)\n @cr = h\n end\n end\n end\n end",
"def available_rooms\n @booking = current_user.bookings.new(booking_params)\n @hotel_rooms = @hotel_category.hotel_rooms.available_rooms(params[:booking][:check_in], params[:booking][:check_out])\n end",
"def join\n game = Game.find(params[:id])\n \n raise \"Game already started\" unless game.open?\n \n # Only add the player to the game if they aren't already in it\n game.join(current_user) unless game.has_player?(current_user)\n current_user.lives = 25\n current_user.save!\n redirect_to game_path\n rescue \n flash[:error] = \"That is not a game that can be joined\"\n redirect_to lobby_path\n end",
"def list_reserved_rooms\n unless @rooms.empty?\n @rooms.each do |key, room|\n puts room.report_lister\n end\n end\n end",
"def rooms_list\n\t\t\t@rooms.map {|room| \"Room: #{room.id}\"}.join(\", \")\n\t\tend",
"def room\n return self\n end",
"def show\n @rooms= Room.all.order(\"RANDOM()\").limit(3)\n @reservation=current_user.reservations.build\n end",
"def join_cult(cult)\n Bloodoath.new(cult, self) \n end",
"def self_joined_room(&block)\n presence(:from => Blather::JID.new(agent_jid_in_room), :type => nil, &block)\n end",
"def join\n @club = Club.find(params[:id])\n authorize @club\n @club.club_memberships.create! user_id: current_user.id\n redirect_to action: :show\n end",
"def search\n '''\n param: date - string\n param: start - string\n param: capacity - string\n param: length - string\n\n '''\n\n avail_rooms_id = []\n i = 1\n start_date_time = Time.parse(params[:date] + \" \" + params[:start])\n end_date_time = start_date_time + (60 * 60 * Integer(params[:length]))\n curr_date_time = start_date_time + (60 * 60)\n meal_room_cap = Integer(params[:capacity]) * 6/10\n comp_room_cap = Integer(params[:capacity]) * 1/10\n\n # Finds and adds conference to desired schedule id's\n conf_room = Schedule.where(\"cap > ? and time = ? and date = ? and avail = true\", \n params[:capacity], \n params[:start], \n params[:date]\n ).ids.first\n\n avail_rooms_id << conf_room\n\n while(curr_date_time != end_date_time - (60 * 60)) do\n \n curr_hour = curr_date_time.strftime('%I:%M %p')\n curr_date = curr_date_time.strftime('%F')\n \n # If i % 6, find room to eat with 60% of participants \n if i % 6 == 0\n\n meal_room = Schedule.where(\"cap > ? and time = ? and date = ? and food = true and avail = true\",\n meal_room_cap,\n curr_hour,\n curr_date\n ).ids.first\n\n avail_rooms_id << meal_room\n\n # else find room with computers to support 10% of participants\n else\n\n comp_room = Schedule.where(\"cap > ? and time = ? and date = ? and comp_avail = true and avail = true\",\n comp_room_cap,\n curr_hour,\n curr_date\n ).ids.first\n \n avail_rooms_id << comp_room\n \n end\n \n # Increments iteration, date, and time\n i += 1\n curr_date_time += (60 * 60)\n end\n\n # Finds and adds final room to desired schedule id's\n final_room = Schedule.where(\"cap > ? and time = ? and date = ?\",\n params[:capacity],\n end_date_time.strftime('%I:00 %p'),\n end_date_time.strftime('%F')\n ).ids.first\n \n avail_rooms_id << final_room\n\n # Checks if rooms were found and assigns them to instance variable\n if avail_rooms_id.empty? == false\n @avail_rooms = Schedule.find(avail_rooms_id)\n end\n end",
"def new\n @room = Room.new\n @room = @venue.rooms.new\n end",
"def join_cult(new_cult)\n # follows single source of truth: many ~*~connecting~*~ to many via the dongle class\n if @age > new_cult.minimum_age\n BloodOath.new(Date.today.to_s, new_cult, self)\n else \n p \"I'm sorry, you are too young to join our community. Please come visit us again in #{new_cult.minimum_age - @age} year(s)!\"\n end\n end",
"def join\n \n #TODO add player to hunt\n #player = User.find(params[:id])\n redirect_to hunt_player_path()\n end",
"def join(force = false)\n post 'join'\n end",
"def sync_rooms\n create_rooms if hotel.rooms.size.zero?\n hotel.rooms.real.each do |room|\n room_id = room.send(connector_room_id_key)\n setup_room_prices(room_id, room.id)\n end\n end",
"def find_available_rooms(rooms, start_date: Date.today, end_date: Date.today + 2)\n return Room.all_available_rooms(rooms, start_date: start_date, end_date: end_date)\n end",
"def roll\n room = Room.new\n room.short_name = short_name\n room.description = description\n room\n end",
"def shared_rooms\n Room.where(id: shared_access.pluck(:room_id))\n end",
"def rooms_from_category(category)\n rooms.find_all do |room|\n room.category(:bedroom)\n end\n require \"pry\"; binding.pry\n end",
"def join\n redirect_to event_url(@event) unless @current_role.blank? || @current_role.new_record?\n end",
"def join\n @character = Character.find(params[:id])\n return_to = Rails.application.routes.recognize_path(request.referrer)[:controller] == \"characters\" ? @character : request.referrer\n if @character.join!\n redirect_to return_to, notice: \"Character is now adventuring in this campaign\"\n else\n flash[:alert] = \"Unable to proccess\"\n render 'show'\n end\n end",
"def assign_room_for_bracket(num_rooms, teams, sorted_chairs, sorted_wings, rooms, round, format)\n\t\t \t#select a room at random for this room\n\t\t \troom = rooms.pop(); #they have already been shuffled\n\n\t\t #for now, we randomly assign teams within the bracket\n\t\t rd = RoomDraw.new(tournament_id: round.tournament[:id], round_id: round[:id], \n\t\t \t\t\t\t\t room_id: room, #it is already an id \n\t\t \t\t\t\t\t status: GlobalConstants::ROOM_DRAW_STATUS[:not_finished]);\n\n\t\t i = 0;\n\t\t while(i < GlobalConstants::FORMAT[format][:num_teams_per_room])\n\t\t #select team at random from the remaining amount\n\t\t chosen_team = teams.pop(); #the bracket was already shuffled\n\t\t #we can just pick them out in order\n\n\t\t #ensure this team has not been this position too many times\n\t\t #the position is i (0 for OG, 1 for OO, etc.)\n\t\t #SOME LOGIC\n\n\t\t #if good selection, remove from the hat\n\t\t teams.delete(chosen_team); #remove team since taken for round\n\t\t \t \n\t\t #input team into room draw\n\t\t input_team(rd, chosen_team, i, format);\n\t\t \n\t\t i = i + 1; #increment to know we have allocated a team\n\t\t end\n\n\t\t #try to save this room since we have all the info\n\t\t if !rd.save();\n\t\t \tthrow(\"Could not save RoomDraw.\");\n\t\t end\n\t\t \n\t\t #throw in the adjs based simply on rank and top room\n\t\t input_adjs(rd, sorted_chairs, sorted_wings, \n\t\t \t\t\t calculate_num_adjs(num_rooms, sorted_chairs.count, sorted_wings.count));\n\n\t \t\n\t \t@num_rooms_assigned = @num_rooms_assigned + 1;\n\t \tround.tournament.update(progress: ((@num_rooms_assigned / num_rooms.to_f) * 100));\n\t\t end",
"def assign_rooms (names_list)\n\t\nmsgs_with_room_no=names_list.collect.each_with_index{ |current_name,current_index| \"Hello, #{current_name}! You'll be assigned to room #{current_index+1}!\"\n }\n\t\nend",
"def room_draws\n return og + oo + cg + co;\n end",
"def initialize\n \t@grid_w = 50\n \t@grid_h = 40\n \t@grid = []\n\t\n\t\t@player_x = 0\n\t\t@player_y = 0\n\t\t@has_enviroment_rendered=false\n\t\t#setup and fill grid with walls\n \t@grid_w.times.with_index do |x|\n \t\t@grid[x] = []\n\t\t\t@grid_h.times.with_index do |y|\n \t\t\t@grid[x][y]= 1\n \t \tend\n \tend\n\t\tmin_rooms = 2\n\t\tmax_rooms = 10\n\t\t#setup number of rooms that will exist\n\t\t@n_rooms = rand(max_rooms - min_rooms) + min_rooms\n\t\tputs \"n rooms #{@n_rooms}\"\n\t\trooms = []\n\t\t#define the size of each room\n\t\t@n_rooms.times.with_index do |room|\n\t\t\trooms[room] = make_room 8,10\n\t\tend\n\t\n\t\t#clears the walls from where rooms will be \n\t\trooms.each_with_index do |r,i| \n\t\t\t(r[:x]..r[:x] + r[:w]).each do |x|\n\t\t\t\t(r[:y]..r[:y] + r[:h]).each do |y|\n\t\t\t\t\t@grid[x][y]= 0\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t#create pathways towards the next room\n\t\trooms.each_cons(2) do |(cur_room, next_room)|\n\t\t\t#find the center of each room \n\t\t\tcenter_x = cur_room[:x] + cur_room[:w].idiv(2)\n\t\t\tcenter_y = cur_room[:y] + cur_room[:h].idiv(2)\n\n\t\t\tnext_center_x = next_room[:x] + next_room[:w].idiv(2)\n\t\t\tnext_center_y = next_room[:y] + next_room[:h].idiv(2)\n\n\t\t\t#loops between each rooms X and Y positions \n\t\t\t#this can be approached differently\n\t\t\t(min(center_x,next_center_x)..max(center_x,next_center_x)).each do |x|\n\t\t\t\t(min(center_y,next_center_y)..max(center_y,next_center_y)).each do |y|\n\t\t\t\t\t#checking if this position is in-line with either rooms x or y centres\n\t\t\t\t\t@grid[x][y] = 0 if y == center_y || y == next_center_y || x == center_x || x == next_center_x\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t@new_grid = []\n\t\t#set new grid to prune unneeded walls to improve performance\n\t\t@grid_w.times.with_index do |x|\n\t \t@new_grid[x] = []\n\t \t@grid_h.times.with_index do |y|\n \t\t\t@new_grid[x][y]= @grid[x][y]\n\t\t\tend\n\t end\n\t\t#set up values\n\t\t@grid_w.times.with_index do |x|\n \t\t@grid_h.times.with_index do |y|\n\t\t\t\t#if surrounded it should not be filled in\n\t\t\t\tif check_surrounding_tiles x,y\n\t\t\t\t\t@grid[x][y] = 0\n\t\t\t\tend\n \t\tend\n \tend\n\t\t#this will set the players starting position to a known safe area\n\t\t@player_x = rooms[0][:x] + rooms[0][:w].idiv(2)\n\t\t@player_y = rooms[0][:y] + rooms[0][:h].idiv(2)\n\t\t@grid[@player_x][@player_y] = 2\n\tend",
"def room\n return Cave.roomInstance(@@currentRoom-1)\n end",
"def build_room_buildings()\n buildings = {}\n $item_by_id.fetch('/buildings/')[:map].each do |building, roomlist|\n roomlist = [] if roomlist.nil?\n\n bcode = building.to_s.upcase\n list = []\n roomlist.map(&$to_room_or_nil).reject(&:nil?).each do |r|\n list << r\n end\n rooms.select { |r| r[:slug].upcase.start_with? bcode }.each do |r|\n list << r\n end\n buildings[bcode] = list.uniq { |r| r[:slug] }.sort_by { |r| [r[:rank], r[:conference_room_id]] }\n buildings[bcode].each do |r|\n r[:building] = bcode\n end\n end\n\n # make sure there are no rooms left without a :building meta attribute\n begin\n errors = rooms.select { |r| r[:building].nil? }\n raise \"there are #{errors.size} room(s) without a building assignment, please put them into content/building.yaml: #{errors.map { |r| r[:slug] }.join(\", \")}\" unless errors.empty?\n end\n\n room_to_building = {}\n buildings.each do |bcode, rooms|\n rooms.each do |r|\n room_to_building[r[:slug]] = bcode\n end\n end\n\n [buildings, room_to_building]\n end",
"def check_in(guest1, room)\n if room.length <= 4\n p \"welcome, #{guest1}\" && room << guest1\n else room.length >= 5\n p \"no room, #{guest1}\"\n end\nend",
"def generate_rooms\n\n allocated_cells = get_allocated_cells\n taken_cells = 0\n room_id = 1\n\n max_room_w = @width * Dungeon::ROOM_SIZE_WEIGHT - 1\n max_room_h = @height * Dungeon::ROOM_SIZE_WEIGHT - 1\n\n # Make rooms until all the allocation has dried out\n while taken_cells < allocated_cells\n\n r_w = (rand*max_room_w).ceil + 1\n r_h = (rand*max_room_h).ceil + 1\n if r_w.odd? && r_h.odd?\n place_room(r_w, r_h, room_id)\n taken_cells += r_w*r_h\n room_id += 1\n end\n end\n end",
"def go_room(command)\n if @current_room.has_exit?(command) \n # current room has this exit \n exit_room = @current_room.get_exit(command) # return string of room name\n # Search for instance of this room\n # update current room\n @game_rooms.each do |room|\n if room.is_room?(exit_room)\n @current_room = room # update current room\n end\n end\n puts \"\\nYou have entered the #{@current_room.print_name}!\\n\"\n else \n puts \"That is not a direction you can travel.\\n\"\n end\n end",
"def join; end",
"def place_room(w,h,room_id)\n \n max_tries = Dungeon::MAX_PLACEMENT_ITERATION\n c_try = 0\n while c_try < max_tries\n\n # Get the top left corner, must be even \n tli = (rand*@width).floor\n tli += 1 if tli.odd?\n tlj = (rand*@height).floor\n tlj += 1 if tlj.odd?\n\n # Check all the cells from this point are unallocated, \n # and an extra 1 width around for perimeter\n failed = false\n (tli..tli+w+1).each do |i|\n (tlj..tlj+h+1).each do |j|\n if !failed\n failed = true if @cells[i][j].type != Cell::UNALLOCATED\n end\n end\n end\n\n \n # if checks ok, build the room and the perimeter\n if !failed\n\t\t\t\t# Probability falls so there are an average of 2 doors per room\n\t\t\t\tper = 2*(w+h)\n\t\t\t\tdoor_chance = Dungeon::ROOM_DOORS/per\n\n\t\t\t\t# Prep for building a logical object ready for dead end removal\n\t\t\t\troom_cells = []\n\n (tli..tli+w+1).each do |i|\n (tlj..tlj+h+1).each do |j|\n @cells[i][j].type = Cell::ROOM\n @cells[i][j].room_id = room_id\n\t\t\t\t\t\t\t# If perimeter wall, assign door if random number is under the threshold\n \t\t\t\t\t\tif i == tli || i == tli+w+1 || j == tlj || j == tlj+h+1 \n @cells[i][j].type = Cell::PERIMETER \n\t\t\t\t\t\t\t\tif i.odd? || j.odd?\n\t\t @cells[i][j].type = Cell::ENTRANCE if rand < door_chance\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\t# Store the room cells read for assignment to logical structure\n\t\t\t\t\t\t\troom_cells << @cells[i][j];\n end\n end\n # Meet loop criterea\n c_try = Dungeon::MAX_PLACEMENT_ITERATION\n\n\t\t\t\t# Build logical object and map entrance cells to the room\n\t\t\t\troom_obj = RoomBranch.new(room_cells)\n\t\t\t\troom_cells.each { |c| room_map[c] = room_obj if c.type == Cell::ENTRANCE }\n\n end\n \n c_try += 1\n end\n \n end",
"def assign_rooms(guest_list)\n #each_with_index: keep track of each name provided and push the message to new array with the name and message\n room_assignments = []\n guest_list.each_with_index { |name, index| room_assignments << \"Hello, #{name}! You'll be assigned to room #{index+1}!\" }\n room_assignments\nend",
"def join_request\n \n end",
"def create_room(company, params = {})\n $LOG.i \"running \" + __method__.to_s\n @client.post '/messages/v3/' + company + '/rooms', params\n end",
"def test_room_paths()\n \t# the parameter is the (name, description) in initialize in class Room\n \t# to create new room of center/north/south\n center = Room.new(\"Center\", \"Test room in the center.\")\n north = Room.new(\"North\", \"Test room in the north.\")\n south = Room.new(\"South\", \"Test room in the south.\")\n\n # to add path of center room\n center.add_paths({:north => north, :south => south})\n\n # check if center.go(:north) really goes to north\n assert_equal(center.go(:north), north)\n # check if center.go(:south) really goes to south\n assert_equal(center.go(:south), south)\n end",
"def generate_rooms\n\n allocated_cells = get_allocated_cells\n taken_cells = 0\n room_id = 1\n\n max_room_w = @width * Dungeon::ROOM_SIZE_WEIGHT - 1\n max_room_h = @height * Dungeon::ROOM_SIZE_WEIGHT - 1\n\n # Make rooms until all the allocation has dried out\n while taken_cells < allocated_cells\n \n r_w = (rand*max_room_w).ceil + 1\n r_h = (rand*max_room_h).ceil + 1\n if r_w.odd? && r_h.odd? \n place_room(r_w, r_h, room_id) \n taken_cells += r_w*r_h\n room_id += 1\n end\n end\n \n puts \"Alloc: #{allocated_cells} Placed:#{taken_cells}\"\n\n end",
"def join\r\n if @trip.participants.include?(current_person)\r\n redirect_to(@trip, :notice => \"You are already a participant in the #{@trip.name}.\")\r\n return\r\n elsif @trip.organizers.include?(current_person) && request.post?\r\n @trip.participants << current_person\r\n redirect_to(manage_membership_trip_url(@trip), :notice => \"You are now a participant in the #{@trip.name}.\")\r\n else\r\n @token = params[:token]\r\n invitation = Invitation.find_by_token(@token)\r\n if invitation.nil?\r\n redirect_to(person_root_url, :error => \"The invitation link you followed is invalid.\")\r\n return\r\n end\r\n \r\n if request.post?\r\n invitation.accept(current_person)\r\n redirect_to(manage_membership_trip_url(@trip), :notice => \"You are now a participant in the #{@trip.name}.\")\r\n end\r\n end\r\n end",
"def assign_rooms(speakers)\n assigned_rooms = []\n speakers.each.with_index(1) do |speaker, room| \n assigned_rooms << \"Hello, #{speaker}! You'll be assigned to room #{room}!\"\n end\n return assigned_rooms\nend",
"def room_entry(capacity)\n if capacity <= 20\n return \"Welcome to the CCC Elvis Room\"\n else\n return \"I'm sorry we are at capacity you could try one of our other rooms\"\n end\n end",
"def create\n \n filteredParams = params.require(:room).permit(:name, :owner_id, :privacy, :password)\n\n if filteredParams[\"privacy\"] && filteredParams[\"privacy\"] == \"on\"\n filteredParams[\"privacy\"] = \"private\"\n else\n filteredParams[\"privacy\"] = \"public\"\n end \n\n if filteredParams[\"name\"].empty?\n res_with_error(\"Invalid parameters\", :bad_request)\n return (false)\n end\n if filteredParams[\"privacy\"] == \"private\"\n if filteredParams[\"password\"].empty?\n res_with_error(\"None empty password required if the room is private\", :bad_request)\n return (false)\n else\n roomPassword = BCrypt::Password.create filteredParams[\"password\"]\n filteredParams[\"password\"] = roomPassword\n end\n end\n\n if !filteredParams[\"name\"] || filteredParams[\"name\"].length == 0 || filteredParams[\"name\"].blank?\n res_with_error(\"Empty Room Name\", :bad_request)\n return (false)\n elsif filteredParams[\"name\"] && filteredParams[\"name\"].length > 42\n res_with_error(\"Room name too long\", :bad_request)\n return (false)\n end\n\n @room = Room.create(filteredParams)\n if @room && !current_user.rooms_as_admin.include?(@room)\n @rla = RoomLinkAdmin.new(room: @room, user: current_user)\n @rla.save\n end\n \n respond_to do |format|\n if @room.save\n ActionCable.server.broadcast \"room_channel\", type: \"rooms\", description: \"create\", user: current_user\n format.html { redirect_to @room, notice: 'Room was successfully created.' }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new }\n format.json { render json: {alert: \"Name already taken\"}, status: :unprocessable_entity }\n end\n end\n end",
"def join(server, already); end",
"def room_list\n @roomtype = DetailRoom.all_types\n @time = Room.all_times\n @day_list = Room.all_days\n if session[:admin] == nil\n redirect_to rooms_path\n end\n @admin = session[:admin]\n @rooms = {} \n @roomtype.each do |type|\n @rooms[type] = DetailRoom.find_all_by_room_type(type)\n end \n end",
"def room_cycle rooms, location\n x = 1\n while x != rooms.count\n puts x.to_s + ': ' + rooms[x][0]\n x = x+1\n end\nend",
"def join\n\t @household = Household.find params[:id]\n\t current_user.update_attribute(:household_id, @household.id)\n\t redirect_to @household\n\tend",
"def make_hotel_rooms\n (1..20).each do |num|\n @all_rooms << num #Hotel::Room.new(num) I don't think I have to do this\n end\n end",
"def list_rooms\n @rooms.each do |room_name, cap| \n puts \"#{room_name} #{cap.available_space()}\"\n end\n end",
"def join\n if request_valid?\n request_user.online!\n \n msg = message(\"joined\")\n msg = javascript_chat_message(msg)\n \n # Inform all joined channels that the user has joined\n Juggernaut.send_to_channels(msg, params[:channels])\n \n render :nothing => true\n else\n # Prevent the user from joining the channel if the request is not\n # from a valid session/user combination\n render :text => \"403\", :status => 403\n end\n end",
"def join\n @booking = Booking.find(params[:id])\n if params[:num_students].to_i > @booking.remaining_slots\n flash[:danger] = \"Oops! There is not enough room for the number of students you've specified.\"\n render :show\n else\n @booking.customers << current_user.customer\n @booked_customer = @booking.booked_customers.find_by(customer: current_user.customer)\n @booked_customer.number_students = params[:num_students]\n @booked_customer.save\n Notification.notify_admin(\"#{current_user.customer.first_name} of #{current_user.customer.school_info.school_name} has joined a booking.\", booking_path(@booking), :join)\n Notification.send_message(@booking.creator.user, \"A school has joined your booking.\", booking_path(@booking), :join)\n flash[:success] = \"Success! You've joined the booking!\"\n redirect_to root_url\n end\n end",
"def block_room\n\t\tself.room.set_occupied\n\tend",
"def join(person)\n members.push(person);\n end",
"def create\n @booking = Booking.new(booking_params)\n Room.where(:room_type_id => @booking.room_type_id).each do |room| \n @booking.room = room \n if (Booking.overlapping(@booking)).size == 0\n respond_to do |format|\n if @booking.save\n format.html {\n redirect_to \"/bookings/#{@booking.id}/payment\", notice: 'Booking was successfully created.' \n return;\n }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { \n render :new \n return\n }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end\n \n end\n\n end",
"def assign_rooms(speakers)\n room_assignments = []\n speakers.each_with_index { |speaker,index| room_assignments << \"Hello, #{speaker}! You'll be assigned to room #{index+1}!\"}\n room_assignments\nend"
] |
[
"0.6929115",
"0.65493333",
"0.6470753",
"0.6353431",
"0.629946",
"0.6285749",
"0.62440854",
"0.6226542",
"0.6131227",
"0.6118975",
"0.61099356",
"0.59364444",
"0.5933658",
"0.59272385",
"0.5920061",
"0.589729",
"0.5849205",
"0.5842395",
"0.5831786",
"0.57516813",
"0.5740848",
"0.57178956",
"0.57131135",
"0.57039756",
"0.56746083",
"0.5672935",
"0.56534255",
"0.564453",
"0.5634475",
"0.5622698",
"0.5606027",
"0.5528278",
"0.551973",
"0.5511486",
"0.55108875",
"0.55086416",
"0.5507953",
"0.5489498",
"0.5488225",
"0.5487718",
"0.5485269",
"0.548152",
"0.5478721",
"0.5464697",
"0.54585564",
"0.5456843",
"0.5452398",
"0.5442701",
"0.54362774",
"0.54357857",
"0.5430434",
"0.54275244",
"0.54181004",
"0.5412977",
"0.54090565",
"0.54080856",
"0.54073584",
"0.53997725",
"0.5397909",
"0.53967774",
"0.53764784",
"0.53749645",
"0.53701746",
"0.53697735",
"0.5369338",
"0.53666574",
"0.5357742",
"0.5354038",
"0.53527176",
"0.5348662",
"0.5340502",
"0.5339829",
"0.53387934",
"0.5337237",
"0.5337215",
"0.53322417",
"0.5325157",
"0.53145134",
"0.5313177",
"0.5310247",
"0.5304472",
"0.53027785",
"0.53014654",
"0.5300953",
"0.5297427",
"0.52957314",
"0.5295018",
"0.5289424",
"0.52674675",
"0.5266282",
"0.5265688",
"0.5265596",
"0.5257726",
"0.52551794",
"0.52451104",
"0.52441275",
"0.5240122",
"0.52399665",
"0.5238204",
"0.5236834"
] |
0.7822134
|
0
|
Find the shortest path from one coordinate to other coordinate
|
def shortest_path(start_coord, destination_coord)
queue = Queue.new
queue << [start_coord]
seen = Set.new([start_coord])
while queue
begin
path = queue.pop(non_block = true)
rescue ThreadError
return nil
end
x, y = path[-1]
if [x, y] == destination_coord
return path
end
for x2, y2 in [[x + 1, y], [x - 1, y], [x, y + 1], [x, y - 1]]
if (0 <= x2 && x2 < @map[0].length) && (0 <= y2 && y2 < @map.length) && (@map[y2][x2] != @WALL && @map[y2][x2] != @PERMANENT_WALL) && !seen.include?([x2, y2])
queue << (path + [[x2, y2]])
seen.add([x2, y2])
end
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def shortest_path\n initial_position_obj = { position: start_position, source: {} }\n\n knights_path = [initial_position_obj]\n\n while knights_path.present?\n current_position = knights_path.shift\n\n position = current_position[:position]\n\n if position == end_position\n return path_to_destination(current_position, initial_position_obj)\n end\n\n add_possible_destination(position, current_position, knights_path)\n end\n end",
"def next_step_to_shortest_path(from_x, from_y, to_x, to_y)\n move = shortest_path(from_x, from_y, to_x, to_y)&.first\n return nil unless move\n if move[0] == from_x && move[1] == from_y + 1\n return 'S'\n elsif move[0] == from_x && move[1] == from_y - 1\n return 'N'\n elsif move[0] == from_x + 1 && move[1] == from_y\n return 'E'\n elsif move[0] == from_x - 1 && move[1] == from_y\n return 'W'\n end\n raise 'This should not happen'\n end",
"def shortest_path(from_x, from_y, to_x, to_y)\n @visited = Array.new(@matrix.size) { Array.new(@matrix.first.size) { false } }\n @farthest_node = nil\n queue = Queue.new\n queue << Node.new(from_x, from_y, 0)\n\n while !queue.empty? do\n node = queue.pop\n\n if !@farthest_node || node.dist > @farthest_node.dist\n @farthest_node =node\n end\n\n if node.x == to_x && node.y == to_y\n # We pathed to the target\n target_node = node\n break\n end\n [[-1,0],[1,0],[0,1],[0,-1]].each do |dir|\n x = node.x + dir[0]\n y = node.y + dir[1]\n if is_valid?(x, y)\n @visited[y][x] = true\n queue.push(Node.new(x, y, node.dist + 1, node))\n end\n end\n end\n\n # We didn't find a path to the target\n return nil unless target_node\n\n # Trace back the journey\n journey = []\n journey.push [node.x,node.y]\n while !node.parent.nil? do\n node = node.parent\n journey.push [node.x,node.y]\n end\n journey.reverse.drop(1)\n end",
"def bfs_shortest_path(node1, node2)\n distance, route = breadth_first_search(node1)\n step = distance[node2]\n node = node2\n path = [ node2 ]\n while node != node1 and route[node]\n node = route[node]\n path.unshift(node)\n end\n return step, path\n end",
"def shortest_path\n pa = AI::AStarAlgorithm.new($map.grid, $map.gen_coordinates)\n pa.astar\n end",
"def compute_shortest_path\n update_distance_of_all_edges_to(Float::INFINITY)\n @distance_to[@source_node] = 0\n\n # The prioriy queue holds a node and its distance from the source node.\n @pq.insert(@source_node, 0)\n while @pq.any?\n node = @pq.remove_min\n node.adjacent_edges.each do |adj_edge|\n relax(adj_edge)\n end\n end\n end",
"def shortest_way(source, dest)\n\t\t@source = source\n dijkstra source\n \n if @distances[dest] != @infinity\n return @distances[dest]\n end\n\tend",
"def shortest_path_between_nodes(initial, destination)\n initial.distance = 0\n\n current = initial\n loop do\n # at the destination node, stop calculating\n break if current == destination\n\n unvisited.delete(current)\n\n calculate_neighbor_shortest_distances(current)\n\n return nil if no_reachable_nodes\n\n current = unvisited.min_by(&:distance)\n end\n\n destination.path\n end",
"def shortest_paths(source, dest)\n\t\t\t@source = source\n\t\t\tdijkstra source\n\t\t\tprint_path dest\n\t\t\treturn @distance[dest]\n\t\tend",
"def find_shortest_path(initial_node, final_node)\n\t\tunless @nodes.include?(initial_node) && @nodes.include?(final_node)\n\t\t raise(\"Either of the nodes not found in the Graph\") \n\t\tend\n\t\tdistance = {}\n\t previous = {}\n\t\tdistance[initial_node] = 0 # Distance from initial_node to initial_node\n\t previous[initial_node] = nil\n\t\tnodes_counted = @nodes\n\t\t\t\n\t\tnodes_counted.each do |n|\n\t\t if n != initial_node \n\t\t\t distance[n] = Float::INFINITY # Unknown distance function from initial_node to final_node\n\t\t\t previous[n] = nil \t # Previous node in optimal path from initial_node\n\t\t\tend\n\t\tend\n\n\t\tuntil nodes_counted.empty? \n\t\t\n\t\t\tu = distance.select{|k,v| nodes_counted.include?(k)}.min_by{|k,v| v}.first # Source node in first case\n\t\t\tbreak if (distance[u] == Float::INFINITY)\n\t\t\tnodes_counted.delete(u)\n\t\t\t\n\t\t\t@paths[u].keys.each do |v|\n\t\t\t\talt = distance[u] + @paths[u][v]\n\t\t\t\tif alt < distance[v] # A shorter path to v has been found\n\t\t\t\t\tdistance[v] = alt\n\t\t\t\t\tprevious[v] = u\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t \n\t\tpath = []\n\t\tcurrent = final_node\n\t\twhile current\n\t\t\tpath.unshift(current)\n\t\t\tcurrent = previous[current]\n\t\tend\n \n\t\treturn distance[final_node], path\n\n\tend",
"def get_path(start, stop)\n @graph.dijkstra_shortest_path(@weight_map, start, stop)\n end",
"def shortest_path\n dist, previous = Hash.new(Infinity), {}\n dist[@source] = 0.0\n queue = @graph.vertex_set.dup\n\n until queue.empty?\n u = queue.min { |a,b| dist[a.name] <=> dist[b.name] }\n break if dist[u.name].infinite?\n queue.delete(u)\n\n u.each_edge do |e, v|\n alt = dist[u.name] + e.weight\n if alt < dist[v.name]\n dist[v.name] = alt\n previous[v.name] = u.name\n end\n end\n end\n\n path = []\n u = @dest\n until previous[u].nil?\n path.unshift(u)\n u = previous[u]\n end\n\n path.unshift(@source)\n end",
"def shortest_path(start_node, end_node, graph)\n adjacent_edges = graph.select{ | edge | edge[NODES].include?(start_node) }\n remaining_edges = graph - adjacent_edges\n shortest_path = Path.new\n adjacent_edges.each do | edge |\n path = Path.new [edge]\n neighbor_node = (edge[NODES] - [start_node])[0] # ['A', 'B'] - ['A'] => ['B']\n unless neighbor_node == end_node\n path_ahead = shortest_path(neighbor_node, end_node, remaining_edges)\n (path_ahead.empty?)? path.clear : path.concat(path_ahead)\n end \n shortest_path = path if path.distance < shortest_path.distance\n end\n shortest_path\n end",
"def shortest_paths(s)\n @source = s\n dijkstra s\n puts \"Source: #{@source}\"\n @nodes.each do |dest|\n puts \"\\nTarget: #{dest}\"\n print_path dest\n if @d[dest] != @INFINITY\n puts \"\\nDistance: #{@d[dest]}\"\n else\n puts \"\\nNO PATH\"\n end\n end\n end",
"def shortest_path_to(other, options = {:method => :djikstra})\n latch = options[:method] == :breadth_first ? 2 : 1\n self.class.shortest_path(latch, id, other.id)\n end",
"def shortest_paths(source, dest)\n @graph_paths=[]\n @source = source\n dijkstra source\n @path=[]\n find_path dest\n actual_distance=if @distance[dest] != INFINITY\n @distance[dest]\n else\n \"no path\"\n end\n \"Shortest route and distance : #{@path.join(\"-->\")}, #{actual_distance} km\"\n end",
"def djikstra(world, from_x, from_y, to_x, to_y)\n key = [world.join, from_x, from_y].join(',')\n cached_prev = DJ_GRAPH_MEMO[key]\n\n prev = cached_prev\n\n unless cached_prev\n nodes = map_each_cell(world) {|cell, x, y| cell == '.' ? [x, y] : nil }.\n flatten(1).\n reject(&:nil?)\n\n source = [from_x, from_y]\n dist = Hash[nodes.zip([INFINITY].cycle)]\n queue = nodes.dup\n queue.push(source) unless queue.include?(source)\n dist[source] = 0\n prev = {}\n\n while !queue.empty?\n queue.sort_by! {|node| dist[node]}\n u = queue.shift\n\n neighbors = DIRECTIONS.values.map {|d| [u[0] + d[:x], u[1] + d[:y]] }\n neighbors = neighbors & nodes\n\n neighbors.each do |v|\n alt = dist[u] + 1\n\n if alt < dist[v]\n dist[v] = alt\n prev[v] = u\n end\n end\n end\n\n DJ_GRAPH_MEMO[key] ||= prev\n end\n\n path = []\n target = [to_x, to_y]\n\n return [source] if target == source\n\n # cannot reach target:\n return nil if prev[target].nil?\n\n while target\n path.push(target)\n target = prev[target]\n end\n\n path = path.reverse\n path\nend",
"def find_min_path(i, j)\n return 1 if i == 0 || j == 0\n return find_min_path(i-1, j) + find_min_path(i, j-1)\nend",
"def shortest_path(start, finish)\n queue << [start, 0]\n loop do\n break if queue.empty?\n vertex, d = queue.pop\n graph[*vertex] = d\n break if vertex == finish\n enqueue_neighbours(*vertex, d + 1)\n end\n queue.clear\n !blank?(finish) ? build_path(start, finish) : []\n end",
"def shortest_distance_between_nodes(initial, destination)\n shortest_path_between_nodes(initial, destination).last.distance\n end",
"def shortest_paths(s)\n\t\t@source = s\n\t\tdijkstra s\n\t\tputs \"Source: #{@source}\"\n\t\t@nodes.each do |dest|\n\t\t\tputs \"\\nTarget: #{dest}\"\n\t\t\tprint_path dest\n\t\t\tif @d[dest] != @INFINITY\n\t\t\t\tputs \"\\nDistance: #{@d[dest]}\"\n\t\t\telse\n\t\t\t\tputs \"\\nNO PATH\"\n\t\t\tend\n\t\tend\n\tend",
"def dijkstra_shortest_path(start, finish)\n visited, unvisited = Array.new, Array.new\n distances = Hash.new\n\n distances[start] = 0\n unvisited << start\n\n # find the distance\n while not unvisited.empty?\n curr_node = unvisited.pop\n visited << curr_node\n get_edges(curr_node).each do |edge| \n if visited.find_index(edge.out_vertex) == nil\n unvisited.unshift(edge.out_vertex) if unvisited.find_index(edge.out_vertex) == nil\n curr_distance, min_distance = distances[curr_node], distances[edge.out_vertex] || 1.0 / 0.0\n if curr_distance + edge.distance < min_distance\n distances[edge.out_vertex] = curr_distance + edge.distance\n end\n end\n end\n end\n\n # figure out the path\n previous = finish\n path = Array.new() \n path << previous\n while distances[previous] != 0\n get_edges(previous).each do |edge|\n if previous != edge.in_vertex && distances[edge.in_vertex] + edge.distance == distances[previous]\n previous = edge.in_vertex\n path << previous\n break\n end\n end\n end\n \n return distances[finish], path.reverse\n end",
"def find_path(source, target, map)\n @main_loop_count = 0\n\n max_y = map.size - 1\n max_x = map[0].size - 1\n target_x = target[0]\n target_y = target[1]\n # target heuristic is 0\n target = [target_x, target_y, 0]\n\n # Sets up the search to begin from the source\n source = source.dup.push((target_x - source[0]).abs + (target_y - source[1]).abs)\n came_from = {}\n came_from[source] = nil\n frontier = [source]\n\n # Until the target is found or there are no more cells to explore from\n until came_from.has_key?(target) || frontier.empty?\n @main_loop_count += 1\n\n # Take the next frontier cell\n new_frontier = frontier.shift\n\n # Find the adjacent neighbors\n adjacent_neighbors = []\n\n # Gets all the valid adjacent_neighbors into the array\n # From southern neighbor, clockwise\n nfx = new_frontier[0]\n nfy = new_frontier[1]\n adjacent_neighbors << [nfx , nfy - 1, (target_x - nfx).abs + (target_y - nfy + 1).abs] unless nfy == 0\n adjacent_neighbors << [nfx - 1, nfy - 1, (target_x - nfx + 1).abs + (target_y - nfy + 1).abs] unless nfx == 0 || nfy == 0\n adjacent_neighbors << [nfx - 1, nfy , (target_x - nfx + 1).abs + (target_y - nfy).abs] unless nfx == 0\n adjacent_neighbors << [nfx - 1, nfy + 1, (target_x - nfx + 1).abs + (target_y - nfy - 1).abs] unless nfx == 0 || nfy == max_y\n adjacent_neighbors << [nfx , nfy + 1, (target_x - nfx).abs + (target_y - nfy - 1).abs] unless nfy == max_y\n adjacent_neighbors << [nfx + 1, nfy + 1, (target_x - nfx - 1).abs + (target_y - nfy - 1).abs] unless nfx == max_x || nfy == max_y\n adjacent_neighbors << [nfx + 1, nfy , (target_x - nfx - 1).abs + (target_y - nfy).abs] unless nfx == max_x\n adjacent_neighbors << [nfx + 1, nfy - 1, (target_x - nfx - 1).abs + (target_y - nfy + 1).abs] unless nfx == max_x || nfy == 0\n\n new_neighbors = adjacent_neighbors.select do |neighbor|\n # That have not been visited and are not walls\n unless came_from.has_key?(neighbor) || map[neighbor[1]][neighbor[0]] != '.'\n # Add them to the frontier and mark them as visited\n # frontier << neighbor\n came_from[neighbor] = new_frontier\n end\n end\n\n # Sort the frontier so cells that are close to the target are then prioritized\n if new_neighbors.length > 0\n new_neighbors = merge_sort(new_neighbors)\n if frontier.length > 0 && new_neighbors[0][2] >= frontier[0][2]\n frontier = merge_sort(new_neighbors.concat(frontier))\n else\n frontier = new_neighbors.concat(frontier)\n end\n end\n end\n\n # If the search found the target\n if came_from.has_key?(target)\n # Calculates the path between the target and star for the greedy search\n # Only called when the greedy search finds the target\n path = []\n next_endpoint = came_from[target]\n while next_endpoint\n path << [next_endpoint[0], next_endpoint[1]]\n next_endpoint = came_from[next_endpoint]\n end\n path\n else\n return nil\n end\n end",
"def return_shortest_path(from)\r\n\r\n queue = Queue.new\r\n queue << from\r\n from.distance = 0\r\n while(!queue.empty?)\r\n v= queue.pop\r\n count=0\r\n adjDir = find_adjacent_rooms(v.roomObject)\r\n while(count < adjDir.length)\r\n w = @vertices[v.roomObject.return_title(adjDir[count])]\r\n\r\n if(w.distance==Float::INFINITY)\r\n w.distance = v.distance + 1\r\n w.path = v.path + \" \" + adjDir[count].to_s()\r\n queue << w\r\n end\r\n count = count + 1\r\n end\r\n count=0\r\n end\r\n\r\n end",
"def shortest_path_to(dest_node)\n return unless has_path_to?(dest_node)\n path = []\n while (dest_node != @node) do\n path.unshift(dest_node)\n dest_node = @edge_to[dest_node]\n end\n path.unshift(@node)\n end",
"def shortest_path(nodes, starting, ending)\n queue = [starting]\n previous = {}\n previous[starting] = nil\n while !queue.empty?\n p queue\n last_node = queue.pop\n if last_node == ending\n path = []\n while previous[last_node]\n path.unshift(last_node)\n last_node = previous[last_node]\n end\n path.unshift(starting)\n return path\n end\n if neighbors = nodes[last_node]\n neighbors.each do |neighbor|\n unless previous.has_key?(neighbor)\n queue.unshift(neighbor) \n previous[neighbor] = last_node\n end\n end\n end\n end\nend",
"def find_shortest_path(start_node, end_node)\n\n\t\tif (!start_node || !end_node)\n\t\t\traise \"start and end nodes must be specified\"\n\t\tend\n\n\t\tqueue = Hash[@edges.keys.map { |k| [k, nil] }]\n\t\tqueue[start_node] = 0\n\n\t\tdistances = queue.dup\n\t\tcrumbs = {}\n\n\t\twhile queue.size > 0\n\n\t\t\texpanded_node = get_min(queue)\n\n\t\t\t# Check if the current path to each neighbor of the expanded_node\n\t\t\t# is shorter than the path currently stored on the distances hash\n\t\t\t@edges[expanded_node].each do |node, edge|\n\n\t\t\t\tif distances[expanded_node]\n\t\t\t\t\n\t\t\t\t\tcurrent_path_distance = distances[expanded_node] + edge.weight\n\n\t\t\t\t\t# The distance to node is shorter via the current path or the distance to node hasn't yet been computed.\n\t\t\t\t\t# Either way, the distance from start_node->node is updated with the current distance (since it is shorter)\n\t\t\t\t\tif (!distances[node] || current_path_distance < distances[node])\n\t\t\t\t\t\tdistances[node], queue[node] = current_path_distance, current_path_distance\n\t\t\t\t\t\tcrumbs[node] = expanded_node\n\t\t\t\t\tend\n\n\t\t\t\tend\n\n\t\t\tend\n\n\t\t\tqueue.delete(expanded_node)\n\n\t\tend\n\n\t\t# List of edges representing the shortest path from start_node to end_node\n\t\tshortest_path = []\n\t\tcurrent_node = end_node\n\n\t\twhile (current_node && current_node != start_node && crumbs.size > 0)\n\t\t\tprevious_node = crumbs[current_node]\n\t\t\tif (previous_node)\n\t\t\t\tshortest_path << @edges[previous_node][current_node]\n\t\t\t\tcrumbs.delete(current_node)\n\t\t\tend\n\t\t\tcurrent_node = previous_node\n\t\tend\n\n\t\treturn shortest_path.reverse\n\n\tend",
"def select_possible_path(possible_paths)\n vertex, data = possible_paths.min_by do |vertex, data|\n data[:cost]\n end\n vertex\nend",
"def find_path(start, goal)\n raise \"loc1 must not be the same as loc2\" if start == goal\n\n # Using A* path-finding algorithm\n # See pseudocode here: https://en.wikipedia.org/wiki/A*_search_algorithm\n # https://www.redblobgames.com/pathfinding/a-star/introduction.html\n # NOTE that this is overkill for this problem...\n open_set = Set.new([start])\n came_from = {}\n\n # Default value of \"Infinity\", but we can just use nil\n g_score = {}\n g_score[start] = 0\n\n # f_score = g_score[node] + h_score[node]\n # This uses both current best path (g score) aka similar to Djikstra's algorithm,\n # plus the heuristic score.\n f_score = {}\n # g_score[start] is 0, so not included here\n f_score[start] = h_score(start, goal)\n\n # Note that we add d_score as the weight of the edge, but in our\n # case, we consider all edges equally, so hardcode 1\n d_score = 1\n\n until open_set.empty? do\n # Node in open set with lowest f score (would ideally use PriorityQueue)\n current = open_set.min_by { |node| f_score[node] }\n\n if current == goal\n return reconstruct_path(came_from, current)\n end\n\n open_set.delete(current)\n\n valid_neighbours(current).each do |neighbour_loc|\n tentative_g_score = g_score[current] + d_score\n if g_score[neighbour_loc].nil? || tentative_g_score < g_score[neighbour_loc]\n # This path to neighbor is better than any previous one. Record it!\n came_from[neighbour_loc] = current\n g_score[neighbour_loc] = tentative_g_score\n f_score[neighbour_loc] = g_score[neighbour_loc] + h_score(neighbour_loc, goal)\n if !open_set.include?(neighbour_loc)\n open_set << neighbour_loc\n end\n end\n end\n end\n\n raise \"error, no path found!\"\n end",
"def solve(from_word, to_word)\n return @word_graph.shortest_path(from_word, to_word)\n end",
"def compute_path(source_x, source_y, destination_x, destination_y)\n build_structures(source_x, source_y)\n path([destination_x, destination_y])\n backtrace(source_x, source_y, destination_x, destination_y)\n end",
"def plan(s1, s2)\r\n if s1 == s2\r\n return []\r\n end\r\n\r\n condensed_path = Array.new\r\n full_path = Array.new\r\n temp = BFS.new(graph, find_node(s1)).shortest_path_to(find_node(s2))\r\n\r\n temp.each {|x| full_path.push(x.to_s)}\r\n condensed_path.push(full_path.first)\r\n condensed_path = condensed_path + transfer_stations(full_path)\r\n \r\n if condensed_path.last != full_path.last #need to test this more\r\n condensed_path << full_path.last\r\n end\r\n\r\n return condensed_path\r\n end",
"def call\n return nil unless on_the_graph? # Prevents a stack overflow in the gem\n return shortest_path[1..-1] if shortest_path.length > 1\n end",
"def shortest_path_to(node)\n return nil if @previous_nodes[node].nil?\n\n nodes = [node]\n while previous_node = @previous_nodes[nodes[0]] do\n nodes.unshift(previous_node)\n end\n\n nodes\n end",
"def shortest_paths(dest)\n position = dest\n final = {}\n analisados = {}\n route = []\n route << dest\n @previous['a'] = -1\n\n @nodes.each do |n|\n analisados[n] = false\n end\n analisados[position] = true\n\n while analisados(analisados)\n adyacentes(position, analisados).each do |n|\n if @distance[n] == (@distance[position] - graph[n][position])\n @previous[position] = n\n position = n\n route << n\n end\n analisados[n] = true\n end\n\n end\n route << 'a'\n route\n end",
"def shortest_route_by_distance_to!(place_or_object_place_was_built_from)\n routes_for!(place_or_object_place_was_built_from).min_by(&:distance_in_meters)\n end",
"def endpoints\n connectors = {\n :NW => [2, 2],\n :SE => [98, 98],\n :NE => [98, 2],\n :SW => [2, 98],\n :N => [50, 0],\n :S => [50, 100],\n :E => [100, 50],\n :W => [0, 50]\n }\n shortest_path = 1000000\n generated_endpoints = []\n connectors.each do |from_key, from_connector|\n ep_from = [from.x + from_connector[0], from.y + from_connector[1]]\n connectors.each do |to_key, to_connector|\n ep_to = [to.x + to_connector[0], to.y + to_connector[1]]\n path = Math.sqrt(((ep_from[0] - ep_to[0]).abs ** 2) + ((ep_from[1] - ep_to[1]).abs ** 2)).to_i\n if path < shortest_path + 25\n shortest_path = path\n generated_endpoints = [ep_from, ep_to]\n end\n end\n end\n return generated_endpoints\n end",
"def shortest_path_to_user(start_coord)\n queue = Queue.new\n queue << [start_coord]\n seen = Set.new([start_coord])\n while queue\n begin\n path = queue.pop(non_block = true)\n rescue ThreadError\n return nil\n end\n x, y = path[-1]\n if @map[y][x] == @USER\n return path\n end\n for x2, y2 in [[x + 1, y], [x - 1, y], [x, y + 1], [x, y - 1]]\n if (0 <= x2 && x2 < @map[0].length) && (0 <= y2 && y2 < @map.length) && (@map[y2][x2] != @WALL && @map[y2][x2] != @PERMANENT_WALL) && !seen.include?([x2, y2])\n queue << (path + [[x2, y2]])\n seen.add([x2, y2])\n end\n end\n end\n end",
"def shortest_length(start, finish)\n infinity = (2**(0.size * 8 - 2) - 1) # max Fixnum integer value\n distances = {} # smallest distance from starting vertex to this one\n previous = {}\n cyclic = start == finish # true if starting vertex = ending vertex\n loops = 0 # useful for cyclic path\n vertex_pq = PriorityQueue.new\n\n adj_lists.each do |vertex|\n vname = vertex.name\n if vname == start\n distances[vname] = 0\n vertex_pq.enq(vname, 0)\n else\n distances[vname] = infinity\n vertex_pq.enq(vname, infinity)\n end\n previous[vname] = nil\n end\n\n while vertex_pq\n loops += 1\n # if cyclic, pretend starting vertex is unvisited. put it back in queue.\n if cyclic && loops == 2\n vertex_pq.enq(start, infinity)\n distances[start] = infinity\n end\n # vertex currently being checked. picks closest one first.\n current = vertex_pq.deq\n vname = current.keys.first\n\n # if we've arrived at final vertex, return shortest distance\n # if cyclic, skip this code during first loop\n if vname == finish && loops > 1\n shortest_path = []\n vname2 = vname\n while previous[vname2]\n shortest_path << vname2\n vname2 = previous[vname2]\n previous[start] = nil if cyclic # pretend starting vertex is unvisited\n end\n shortest_path = [start] + shortest_path.reverse\n print \"Shortest path: #{shortest_path}, Length = #{path_length(shortest_path)}\\n\"\n return distances[finish]\n end\n\n # leave if we never get to final vertex\n break if vname == nil || distances[vname] == infinity\n\n adj_vertices(vname, adj_lists).each do |vertex|\n alt_distance = distances[vname] + dist(vname, vertex)\n # if total distance to neighbor < last minimum total distance\n # to neighbor, replace it with this new distance\n if alt_distance < distances[vertex]\n distances[vertex] = alt_distance\n previous[vertex] = vname\n vertex_pq.enq(vertex, alt_distance)\n end\n end\n end\n\n end",
"def find_any_path_between_vertices(source_vertex, destination_vertex)\n validate_integer(source_vertex, destination_vertex)\n return nil if @vertices[source_vertex].nil? || @vertices[destination_vertex].nil?\n return path_between_vertices(source_vertex, destination_vertex)\n end",
"def shortest_paths(source)\n init(source)\n relax_edges\n PathBuilder.new(source, @visitor.parents_map).paths(@graph.vertices)\n end",
"def best_path(start, target)\n queue = []\n path = []\n targetX = target[0]\n targetY = target[1] \n update_possible_moves(start)\n path << [@x, @y]\n until @x == targetX && @y == targetY\n @moves.each do |valid_move|\n queue << valid_move unless out_of_bounds?(valid_move) \n end\n #shift because we want bread-first search\n next_move = queue.shift\n update_possible_moves(next_move)\n path << [@x, @y] \n end\n # Filter out the best path and present it\n best_possible_path = filter_path(path)\n puts \"You made it in #{best_possible_path.length} moves! The path is:\\n#{best_possible_path}\"\n end",
"def shortest_distance()\n min = 1000000\n s = \"\"\n @edges.each do |city, dests|\n dests.each do |dest|\n if min > dest.distance\n min = dest.distance\n s = \"#{city} to #{dest.name}\"\n end\n end\n end\n \"Shortest distance is #{min} from #{s}\"\n end",
"def path_from_to(a, b)\n # Work with the fixed anchors of the nodes because that's where the\n # control flow is fixed to.\n\n a = fixed_anchor(a)\n b = fixed_anchor(b)\n\n # We're going to do a depth-first search starting with the first node\n # and we're going to see if we can find the second node. We keep a stack\n # of nodes that we need to visit, and a set of nodes that we've already\n # visited so that we don't visit nodes more than once. We pop a node\n # off the stack, return if it was the node we were looking for, or move\n # on if we've already visited it, if not we push the outputs of the node\n # to visit next.\n\n worklist = [a]\n considered = Set.new\n until worklist.empty?\n node = worklist.pop\n return true if node == b\n if considered.add?(node)\n worklist.push *node.outputs.control_edges.to_nodes\n end\n end\n\n # We traversed the whole graph accessible from the first node and didn't\n # find the second one.\n\n false\n end",
"def dijkstra_shortest_path(source, destination, graph)\n distances, previouses = Hash.new(Float::INFINITY), Hash.new\n distances[source] = 0\n\n vertices = graph.vertices.dup\n\n while !vertices.empty?\n closest_vertex = vertices.min_by { |v| distances[v] }\n vertices.delete closest_vertex\n\n if closest_vertex == destination\n return path(previouses, destination, [])\n end\n\n closest_vertex.adjacent_edges.each do |e|\n neighbor = e.destination\n distance = e.weight + distances[closest_vertex]\n\n if distance < distances[neighbor]\n distances[neighbor] = distance\n previouses[neighbor] = closest_vertex\n end\n end\n end\n\n return [] #no path to destination\nend",
"def shortest_path(src, dst = nil)\n distances = {}\n previouses = {}\n self.each do |node|\n distances[node] = nil\n previouses[node] = nil\n end\n distances[src] = 0\n nodes = self.clone\n until nodes.empty?\n nearest_node = nodes.inject do |a, b|\n next b unless distances[a]\n next a unless distances[b]\n next a if distances[a] < distances[b]\n b\n end\n break unless distances[nearest_node] # Infinity\n if dst and nearest_node == dst\n return distances[dst]\n end\n neighbors = nodes.neighbors_from(nearest_node)\n neighbors.each do |node|\n alt = distances[nearest_node] + nodes.distance(nearest_node, node)\n if distances[node].nil? or alt < distances[node]\n distances[node] = alt\n previouses[node] = nearest_node\n # decrease-key v in Q # ???\n end\n end\n nodes.delete nearest_node\n end\n if dst\n return nil\n else\n return distances\n end\n end",
"def shortest_path_from(from, check=nil)\n dirs = [ [1,0], [0,1], [0,-1], [-1,0] ]\n \n #return [1,0]\n \n unless @cache and @cached_for == towers.keys+[check]\n\tmarked = {}\n\tmarked.default = false\n\n\tq = [Config.monsters_end_at]\n\tfirst = 0\n\t\n\tmarked[Config.monsters_end_at] = true\n\t\n\twhile first < q.size\n\t v = q[first]\n\t first += 1\n\t for i in dirs\n\t w = [v[0]+i[0], v[1]+i[1]]\n\t next if w != Config.monsters_start_at and w != Config.monsters_end_at and\n\t\t (w[0] < 0 or w[1] < 0 or w[0] >= Config.map_size[0] or w[1] >= Config.map_size[1])\n\t next if marked[w] or w == check or towers[w]\n\t marked[w] = [-i[0], -i[1] ]\n\t q << w\n\t end\n\tend\n\t\n\t@cached_for = towers.keys+[check]\n\t@cache = marked\n end\n \n return @cache[from]\n end",
"def shortest_single_flight\n\n min_distance = @largest_integer\n flight = \"\"\n @query.get_graph.each_key do |city|\n route_dict = get_outgoing_routes(city)\n route_dict.each do |dest, dist|\n if dist < min_distance\n min_distance = dist\n flight = \"#{get_city_info(city,\"name\")}-#{dest}\"\n end\n end\n end\n\n return flight\n\n end",
"def find_shortest_path(exclude_path_with_tile = nil)\n node = find_end_tile(exclude_path_with_tile)\n return [@start_tile, @end_tile] if node.nil?\n expand_path(node)\n end",
"def shortest_paths(src, destinations)\n return [] if destinations.empty?\n\n paths = []\n visited = Set.new([src])\n queue = Containers::MinHeap.new\n queue.push([1, [src]])\n\n until queue.empty?\n _, path = queue.pop\n\n # Not going to find shorter paths than current best, return.\n break if paths.any? && paths[0].size < path.size\n\n cur = path.last\n paths << path if destinations.include?(cur)\n\n neighbors(cur).each do |pos|\n next if visited.include?(pos) || occupied?(pos)\n\n visited.add(pos)\n new_path = Array.new(path.size) { |i| path[i].dup }\n new_path << pos\n queue.push([new_path.size, new_path])\n end\n end\n\n paths\n end",
"def find_best_way(xx,yy)\n pf = Pathfinder.new($map)\n pf.ignore_obs_target = true # permit to calculate a path to a case with an ennemy on it\n path = pf.find([x,y],[xx,yy])\n end",
"def find_path(tile_a, tile_b)\n if rand(0..1).floor() === 1\n # start horizontal\n x, y = tile_a.x, tile_b.y\n else\n # start vertical\n x, y = tile_b.x, tile_a.y\n end\n\n turn_point = tile_by_coordinates(x, y)\n\n [tile_a, turn_point, tile_b]\n\n # if (x2 > x1)\n # delta_x = x2 - x1\n # delta_y = y2 - y1\n # else\n # delta_x = x1 - x2\n # delta_y = y1 - y2\n # end\n end",
"def min_path\n if @layers.count == 2\n return [ top ] + [ @layers[1].min ]\n end\n\n left_min_path = left_child.min_path\n left_min_path_sum = left_min_path.inject(0, :+)\n right_min_path = right_child.min_path\n right_min_path_sum = right_min_path.inject(0, :+)\n\n if left_min_path_sum < right_min_path_sum\n [ top ] + left_child.min_path \n else\n [ top ] + right_child.min_path\n end\n end",
"def shortest_distance_from(latitude, longitude)\n\t\tmin_dist = BigDecimal.new(\"10.0\")\n\t\tinput_lat = BigDecimal.new(latitude)\n\t\tinput_lng = BigDecimal.new(longitude)\n\n\t\t#Find waypoint with shortest distance from input\n\t\tfor location in self.locations\n\t\t\tpoint_lat = BigDecimal(location.coord.latitude.to_s)\n\t\t\tpoint_lng = BigDecimal(location.coord.longitude.to_s)\n\n\t\t\t#Get distance between two points\n\t\t\tdist = ((input_lat - point_lat)**2 + (input_lng - point_lng)**2).sqrt(10)\n\n\t\t\t#Update the minimum\n\t\t\tif min_dist > dist\n\t\t\t\tmin_dist = dist\n\t\t\tend\n\t\tend\n\n\t\treturn min_dist\n\tend",
"def build_path(start, finish)\n path = [finish]\n loop do\n vertex = path.last\n d = graph[*vertex]\n neighbours = get_neighbours(*vertex)\n next_vertex = neighbours.select{|n_vert| graph[*n_vert] == d - 1}.first\n path << next_vertex if next_vertex\n break if vertex == start\n end\n path\n end",
"def shortest_distance_to(node)\n @distances[node]\n end",
"def find_path(start_node, end_node, grid)\n start_node = sanitize(start_node)\n end_node = sanitize(end_node)\n if grid.nil?\n [start_node]\n else\n _max_x = grid.max_x\n _max_y = grid.max_y\n\n @current_grid = grid.inner_grid.clone\n\n raise 'max_x & max_y required' unless _max_x && _max_y\n\n _start_node = start_node.clone\n _end_node = end_node.clone\n\n heuristic = @heuristic.new(_end_node, @weight)\n\n _start_node[:f] = 0 # sum of g and h\n _start_node[:g] = 0 # steps to start node\n _start_node[:h] = nil # steps to end node\n _start_node[:opened] = true\n\n # use heap or tree for better perf\n open = []\n open.push _start_node\n\n while !open.empty? do\n _current_node = open.pop\n\n _current_node[:closed] = true\n @current_grid[node_to_a(_current_node)] = _current_node\n\n if node_to_a(_current_node) == node_to_a(_end_node)\n return final_path(_current_node)\n end\n\n new_g = _current_node[:g] + 1\n\n x = _current_node[:x]\n y = _current_node[:y]\n\n neighbors = []\n\n neighbors << [x-1, y] if x > 0\n neighbors << [x, y-1] if y > 0\n neighbors << [x+1, y] if x < _max_x-1\n neighbors << [x, y+1] if y < _max_y-1\n\n _neighbors = neighbors.map do |position|\n node = @current_grid[position]\n if node.nil? || node[:walkable]\n node ||= {}\n @current_grid[position] = node.merge({\n x: position.first,\n y: position[1],\n closed: false,\n opened: false\n })\n end\n end.compact\n\n _neighbors.each do |neighbor|\n if (!neighbor[:opened] || new_g < neighbor[:g])\n neighbor[:g] = new_g\n neighbor[:h] ||= heuristic.h(neighbor)\n neighbor[:f] = neighbor[:g] + neighbor[:h]\n neighbor[:parent] = node_to_a(_current_node)\n\n if (!neighbor[:opened])\n open.push neighbor\n neighbor[:opened] = true\n else\n # ???\n puts \"got here some how!!!\"\n end\n end\n end\n\n open.sort_by! {|i| [-i[:f], -i[:h]]}\n # grid_p\n end\n end\n end",
"def shortest_route visit_path, dst, condition=nil\n return route(visit_path, dst).first.cost\n end",
"def test_shortest_path\n\n test_map = ' { \"metros\" : [ {\n \"code\" : \"LON\" ,\n \"name\" : \"London\" ,\n \"country\" : \"X\" ,\n \"continent\" : \"X\" ,\n \"timezone\" : 1 ,\n \"coordinates\" : {\"N\" : 1, \"E\" : 1} ,\n \"population\" : 1,\n \"region\" : 1\n } , {\n \"code\" : \"PAR\" ,\n \"name\" : \"Paris\" ,\n \"country\" : \"X\" ,\n \"continent\" : \"X\" ,\n \"timezone\" : 1 ,\n \"coordinates\" : {\"N\" : 1, \"E\" : 1} ,\n \"population\" : 1,\n \"region\" : 1\n } , {\n \"code\" : \"LIM\" ,\n \"name\" : \"Lima\" ,\n \"country\" : \"X\" ,\n \"continent\" : \"X\" ,\n \"timezone\" : 1 ,\n \"coordinates\" : {\"N\" : 1, \"E\" : 1} ,\n \"population\" : 1,\n \"region\" : 1\n } , {\n \"code\" : \"MOW\" ,\n \"name\" : \"Moscow\" ,\n \"country\" : \"X\" ,\n \"continent\" : \"X\" ,\n \"timezone\" : 1 ,\n \"coordinates\" : {\"N\" : 1, \"E\" : 1} ,\n \"population\" : 1,\n \"region\" : 1\n } ] ,\n \"routes\" : [ {\n \"ports\" : [\"LON\" , \"PAR\"] ,\n \"distance\" : 200\n } , {\n \"ports\" : [\"PAR\" , \"LIM\"] ,\n \"distance\" : 400\n } , {\n \"ports\" : [\"LIM\" , \"MOW\"] ,\n \"distance\" : 600\n } , {\n \"ports\" : [\"PAR\" , \"MOW\"] ,\n \"distance\" : 600\n }] } ' \n graph = Graph.new()\n graph.parse_json_string(test_map)\n\n # There is a less direct path (more stop overs) with shortest distance\n assert_equal( graph.get_dijkstra_path(\"LON\",\"MOW\"), \"LON-PAR-MOW\" )\n \n test_map = ' { \"metros\" : [ {\n \"code\" : \"LON\" ,\n \"name\" : \"London\" ,\n \"country\" : \"X\" ,\n \"continent\" : \"X\" ,\n \"timezone\" : 1 ,\n \"coordinates\" : {\"N\" : 1, \"E\" : 1} ,\n \"population\" : 1,\n \"region\" : 1\n } , {\n \"code\" : \"PAR\" ,\n \"name\" : \"Paris\" ,\n \"country\" : \"X\" ,\n \"continent\" : \"X\" ,\n \"timezone\" : 1 ,\n \"coordinates\" : {\"N\" : 1, \"E\" : 1} ,\n \"population\" : 1,\n \"region\" : 1\n } , {\n \"code\" : \"LIM\" ,\n \"name\" : \"Lima\" ,\n \"country\" : \"X\" ,\n \"continent\" : \"X\" ,\n \"timezone\" : 1 ,\n \"coordinates\" : {\"N\" : 1, \"E\" : 1} ,\n \"population\" : 1,\n \"region\" : 1\n } , {\n \"code\" : \"MOW\" ,\n \"name\" : \"Moscow\" ,\n \"country\" : \"X\" ,\n \"continent\" : \"X\" ,\n \"timezone\" : 1 ,\n \"coordinates\" : {\"N\" : 1, \"E\" : 1} ,\n \"population\" : 1,\n \"region\" : 1\n } ] ,\n \"routes\" : [ {\n \"ports\" : [\"LON\" , \"PAR\"] ,\n \"distance\" : 200\n } , {\n \"ports\" : [\"PAR\" , \"LIM\"] ,\n \"distance\" : 200\n } , {\n \"ports\" : [\"LIM\" , \"MOW\"] ,\n \"distance\" : 200\n } , {\n \"ports\" : [\"PAR\" , \"MOW\"] ,\n \"distance\" : 500\n }] } ' \n graph = Graph.new()\n graph.parse_json_string(test_map)\n \n # The flight with more stop overs is shorter\n assert_equal( graph.get_dijkstra_path(\"LON\",\"MOW\"), \"LON-PAR-LIM-MOW\" )\n \n end",
"def solve_dijkstra\n\n unvisited_set = @unvisited_set.dup\n\n # create a queue for nodes to check\n @queue = []\n current_node = @start_node\n @queue << current_node\n\n # Stop If there are no unvisited nodes or the queue is empty\n while unvisited_set.size > 0 && @queue.size > 0 do\n\n # set the current node as visited and remove it from the unvisited set\n current_node = @queue.shift\n\n # remove visited node from the list of unvisited nodes\n unvisited_set.delete(current_node)\n\n # find the current node's neighbours and add them to the queue\n rolling_node = @node_list.find { |hash| hash[:id] == current_node }\n rolling_node[:neighs].each do |p|\n # only add them if they are unvisited and they are not in the queue\n if unvisited_set.index(p) && !@queue.include?(p)\n @queue << p\n # set the previous node as the current for its neighbours\n change_node = @node_list.find { |hash| hash[:id] == p }\n change_node[:prev] = current_node\n # increase the distance of each node visited\n change_node[:dist] = rolling_node[:dist] + @step\n end\n end\n\n if current_node == @goal_node\n find_shortest_path(rolling_node)\n break\n end\n end\n return @shortest_path_coords\n end",
"def path_to(x:, y:)\n x_signal = x / [x.abs, 1].max\n y_signal = y / [y.abs, 1].max\n\n if x.abs > y.abs\n [[1 * x_signal, 0]]\n elsif x.zero? && y.zero?\n [[0, 0]]\n else\n [[0, 1 * y_signal]]\n end\n end",
"def knight_path(from, to)\n\topen_queue = [PositionPath.new( from, [copy(from)] )]\n\tdiscovered = [from]\n\n\tuntil open_queue.empty?\n\t\tcurrent = open_queue.shift\n\n\t\treturn current.path if current.position == to\n\t\tvalid_moves(current.position).each do |move|\n\t\t\tunless discovered.include?(move)\n\t\t\t\tdiscovered << move\n\t\t\t\topen_queue.push(make_position_path(current, move)) \n\t\t\tend\n\t\tend\n\tend\n\t\nend",
"def find_path(start, finish, *avoid_sectors)\n shortest_path(start, finish, avoid_sectors.flatten)\n end",
"def guide(from, to, unit_type=nil, max_depth=400)\n return nil if @map.blocked?(from, unit_type) || @map.blocked?(to, unit_type)\n from_element = PathElement.new(from)\n from_element.dist_from = @map.distance(from,to)\n open = PriorityQueue.new { |x, y| (x <=> y) == -1 }\n open.push from_element, from_element.rating\n closed = SplayTreeMap.new\n step = 0\n \n until open.empty? || step > max_depth\n step += 1\n \n current_element = open.pop\n @nodes_considered += 1\n \n loc = current_element.location\n if @map.cost(loc,to) == 0\n path = []\n until current_element.parent.nil?\n path.unshift current_element\n current_element = current_element.parent\n end\n\n return path\n else\n closed.push loc, current_element\n @map.neighbors(loc).each do |next_door|\n next if closed.has_key? next_door\n\n el = PathElement.new(next_door,current_element)\n\n if @map.blocked? next_door, unit_type\n closed.push el.location, el\n else\n current_rating = current_element.cost_to + @map.cost(loc, next_door)\n\n # add to open\n el.cost_to = current_rating\n el.dist_from = @map.distance(next_door,to)\n \n open.push el, el.rating\n end\n end\n end\n end\n nil\n end",
"def getPath(location1, location2)\n accTime = 0.0 # accumulated driving time in seconds\n fullPath = \"\" # track this path\n\n # counters for distances traveled\n needX = (@locations[location2].x - @locations[location1].x)\n needY = (@locations[location2].y - @locations[location1].y)\n currentX = @locations[location1].x\n currentY = @locations[location1].y\n\n absX = needX.abs # Absolute distance to be traveled in X direction \n absY = needY.abs # Absolute distance to be traveled Y\n if (absX > 2 || absY > 2) # allow for a \"looser\" travel algorithm for longer distances\n loose = true # This is meant to meander a bit outside of a direct path to see\n else # if any advantage can be gained\n loose = false\n end\n \n if absX == 0 # sign is 0 is there is no travel needed in X direction\n signX = 0\n else # Otherwise, sign will be +1 or -1, depending on direction we need to go \n signX = needX / absX # direction we are going X\n end\n if absY == 0 # same treatment for Y\n signY = 0\n else\n signY = needY / absY # direction we are going Y\n end\n\n fullPath << \"Moving from location #{@locations[location1].name} to #{@locations[location2].name}:\\n\"\n\n counter = 1\n while (needX != 0 || needY != 0) do\n # make a move\n # if running the more \"loose\" algorithm, then possibly start with one, two, or three counter-intuitive moves\n if loose && counter == 1 && rand(3) == 1\n moves = rand(3) + 1 # do 1, 2, or 3 counter-intuitive moves\n case rand(2) # what direction?\n when 0 # make an \"exploratory\" move in the X direction\n fullPath << \" Exploring X direction #{moves} moves, \"\n needX += signX * moves # make the move if still need progress in this direction\n currentX -= signX * moves\n speed = Rules::SPEED_LIMITX[currentY] # get the speed limit on this \"street\"\n fullPath << \"speed limit is #{speed}, \"\n speed = speed.to_f / 3600.0 # convert speed from mph to miles per second\n time = moves / speed # time required is dist traveled (1 mile) / speed\n fullPath << \"time required #{time.round(2)}\\n\"\n accTime += time # Add travel time this move, in seconds\n counter += 1\n next\n\n when 1 # make an \"exploratory\" move in the Y direction\n fullPath << \" Exploring Y direction #{moves} moves, \"\n needY += signY * moves # make the move if still need progress in this direction\n currentY -= signY * moves\n speed = Rules::SPEED_LIMITY[currentX] # get the speed limit on this \"street\"\n fullPath << \"speed limit is #{speed}, \"\n speed = speed.to_f / 3600.0 # convert speed from mph to miles per second\n time = moves / speed # time is dist traveled (1 mile) / speed\n fullPath << \"time required #{time.round(2)}\\n\" \n accTime += time # Add travel time this move, in seconds\n counter += 1\n next\n end\n end\n\n case rand(2) # choose a move (one mile) at random, either in X direction or Y\n when 0 # moving in the X direction\n next if needX == 0 # try another move if we don't need to move in X direction\n fullPath << \" Moving X direction, \"\n needX -= signX # make the move if still need progress in this direction\n currentX += signX\n speed = Rules::SPEED_LIMITX[currentY] # get the speed limit on this \"street\"\n fullPath << \"speed limit is #{speed}, \"\n speed = speed.to_f / 3600.0 # convert speed from mph to miles per second\n time = 1.0 / speed # time required is dist traveled (1 mile) / speed\n fullPath << \"time required #{time.round(2)}\\n\"\n accTime += time # Add travel time this move, in seconds\n when 1 # moving in the Y direction\n\n next if needY == 0 # try another move if we don't need to move in Y direction\n fullPath << \" Moving Y direction, \"\n needY -= signY # make the move if still need progress in this direction\n currentY += signY\n speed = Rules::SPEED_LIMITY[currentX] # get the speed limit on this \"street\"\n fullPath << \"speed limit is #{speed}, \"\n speed = speed.to_f / 3600.0 # convert speed from mph to miles per second\n time = 1.0 / speed # time is dist traveled (1 mile) / speed\n fullPath << \"time required #{time.round(2)}\\n\" \n accTime += time # Add travel time this move, in seconds \n end\n counter += 1\n end \n\n # Confirm that we are at the end point, otherwise the code is jacked up!! \n puts \" Travel error!\" if currentX != @locations[location2].x || currentY != @locations[location2].y\n accTime = accTime.round(2) # reduce precision to hundreths of a second\n return [accTime, fullPath]\n end",
"def shortest_circuit()\n shortest_cir = Array.new\n shortest_weight = 99999\n\n vert = vertex_list()\n start_point = vert[0]\n vert.delete_at(0)\n\n vert_perm = vert.permutation.to_a()\n\n vert_perm.each{ |x|\n x.insert(0,start_point)\n x.insert(x.length,start_point)\n weight = path_weight(x)\n \n if weight == nil\n weight = 99999\n end\n\n if weight < shortest_weight\n shortest_weight = path_weight(x)\n shortest_cir = x\n end\n }\n return \"Shortest Circuit = \",shortest_cir.inspect, \"\\nWeight = \", shortest_weight\n\n end",
"def pathfind begTile, endTile\n @traveled_tiles = [begTile]\n @current_tiles = [begTile]\n @next_tiles = Array.new\n #iterate through the maze one movement at a time, hard stop when all tiles have been exhausted\n while (!@current_tiles.include? endTile) && @traveled_tiles.length < @maze.size\n @current_tiles.each do |tile|\n (get_adjacent_floors tile).each do |next_tile|\n #makes sure no tiles are double counted, the first to hit will always be the shortest\n if (next_tile.is_floor) && (!@next_tiles.include? next_tile) && (!@traveled_tiles.include? next_tile)\n @next_tiles.push next_tile\n next_tile.previous_tile tile\n end\n end\n end\n @traveled_tiles.concat @next_tiles\n @current_tiles = @next_tiles.dup\n @next_tiles.clear\n end\n endTile.get_path\n end",
"def shortest_distance_to_all_nodes(initial)\n Hash[shortest_path_to_all_nodes(initial).map {|n| [n, n.distance]}]\n end",
"def shortest_path_to_all_nodes(initial)\n initial.distance = 0\n\n current = initial\n loop do\n unvisited.delete(current)\n\n calculate_neighbor_shortest_distances(current)\n\n return graph.vertices if no_reachable_nodes\n\n current = unvisited.min_by(&:distance)\n end\n end",
"def find_shortest_path(rolling_node)\n\n @backtrack = []\n @backtrack << @goal_node\n\n # iterate until we arrive at the start node\n while rolling_node[:prev] != nil do\n temp_node = @node_list.find { |hash| hash[:id] == rolling_node[:prev] }\n @backtrack << temp_node[:id]\n rolling_node = temp_node\n end\n\n # create a table with the 1d and the 2d array node values\n @shortest_path = []\n\n @backtrack.each do |p|\n @shortest_path << [p, @table_convert[p]]\n @shortest_path_coords << @table_convert[p][1]\n end\n end",
"def shortest_route_by_distance_to(place_or_object_place_was_built_from)\n routes = routes_for place_or_object_place_was_built_from\n select_ok_routes(routes).min_by(&:distance_in_meters)\n end",
"def shortest(word1, word2)\n \n end",
"def shortest_path(root, dest)\n priority = Hash.new\n visited = Hash.new\n previous = Hash.new\n q = PriorityQueue.new\n @vertices.each do |k, up|\n if up\n priority[k] = @@infinity\n visited[k] = false\n previous[k] = nil\n end\n end\n priority[root] = 0\n q[root] = 0\n until q.empty?\n u = q.delete_min\n visited[u[0]] = true\n break if u[1] == @@infinity\n @edges_cost.each_key do |s|\n @edges_cost[s].each_key do |d|\n if edges_up[s].fetch(d) and vertices[s] and vertices[d]\n if !visited[d] and priority[s] + @edges_cost[s].fetch(d) < priority[d]\n previous[d] = s\n priority[d] = priority[s] + @edges_cost[s].fetch(d)\n q[d] = priority[d]\n end\n end\n end\n end\n end\n prior = dest\n out = \"#{prior} \"\n while previous[prior]\n out = \"#{previous[prior]} \" + out\n prior = previous[prior]\n end\n out += \"#{priority[dest]}\\n\"\n print out\n priority[dest]\n end",
"def guide(from, to, unit_type=nil, max_depth=400)\n return nil if @map.blocked?(from, unit_type) || @map.blocked?(to, unit_type)\n from_element = PathElement.new(from)\n from_element.dist_from = @map.distance(from,to)\n open = PrioritySet.new\n open.push from_element, from_element.rating\n closed = SplayTreeMap.new\n step = 0\n\n until open.empty? || step > max_depth\n step += 1\n\n current_element = open.pop\n @nodes_considered += 1\n\n loc = current_element.location\n if @map.cost(loc,to) == 0\n path = []\n until current_element.parent.nil?\n path.unshift current_element\n current_element = current_element.parent\n end\n\n return path\n else\n closed.push loc, current_element\n @map.neighbors(loc).each do |next_door|\n if closed.has_key? next_door\n next\n end\n \n el = PathElement.new(next_door,current_element)\n\n if @map.blocked? next_door, unit_type\n closed.push el.location, el\n else\n current_rating = current_element.cost_to + @map.cost(loc, next_door)\n\n # add to open\n el.cost_to = current_rating\n el.dist_from = @map.distance(next_door,to)\n el.reset_rating\n\n open.push el, el.rating\n end\n end\n end\n end\n nil\n end",
"def path(x, y)\r\n\t\t# If x or y are on the edge, meaning they have only one path, return 1\r\n\t\tif (x == 0 || y == 0)\r\n\t\t\treturn 1\r\n\t\r\n\t\t# If in the middle of the square, check to see if sum of paths for node already calculated?\r\n\t\telse\r\n\t\t\t# If so, return calculated sum of paths for node\r\n\t\t\tif @node[x][y] != 0\r\n\t\t\t\treturn @node[x][y]\r\n\t\t\t\t\r\n\t\t\t# Otherwise, set node[x][y] to sum of paths for connected nodes through recursion\r\n\t\t\t# Return newly calculated node[x][y]\r\n\t\t\telse\r\n\t\t\t\t@node[x][y] = path(x-1, y) + path(x, y-1)\r\n\t\t\t\treturn @node[x][y]\r\n\t\t\tend\r\n\t\tend\t\r\n\tend",
"def find_path_brute_force( board, start_point )\n options = get_options( start_point, board )\n\n # Bottom right corner\n if options.length == 0\n return { points: [start_point], best_value: get_value( start_point, board ) }\n end\n\n # If there's only one option, this works fine still.\n first_result = find_path_brute_force( board, options.first )\n second_result = find_path_brute_force( board, options.last )\n if first_result[:best_value] > second_result[:best_value]\n return {\n points: [start_point] + first_result[:points],\n best_value: first_result[:best_value] + get_value( start_point, board )\n }\n else\n return {\n points: [start_point] + second_result[:points],\n best_value: second_result[:best_value] + get_value( start_point, board )\n }\n end\nend",
"def search(start, goal)\n openset = Set.new\n closedset = Set.new\n current = start\n\n if @maximize_cost # serves to invert the comparison\n openset_min_max = openset.method(:max_by)\n flip = -1\n else\n openset_min_max = openset.method(:min_by)\n flip = 1\n end\n\n openset.add(current)\n while not openset.empty?\n current = openset_min_max.call{|o| o.g + o.h }\n if current == goal\n path = []\n while current.parent\n path << current\n current = current.parent\n end\n path << current\n return path.reverse\n end\n openset.delete(current)\n closedset.add(current)\n @graph[current].each do |node|\n next if closedset.include? node\n\n if openset.include? node\n new_g = current.g + current.move_cost(node)\n if (node.g - new_g) * flip > 0\n node.g = new_g\n node.parent = current\n end\n else\n node.g = current.g + current.move_cost(node)\n node.h = heuristic(node, start, goal)\n node.parent = current\n openset.add(node)\n end\n end\n end\n return nil\n end",
"def get_route(start_arr, end_arr)\n root = Position.new(start_arr[0], start_arr[1])\n target = Position.new(end_arr[0], end_arr[1])\n solution = get_target_value(target, root)\n\n route = []\n route.unshift([target.x, target.y])\n location = solution.parent\n until location == nil\n route.unshift [location.x, location.y]\n location = location.parent\n end\n return route\nend",
"def solver(flights)\n (p all_paths(flights)).min_by { |path| cost_of_path(path) }\nend",
"def min_cost(cost, inf)\n # dist[i] stores minimum cost to reach station i from station 0.\n dist = {};\n\n i = 0\n n = cost.length\n while i < n do\n dist[i] = inf\n i += 1\n end\n dist[0] = 0\n\n # Go through every station and check if using it as an intermediate station gives better path\n i = 0\n while i < n do\n j = i + 1\n while j < n do\n c = dist[i] + cost[i][j]\n dist[j] = c if dist[j] > c\n j += 1\n end\n i += 1\n end\n return dist[n-1];\nend",
"def nearest_driver(coord_from)\n queue = Queue.new\n queue << [coord_from]\n seen = Set.new([coord_from])\n while queue\n begin\n path = queue.pop(non_block = true)\n rescue ThreadError\n return nil\n end\n x, y = path[-1]\n if @map[y][x].instance_of?(Driver) && [x, y] != coord_from\n return { \"coord\" => [x, y], \"route\" => path, \"object\" => @map[y][x] }\n end\n for x2, y2 in [[x + 1, y], [x - 1, y], [x, y + 1], [x, y - 1]]\n if (0 <= x2 && x2 < @map[0].length) && (0 <= y2 && y2 < @map.length) && (@map[y2][x2] != @WALL && @map[y2][x2] != @PERMANENT_WALL) && !seen.include?([x2, y2])\n queue << (path + [[x2, y2]])\n seen.add([x2, y2])\n end\n end\n end\n end",
"def shortest a, b\n left = -1\n last = b.chars.map { |c| [c, -1] }.to_h\n bcount = 0\n min_length = a.length + 1\n min_left = min_right = -1\n a.chars.each_with_index do |c, right|\n if not last.has_key? c\n left = right\n bcount = 0\n else\n bcount += 1 if last[c] <= left\n last[c] = right\n while last[a[left + 1]] != left + 1\n left += 1\n end\n length = right - left\n if bcount == b.length and length < min_length\n min_length = length\n min_left = left\n min_right = right\n end\n end\n end\n if min_length < a.length + 1\n return a[(min_left + 1)..min_right]\n else\n return ''\n end\nend",
"def _closest_pair(px, py)\n nx, ny = px.length, py.length\n return [px[0], py[0]] if nx == 1 and ny == 1\n return best([px[0], px[1]], [py[0], py[1]]) if nx == 2 and ny == 2\n qx, rx, qy, ry = px[0...nx/2], px[nx/2...nx], py[0...ny/2], py[ny/2...ny]\n qpair = _closest_pair(qx, qy)\n rpair = _closest_pair(rx, ry)\n min_dist = [distance(qpair[0], qpair[1]), distance(rpair[0], rpair[1])].min\n split_pair = closest_split_pair(px, py, min_dist)\n best(qpair, rpair, split_pair)\nend",
"def build_path(start, end_pos)\n node = Node.new(start[0], start[1])\n target = Node.new(end_pos[0], end_pos[1])\n visited_nodes = []\n next_moves = [node]\n until next_moves.empty? do\n node = next_moves.shift\n puts \"Current node: #{node.x}, #{node.y}\"\n if node.x == target.x && node.y == target.y \n return node\n end\n visited_nodes.push(node)\n node.moves = get_moves(node)\n node.moves.reject do |square|\n visited_nodes.include?(square)\n end\n node.moves.each do |move| \n next_moves.push(move)\n end\n end\n return node\nend",
"def dijkstra(src, target = nil)\n frontier = PriorityQueue.new\n shortest_paths = {src => 0}\n frontier[src] = 0\n\n until frontier.empty?\n v, c = frontier.pop_min # much faster\n\n return c if target == v\n shortest_paths[v] = c\n\n v.outer_edges.each do |e|\n v2, c2 = e.to, e.cost\n next if shortest_paths[v2]\n\n frontier.insert([v2, c + c2]) # faster\n end\n end\n\n shortest_paths\nend",
"def nearest_mine\n src = @pos\n shortest_dst = 63\n nearest = [0,0]\n unowned_mines = @game.mines_locs.reject { |pos, hero_id| hero_id == @hero_id }\n unowned_mines.each do |pos, hero_id|\n build_branching_paths(src, pos)\n path = find_path(pos)\n if path.length < shortest_dst\n shortest_dst = path.length\n nearest = pos\n end\n end\n nearest\n end",
"def test_shortest_path\n expected = Amazeingly::Path.new([\n { step_number: 1, room: @rooms_collection.find(6), collected_objects: [] },\n { step_number: 2, room: @rooms_collection.find(5), collected_objects: [] },\n { step_number: 3, room: @rooms_collection.find(7), collected_objects: [] },\n { step_number: 4, room: @rooms_collection.find(4), collected_objects: [] }\n ])\n\n assert_equal expected, @path_finder.shortest_path(from_room: @rooms_collection.find(6), to_room: @rooms_collection.find(4))\n end",
"def offPath(points, coord)\n i = 0\n p1 = points[0]\n dist = getGeoDistance(p1, coord)\n while (dist > 0 && i < points.length)\n p2 = points[i]\n dist = [dist, offLine(p1, p2, coord)].min\n p1 = p2\n i += 1\n end\n return dist\n end",
"def shortest_path(v,w)\n raise ArgumentError unless path?(v,w) \n to_edge = []\n bfs(w) { |v1,v2| to_edge[v2] = v1 }\n result = []\n x = v\n while x != w\n result << x\n x = to_edge[x]\n end\n result << x\n end",
"def djikstra(graph, start_node, end_node)\n path_weights = {}\n previous_shortest_path = {}\n remaining = graph.nodes\n\n # Begin by setting weight of start node to 0, others to infinity\n graph.nodes.each do |node|\n if node == start_node\n path_weights[node] = 0\n else\n path_weights[node] = Float::INFINITY\n end\n end\n\n #TODO: can stop when we reach destination\n\n # pluck the node in remaining with lowest path weight. this will always be the start node to begin\n while remaining.length > 0\n min_index = nil\n lowest_score = Float::INFINITY\n remaining.each_with_index do |remaining_node, i|\n if path_weights[remaining_node] < lowest_score\n min_index = i\n lowest_score = path_weights[remaining_node]\n end\n end\n node = remaining.delete_at(min_index)\n\n # Update path_weight/previous of neighboring nodes based on shortest path\n # Also notice how we consider there may be no connections for the min_node.\n (node.connections || []).each do |neighbor, weight|\n if path_weights[neighbor] > (path_weights[node] + weight)\n path_weights[neighbor] = path_weights[node] + weight\n previous_shortest_path[neighbor] = node\n end\n end\n end\n\n node = end_node\n shortest_path = []\n\n while node\n shortest_path.unshift(node)\n node = previous_shortest_path[node]\n end\n\n puts path_weights[end_node]\n shortest_path.map{|node| node.value}\nend",
"def find_moves(start, target)\n visited = breadth_first_search(start, target)\n moves = []\n find_coordinate = target\n visited.reverse.each do |vertex|\n vertex.neighbors.each do |coordinate|\n if coordinate == find_coordinate\n moves << vertex.key\n find_coordinate = vertex.key\n end\n end\n end\n moves.reverse << target\n end",
"def dijkstra(city1, city2)\n #if city's distance is the same\n if city1==city2\n return 0\n end\n #set up dijkstra\n\n active = []\n distance = Hash.new\n previous = Hash.new\n\n @metros.each do |city_code, metro|\n distance[city_code] = Float::INFINITY\n previous[city_code] = nil\n active.push(city_code)\n end\n\n distance[city1] = 0\n until active.empty?\n #remove the min from dis\n min_city = active[0]\n min_dist = distance[min_city]\n active.each do |city|\n if distance[city]<min_dist\n min_dist = distance[min_city]\n min_city = city\n end\n end\n active.delete(min_city)\n this_city = min_city\n\n #for all the neighbor\n dest = @metros[this_city].destination\n dest.each do |next_city, dist|\n current_distance = get_distance(this_city, next_city)\n total_distance = distance[this_city]+current_distance\n if total_distance < distance[next_city]\n distance[next_city] = total_distance\n previous[next_city] = this_city\n end\n end\n end\n #return a list of prebious cities\n return previous, distance\n\n end",
"def find_path(start, target)\n node = build_path(start, target)\n path = [node]\n until node.next_node.nil? do\n node = node.next_node\n path.push(node)\n end\n path = path.reverse\n puts \"You made it in #{path.length} moves. Here is your path: \"\n path.each do |node|\n puts \"[#{node.x}], [#{node.y}]\"\n end\nend",
"def shortest_paths( exclusions = [] )\n # Initialization\n exclusions ||= []\n source = hex\n dist = Hash.new\n previous = Hash.new\n q = []\n @game.map.each do |h|\n if not exclusions.include? h\n dist[ h ] = INFINITY\n q << h\n end\n end\n dist[ source ] = 0\n \n # Work\n while not q.empty?\n u = q.inject { |best,h| dist[ h ] < dist[ best ] ? h : best }\n q.delete u\n @game.map.hex_neighbours( u ).each do |v|\n next if exclusions.include? v\n alt = dist[ u ] + entrance_cost( v )\n if alt < dist[ v ]\n dist[ v ] = alt\n previous[ v ] = u\n end\n end\n end\n \n # Results\n previous\n end",
"def find_solution\n open = [{:cell => @start_cell, :parent => nil, :distance => 0}]\n closed = []\n\n while !open.empty?\n # Find the lowest movement cost\n current_node = open.min{ |a,b| a[:distance] <=> b[:distance]}\n\n # Check if we reached the end cell\n if is_end?(current_node[:cell])\n return current_node[:distance]\n end\n\n # Find immediate neighbors\n current_neighbors = find_neighbors(current_node[:cell])\n current_neighbors.each { | neighbor |\n if closed.find { | node | node[:cell].eql?(neighbor[:cell])}.nil?\n # Find if the cell is already in the open list\n existing_open = open.find { |node | node[:cell].eql?(neighbor[:cell])}\n if existing_open\n # Find the shorter distance to the cell\n current_distance = existing_open[:distance]\n new_distance = current_node[:distance] + neighbor[:distance]\n existing_opened[:distance] = new_distance if current_distance > new_distance\n else\n # Add the new visited cell to the open list\n neighbor[:distance] = neighbor[:distance] + current_node[:distance]\n open << neighbor\n end\n end\n }\n closed << current_node\n open.delete(current_node)\n end\n 0\n end",
"def find_path(x, y, path = [])\n if x.zero? && y.zero?\n @results << path\n return 1\n elsif x < 0 || y < 0\n return 0\n elsif @grid[x][y] == 1\n return 0\n end\n\n new_path = path.dup\n new_path.insert(0, [y, x])\n\n @cache[[x - 1 , y]] ||= find_path(x - 1, y, new_path)\n @cache[[x, y - 1]] ||= find_path(x, y - 1, new_path)\n end",
"def dijkstra\n # Intialise the algorithom if first run\n init_dijkstra if empty_path?\n\n # Stop the execution if all the nides have been reached\n return path if completed_path?\n\n # Make sure that all the weights are updated\n current_node[:node].adjacent_nodes.values.each do |node|\n @pool << node.merge(\n from: current_node[:node],\n weight: node[:weight] + current_node[:weight]\n )\n end\n\n # Sort the pool of nodes/edges by weight so to be able to grab the smallest\n # weight.\n pool.sort_by! { |edge| edge[:weight] }\n\n # Pick the next untouched node by shifting the nodes in the pool starting\n # from the smallest to the greatest.\n next_node = nil\n loop do\n next_node = pool.shift\n break unless values_in_path.include?(next_node[:node].value)\n end\n\n # Push the next step (from -> to) in the path\n @path << \"#{next_node[:from].value} ==> #{next_node[:node].value}\"\n\n # Track the node as seen\n @values_in_path += [next_node[:node].value, current_node[:node].value]\n\n # Update the current node\n @current_node = next_node\n\n # Keep the execution going\n dijkstra\n end",
"def get_path(start, finish) \n @retreat_algorithm.set_graph(memory.construct_grid) \n @retreat_algorithm.run(start, finish)\n end",
"def shortest(word1, word2)\n ans = @M\n for i in @d[word1]\n for j in @d[word2]\n ans = [ans, (i-j).abs].min\n end\n end\n return ans\n end",
"def shortest_path( dest, exclusions = [] )\n exclusions ||= []\n previous = shortest_paths( exclusions )\n s = []\n u = dest.hex\n while previous[ u ]\n s.unshift u\n u = previous[ u ]\n end\n s\n end"
] |
[
"0.7697564",
"0.743759",
"0.73410743",
"0.7272909",
"0.7203339",
"0.7181298",
"0.7136766",
"0.7038711",
"0.69993603",
"0.69938767",
"0.69314754",
"0.69020987",
"0.68623686",
"0.681849",
"0.6803307",
"0.6781413",
"0.67556626",
"0.6724962",
"0.6721541",
"0.67188454",
"0.6713906",
"0.6692522",
"0.6690164",
"0.6682542",
"0.6667078",
"0.6655667",
"0.6642303",
"0.6638631",
"0.6632105",
"0.65946853",
"0.6532912",
"0.6531765",
"0.6511708",
"0.65099126",
"0.6475027",
"0.6441672",
"0.6425422",
"0.64203423",
"0.6391208",
"0.6386079",
"0.6353851",
"0.6348011",
"0.63305277",
"0.6325819",
"0.63202655",
"0.63093776",
"0.6306742",
"0.6285295",
"0.6283617",
"0.62791044",
"0.62713957",
"0.6260127",
"0.6233654",
"0.62056315",
"0.6150447",
"0.6147338",
"0.61468035",
"0.61461806",
"0.6121862",
"0.6097395",
"0.6088167",
"0.60822934",
"0.6079128",
"0.6075214",
"0.60652995",
"0.6064148",
"0.60554355",
"0.60419863",
"0.6022039",
"0.6014451",
"0.60133654",
"0.6011776",
"0.6003338",
"0.59976023",
"0.5996399",
"0.59929144",
"0.59896547",
"0.59880084",
"0.5984286",
"0.59802103",
"0.5979507",
"0.5968088",
"0.5967504",
"0.59381986",
"0.59316504",
"0.5928844",
"0.59269273",
"0.59116745",
"0.59074175",
"0.59043974",
"0.59013915",
"0.58655554",
"0.5860746",
"0.5856492",
"0.5849558",
"0.58467823",
"0.5835599",
"0.5832801",
"0.5832181",
"0.58112407"
] |
0.7386457
|
2
|
Find the nearest path to user from the given coordinate It will return the shortest path to the user
|
def shortest_path_to_user(start_coord)
queue = Queue.new
queue << [start_coord]
seen = Set.new([start_coord])
while queue
begin
path = queue.pop(non_block = true)
rescue ThreadError
return nil
end
x, y = path[-1]
if @map[y][x] == @USER
return path
end
for x2, y2 in [[x + 1, y], [x - 1, y], [x, y + 1], [x, y - 1]]
if (0 <= x2 && x2 < @map[0].length) && (0 <= y2 && y2 < @map.length) && (@map[y2][x2] != @WALL && @map[y2][x2] != @PERMANENT_WALL) && !seen.include?([x2, y2])
queue << (path + [[x2, y2]])
seen.add([x2, y2])
end
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def next_step_to_shortest_path(from_x, from_y, to_x, to_y)\n move = shortest_path(from_x, from_y, to_x, to_y)&.first\n return nil unless move\n if move[0] == from_x && move[1] == from_y + 1\n return 'S'\n elsif move[0] == from_x && move[1] == from_y - 1\n return 'N'\n elsif move[0] == from_x + 1 && move[1] == from_y\n return 'E'\n elsif move[0] == from_x - 1 && move[1] == from_y\n return 'W'\n end\n raise 'This should not happen'\n end",
"def nearest_driver(coord_from)\n queue = Queue.new\n queue << [coord_from]\n seen = Set.new([coord_from])\n while queue\n begin\n path = queue.pop(non_block = true)\n rescue ThreadError\n return nil\n end\n x, y = path[-1]\n if @map[y][x].instance_of?(Driver) && [x, y] != coord_from\n return { \"coord\" => [x, y], \"route\" => path, \"object\" => @map[y][x] }\n end\n for x2, y2 in [[x + 1, y], [x - 1, y], [x, y + 1], [x, y - 1]]\n if (0 <= x2 && x2 < @map[0].length) && (0 <= y2 && y2 < @map.length) && (@map[y2][x2] != @WALL && @map[y2][x2] != @PERMANENT_WALL) && !seen.include?([x2, y2])\n queue << (path + [[x2, y2]])\n seen.add([x2, y2])\n end\n end\n end\n end",
"def shortest_path(start_coord, destination_coord)\n queue = Queue.new\n queue << [start_coord]\n seen = Set.new([start_coord])\n while queue\n begin\n path = queue.pop(non_block = true)\n rescue ThreadError\n return nil\n end\n x, y = path[-1]\n if [x, y] == destination_coord\n return path\n end\n for x2, y2 in [[x + 1, y], [x - 1, y], [x, y + 1], [x, y - 1]]\n if (0 <= x2 && x2 < @map[0].length) && (0 <= y2 && y2 < @map.length) && (@map[y2][x2] != @WALL && @map[y2][x2] != @PERMANENT_WALL) && !seen.include?([x2, y2])\n queue << (path + [[x2, y2]])\n seen.add([x2, y2])\n end\n end\n end\n end",
"def shortest_path\n pa = AI::AStarAlgorithm.new($map.grid, $map.gen_coordinates)\n pa.astar\n end",
"def shortest_path(from_x, from_y, to_x, to_y)\n @visited = Array.new(@matrix.size) { Array.new(@matrix.first.size) { false } }\n @farthest_node = nil\n queue = Queue.new\n queue << Node.new(from_x, from_y, 0)\n\n while !queue.empty? do\n node = queue.pop\n\n if !@farthest_node || node.dist > @farthest_node.dist\n @farthest_node =node\n end\n\n if node.x == to_x && node.y == to_y\n # We pathed to the target\n target_node = node\n break\n end\n [[-1,0],[1,0],[0,1],[0,-1]].each do |dir|\n x = node.x + dir[0]\n y = node.y + dir[1]\n if is_valid?(x, y)\n @visited[y][x] = true\n queue.push(Node.new(x, y, node.dist + 1, node))\n end\n end\n end\n\n # We didn't find a path to the target\n return nil unless target_node\n\n # Trace back the journey\n journey = []\n journey.push [node.x,node.y]\n while !node.parent.nil? do\n node = node.parent\n journey.push [node.x,node.y]\n end\n journey.reverse.drop(1)\n end",
"def shortest_path\n initial_position_obj = { position: start_position, source: {} }\n\n knights_path = [initial_position_obj]\n\n while knights_path.present?\n current_position = knights_path.shift\n\n position = current_position[:position]\n\n if position == end_position\n return path_to_destination(current_position, initial_position_obj)\n end\n\n add_possible_destination(position, current_position, knights_path)\n end\n end",
"def find_best_way(xx,yy)\n pf = Pathfinder.new($map)\n pf.ignore_obs_target = true # permit to calculate a path to a case with an ennemy on it\n path = pf.find([x,y],[xx,yy])\n end",
"def findnearest( coords, targetx, targety )\n # find nearest coordinate\n nearest = 0\n targetcounter = 0\n target = -1\n coords.each do |neighborx,neighbory|\n d = Math::sqrt( ( neighborx - targetx ) ** 2 + ( neighbory - targety ) ** 2 )\n if d < 0.2\n target = targetcounter\n end\n targetcounter += 1\n end\n return target\nend",
"def select_possible_path(possible_paths)\n vertex, data = possible_paths.min_by do |vertex, data|\n data[:cost]\n end\n vertex\nend",
"def nearest_mine\n src = @pos\n shortest_dst = 63\n nearest = [0,0]\n unowned_mines = @game.mines_locs.reject { |pos, hero_id| hero_id == @hero_id }\n unowned_mines.each do |pos, hero_id|\n build_branching_paths(src, pos)\n path = find_path(pos)\n if path.length < shortest_dst\n shortest_dst = path.length\n nearest = pos\n end\n end\n nearest\n end",
"def find_nearest_route(path)\n\t\t\tpath_parts = path.parts.dup\n\t\t\tloop do\n\t\t\t\troute = routes.navigate(*path_parts)&.first_route\n\t\t\t\tbreak route if route || path_parts.pop.nil?\n\t\t\tend\n\t\tend",
"def find_path_brute_force( board, start_point )\n options = get_options( start_point, board )\n\n # Bottom right corner\n if options.length == 0\n return { points: [start_point], best_value: get_value( start_point, board ) }\n end\n\n # If there's only one option, this works fine still.\n first_result = find_path_brute_force( board, options.first )\n second_result = find_path_brute_force( board, options.last )\n if first_result[:best_value] > second_result[:best_value]\n return {\n points: [start_point] + first_result[:points],\n best_value: first_result[:best_value] + get_value( start_point, board )\n }\n else\n return {\n points: [start_point] + second_result[:points],\n best_value: second_result[:best_value] + get_value( start_point, board )\n }\n end\nend",
"def grab_nearest_by_location(distance, loc)\n\n end",
"def shortest_route_by_distance_to!(place_or_object_place_was_built_from)\n routes_for!(place_or_object_place_was_built_from).min_by(&:distance_in_meters)\n end",
"def nearest_driver(map,user)\n driver_pos=[]\n\n for i in 0..map.length-1\n for j in 0..map.length-1\n if map[i][j] == \" D \"\n driver_pos << [i,j]\n end\n end\n end\n @driver_pos=driver_pos\n\n nearest_driver_position = driver_pos[0]\n distance = driver_pos[0].zip(user).map { |x| x.reduce(:-).abs }.sum\n\n for i in 1..driver_pos.length-1\n temp = driver_pos[i].zip(user).map { |x| x.reduce(:-).abs }.sum\n if temp < distance\n distance = temp\n nearest_driver_position = driver_pos[i]\n end\n end\n nearest_driver_position\n end",
"def get_path(start, stop)\n @graph.dijkstra_shortest_path(@weight_map, start, stop)\n end",
"def best_path(start, target)\n queue = []\n path = []\n targetX = target[0]\n targetY = target[1] \n update_possible_moves(start)\n path << [@x, @y]\n until @x == targetX && @y == targetY\n @moves.each do |valid_move|\n queue << valid_move unless out_of_bounds?(valid_move) \n end\n #shift because we want bread-first search\n next_move = queue.shift\n update_possible_moves(next_move)\n path << [@x, @y] \n end\n # Filter out the best path and present it\n best_possible_path = filter_path(path)\n puts \"You made it in #{best_possible_path.length} moves! The path is:\\n#{best_possible_path}\"\n end",
"def find_path(x, y, path = [])\n if x.zero? && y.zero?\n @results << path\n return 1\n elsif x < 0 || y < 0\n return 0\n elsif @grid[x][y] == 1\n return 0\n end\n\n new_path = path.dup\n new_path.insert(0, [y, x])\n\n @cache[[x - 1 , y]] ||= find_path(x - 1, y, new_path)\n @cache[[x, y - 1]] ||= find_path(x, y - 1, new_path)\n end",
"def return_shortest_path(from)\r\n\r\n queue = Queue.new\r\n queue << from\r\n from.distance = 0\r\n while(!queue.empty?)\r\n v= queue.pop\r\n count=0\r\n adjDir = find_adjacent_rooms(v.roomObject)\r\n while(count < adjDir.length)\r\n w = @vertices[v.roomObject.return_title(adjDir[count])]\r\n\r\n if(w.distance==Float::INFINITY)\r\n w.distance = v.distance + 1\r\n w.path = v.path + \" \" + adjDir[count].to_s()\r\n queue << w\r\n end\r\n count = count + 1\r\n end\r\n count=0\r\n end\r\n\r\n end",
"def find_path(source, target, map)\n @main_loop_count = 0\n\n max_y = map.size - 1\n max_x = map[0].size - 1\n target_x = target[0]\n target_y = target[1]\n # target heuristic is 0\n target = [target_x, target_y, 0]\n\n # Sets up the search to begin from the source\n source = source.dup.push((target_x - source[0]).abs + (target_y - source[1]).abs)\n came_from = {}\n came_from[source] = nil\n frontier = [source]\n\n # Until the target is found or there are no more cells to explore from\n until came_from.has_key?(target) || frontier.empty?\n @main_loop_count += 1\n\n # Take the next frontier cell\n new_frontier = frontier.shift\n\n # Find the adjacent neighbors\n adjacent_neighbors = []\n\n # Gets all the valid adjacent_neighbors into the array\n # From southern neighbor, clockwise\n nfx = new_frontier[0]\n nfy = new_frontier[1]\n adjacent_neighbors << [nfx , nfy - 1, (target_x - nfx).abs + (target_y - nfy + 1).abs] unless nfy == 0\n adjacent_neighbors << [nfx - 1, nfy - 1, (target_x - nfx + 1).abs + (target_y - nfy + 1).abs] unless nfx == 0 || nfy == 0\n adjacent_neighbors << [nfx - 1, nfy , (target_x - nfx + 1).abs + (target_y - nfy).abs] unless nfx == 0\n adjacent_neighbors << [nfx - 1, nfy + 1, (target_x - nfx + 1).abs + (target_y - nfy - 1).abs] unless nfx == 0 || nfy == max_y\n adjacent_neighbors << [nfx , nfy + 1, (target_x - nfx).abs + (target_y - nfy - 1).abs] unless nfy == max_y\n adjacent_neighbors << [nfx + 1, nfy + 1, (target_x - nfx - 1).abs + (target_y - nfy - 1).abs] unless nfx == max_x || nfy == max_y\n adjacent_neighbors << [nfx + 1, nfy , (target_x - nfx - 1).abs + (target_y - nfy).abs] unless nfx == max_x\n adjacent_neighbors << [nfx + 1, nfy - 1, (target_x - nfx - 1).abs + (target_y - nfy + 1).abs] unless nfx == max_x || nfy == 0\n\n new_neighbors = adjacent_neighbors.select do |neighbor|\n # That have not been visited and are not walls\n unless came_from.has_key?(neighbor) || map[neighbor[1]][neighbor[0]] != '.'\n # Add them to the frontier and mark them as visited\n # frontier << neighbor\n came_from[neighbor] = new_frontier\n end\n end\n\n # Sort the frontier so cells that are close to the target are then prioritized\n if new_neighbors.length > 0\n new_neighbors = merge_sort(new_neighbors)\n if frontier.length > 0 && new_neighbors[0][2] >= frontier[0][2]\n frontier = merge_sort(new_neighbors.concat(frontier))\n else\n frontier = new_neighbors.concat(frontier)\n end\n end\n end\n\n # If the search found the target\n if came_from.has_key?(target)\n # Calculates the path between the target and star for the greedy search\n # Only called when the greedy search finds the target\n path = []\n next_endpoint = came_from[target]\n while next_endpoint\n path << [next_endpoint[0], next_endpoint[1]]\n next_endpoint = came_from[next_endpoint]\n end\n path\n else\n return nil\n end\n end",
"def find_path(start, goal)\n raise \"loc1 must not be the same as loc2\" if start == goal\n\n # Using A* path-finding algorithm\n # See pseudocode here: https://en.wikipedia.org/wiki/A*_search_algorithm\n # https://www.redblobgames.com/pathfinding/a-star/introduction.html\n # NOTE that this is overkill for this problem...\n open_set = Set.new([start])\n came_from = {}\n\n # Default value of \"Infinity\", but we can just use nil\n g_score = {}\n g_score[start] = 0\n\n # f_score = g_score[node] + h_score[node]\n # This uses both current best path (g score) aka similar to Djikstra's algorithm,\n # plus the heuristic score.\n f_score = {}\n # g_score[start] is 0, so not included here\n f_score[start] = h_score(start, goal)\n\n # Note that we add d_score as the weight of the edge, but in our\n # case, we consider all edges equally, so hardcode 1\n d_score = 1\n\n until open_set.empty? do\n # Node in open set with lowest f score (would ideally use PriorityQueue)\n current = open_set.min_by { |node| f_score[node] }\n\n if current == goal\n return reconstruct_path(came_from, current)\n end\n\n open_set.delete(current)\n\n valid_neighbours(current).each do |neighbour_loc|\n tentative_g_score = g_score[current] + d_score\n if g_score[neighbour_loc].nil? || tentative_g_score < g_score[neighbour_loc]\n # This path to neighbor is better than any previous one. Record it!\n came_from[neighbour_loc] = current\n g_score[neighbour_loc] = tentative_g_score\n f_score[neighbour_loc] = g_score[neighbour_loc] + h_score(neighbour_loc, goal)\n if !open_set.include?(neighbour_loc)\n open_set << neighbour_loc\n end\n end\n end\n end\n\n raise \"error, no path found!\"\n end",
"def getPointOnPath(view_path_coordinates, average_speed, time)\n distance = average_speed * time\n ans = getDirectionAndPointOnPath(view_path_coordinates, distance, average_speed)\n return ans[:coord]\n end",
"def compute_shortest_path\n update_distance_of_all_edges_to(Float::INFINITY)\n @distance_to[@source_node] = 0\n\n # The prioriy queue holds a node and its distance from the source node.\n @pq.insert(@source_node, 0)\n while @pq.any?\n node = @pq.remove_min\n node.adjacent_edges.each do |adj_edge|\n relax(adj_edge)\n end\n end\n end",
"def find_closest\n find_target_coordinates\n location = build_query.geo_near(@target_cord).first\n\n return nil if location.nil?\n [(location.phone_numbers & customer_numbers).first, location.geo_name]\n end",
"def find_shortest_path(initial_node, final_node)\n\t\tunless @nodes.include?(initial_node) && @nodes.include?(final_node)\n\t\t raise(\"Either of the nodes not found in the Graph\") \n\t\tend\n\t\tdistance = {}\n\t previous = {}\n\t\tdistance[initial_node] = 0 # Distance from initial_node to initial_node\n\t previous[initial_node] = nil\n\t\tnodes_counted = @nodes\n\t\t\t\n\t\tnodes_counted.each do |n|\n\t\t if n != initial_node \n\t\t\t distance[n] = Float::INFINITY # Unknown distance function from initial_node to final_node\n\t\t\t previous[n] = nil \t # Previous node in optimal path from initial_node\n\t\t\tend\n\t\tend\n\n\t\tuntil nodes_counted.empty? \n\t\t\n\t\t\tu = distance.select{|k,v| nodes_counted.include?(k)}.min_by{|k,v| v}.first # Source node in first case\n\t\t\tbreak if (distance[u] == Float::INFINITY)\n\t\t\tnodes_counted.delete(u)\n\t\t\t\n\t\t\t@paths[u].keys.each do |v|\n\t\t\t\talt = distance[u] + @paths[u][v]\n\t\t\t\tif alt < distance[v] # A shorter path to v has been found\n\t\t\t\t\tdistance[v] = alt\n\t\t\t\t\tprevious[v] = u\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t \n\t\tpath = []\n\t\tcurrent = final_node\n\t\twhile current\n\t\t\tpath.unshift(current)\n\t\t\tcurrent = previous[current]\n\t\tend\n \n\t\treturn distance[final_node], path\n\n\tend",
"def call\n return nil unless on_the_graph? # Prevents a stack overflow in the gem\n return shortest_path[1..-1] if shortest_path.length > 1\n end",
"def shortest_route_by_distance_to(place_or_object_place_was_built_from)\n routes = routes_for place_or_object_place_was_built_from\n select_ok_routes(routes).min_by(&:distance_in_meters)\n end",
"def offPath(points, coord)\n i = 0\n p1 = points[0]\n dist = getGeoDistance(p1, coord)\n while (dist > 0 && i < points.length)\n p2 = points[i]\n dist = [dist, offLine(p1, p2, coord)].min\n p1 = p2\n i += 1\n end\n return dist\n end",
"def find_path(start_node, end_node, grid)\n start_node = sanitize(start_node)\n end_node = sanitize(end_node)\n if grid.nil?\n [start_node]\n else\n _max_x = grid.max_x\n _max_y = grid.max_y\n\n @current_grid = grid.inner_grid.clone\n\n raise 'max_x & max_y required' unless _max_x && _max_y\n\n _start_node = start_node.clone\n _end_node = end_node.clone\n\n heuristic = @heuristic.new(_end_node, @weight)\n\n _start_node[:f] = 0 # sum of g and h\n _start_node[:g] = 0 # steps to start node\n _start_node[:h] = nil # steps to end node\n _start_node[:opened] = true\n\n # use heap or tree for better perf\n open = []\n open.push _start_node\n\n while !open.empty? do\n _current_node = open.pop\n\n _current_node[:closed] = true\n @current_grid[node_to_a(_current_node)] = _current_node\n\n if node_to_a(_current_node) == node_to_a(_end_node)\n return final_path(_current_node)\n end\n\n new_g = _current_node[:g] + 1\n\n x = _current_node[:x]\n y = _current_node[:y]\n\n neighbors = []\n\n neighbors << [x-1, y] if x > 0\n neighbors << [x, y-1] if y > 0\n neighbors << [x+1, y] if x < _max_x-1\n neighbors << [x, y+1] if y < _max_y-1\n\n _neighbors = neighbors.map do |position|\n node = @current_grid[position]\n if node.nil? || node[:walkable]\n node ||= {}\n @current_grid[position] = node.merge({\n x: position.first,\n y: position[1],\n closed: false,\n opened: false\n })\n end\n end.compact\n\n _neighbors.each do |neighbor|\n if (!neighbor[:opened] || new_g < neighbor[:g])\n neighbor[:g] = new_g\n neighbor[:h] ||= heuristic.h(neighbor)\n neighbor[:f] = neighbor[:g] + neighbor[:h]\n neighbor[:parent] = node_to_a(_current_node)\n\n if (!neighbor[:opened])\n open.push neighbor\n neighbor[:opened] = true\n else\n # ???\n puts \"got here some how!!!\"\n end\n end\n end\n\n open.sort_by! {|i| [-i[:f], -i[:h]]}\n # grid_p\n end\n end\n end",
"def shortest_distance_from(latitude, longitude)\n\t\tmin_dist = BigDecimal.new(\"10.0\")\n\t\tinput_lat = BigDecimal.new(latitude)\n\t\tinput_lng = BigDecimal.new(longitude)\n\n\t\t#Find waypoint with shortest distance from input\n\t\tfor location in self.locations\n\t\t\tpoint_lat = BigDecimal(location.coord.latitude.to_s)\n\t\t\tpoint_lng = BigDecimal(location.coord.longitude.to_s)\n\n\t\t\t#Get distance between two points\n\t\t\tdist = ((input_lat - point_lat)**2 + (input_lng - point_lng)**2).sqrt(10)\n\n\t\t\t#Update the minimum\n\t\t\tif min_dist > dist\n\t\t\t\tmin_dist = dist\n\t\t\tend\n\t\tend\n\n\t\treturn min_dist\n\tend",
"def find_path(start, finish, *avoid_sectors)\n shortest_path(start, finish, avoid_sectors.flatten)\n end",
"def find_min_path(i, j)\n return 1 if i == 0 || j == 0\n return find_min_path(i-1, j) + find_min_path(i, j-1)\nend",
"def getDirectionAndPointOnPath(view_path_coordinates, target, average_speed)\n dist = 0.0\n vpcs = view_path_coordinates\n #puts \"PoP: ***** vps = #{vpcs.inspect}\"\n last_point = vpcs.first\n ti_dist = 0\n for p2 in vpcs.drop(1) do\n if equalCoordinates?(last_point,p2)\n last_point = p2\n next\n end\n # Direction should be valid as there is a distance.\n bearing = getBearing(last_point,p2)\n direction = getGeoAngle(last_point,p2)\n if (dist < target)\n dist2 = dist + getGeoDistance(last_point,p2)\n #puts \"PoP: dist = #{dist} target = #{target} dist2 = #{dist2} target-dist = #{target-dist} last_point = #{last_point.inspect} p2= #{p2.inspect}\"\n if (target <= dist2)\n lon, lat = getDestinationPoint(last_point, target-dist, bearing)\n# ratio = (target-dist)/(dist2-dist)\n# a = getGeoAngle(last_point,p2)\n# lon = last_point[0] + Math.cos(a) * (target-dist) * (1/Math.cos(rad(last_point[1])) * LON_PER_FOOT)\n# lat = last_point[1] + Math.sin(a) * (target-dist) * LAT_PER_FOOT\n# #puts \"PoP: a = #{a} dist = #{target-dist} pop = #{[lon,lat].inspect}\"\n# # This is just integrity check. It can be eliminated.\n if !onLine(last_point,p2,60,[lon,lat])\n onLine1(last_point,p2,60,[lon,lat])\n raise \"Not on Path\"\n end\n ti_dist += getGeoDistance(last_point,[lon,lat])/average_speed\n # We have been returning the GeoAngle, which is different than a bearing. Messes up clients if not.\n # direction should be the same as getGeoAngle(last_point, p2)\n return { :distance => target, :direction => direction,\n :coord => [lon,lat], :ti_dist => ti_dist}\n end\n ti_dist += getGeoDistance(last_point,p2)/average_speed\n dist = dist2\n last_point = p2\n end\n end\n # target is past distance. Return last point, direction may be nil (all equal points)\n return { :distance => dist, :direction => direction, :coord => last_point, :ti_dist => ti_dist }\n end",
"def shortest_way(source, dest)\n\t\t@source = source\n dijkstra source\n \n if @distances[dest] != @infinity\n return @distances[dest]\n end\n\tend",
"def shortest_paths(s)\n @source = s\n dijkstra s\n puts \"Source: #{@source}\"\n @nodes.each do |dest|\n puts \"\\nTarget: #{dest}\"\n print_path dest\n if @d[dest] != @INFINITY\n puts \"\\nDistance: #{@d[dest]}\"\n else\n puts \"\\nNO PATH\"\n end\n end\n end",
"def proximity_to_star(x, y)\n distance_x = (grid.star.x - x).abs\n distance_y = (grid.star.y - y).abs\n\n if distance_x > distance_y\n return distance_x\n else\n return distance_y\n end\n end",
"def find_shortest_path(exclude_path_with_tile = nil)\n node = find_end_tile(exclude_path_with_tile)\n return [@start_tile, @end_tile] if node.nil?\n expand_path(node)\n end",
"def nearestLocation _args\n \"nearestLocation _args;\" \n end",
"def nearest_fortress_exit_point(point)\n nearest_fortress_exit_cell = nil\n nearest_distance = MAX_DISTANCE\n fortress_exit_cells.each do |exit_cell|\n distance = Tools.calc_distance(point, exit_cell)\n if distance < nearest_distance\n nearest_distance = distance\n nearest_fortress_exit_cell = exit_cell\n end\n end\n return Point.new(nearest_fortress_exit_cell.x, nearest_fortress_exit_cell.y)\n end",
"def solve(from_word, to_word)\n return @word_graph.shortest_path(from_word, to_word)\n end",
"def find_closest(vertex)\n closest = @vertices.first\n closest_distance = Vertex.euclidean_distance(vertex, closest)\n @vertices.each do |v|\n distance = Vertex.euclidean_distance(vertex, v)\n if distance < closest_distance\n closest_distance = distance\n closest = v\n end\n end\n return closest\n end",
"def calc_path\n endpoint = grid.target\n while endpoint\n search.path[endpoint] = true\n endpoint = search.came_from[endpoint]\n end\n end",
"def determine_farthest_room_from_user(user_pos)\r\n max =-999\r\n room = nil\r\n @path_weights.each{\r\n |key,value|\r\n value.each{\r\n |key2,value2|\r\n if(key2==user_pos.title)\r\n if(value2.distance > max)\r\n max = value2.distance\r\n room = @current_world.rooms[key]\r\n end\r\n end\r\n }\r\n }\r\n return room\r\n end",
"def shortest_single_flight\n\n min_distance = @largest_integer\n flight = \"\"\n @query.get_graph.each_key do |city|\n route_dict = get_outgoing_routes(city)\n route_dict.each do |dest, dist|\n if dist < min_distance\n min_distance = dist\n flight = \"#{get_city_info(city,\"name\")}-#{dest}\"\n end\n end\n end\n\n return flight\n\n end",
"def shortest_paths(s)\n\t\t@source = s\n\t\tdijkstra s\n\t\tputs \"Source: #{@source}\"\n\t\t@nodes.each do |dest|\n\t\t\tputs \"\\nTarget: #{dest}\"\n\t\t\tprint_path dest\n\t\t\tif @d[dest] != @INFINITY\n\t\t\t\tputs \"\\nDistance: #{@d[dest]}\"\n\t\t\telse\n\t\t\t\tputs \"\\nNO PATH\"\n\t\t\tend\n\t\tend\n\tend",
"def shortest_path_between_nodes(initial, destination)\n initial.distance = 0\n\n current = initial\n loop do\n # at the destination node, stop calculating\n break if current == destination\n\n unvisited.delete(current)\n\n calculate_neighbor_shortest_distances(current)\n\n return nil if no_reachable_nodes\n\n current = unvisited.min_by(&:distance)\n end\n\n destination.path\n end",
"def find_one_closest_point(reference_point, guess, geometric_resolution)\n do_find_one_closest_point(reference_point.to_a, guess, geometric_resolution)\n end",
"def find_path(goal = @maze.find_end)\n path = [goal]\n spot = goal\n until @branching_paths[spot] == nil\n path << @branching_paths[spot]\n spot = @branching_paths[spot]\n end\n path\n end",
"def robot_paths(x, y, map={})\n if x == 0 && y == 0\n 0\n elsif (x == 0 && y >= 0) || (x >= 0 && y == 0)\n 1\n elsif map[x] && map[x][y]\n map[x][y]\n else\n result = robot_paths(x - 1, y, map) + robot_paths(x, y - 1, map)\n map[x] ? map[x][y] = result : map[x] = {y => result}\n map[x][y]\n end\nend",
"def dijkstra_shortest_path(start, finish)\n visited, unvisited = Array.new, Array.new\n distances = Hash.new\n\n distances[start] = 0\n unvisited << start\n\n # find the distance\n while not unvisited.empty?\n curr_node = unvisited.pop\n visited << curr_node\n get_edges(curr_node).each do |edge| \n if visited.find_index(edge.out_vertex) == nil\n unvisited.unshift(edge.out_vertex) if unvisited.find_index(edge.out_vertex) == nil\n curr_distance, min_distance = distances[curr_node], distances[edge.out_vertex] || 1.0 / 0.0\n if curr_distance + edge.distance < min_distance\n distances[edge.out_vertex] = curr_distance + edge.distance\n end\n end\n end\n end\n\n # figure out the path\n previous = finish\n path = Array.new() \n path << previous\n while distances[previous] != 0\n get_edges(previous).each do |edge|\n if previous != edge.in_vertex && distances[edge.in_vertex] + edge.distance == distances[previous]\n previous = edge.in_vertex\n path << previous\n break\n end\n end\n end\n \n return distances[finish], path.reverse\n end",
"def closest_point_to(target, min_distance=3)\n angle_rad = target.calculate_rad_angle_between(self)\n radius = target.radius + min_distance\n x = target.x + radius * Math.cos(angle_rad)\n y = target.y + radius * Math.sin(angle_rad)\n\n Position.new(x, y)\n end",
"def _closest_pair(px, py)\n nx, ny = px.length, py.length\n return [px[0], py[0]] if nx == 1 and ny == 1\n return best([px[0], px[1]], [py[0], py[1]]) if nx == 2 and ny == 2\n qx, rx, qy, ry = px[0...nx/2], px[nx/2...nx], py[0...ny/2], py[ny/2...ny]\n qpair = _closest_pair(qx, qy)\n rpair = _closest_pair(rx, ry)\n min_dist = [distance(qpair[0], qpair[1]), distance(rpair[0], rpair[1])].min\n split_pair = closest_split_pair(px, py, min_dist)\n best(qpair, rpair, split_pair)\nend",
"def shortest_path_from(from, check=nil)\n dirs = [ [1,0], [0,1], [0,-1], [-1,0] ]\n \n #return [1,0]\n \n unless @cache and @cached_for == towers.keys+[check]\n\tmarked = {}\n\tmarked.default = false\n\n\tq = [Config.monsters_end_at]\n\tfirst = 0\n\t\n\tmarked[Config.monsters_end_at] = true\n\t\n\twhile first < q.size\n\t v = q[first]\n\t first += 1\n\t for i in dirs\n\t w = [v[0]+i[0], v[1]+i[1]]\n\t next if w != Config.monsters_start_at and w != Config.monsters_end_at and\n\t\t (w[0] < 0 or w[1] < 0 or w[0] >= Config.map_size[0] or w[1] >= Config.map_size[1])\n\t next if marked[w] or w == check or towers[w]\n\t marked[w] = [-i[0], -i[1] ]\n\t q << w\n\t end\n\tend\n\t\n\t@cached_for = towers.keys+[check]\n\t@cache = marked\n end\n \n return @cache[from]\n end",
"def knight_path(from, to)\n\topen_queue = [PositionPath.new( from, [copy(from)] )]\n\tdiscovered = [from]\n\n\tuntil open_queue.empty?\n\t\tcurrent = open_queue.shift\n\n\t\treturn current.path if current.position == to\n\t\tvalid_moves(current.position).each do |move|\n\t\t\tunless discovered.include?(move)\n\t\t\t\tdiscovered << move\n\t\t\t\topen_queue.push(make_position_path(current, move)) \n\t\t\tend\n\t\tend\n\tend\n\t\nend",
"def guide(from, to, unit_type=nil, max_depth=400)\n return nil if @map.blocked?(from, unit_type) || @map.blocked?(to, unit_type)\n from_element = PathElement.new(from)\n from_element.dist_from = @map.distance(from,to)\n open = PriorityQueue.new { |x, y| (x <=> y) == -1 }\n open.push from_element, from_element.rating\n closed = SplayTreeMap.new\n step = 0\n \n until open.empty? || step > max_depth\n step += 1\n \n current_element = open.pop\n @nodes_considered += 1\n \n loc = current_element.location\n if @map.cost(loc,to) == 0\n path = []\n until current_element.parent.nil?\n path.unshift current_element\n current_element = current_element.parent\n end\n\n return path\n else\n closed.push loc, current_element\n @map.neighbors(loc).each do |next_door|\n next if closed.has_key? next_door\n\n el = PathElement.new(next_door,current_element)\n\n if @map.blocked? next_door, unit_type\n closed.push el.location, el\n else\n current_rating = current_element.cost_to + @map.cost(loc, next_door)\n\n # add to open\n el.cost_to = current_rating\n el.dist_from = @map.distance(next_door,to)\n \n open.push el, el.rating\n end\n end\n end\n end\n nil\n end",
"def nearest var, path\n values = []\n path.inject(self) do |branch, k|\n values << branch.var( var )\n branch[ k ]\n end\n values.compact.last\n end",
"def find_path(char)\n # get pixel movement rate\n pix = $BlizzABS.pixel\n # use request\n request = @request[char]\n # if no nodes to test\n if request.open.size == 0\n # abort testing for this character\n @request.delete(char)\n # resets state\n char.ai.state = (char.ai.state == Invalid ? Return : Ready)\n # stop execution\n return []\n end\n # found\n found = false\n # find minimal key\n key = request.open.keys.min {|a, b|\n Math.hypot(a[0] - request.tx, a[1] - request.ty) <=>\n Math.hypot(b[0] - request.tx, b[1] - request.ty)}\n # this node is now logged as checked\n request.closed[key[0], key[1]] = request.open[key]\n # remove this node from the pending array\n request.open.delete(key)\n # iterate through all possible directions with relative offsets\n Cache::PathDirs.each {|dir|\n # coordinates of new position\n kx, ky = key[0] + dir[0], key[1] + dir[1]\n # if new coordinates are destination\n if kx == request.tx && ky == request.ty\n # the new node was checked\n request.closed[kx, ky] = dir[2]\n # path was found\n found = true\n # stop checking\n break\n # if new node not checked yet and coordinates are passable\n elsif request.closed[kx, ky] == 0 &&\n char.passable?(key[0] * pix, key[1] * pix, dir[2])\n # add new node to be checked\n request.open[[kx, ky]] = dir[2]\n end}\n # stop execution except if found path\n return nil unless found\n # backtrack the path\n result = request.backtrack\n # finish testing for this character\n @request.delete(char)\n # resets state\n char.ai.state = (char.ai.state == Invalid ? Return : Ready)\n # return movement command array\n return result\n end",
"def find_path()\n visited = Array.new(8) {Array.new(8)}\n return [] if @destination == @currentPosition\n paths = [[@currentPosition]]\n visited[@currentPosition[0]][@currentPosition[1]] = true\n\n until paths.empty?\n new_paths = []\n paths.each do |path|\n next_positions = possibleMoves(path.last, visited)\n next_positions.each do |move|\n newpath = path.dup << move\n if move == @destination #if we reached our destination stop and return the path\n return newpath\n end\n visited[move[0]][move[1]] = true\n new_paths.push(newpath)\n end\n end\n paths = new_paths\n end\n end",
"def pathfind begTile, endTile\n @traveled_tiles = [begTile]\n @current_tiles = [begTile]\n @next_tiles = Array.new\n #iterate through the maze one movement at a time, hard stop when all tiles have been exhausted\n while (!@current_tiles.include? endTile) && @traveled_tiles.length < @maze.size\n @current_tiles.each do |tile|\n (get_adjacent_floors tile).each do |next_tile|\n #makes sure no tiles are double counted, the first to hit will always be the shortest\n if (next_tile.is_floor) && (!@next_tiles.include? next_tile) && (!@traveled_tiles.include? next_tile)\n @next_tiles.push next_tile\n next_tile.previous_tile tile\n end\n end\n end\n @traveled_tiles.concat @next_tiles\n @current_tiles = @next_tiles.dup\n @next_tiles.clear\n end\n endTile.get_path\n end",
"def getStationNearest\n coordinate_lat = params[:lattitude].to_f\n coordinate_lng = params[:longtitude].to_f\n distance_input = params[:distance].to_f\n end",
"def shortest_paths(source, dest)\n\t\t\t@source = source\n\t\t\tdijkstra source\n\t\t\tprint_path dest\n\t\t\treturn @distance[dest]\n\t\tend",
"def proximity_to_star(x, y)\n distance_x = (state.star.x - x).abs\n distance_y = (state.star.y - y).abs\n\n if distance_x > distance_y\n return distance_x\n else\n return distance_y\n end\n end",
"def djikstra(world, from_x, from_y, to_x, to_y)\n key = [world.join, from_x, from_y].join(',')\n cached_prev = DJ_GRAPH_MEMO[key]\n\n prev = cached_prev\n\n unless cached_prev\n nodes = map_each_cell(world) {|cell, x, y| cell == '.' ? [x, y] : nil }.\n flatten(1).\n reject(&:nil?)\n\n source = [from_x, from_y]\n dist = Hash[nodes.zip([INFINITY].cycle)]\n queue = nodes.dup\n queue.push(source) unless queue.include?(source)\n dist[source] = 0\n prev = {}\n\n while !queue.empty?\n queue.sort_by! {|node| dist[node]}\n u = queue.shift\n\n neighbors = DIRECTIONS.values.map {|d| [u[0] + d[:x], u[1] + d[:y]] }\n neighbors = neighbors & nodes\n\n neighbors.each do |v|\n alt = dist[u] + 1\n\n if alt < dist[v]\n dist[v] = alt\n prev[v] = u\n end\n end\n end\n\n DJ_GRAPH_MEMO[key] ||= prev\n end\n\n path = []\n target = [to_x, to_y]\n\n return [source] if target == source\n\n # cannot reach target:\n return nil if prev[target].nil?\n\n while target\n path.push(target)\n target = prev[target]\n end\n\n path = path.reverse\n path\nend",
"def shortest_degrees_of_separation(entity)\n @@neo = Neography::Rest.new\n self_node = self.get_node\n entity_node = entity.get_node\n if self_node && entity_node\n paths = []\n self_node.shortest_path_to(entity_node).incoming(:friends).depth(5).nodes.each do |path|\n # path << node.object_type.safe_constantize.find(node[\"object_id\"])\n in_between = path.map{|n| begin n.object_type.safe_constantize.find(n[:object_id]).id rescue Exception end }\n path = {length: path.size-1, users: in_between}\n paths << path\n # puts \"#{(path.size - 1)} degrees: \" + path.map{|n| begin n.object_type.safe_constantize.find(n[:object_id]).name rescue Exception end }.join(\" => friends =>\") \n end\n paths\n end\n end",
"def solver(flights)\n (p all_paths(flights)).min_by { |path| cost_of_path(path) }\nend",
"def point_on_path(t)\n coord = getPointOnPath(view_path_coordinates[\"LonLat\"], average_speed, t)\n if !isOnRoute(coord, 60)\n raise \"Not on Route\"\n end\n coord\n end",
"def guide(from, to, unit_type=nil, max_depth=400)\n return nil if @map.blocked?(from, unit_type) || @map.blocked?(to, unit_type)\n from_element = PathElement.new(from)\n from_element.dist_from = @map.distance(from,to)\n open = PrioritySet.new\n open.push from_element, from_element.rating\n closed = SplayTreeMap.new\n step = 0\n\n until open.empty? || step > max_depth\n step += 1\n\n current_element = open.pop\n @nodes_considered += 1\n\n loc = current_element.location\n if @map.cost(loc,to) == 0\n path = []\n until current_element.parent.nil?\n path.unshift current_element\n current_element = current_element.parent\n end\n\n return path\n else\n closed.push loc, current_element\n @map.neighbors(loc).each do |next_door|\n if closed.has_key? next_door\n next\n end\n \n el = PathElement.new(next_door,current_element)\n\n if @map.blocked? next_door, unit_type\n closed.push el.location, el\n else\n current_rating = current_element.cost_to + @map.cost(loc, next_door)\n\n # add to open\n el.cost_to = current_rating\n el.dist_from = @map.distance(next_door,to)\n el.reset_rating\n\n open.push el, el.rating\n end\n end\n end\n end\n nil\n end",
"def shortest_distance_to(node)\n @distances[node]\n end",
"def bfs_shortest_path(node1, node2)\n distance, route = breadth_first_search(node1)\n step = distance[node2]\n node = node2\n path = [ node2 ]\n while node != node1 and route[node]\n node = route[node]\n path.unshift(node)\n end\n return step, path\n end",
"def shortest_paths(source, dest)\n @graph_paths=[]\n @source = source\n dijkstra source\n @path=[]\n find_path dest\n actual_distance=if @distance[dest] != INFINITY\n @distance[dest]\n else\n \"no path\"\n end\n \"Shortest route and distance : #{@path.join(\"-->\")}, #{actual_distance} km\"\n end",
"def get_path(start, finish) \n @retreat_algorithm.set_graph(memory.construct_grid) \n @retreat_algorithm.run(start, finish)\n end",
"def find_shortest_path(rolling_node)\n\n @backtrack = []\n @backtrack << @goal_node\n\n # iterate until we arrive at the start node\n while rolling_node[:prev] != nil do\n temp_node = @node_list.find { |hash| hash[:id] == rolling_node[:prev] }\n @backtrack << temp_node[:id]\n rolling_node = temp_node\n end\n\n # create a table with the 1d and the 2d array node values\n @shortest_path = []\n\n @backtrack.each do |p|\n @shortest_path << [p, @table_convert[p]]\n @shortest_path_coords << @table_convert[p][1]\n end\n end",
"def Knight_long_path(position, target)\n possible_moves = []\n moves = ['move_down', 'move_up', 'move_right', 'move_left']\n chessercise = Chessercise.new\n for i in moves do\n for j in moves do\n now = getposition(position)\n if i != j\n if @directions_flag[i.to_sym] != @directions_flag[j.to_sym]\n if chessercise.send(i.to_sym, now) != nil\n mv_now = chessercise.send(i.to_sym, now)\n now = getposition(mv_now)\n if chessercise.send(j.to_sym, now) != nil\n mv_now = chessercise.send(j.to_sym, now)\n now = getposition(mv_now)\n if chessercise.send(j.to_sym, now) != nil\n mv_now = chessercise.send(j.to_sym, now)\n possible_moves.push(mv_now)\n end\n end\n end\n end\n end\n end\n end\n return possible_moves\n # print Knight_long_path('d2')\n end",
"def next_step_from(paths)\n paths.map do |path|\n possible_neighbours(path.most_recent_step.coordinate, @max_x, @max_y) \n .map { |c| coord_to_step_on_path(c, path) }\n .reject { |p| p == nil }\n end\n .flatten\n end",
"def shortest_path_to(node)\n return nil if @previous_nodes[node].nil?\n\n nodes = [node]\n while previous_node = @previous_nodes[nodes[0]] do\n nodes.unshift(previous_node)\n end\n\n nodes\n end",
"def main(points) # array with all the points\n #copy of the array by an especific cordinate\n #nlogn\n # This is a primitive, aka operations that are costless compared to the\n # total complexity we are aming for\n px = sort_by_cordinate(points, 0)\n py = sort_by_cordinate(points, 1)\n\n result = closest_pair(px, py)\nend",
"def mark_optimal_path_with(pos)\n if self[*pos] == 1\n self[*pos] = \"X\"\n return nil \n end\n \n next_step = neighbors(*pos).select do |step| \n self[*step] != \"X\" && self[*step] == (self[*pos] - 1) \n end[0]\n\n self[*pos] = \"X\"\n mark_optimal_path_with next_step \n \n end",
"def find_closest_points(reference_point, geometric_resolution)\n do_find_closest_points(reference_point.to_a, geometric_resolution)\n end",
"def find_path(start, target)\n node = build_path(start, target)\n path = [node]\n until node.next_node.nil? do\n node = node.next_node\n path.push(node)\n end\n path = path.reverse\n puts \"You made it in #{path.length} moves. Here is your path: \"\n path.each do |node|\n puts \"[#{node.x}], [#{node.y}]\"\n end\nend",
"def shortest_path\n dist, previous = Hash.new(Infinity), {}\n dist[@source] = 0.0\n queue = @graph.vertex_set.dup\n\n until queue.empty?\n u = queue.min { |a,b| dist[a.name] <=> dist[b.name] }\n break if dist[u.name].infinite?\n queue.delete(u)\n\n u.each_edge do |e, v|\n alt = dist[u.name] + e.weight\n if alt < dist[v.name]\n dist[v.name] = alt\n previous[v.name] = u.name\n end\n end\n end\n\n path = []\n u = @dest\n until previous[u].nil?\n path.unshift(u)\n u = previous[u]\n end\n\n path.unshift(@source)\n end",
"def closest_floor(x, y)\n # create mark table and pending array\n table, pending = Table.new($game_map.width, $game_map.height), [[x, y]]\n # as long as there are pending coordinates\n while pending.size > 0\n # current coordinates\n cx, cy = pending.shift\n # if floor beneath\n if !Config::NO_FLOOR_TAGS.include?($game_map.terrain_tag(cx, cy))\n # return found coordinates\n return [cx, cy]\n end\n # mark current coordinates as checked\n table[cx, cy] = 1\n # add tiles around current coordinates if they were not marked yet\n pending.push([cx, cy+1]) if table[cx, cy+1] == 0\n pending.push([cx-1, cy]) if table[cx-1, cy] == 0\n pending.push([cx+1, cy]) if table[cx+1, cy] == 0\n pending.push([cx, cy-1]) if table[cx, cy-1] == 0\n end\n return [x, y]\n end",
"def is_nearby?(user_lat, user_long, bus_lat, bus_long)\n Math.hypot((user_lat - bus_lat), (user_long - bus_long)) <= .01\n end",
"def get_path(s, e, maze)\n if maze[s[0]][s[1]] == 1 || # found a wall or visited area\n s[0] < 0 || s[1] < 0 || # top or left edge\n s[0] >= maze.length || s[1] >= maze[0].length # bottom or right edge\n\n path = nil\n\n elsif s[0] == e[0] && s[1] == e[1] # exit spot\n\n path = [s]\n\n else\n\n maze[s[0]][s[1]] = 1 # visit current node\n path =\n get_path([s[0] - 1, s[1]], e, maze) ||\n get_path([s[0], s[1] + 1], e, maze) ||\n get_path([s[0], s[1] - 1], e, maze) ||\n get_path([s[0] + 1, s[1]], e, maze)\n\n path << s unless path.nil?\n\n end\n \n return path\nend",
"def path(x, y)\r\n\t\t# If x or y are on the edge, meaning they have only one path, return 1\r\n\t\tif (x == 0 || y == 0)\r\n\t\t\treturn 1\r\n\t\r\n\t\t# If in the middle of the square, check to see if sum of paths for node already calculated?\r\n\t\telse\r\n\t\t\t# If so, return calculated sum of paths for node\r\n\t\t\tif @node[x][y] != 0\r\n\t\t\t\treturn @node[x][y]\r\n\t\t\t\t\r\n\t\t\t# Otherwise, set node[x][y] to sum of paths for connected nodes through recursion\r\n\t\t\t# Return newly calculated node[x][y]\r\n\t\t\telse\r\n\t\t\t\t@node[x][y] = path(x-1, y) + path(x, y-1)\r\n\t\t\t\treturn @node[x][y]\r\n\t\t\tend\r\n\t\tend\t\r\n\tend",
"def greedy_salesman (cities)\n path = []\n not_visited = cities\n path.push(not_visited.shift)\n loop do\n current = path.last\n # for testing, only prints if PRINT_STEPS is set to true at the top of the file\n puts \"current: \" + current.name + \" (\" + current.x.round(2).to_s + \",\" + current.y.round(2).to_s + \")\" if PRINT_STEPS\n next_city = nearest_possible_neighbor(current,not_visited)\n path.push(not_visited.delete(next_city))\n break if not_visited.empty?\n end\n path\nend",
"def test_shortest_path\n expected = Amazeingly::Path.new([\n { step_number: 1, room: @rooms_collection.find(6), collected_objects: [] },\n { step_number: 2, room: @rooms_collection.find(5), collected_objects: [] },\n { step_number: 3, room: @rooms_collection.find(7), collected_objects: [] },\n { step_number: 4, room: @rooms_collection.find(4), collected_objects: [] }\n ])\n\n assert_equal expected, @path_finder.shortest_path(from_room: @rooms_collection.find(6), to_room: @rooms_collection.find(4))\n end",
"def get_closest_edge_vertices(lat, lon)\n #Override this function in the corresponding extension (tiger and osm initially)\n return nil\n end",
"def shortest_path(start, finish)\n queue << [start, 0]\n loop do\n break if queue.empty?\n vertex, d = queue.pop\n graph[*vertex] = d\n break if vertex == finish\n enqueue_neighbours(*vertex, d + 1)\n end\n queue.clear\n !blank?(finish) ? build_path(start, finish) : []\n end",
"def is_nearby?(user_lat, user_long, bus_lat, bus_long)\n\n# max distance is about 0.6 miles away 0.01 degrees\n\nmax_distance = 0.01\n\ndifference_latitudes = user_lat - bus_lat.to_f\ndifference_longitudes = user_long - bus_long.to_f\n\ndistance = Math.sqrt(difference_latitudes ** 2 + difference_longitudes ** 2)\n\ndistance <= max_distance\n\nend",
"def closest_arrow_and_tile(row, x, y)\n all_coord = []\n\n @game_board.board[row].each do |tile|\n all_coord << tile.center_top\n all_coord << tile.center_bottom\n all_coord << tile.center_right\n all_coord << tile.center_left\n end\n\n closest_arrow = all_coord.inject do |sum, value|\n distance_sum = Gosu::distance(x, y, sum[0], sum[1])\n distance_val = Gosu::distance(x, y, value[0], value[1])\n distance_sum < distance_val ? sum : value\n end\n\n column = find_col_in_row(all_coord, closest_arrow)\n\n tile = @game_board.board[row][column]\n tile_position = [row, column]\n [tile, closest_arrow, tile_position]\n end",
"def compute_path(source_x, source_y, destination_x, destination_y)\n build_structures(source_x, source_y)\n path([destination_x, destination_y])\n backtrace(source_x, source_y, destination_x, destination_y)\n end",
"def nearby\n if current_user.lat\n dist = 1.5\n minlat = current_user.lat - dist\n maxlat = current_user.lat + dist\n minlon = current_user.lon - dist\n maxlon = current_user.lon + dist\n @users = DrupalUsers.find(:all, :conditions => [\"lat != 0.0 AND lon != 0.0 AND lat > ? AND lat < ? AND lon > ? AND lon < ?\",minlat,maxlat,minlon,maxlon])\n end\n end",
"def min_path(triangle)\n min_path_helper(triangle, level = triangle.size - 1)\nend",
"def closest_to(*args)\n if args.length == 1\n if args.first.respond_to?(:distance_to)\n closest_to_coordinates(args.first)\n elsif %w(first last).all? { |m| args.first.respond_to?(m) }\n closest_to_lat_lng(args.first)\n else\n raise ArgumentError, \"expected two-element Array or GeoKit::LatLng\"\n end\n elsif args.length == 2\n closest_to_lat_lng(args)\n else\n raise ArgumentError, \"closest_to() will accept one Array argument, one GeoKit::LatLng argument, or two FixNum arguments\"\n end\n end",
"def closest(num = 8)\n opts = {\n order: {\n _geo_distance: {\n 'location' => \"#{latitude},#{longitude}\",\n 'order' => 'asc',\n 'unit' => 'mi'\n }\n },\n limit: num,\n where: {\n id: { not: id }\n }\n }\n Location.search('*', opts).results\n end",
"def astar_search(origin:, target:)\n costs = {}\n seen = {}\n path = {}\n initial_estimate = heuristic(current: origin, target: target)\n costs[origin] = 0\n\n pq = PriorityQueue.new\n\n pq.push(origin, initial_estimate)\n\n loop do\n current = pq.delete_min_return_key\n\n # made it\n return path if current == target\n\n seen[current] = true\n\n # get moves and estimate costs\n moves(current).each do |move|\n move_pair = move[0]\n cost = move[1]\n\n next if seen[move_pair]\n\n new_cost = costs[current] + cost\n\n # skip if more costly\n next if pq.has_key?(move_pair) && !costs[move_pair].nil? && new_cost >= costs[move_pair]\n\n path[move_pair] = current\n costs[move_pair] = new_cost\n estimate = new_cost + heuristic(current: move_pair, target: target)\n\n if pq.has_key?(move_pair)\n pq.change_priority(move_pair, estimate)\n else\n pq.push(move_pair, estimate)\n end\n end\n end\nend",
"def belongsToWhichPostcode lat, lon\n\tsmallestPostcode = Postcode\n\tsmallestDist = 9999999999999999999.0\n\t#we want to look at all post codes & find closest\n\tPosition.all.each do |pos|\n\t\tif pos.postcodes.last\n\t\t\tcurrentDist = Math.sqrt( ((pos.latitude.to_f - lat).abs)**2 + ((pos.longitude.to_f - lon).abs)**2 )\n\t\t\tif(currentDist < smallestDist)\n\t\t\t\tsmallestDist = currentDist\n\t\t\t\tsmallestPostcode = pos.postcodes\n\t\t\tend\n\t\tend\n\tend\n\t#return the last postcode that was made for that position\n\tsmallestPostcode.last\nend",
"def get_walk_path(goalx, goaly)\n current_track_address = hash_address(goalx,goaly)\n path = []\n path_address = []\n go_dir = []\n path.push(current_track_address)\n \n while @nodes_parent_id[current_track_address]\n path.unshift( @nodes_parent_id[current_track_address] )\n go_dir.unshift( @move_dir[current_track_address] )\n \n current_track_address = @nodes_parent_id[current_track_address]\n break if current_track_address == @nodes_parent_id[current_track_address]\n end\n \n path.each do |hash_value|\n _address = dehash_address(hash_value)\n path_address.push( Map_Address.new( _address[0], _address[1]) )\n end\n \n return get_route_command(path_address,go_dir)\n end",
"def shortest_path_to(dest_node)\n return unless has_path_to?(dest_node)\n path = []\n while (dest_node != @node) do\n path.unshift(dest_node)\n dest_node = @edge_to[dest_node]\n end\n path.unshift(@node)\n end",
"def find_path(paths = [[@position]])\n if not @path and finished?(paths)\n return @path\n else\n new_paths = []\n change = false\n paths.each do |path|\n possible_positions?(path).each do |position|\n new_paths << path.dup.push(position)\n change = true\n end\n end\n find_path(new_paths) if change\n end\n end"
] |
[
"0.7033883",
"0.6896861",
"0.68080926",
"0.66212493",
"0.6564974",
"0.65628564",
"0.65618485",
"0.64153",
"0.64108837",
"0.63817585",
"0.6262553",
"0.6261021",
"0.6248313",
"0.6236319",
"0.6222654",
"0.6213536",
"0.6202141",
"0.62017614",
"0.6198533",
"0.61870044",
"0.61563694",
"0.6155213",
"0.6097473",
"0.60827667",
"0.6058258",
"0.60287523",
"0.60146004",
"0.59827566",
"0.598093",
"0.596231",
"0.5942215",
"0.5932557",
"0.59294486",
"0.5911993",
"0.5893254",
"0.58826345",
"0.58799434",
"0.58776426",
"0.58722067",
"0.58586633",
"0.583025",
"0.5822673",
"0.58149284",
"0.580996",
"0.5794611",
"0.5792238",
"0.57808083",
"0.5775134",
"0.57628316",
"0.57611084",
"0.5751431",
"0.57488436",
"0.574067",
"0.57359177",
"0.57172704",
"0.5713291",
"0.5709312",
"0.5707086",
"0.5692573",
"0.56911767",
"0.5685067",
"0.5684549",
"0.5673075",
"0.5669473",
"0.5664412",
"0.56480986",
"0.5644829",
"0.5621036",
"0.5617028",
"0.5611182",
"0.5610464",
"0.5597009",
"0.55956197",
"0.55933535",
"0.55930454",
"0.5590591",
"0.5589699",
"0.5587761",
"0.5587068",
"0.55785185",
"0.5578324",
"0.55642325",
"0.5563788",
"0.55515563",
"0.5540853",
"0.5529712",
"0.55281276",
"0.55205125",
"0.55185395",
"0.5507583",
"0.55049825",
"0.54983556",
"0.5494981",
"0.5492517",
"0.54903185",
"0.54888386",
"0.54783076",
"0.54707235",
"0.5462566",
"0.5456923"
] |
0.7334569
|
0
|
Find the nearest driver from given coordinate It will return a hash about the nearest driver coordinate, driver object, and the shortest route to the driver
|
def nearest_driver(coord_from)
queue = Queue.new
queue << [coord_from]
seen = Set.new([coord_from])
while queue
begin
path = queue.pop(non_block = true)
rescue ThreadError
return nil
end
x, y = path[-1]
if @map[y][x].instance_of?(Driver) && [x, y] != coord_from
return { "coord" => [x, y], "route" => path, "object" => @map[y][x] }
end
for x2, y2 in [[x + 1, y], [x - 1, y], [x, y + 1], [x, y - 1]]
if (0 <= x2 && x2 < @map[0].length) && (0 <= y2 && y2 < @map.length) && (@map[y2][x2] != @WALL && @map[y2][x2] != @PERMANENT_WALL) && !seen.include?([x2, y2])
queue << (path + [[x2, y2]])
seen.add([x2, y2])
end
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def nearest_driver(map,user)\n driver_pos=[]\n\n for i in 0..map.length-1\n for j in 0..map.length-1\n if map[i][j] == \" D \"\n driver_pos << [i,j]\n end\n end\n end\n @driver_pos=driver_pos\n\n nearest_driver_position = driver_pos[0]\n distance = driver_pos[0].zip(user).map { |x| x.reduce(:-).abs }.sum\n\n for i in 1..driver_pos.length-1\n temp = driver_pos[i].zip(user).map { |x| x.reduce(:-).abs }.sum\n if temp < distance\n distance = temp\n nearest_driver_position = driver_pos[i]\n end\n end\n nearest_driver_position\n end",
"def findnearest( coords, targetx, targety )\n # find nearest coordinate\n nearest = 0\n targetcounter = 0\n target = -1\n coords.each do |neighborx,neighbory|\n d = Math::sqrt( ( neighborx - targetx ) ** 2 + ( neighbory - targety ) ** 2 )\n if d < 0.2\n target = targetcounter\n end\n targetcounter += 1\n end\n return target\nend",
"def search\n\t\tmin = 2**30 - 2 \t\t\t#maximum for 32-bit\n\t\ttest = 0\n\t\t@arr_driver.each do |driver|\n\t\t\ttest = (driver.x - user.x)**2 + (driver.y - user.y)**2\n\t\t\ttest = Math.sqrt(test)\n\t\t\tif (test<min)\n\t\t\t\tmin = test\n\t\t\t\t@assigned_driver = driver\n\t\t\tend\n\t\tend\n\tend",
"def find_best_way(xx,yy)\n pf = Pathfinder.new($map)\n pf.ignore_obs_target = true # permit to calculate a path to a case with an ennemy on it\n path = pf.find([x,y],[xx,yy])\n end",
"def nearest_driver_name(pos)\n a = @driver_pos.find_index(pos)\n @driver_name[a]\n end",
"def closest_neighbors(num_neighbors, point, data)\n data.keys.sort { |a,b| euclidean_distance(a, point) <=> euclidean_distance(b, point) }.take(num_neighbors)\nend",
"def grab_nearest_by_location(distance, loc)\n\n end",
"def find_closest\n find_target_coordinates\n location = build_query.geo_near(@target_cord).first\n\n return nil if location.nil?\n [(location.phone_numbers & customer_numbers).first, location.geo_name]\n end",
"def find_nearest(key)\n node_value(find_nearest_node(key))\n end",
"def find_nearest(key)\n node_value(find_nearest_node(key))\n end",
"def find_nearest_node(key) #:nodoc:\n x = anchor\n level = node_level(x)\n while level > 0\n level -= 1\n xnext = node_next(x, level)\n while node_compare(xnext, key) <= 0\n x = xnext\n xnext = node_next(x, level)\n end\n end\n x\n end",
"def main(points) # array with all the points\n #copy of the array by an especific cordinate\n #nlogn\n # This is a primitive, aka operations that are costless compared to the\n # total complexity we are aming for\n px = sort_by_cordinate(points, 0)\n py = sort_by_cordinate(points, 1)\n\n result = closest_pair(px, py)\nend",
"def find_nearest_node(key) #:nodoc:\n x = node_first\n level = node_level(x)\n while level > 0\n level -= 1\n xnext = node_next(x, level)\n while node_compare(xnext, key) <= 0\n x = xnext\n xnext = node_next(x, level)\n end\n end\n x\n end",
"def find_cell(coordinate)\n storage.select do |cell|\n cell.coord_x == coordinate[0] && cell.coord_y == coordinate[1]\n end.first\n end",
"def nearby_location(dist)\n data = Location.all\n nearby_wifi = data.select { |spot| self.distance_to([spot.latitude,spot.longitude]) <= dist }\n sort_nearby_wifi = nearby_wifi.sort_by { |close| self.distance_to([close.latitude, close.longitude]) }\n end",
"def find_path_brute_force( board, start_point )\n options = get_options( start_point, board )\n\n # Bottom right corner\n if options.length == 0\n return { points: [start_point], best_value: get_value( start_point, board ) }\n end\n\n # If there's only one option, this works fine still.\n first_result = find_path_brute_force( board, options.first )\n second_result = find_path_brute_force( board, options.last )\n if first_result[:best_value] > second_result[:best_value]\n return {\n points: [start_point] + first_result[:points],\n best_value: first_result[:best_value] + get_value( start_point, board )\n }\n else\n return {\n points: [start_point] + second_result[:points],\n best_value: second_result[:best_value] + get_value( start_point, board )\n }\n end\nend",
"def _closest_pair(px, py)\n nx, ny = px.length, py.length\n return [px[0], py[0]] if nx == 1 and ny == 1\n return best([px[0], px[1]], [py[0], py[1]]) if nx == 2 and ny == 2\n qx, rx, qy, ry = px[0...nx/2], px[nx/2...nx], py[0...ny/2], py[ny/2...ny]\n qpair = _closest_pair(qx, qy)\n rpair = _closest_pair(rx, ry)\n min_dist = [distance(qpair[0], qpair[1]), distance(rpair[0], rpair[1])].min\n split_pair = closest_split_pair(px, py, min_dist)\n best(qpair, rpair, split_pair)\nend",
"def delete_driver(driver_coord)\n @drivers.delete_if do |driver|\n driver[\"coord\"] == driver_coord\n end\n x, y = driver_coord\n @map[y][x] = @FLOOR\n end",
"def get_closest_node(id, num = 1)\n @link_table.closest_peers(id, num)\n end",
"def nearest(coords, code, n=5)\n with_distance = find(code).map { |pos| [pos, (pos[0] - coords[0]).abs + (pos[1] - coords[1]).abs + (pos[2] - coords[2]).abs ] }\n return with_distance.sort_by { |pos, dist| dist }[0..n]\n end",
"def select_possible_path(possible_paths)\n vertex, data = possible_paths.min_by do |vertex, data|\n data[:cost]\n end\n vertex\nend",
"def nearest_mine\n src = @pos\n shortest_dst = 63\n nearest = [0,0]\n unowned_mines = @game.mines_locs.reject { |pos, hero_id| hero_id == @hero_id }\n unowned_mines.each do |pos, hero_id|\n build_branching_paths(src, pos)\n path = find_path(pos)\n if path.length < shortest_dst\n shortest_dst = path.length\n nearest = pos\n end\n end\n nearest\n end",
"def astar_search(origin:, target:)\n costs = {}\n seen = {}\n path = {}\n initial_estimate = heuristic(current: origin, target: target)\n costs[origin] = 0\n\n pq = PriorityQueue.new\n\n pq.push(origin, initial_estimate)\n\n loop do\n current = pq.delete_min_return_key\n\n # made it\n return path if current == target\n\n seen[current] = true\n\n # get moves and estimate costs\n moves(current).each do |move|\n move_pair = move[0]\n cost = move[1]\n\n next if seen[move_pair]\n\n new_cost = costs[current] + cost\n\n # skip if more costly\n next if pq.has_key?(move_pair) && !costs[move_pair].nil? && new_cost >= costs[move_pair]\n\n path[move_pair] = current\n costs[move_pair] = new_cost\n estimate = new_cost + heuristic(current: move_pair, target: target)\n\n if pq.has_key?(move_pair)\n pq.change_priority(move_pair, estimate)\n else\n pq.push(move_pair, estimate)\n end\n end\n end\nend",
"def belongsToWhichPostcode lat, lon\n\tsmallestPostcode = Postcode\n\tsmallestDist = 9999999999999999999.0\n\t#we want to look at all post codes & find closest\n\tPosition.all.each do |pos|\n\t\tif pos.postcodes.last\n\t\t\tcurrentDist = Math.sqrt( ((pos.latitude.to_f - lat).abs)**2 + ((pos.longitude.to_f - lon).abs)**2 )\n\t\t\tif(currentDist < smallestDist)\n\t\t\t\tsmallestDist = currentDist\n\t\t\t\tsmallestPostcode = pos.postcodes\n\t\t\tend\n\t\tend\n\tend\n\t#return the last postcode that was made for that position\n\tsmallestPostcode.last\nend",
"def lookup_by_coords(x, y)\n diameter = Cfg.galaxy_zone_diameter\n lookup(\n (x.to_f / diameter).floor,\n (y.to_f / diameter).floor\n )\n end",
"def find_path(source, target, map)\n @main_loop_count = 0\n\n max_y = map.size - 1\n max_x = map[0].size - 1\n target_x = target[0]\n target_y = target[1]\n # target heuristic is 0\n target = [target_x, target_y, 0]\n\n # Sets up the search to begin from the source\n source = source.dup.push((target_x - source[0]).abs + (target_y - source[1]).abs)\n came_from = {}\n came_from[source] = nil\n frontier = [source]\n\n # Until the target is found or there are no more cells to explore from\n until came_from.has_key?(target) || frontier.empty?\n @main_loop_count += 1\n\n # Take the next frontier cell\n new_frontier = frontier.shift\n\n # Find the adjacent neighbors\n adjacent_neighbors = []\n\n # Gets all the valid adjacent_neighbors into the array\n # From southern neighbor, clockwise\n nfx = new_frontier[0]\n nfy = new_frontier[1]\n adjacent_neighbors << [nfx , nfy - 1, (target_x - nfx).abs + (target_y - nfy + 1).abs] unless nfy == 0\n adjacent_neighbors << [nfx - 1, nfy - 1, (target_x - nfx + 1).abs + (target_y - nfy + 1).abs] unless nfx == 0 || nfy == 0\n adjacent_neighbors << [nfx - 1, nfy , (target_x - nfx + 1).abs + (target_y - nfy).abs] unless nfx == 0\n adjacent_neighbors << [nfx - 1, nfy + 1, (target_x - nfx + 1).abs + (target_y - nfy - 1).abs] unless nfx == 0 || nfy == max_y\n adjacent_neighbors << [nfx , nfy + 1, (target_x - nfx).abs + (target_y - nfy - 1).abs] unless nfy == max_y\n adjacent_neighbors << [nfx + 1, nfy + 1, (target_x - nfx - 1).abs + (target_y - nfy - 1).abs] unless nfx == max_x || nfy == max_y\n adjacent_neighbors << [nfx + 1, nfy , (target_x - nfx - 1).abs + (target_y - nfy).abs] unless nfx == max_x\n adjacent_neighbors << [nfx + 1, nfy - 1, (target_x - nfx - 1).abs + (target_y - nfy + 1).abs] unless nfx == max_x || nfy == 0\n\n new_neighbors = adjacent_neighbors.select do |neighbor|\n # That have not been visited and are not walls\n unless came_from.has_key?(neighbor) || map[neighbor[1]][neighbor[0]] != '.'\n # Add them to the frontier and mark them as visited\n # frontier << neighbor\n came_from[neighbor] = new_frontier\n end\n end\n\n # Sort the frontier so cells that are close to the target are then prioritized\n if new_neighbors.length > 0\n new_neighbors = merge_sort(new_neighbors)\n if frontier.length > 0 && new_neighbors[0][2] >= frontier[0][2]\n frontier = merge_sort(new_neighbors.concat(frontier))\n else\n frontier = new_neighbors.concat(frontier)\n end\n end\n end\n\n # If the search found the target\n if came_from.has_key?(target)\n # Calculates the path between the target and star for the greedy search\n # Only called when the greedy search finds the target\n path = []\n next_endpoint = came_from[target]\n while next_endpoint\n path << [next_endpoint[0], next_endpoint[1]]\n next_endpoint = came_from[next_endpoint]\n end\n path\n else\n return nil\n end\n end",
"def find_nearest_place_id max_dist\n\t#byebug\n\tphot=self.class.find(@id) #returns instance of photo\n\tphot_loc=phot.location #gets location from photo (point where photo was taken)\n\tphot_place=Place.near(phot_loc,max_dist).projection(:_id=>1).first #find closest place to point\n\tphot_place.nil? ? nil : phot_place[:_id] #return the id of the closest place to that point\nend",
"def find_closest(vertex)\n closest = @vertices.first\n closest_distance = Vertex.euclidean_distance(vertex, closest)\n @vertices.each do |v|\n distance = Vertex.euclidean_distance(vertex, v)\n if distance < closest_distance\n closest_distance = distance\n closest = v\n end\n end\n return closest\n end",
"def find_one_closest_point(reference_point, guess, geometric_resolution)\n do_find_one_closest_point(reference_point.to_a, guess, geometric_resolution)\n end",
"def proximity_to_star(x, y)\n distance_x = (grid.star.x - x).abs\n distance_y = (grid.star.y - y).abs\n\n if distance_x > distance_y\n return distance_x\n else\n return distance_y\n end\n end",
"def find_closest_points(reference_point, geometric_resolution)\n do_find_closest_points(reference_point.to_a, geometric_resolution)\n end",
"def shortest_path(start_coord, destination_coord)\n queue = Queue.new\n queue << [start_coord]\n seen = Set.new([start_coord])\n while queue\n begin\n path = queue.pop(non_block = true)\n rescue ThreadError\n return nil\n end\n x, y = path[-1]\n if [x, y] == destination_coord\n return path\n end\n for x2, y2 in [[x + 1, y], [x - 1, y], [x, y + 1], [x, y - 1]]\n if (0 <= x2 && x2 < @map[0].length) && (0 <= y2 && y2 < @map.length) && (@map[y2][x2] != @WALL && @map[y2][x2] != @PERMANENT_WALL) && !seen.include?([x2, y2])\n queue << (path + [[x2, y2]])\n seen.add([x2, y2])\n end\n end\n end\n end",
"def nearestLocationWithDubbing _args\n \"nearestLocationWithDubbing _args;\" \n end",
"def closest(num = 8)\n opts = {\n order: {\n _geo_distance: {\n 'location' => \"#{latitude},#{longitude}\",\n 'order' => 'asc',\n 'unit' => 'mi'\n }\n },\n limit: num,\n where: {\n id: { not: id }\n }\n }\n Location.search('*', opts).results\n end",
"def closest_pair vector_array\n\tby_x = vector_array.sort_by { |e| e.x }\n\tby_y = vector_array.sort_by { |e| e.y }\n\n\tarray, best = recursive_split by_x\n\tp \"Da #{best.distance}\"\nend",
"def agents_nearest(coord, count)\n living_agents.sort_by{ |a| coord.vector_to(a.tank).length }[0...count]\n end",
"def unique_distance_to_point?\n # ALL_POINTS.sort_by { |obj| obj.distance_to_main }.first\n @distances = ALL_POINTS.map(&:distance_to_main)\n @sorted_distances = @distances.sort\n @closest = @sorted_distances.first\n @distances.one?(@closest)\nend",
"def nearest_hex( hex_array )\n nearest_hex = nil\n current_distance = nil\n hex_array.each do |h|\n if nearest_hex\n dist = distance( h )\n if distance( h ) < current_distance\n nearest_hex = h\n current_distance = dist\n end\n else\n nearest_hex = h\n current_distance = distance( h )\n end\n end\n nearest_hex\n end",
"def nearest_hex( hex_array )\n nearest_hex = nil\n current_distance = nil\n hex_array.each do |h|\n if nearest_hex\n dist = distance( h )\n if distance( h ) < current_distance\n nearest_hex = h\n current_distance = dist\n end\n else\n nearest_hex = h\n current_distance = distance( h )\n end\n end\n nearest_hex\n end",
"def nearest_fortress_exit_point(point)\n nearest_fortress_exit_cell = nil\n nearest_distance = MAX_DISTANCE\n fortress_exit_cells.each do |exit_cell|\n distance = Tools.calc_distance(point, exit_cell)\n if distance < nearest_distance\n nearest_distance = distance\n nearest_fortress_exit_cell = exit_cell\n end\n end\n return Point.new(nearest_fortress_exit_cell.x, nearest_fortress_exit_cell.y)\n end",
"def shortest_path\n pa = AI::AStarAlgorithm.new($map.grid, $map.gen_coordinates)\n pa.astar\n end",
"def locate!\n if foursquare_venue_id\n locate_via_foursquare!\n else\n locate_via_coords!\n end\n end",
"def find_solution\n open = [{:cell => @start_cell, :parent => nil, :distance => 0}]\n closed = []\n\n while !open.empty?\n # Find the lowest movement cost\n current_node = open.min{ |a,b| a[:distance] <=> b[:distance]}\n\n # Check if we reached the end cell\n if is_end?(current_node[:cell])\n return current_node[:distance]\n end\n\n # Find immediate neighbors\n current_neighbors = find_neighbors(current_node[:cell])\n current_neighbors.each { | neighbor |\n if closed.find { | node | node[:cell].eql?(neighbor[:cell])}.nil?\n # Find if the cell is already in the open list\n existing_open = open.find { |node | node[:cell].eql?(neighbor[:cell])}\n if existing_open\n # Find the shorter distance to the cell\n current_distance = existing_open[:distance]\n new_distance = current_node[:distance] + neighbor[:distance]\n existing_opened[:distance] = new_distance if current_distance > new_distance\n else\n # Add the new visited cell to the open list\n neighbor[:distance] = neighbor[:distance] + current_node[:distance]\n open << neighbor\n end\n end\n }\n closed << current_node\n open.delete(current_node)\n end\n 0\n end",
"def cell_closest_to_mouse\n # Closest cell to the mouse in the first grid\n x = (inputs.mouse.point.x / grid.cell_size).to_i\n y = (inputs.mouse.point.y / grid.cell_size).to_i\n # Bound x and y to the grid\n x = grid.width - 1 if x > grid.width - 1\n y = grid.height - 1 if y > grid.height - 1\n # Return closest cell\n [x, y]\n end",
"def cell_closest_to_mouse\n # Closest cell to the mouse in the first grid\n x = (inputs.mouse.point.x / grid.cell_size).to_i\n y = (inputs.mouse.point.y / grid.cell_size).to_i\n # Bound x and y to the grid\n x = grid.width - 1 if x > grid.width - 1\n y = grid.height - 1 if y > grid.height - 1\n # Return closest cell\n [x, y]\n end",
"def nearestLocation _args\n \"nearestLocation _args;\" \n end",
"def calc_dijkstra\n # The initial values for the Dijkstra search\n dijkstra_search.frontier << [state.star, 0]\n dijkstra_search.came_from[state.star] = nil\n dijkstra_search.cost_so_far[state.star] = 0\n\n # Until their are no more cells to be explored\n until dijkstra_search.frontier.empty?\n # Get the next cell to be explored from\n # We get the first element of the array which is the cell. The second element is the priority.\n current = dijkstra_search.frontier.shift[0]\n\n # Stop the search if we found the target\n return if current == state.target\n\n # For each of the neighbors\n adjacent_neighbors(current).each do | neighbor |\n # Unless this cell is a wall or has already been explored.\n unless dijkstra_search.came_from.key?(neighbor) or state.walls.key?(neighbor)\n # Calculate the movement cost of getting to this cell and memo\n new_cost = dijkstra_search.cost_so_far[current] + cost(neighbor)\n dijkstra_search.cost_so_far[neighbor] = new_cost\n\n # Add this neighbor to the cells too be explored\n dijkstra_search.frontier << [neighbor, new_cost]\n dijkstra_search.came_from[neighbor] = current\n end\n end\n\n # Sort the frontier so exploration occurs that have a low cost so far.\n # My implementation of a priority queue\n dijkstra_search.frontier = dijkstra_search.frontier.sort_by {|cell, priority| priority}\n end\n end",
"def key_for_min_value(name_hash)\nlowest_value = 0 \n\nname_hash.index do |(x,y)|\n\nx = key \ny = value \nend",
"def find_best_move\n return 5 if @board.unmarked_keys.count == 9\n\n bests = { val: -INFINITY, move: nil }\n\n board.squares.each do |cell, square|\n if square.unmarked?\n move_val = simulate_computer_move(cell)\n if move_val > bests[:val]\n bests[:val] = move_val\n bests[:move] = cell\n end\n end\n end\n bests[:move]\n end",
"def find_closest_pair(pairs)\n zz = {:x => 0, :y => 0}\n distances_from_zz = pairs.map { |p| {:distance => distance(p, zz), :point => p} } # O(n)\n cloest_pair = distances_from_zz.sort { |p1, p2|\n dist = abs(p1[:distance] - p2[:distance])\n puts dist\n dist\n }.take(2)\n cloest_pair.map { |p| \"#{p[:point][:x]}, #{p[:point][:y]} -- distance: #{p[:distance]}\" }\nend",
"def closest_floor(x, y)\n # create mark table and pending array\n table, pending = Table.new($game_map.width, $game_map.height), [[x, y]]\n # as long as there are pending coordinates\n while pending.size > 0\n # current coordinates\n cx, cy = pending.shift\n # if floor beneath\n if !Config::NO_FLOOR_TAGS.include?($game_map.terrain_tag(cx, cy))\n # return found coordinates\n return [cx, cy]\n end\n # mark current coordinates as checked\n table[cx, cy] = 1\n # add tiles around current coordinates if they were not marked yet\n pending.push([cx, cy+1]) if table[cx, cy+1] == 0\n pending.push([cx-1, cy]) if table[cx-1, cy] == 0\n pending.push([cx+1, cy]) if table[cx+1, cy] == 0\n pending.push([cx, cy-1]) if table[cx, cy-1] == 0\n end\n return [x, y]\n end",
"def find_node(calling_node, key)\n @router.touch(calling_node)\n return @router.get_closest_nodes(key)\n end",
"def shortest_route_by_distance_to!(place_or_object_place_was_built_from)\n routes_for!(place_or_object_place_was_built_from).min_by(&:distance_in_meters)\n end",
"def cell_closest_to_mouse2\n # Closest cell grid to the mouse in the second\n x = (inputs.mouse.point.x / grid.cell_size).to_i\n y = (inputs.mouse.point.y / grid.cell_size).to_i\n # Translate the cell to the first grid\n x -= grid.width + 1\n # Bound x and y to the first grid\n x = 0 if x < 0\n y = 0 if y < 0\n x = grid.width - 1 if x > grid.width - 1\n y = grid.height - 1 if y > grid.height - 1\n # Return closest cell\n [x, y]\n end",
"def find_new_road\n return nil if finding_new_road?\n return nil if Params::NEW_ROOT_FIND_PERCENTAGE < rand(Params::PERCENT_DENOMINATOR)\n\n found_mini_map_ids = mini_map_roads.collect{|r| r.end_mini_map_id}\n found_mini_map_ids << id\n not_found_mini_map_ids = MiniMap.all.collect{|m| m.id} - found_mini_map_ids\n end_mini_map_id = not_found_mini_map_ids[rand(not_found_mini_map_ids.size)]\n \n return end_mini_map_id\n end",
"def find(address)\n # Geocode the given address.\n geocode address\n\n ward = Data.new(data)\n ward.to_hash\n end",
"def find_by_route\n @result = Array.new\n @distancias = Array.new\n\n @ride = Ride.order('id')\n if params[:radio] != '0'\n @ride.each do |p|\n distancia1 =Geocoder::Calculations.distance_between([params[:destLatitud],params[:destLongitud]], [p.destPointLat,p.destPointLong])\n distancia2 =Geocoder::Calculations.distance_between([params[:startLatitud],params[:startLongitud]], [p.startPointLat,p.startPointLong])\n if distancia1 <params[:radio].to_f && distancia2 <params[:radio].to_f\n @result.push(p)\n #@distancias.push(distancia1)\n end\n end\n # json_response={\n # result: @result,\n # distancias: @distancias\n # } \n respond_with @result , location: nil\n end\n if params[:radio] == '0'\n respond_with @ride,location: nil\n end \n #Ride.find_by_destPointLat_and_destPointLong(params[:latitud],params[:longitud])\n \n end",
"def nearest(geometry_index: nil, xy:)\n position = nil\n min_distance = 21_000_000 # max distance on earth in meters\n @geometries.each.with_index do |geometry, g_index|\n next unless geometry_index.nil? || geometry_index == g_index\n geometry.each.with_index do |coordinates, c_index|\n distance = xy.distance(coordinates).dim\n if distance < min_distance\n position = Position.new(geometries: geometries, geometry_index: g_index, coordinates_index: c_index)\n min_distance = distance\n end\n end\n end\n position\n end",
"def find_pair\n before = self.entropy\n reduce_pair_line\n reduce_pair_col\n reduce_pair_grid\n reduce_solved if before > self.entropy\n self\n end",
"def find_best_location(asteroids)\n\tresults = Hash.new\n\tbest = nil\n\tmax = 0\n\tasteroids.each do |(x,y), item|\n\t\tar = asteroid_relative(x,y,asteroids)\n\t\tresult = seen_i(ar)\n\t\tsize = result.size\n\t\tif size > max\n\t\t\tmax = size\n\t\t\tbest = [ x, y, result]\n\t\tend\n\tend\n\tremove_self(*best)\n\tbest\nend",
"def node(keystr)\n return nil if @ring.empty?\n key = hash(keystr)\n @nodesort.length.times do |i|\n node = @nodesort[i]\n return @ring[node] if key <= node\n end\n @ring[ @nodesort[0] ]\n end",
"def nearest_neighbor(direction)\n case direction\n when :above\n return if row.first?\n\n adjacent = nil\n adj_distance = nil\n # find closest on next row\n previous_row = row.layout.rows[row.number-1]\n return unless previous_row\n # p1 = {\n # x: row_offset+(width/2),\n # y: number.to_f-(height/2)+height\n # }\n\n previous_row.keys.each_with_index do |key|\n # p2 = {\n # x: (key.row_offset)+(key.width/2),\n # y: next_row.number.to_f-(key.height/2)+key.height\n # }\n\n # len = Math.sqrt( ((p1[:x]-p2[:x]).to_i**2) + ((p1[:y]-p2[:y]).to_i**2) )\n len = distance_to(key)\n if !adj_distance || len < adj_distance\n adjacent = key\n adj_distance = len\n end\n end\n return adjacent\n\n when :below\n return if row.last?\n\n adjacent = nil\n adj_distance = nil\n # find closest on next row\n next_row = row.layout.rows[row.number+1]\n return unless next_row\n # p1 = {\n # x: row_offset+(width/2),\n # y: number.to_f-(height/2)+height\n # }\n\n next_row.keys.each_with_index do |key|\n # p2 = {\n # x: (key.row_offset)+(key.width/2),\n # y: next_row.number.to_f-(key.height/2)+key.height\n # }\n\n # len = Math.sqrt( ((p1[:x]-p2[:x]).to_i**2) + ((p1[:y]-p2[:y]).to_i**2) )\n len = distance_to(key)\n if !adj_distance || len < adj_distance\n adjacent = key\n adj_distance = len\n end\n end\n return adjacent\n\n when :side\n raise NotImplementedError\n else\n raise ArgumentError, \"Unknown direction #{direction.inspect}\"\n end\n end",
"def find_closest_distance\n closest_distance = 1\n closest_clusters = [nil, nil]\n\n @clusters.combination(2) do |c|\n dist = c[0].distance_to(c[1])\n if dist < closest_distance\n closest_distance = dist\n closest_clusters = [c[0], c[1]]\n end\n end\n\n return closest_distance, closest_clusters[0], closest_clusters[1]\n end",
"def guide(from, to, unit_type=nil, max_depth=400)\n return nil if @map.blocked?(from, unit_type) || @map.blocked?(to, unit_type)\n from_element = PathElement.new(from)\n from_element.dist_from = @map.distance(from,to)\n open = PrioritySet.new\n open.push from_element, from_element.rating\n closed = SplayTreeMap.new\n step = 0\n\n until open.empty? || step > max_depth\n step += 1\n\n current_element = open.pop\n @nodes_considered += 1\n\n loc = current_element.location\n if @map.cost(loc,to) == 0\n path = []\n until current_element.parent.nil?\n path.unshift current_element\n current_element = current_element.parent\n end\n\n return path\n else\n closed.push loc, current_element\n @map.neighbors(loc).each do |next_door|\n if closed.has_key? next_door\n next\n end\n \n el = PathElement.new(next_door,current_element)\n\n if @map.blocked? next_door, unit_type\n closed.push el.location, el\n else\n current_rating = current_element.cost_to + @map.cost(loc, next_door)\n\n # add to open\n el.cost_to = current_rating\n el.dist_from = @map.distance(next_door,to)\n el.reset_rating\n\n open.push el, el.rating\n end\n end\n end\n end\n nil\n end",
"def find_smallest_dist(active, visited, distance)\n\t\tbestdist = Float::INFINITY\n\t\tbestnode = nil\n\t\t\n\t\tnodeIndex = 0\n\t\tactive.each do |node|\n\t\t\tif (!visited[node]) && (distance[node] < bestdist)\n\t\t\t\tbestdist = distance[node]\n\t\t\t\tbestnode = nodeIndex\n\t\t\tend\n\t\t\tnodeIndex += 1\n\t\tend\n\t\treturn bestnode\n\tend",
"def shortest_route_by_distance_to(place_or_object_place_was_built_from)\n routes = routes_for place_or_object_place_was_built_from\n select_ok_routes(routes).min_by(&:distance_in_meters)\n end",
"def proximity_to_star(x, y)\n distance_x = (state.star.x - x).abs\n distance_y = (state.star.y - y).abs\n\n if distance_x > distance_y\n return distance_x\n else\n return distance_y\n end\n end",
"def guide(from, to, unit_type=nil, max_depth=400)\n return nil if @map.blocked?(from, unit_type) || @map.blocked?(to, unit_type)\n from_element = PathElement.new(from)\n from_element.dist_from = @map.distance(from,to)\n open = PriorityQueue.new { |x, y| (x <=> y) == -1 }\n open.push from_element, from_element.rating\n closed = SplayTreeMap.new\n step = 0\n \n until open.empty? || step > max_depth\n step += 1\n \n current_element = open.pop\n @nodes_considered += 1\n \n loc = current_element.location\n if @map.cost(loc,to) == 0\n path = []\n until current_element.parent.nil?\n path.unshift current_element\n current_element = current_element.parent\n end\n\n return path\n else\n closed.push loc, current_element\n @map.neighbors(loc).each do |next_door|\n next if closed.has_key? next_door\n\n el = PathElement.new(next_door,current_element)\n\n if @map.blocked? next_door, unit_type\n closed.push el.location, el\n else\n current_rating = current_element.cost_to + @map.cost(loc, next_door)\n\n # add to open\n el.cost_to = current_rating\n el.dist_from = @map.distance(next_door,to)\n \n open.push el, el.rating\n end\n end\n end\n end\n nil\n end",
"def get_neighbors_pins_coordinates(item)\n item.set_default_neighbors_settings\n by_distance = item.neighbors_ids_by_distance\n by_choice = item.neighbors_ids_by_choice\n by_property = item.neighbors_ids_by_property\n union = by_choice\n if by_property\n union = union | by_distance & by_property\n else\n union = union | by_distance\n end\n list = []\n Spree::Location.where(:id => union).each do |location|\n product = location.locatable\n next if product.nil?\n list << {\n :latitude => location.latitude,\n :longitude => location.longitude,\n :distance => item.distance_from([location.latitude, location.longitude]),\n :locatable_id => location.id\n }\n end\n\n sorted = list\n if item.neighbors_settings\n case item.neighbors_settings.sort\n when 2 then sorted = list.sort_by { |neighbor| Spree::Location.find(neighbor[:locatable_id]).locatable.name }\n when 1 then sorted = list.sort_by { |neighbor| neighbor[:distance] }\n end\n end\n sorted = sorted[0,item.neighbors_settings.count] if item.neighbors_settings && item.neighbors_settings.count > 0\n sorted\n end",
"def getStationNearest\n coordinate_lat = params[:lattitude].to_f\n coordinate_lng = params[:longtitude].to_f\n distance_input = params[:distance].to_f\n end",
"def find_path(start, goal)\n raise \"loc1 must not be the same as loc2\" if start == goal\n\n # Using A* path-finding algorithm\n # See pseudocode here: https://en.wikipedia.org/wiki/A*_search_algorithm\n # https://www.redblobgames.com/pathfinding/a-star/introduction.html\n # NOTE that this is overkill for this problem...\n open_set = Set.new([start])\n came_from = {}\n\n # Default value of \"Infinity\", but we can just use nil\n g_score = {}\n g_score[start] = 0\n\n # f_score = g_score[node] + h_score[node]\n # This uses both current best path (g score) aka similar to Djikstra's algorithm,\n # plus the heuristic score.\n f_score = {}\n # g_score[start] is 0, so not included here\n f_score[start] = h_score(start, goal)\n\n # Note that we add d_score as the weight of the edge, but in our\n # case, we consider all edges equally, so hardcode 1\n d_score = 1\n\n until open_set.empty? do\n # Node in open set with lowest f score (would ideally use PriorityQueue)\n current = open_set.min_by { |node| f_score[node] }\n\n if current == goal\n return reconstruct_path(came_from, current)\n end\n\n open_set.delete(current)\n\n valid_neighbours(current).each do |neighbour_loc|\n tentative_g_score = g_score[current] + d_score\n if g_score[neighbour_loc].nil? || tentative_g_score < g_score[neighbour_loc]\n # This path to neighbor is better than any previous one. Record it!\n came_from[neighbour_loc] = current\n g_score[neighbour_loc] = tentative_g_score\n f_score[neighbour_loc] = g_score[neighbour_loc] + h_score(neighbour_loc, goal)\n if !open_set.include?(neighbour_loc)\n open_set << neighbour_loc\n end\n end\n end\n end\n\n raise \"error, no path found!\"\n end",
"def find(source, destination)\n @source_station = @network.find_station_by_name(source)\n @destination_station = @network.find_station_by_name(destination)\n return {} unless @source_station && @network.find_station_by_name(destination)\n\n prepare\n visit(@source_station)\n @routes\n end",
"def shortest_path_to_user(start_coord)\n queue = Queue.new\n queue << [start_coord]\n seen = Set.new([start_coord])\n while queue\n begin\n path = queue.pop(non_block = true)\n rescue ThreadError\n return nil\n end\n x, y = path[-1]\n if @map[y][x] == @USER\n return path\n end\n for x2, y2 in [[x + 1, y], [x - 1, y], [x, y + 1], [x, y - 1]]\n if (0 <= x2 && x2 < @map[0].length) && (0 <= y2 && y2 < @map.length) && (@map[y2][x2] != @WALL && @map[y2][x2] != @PERMANENT_WALL) && !seen.include?([x2, y2])\n queue << (path + [[x2, y2]])\n seen.add([x2, y2])\n end\n end\n end\n end",
"def next_river(rivers, mines, state)\n tips = state[\"tips\"]\n free_rivers = rivers.select{|_, _, owner| owner == -1}\n\n # 鉱脈周りの川が空いていたらランダムで一本だけ抑える\n if tips.empty?\n src, tgt, _ = free_rivers.select{|s, t, _|\n if mines.include?(s) && mines.include?(t)\n false\n elsif mines.include?(s)\n true\n elsif mines.include?(t)\n true\n else\n false\n end\n }.sample(1).first\n\n if mines.include?(src)\n state[\"tips\"] << [tgt, 1]\n elsif mines.include?(tgt)\n state[\"tips\"] << [src, 1]\n end\n return src, tgt, state if src\n end\n\n # 枝をひたすら先に伸ばす\n while tip = state[\"tips\"].pop\n node, len = tip\n free_rivers.each do |s, t, _|\n if s == node || t == node\n state[\"tips\"] << tip\n state[\"tips\"] << [(s == node ? t : s), len+1]\n state[\"tips\"].sort_by!{|node, len| len}\n return s, t, state\n end\n end\n end\n\n # 無理なら適当に\n src, tgt, _ = free_rivers.first\n return src, tgt, state\nend",
"def board_scan source\n map = {}\n\n @board.each do |(key, value)|\n map[key] = {\n predecessor: nil,\n distance: nil\n }\n end\n\n map[source.name][:distance] = 0\n\n queue = []\n queue.append(source)\n\n while queue.length > 0\n temp = queue[0]\n queue.shift\n\n temp.neighbours.each do |neighbour|\n if map[neighbour.name][:distance].nil?\n map[neighbour.name][:distance] = map[temp.name][:distance] + 1\n map[neighbour.name][:predecessor] = temp\n\n queue.append(neighbour)\n end\n end\n end\n\n map\n end",
"def find_moves(start, target)\n visited = breadth_first_search(start, target)\n moves = []\n find_coordinate = target\n visited.reverse.each do |vertex|\n vertex.neighbors.each do |coordinate|\n if coordinate == find_coordinate\n moves << vertex.key\n find_coordinate = vertex.key\n end\n end\n end\n moves.reverse << target\n end",
"def closest(obj)\n zombie = @zombies.first\n\n min_dist = 19000 ** 2 + 6000 ** 2\n\n @zombies.each do |z|\n dist = z.distance(obj)\n if dist < min_dist\n zombie = z\n min_dist = dist\n end\n end\n\n zombie\n end",
"def board_node_by_location(location)\n $board.each { |x| return x if x.location == location }\n return nil\nend",
"def find_nearest_route(path)\n\t\t\tpath_parts = path.parts.dup\n\t\t\tloop do\n\t\t\t\troute = routes.navigate(*path_parts)&.first_route\n\t\t\t\tbreak route if route || path_parts.pop.nil?\n\t\t\tend\n\t\tend",
"def closest(object)\n\t\treturn nil if empty? # edgecase\n\t\tfirst_index(object)[1]\n\tend",
"def search_jps\n open_list = [@nodes[@route.start_id]]\n close_list = []\n goal = @nodes[@route.goal_id]\n\n until open_list.empty?\n n = open_list.min_by { |node| @route.estimated_cost(node) }\n if n == goal\n @route.found = true\n break\n end\n\n close_list.push( open_list.delete(n) )\n\n adjacents_of_n = n.pruned_neighbors(@route.parent(n))\n adjacents_of_n.keys.each do |m|\n j = jump(n, clamp(m.x - n.x, -1, 1), clamp(m.y - n.y, -1, 1))\n next if j == nil or close_list.include?(j)\n h = @heuristic.call(j, goal)\n new_real_cost_j = @route.real_cost(n) + Math.sqrt((n.x-j.x)**2 + (n.y-j.y)**2) # g\n new_estimated_cost_j = new_real_cost_j + h # f = g + h\n if open_list.include?(j)\n # If estimated costs are equal then use real costs for more precise comparison (or we may get less optimal path).\n next if new_estimated_cost_j > @route.estimated_cost(j)\n next if new_estimated_cost_j == @route.estimated_cost(j) && new_real_cost_j >= @route.real_cost(j)\n @route.record(j, n, new_real_cost_j, h)\n else\n open_list.push(j)\n @route.record(j, n, new_real_cost_j, h)\n end\n @visited << j.id unless @visited.include? j.id # stats\n end\n @search_iter += 1 # stats\n end\n end",
"def drivers_ranking(data_for_riders, request_info)\n if request_info == \"cost\"\n money_ranking = Hash.new\n data_for_riders.each do |driver, rides|\n money_ranking[driver] = rides.sum { |info| info[:cost] }\n end\n ranking_for_drivers = money_ranking.select { |driver, value| value == (money_ranking.max_by { |driver,earning| earning })[1] }\n\n elsif request_info == \"rating\"\n ave_rating_ranking = Hash.new\n data_for_riders.each do |driver, rides|\n ave_rating_ranking[driver] = (rides.sum { |info| info[:rating] } / rides.count).to_f\n end\n ranking_for_drivers = ave_rating_ranking.find_all { |driver, value| value == (ave_rating_ranking.max_by { |driver, rating| rating })[1] }\n end\n return ranking_for_drivers\nend",
"def find_nearest_place_id(max_meters)\n Place.collection.find(\n {'geometry.geolocation':\n {'$near': @location.to_hash}\n }).limit(1).projection({:_id=>1}).first[:_id]\n end",
"def robot_paths(x, y, map={})\n if x == 0 && y == 0\n 0\n elsif (x == 0 && y >= 0) || (x >= 0 && y == 0)\n 1\n elsif map[x] && map[x][y]\n map[x][y]\n else\n result = robot_paths(x - 1, y, map) + robot_paths(x, y - 1, map)\n map[x] ? map[x][y] = result : map[x] = {y => result}\n map[x][y]\n end\nend",
"def find_neighborhood\n results = Geocoder.search(\"#{coordinates[1]},#{coordinates[0]}\")\n unless results.blank?\n n = 0\n m = 0\n has_neighborhood = false\n (0..(results.count-1)).each do |i|\n if results[i].types.include?(\"neighborhood\")\n has_neighborhood = true\n n = i\n break\n end\n end\n if has_neighborhood\n (0..(results[n].address_components.count-1)).each do |i|\n if results[n].address_components[i][\"types\"].include?(\"neighborhood\")\n m = i\n break\n end\n end\n results[n].address_components[m][\"long_name\"]\n else\n return nil\n end\n else\n return nil\n end\n \n end",
"def Closest(station, num)\n\tdist_list = []\n\tdist_list_id = []\n\tdist_list_sort_id = []\n\tfor a in (4..335)\n\t\tdist_list << Station_dist(station, Station.find(a))\n\t\tdist_list_id << a\n\tend\n\tdist_list_sort = dist_list.sort\n for b in dist_list_sort\n dist_list_sort_id << dist_list_id[dist_list.index(b)]\n end\n\treturn dist_list_sort_id[1..num]\nend",
"def nearest var, path\n values = []\n path.inject(self) do |branch, k|\n values << branch.var( var )\n branch[ k ]\n end\n values.compact.last\n end",
"def nearest(lat, long, limit)\n spatial_store.nearestk(lat, long, limit)\n end",
"def closest(obj)\n human = @humans.first\n\n min_dist = MAX_DIST\n\n @humans.each do |h|\n dist = h.distance(obj)\n if dist < min_dist\n human = h\n min_dist = dist\n end\n end\n\n human\n end",
"def nearest\n page, per_page = pagination(params)\n miles = search_with_in_miles(params)\n parking_lots = ParkingLot.within(miles, origin:[params[:latitude], params[:longitude]])\n .available_lots.sort_with_higher_availabiltiy\n size = parking_lots.size\n parking_lots = parking_lots.limit(per_page).offset(per_page * page)\n json_response(parking_lots, size)\n end",
"def find_driver\n RideShare::Driver.find(@driver_id)\n # returns Driver instance associated with this Trip instance\n end",
"def get_closest_edge_vertices(lat, lon)\n #Override this function in the corresponding extension (tiger and osm initially)\n return nil\n end",
"def djikstra(world, from_x, from_y, to_x, to_y)\n key = [world.join, from_x, from_y].join(',')\n cached_prev = DJ_GRAPH_MEMO[key]\n\n prev = cached_prev\n\n unless cached_prev\n nodes = map_each_cell(world) {|cell, x, y| cell == '.' ? [x, y] : nil }.\n flatten(1).\n reject(&:nil?)\n\n source = [from_x, from_y]\n dist = Hash[nodes.zip([INFINITY].cycle)]\n queue = nodes.dup\n queue.push(source) unless queue.include?(source)\n dist[source] = 0\n prev = {}\n\n while !queue.empty?\n queue.sort_by! {|node| dist[node]}\n u = queue.shift\n\n neighbors = DIRECTIONS.values.map {|d| [u[0] + d[:x], u[1] + d[:y]] }\n neighbors = neighbors & nodes\n\n neighbors.each do |v|\n alt = dist[u] + 1\n\n if alt < dist[v]\n dist[v] = alt\n prev[v] = u\n end\n end\n end\n\n DJ_GRAPH_MEMO[key] ||= prev\n end\n\n path = []\n target = [to_x, to_y]\n\n return [source] if target == source\n\n # cannot reach target:\n return nil if prev[target].nil?\n\n while target\n path.push(target)\n target = prev[target]\n end\n\n path = path.reverse\n path\nend",
"def nearby_bike_parking(string, dist)\n area = process_coords(area)\n querry = \"$where=within_circle(geom, #{area[1]}, #{area[0]}, #{dist})\"\n bike_grabber(querry)\n end",
"def next_down_the_street_from(x)\n map.east_neighbor_of x\n end",
"def estimate_hits\n nodes = @driver.neighbors\n authority_prime = 0.0\n hub_prime = 0.0\n square_sum_authority_prime = 0.0\n square_sum_hub_prime = 0.0\n # Compute the sum\n nodes.each do |p|\n authority_prime += p.hub\n hub_prime += p.authority\n square_sum_authority_prime += p.authority_prime**2\n square_sum_hub_prime += p.hub_prime**2\n end\n square_sum_authority_prime += authority_prime**2\n square_sum_hub_prime += hub_prime**2\n # Normalize\n authority = authority_prime**2/square_sum_authority_prime\n hub = hub_prime**2/square_sum_hub_prime\n\n # Update routing\n new_routing = @driver.update_routing do |routing|\n routing.authority = authority\n routing.hub = hub\n routing.authority_prime = authority_prime\n routing.hub_prime = hub_prime\n routing.last_update = DateTime.now\n end\n\n new_routing\n end",
"def assignClosest(parr)\n self.dims[0].times do |i|\n self.dims[1].times do |j|\n distances = Array.new\n parr.each do |point|\n distances << point.distance(i, j)\n end\n mins = distances.min(2)\n if mins[0] == mins[1]\n @grid[i][j] = -1\n else\n @grid[i][j] = distances.index(mins[0])\n end\n end\n end\n end",
"def generate_best_pairings(state)\n teams = state.teams\n\n state.matches = state.driver.matches_hash\n\n state.score_range = state.scores.values.max - state.scores.values.min\n state.average_score_difference = state.score_range / teams.length.to_f\n\n state.team_index_map = teams.map.with_index.to_h\n\n Algorithm::Matching.minimum_weight_perfect_matching(teams) do |home_team, away_team|\n cost_function(state, home_team, away_team)\n end\n end",
"def shortest_paths( exclusions = [] )\n # Initialization\n exclusions ||= []\n source = hex\n dist = Hash.new\n previous = Hash.new\n q = []\n @game.map.each do |h|\n if not exclusions.include? h\n dist[ h ] = INFINITY\n q << h\n end\n end\n dist[ source ] = 0\n \n # Work\n while not q.empty?\n u = q.inject { |best,h| dist[ h ] < dist[ best ] ? h : best }\n q.delete u\n @game.map.hex_neighbours( u ).each do |v|\n next if exclusions.include? v\n alt = dist[ u ] + entrance_cost( v )\n if alt < dist[ v ]\n dist[ v ] = alt\n previous[ v ] = u\n end\n end\n end\n \n # Results\n previous\n end",
"def select_point(point)\n closest = live_branches.sort_by do |leaf| \n Gosu::distance(point.x, point.y, leaf.end.x, leaf.end.y) \n end.find do |leaf| \n leaf.should_branch?(point)\n end\n\n self.selected = closest if closest\n end"
] |
[
"0.6496551",
"0.6214725",
"0.59901685",
"0.5965178",
"0.5848656",
"0.58154273",
"0.56944966",
"0.5630501",
"0.55432105",
"0.55432105",
"0.55278695",
"0.5414297",
"0.5389519",
"0.53645104",
"0.5308795",
"0.5308255",
"0.5300886",
"0.5296709",
"0.52879435",
"0.5269035",
"0.5250321",
"0.5247099",
"0.52419174",
"0.52409923",
"0.52374315",
"0.5224163",
"0.5204626",
"0.5176503",
"0.5168583",
"0.5139527",
"0.5108102",
"0.51017505",
"0.5093315",
"0.50880337",
"0.5073938",
"0.50650895",
"0.50518817",
"0.50508744",
"0.50508744",
"0.50474167",
"0.5046245",
"0.50456256",
"0.50343823",
"0.50334126",
"0.50334126",
"0.502928",
"0.5026321",
"0.5020918",
"0.50121164",
"0.5009166",
"0.50001574",
"0.49879193",
"0.49869388",
"0.49724567",
"0.49703515",
"0.496629",
"0.49647567",
"0.49621946",
"0.4959279",
"0.49501207",
"0.49424282",
"0.49402478",
"0.4940153",
"0.4939171",
"0.49369624",
"0.4935247",
"0.49316475",
"0.49222025",
"0.49221095",
"0.49175778",
"0.48945084",
"0.4894169",
"0.488425",
"0.48788226",
"0.4875969",
"0.48660207",
"0.48610857",
"0.48493356",
"0.48457167",
"0.48450446",
"0.4842368",
"0.48380396",
"0.483327",
"0.48324078",
"0.48269102",
"0.4817335",
"0.48169637",
"0.4814631",
"0.48081067",
"0.48057556",
"0.47983843",
"0.47912547",
"0.47904778",
"0.47902936",
"0.47899905",
"0.4783099",
"0.47799292",
"0.47790864",
"0.47642142",
"0.47627485"
] |
0.77339447
|
0
|
Put an object randomly on map floor
|
def put_random(object)
while true
random_row = rand(1...@height - 1)
random_column = rand(1...@width - 1)
if @map[random_row][random_column] == @FLOOR
@map[random_row][random_column] = object
return [random_column, random_row]
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def place_oject_randomly(object)\n while is_wall?(object.location)\n object.location_x = 1 + rand(width - 1)\n\n object.location_y = 1 + rand(height - 1)\n end\n\n objects << object\n end",
"def create_random_world\n randomize_terrain\n randomize_entities\n end",
"def rand_location\n {lat: rand_in(40, 50), lon: rand_in(40, 80) * -1, ele: rand_in(200, 400)}\nend",
"def pbRandomRoam(index)\n if $PokemonGlobal.roamPosition\n keys=pbRoamingAreas(index).keys\n $PokemonGlobal.roamPosition[index]=keys[rand(keys.length)]\n end\nend",
"def fortress_random_point\n FortressCell.where(\"mini_map_id=? and symbol=?\", mini_map.id, :concrete.to_s).sample\n end",
"def place_randomly(width=@width, height=@height, nodeset=@nodes)\n nodeset.each_value do |node|\n node.location = Vector[rand(width), rand(height)] if !node.static\n end\n end",
"def draw_tile\n\t@tile_bag.delete_at(rand (@tile_bag.length))\n\n end",
"def populate_map(map, n)\n ret = Array.new\n\n n.times do\n begin\n x, y = [rand(map.width), rand(map.height)]\n end while(not empty?(x,y,map)) \n \n creat = CreatureGenerator.create_random(self, x, y)\n ret << creat\n end\n \n return ret\n end",
"def random_move probability = 1\n return if rand > probability\n\n room = get_object self.container\n area = room.area\n unless room.nil?\n exits = room.exits.select do |e|\n other_side = get_object e.exit_room\n not other_side.nil? and other_side.area == area\n end.map {|e| e.alt_names[0] }\n\n if exits.respond_to? :shuffle\n exits = exits.shuffle\n else\n exits = exits.sort_by { rand }\n end\n\n go exits[rand(exits.length)]\n end\n end",
"def create_object_position\n @location = Sprite.new\n @location.bitmap = Cache.picture(LOCATION_PICTURE)\n center_im(@location)\n @location.z = 16\n @circlel = Sprite.new\n @circlel.tone.set(255, 0, 0)\n @circlel.blend_type = 1\n @circlel.bitmap = Cache.picture(CIRCLE_PICTURE)\n center_im(@circlel)\n @circlel.z = 16\n place_object\n end",
"def get_object\n next_x = @cur_x + DIRECTION[@hero_direction][0]\n next_y = @cur_y + DIRECTION[@hero_direction][1]\n return if next_x < 0 || next_x > 14 || next_y < 0 || next_y > 14\n #look at new square in room\n next_square = @room[next_x][next_y]\n if next_square == CHAR_POTION || next_square == CHAR_CHEST || next_square == CHAR_IDOL\n @room[next_x][next_y] = CHAR_FLOOR\n draw_map(next_x,next_y)\n @potions += 1 if next_square == CHAR_POTION\n @treasure += 1 if next_square == CHAR_CHEST\n @idol_found = true if next_square == CHAR_IDOL\n @stats[:experience] += 0.25\n end\n end",
"def rand_point()\n \n end",
"def random_coord(min, max)\n rand * (max-min) + min\nend",
"def generate\n @map.each_index do |x|\n @map[x].each_index do |y|\n rand(4) > 0 ? @map[x][y] = :empty : @map[x][y] = :full\n end\n end\n end",
"def meta_random_location(array)\n @plataforma_meta.x = array[0]\n @plataforma_meta.y = array[1] + 45\n end",
"def randomize_terrain\n valid_terrains = @@data[:terrain].values.map { |i| i[:symbol] }\n\n (0...@width).each do |x|\n (0...@height).each do |y|\n @terrain_map[x][y] = valid_terrains[rand valid_terrains.length]\n end\n end\n end",
"def make_random_map\n entire_map = []\n 20.times do\n single_row = []\n 20.times do \n if rand(2) == 1\n single_row << :room\n else\n single_row << :wall \n end \n end \n entire_map << single_row\n end\n entire_map\nend",
"def change_map(i, j)\n \n @world_map.current = [i,j]\n @map = @world_map.current\n if !@world_map.creatures\n rep = CreatureRepartition.create_random(\n @time,\n CreatureGenerator.names,\n 20\n )\n @world_map.creatures = rep\n else\n @world_map.creatures.evolve!(@time)\n end\n \n @creatures = @world_map.creatures.populate(self, @map)\n\n end",
"def random_middle(delta, rock_count, now)\n if delta > 100 && rock_count < 1 #rand(5..15)\n rand_x = @window.width * rand(0.4..0.6)\n rand_y = @window.height * rand(0.4..0.6)\n Rock.new(@window, @object_pool, x: rand_x, y: rand_y, vel_x: 0, vel_y: 0, ang_vel: 1)\n @last_spawn = now\n end \n end",
"def randomize_entities\n valid_entities = @@data[:entities][:types].select { |e| e.random_spawn_chance > 0 }\n (0...@width).each do |x|\n (0...@height).each do |y|\n \n # Roll to see if any entities are created here\n chosen_entity = nil\n valid_entities.each do |e|\n roll = rand(100) / 100.0\n if roll < e.random_spawn_chance\n chosen_entity = e\n break\n end\n end\n\n # If an entity would be created here, add it to the world\n if chosen_entity\n @living_entities << chosen_entity.new(x, y)\n end\n\n end\n end\n end",
"def place_random_ship\n unless full?\n placement = []\n placement << (0...@grid.length).to_a.shuffle.first\n placement << (0...@grid[0].length).to_a.shuffle.first\n @grid[placement[0]][placement[1]] = :s\n else\n raise 'Board is full'\n end\n\n end",
"def spawn_smulg\r\n smulg = spawn_monster(\"Smulg\", 30, 15, 65, 50, rand(3..5), (3..10))\r\nend",
"def generate_map\n map = make_random_map\n map = add_borders(map)\n map = ensure_adjacent_rooms(map)\nend",
"def set_coordinates\n [rand(-100..100), rand(-100..100)]\n end",
"def initialize\n @offset = rand(0...BOUNDARY)\n end",
"def plant_mines\n row_count = @field.length\n cell_count = @field[0].length\n @mine_count.times do |plant|\n row_index = rand(row_count)\n cell_index = rand(cell_count)\n if @field[row_index][cell_index].mine = false\n @field[row_index][cell_index].place_mines\n else\n @field[rand(row_count)][rand(cell_count)].place_mines\n end\n end\n @field\n end",
"def get_random_position\n arr = $game_map.region_tile_mapping[@page.random_position_region]\n return arr.delete_at(rand(arr.length))\n end",
"def generate_tectonic_plates\n max_radius = (width / 10) * 2.0\n\n hill_resources = [ :coal, :iron, :uranium ]\n mountain_resources = [ :coal, :iron, :uranium ]\n\n (width/4).times do\n candidates = { }\n\n radius = (width / 10) * (1.0 + Kernel::rand)\n pos = [ Kernel::rand(@maxx), Kernel::rand(@maxy) ]\n cx,cy = pos\n\n tiles = { }\n\n 1.upto(radius) do |r|\n (cx-r).upto(cx+r) do |x|\n (cy-r).upto(cy+r) do |y|\n pos = [x,y]\n next if tiles[pos]\n next unless in_range?(pos)\n\n if Kernel::rand >= r.to_f/max_radius\n tiles[pos] = true\n tile = self[pos]\n if tile[:terrain] == :grass then\n tile[:terrain] = :hills\n tile[:resource] = nil\n tile[:resource] = hill_resources[Kernel::rand(hill_resources.length - 1)] if Kernel::rand < 0.20\n tile[:resource] = :arable if tile[:resource].nil? && Kernel::rand < 0.40\n elsif tile[:terrain] == :hills then\n tile[:terrain] = :mountains\n tile[:resource] = nil\n tile[:resource] = mountain_resources[Kernel::rand(mountain_resources.length - 1)] if Kernel::rand < 0.40\n else\n tile[:terrain] = :grass\n tile[:resource] = nil\n tile[:resource] = :arable if Kernel::rand < 0.10\n tile[:resource] = :oil if Kernel::rand < 0.03\n tile[:resource] = hill_resources[Kernel::rand(hill_resources.length - 1)] if tile[:resource].nil? && Kernel::rand < 0.05\n end\n end\n end\n end\n end\n end\n end",
"def seed_grid\n @BOMBS.times do\n bomb_placed = false\n until bomb_placed\n pos = [rand(@Y_DIM), rand(@X_DIM)]\n unless self[pos].bomb\n self[pos].bomb = true\n bomb_placed = true\n end\n end\n end\n end",
"def place_rover(r)\n @map[r.coordinate[0],r.coordinate[1]] = r\n end",
"def generate(north_west_corner,south_east_corner)\n\t\tn_y,n_x=north_west_corner.position\n\t\ts_y,s_x=south_east_corner.position\n\t\tsplit_point=Point.new(rand(n_y+2..s_y-2),rand(n_x+2..s_x-2),'wall')\n\t\tif(split_point.x==nil or split_point.y==nil)\n\t\t\treturn @map\n\t\tend\n\t\tgenerate_walls(split_point,north_west_corner,south_east_corner)\n\t\tpoint_array=middle_points(north_west_corner,south_east_corner,split_point)\t\n\t\tpoint_array.each_slice(2) {|a|\n\t\t\tgenerate(a[0],a[1])\n\t\t}\n\tend",
"def execute\n if Settings['zombie']['spawn']['chance'] > rand() * 100\n number_of_zombies = rand(1..5)\n puts \"spawning #{number_of_zombies} zombies\" unless Rails.env.test?\n number_of_zombies.times do\n spawn_point = random_spawn_coords(lat: character.lat, lon: character.lon)\n Zombie.create(lat: spawn_point[0], lon: spawn_point[1])\n end\n end\n end",
"def addrandomcars(lat0,lon0,lat1,lon1, count )\n Fiber.new do\n count.times do\n lat = (lat1-lat0) * rand() + lat0\n lon = (lon1-lon0) * rand() + lon0\n @pgconn.query(\"insert into cars(lat,lon,avail) values(#{lat},#{lon}, true)\")\n end\n end.resume\n end",
"def initialize(mX, mY, mT, mW)\n @MapX = mX\n @MapY = mY\n @MapTerrain = mT\n @MapWeather = mW\n \n rt = Random.new()\n @@mapContent = Array.new(2) {Array.new(3) {|index| index = rt.rand(4)}}\n #(0..5).each {|x| @@mapContent[x] = (0..5).each {|y| @@mapContent[x][y] = rt.rand(4)}}\n end",
"def pick\n @gommis_count = Gommi.count\n @gommis = Gommi.offset(rand(Gommi.count)).first\nend",
"def update_player_map\n @map.tiles[@location.first][location.second].seen = true\n #corners\n @map.tiles[@location.first + 1][@location.second - 1].seen = true\n @map.tiles[@location.first - 1][@location.second - 1].seen = true\n @map.tiles[@location.first + 1][@location.second + 1].seen = true\n @map.tiles[@location.first - 1][@location.second + 1].seen = true\n #cardinal directions\n @map.tiles[@location.first][@location.second + 1].seen = true\n @map.tiles[@location.first][@location.second - 1].seen = true\n @map.tiles[@location.first - 1][@location.second].seen = true\n @map.tiles[@location.first + 1][@location.second].seen = true\n\n #TODO Uncomment\n if !(@map.tiles[@location.first][location.second].monsters.empty?)\n here = @map.tiles[@location.first][location.second]\n #20% chance of monster appearing\n monster_outcome = Random.rand(here.monsters.size * 5)\n if (monster_outcome < here.monsters.size)\n system(\"clear\")\n battle(self, here.monsters[monster_outcome])\n end\n end\n end",
"def random_typhoon_generator\n\n #Normal Typhoon\n r = rand(50) #Currently: 1/50 chance\n if (r%49 == 0)\n sz = rand(3)\n sX = rand(40-12) + 12\n sY = rand(12-1) + 1\n dX = rand(10-3) + 3\n dY = rand(2-1) + 1\n typhoon1 = Typhoon.new(sz, sX, sY, dX, dY, @currentTime)\n addObject(typhoon1)\n end\n #Strong Typhoon\n r = rand(90) #Currently: 1/90 chance\n if (r%89 == 0)\n sz = 3\n sX = rand(46-12) + 12\n sY = rand(12-1) + 1\n dX = rand(11-3) + 3\n dY = rand(2-1) + 1\n typhoon1 = Typhoon.new(sz, sX, sY, dX, dY, @currentTime)\n addObject(typhoon1)\n end\n end",
"def populate_random(n)\n n.times do\n set(rand(0...@x_size), rand(0...@y_size), :alive)\n end\n end",
"def generateMap difficulty\r\n width = 12\r\n height = 100\r\n map = Array.new(height)\r\n i = 0\r\n previousCutterYPos = 0\r\n noCuttterForFirst10Block = 0\r\n while i < height-1\r\n map[i] = Array.new(width)\r\n if(i%3==0) #if the coloumn consist plank then draws the wooden plank on the random position and fills the left space with 0\r\n posX = rand(1..6) #6 randomply decides the position where to draw the wooden plank\r\n plankWithBomb = rand(30)\r\n width.times do |x| \r\n if(x < posX || (posX+4) < x) # fills the coordinate with space i.e 0\r\n map[i][x] = 0\r\n else # fills the coordinate with wooden plank i.e 1 \r\n if(plankWithBomb % (5-difficulty)==0) \r\n map[i][x] = 3\r\n else\r\n map[i][x] = 1 \r\n end\r\n end\r\n end\r\n else #else then just draw the space i.e 0 or cutters \r\n posX = -1\r\n if(previousCutterYPos!=(i-1) && rand(15) % (10-difficulty)==0 && i < 90) # i > 10 denotes that there are no cutter for first 10 blocks or jumps\r\n posX = [0,11].sample \r\n previousCutterYPos = i\r\n end\r\n \r\n 12.times do |x|\r\n if(posX==x)\r\n map[i][posX] = 2\r\n else\r\n map[i][x] = 0\r\n end\r\n end\r\n end\r\n i+=1\r\n end\r\n\r\n # map[height-1] = Array.new()\r\n map[height-1] = [1,1,1,1,1,1,1,1,1,1,1,1] # just making the last block as platform for player to move around\r\n\r\n map # return the map to the calling function\r\nend",
"def plant_bombs\n while num_bombs < 15\n rand_col = rand(@grid.length)\n rand_row = rand(@grid.length)\n @grid[rand_col][rand_row] = :B\n end\n end",
"def add type, x = nil, y = nil, &random_function\n thing = type.new self\n position = x && y && [x, y] || random_function && random_function[]\n thing.warp_to *position\n thing.show\n thing\n end",
"def random_ship\n SHIPS[SHIPS.keys.sample]\n end",
"def generate_bombs\n until @bomb_locations.length == 10\n coords = [rand(0..@NUM_OF_ROWS-1), rand(0..@NUM_OF_COLUMNS-1)]\n if !@bomb_locations.include?(coords) && (!self[coords] || self[coords].value != \"O\")\n @bomb_locations.add(coords)\n self[coords] = Square.new(\"O\")\n end\n end\n end",
"def insert_mines\n @random_spots = []\n @num_of_mine.times do\n\n while @random_spots.length < @num_of_mine\n rand_num = Random.rand(@num_of_tiles**2)\n\n if !@random_spots.include?(rand_num)\n @random_spots << rand_num\n end\n\n end\n end\nend",
"def random\n redirect_to_random(Place)\n end",
"def treasures_allot\r\n randomnums = Random.new\r\n for num in (1..4) do\r\n roomn = randomnums.rand(1...19)\r\n num += 1\r\n while roomn == 6 or roomn == 11 or roomn == 9 or get_some_room_stuff(roomn,6) != 0\r\n roomn = randomnums.rand(1...19)\r\n end\r\n num-=1\r\n set_at_room(roomn,6, randomnums.rand(10...109))\r\n #puts $ooms_map[roomn]\r\n #puts(\"----------------treasure\")\r\n end\r\nend",
"def place_random_ships\n ship_count = size / 4\n while ship_count.positive?\n row = rand(@grid.size)\n col = rand(@grid.size)\n if self[[row, col]] == :N\n self[[row, col]] = :S\n ship_count -= 1\n end\n end\n end",
"def generate_lands!\n\n resources = %w(wood brick metal stone)\n random_resource = resources.concat(resources.sample(2)).shuffle\n random_dice_points = %w(1 2 3 4 5 6).shuffle\n\n %w(0 1 2 3 4 5).shuffle.each.with_index do |position, index|\n game.lands.create(\n resource_type: random_resource[index],\n position: position,\n dice_point: random_dice_points[index]\n )\n end\n end",
"def rand_point\n return nil if @width == 0 || @height == 0\n Point.new(1 + @x + rand(@x + @width), 1 + @y + rand(@y + @height))\n end",
"def place_room(w,h,room_id)\n \n max_tries = Dungeon::MAX_PLACEMENT_ITERATION\n c_try = 0\n while c_try < max_tries\n\n # Get the top left corner, must be even \n tli = (rand*@width).floor\n tli += 1 if tli.odd?\n tlj = (rand*@height).floor\n tlj += 1 if tlj.odd?\n\n # Check all the cells from this point are unallocated, \n # and an extra 1 width around for perimeter\n failed = false\n (tli..tli+w+1).each do |i|\n (tlj..tlj+h+1).each do |j|\n if !failed\n failed = true if @cells[i][j].type != Cell::UNALLOCATED\n end\n end\n end\n\n \n # if checks ok, build the room and the perimeter\n if !failed\n\t\t\t\t# Probability falls so there are an average of 2 doors per room\n\t\t\t\tper = 2*(w+h)\n\t\t\t\tdoor_chance = Dungeon::ROOM_DOORS/per\n\n\t\t\t\t# Prep for building a logical object ready for dead end removal\n\t\t\t\troom_cells = []\n\n (tli..tli+w+1).each do |i|\n (tlj..tlj+h+1).each do |j|\n @cells[i][j].type = Cell::ROOM\n @cells[i][j].room_id = room_id\n\t\t\t\t\t\t\t# If perimeter wall, assign door if random number is under the threshold\n \t\t\t\t\t\tif i == tli || i == tli+w+1 || j == tlj || j == tlj+h+1 \n @cells[i][j].type = Cell::PERIMETER \n\t\t\t\t\t\t\t\tif i.odd? || j.odd?\n\t\t @cells[i][j].type = Cell::ENTRANCE if rand < door_chance\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\t# Store the room cells read for assignment to logical structure\n\t\t\t\t\t\t\troom_cells << @cells[i][j];\n end\n end\n # Meet loop criterea\n c_try = Dungeon::MAX_PLACEMENT_ITERATION\n\n\t\t\t\t# Build logical object and map entrance cells to the room\n\t\t\t\troom_obj = RoomBranch.new(room_cells)\n\t\t\t\troom_cells.each { |c| room_map[c] = room_obj if c.type == Cell::ENTRANCE }\n\n end\n \n c_try += 1\n end\n \n end",
"def place_room(w, h, room_id)\n\n max_tries = Dungeon::MAX_PLACEMENT_ITERATION\n c_try = 0\n while c_try < max_tries\n\n # Get the top left corner, must be even \n tli = (rand*@width).floor\n tli += 1 if tli.odd?\n tlj = (rand*@height).floor\n tlj += 1 if tlj.odd?\n\n # Check all the cells from this point are unallocated, \n # and an extra 1 width around for perimeter\n failed = false\n (tli..tli+w+1).each do |i|\n (tlj..tlj+h+1).each do |j|\n if !failed\n failed = true if @cells[i][j].type != Cell::UNALLOCATED\n end\n end\n end\n\n\n # if checks ok, build the room and the perimeter\n if !failed\n # Probability falls so there are an average of 2 doors per room\n per = 2*(w+h)\n door_chance = Dungeon::ROOM_DOORS/per\n\n # Prep for building a logical object ready for dead end removal\n room_cells = []\n\n (tli..tli+w+1).each do |i|\n (tlj..tlj+h+1).each do |j|\n @cells[i][j].type = Cell::ROOM\n @cells[i][j].room_id = room_id\n # If perimeter wall, assign door if random number is under the threshold\n if i == tli || i == tli+w+1 || j == tlj || j == tlj+h+1\n @cells[i][j].type = Cell::PERIMETER\n if i.odd? || j.odd?\n @cells[i][j].type = Cell::ENTRANCE if rand < door_chance\n end\n end\n\n # Store the room cells read for assignment to logical structure\n room_cells << @cells[i][j];\n end\n end\n # Meet loop criterea\n c_try = Dungeon::MAX_PLACEMENT_ITERATION\n\n # Build logical object and map entrance cells to the room\n room_obj = RoomBranch.new(room_cells)\n room_cells.each { |c| room_map[c] = room_obj if c.type == Cell::ENTRANCE }\n\n end\n\n c_try += 1\n end\n\n end",
"def next_location(rando)\n random = Random.new(rando.seed)\n @neighbors[random.rand(0...@neighbors.count)]\n end",
"def make_room max_w,max_h\n\t{\n\t\tx: rand(@grid_w - max_w - 1) + 1,\n\t\ty: rand(@grid_h - max_h - 1) + 1,\n\t\tw: rand(max_w) + 1,\n\t\th: rand(max_h) + 1,\n\t}\n\tend",
"def gen_location\n while true do\n position = rand(Avoid::SCREEN_W - height)\n return position if can_place(position)\n end\n end",
"def random_typhoon_generator\n\t\t\n\t\t#Normal Typhoon\n\t\tr = rand(50) #Currently: 1/50 chance\n\t\tif(r%49 == 0)\n\t\tsz = rand(3)\n\t\tsX = rand(40-12) + 12\n\t\tsY = rand(12-1) + 1\n\t\tdX = rand(10-3) + 3\n\t\tdY = rand(2-1) + 1\n\t\ttyphoon1 = Typhoon.new(sz, sX, sY, dX, dY, @currentTime)\n\t\taddObject(typhoon1)\n\t\tend\n\t\t#Strong Typhoon\n\t\tr = rand(90) #Currently: 1/90 chance\n\t\tif(r%89 == 0)\n\t\tsz = 3\n\t\tsX = rand(46-12) + 12\n\t\tsY = rand(12-1) + 1\n\t\tdX = rand(11-3) + 3\n\t\tdY = rand(2-1) + 1\n\t\ttyphoon1 = Typhoon.new(sz, sX, sY, dX, dY, @currentTime)\n\t\taddObject(typhoon1)\n\t\tend\n\tend",
"def setup_castle\r\n randomnums = Random.new\r\n zero_out\r\n treasures_allot\r\n terrors_allot\r\n set_at_room(4,6, 100 + randomnums.rand(1...100))\r\n set_at_room(16,6, 100 + randomnums.rand(1...100))\r\nend",
"def create_map\n @map = Sprite.new\n @map.bitmap = Cache.picture(MAP_PICTURE)\n @map.x = M_X\n @map.y = M_Y\n @map.z = 11\n end",
"def random_body_location(roll)\n case roll\n when 1\n \"head\"\n when 2\n \"neck\"\n when 3\n \"torso\"\n when 4\n \"groin\"\n when 5\n \"right hand\"\n when 6\n \"left hand\"\n when 7\n \"right lower arm\"\n when 8\n \"right upper arm\"\n when 9\n \"right shoulder\"\n when 10\n \"left shoulder\"\n when 11\n \"left upper arm\"\n when 12\n \"left lower arm\"\n when 13\n \"butt\"\n when 14\n \"right thigh\"\n when 15\n \"right shin\"\n when 16\n \"right foot\"\n when 17\n \"left thigh\"\n when 18\n \"left shin\"\n when 19\n \"left foot\"\n when 20\n \"back\"\n end\nend",
"def createRoom()\n\t\twidth = rand(@areaWidth * 0.5 .. @areaWidth * 0.7).floor\n\t\theight = rand(@areaHeight * 0.5 .. @areaHeight * 0.7).floor\n\t\t@room = [\n\t\t\trand(@areaX + @areaWidth * 0.15 .. @areaX + @areaWidth - width * 1.15).ceil,\n\t\t\trand(@areaY + @areaHeight * 0.15 .. @areaY + @areaHeight - height * 1.15).ceil,\n\t\t\twidth,\n\t\t\theight,\n\t\t]\n\tend",
"def create_shape\n id = rand 7\n @cur_y = 0\n @cur_x = 5\n @shape = SHAPES[id].dup\n end",
"def grab_x_loc\n rand 100\n end",
"def is_above_ground_foundation_wall?()\n #p \"randomize is_above_ground_foundation_wall?\"\n srand();rand(2)\n end",
"def place_mines\n\t\t(0...@size).to_a.shuffle.slice(0,@total_mines).each do |rand|\n\t\t\tmine_row = rand / @width\n\t\t\tmine_col = rand % @width\n\t\t\t@cell_at[mine_row][mine_col].risk = :mine\n\t\t\t@cells_with_mines << [mine_row, mine_col]\n\t\tend\n\tend",
"def host_opens_door(car_location)\n case car_location\n when 2\n 3 # the only unpicked door with a goat\n when 3\n 2 # the only unpicked door with a goat\n else\n random.rand(2..3)\n end\n end",
"def randomly( word )\n send( [ :point, :delete, :insert ].random, word )\n end",
"def identity_random\r\n new_point = identity\r\n if new_point.x != 0 and new_point.y != 0\r\n if rand(2) > 0\r\n new_point.x = 0\r\n else\r\n new_point.y = 0\r\n end\r\n end\r\n return new_point\r\n end",
"def markOrigin(ox, oy, oz)\n t = df.map_tile_at(ox, oy, oz)\n if t then\n s = t.shape_basic\n #TODO: preseve designation:\n #$originTile = t.designation # a global to store the original origin state\n #puts \"origin: #{$originTile}\"\n t.dig(:Default) if s == :Wall\n end\nend",
"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 initialize\n # Random number between 0 and 12\n @x = rand(12) + 1\n \n # We want vials and herbs to have higher chance to show up in rooms. \n if @x >= 8 and @x < 10\n @objX = $objs[4]\n @x = 4\n elsif @x >= 10\n @objX = $objs[7]\n @x = 7\n else\n @objX = $objs[@x]\n end\n end",
"def first\n\t\trandom = get_rand(4)\n\t\tif random == 0\n\t\t\t@location = \"Museum\"\n\t\telsif random == 1\n\t\t\t@location = \"Cathedral\"\n\t\telsif random == 2\n\t\t\t@location = \"Hospital\"\n\t\telsif random == 3\n\t\t\t@location = \"Hillman\"\n\t\telse\n\t\t\traise \"Something bad has happened\"\n\t\tend\n\tend",
"def random_square(region_id)\n reg = @region_mapper[region_id] || []\n reg.sample\n end",
"def place_player(loc)\n puts \"Map thinks player was at #{@player_location}\" if Settings.debug_mode()\n place_object(1, @player_location)\n place_object(4, loc)\n @player_location = loc\n puts \"Map thinks player is now at #{@player_location}\" if Settings.debug_mode()\n end",
"def uniform_random_position\n [rand(self.width), rand(self.height)]\n end",
"def setRandomLip _obj, _args\n \"_obj setRandomLip _args;\" \n end",
"def set_place\n places_size = Place.count - 1\n place_index = Random.new.rand(0..places_size)\n current_place = Place.find(place_index)\n session[:current_place] = current_place.id\n return current_place\n 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 warp(map_id, x_pos, y_pos, direction)\n $game_temp.player_new_x = x_pos\n $game_temp.player_new_y = y_pos\n $game_temp.player_new_direction = direction\n $game_temp.player_new_map_id = map_id\n $game_temp.player_transferring = true\n end",
"def add_hazard(hazard, numOfRooms)\n for roomToAdd in 0...numOfRooms\n generatedRandom =random_room\n #Check that the generated room has hazard or not \n while generatedRandom.has?(hazard)\n generatedRandom =random_room\n end\n #Call Room.add(haze)\n generatedRandom.add(hazard) \n end\n \n end",
"def position_generator(pos1, pos2, length)\n # generate a position away from earth and moon\n position = rand(1..length - 1)\n if pos1.include? position or pos2.include? position\n position = position_generator(pos1, pos2, length)\n end\n return position\nend",
"def gather_scene_info\n\n id = rand(2**60).to_s\n p \"******gather info now #{id}\"\n SceneTemplate.new(@toys_in_scene, edges, @actions, id, self.bounds, @gravity, @boundaries, self.backgroundColor, @backgroundImage)\n end",
"def mock_leaderboard\n overtake = (rand * 10).round == 7\n swap_at((rand * 9).floor) if overtake\n $state.each.with_index do |car, i|\n $state[i][:interval] = $state[i-1][:interval] - (rand * 4) if i != 0\n $state[i][:last_lap] = 39 + (rand * 3)\n end\n return $state\nend",
"def get_people(floor_num)\n number_of_people = rand(0..MAX_PEOPLE_PER_FLOOR)\n people_arr = []\n number_of_people.times do\n destination_floor = rand(0...NUM_OF_FLOORS)\n # makes sure that no one wants to go to the floor they start on\n people_arr << Person.new(destination_floor) if destination_floor != floor_num\n end\n people_arr\nend",
"def draw_map_obj\n MapCellWall.destroy_all\n MapCellGen.destroy_all\n HPBar.destroy_all\n clear_towers\n $map.occupied_spaces.each do |cell|\n x = cell.x\n y = cell.y\n case cell.object\n when MapAbxn::Wall\n MapCellWall.create(:x => $node_size * 5 * x + $node_size * 5 / 2.0, :y => $node_size * 5 * y + $node_size * 5/2.0)\n when MapAbxn::Tower\n draw_tower(cell.object, $node_size * 5 * x, $node_size * 5 * y, 0.1)\n when MapAbxn::Generator\n MapCellGen.create(:x => $node_size * 5 * x + $node_size * 5 / 2.0, :y => $node_size * 5 * y + $node_size * 5/2.0)\n end\n end\n end",
"def create_random_Ant\n\n myAnt = Ant.new\n\n myAnt.x = @x\n myAnt.y = @y\n myAnt.anthill = self\n rand_number = rand(3)\n if rand_number == 0\n myAnt = create_Forager(myAnt)\n elsif rand_number == 1\n myAnt = create_Builder(myAnt)\n else\n myAnt = create_Warrior(myAnt)\n \n end\n\n Meadow.instance.add_AntToCell(myAnt, @x, @y)\n @food -= 1 \n end",
"def random_incoming(delta, rock_count, now)\n if delta > 100 && rock_count < rand(5..15)\n rand_rot = rand(0.1..0.5) * [-1, 1].sample\n Rock.new(@window, @object_pool, x: @window.width, y: rand(0.0..@window.height), vel_x: rand(-3.0..-2.0), vel_y: rand(-0.5..0.5), ang_vel: rand_rot)\n @last_spawn = now\n end\n end",
"def place_scenario\n associate TweetPong::Stage::Wall.new(:x => 0, :y => 0, :width => width, :height => 0)\n associate TweetPong::Stage::Wall.new(:x => width, :y => 0, :width => 0, :height => height)\n associate TweetPong::Stage::Wall.new(:x => 0, :y => height, :width => width, :height => 0)\n associate TweetPong::Stage::Wall.new(:x => 0, :y => 0, :width => 0, :height => height)\n\n end",
"def place_object\n @board.place_object *next_position\n end",
"def add_object object\n return unless @map\n puts new_o = eval(object).new(:x =>mouse_x,:y=>mouse_y)\n @object_info << {:type =>eval(object),:x=>mouse_x - @map.x,:y =>mouse_y-@map.y}\n @objects << new_o\n end",
"def rand\n return @location + @scale * rand_std_ratio_method\n end",
"def coordinates\n [rand(50), rand(90)]\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 create_rand_spot\n spot_list = []\n 100.times {\n spot_list << @spot = Spot.new\n }\n spot_list\nend",
"def hatch\n @status = Idle\n @target = nil\n @virility = 0\n babies = []\n rand(MaxBabiesFromEgg).to_i.times {babies << baby_salmon}\n babies\n end",
"def random_fire_upon(player_board)\n @available_cells.shuffle!\n target_coord = @available_cells.pop\n player_board.cells[target_coord].fire_upon\n target_coord\n end",
"def generate(size_x, size_y)\n @size_x = size_x\n @data = Array.new(size_x * size_y, 0)\n first_iteration = true\n\n number_of_passes.times do\n drops = create_drops\n\n # initial drop position is at the center of the map\n drop_point_x, drop_point_y = size_x / 2, size_y / 2\n\n drops.each do |drop|\n # drop particles\n drop.each { |particle| particle.drop(@data, drop_point_x, drop_point_y, size_x) }\n\n # move drop point for next drop\n if first_iteration\n drop_point_x = rand(size_x - 8) + 4 # make sure that particles\n drop_point_y = rand(size_y - 8) + 4 # aren't created near the edges\n else\n drop_point_x = rand(size_x / 2) + size_x / 4\n drop_point_y = rand(size_y / 2) + size_y / 4\n end\n end\n\n first_iteration = false\n change_variables_for_next_pass\n end\n\n @data\n end",
"def insert(game_object)\r\n start_x = ( game_object.bb.left / @grid[0] ).to_i\r\n stop_x = ( game_object.bb.right / @grid[0] ).to_i\r\n \r\n (start_x ... stop_x).each do |x|\r\n start_y = ( game_object.bb.top / @grid[1] ).to_i\r\n stop_y = ( game_object.bb.bottom / @grid[1] ).to_i\r\n \r\n @game_object_positions[game_object] = [(start_x ... stop_x), (start_y ... stop_y)]\r\n \r\n @map[x] ||= []\r\n (start_y ... stop_y).each do |y|\r\n @map[x][y] = game_object\r\n puts \"#{game_object.class} => map[#{x}][#{y}]\" if @debug\r\n end\r\n end \r\n end",
"def put_ship(ship_size)\n free_field = free_fields.select { |field| field.count >= ship_size }.sample\n random = rand(0..free_field.count - ship_size)\n @ships << free_field.slice(random, ship_size)\n @ships.last.each { |cell| cell.ship = '#' }\n end",
"def add_monster who, how\n case how\n when :STAIR_UP\n who.move_to @dx, @dy\n when :STAIR_DOWN\n who.move_to @ux, @uy\n when :OTHER\n begin\n y = Kernel.rand(Dungeon::NROW)\n x = Kernel.rand(Dungeon::NCOL)\n end while not @pile[y][x].empty?\n who.move_to x, y\n end\n end",
"def computer_place_pices(board) #is the \"board\" in parameter meas the \"board\" from the \"board = initialize_board\"?\n position = empty_pices(board).sample\n board[position] = \"O\"\nend",
"def populate!()\n\n tile_factory = TileFactory.new()\n livingbeing_factory = LivingBeingFactory.new()\n\n @m.times do |y|\n @n.times do |x|\n\n # Water vs Ground\n location = Location.new(@n, @m, x, y)\n wg = tile_factory.create(Utils.generate_random_percentage(), location)\n\n if wg\n\n @tiles[x][y] = wg\n else\n\n raise StandardError.new(\"Incorrect Percentages less than 100\")\n end\n\n # If tile is Ground type...\n if @tiles[x][y].is_a?(Ground)\n \n lb = livingbeing_factory.create(Utils.generate_random_percentage())\n\n @tiles[x][y].livingbeing = lb if lb\n end\n end\n end\n\n self\n end"
] |
[
"0.77853715",
"0.71777976",
"0.6342371",
"0.6325588",
"0.6325415",
"0.62598896",
"0.6256992",
"0.62299323",
"0.6205703",
"0.6198474",
"0.615919",
"0.6149883",
"0.6089877",
"0.6063938",
"0.6052327",
"0.60449165",
"0.6035289",
"0.60232246",
"0.60132855",
"0.60106415",
"0.6007746",
"0.59983134",
"0.5983751",
"0.5977446",
"0.59759796",
"0.5972319",
"0.59598804",
"0.5943718",
"0.5931817",
"0.59172004",
"0.59138614",
"0.5898019",
"0.58881825",
"0.58846945",
"0.58843946",
"0.5882874",
"0.5861421",
"0.58438456",
"0.5840858",
"0.5832251",
"0.58213806",
"0.58175325",
"0.5817148",
"0.58028126",
"0.5778986",
"0.5776301",
"0.5772812",
"0.57451326",
"0.5731362",
"0.57225597",
"0.5719574",
"0.57149583",
"0.5693755",
"0.56670296",
"0.56614333",
"0.5661419",
"0.56598216",
"0.5656019",
"0.5637749",
"0.5636966",
"0.56348777",
"0.56346786",
"0.56297445",
"0.5627625",
"0.5623324",
"0.56158954",
"0.56023324",
"0.5586817",
"0.55719095",
"0.55704397",
"0.55652153",
"0.55648494",
"0.5554023",
"0.55334735",
"0.55316913",
"0.5527884",
"0.5526374",
"0.55065",
"0.5505058",
"0.5488536",
"0.5485578",
"0.5479791",
"0.54686356",
"0.54681504",
"0.545635",
"0.5456308",
"0.54546744",
"0.5451771",
"0.5448943",
"0.54287416",
"0.5424224",
"0.54222345",
"0.5416465",
"0.54120755",
"0.54117554",
"0.54117006",
"0.54112357",
"0.5410294",
"0.54012626",
"0.53886425"
] |
0.77610946
|
1
|
Delete driver from the map
|
def delete_driver(driver_coord)
@drivers.delete_if do |driver|
driver["coord"] == driver_coord
end
x, y = driver_coord
@map[y][x] = @FLOOR
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @mind_map.destroy\n end",
"def destroy\n\t\t\t\trespond_with Driver.destroy(params[:id])\n end",
"def delete_maps\n own_maps.each do | map |\n logger.debug \"deleting map #{map.inspect}\"\n map.destroy\n end\n end",
"def delete_maps\n own_maps.each do | map |\n logger.debug \"deleting map #{map.inspect}\"\n map.destroy\n end\n end",
"def destroy\n @map.destroy\n\n head :no_content\n end",
"def delete_all\n\t\t\t@@driver.delete_all\n\t\tend",
"def del\n connection.del(key_label)\n end",
"def destroy\n @driver = Driver.find(params[:id])\n @driver.destroy\n\n respond_to do |format|\n format.html { redirect_to drivers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @driver.destroy\n respond_to do |format|\n format.html { redirect_to drivers_url }\n format.json { head :no_content }\n end\n end",
"def delete\n @mapper.delete(@remote_key)\n\n forget\n end",
"def delete(key)\n instrument :delete, key: key do\n map = find_map_by_key(key)\n if map\n client.image.image_delete(map.imgur_id)\n map.destroy!\n end\n end\n end",
"def delete(identifier)\n\t\tif @symbols.has_key?(identifier)\n\t\t\t@symbols.delete(identifier)\n\t\telse\n\t\t\tputs \"Identificador: #{identifier}, no se encuentra en ningun alcance\"\n\t\tend\n\tend",
"def clear\n @driver.clear\n end",
"def delete\n NamedMap.stats_aggregator.timing('named-map.delete') do\n response = self.class.http_client.delete( url + '?api_key=' + @parent.api_key,\n {\n headers: @parent.headers,\n ssl_verifypeer: @parent.verify_cert,\n ssl_verifyhost: @parent.verify_host,\n followlocation: true,\n connecttimeout: HTTP_CONNECT_TIMEOUT,\n timeout: HTTP_REQUEST_TIMEOUT\n } )\n raise HTTPResponseError, \"DELETE:#{response.code} #{response.request.url} #{response.body}\" unless response.code == 204\n end\n end",
"def remove_map\n remove_widget\n end",
"def destroy\n @driver.destroy\n respond_to do |format|\n format.html { redirect_to drivers_url, notice: 'Driver was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @driver.destroy\n respond_to do |format|\n format.html { redirect_to drivers_url, notice: 'Driver was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @driver.destroy\n respond_to do |format|\n format.html { redirect_to drivers_url, notice: 'Driver was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(keys)\n\t\t\tunless key.is_a? Array\n\t\t\t\tkey = [key]\n\t\t\tend\n\n\t\t\t@@driver.delete(keys)\n\t\tend",
"def remove_mapping(grub_device)\n data.delete(grub_device)\n end",
"def purge!\n @map = {}\n end",
"def delete_identity(identity_map)\n identity_map.delete(@remote_key)\n\n self\n end",
"def delete_matched(matcher, options = nil)\n key = expand_key(matcher)\n\n begin\n @gibson.mdel key\n rescue\n 0\n end\n end",
"def delete_object(x, y)\n @generator_flag = false if @grid[y][x].object.class == MapAbxn::Generator\n @grid[y][x] = nil\n end",
"def delete(value)\n @driver_instance.delete_list_value(@key, value)\n end",
"def delete(field_name)\n @element_map.delete(field_name.to_s)\n end",
"def destroy\n @driver.destroy\n respond_to do |format|\n format.html { redirect_to enterprise_drivers_path(current_user), notice: 'Driver was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def del\n delete\n end",
"def destroy\n # Logic to delete a record\n @driver = Driver.find(params[:id])\n @driver.destroy\n\n respond_to do |format|\n format.html { redirect_to drivers_url }\n format.json { head :no_content }\n end\n end",
"def remove(key)\n @map.delete(key)\n end",
"def delete_entry(key, options)\n @hash.delete(key)\n end",
"def destroy\n @map.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @driver_record = DriverRecord.find(params[:id])\n @driver_record.destroy\n\n respond_to do |format|\n format.html { redirect_to driver_records_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n # delete pc_map\n PcMap.find(params[:custom_id]).destroy\n # flash message\n flash.now[:success] = \"削除完了しました。\"\n end",
"def delete\n # TODO: implement delete\n end",
"def delete(o)\n @hash.delete(o)\n self\n end",
"def delete(o)\n @hash.delete(o)\n self\n end",
"def delete_at(index)\n @driver_instance.delete_list_value_at(@key, index)\n end",
"def class_delete class_name\n\t\t\t\t@monitor.synchronize do\n\t\t\t\t\tproviders.each{|p| p.class_delete class_name}\n\t\t\t\tend\n\t\t\tend",
"def quit_driver()\n @driver.shutdown\n end",
"def eject!\n #removes the first node\n node = @store.first\n @store.remove(node.key)\n\n #get rid of the map's reference to the deleted node\n @map.delete(node.key)\n end",
"def delete\n MoxiworksPlatform::Event.delete(self.to_hash)\n end",
"def cfg_delete(cfg)\n obj_delete cfg, ZoneConfiguration\n end",
"def remove_map(map_id)\n logger.info \"layer #{self.id} will have map #{map_id} removed from it\"\n map_layer = LayersMap.where([\"map_id = ? and layer_id = ?\", map_id, self.id]).first\n logger.info \"this relationship to be deleted\"\n logger.info map_layer.inspect\n map_layer.destroy\n update_counts\n update_layer\n\n end",
"def delete\n CONNECTION.execute(\"DELETE FROM locations WHERE id = #{self.id};\")\n end",
"def delete_from_disk; end",
"def delete_class(klass)\n raise \"please use a Class type for the klass argument\" unless klass.is_a?(Class)\n\n deleted = {}\n map.each do |key, matchers|\n deleted_matchers = []\n matchers.delete_if do |matcher|\n # because matcher[:klass] may be a string (which needs to die), coerce both to strings to compare somewhat canonically\n if matcher[:klass].to_s == klass.to_s\n deleted_matchers << matcher\n true\n end\n end\n deleted[key] = deleted_matchers unless deleted_matchers.empty?\n map.delete(key) if matchers.empty?\n end\n deleted\n end",
"def delete(key)\n doozer_pool.with_connection do |doozer|\n doozer.delete(full_key(key))\n end\n end",
"def destroy\n @ride_driver.destroy\n respond_to do |format|\n format.html { redirect_to @root }\n format.json { head :no_content }\n end\n end",
"def delete(p)\n @store.delete(p)\n end",
"def delete(key); end",
"def delete(key); end",
"def delete(key); end",
"def delete(key); end",
"def delete(key); end",
"def destroy\n @beacon.destroy\n end",
"def free_driver(driver)\n @@semaphore.synchronize do\n @@pool.each do |entry|\n if entry[:driver] == driver\n entry[:taken] = false\n end\n end\n end\n nil\n end",
"def delete *paths\n branch = _find_delegate_hash *paths\n if branch.has_key? paths.last\n branch[paths.last].remove\n end\n end",
"def quit_driver\n driver.quitDriver\n end",
"def destroy\n @moretinymap = Moretinymap.find(params[:id])\n @moretinymap.destroy\n\n respond_to do |format|\n format.html { redirect_to moretinymaps_url }\n format.json { head :no_content }\n end\n end",
"def delete_key(key)\n end",
"def delete()\n @ole.Delete()\n end",
"def delete()\n @ole.Delete()\n end",
"def delete()\n @ole.Delete()\n end",
"def delete()\n @ole.Delete()\n end",
"def delete_entry(key, options)\n dataset.delete Google::Cloud::Datastore::Key.new @datastore_kind_name, key\n end",
"def remove(instance)\n @registry.each_with_index do |item, i|\n if item.to_h == instance.to_h\n @registry.delete_at(i)\n end\n end\n sync\n end",
"def delete(el)\n store.delete(el)\n end",
"def destroy\n @map_chip.destroy\n respond_to do |format|\n format.html { redirect_to map_chips_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 delete\n BasicInterfaceRegister[@data_lib].delete(@data_set_name)\n end",
"def destroy\n get_map\n @map.destroy\n\n respond_to do |format|\n format.html { redirect_to maps_url }\n format.json { head :no_content }\n end\n end",
"def delete(_spec)\n raise NotImplementedError, not_implemented_msg(:delete)\n end",
"def delete\n @dbman.delete\n @dbprot.clear\n end",
"def delete\n super do\n @strands.each do |strand|\n Cluster.redis.hdel LOOKUP, strand.id\n end\n Cluster.redis.hdel TOPICS, @id\n end\n end",
"def remove_entry(p)\n\t\t@person.delete(p)\n\tend",
"def destroy\n self.class.remove(key)\n end",
"def destroy\n self.class.remove(key)\n end",
"def delete(key)\n\n end",
"def drop(options = {})\n if key = @backend.keys.first\n [key, delete(key)]\n end\n end",
"def destroy\n @map = Map.find(params[:id])\n @map.destroy\n\n respond_to do |format|\n format.html { redirect_to request.env[\"HTTP_REFERER\"] || @map.mapable, notice: 'Map removed!' }\n format.json { head :no_content }\n end\n end",
"def delete_pair(key)\r\n @redis.del key \r\n end",
"def delete!(key)\n @table.delete(key.to_sym)\n end",
"def delete(*args, &block)\n map_method(:delete, args, &block)\n end",
"def destroy\n @trip_driver = TripDriver.find(params[:id])\n @trip_driver.destroy\n\n respond_to do |format|\n format.html { redirect_to trip_drivers_url }\n format.json { head :no_content }\n end\n end",
"def delete\n super(ZONE_METHODS[:delete])\n end",
"def remove(selector={})\n @db.remove_from_db(@name, selector)\n end",
"def destroy\n review_response_maps.each(&:destroy)\n super\n end",
"def delete(key)\n db.delete(key)\n end",
"def delete(path, options = {}, &block)\n map(path, options, :delete, &block)\n end",
"def deletePlayer()\n\t\ttimeMax = @rankedTimeDB.execute(\"SELECT MAX(time) FROM rankedTime WHERE idMap = '#{@idMap}'\").shift.shift\n\t\t@rankedTimeDB.execute(\"DELETE FROM rankedTime WHERE time = '#{timeMax}'\")\n\t\t\n\tend",
"def delete_from_dor\n CocinaObjectStore.destroy(druid)\n AdministrativeTags.destroy_all(identifier: druid)\n ObjectVersion.where(druid:).destroy_all\n Event.where(druid:).destroy_all\n end",
"def delete(value)\n @hash.delete(value) && @hash.send(:convert_key, value)\n end",
"def delete(instance)\n @cache[mapped_class(instance.class)].delete(instance.key)\n end",
"def remove_from_position_map(position)\n self.position_ts_map.delete position.id\n end",
"def destroy\n @driver = Driver.find(params[:id])\n @driver.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n expire_fragment \"event-#{@driver.event.id}\"\n end",
"def delete_device(device)\n device.trace_point&.disable\n @devices -= [device]\n end",
"def delete(symbol)\n configuration.delete(symbol)\n end",
"def delete(key)\n @db.delete(key.to_s.downcase)\n end",
"def delete_locator(loc)\n check_locator(loc)\n index = loc.send(:index)\n if @heapsize <= index\n priority, subpriority = get_entry_ps(index)\n last = self.size - 1\n if index != last\n loc2, priority2, subpriority2 = get_entry(last)\n set_entry(index, loc2, priority2, subpriority2)\n loc2.send(:index=, index)\n end\n delete_last_entry\n loc.send(:internal_deleted, priority, subpriority)\n loc\n else\n mode_heapify\n @heapsize = mode_call(:delete_loc, loc)\n loc\n end\n end"
] |
[
"0.6448386",
"0.64195776",
"0.61932623",
"0.61932623",
"0.60951954",
"0.6063446",
"0.6034535",
"0.60285723",
"0.60175073",
"0.6015528",
"0.600267",
"0.59961265",
"0.598021",
"0.59604883",
"0.59193075",
"0.58729386",
"0.58729386",
"0.58729386",
"0.5870536",
"0.5807259",
"0.5793681",
"0.57932746",
"0.57612556",
"0.5745464",
"0.57339823",
"0.5700948",
"0.568571",
"0.5681925",
"0.5679543",
"0.5662037",
"0.56343585",
"0.56301415",
"0.5622885",
"0.56119215",
"0.55882764",
"0.55773073",
"0.55773073",
"0.55744267",
"0.55713904",
"0.5569502",
"0.5561836",
"0.55546105",
"0.554779",
"0.5537942",
"0.55372846",
"0.5529866",
"0.55216825",
"0.55172056",
"0.5509695",
"0.55015063",
"0.5490737",
"0.5490737",
"0.5490737",
"0.5490737",
"0.5490737",
"0.54874706",
"0.54827964",
"0.5482175",
"0.54741865",
"0.5472948",
"0.5471823",
"0.54621816",
"0.54621816",
"0.54621816",
"0.54621816",
"0.54614896",
"0.5460257",
"0.5455786",
"0.54487646",
"0.5447859",
"0.54434484",
"0.54427433",
"0.54415935",
"0.5440204",
"0.54375386",
"0.5431728",
"0.5424094",
"0.5424094",
"0.5417095",
"0.54138935",
"0.54112536",
"0.54091525",
"0.53994733",
"0.53982514",
"0.53959787",
"0.5390758",
"0.5385507",
"0.5383237",
"0.5383141",
"0.53821045",
"0.53811735",
"0.53784287",
"0.53769904",
"0.5374635",
"0.5373988",
"0.5372395",
"0.53668475",
"0.5365648",
"0.5362553",
"0.5361318"
] |
0.74614185
|
0
|
Show the path that has been passed Path should be an array of coordinate
|
def show_map_with_path(path)
map_temp = @map.map(&:clone) # Had to clone the map
for x, y in path
map_temp[y][x] = @PATH # Writing down the path
end
for row in map_temp
row_to_print = []
for item in row
if item == @FLOOR
row_to_print.push(" ") # Floor
elsif item == @PATH
row_to_print.push(".") # Path that the driver has passed
elsif item == @USER
row_to_print.push("\e[32m@\e[0m") # @ with green color
elsif item.instance_of?(Driver)
row_to_print.push("D") # Driver
elsif item.instance_of?(Restaurant)
row_to_print.push("R") # Restaurant
elsif item == @WALL || item == @PERMANENT_WALL
row_to_print.push("#") # Wall
else
row_to_print.push(" ")
end
end
puts row_to_print.join(" ")
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def draw_paths; end",
"def print_path\n @path.each{|x| puts x.inspect}\n end",
"def draw_paths=(_arg0); end",
"def drawMapPath(startPoint, endPoint, path)\n print \"Width: \"+@width.to_s+\"\\n\"\n print \"Height: \"+@height.to_s+\"\\n\"\n print \"Path Length: \"+path.count.to_s+\"\\n\"\n print self.getMapToText(startPoint, endPoint, path)+\"\\n\"\n end",
"def render_path\n # If the star and target are disconnected there will only be one path\n # The path should not render in that case\n unless search.path.size == 1\n search.path.each_key do | cell |\n # Renders path on both grids\n outputs.solids << [scale_up(cell), path_color]\n end\n end\n end",
"def path\n @path ||= [ path_only ].concat( [*matrix].delete_if { |v| v.respond_to?(:empty?) and v.empty? } ).join('')\n end",
"def inspect\n \"#<Path #{@path}>\"\n end",
"def print_path(path)\n printed = \"You made it in #{path.length - 1} moves! Here's your path:\\n\"\n path.each { |position| printed += \"#{position}\\n\"}\n puts printed.chomp \n end",
"def drawPath(path)\n color = @@colors[path[0]]\n glBegin GL_LINES\n glColor4f(*color)\n path[1].each do |point|\n glVertex3f(*point)\n end\n glEnd\n end",
"def path\n coordinates = steps.map(&:start_location)\n coordinates << legs.last.steps.last.end_location\n coordinates\n end",
"def putPaths()\r\n\t\tif @paths.nil?\r\n\t\t\tputs \"Empty Path\"\r\n\t\telsif @paths.respond_to?(\"join\")\r\n\t\t\tputs \"Path: #{@paths.join(\", \")}\"\r\n\t\telse\r\n\t\t\tputs \"Path: #{@paths}\"\r\n\t\tend\r\n\tend",
"def path(c,r, matrix_map)\n \n \n\nend",
"def display_path path\n\tif path.length <= 1\n\t\tputs \"You are already at your destination :-)\"\n return\n end\n\tputs \"You made it in #{path.length - 1} move#{path.length > 2 ? \"s\" : \"\"}! Here's your path:\"\n path_string = \"\"\n\tpath.each { |position| path_string += position.to_s + \"-->\" }\n\tpath_string[-3..-1] = \"\"\n\tputs path_string\nend",
"def path_array\n path = []\n yield_path do |x, y|\n path << [x,y]\n end\n path.reverse\n end",
"def patharray\n return @pathArray\n end",
"def path\n @path || []\n end",
"def path(current)\n output = \" \"\n path = [[current.x, current.y]]\n while current.parent != nil\n path << [current.parent.x, current.parent.y]\n current = current.parent\n end\n path.reverse!\n path.each do |space|\n output += \"#{space} \"\n @board.update_board(space)\n end\n output\n end",
"def path(cmds)\n primitive \"path '\" + cmds + \"'\"\n end",
"def to_s\n @paths\n end",
"def print_path(node)\n print_arr = [node.value]\n while !node.parent.nil?\n print_arr << node.parent.value\n node = node.parent\n end\n print_arr.reverse!\n puts \"You reached your destination in #{print_arr.length - 1} moves! Here was your path:\"\n print_arr.each {|value| puts \"\\t#{value}\"}\n end",
"def to_path\n Path.new(\n N.n(@x, @y),\n N.n(@x - @width / 2, @y + @height),\n N.n(@x + @width / 2, @y + @height),\n **@options\n )\n end",
"def display_path path\r\n\tif path.length <= 1\r\n\t\tputs \"You are already at your destination :-)\"\r\n return\r\n end\r\n\tputs \"You made it in #{path.length - 1} move#{path.length > 2 ? \"s\" : \"\"}! Here's your path:\"\r\n path_string = \"\"\r\n\tpath.each { |position| path_string += position.to_s + \"-->\" }\r\n\tpath_string[-3..-1] = \"\"\r\n\tputs path_string\r\nend",
"def path\n\t\t\t@path_elements.join(\"/\")\n\t\tend",
"def path\n @data[\"path\"].to_s\n end",
"def path=(value)\n @path = value\n end",
"def inspect\n ::Ice::__stringify(self, T_PathPlanner2d)\n end",
"def paths_s\n \"['#{paths.join(\"','\")}']\"\n end",
"def path(*) end",
"def print_out(path)\n\t\n\t# add X's for path\n\tpath.each do |coord|\n\t\tCOORDS_HASH[coord] = \"X\" unless (COORDS_HASH[coord]==\"S\" || COORDS_HASH[coord]==\"E\")\n\tend\n\t\n\tmaze = COORDS_HASH.values.join\n\t\n\tFile.open(\"maze_gen_sln.txt\", \"w\"){ |somefile| somefile.puts \"#{maze}\"}\nend",
"def path=(value)\n @path = value\n end",
"def path=(value)\n @path = value\n end",
"def path=(value)\n @path = value\n end",
"def print_paths\n path, counter = [], 0\n puts '************************ Tree Paths ***********************************'\n puts\n print_tree_paths(self.root, path, counter)\n puts\n puts '***********************************************************************'\n end",
"def path\n @path ||= position.sub(/\\.\\d+\\z/, \"\")\n end",
"def path() end",
"def path() end",
"def path() end",
"def get_path_pins(path); end",
"def get_path_pins(path); end",
"def path!\n model.dataset.select(:path).get_unfiltered_raw(id).try(:[], :path)\n end",
"def printpath(path)\n puts \"Path: From Startsburg (A) to Endenville (j)\"\n n = path.size\n while n >= 0\n print(\"#{path[n]} \")\n n-=1\n end\n puts \"\\n\"\n puts \"Path length: #{path.size-2}\"\nend",
"def pathlist\n @path\n end",
"def path\n Especie.where(id: path_ids)\n end",
"def path\n @path\n end",
"def path\n @path\n end",
"def path\n return @path if instance_variable_defined? :@path\n @path = path_components\n end",
"def path\n [name]\n end",
"def path\n\t\t@path\n\tend",
"def spec( *args )\n\n if args[0].kind_of? Array\n\n # Coord pairs.\n args.each do |p|\n @path.push Pos.ini( p[0], p[1] )\n end\n\n else\n\n if args[0].kind_of? Pos\n # List of pos.\n @path = args\n else\n # Odd index in Array\n odd = false\n x = nil\n y = nil\n # Alternating x, y.\n args.each do |p|\n if odd\n @path.push Pos.ini( x, p )\n else\n x = p\n end\n odd = not( odd )\n end\n end\n end\n\n self\n end",
"def path\n @path\n end",
"def path\n @path\n end",
"def path\n @path\n end",
"def path\n @path\n end",
"def to_s\n @path\n end",
"def to_s\n @path\n end",
"def path\n @path\n end",
"def path\n @path\n end",
"def path\n @path\n end",
"def path\n @path\n end",
"def path_arr()\n return @paths\n end",
"def path\n end",
"def inspect\n \"#<#{self.class} @path=#{@path.inspect}>\"\n end",
"def path=(p)\n @path = p\n end",
"def path_string\n \"\\#{#{position}}\"\n end",
"def to_s\n path\n end",
"def path\n Pathname(@path.respond_to?(:to_path) ? @path.to_path : @path.to_s).expand_path\n end",
"def get_line_str(coords)\n line_str = ''\n coords.each{|x,y| line_str << @box[x][y]}\n line_str\n end",
"def path(value)\n define_singleton_method(:path_value) { value.to_s }\n private_class_method :path_value\n end",
"def path(id)\n\t\tpoints = Points.new\n\t\t\n\t\tif path = @doc.at(\"//g path[@id='#{id.to_s}']\")\n\t\t\tpath[:d].split(\" \").each do |point|\t\n\t\t\t\tx, y = point.split(\",\")\n\t\t\t\tpoints << [x.to_f, y.to_f]\tif x and y\n\t\t\tend\n\t\telse\n\t\t\traise \"Cant find item with id=#{id.to_s}\"\n\t\tend\n\t\t@paths[id.to_sym] = points\n\tend",
"def path; @path_stack end",
"def path\r\n @pathname.to_s\r\n end",
"def path\n return @path\n end",
"def path\n return @path\n end",
"def path\n return @path\n end",
"def\n\t\tprint_point\n\t\tp \"(#{x}, #{y})\"\t\n\tend",
"def dump_points(cur_path = [])\n self.each do |geom|\n cur_path << geom.dump_points\n end\n cur_path\n end",
"def path(*args)\n @path = args.map(&:to_sym)\n self\n end",
"def path\n end",
"def path\n end",
"def path\n end",
"def path\n s = ''\n s << '/' if @absolute\n s << @path.join('/')\n s << '/' if @trail\n s << '.' if s.empty?\n s\n end",
"def path\n if value.is_a?(String)\n value\n else\n value.send(path_method, *path_arguments)\n end\n end",
"def path_str\n path.join(\"-\")\n end",
"def path_to(x:, y:)\n x_signal = x / [x.abs, 1].max\n y_signal = y / [y.abs, 1].max\n\n if x.abs > y.abs\n [[1 * x_signal, 0]]\n elsif x.zero? && y.zero?\n [[0, 0]]\n else\n [[0, 1 * y_signal]]\n end\n end",
"def getPointOnPath(view_path_coordinates, average_speed, time)\n distance = average_speed * time\n ans = getDirectionAndPointOnPath(view_path_coordinates, distance, average_speed)\n return ans[:coord]\n end",
"def path(path)\n @path = path\n end",
"def steps (x, y, path)\n if x == 0 && y == 0\n then puts (path)\n return\n end\n if x > 0\n then steps(x - 1, y, path + \"R\")\n steps(x - 1, y + 1, path + \"L\")\n end\n if y > 0\n then steps(x, y - 1, path + \"H\")\n end\nend",
"def path\n return @path\n end",
"def coordinates\n\t coordinate_array.map(&:to_s).join(\",\")\n\tend",
"def inspect\n \"#<#{self.class.name}:#{object_id} {path: #{path.inspect}}>\"\n end",
"def show\n x = @plot.user.x\n y = @plot.user.y\n puts x\n puts y\n \n end",
"def path\n @path ||= Path.new\n end",
"def to_s\n path\n end",
"def to_s\n \"#{@x}/#{@y}\"\n end",
"def path_expanded path\n end",
"def path\n ([*@options['path']].first.split(',').first || '/').strip\n end",
"def to_s\n \"#{self.point.x},#{self.point.y},#{self.width},#{self.height}\"\n end",
"def print_rover\n puts \"#{coordinate[0]} #{coordinate[1]} #{coordinate[2]}\"\n end",
"def paths\n end_verts = ends\n paths = []\n vertices.each do |v|\n end_verts.each do |e|\n x = path?(v.id, e.id)\n if x.is_a?(Array)\n x[1] << v.data\n paths << x[1]\n end\n end\n end\n end_verts.each { |e| paths << e.data }\n paths\n end",
"def paths; end"
] |
[
"0.6814275",
"0.67022854",
"0.66322815",
"0.65466475",
"0.64858454",
"0.63821626",
"0.6307617",
"0.6237354",
"0.6206942",
"0.6191151",
"0.61810964",
"0.6135012",
"0.6121396",
"0.6022216",
"0.6020184",
"0.59939325",
"0.598658",
"0.5950732",
"0.5915559",
"0.59137577",
"0.5911396",
"0.5877575",
"0.585365",
"0.5832841",
"0.580326",
"0.5765608",
"0.57591134",
"0.57550895",
"0.57500076",
"0.5746084",
"0.5746084",
"0.5746084",
"0.5735296",
"0.573519",
"0.5727334",
"0.5727334",
"0.5727334",
"0.572474",
"0.572474",
"0.57012373",
"0.56941104",
"0.56857747",
"0.5676844",
"0.56441605",
"0.56441605",
"0.56308097",
"0.5620427",
"0.56152296",
"0.5613007",
"0.56123394",
"0.56123394",
"0.56123394",
"0.56123394",
"0.55944353",
"0.55944353",
"0.556559",
"0.556559",
"0.556559",
"0.556559",
"0.55508375",
"0.5537152",
"0.553313",
"0.55301297",
"0.5524867",
"0.5482253",
"0.54730964",
"0.5471956",
"0.5456571",
"0.5439803",
"0.5431348",
"0.5417464",
"0.5400016",
"0.5400016",
"0.5400016",
"0.5398133",
"0.539616",
"0.5395701",
"0.5392667",
"0.5392667",
"0.5392667",
"0.5388504",
"0.5380264",
"0.53766954",
"0.53723246",
"0.5365752",
"0.53637874",
"0.53635734",
"0.53599644",
"0.5357193",
"0.53496015",
"0.53491455",
"0.5340223",
"0.53397536",
"0.533274",
"0.5326913",
"0.53119093",
"0.5308137",
"0.5305905",
"0.52955514",
"0.5270664"
] |
0.6603907
|
3
|
See ActionController::RequestForgeryProtection for details
|
def location_path(location)
url_for(:controller => 'locations', :action => 'show', :city => location.city.gsub(' ','_'), :state => location.state)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def protect_against_forgery?; end",
"def disable_request_forgery_protection; end",
"def disable_request_forgery_protection=(_arg0); end",
"def allow_forgery_protection\n true\n end",
"def protect_against_forgery?\n end",
"def protect_against_forgery?\n\n end",
"def protect_from_forgery\n end",
"def protect_against_forgery? #:nodoc:\n false\n end",
"def protect_against_forgery?\n false\n end",
"def protect_against_forgery?\n false\nend",
"def protect_against_forgery?\n false\n end",
"def protect_against_forgery?\n false\n end",
"def protect_against_forgery?\n false\n end",
"def protect_against_forgery?\n false\n end",
"def protect_against_forgery?\n false\n end",
"def protect_against_forgery?\n false\n end",
"def protect_against_forgery?\n false\n end",
"def protect_against_forgery?\n @paf ||= ActionController::Base.new.send(:protect_against_forgery?)\n end",
"def protect_against_forgery?\n false\n end",
"def skip_forgery_protection(options = T.unsafe(nil)); end",
"def protect_against_forgery?\n false\n end",
"def protect_against_forgery?\n false\n end",
"def protect_against_forgery?\n controller.send(:protect_against_forgery?)\n end",
"def use_null_session\n ActionController::RequestForgeryProtection::ProtectionMethods::NullSession.new(self)\n .handle_unverified_request\n end",
"def handle_unverified_request\n logger.warn \" Form token: #{params[request_forgery_protection_token]}\" if logger\n logger.warn \" Header token: #{request.headers['X-CSRF-Token']}\" if logger\n logger.warn \" Session token: #{session[:_csrf_token]}\" if logger\n super\n end",
"def csrf; end",
"def handle_unverified_request\n super\n render :text => \"Forgery protection token was not present.\", :status => :unauthorized\n end",
"def verified_request?\n !protect_against_forgery? ||\n request.method == :get ||\n !verifiable_request_format? ||\n form_authenticity_token == params[request_forgery_protection_token]\n end",
"def verified_request?\n !protect_against_forgery? ||\n request.method == :get ||\n request.xhr? ||\n !verifiable_request_format? ||\n form_authenticity_token == params[request_forgery_protection_token]\n end",
"def request_authenticity_tokens; end",
"def verified_request?\n\t\t!protect_against_forgery? || request.get? ||\n\t\t\tform_authenticity_token == params[request_forgery_protection_token] || form_authenticity_token == request.headers['X-CSRF-Token'] ||\n\t\t\trequest.headers['X-XSRF-Token'] && form_authenticity_token == request.headers['X-XSRF-Token'].gsub!(/\\A\"|\"\\Z/, '')\n\tend",
"def verified_request?\n !protect_against_forgery? || request.get? ||\n form_authenticity_token == params[request_forgery_protection_token] ||\n form_authenticity_token == request.headers['X-XSRF-Token']\n end",
"def verified_request?\n !protect_against_forgery? || request.get? ||\n form_authenticity_token == params[request_forgery_protection_token] ||\n form_authenticity_token == request.headers['X-XSRF-Token']\n end",
"def verified_request?\n !protect_against_forgery? || request.get? ||\n form_authenticity_token == params[request_forgery_protection_token] ||\n form_authenticity_token == request.headers['X-XSRF-Token']\n end",
"def refuse_request\n request = Request.first\n RequestMailer.refuse_request(request)\n end",
"def handle_unverified_request\n redirect_to root_url, :notice => \"We detect unmatching token form your form, please do not hack us\"\n \n end",
"def need_protection?(request)\n request.params.has_key?('access_token')\n end",
"def clean_up_csrf?; end",
"def clean_up_csrf?; end",
"def csrf_token_hash(action=nil)\n vc = @controller.view_context\n # :nocov:\n if vc.protect_against_forgery?\n # :nocov:\n {vc.request_forgery_protection_token.to_s=>vc.form_authenticity_token}\n end\n end",
"def rails_check_csrf!\n rails_controller_instance.send(:verify_authenticity_token)\n end",
"def csrf_meta_tags; end",
"def verify_authenticity_token; end",
"def email_confirmed?\n # Validate if the user has the email confirmed in the\n # server side session. This is set by the controller.\n # after we've validated the email. If the user doesn't\n # have this session value, he can't complete this form.\n #\n # If the user attempts to share/bookmark this url, for example\n # and the incoming session is not found to be valid\n # then the user is redirected to the terms and conditions\n # and a notification that their link has expired is\n # shown.\n if session[\"email_confirmed\"].to_s.length == 0 or\n session[\"email_confirmed\"] == false or\n session[\"email\"].to_s.length == 0 or\n session[\"locked_address\"].to_s.length == 0\n redirect to ('/?expired=true')\n # If the email address and the locked address\n # do not match, we could have a user using\n # multiple tabs at the same time to process different\n # certificate requests. This could happen if a\n # shared computer is left open with a partially\n # uncompleted request that already has access to the\n # form, and another request that is processing an email\n # confirmation. Other than that, and on a more malicious\n # note, an attacker could be trying to exploit our\n # session system, to attempt to send email to an\n # unconfirmed address. We stop both potential situations\n # immediately here.\n elsif (session[\"locked_address\"] != session[\"email\"])\n redirect to ('/?email=false')\n end\n\nend",
"def verified_request?\r\n super || form_authenticity_token == request.headers['X-XSRF-TOKEN']\r\n end",
"def form_authenticity_param; end",
"def handle_unverified_request\n raise ActionController::InvalidAuthenticityToken\n end",
"def handle_unverified_request\n raise ActionController::InvalidAuthenticityToken\n end",
"def rails_csrf_param\n rails_controller.request_forgery_protection_token\n end",
"def check_csrf?\n true\n end",
"def verified_request?\n super || form_authenticity_token == request.headers['X-XSRF-TOKEN']\n end",
"def verified_request?\n super || form_authenticity_token == request.headers['X-XSRF-TOKEN']\n end",
"def verified_request?\n super || form_authenticity_token == request.headers['X-XSRF-TOKEN']\n end",
"def verified_request?\n super || form_authenticity_token == request.headers['X-XSRF-TOKEN']\n end",
"def rails_check_csrf!\n rails_controller_instance.send(:verify_authenticity_token)\n end",
"def verified_request?\n\t\tsuper || form_authenticity_token == request.headers['X-XSRF-TOKEN']\n\tend",
"def rails_csrf_param\n rails_controller.request_forgery_protection_token\n end",
"def check_csrf?\n true\n end",
"def verify_csrf_token?\n false\n end",
"def check_csrf\n rails_check_csrf!\n end",
"def use_request_specific_csrf_tokens?\n csrf_options[:require_request_specific_tokens]\n end",
"def handle_unverified_request; end",
"def handle_unverified_request; end",
"def handle_unverified_request\n \n # By default this method raises ActionController::InvalidAuthenticityToken\n #redirect_to root_url\n end",
"def csrf=(_arg0); end",
"def clean_up_csrf?\n false\n end",
"def check_csrf\n rails_check_csrf!\n end",
"def before_request\n end",
"def form_authenticity_token\n \"foo\"\n end",
"def clean_up_csrf?\n true\n end",
"def clean_up_csrf?\n true\n end",
"def clean_up_csrf?\n false\n end",
"def csrf_params_hash\n return { request_forgery_protection_token => form_authenticity_token }\n end",
"def auth_token\n (protect_against_forgery? ? form_authenticity_token : nil)\n end",
"def handle_unverified_request\n true\n end",
"def handle_unverified_request\n true\n end",
"def masked_authenticity_token(session, form_options: T.unsafe(nil)); end",
"def handle_unverified_request\n if Rails.env.production?\n reset_session\n else\n raise ActionController::InvalidAuthenticityToken\n end\n end",
"def handle_unverified_request\n true\n end",
"def handle_unverified_request\n true\n end",
"def handle_unverified_request\n true\n end",
"def handle_unverified_request\n true\n end",
"def handle_unverified_request\n true\n end",
"def handle_unverified_request\n true\n end",
"def handle_unverified_request\n true\n end",
"def handle_unverified_request\n true\n end",
"def handle_unverified_request\n true\n end",
"def handle_unverified_request\n true\n end",
"def handle_unverified_request\n true\n end",
"def handle_unverified_request\n true\n end",
"def any_authenticity_token_valid?; end",
"def form_authenticity_token\n @form_authenticity_token ||= if !session.respond_to?(:session_id)\n raise InvalidAuthenticityToken, \"Request Forgery Protection requires a valid session. Use #allow_forgery_protection to disable it, or use a valid session.\"\n elsif request_forgery_protection_options[:secret]\n authenticity_token_from_session_id\n elsif session.respond_to?(:dbman) && session.dbman.respond_to?(:generate_digest)\n authenticity_token_from_cookie_session\n else\n raise InvalidAuthenticityToken, \"No :secret given to the #protect_from_forgery call. Set that or use a session store capable of generating its own keys (Cookie Session Store).\"\n end\n end",
"def verified_request?; end",
"def request_allowed?(request)\n true\n end",
"def password_reset_request\n end",
"def marked_for_same_origin_verification?; end",
"def security_enabled_request_state\n super\n end",
"def verify_csrf_token?(req, *)\n !IDEMPOTENT_HTTP_METHODS[req.request_method]\n end",
"def verify_authenticity_token\n super unless request_comes_from_facebook?\n end",
"def verified_request?\n\t\tsuper || valid_authenticity_token?(session, request.headers['X-XSRF-TOKEN'])\n\tend",
"def auth_csrf_token\n request.env['HTTP_X_AUTH_CSRF']\n end"
] |
[
"0.76337904",
"0.7546625",
"0.7545239",
"0.728618",
"0.7254646",
"0.72267616",
"0.7150694",
"0.7117463",
"0.711017",
"0.7095813",
"0.7085116",
"0.7084132",
"0.7084132",
"0.7084132",
"0.7084132",
"0.7084132",
"0.7084132",
"0.70564467",
"0.70140094",
"0.7009851",
"0.6961618",
"0.6961618",
"0.68930817",
"0.67778385",
"0.67142445",
"0.6697535",
"0.65658027",
"0.64281344",
"0.6414466",
"0.63684493",
"0.63250613",
"0.6305722",
"0.6305722",
"0.6305722",
"0.6304732",
"0.6269624",
"0.6241332",
"0.6239533",
"0.6239533",
"0.6212421",
"0.6187312",
"0.618365",
"0.6174663",
"0.61723447",
"0.61553246",
"0.6142451",
"0.6134814",
"0.6134814",
"0.61320484",
"0.6118887",
"0.6075919",
"0.6075919",
"0.6075919",
"0.6075919",
"0.6075024",
"0.6033302",
"0.60232323",
"0.6017666",
"0.6005948",
"0.5984026",
"0.5970675",
"0.5951892",
"0.5951892",
"0.59504634",
"0.59487504",
"0.59413624",
"0.5895622",
"0.5880421",
"0.5878703",
"0.58760256",
"0.58760256",
"0.5852909",
"0.58432984",
"0.5828255",
"0.58239704",
"0.58239704",
"0.5807376",
"0.5776665",
"0.57731587",
"0.57731587",
"0.57731587",
"0.57731587",
"0.57731587",
"0.57731587",
"0.57731587",
"0.57731587",
"0.57731587",
"0.57731587",
"0.57731587",
"0.57731587",
"0.5749223",
"0.5745229",
"0.57164425",
"0.5715669",
"0.57036513",
"0.57006454",
"0.5698588",
"0.56825644",
"0.56791204",
"0.5665022",
"0.5662179"
] |
0.0
|
-1
|
Included in the Logins concern
|
def index # This is what we'll need if we want our url/tags page to exist
@tags = Tag.all
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def logged_in\r\n end",
"def log_in\n end",
"def logging_in\n end",
"def logging_in\n \t\t\n \tend",
"def login; end",
"def require_login\n end",
"def logging_in\n current_user.absorb_from(guest_user)\n end",
"def login\n end",
"def sign_in\n trait()\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def logged_in_account\n unless logged_in?\n redirect_to login_path\n end\n \tend",
"def login\n self.login\n end",
"def user_authentication\n end",
"def login_instructions\n end",
"def auth\n end",
"def auth\n end",
"def sign_in\n\tend",
"def logging_in\n logger.debug \"ApplicationController:logging_in >>> \"\n current_user.transfer_data(guest_user)\n end",
"def sign_in\n\n end",
"def sign_in\n end",
"def sign_in_local\n __log_activity\n __debug_route\n end",
"def login\n\n end",
"def login\n\n end",
"def login\n update_parents\n super if defined? super\n end",
"def initialize login\n self.login = login\n end",
"def logged_in?\n end",
"def auth_store; end",
"def login\n\tend",
"def http_auth_login\n # FIXME: Implement\n end",
"def sign_in\n trait\n end",
"def authentication_statistics\n super\n end",
"def authenticated?; super; end",
"def logged_in_account\n unless logged_in?\n redirect_to login_path\n end\n end",
"def auth_trap_state\n super\n end",
"def log_on_user(user,session,cookies)\n raise NotImplementedError\n end",
"def needs_login?() false end",
"def signin\n end",
"def login_page\n end",
"def capable_login_auth?; end",
"def authentication_profile\n super\n end",
"def before_request\n self.login if require_login? && !@authenticating\n end",
"def login_attribute\n super\n end",
"def after_custom_authentication; end",
"def after_crowd_authentication\n end",
"def login\n self[:login]\n end",
"def login\n self[:login]\n end",
"def login\n self[:login]\n end",
"def login_choice\n end",
"def log()\n if user_signed_in?\n else\n \tredirect_to \"http://localhost:3000/users/sign_in\"\n end\n end",
"def login\n @user_login\n end",
"def log_on_cephuser(user,session,cookies)\n raise NotImplementedError\n end",
"def credentials; end",
"def credentials; end",
"def credentials; end",
"def credentials; end",
"def credentials; end",
"def authenticates_access\n include InstanceMethods\n end",
"def loggedIn\n @user = current_user\nend",
"def signingIn (authentication)\n\n if authentication.instance_of?(Authentications)\n user = Customer.where(:id => authentication.user_id).first\n session[:user_id] = user.id\n current_user.sign_in_count +=1\n current_user.last_sign_in_at = Time.now\n current_user.current_sign_in_at = Time.now\n current_user.last_sign_in_ip = request.remote_ip \n current_user.current_sign_in_ip = request.remote_ip \n current_user.save\n @@logingIn=0\n redirect_to root_path, :notice => \"Logged in successfully\"\n else\n @@logingIn=0\n redirect_to root_path, :notice => \"Sorry! You need to register first \"\n\n end\n\n\nend",
"def did_log_in\n self.last_logged_in_at = DateTime.now\n self.class.execute_without_timestamps { save }\n end",
"def loginpage\n end",
"def index\n @logins = Login.all\n #cookies[:current_user] = \"user\"\n login_user = Login.find_by_id(session[:login_id])\n end",
"def to_login_server\n MenuControllerContracts.invariant(self)\n @current_view = @views[4]\n MenuControllerContracts.invariant(self)\n end",
"def logged_in_any\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logging_in\n # For example:\n # guest_comments = guest_user.comments.all\n # guest_comments.each do |comment|\n # comment.user_id = current_user.id\n # comment.save!\n # end\n end",
"def authorization; end",
"def initialize\n @loggedin = false\n @cookie = nil\n end",
"def autenticathe_login!\n unless someone_is_logged_in?\n store_location\n flash[:danger] = \"Por favor, Inicie sesion.\"\n redirect_to welcome_path\n end\n end",
"def logged_in_band\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to band_login_url\n end\n end",
"def access_control\n \n end",
"def login\n make_login_call\n end",
"def logged_in_user\n unless logged_in?\n puts \"not logged in\"\n end\n end",
"def author_login\r\n user.login if user\r\n end",
"def show\n # while accesing a customer a user we'll be able to see the page with logins associated to \n # that concrete customer\n api = SaltEdge.new(ENV[\"salt_edge_app_id\"], ENV[\"salt_edge_secret\"], \"private.pem\")\n r = api.simple_request(\"GET\", \"https://www.saltedge.com/api/v4/logins/\")\n cust_id = current_user.customers.first.cust_id\n r[\"data\"].each do |login|\n if cust_id == login[\"customer_id\"]\n Login.where(log_id: login[\"id\"]).first_or_create do |log|\n log.provider_name = login[\"provider_name\"]\n log.customer_id = current_user.customers.first.id\n end\n end\n end \n @logins = @customer.logins\n end",
"def user_init; end",
"def set_log_in\n @log_in = LogIn.find(params[:id])\n end",
"def after_custom_authentication\n\n end",
"def signin\n\t\t\t# Author\n\t\t\tauthorize! :login, nil\n\t\tend",
"def active_for_authentication?; end",
"def active_for_authentication?; end",
"def logged_in\n unless customer_logged_in? || employee_logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to customer_login_url\n end\n end",
"def user_login\n unless logged_in?\n navigated_location #stores the location that was navigated before login\n flash[:alert]= \"You Must Be Log In Order To Access that Portion of the Site\" \n redirect_to login_path\n end\n end",
"def authenticate_once_state\n super\n end",
"def authenticate_user!\n store_location and raise NotLoggedIn unless logged_in?\n end",
"def logged_in\n logged_in_user != nil\n end",
"def logged_user_only\n unless logged_in?\n\t store_location\n\t flash[:danger] = \"Please log in!\"\n\t redirect_to login_url\n\t end\n end",
"def logoff()\n #This is a stub, used for indexing\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Veuillez svp vous connecter\"\n redirect_to connexion_url\n end\n end",
"def index\n @log_ins = LogIn.all\n end",
"def logged_in_user\n unless logged_in?\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Por favor Inicia Sesion.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Admin Access Only.\"\n redirect_to login_url\n \n end\n end",
"def authentication_method\n super\n end"
] |
[
"0.74480385",
"0.74322075",
"0.73933727",
"0.73253226",
"0.67111313",
"0.66492784",
"0.65092254",
"0.649095",
"0.64809084",
"0.6478524",
"0.6478524",
"0.6478524",
"0.6478524",
"0.6478524",
"0.6478524",
"0.6478524",
"0.6478524",
"0.6478524",
"0.6465449",
"0.645956",
"0.6453365",
"0.6448609",
"0.64296806",
"0.64296806",
"0.6421379",
"0.6410946",
"0.63900995",
"0.6387353",
"0.6386663",
"0.6380307",
"0.6380307",
"0.6374258",
"0.6329037",
"0.6326762",
"0.63229173",
"0.6322527",
"0.62875956",
"0.62853664",
"0.6275997",
"0.62646437",
"0.62562495",
"0.62364906",
"0.6186864",
"0.6182238",
"0.6177718",
"0.61595434",
"0.61551774",
"0.61446846",
"0.61316913",
"0.61236256",
"0.6120904",
"0.6117889",
"0.6068508",
"0.6068508",
"0.6068508",
"0.6054535",
"0.6050185",
"0.6044465",
"0.6025552",
"0.6012768",
"0.6012768",
"0.6012768",
"0.6012768",
"0.6012768",
"0.600503",
"0.59982955",
"0.5994793",
"0.59941345",
"0.5990459",
"0.59711313",
"0.5966074",
"0.5965046",
"0.59642005",
"0.5963565",
"0.59634477",
"0.5954005",
"0.59515256",
"0.5946125",
"0.593745",
"0.593529",
"0.5918083",
"0.5917532",
"0.59172124",
"0.5915198",
"0.5914571",
"0.5913541",
"0.5911549",
"0.5911549",
"0.5908394",
"0.5908041",
"0.59018195",
"0.59012955",
"0.5890181",
"0.58878434",
"0.5869391",
"0.58690435",
"0.58680016",
"0.5864933",
"0.58640516",
"0.5862795",
"0.5852187"
] |
0.0
|
-1
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.