query
stringlengths 7
9.55k
| document
stringlengths 10
363k
| metadata
dict | negatives
sequencelengths 0
101
| negative_scores
sequencelengths 0
101
| document_score
stringlengths 3
10
| document_rank
stringclasses 102
values |
---|---|---|---|---|---|---|
N Without this we can't easily and compactly display the file name and hash value | def to_s
return "#{name} (#{hash})"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def digest\n assert_file!\n Digest::SHA256.hexdigest(@name + Digest::SHA256.file(@path).to_s)\n end",
"def file_digest_key(stat)\n \"file_digest:#{compressed_path}:#{stat}\"\n end",
"def hash\n Digest::MD5.hexdigest(abs_filepath)[0..5]\n end",
"def hash\r\n # TODO what if file is empty?\r\n @hash ||= Digest::SHA1.file(File.join(@directory, @filename)).hexdigest\r\n end",
"def file_sha256\n Digest::SHA256.file(self).hexdigest\n end",
"def hash\n return (path + file_id.to_s).hash\n end",
"def filename\n [Digest::SHA1.hexdigest(file.read),file.extension].join('.') if original_filename\n end",
"def id(source_file)\n Digest::SHA1.hexdigest(source_file.filename)\n end",
"def id(source_file)\n Digest::SHA1.hexdigest(filename(source_file))\n end",
"def findSmallHash(f)\r\n return Digest::SHA1.file(f).hexdigest()\r\nend",
"def hash_to_file_name(hash)\n version = \"-#{hash[:version]}\" if hash[:version]\n classifier = \"-#{hash[:classifier]}\" if hash[:classifier]\n \"#{hash[:id]}#{version}#{classifier}.#{extract_type(hash[:type]) || DEFAULT_TYPE}\"\n end",
"def filename\n self.class.path(hash)\n end",
"def calculate_file_name(file_path,file_name)\n file_sha = Digest::SHA256.file(file_path)\n \"#{file_sha}_#{file_name}\"\n end",
"def file_sha1\n Digest::SHA1.file(self).hexdigest\n end",
"def filename\n \"#{Digest::SHA1.file(file.file).hexdigest}.png\" if original_filename\n end",
"def file_hash\n return @file_hash\n end",
"def get_file_hash(fullPath)\n contents = File.read(fullPath)\n fileHash = Digest::MD5.hexdigest(contents)\n return fileHash\nend",
"def hash_file(name, length)\n pieces = String.new\n file = ::File.open(name, 'r')\n pieces << Digest::SHA1.digest(file.read(length)) until file.eof?\n file.close\n pieces\n end",
"def filename\n author_hash = SHA1.new(author).to_s[0..4]\n hash = SHA1.new(name + author + timestamp +\n (log.nil? ? '' : log.gsub(/\\n/, '')) +\n (inverted? ? 't' : 'f'))\n \"#{timestamp}-#{author_hash}-#{hash}.gz\"\n end",
"def inspect\n \"#<HG Versioned File: #{to_s}>\"\n end",
"def fingerprint(filename)\n \"SHA256: \" + X509.fingerprint(\"SHA256\", Path.named_path(filename))\n end",
"def hash(pathname)\n ext = pathname.extname\n ext = ('' == ext || nil == ext) ? :none : ext.to_sym\n digest = Digest::MD5.hexdigest(File.read(pathname.to_s))\n @scanned[ext] ||= {}\n @scanned[ext][digest] ||= []\n @scanned[ext][digest] << pathname\n end",
"def digest\n Digest::MD5.file(file).hexdigest\n end",
"def fedora_shasum\n \"urn:sha1:#{Digest::SHA1.file(file_path)}\"\n end",
"def access_file_name\n @hash[\"AccessFileName\"]\n end",
"def hash_file(filename)\n file = File.read(filename)\n tlsh_hash(file.bytes)\n end",
"def digest_filename(filename)\n digest = Digest::SHA256.digest(filename.to_s)\n Base64.urlsafe_encode64(digest, padding: false)\n end",
"def file_name\n\t\treturn 'st' + student_id.to_s + 'pr' + problem_id.to_s + 'so' + id.to_s\n\tend",
"def info(filename, nohash = nil)\n\tf = filename\n\tif test_file(f)\n\t\th = nohash ? (nil) : (Digest::SHA1.hexdigest(File.read(f)))\n\t\treturn [File.mtime(f), File.stat(f).mode.to_s(8).to_i, h]\n\tend\n\treturn []\nend",
"def genhash(absolute_filename)\n HDB.debug and puts \"Absolute filename #{absolute_filename}\"\n if File.file?(absolute_filename)\n HDB.debug and puts \"Digesting\"\n hash = Digest::SHA512.new\n # Save atime\n PRESERVE_ATIME and atime = File.stat(absolute_filename).atime\n File.open(absolute_filename, 'r') do |fh|\n while buffer = fh.read(BUFSIZE)\n hash << buffer\n end\n end\n # Reset atime, preserve mtime\n PRESERVE_ATIME and File.utime(atime, File.stat(absolute_filename).mtime, absolute_filename)\n return hash.to_s\n else\n HDB.debug and puts \"Not a file\"\n return NAHASH\n end\n end",
"def hash_file path, hash_store\r\n\thexdigest = HASH_DIGEST.hexdigest(open(path, 'rb') { |io| io.read })\r\n\thash_store[hexdigest] << path\r\nend",
"def digest\n OpenSSL::Digest::SHA256.file(path).hexdigest\n end",
"def generate_uniq_filename_from(data)\n if data.respond_to?(:path)\n Digest::MD5.hexdigest(data.path)\n elsif data.respond_to?(:read)\n chunk = data.read(1024)\n data.rewind\n Digest::MD5.hexdigest(chunk)\n else\n Digest::MD5.hexdigest(data)\n end\n end",
"def generate_uniq_filename_from(data)\n if data.respond_to?(:path)\n Digest::MD5.hexdigest(data.path)\n elsif data.respond_to?(:read)\n chunk = data.read(1024)\n data.rewind\n Digest::MD5.hexdigest(chunk)\n else\n Digest::MD5.hexdigest(data)\n end\n end",
"def get_filename(text)\n if text =~ /[^\\w\\.\\-_]/\n Digest::SHA256.hexdigest(text)\n else\n text\n end\nend",
"def filehash(filepath)\n sha1 = Digest::SHA1.new\n File.open(filepath) do|file|\n buffer = ''\n # Read the file 512 bytes at a time\n while not file.eof\n file.read(512, buffer)\n sha1.update(buffer)\n end\n end\n return sha1.to_s\n end",
"def file_digest(file)\n # Get the actual file by #tempfile if the file is an `ActionDispatch::Http::UploadedFile`.\n Digest::SHA256.file(file.try(:tempfile) || file).hexdigest\n end",
"def file_id\n # If the file name exceeds the maximum length, then generate an MD5 to truncate the end of the file name.\n result = \"#{@node}_#{@environment}\"\n if result.size > MAX_FILE_ID_SIZE\n # Truncate it, but add a unique ID in it.\n result = \"-#{Digest::MD5.hexdigest(result)[0..7]}\"\n result = \"#{@node}_#{@environment}\"[0..MAX_FILE_ID_SIZE - result.size - 1] + result\n end\n result\n end",
"def art_file\n \"#{Digest::SHA1.hexdigest(\"#{artist_name}/#{album_name}\")}.png\"\n end",
"def filename\n @name ||= \"#{md5}.#{file.extension}\" if original_filename.present?\n end",
"def inspect\n #N Without this output, we won't know what class it belongs to or what the relative path and file content hash is\n return \"RelativePathWithHash[#{relativePath}, #{hash}]\"\n end",
"def access_file_name\n end",
"def file_hash=(value)\n @file_hash = value\n end",
"def getHash element\n\tfile = File.new(element)\n\thash = Digest::SHA256.file file\n\tfile.close\n\treturn hash.hexdigest \n\tend",
"def compute_hash( path )\n res = '0'\n autorelease_pool { res = NSData.sha1FromContentsOfFile(path) }\n res\n end",
"def hash\n raise NotImplementedError.new(\"hash() must be implemented by subclasses of AbstractVersionedFile.\")\n end",
"def filename\n DateTime.now.strftime('%Q') + Digest::MD5.hexdigest(original_filename) + original_filename if original_filename\n end",
"def content_of file:, for_sha:\n result = output_of \"git show #{for_sha}:#{file}\"\n result = '' if result == default_file_content_for(file)\n result\nend",
"def hashFromFile(file, auth, algo)\n u = URI::NI.buildFromFile(auth, file, nil, algo)\n type=`file --mime-type #{file}`.split[1]\n u.contentType!(type)\n u\nend",
"def summarize_file path\n \"#<File:#{path} (#{File.size(path)} bytes)>\"\n end",
"def show_file_version\n\t\t\tputs \" Version: #{@elf_version.to_h}\"\n\t\tend",
"def file_md5\n Digest::MD5.file(self).hexdigest\n end",
"def hash\n @relative_name.hash\n end",
"def get_image_name(user_hash)\n image_name = user_hash[\"image\"][:filename]\nend",
"def files_hash\n @files_hash\n end",
"def filename\n File.join(%w{public finished-jobs},Digest::SHA1.hexdigest(url)+\".txt\")\n end",
"def generate_sha(file)\n\n sha1 = Digest::SHA1.file file\n return sha1\n\nend",
"def summary\n [hexdigest, @buffer.size]\n end",
"def contents_hash(paths)\n return if paths.nil?\n\n paths = paths.compact.select { |path| File.file?(path) }\n return if paths.empty?\n # rubocop:disable GitHub/InsecureHashAlgorithm\n paths.sort\n .reduce(Digest::XXHash64.new, :file)\n .digest\n .to_s(16) # convert to hex\n # rubocop:enable GitHub/InsecureHashAlgorithm\n end",
"def hash\n [file_info, output_path, encoding, recognize_lists, leading_spaces, trailing_spaces, enable_pagination].hash\n end",
"def ssn\n file_number\n end",
"def name() @filename end",
"def index_signature\n Digest::SHA256.new(@gems.keys.sort.join(',')).to_s\n end",
"def etag\n stat = ::File.stat(@path)\n '\"' + Digest::SHA1.hexdigest(stat.ino.to_s + stat.size.to_s + stat.mtime.to_s) + '\"'\n end",
"def digest\n @digest ||= begin\n Digest::SHA1.hexdigest \"defaults-#{NilavuStylesheets.last_file_updated}\"\n end\n end",
"def inspect\n \"File: #{@name} #{@ext}\"\n end",
"def file_ids_hash\n if @file_ids_hash.blank?\n # load the file sha's from cache if possible\n cache_file = File.join(self.path,'.loopoff')\n if File.exists?(cache_file)\n @file_ids_hash = YAML.load(File.read(cache_file))\n else\n # build it\n @file_ids_hash = {}\n self.loopoff_file_names.each do |f|\n @file_ids_hash[File.basename(f)] = Grit::GitRuby::Internal::LooseStorage.calculate_sha(File.read(f),'blob')\n end\n # write the cache\n File.open(cache_file,'w') do |f|\n f.puts YAML.dump(@file_ids_hash) \n end\n end \n end\n @file_ids_hash\n end",
"def file_digest(path)\n if stat = self.stat(path)\n self.stat_digest(path, stat)\n end\n end",
"def digest_file( x)\n path = requested_file( x[:request] )\n if File.exist?(path) && !File.directory?(path)\n Digest::MD5.hexdigest(File.read(path))\n else\n nil\n end\n end",
"def fullname\n \"#@filename\\##@revision\"\n end",
"def file_content_column(record)\n value = \"-\"\n if !record.file_content.nil? && record.file_content.mime_type != \"UNKNOWN\"\n value = \"sha1: \" + record.file_content.sha1.to_s\n if !record.file_content.data.nil?\n value = link_to(h(\"sha1: \" + record.file_content.sha1.to_s), { :controller => \"file_contents\", :action => \"download_data\", :id => record.file_content.id }, :confirm => \"WARNING: This file potentially contains malware.\\nNOTE: When extracting, use the password: '\" + Configuration.find_retry(:name => \"file_content.zip.password\", :namespace => \"FileContent\").to_s + \"'\\nProceed with download?\")\n end\n end\n return value\n end",
"def md5; Digest::MD5.file(fname).hexdigest; end",
"def file_digest(pathname)\n key = pathname.to_s\n if @digests.key?(key)\n @digests[key]\n else\n @digests[key] = super\n end\n end",
"def block_hash\n\t\tdigest = Digest::SHA2.new\n\n\t\tdigest << '%d' % [ self.index ]\n\t\tdigest << self.timestamp.strftime( '%s%N' )\n\t\tdigest << self.payload\n\t\tdigest << self.payload_hash\n\t\tdigest << self.proof.to_s\n\t\tdigest << self.previous_hash\n\t\t\n\t\treturn digest.hexdigest\n\tend",
"def filename\n \"#{secure_token(10)}.#{file.extension}\" if original_filename.present?\n end",
"def findLargeHash(f)\r\n incr_digest = Digest::SHA1.new()\r\n file = File.open(f, \"rb\")\r\n count = 0\r\n file.each_line do |line|\r\n if count == 1\r\n incr_digest << line\r\n end\r\n count = count + 1\r\n if count >= 2\r\n break\r\n end\r\n end\r\n return incr_digest.hexdigest + File.size(f).to_s(16)\r\nend",
"def file_fingerprint(options=nil)\n temp_options(options) if options\n fingerprint = Digest::MD5.hexdigest(all_files.map! { |path| \"#{File.mtime(path).to_i}\" }.join + @options.to_s)\n reset_options if options\n fingerprint\n end",
"def file_name\n @file_name\n end",
"def file name\n \n end",
"def file_name\n @file_name ||= File.basename tree\n end",
"def filename()\n #This is a stub, used for indexing\n end",
"def hash\n fullname.hash\n end",
"def find_dups(hash)\n open(\"dups.txt\", 'w') do |f|\n f.puts '=== Identical Files ===' \n hash.each_value do |a|\n next if a.length == 1\n a.each { |fname| f << (\"\\t\" + fname) }\n f << \"\\n\\n\"\n end\n end\nend",
"def to_s\n return \"%s %08x %s\" % [@sha512hash, @mtime.to_i, @archive_filename]\n end",
"def file_name\n self.file_file_name\n end",
"def hexdigest\n self.class.hexdigest_for(path)\n end",
"def digest\n digest = ''\n @entries.each { |entry| digest << entry.digest << ' ' }\n digest\n end",
"def label_for(file)\n if file.is_a?(Hyrax::UploadedFile) # filename not present for uncached remote file!\n file.uploader.filename.present? ? file.uploader.filename : File.basename(Addressable::URI.parse(file.file_url).path)\n elsif file.respond_to?(:original_name) # e.g. Hydra::Derivatives::IoDecorator\n file.original_name\n elsif file_set.import_url.present?\n # This path is taken when file is a Tempfile (e.g. from ImportUrlJob)\n File.basename(Addressable::URI.parse(file_set.import_url).path)\n else\n File.basename(file)\n end\n end",
"def file_list(hash)\n\nend",
"def file_list(hash)\n\nend",
"def filekey(value)\n merge(filekey: value.to_s)\n end",
"def square_name\n \"#{file}#{rank}\".to_sym\n end",
"def generate_filename(filename)\n\t\t# Just some entropy to prevent collisions... not trying\n\t\t# to protect any information.\n\t\tfilename = \"#{filename}:#{SecureRandom.hex(10)}:#{Time.now}\"\n\n\t\tdigest = Digest::SHA256.new\n\t\treturn digest.hexdigest filename\n\tend",
"def file_name\n return @file_name\n end",
"def file_name\n return @file_name\n end",
"def hash\n name.hash ^ version.hash\n end",
"def public_filename(thumbnail = nil)\n [ self.class.ssh_config[:url].to_s %\n Technoweenie::AttachmentFu::Backends::SshBackend.cycled_asset_id,\n base_path(thumbnail ? thumbnail_class : self) { |path|\n ERB::Util.url_encode(path)\n },\n ERB::Util.url_encode(thumbnail_name_for(thumbnail)) ].\n reject(&:blank?).join(\"/\")\n end",
"def full_filename(for_file)\n # 兼容 #{mounted_as}_fingerprint\n if version_name.present? && model.try(:\"#{mounted_as}_fingerprint\")\n [version_name, model.send(:\"#{mounted_as}_fingerprint\"), for_file].compact.join('_')\n elsif version_name.present?\n [version_name, model.send(:\"#{mounted_as}_identifier\")].compact.join('_')\n else\n super\n end\n end",
"def sha1\n RunLoop::Directory.directory_digest(path)\n end",
"def get_digest(file, version)\n # Make a hash with each individual file as a key, with the appropriate digest as value.\n inverted = get_state(version).invert\n my_files = {}\n inverted.each do |files, digest|\n files.each do |i_file|\n my_files[i_file] = digest\n end\n end\n # Now see if the requested file is actually here.\n unless my_files.key?(file)\n raise OcflTools::Errors::FileMissingFromVersionState, \"Get_digest can't find requested file #{file} in version #{version}.\"\n end\n\n my_files[file]\n end",
"def file_name(token)\n FileHelper.file_cache_name(file_cache_dir, token)\n end"
] | [
"0.693466",
"0.6923132",
"0.685502",
"0.6758931",
"0.6752252",
"0.67483485",
"0.67191595",
"0.65860593",
"0.65592265",
"0.65478104",
"0.653117",
"0.6510235",
"0.6506937",
"0.6460275",
"0.6407951",
"0.6388847",
"0.63875854",
"0.6363617",
"0.62643",
"0.6218101",
"0.6215845",
"0.6181402",
"0.6181347",
"0.61730057",
"0.61691415",
"0.61465454",
"0.6144972",
"0.6135701",
"0.61206543",
"0.61186886",
"0.6117011",
"0.6110991",
"0.61006474",
"0.61006474",
"0.6088801",
"0.60879606",
"0.60781366",
"0.60750765",
"0.60675204",
"0.605897",
"0.60539377",
"0.60352325",
"0.6006872",
"0.5984773",
"0.5974109",
"0.5969123",
"0.5960894",
"0.5950701",
"0.5940654",
"0.59368324",
"0.59326",
"0.59078544",
"0.5896445",
"0.58923477",
"0.58852303",
"0.5882888",
"0.58816576",
"0.5872337",
"0.58633363",
"0.58555865",
"0.5852137",
"0.5840258",
"0.5840082",
"0.5837897",
"0.5836593",
"0.5831237",
"0.582601",
"0.5816336",
"0.5812325",
"0.5812226",
"0.581168",
"0.58010614",
"0.57986647",
"0.5794909",
"0.57818604",
"0.5773667",
"0.5770801",
"0.5766209",
"0.5760155",
"0.575003",
"0.5749282",
"0.57485247",
"0.5747742",
"0.5741214",
"0.574075",
"0.57380545",
"0.57376194",
"0.5737048",
"0.5734527",
"0.5734527",
"0.5732162",
"0.5730225",
"0.57197416",
"0.5719286",
"0.5719286",
"0.57169193",
"0.5711582",
"0.5709656",
"0.57013136",
"0.56994826",
"0.569751"
] | 0.0 | -1 |
The relative name of this file in the content tree (relative to the base dir) N Without this we can't easily reconstruct the relative path as a single string | def relativePath
return (parentPathElements + [name]).join("/")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def base_name\n File.basename @relative_name\n end",
"def file_name\n @file_name ||= File.basename tree\n end",
"def relative_path\n name\n end",
"def full_name\n @relative_name\n end",
"def full_name\n @relative_name\n end",
"def name\n file.partition(base).last.gsub(/[_\\/]/, \" \").strip\n end",
"def file_name\n return unless @file\n\n @file.absolute_name\n end",
"def file_name\n File.basename @path\n end",
"def name\n name = nil\n if root?\n name = path.to_s\n else\n name = @path.basename.to_s\n end\n return name\n end",
"def base_name\n File.basename @absolute_name\n end",
"def relative(file)\n if File.directory?(full_path)\n file[full_path.length+1..-1]\n else\n File.basename(file)\n end\n end",
"def file_name\n \"/\" + current_file.path.split('/').pop\n end",
"def friendly_name\n Pathname.new(self.relative_path).basename.to_s\n end",
"def name\n File.basename(@root)\n end",
"def inspect\n File.basename @__path\n end",
"def name\n @name ||= File.basename(relative_file, '.png')\n end",
"def parent_file_name\n @parent ? @parent.base_name : '(unknown)'\n end",
"def relative_path\n @relative_path ||= File.join(@dir, @name)\n end",
"def base_name\n File.basename(file_name)\n end",
"def file_name_with_path\n root_path.dup + file_name\n end",
"def name\n File.basename(self.path)\n end",
"def name\n File.basename(absolute_path)\n end",
"def name\n File.basename(@path)\n end",
"def name\n File.basename(@path)\n end",
"def name\n File.basename(@path)\n end",
"def rel_path(file)\n File.dirname(file)\n end",
"def file_name\n File.basename(file_path)\n end",
"def name()\n basename.to_s\n end",
"def relativePath\n #N Without this the path elements won't be joined together with \"/\" to get the relative path as a single string\n return @pathElements.join(\"/\")\n end",
"def relative_path\n @relative_path ||= PathManager.join(@dir, @name).delete_prefix(\"/\")\n end",
"def relative_path\n @relative_path ||= File.join(*[@dir, @name].map(&:to_s).reject(&:empty?)).delete_prefix(\"/\")\n end",
"def full_path\n entity = Entity.find( self.id )\n full_name = entity.name\n while !( entity.parent.nil? )\n entity = entity.parent\n full_name = entity.name + \"-\" + full_name\n end\n return full_name\n end",
"def full_filename(for_file)\n #[remote_process!, for_file].join(\".\")\n for_file\n end",
"def name\n ::File.basename(path)\n end",
"def path\n File.join(@base, @name)\n end",
"def path_name\n @parent ? \"#{@parent.path_name}.#{name}\" : name\n end",
"def path_name\n str = name.dup\n str << '/' if is_dir\n str = parent.path_name + str if parent\n str\n end",
"def path\n File.join(@base, @name)\n end",
"def base\n File.basename @filename, extension_with_delimiter\n end",
"def get_corresponding_file_base_name\n return File.basename(@URL)\n end",
"def name\n File.basename(path)\n end",
"def to_partial_path\n ::File.basename(super)\n end",
"def path()\n return ::File.join(@root, @name)\n end",
"def page_name\n basename = File.basename @relative_name\n basename =~ /\\.(rb|rdoc|txt|md)$/i\n\n $` || basename\n end",
"def name\n @name ||= ::File.basename(@path)\n end",
"def path_name\n return unless @basename\n\n parts = @basename.split('.')\n parts.pop if parts.length > 1 && parts.last =~ /^\\w+$/\n parts.pop if parts.last =~ /^\\d+$/\n parts.join('.')\n end",
"def to_relative_path\n File.join('.', to.path(identify).to_s)\n end",
"def full_path\n File.join(@path, @name)\n end",
"def original_filename\n File.basename(self.path)\n end",
"def original_filename\n File.basename(self.path)\n end",
"def original_filename\n File.basename(self.path)\n end",
"def name\n @name ||= File.basename(path)\n end",
"def filename\n if super.present?\n @name ||= Digest::MD5.hexdigest(File.dirname(current_path))\n \"#{@name}#{File.extname(original_filename).downcase}\"\n end\n end",
"def filename\n if super.present?\n @name ||= Digest::MD5.hexdigest(File.dirname(current_path))\n \"#{@name}#{File.extname(original_filename).downcase}\"\n end\n end",
"def full_defined_path()\n return nil if is_root?\n return name if parent.is_root?\n return \"#{parent.full_defined_path}.#{name}\"\n end",
"def relative_directory\n return '' unless @directory_root\n @path - @directory_root - name\n end",
"def filename\n\t\treturn self.fullpath.split('/').last\n\tend",
"def name\n file.basename('.rb').to_s if file\n end",
"def name\n file.basename('.rb').to_s if file\n end",
"def base file, ext; return File.basename file, ext end",
"def base file, ext; return File.basename file, ext end",
"def base()\n sub_ext('').basename.to_s\n end",
"def name\n @name ||= File.basename(path)\n end",
"def name\n @name ||= File.basename(path)\n end",
"def filename\n File.basename( fullpath )\n end",
"def original_filename\n File.basename(@file_path)\n end",
"def filename\n \"#{folder_id}#{File.extname(super)}\"\n end",
"def file_name(at_path = nil)\n at_path ||= @full_path\n File.basename at_path, '.*'\n end",
"def file_name(at_path = nil)\n at_path ||= @full_path\n File.basename at_path, '.*'\n end",
"def filename\n File.basename(path)\n end",
"def filename\n tmp_path = self.path\n if self.partial\n tmp_path.gsub(/([^\\/]+)\\z/, '_\\1')\n else\n tmp_path\n end\n end",
"def filename\n @file.basename.to_s\n end",
"def relative_path\n must_be File\n Pathname.new(self.full_path).relative_path_from(Pathname.new(Dir.pwd)).to_s\n end",
"def path\n \"#{@parent.path}##{@name}\"\n end",
"def path\n \"#{@parent.path}##{@name}\"\n end",
"def fullname\n @fullname ||= ::File.join(location, loadpath, filename + (extension || ''))\n end",
"def file_name\n \"#{@file_name}.#{extension}\"\n end",
"def file_name\n # file = full_name\n # file = file.gsub('::', '/')\n # file = file.gsub('#' , '/')\n # file = file.gsub('.' , '-')\n # #file = File.join(output, file + '.html')\n # file\n WebRI.entry_to_path(full_name)\n end",
"def path\n name + extension\n end",
"def rootname filename\n if (last_dot_idx = filename.rindex '.')\n (filename.index '/', last_dot_idx) ? filename : (filename.slice 0, last_dot_idx)\n else\n filename\n end\n end",
"def access_file_name\n end",
"def file_name\n name.underscore\n end",
"def relative_src(filename, dir=nil)\n file = expand_src filename, dir\n base = Pathname.new File.dirname path_info\n Pathname.new(file).relative_path_from(base).to_s\n end",
"def relroot\n Pathname.new(File.expand_path(path)).\n relative_path_from(Pathname.new(File.expand_path(root))).to_s\n end",
"def raw_script_name\n File.basename($0)\n end",
"def filename\n path.split(File::Separator).join(\"_\")\n end",
"def tree_base\n tree.gsub File.extname( tree ), ''\n end",
"def relative_path(filename)\n pieces = split_filename(File.expand_path(filename))\n File.join(pieces[@mount_dir_pieces.size..-1])\n end",
"def path\n real_path = Pathname.new(root).realpath.to_s\n full_path.sub(%r{^#{real_path}/}, '')\n end",
"def name\n @name ||= @project.dir.path.match(/.*\\/(.*)$/).nil? ? \"unknown\" : $1\n end",
"def path\n \"%s/%s\" % [dirname, filename]\n end",
"def relative_path(filename)\n @mount_dir_pieces ||= @mount_dir.size\n pieces = split_filename(File.expand_path(filename))\n File.join(pieces[@mount_dir_pieces..-1])\n end",
"def shortName\n name = @dir_ent['name'][0, 8].strip\n ext = @dir_ent['name'][8, 3].strip\n name += \".\" + ext if ext != \"\"\n return name\n end",
"def previous_fullname\n return nil if @revision == 1\n \"#@filename\\##{@revision-1}\"\n end",
"def filename\n @basename + PAGE_FILE_EXT\n end",
"def _relative_path\n if _is_root?\n nil\n else\n self.class.name.demodulize.underscore\n end\n end",
"def relative_pathname\n @relative_pathname ||= Pathname.new(relativize_root_path(pathname))\n end",
"def default_name\n path.dirname.basename.to_s\n end",
"def name\n @name ||= File.basename(file).chomp(File.extname(file))\n end",
"def filename\n unless @filename\n @filename = @path.basename.to_s\n end\n\n @filename\n end"
] | [
"0.73514366",
"0.7159663",
"0.71327853",
"0.68912554",
"0.68912554",
"0.68154967",
"0.6811721",
"0.67829454",
"0.6760152",
"0.67581767",
"0.6756996",
"0.6729433",
"0.6613176",
"0.6596809",
"0.6593314",
"0.6582467",
"0.65686816",
"0.6567662",
"0.6563027",
"0.65217596",
"0.651069",
"0.6500525",
"0.6490034",
"0.6490034",
"0.6490034",
"0.645422",
"0.6426577",
"0.6420164",
"0.64151245",
"0.64076895",
"0.6385861",
"0.6372191",
"0.636211",
"0.6360217",
"0.63476926",
"0.63381547",
"0.6335851",
"0.6330888",
"0.63134575",
"0.62965864",
"0.62840015",
"0.62816006",
"0.6276311",
"0.6256729",
"0.62533957",
"0.6237411",
"0.622895",
"0.6216492",
"0.6207825",
"0.6207825",
"0.6207825",
"0.61955756",
"0.6195141",
"0.6195141",
"0.61884415",
"0.6184107",
"0.6179448",
"0.6174274",
"0.6174274",
"0.6172106",
"0.6172106",
"0.6171445",
"0.6169521",
"0.6169521",
"0.6160201",
"0.6141584",
"0.61291814",
"0.6128595",
"0.6128595",
"0.6112045",
"0.61085165",
"0.610388",
"0.6100191",
"0.6097825",
"0.6097825",
"0.60958105",
"0.60867316",
"0.60727054",
"0.60720164",
"0.6056088",
"0.60537726",
"0.60403246",
"0.6039869",
"0.60336906",
"0.60238045",
"0.602186",
"0.6010638",
"0.60089815",
"0.600462",
"0.59917104",
"0.59743875",
"0.59695184",
"0.5953566",
"0.5950239",
"0.59499866",
"0.5947412",
"0.59470975",
"0.59451073",
"0.5944926",
"0.5940898"
] | 0.6708049 | 12 |
N Without this we won't be able to initialise information about this directory based on knowing it's name and it's relative path, ready to have information about files and subdirectories added to it, and ready to be marked for deletion or copying as required. | def initialize(name = nil, parentPathElements = nil)
#N Without this we won't remember the name of the directory
@name = name
#N Without this we won't know the path elements of the sub-directory (within the directory tree) containing this directory
@pathElements = name == nil ? [] : parentPathElements + [name]
#N Without this we won't be ready to add files to the list of files in this directory
@files = []
#N Without this we won't be ready to add directories to the list of sub-directories immediately contained in this directory
@dirs = []
#N Without this we won't be ready to add files so we can look them up by name
@fileByName = {}
#N Without this we won't be ready to add immediate sub-directories so we can look them up by name
@dirByName = {}
#N Without this the directory object won't be in a default state of _not_ to be copied
@copyDestination = nil
#N Without this the directory object won't be in a default state of _not_ to be deleted
@toBeDeleted = false
#N Without this the directory object won't be in a default state of not yet having set the timestamp
@time = nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_dirs; end",
"def directory(dir); end",
"def populate(level)\n\t\tinitialize\n\t\tself.name = level\n\t\tself.path = \"#{self.path}/#{level}\"\n\n\t\tDir.new(base_dir = \"#{self.path}\").each do |name|\n\t\tpath = \"#{base_dir}/#{name}\"\n\t\t\tif name !~ /^\\./\n\t\t\t\tif FileTest.directory?(path)\n\t\t\t\t\ttemp_dir = Directory.new\n\t\t\t\t\ttemp_dir.populate(\"#{level}/#{name}\")\n\t\t\t\t\tself.directories << temp_dir\n\t\t\t\telse\n\t\t\t\t\tself.files << name\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def directories; end",
"def directories; end",
"def initialize \n @dirpath = self.class.dirname\n\n if Dir.exist? @dirpath\n raise \"Directory is not readable\" unless File.readable? @dirpath\n raise \"Directory is not writable\" unless File.writable? @dirpath\n else \n Dir.mdkir @dirpath\n raise \"Directory does not exist and could not be created\" unlesss Dir.exist? @dirpath\n end \n\n refresh_cached_files\n end",
"def initialize(name, hash, parentPathElements)\n #N Without this we won't remember the name of the file\n @name = name\n #N Without this we won't know the hash of the contents of the file\n @hash = hash\n #N Without this we won't know the path elements of the sub-directory (within the directory tree) containing the file\n @parentPathElements = parentPathElements\n #N Without this the file object won't be in a default state of _not_ to be copied\n @copyDestination = nil\n #N Without this the file object won't be in a default state of _not_ to be deleted\n @toBeDeleted = false\n end",
"def init_existing\n return unless current_directory?\n\n FolderTree.for_path linked_path, root: directory, limit: folder_limit\n end",
"def make_child_entry(name)\n if CHILDREN.include?(name)\n return nil unless root_dir\n\n return root_dir.child(name)\n end\n\n paths = (child_paths[name] || []).select { |path| File.exist?(path) }\n if paths.size == 0\n return NonexistentFSObject.new(name, self)\n end\n\n case name\n when \"acls\"\n dirs = paths.map { |path| AclsDir.new(name, self, path) }\n when \"client_keys\"\n dirs = paths.map { |path| ClientKeysDir.new(name, self, path) }\n when \"clients\"\n dirs = paths.map { |path| ClientsDir.new(name, self, path) }\n when \"containers\"\n dirs = paths.map { |path| ContainersDir.new(name, self, path) }\n when \"cookbooks\"\n if versioned_cookbooks\n dirs = paths.map { |path| VersionedCookbooksDir.new(name, self, path) }\n else\n dirs = paths.map { |path| CookbooksDir.new(name, self, path) }\n end\n when \"cookbook_artifacts\"\n dirs = paths.map { |path| CookbookArtifactsDir.new(name, self, path) }\n when \"data_bags\"\n dirs = paths.map { |path| DataBagsDir.new(name, self, path) }\n when \"environments\"\n dirs = paths.map { |path| EnvironmentsDir.new(name, self, path) }\n when \"groups\"\n dirs = paths.map { |path| GroupsDir.new(name, self, path) }\n when \"nodes\"\n dirs = paths.map { |path| NodesDir.new(name, self, path) }\n when \"policy_groups\"\n dirs = paths.map { |path| PolicyGroupsDir.new(name, self, path) }\n when \"policies\"\n dirs = paths.map { |path| PoliciesDir.new(name, self, path) }\n when \"roles\"\n dirs = paths.map { |path| RolesDir.new(name, self, path) }\n when \"users\"\n dirs = paths.map { |path| UsersDir.new(name, self, path) }\n else\n raise \"Unknown top level path #{name}\"\n end\n MultiplexedDir.new(dirs)\n end",
"def initialize_directory(dir)\n Dir.mkdir(dir) unless Dir.exist?(dir)\n dir\nend",
"def root_dir\n existing_paths = root_paths.select { |path| File.exist?(path) }\n if existing_paths.size > 0\n MultiplexedDir.new(existing_paths.map do |path|\n dir = FileSystemEntry.new(name, parent, path)\n dir.write_pretty_json = !!write_pretty_json\n dir\n end)\n end\n end",
"def directory; end",
"def directory; end",
"def dirs; end",
"def dirs; end",
"def initialize_copy(source)\n super\n\n @files = {}\n @directories = {}\n @parent = nil\n\n source.directories.map(&:dup).each do |new_directory|\n add_directory(new_directory)\n end\n\n source.files.map(&:dup).each do |new_file|\n add_file(new_file)\n end\n end",
"def directory_hash(path, name=nil)\n data = {:folder => (name || path.split(\"/\").last)}\n data[:children] = children = []\n Dir.foreach(path) do |entry|\n next if (entry == '..' || entry == '.' || entry == 'yamproject.json' || entry == '.DS_Store')\n full_path = File.join(path, entry)\n if File.directory?(full_path)\n children << directory_hash(full_path, entry)\n else\n children << entry\n end\n end\n return data\nend",
"def build_directory_tree\n\n # Add the user's config directories to the \"ignore_dir\" option because these are all things we won't need printed in a NavTree.\n options.ignore_dir << app.config[:js_dir]\n options.ignore_dir << app.config[:css_dir]\n options.ignore_dir << app.config[:fonts_dir]\n options.ignore_dir << app.config[:images_dir]\n options.ignore_dir << app.config[:helpers_dir]\n options.ignore_dir << app.config[:layouts_dir]\n options.ignore_dir << app.config[:partials_dir]\n\n # Build a hash out of our directory information\n tree_hash = scan_directory(app.config[:source], options)\n\n # Write our directory tree to file as YAML.\n FileUtils.mkdir_p(app.config[:data_dir])\n data_path = app.config[:data_dir] + '/' + options.data_file\n IO.write(data_path, YAML::dump(tree_hash))\n end",
"def directories_at_path(_path, with_attrs: true)\n raise NotImplementedError\n end",
"def directory_hash(path, name=nil, exclude = [])\n exclude.concat(['..', '.', '.git', '__MACOSX', '.DS_Store'])\n data = {'name' => (name || path), 'type' => 'folder'}\n data[:children] = children = []\n Dir.entries(path).sort.each do |entry|\n # Dir.entries(path).each\n # puts entry\n next if exclude.include?(entry)\n full_path = File.join(path, entry)\n if File.directory?(full_path)\n if entry.include?(\"credit app\")\n kids = Dir.entries(full_path)\n kids.reject! {|x|exclude.include?(x)}\n if kids.length >= 1\n # can add a kids.each loop here if mom ever wants more than one credit app\n child_path = File.join(full_path, kids[0])\n true_path = child_path.partition(\"app/assets/images/\")[2]\n link = ActionController::Base.helpers.image_path(true_path)\n # puts full_path\n # puts link\n entry = entry.split('.')[0]\n if entry.include?('--')\n entry = entry.split('--')[1]\n end\n entry = entry.upcase\n\n children << \"<li class='category'>CREDIT APP<li class='kid'><a href='#{link}'>#{entry}</a></li></li>\"\n else\n # gotta fix these two somehow\n children << \"<li><a href='#'>NO APP</a></li>\"\n end\n elsif entry.include?('flipbook')\n # Dir.entries(full_path).each do |flipbook|\n # next if exclude.include?(flipbook)\n # if File.directory?(full_path)\n name = entry.split(\"-\")[1]\n name = name.upcase\n if @account==\"UNDER ARMOUR\" && full_path.include?('UA GOLF')\n uasub = 'UA GOLF'\n elsif @account==\"UNDER ARMOUR\" && full_path.include?('UA FITNESS')\n uasub = 'UA FITNESS'\n end\n\n linky = view_context.link_to name, controller: 'catalogues', action: 'flipbook', id: @account, subid: entry, :data => { :uaname => uasub }\n children << \"<li class='kid'>#{linky}</li>\"\n # catfolder = full_path.split('/flipbook')[0]\n # end\n\n # end\n elsif entry.include?(\"toplevel\")\n # replace toplevel with a better check, something like if parent = pictures\n entryname=entry.split('-')[0].upcase\n children << \"<li class='kid'><a href='/catalogues/#{@account}/pictures/#{entry}'>#{entryname}</a></li>\"\n\n else\n children << directory_hash(full_path, entry)\n end\n else\n # true_path = full_path.partition(\"app/assets/images/\")[2]\n\n true_path = full_path.partition(\"app/assets/images/\")[2]\n # puts true_path\n link = ActionController::Base.helpers.image_path(true_path)\n\n # puts link\n entry = entry.split('.')[0]\n if entry.include?('--')\n entry = entry.split('--')[1]\n end\n # this is where final kids are created\n entry = entry.upcase\n children << \"<li class='kid'><a href='#{link}'>#{entry}</a></li>\"\n end\n end\n return data\n end",
"def add_directory(path, parent_baton,\n copyfrom_path, copyfrom_revision)\n # Output 'A' to indicate that the directory was added.\n # Also put a trailing slash since it's a directory.\n puts \"A #{path}/\"\n\n # The directory has been printed -- don't print it again.\n [false, path]\n end",
"def initialize(parent, directory)\n @parent = parent\n @data = {}\n @pathname = (\n case parent\n when Pathname\n parent + directory\n when FileStore\n parent.pathname + directory\n else\n Pathname.new(directory)\n end\n )\n end",
"def ensure_directory_exists\r\n dir = File.dirname(full_path_from_current_attributes)\r\n FileUtils.mkdir_p(dir) unless File.exists?(dir)\r\n end",
"def collect_in_dir directory, recursive = true\n if not File.readable? directory\n puts \"#{directory} not readable. Skipping.\" if @verbose\n else\n directory += \"/\" if not directory.end_with? \"/\"\n if File.directory? directory\n files = Dir.entries directory\n files.reject! {|d| d.match /^\\.{1,2}$/} # ignore parent and self links\n files.map! { |f| directory + f }\n files.each do |fname|\n if File.directory?(fname) and recursive\n collect_in_dir fname\n elsif not File.readable? fname\n puts \"#{fname} not readable.Skipping.\" if @verbose\n elsif File.file? fname and File.extname(fname) == @extension # if no directory\n pkg_info = parse_pkg fname\n @files[fname] = pkg_info if pkg_info\n end\n end\n end\n end\n end",
"def initialize(name)\n @path, @name = nil\n\n if File.directory?(name)\n @path, @name = name, File.basename(name)\n\n elsif Main.respond_to?(:extensions_path)\n @name = name\n [Main.extensions_path].flatten.each do |dir|\n next unless @path.nil?\n @path = File.join(dir, name)\n @path = nil unless File.directory?(@path)\n end\n end\n\n raise ExtensionNotFound unless File.directory?(@path.to_s)\n end",
"def dir; end",
"def dir; end",
"def dir; end",
"def dir\n calc_dir(@basename)\n end",
"def initialize root_dir\n find_files root_dir\n end",
"def hook_add_directories\n @flavor.class.after_add_directories do |directories|\n directories.each do |dir|\n actions_taken << \"create directory #{dir}\"\n end\n end\n end",
"def add_dir(path)\n Dir.foreach(@new_base + path) do |fname|\n path_fname = path + fname\n next if fname == '.' || fname == '..' || filter_fname(path_fname)\n type = File.ftype(@new_base + path_fname).to_sym\n @entries << [path_fname, type, :added]\n add_dir(path_fname + '/') if type == :directory\n end\n end",
"def prepare(directory, name = T.unsafe(nil)); end",
"def dir\n @dir ||= File.join Hoboku.data_dir, name\n end",
"def ensure_dir_data(dir)\r\n unless @dirs[dir].key?(:files)\r\n files = {}\r\n dirs = {}\r\n Dir.glob(\"#{dir}/*\", File::FNM_DOTMATCH).each do |file|\r\n base_name = File.basename(file)\r\n if File.directory?(file)\r\n dirs[base_name] = nil if base_name != '.' && base_name != '..'\r\n else\r\n files[base_name] = nil\r\n end\r\n end\r\n @dirs[dir] = {\r\n files: files,\r\n dirs: dirs\r\n }\r\n end\r\n end",
"def relative_directory; end",
"def dir=(value)\n @data['info']['name'] = value if @data['info'].key?('files')\n end",
"def initialize(path)\n @path = path\n @real_path = File.expand_path(@path)\n @dir_path = File.dirname(@real_path)\n @dir = File.directory?(@real_path)\n @name = File.basename(@real_path)\n unless @dir\n @ext = File.extname(@name, conf[:options][:dots])\n @name.gsub!(Regexp.new('.' << Regexp.escape(@ext) << '$'), '') unless @ext.empty?\n @level = 0\n else\n @level = @real_path.split('/').size\n end\n end",
"def directory?() end",
"def walk\n FileTreeProfiler.monitor_report(:profile, :dir, path)\n @children = []\n Dir.foreach(path) do |entry|\n next if (entry == '..' || entry == '.')\n full_path = ::File.join(path, entry)\n if ::File.directory?(full_path)\n children.push DirFile.new(self, entry)\n else\n children.push DataFile.new(self, entry)\n end\n end\n end",
"def relative_directory\n return '' unless @directory_root\n @path - @directory_root - name\n end",
"def dir(*) end",
"def parent_dirs(file); end",
"def collect\n return if stat.ftype == \"directory\"\n self\n end",
"def file_get_initialization(structure = ENV[\"HOME\"]) # this is linux specific for now\n @file_information = {} # {\"/directory\"=>[\"file\"], \"/directory/directory\"=>[\"file\", \"file\"]\n files = [] \n directory = \"\"\n directories = [] \n things = structure.split('/')\n things.each do |thing|\n if thing == \"\"\n directories.push(\"/root\")\n else\n directory = \"#{directory}/#{thing}\" \n @current_directory = directory\n directories.push(\"#{directory}\") if File.directory?(\"#{directory}\")\n end\n end \n return directories\n end",
"def initialize\n @dir = N\n end",
"def dir\n @directory\n end",
"def setup()\n create_directories\n end",
"def add_directory(name)\n full_path = File.join(path, name)\n\n Dir.mkdir(full_path) unless File.directory?(full_path)\n\n self.class.new(full_path)\n end",
"def load_instance(sub_paths, sub_paths_index, size, modification_time)\n # initialize dirs and files.\n @dirs = {} unless @dirs\n @files = {} unless @files\n if sub_paths.size-1 == sub_paths_index\n # Add File case - index points to last entry - leaf case.\n file_stat = FileStat.new(sub_paths[sub_paths_index], FileStatEnum::STABLE, size, modification_time, true)\n add_file(file_stat)\n else\n # Add Dir to tree if not present. index points to new dir path.\n dir_stat = @dirs[sub_paths[sub_paths_index]]\n #create new dir if not exist\n unless dir_stat\n dir_stat = DirStat.new(sub_paths[sub_paths_index])\n add_dir(dir_stat)\n end\n # continue recursive call on tree with next sub path index\n dir_stat.load_instance(sub_paths, sub_paths_index+1, size, modification_time)\n end\n end",
"def retrieve_dirs(_base, dir, dot_dirs); end",
"def keep_dirs; end",
"def directory_record_for(path)\n\t\t\tRecord.new(:directory, path.relative_path, metadata_for(:directory, path))\n\t\tend",
"def file_type; 'directory' end",
"def relative_directory\n @relative_directory ||= \"_#{label}\"\n end",
"def new_dirs\n @new_dirs ||= new_files.flat_map { |file| parent_dirs(file) }.to_set\n end",
"def initialize(dir)\n @dir = Pathname.new(dir)\n end",
"def dir\n @data['info']['name']\n end",
"def create_directories\n directory '.', './'\n end",
"def directories\n directory_entries.map{ |f| FileObject[path, f] }\n end",
"def directory\r\n \[email protected]\r\n end",
"def recurse_local\n result = perform_recursion(self[:path])\n return {} unless result\n result.inject({}) do |hash, meta|\n next hash if meta.relative_path == \".\"\n\n hash[meta.relative_path] = newchild(meta.relative_path)\n hash\n end\n end",
"def prepare\n FileUtils.mkdir_p(@base_dir)\n end",
"def initialize root=\".\", verbose = true, ext=\".java\"\n @root = File.absolute_path root\n @verbose = verbose\n @files = Hash.new # files found\n @extension = ext\n end",
"def dir(name, &block)\n path = @path + name\n unless ::File.directory?(path)\n FileUtils.mkdir_p(path)\n @ctx.add(path)\n end\n d = self.class.new(@ctx, path)\n d.instance_eval(&block) if block_given?\n d\n end",
"def ensure_meta_info_dir_exists!\n FileUtils.mkdir_p(RubyFileReader::Reader.meta_info_dir_pathname)\n end",
"def create_user_directories\n #Directories\n avatar = \"#{Rails.root}/data/avatars/#{resource.id}\"\n push = \"#{Rails.root}/data/push/#{resource.id}\"\n passes = \"#{Rails.root}/data/passes/#{resource.id}\"\n coredata = \"#{Rails.root}/data/coredata/#{resource.id}\"\n #Avatar Upload Pictures\n Dir.mkdir(avatar) unless File.exists?(avatar)\n #Push Notification Certificates\n Dir.mkdir(push) unless File.exists?(push)\n #Avatar Passbook\n Dir.mkdir(passes) unless File.exists?(passes)\n #Core Data\n Dir.mkdir(coredata) unless File.exists?(coredata)\n end",
"def initialize(uid)\n @dl_queue = Queue.new\n fList = []\n ftable = Account[uid].fileinfos\n ftable.each do |file|\n fList[file.id] = file\n end\n ftable.each do |file|\n if file.parent_id == file.id\n @root_dir = file\n else\n fList[file.parent_id].add_file(file)\n end\n end\n if ftable.empty?\n @root_dir = CreateFileinfo.call(name: 'ROOT', account_id: uid, portion: 0)\n @root_dir.parent_id = @root_dir.id\n @root_dir.save\n # fList[@root_dir.id] = @root_dir\n end\n end",
"def scan_directory(path, options, name=nil)\n\n data = {}\n Dir.foreach(path) do |filename|\n\n # Check to see if we should skip this file. We skip invisible files (starts with \".\") and ignored files.\n next if (filename[0] == '.')\n next if (filename == '..' || filename == '.')\n next if options.ignore_files.include? filename\n\n full_path = File.join(path, filename)\n if File.directory?(full_path)\n\n # This item is a directory. Check to see if we should ignore this directory.\n next if options.ignore_dir.include? filename\n\n # Loop through the method again.\n position = get_directory_display_order(full_path)\n data.store(\"#{'%04d' % position}-\" + filename.gsub(' ', '%20'), scan_directory(full_path, options, filename))\n\n else\n # This item is a file.\n if !options.ext_whitelist.empty?\n\n # Skip any whitelisted extensions.\n next unless options.ext_whitelist.include? File.extname(filename)\n end\n\n original_path = path.sub(/^#{app.config[:source]}/, '') + '/' + filename\n\n # Get this resource so we can figure out the display order\n this_resource = resource_from_value(original_path)\n position = get_file_display_order(this_resource)\n\n data.store(\"#{'%04d' % position}-\" + filename.gsub(' ', '%20'), original_path.gsub(' ', '%20'))\n end\n end\n\n # Return this level's data as a hash sorted by keys.\n return Hash[data.sort]\n end",
"def directories\n @directories ||= []\n end",
"def directories\n @directories ||= []\n end",
"def directory_index\n end",
"def initialize\n super(DIR_NAME, :hidden => true)\n end",
"def ensure_dir(path)\n directory path do\n action :create\n recursive true\n end\nend",
"def make_directory_tree\n project_tmp = \"/tmp/#{@package_name}\"\n @scratch = \"#{project_tmp}/#{@title}\"\n @working_tree = {\n 'scripts' => \"#{@scratch}/scripts\",\n 'resources' => \"#{@scratch}/resources\",\n 'working' => \"#{@scratch}/root\",\n 'payload' => \"#{@scratch}/payload\",\n }\n puts \"Cleaning Tree: #{project_tmp}\"\n FileUtils.rm_rf(project_tmp)\n @working_tree.each do |key,val|\n puts \"Creating: #{val}\"\n FileUtils.mkdir_p(val)\n end\n File.open(\"#{@scratch}/#{'prototype.plist'}\", \"w+\") do |f|\n f.write(ERB.new(File.read('tasks/templates/prototype.plist.erb')).result())\n end\n File.open(\"#{@working_tree[\"scripts\"]}/preflight\", \"w+\") do |f|\n f.write(ERB.new(File.read('ext/osx/preflight.erb')).result())\n end\nend",
"def register path\n FileUtils.mkdir_p(path)\n s = File.stat path\n if Pile.where(:inode => s.ino).empty?\n w = Pile.new\n w.inode = s.ino\n w.save!\n dir = File.dirname(path)\n $L.debug dir\n register dir\n end\n end",
"def initialize(fname, basedir=nil, datafile=nil, indexfile=nil)\n base = basedir || Dir.pwd\n @fname = File.absolute_path(fname, base)\n if @fname == fname\n raise \"CONSTRUCTED WITH ABSOLUTE PATH #{fname}\"\n end\n indexdir = File.join base, HIDDEN_DIR, \"index\"\n datadir = File.join base, HIDDEN_DIR, \"data\"\n @indexfile = indexfile || (File.join indexdir, fname)\n @datafile = datafile || (File.join datadir, fname)\n [indexdir, datadir].each do |d|\n unless File.directory?(d)\n FileUtils.mkdir_p(d)\n end\n end\n end",
"def watchable_dirs; end",
"def dir? ; directory? ? self : nil ; end",
"def create\n create_directories\n end",
"def initialize(path)\n @path = path\n @dirs = {}\n @files = {}\n @non_utf8_paths = {} # Hash: [\"path\" -> true|false]\n @symlinks = {} # Hash: [[server, link file name]] -> \" target file name\"]\n # indicates if path EXISTS in file system.\n # If true, file will not be removed during removed_unmarked_paths phase.\n @marked = false\n\n end",
"def scan_dirs(indir)\n @acs_dirs = {}\n Dir.chdir(indir)\n all_dirs = Dir.glob('*').select { |f| File.directory? f }\n all_dirs.each do |subdir|\n @acs_dirs[subdir] = HRRTACSDir.new(File.join(indir, subdir))\n @acs_dirs[subdir].create_hrrt_files\n end\n end",
"def simple_dir(name)\n\treturn D.new(@cvsroot, self, @path + '/' + name)\n end",
"def visit_location(name)\n\t\tif File.exists?(name) \n\t\t\tif (File.directory?(name)) \n\t\t\t\tDir.foreach(name) { |child| visit_location(name + \"/\" + child) if child != \".\" && child != \"..\" }\n\t\t\telse\n\t\t\t\tvisit_file(name)\n\t\t\tend\n\t\telse\n\t\t\tSTDERR.puts \"#{name} doesn't exist.\"\n\t\tend\n\tend",
"def initialize(dir, **opts)\n raise Errors::NoDirectoryError, dir: dir unless File.directory? dir\n\n @options = { nesting_levels: 2, folder_limit: 10_000 }.update(opts)\n @directory = dir\n @current_directory = File.join @options.fetch(:link_location, directory),\n CURRENT_STORE_PATH\n\n @tree = init_existing || init_new(nesting_levels)\n link_target\n end",
"def directories\n @@directories ||= default_directories\n end",
"def gen_sub_directories\n\t\[email protected]\n\tend",
"def gen_sub_directories\n\t\[email protected]\n\tend",
"def directories\n directory.directoires\n end",
"def initialize(config)\n super(config)\n @max_folder_depth = 20\n @implements_working_uidplus = true\n # unselectable parent folders are removed automatically\n end",
"def dir\n Dir.new(self)\n end",
"def prepare_path\n log(\"prepare_path\")\n FileUtils.mkdir_p(path) unless Dir.exist?(path)\n rescue Exception => e\n log(\"prepare_path\", \"ERROR #{e}\")\n notify( \"reader.error\", { :error => \"prepare_path\" } )\n end",
"def read_directories(dir = T.unsafe(nil)); end",
"def gen_sub_directories\n @outputdir.mkpath\n end",
"def file_get_more_information(directory) \n @files = []\n @file_information = {} # {\"/directory\"=>[\"file\"], \"/directory/directory\"=>[\"file\", \"file\"]\n directory = \"#{@current_directory}/#{directory}\" unless @current_directory == \"\"\n @current_directory = directory \n Dir.chdir(\"#{directory}\") \n Dir.foreach(\"#{directory}\") { |d| @files.push(d) unless d == \".\" || d == \"..\" }\n @file_information.store(directory, @files)\n @files = []\n return @file_information\n end",
"def create_directory(branch, destination, name, author)\n destination ||= ''\n repo = satelliterepo\n repo.checkout(branch) unless repo.empty?\n file = File.join(name, '.gitignore')\n file = File.join(destination, file) unless destination.empty?\n absolute = File.join(satellitedir, file)\n FileUtils.mkdir_p File.dirname(absolute)\n FileUtils.touch(absolute)\n repo.index.add file\n message = \"Add directory #{name}\"\n commit_id = satellite_commit(repo, message, author, branch)\n fake_thumbnail commit_id\n repo.checkout('master')\n File.dirname(file)\n end",
"def create_directory(branch, destination, name, author)\n destination ||= ''\n repo = satelliterepo\n repo.checkout(branch) unless repo.empty?\n file = File.join(name, '.gitignore')\n file = File.join(destination, file) unless destination.empty?\n absolute = File.join(satellitedir, file)\n FileUtils.mkdir_p File.dirname(absolute)\n FileUtils.touch(absolute)\n repo.index.add file\n message = \"Add directory #{name}\"\n commit_id = satellite_commit(repo, message, author, branch)\n fake_thumbnail commit_id\n repo.checkout('master')\n File.dirname(file)\n end",
"def for(file_or_dir); end",
"def file_dir # :nodoc:\n nil\n end",
"def build_directory root\n root += \"/\" if not root.end_with? \"/\" # add backslash for later concatenation\n if not caller[0] =~ /.*build_directory.*/\n puts \"Building in #{root + @name}.\"\n puts \"Warning. No files in this package tree.\" if file_count == 0\n end\n Dir.mkdir(root + @name) if not File.exist? root + @name # make root dir if not already present\n @files.each do |file|\n puts \"Copying file #{File.basename file} to #{root + @name}.\" if @verbose\n begin\n if @verbose and File.exists? root + @name\n puts \"File already present.\"\n end\n cp file, root + @name \n rescue ArgumentError # raised if files are identical\n puts \"Warning: Can't copy #{File.basename file}. Source and destination are identical.\"\n end\n end\n @subpackages.each_value do |p| # recursively build directory tree\n p.build_directory root + @name\n end\n end"
] | [
"0.67366225",
"0.630066",
"0.62976193",
"0.6225253",
"0.6225253",
"0.6178601",
"0.6106406",
"0.6095938",
"0.59985054",
"0.5994428",
"0.59929293",
"0.5990757",
"0.5990757",
"0.5982805",
"0.5982805",
"0.5953122",
"0.59180796",
"0.5862592",
"0.58610743",
"0.58389884",
"0.5837092",
"0.5809076",
"0.5772135",
"0.57704014",
"0.5760626",
"0.5756602",
"0.5756602",
"0.5756602",
"0.5754123",
"0.575088",
"0.57464135",
"0.573401",
"0.571921",
"0.5701864",
"0.5668154",
"0.56677985",
"0.5664129",
"0.5662755",
"0.56609327",
"0.56559145",
"0.56554437",
"0.56546915",
"0.5652095",
"0.56457233",
"0.5641812",
"0.56403327",
"0.5634098",
"0.56340975",
"0.56273997",
"0.5623228",
"0.5607839",
"0.56040275",
"0.5603066",
"0.5602054",
"0.5597828",
"0.55803204",
"0.5570701",
"0.55627793",
"0.55568296",
"0.5555571",
"0.5546105",
"0.55422324",
"0.55383915",
"0.5537459",
"0.5534799",
"0.5531831",
"0.55270576",
"0.5526905",
"0.5524047",
"0.5514795",
"0.5514795",
"0.55128974",
"0.5509506",
"0.5508662",
"0.550502",
"0.5504162",
"0.5502718",
"0.5502258",
"0.54876435",
"0.5482931",
"0.54789424",
"0.5454479",
"0.5453887",
"0.5450964",
"0.54497707",
"0.54477155",
"0.5429347",
"0.5429347",
"0.5424951",
"0.54215485",
"0.5421475",
"0.54191417",
"0.54177046",
"0.5416718",
"0.5415696",
"0.5410003",
"0.5410003",
"0.5398301",
"0.5394261",
"0.5391058"
] | 0.7310212 | 0 |
mark this directory to be copied to a destination directory N Without this we can't mark a directory to be copied to a directory on a remote system | def markToCopy(destinationDirectory)
#N Without this it won't be marked for copying
@copyDestination = destinationDirectory
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def markToCopy(destinationDirectory)\n #N Without this we won't remember that the file is to be copied to the destination directory\n @copyDestination = destinationDirectory\n end",
"def markCopyOperations(destinationDir)\n #N Without this we can't loop over the immediate sub-directories to determine how each one needs to be marked for copying\n for dir in dirs\n #N Without this we won't have the corresponding sub-directory in the other directory with the same name as this sub-directory (if it exists)\n destinationSubDir = destinationDir.getDir(dir.name)\n #N Without this check, we won't be able to correctly process a sub-directory based on whether or not one with the same name exists in the other directory\n if destinationSubDir != nil\n #N Without this, files and directories missing or changed from the other sub-directory (which does exist) won't get copied\n dir.markCopyOperations(destinationSubDir)\n else\n #N Without this, the corresponding missing sub-directory in the other directory won't get updated from this sub-directory\n dir.markToCopy(destinationDir)\n end\n end\n #N Without this we can't loop over the files to determine how each one needs to be marked for copying\n for file in files\n #N Without this we won't have the corresponding file in the other directory with the same name as this file (if it exists)\n destinationFile = destinationDir.getFile(file.name)\n #N Without this check, this file will get copied, even if it doesn't need to be (it only needs to be if it is missing, or the hash is different)\n if destinationFile == nil or destinationFile.hash != file.hash\n #N Without this, a file that is missing or changed won't get copied (even though it needs to be)\n file.markToCopy(destinationDir)\n end\n end\n end",
"def copy_to!(dest)\n Pow(dest).parent.create_directory\n copy_to(dest)\n end",
"def copy_folder_ind\n create_process(process: \"COPY_FOLDER\")\n end",
"def preform_copy_directory\n @destination_directories.each do |destination|\n @sources.each do |source|\n write_mode = 'w'\n new_path = Pathname.new(destination.to_s).join(source.basename)\n # Check if the specified file is a directory\n if new_path.directory?\n return false if get_input(\"Destination path '\" + new_path.to_s + \"' is a directory. (S)kip the file or (C)ancel: \", ['s','c']) == 'c'\n next\n end\n # Copy the file\n return false unless copy_file(source, new_path)\n end\n end\n return true\n end",
"def copy_to_folder=(value)\n @copy_to_folder = value\n end",
"def move_to!(dest)\n Pow(dest).parent.create_directory\n move_to(dest)\n end",
"def cp_dir(src, dst)\n puts \"#{cmd_color('copying')} #{dir_color(src)}\"\n puts \" -> #{dir_color(dst)}\"\n Find.find(src) do |fn|\n next if fn =~ /\\/\\./\n r = fn[src.size..-1]\n if File.directory? fn\n mkdir File.join(dst,r) unless File.exist? File.join(dst,r)\n else\n cp(fn, File.join(dst,r))\n end\n end\nend",
"def chown(p0, p1) end",
"def copyLocalFileToRemoteDirectory(sourcePath, destinationPath, dryRun)\n #N Without this, the copy command won't be run at all\n sshAndScp.copyLocalFileToRemoteDirectory(sourcePath, destinationPath, dryRun)\n end",
"def move_disks(n, src, dest, remain)\n return if n <= 0\n move_disks n - 1, src, remain, dest\n move_disk src, dest\n move_disks n - 1, remain, dest, src\n end",
"def copy_directory(source, destination)\n FileUtils.cp_r(FileSyncer.glob(\"#{source}/*\"), destination)\n end",
"def copy_directory(source, destination)\n FileUtils.cp_r(FileSyncer.glob(\"#{source}/*\"), destination)\n end",
"def copyLocalToRemoteDirectory(sourcePath, destinationPath, dryRun)\n #N Without this, the copy command won't be run at all\n sshAndScp.copyLocalToRemoteDirectory(sourcePath, destinationPath, dryRun)\n end",
"def mark_as_copied(file)\n cmd = cmd(\"setlabel\", [ file, COPIED ])\n system(cmd)\nend",
"def update_copied_remote_file(file, copy)\n # the remote has a file that has been copied or moved from copy[file] to file.\n # file is also destination.\n src = copy[file]\n \n # If the user doen't even have the source, then we apparently renamed a directory.\n if !(working_changeset.include?(file2))\n directory nil, file, src, remote.flags(file)\n elsif remote.include? file2\n # If the remote also has the source, then it was copied, not moved\n merge src, file, file, flag_merge(src, file, src), false\n else\n # If the source is gone, it was moved. Hence that little \"true\" at the end there.\n merge src, file, file, flag_merge(src, file, src), true\n end\n end",
"def move_to(n)\n cd(n)\n end",
"def copyLocalToRemoteDirectory(sourcePath, destinationPath, dryRun)\n #N Without this, the external SCP application won't actually be run to copy the directory\n executeCommand(\"#{@scpCommandString} -r #{sourcePath} #{userAtHost}:#{destinationPath}\", dryRun)\n end",
"def set_owner\n return unless owner || group\n chown = command? 'chown'\n\n return unless chown\n\n cmd = [chown, '-R', \"#{owner}:#{group}\", destination_path]\n logger.debug { \"Running command: #{cmd.join ' '}\" }\n system(*cmd)\n end",
"def sync(srcDir, dstDir)\n end",
"def cp(src, dst, owner = nil, mode = nil)\n FileUtils.cp_r(src, dst, :preserve => true, :verbose => verbose?)\n if owner && !File.symlink?(dst) \n chown(dst, owner) \n end\n if mode\n chmod(dst, mode)\n end\n end",
"def copyLocalToRemoteDirectory(sourcePath, destinationPath, dryRun)\n #N Without this there won't be a description of the copy operation that can be displayed to the user as feedback\n description = \"SCP: copy directory #{sourcePath} to #{user}@#{host}:#{destinationPath}\"\n #N Without this the user won't see the echoed description\n puts description\n #N Without this check, the files will be copied even if it is only meant to be a dry run.\n if not dryRun\n #N Without this, the files won't actually be copied.\n scpConnection.upload!(sourcePath, destinationPath, :recursive => true)\n end\n end",
"def cp_r(src, dest, options = {})\r\n fu_check_options options, OPT_TABLE['cp_r']\r\n fu_output_message \"cp -r#{options[:preserve] ? 'p' : ''}#{options[:remove_destination] ? ' --remove-destination' : ''} #{[src,dest].flatten.join ' '}\" if options[:verbose]\r\n return if options[:noop]\r\n options[:dereference_root] = true unless options.key?(:dereference_root)\r\n fu_each_src_dest(src, dest) do |s, d|\r\n copy_entry s, d, options[:preserve], options[:dereference_root], options[:remove_destination]\r\n end\r\n end",
"def cp_r(src, dest, options = {})\r\n fu_check_options options, OPT_TABLE['cp_r']\r\n fu_output_message \"cp -r#{options[:preserve] ? 'p' : ''}#{options[:remove_destination] ? ' --remove-destination' : ''} #{[src,dest].flatten.join ' '}\" if options[:verbose]\r\n return if options[:noop]\r\n options[:dereference_root] = true unless options.key?(:dereference_root)\r\n fu_each_src_dest(src, dest) do |s, d|\r\n copy_entry s, d, options[:preserve], options[:dereference_root], options[:remove_destination]\r\n end\r\n end",
"def copy(dest_path, overwrite = false, depth = nil)\n NotImplemented\n end",
"def force_copy\n add option: \"-force-copy\"\n end",
"def rsync_to(source, target, dest, port = 22, extra_flags = [\"--ignore-existing\"])\n rsync = find_program_on_path('rsync')\n flags = \"-rHlv --no-perms --no-owner --no-group\"\n unless extra_flags.empty?\n flags << \" \" << extra_flags.join(\" \")\n end\n ex(\"#{rsync} -e '#{ssh_command(port)}' #{flags} #{source} #{target}:#{dest}\")\n end",
"def chown(path, owner); raise NotImplementedError; end",
"def copy_perms(src, dst)\n stat = File.stat(src)\n File.chmod(stat.mode, dst)\n end",
"def local_copy(source, target)\n FileUtils.mkpath(File.dirname(target))\n FileUtils.copy(source, \"#{target}.in_progress\")\n FileUtils.move(\"#{target}.in_progress\", target)\n end",
"def install(source, target, options={})\n nest_opts(options[:backup], :mv => true) do |opts|\n only_if _file?(target) do\n backup target, opts\n end\n end\n \n nest_opts(options[:directory]) do |opts|\n directory File.dirname(target), opts\n end\n \n cp source, target\n chmod options[:mode], target\n chown options[:user], options[:group], target\n\nend",
"def notify_file_cp(src, dst)\r\n if @files.key?(src)\r\n @files[dst] = @files[src].clone\r\n else\r\n @files[src] = { exist: true }\r\n @files[dst] = { exist: true }\r\n end\r\n register_file_in_dirs(dst)\r\n end",
"def cp_with_mkdir(src, dst, owner = nil, mode = nil)\n mkdir_if_necessary(File.dirname(dst))\n cp(src, dst, owner, mode)\n end",
"def copyLocalFileToRemoteDirectory(sourcePath, destinationPath, dryRun)\n #N Without this, the external SCP application won't actually be run to copy the file\n executeCommand(\"#{@scpCommandString} #{sourcePath} #{userAtHost}:#{destinationPath}\", dryRun)\n end",
"def install_overwrite!\n\t\t\t# This may not happen because for a directory entry, an existing\n\t\t\t# target is either current (if it's a directory or a symlink to a\n\t\t\t# directory) or blocking (it it's anything else), and both must\n\t\t\t# be checked before calling this method.\n\t\t\traise \"Trying to overwrite a directory\"\n\t\tend",
"def copy_to(destination, name=nil)\n parent = {'parent' => {'id' => destination.id}}\n parent.merge!('name' => name) if name\n\n RubyBox::Folder.new(@session, post(folder_method(:copy), parent))\n end",
"def preform_copy_file\n @destination_files.each do |destination|\n copy_file(@sources.pop, destination)\n end\n end",
"def cp srcpath, dstpath\n end",
"def move_folder_ind\n create_process(process: \"MOVE_FOLDER\")\n end",
"def atomic_symlink(src, dest)\n raise ArgumentError.new(\"#{src} is not a directory\") unless File.directory?(src)\n say_status :symlink, \"from #{src} to #{dest}\"\n tmp = \"#{dest}-new-#{rand(2**32)}\"\n # Make a temporary symlink\n File.symlink(src, tmp)\n # Atomically rename the symlink, possibly overwriting an existing symlink\n File.rename(tmp, dest)\n end",
"def destination(dest); end",
"def destination(dest); end",
"def move_directory(directory,target)\n log_new(\"move directory -> #{File.basename(directory)}\")\n \n if File.exists? \"#{target}/#{File.basename(directory)}\"\n log(\"warning dst directory exists: \\'#{File.basename(directory)}\\'\")\n else \n # if the directory does not exist it is created\n FileUtils.mkdir_p(target,$options) if not File.directory? target\n FileUtils.mv(directory,target,$options) if ( (File.dirname directory) != target.gsub(/\\/$/,'')) \n symlink_on_move(directory,target)\n end\nend",
"def replicate_dir(f)\n out_original = f.sub($queue,$original)\n out_watermarked = f.sub($queue,$watermarked)\n if !File.exist?(out_original) && !File.exist?(out_watermarked)\n FileUtils.mkdir(out_original)\n FileUtils.mkdir(out_watermarked) \n end\nend",
"def directory(file, remote_file, file_dest, flags)\n @actions << Action::DirectoryAction.new(file, remote_file, file_dest, flags)\n end",
"def remote_deploy_directory(from_directory, to_directory)\n execute :mkdir, \"-p #{to_directory}\"\n Dir.foreach(from_directory) do |file|\n next if file == '.' or file == '..'\n path = \"#{from_directory}#{File::SEPARATOR}#{file}\"\n if File.directory?(path)\n remote_deploy_directory(path,\"#{to_directory}#{File::SEPARATOR}#{file}\")\n else\n remote_deploy(path,\"#{to_directory}#{File::SEPARATOR}#{file}\")\n end\n end\n end",
"def cp_to(filename, mounted_dest) # Always returns the destination as an explicit location relative to the mount directory\n dest = File.join(@mount_dir, mounted_dest )#, File.basename(filename))\n FileUtils.mkdir_p(dest)\n FileUtils.cp( filename, dest, :preserve => true)\n File.join(dest, File.basename(filename))\n end",
"def copy(command)\n src = clean_up(command[1])\n dest = clean_up(command[2])\n pp @client.files.copy(src, dest)\n end",
"def move( branch, newdn )\n\t\tsource_rdn, source_parent_dn = branch.split_dn( 2 )\n\t\tnew_rdn, new_parent_dn = newdn.split( /\\s*,\\s*/, 2 )\n\n\t\tif new_parent_dn.nil?\n\t\t\tnew_parent_dn = source_parent_dn\n\t\t\tnewdn = [new_rdn, new_parent_dn].join(',')\n\t\tend\n\n\t\tif new_parent_dn != source_parent_dn\n\t\t\traise Treequel::Error,\n\t\t\t\t\"can't (yet) move an entry to a new parent\"\n\t\tend\n\n\t\tself.log.debug \"Modrdn (move): %p -> %p within %p\" % [ source_rdn, new_rdn, source_parent_dn ]\n\n\t\tself.conn.modrdn( branch.dn, new_rdn, true )\n\t\tbranch.dn = newdn\n\tend",
"def make_copy(src, dest)\n#\tcommandz(\"cp -p #{src} #{dest}\")\n\n\t#Now with Ruby :)\n\tFileUtils.cp(\"#{src}\", \"#{dest}\", :preserve => true )\nend",
"def copy(destination, file, folder = './downloads')\n FileUtils.mkdir_p(File.dirname(\"#{destination}/#{file}\"))\n FileUtils.cp_r(\"#{folder}/#{file}\", \"#{destination}/#{file}\")\n end",
"def scp_set_folder_perms(remote_folder)\n # set proper permissions for remote host (allowing for client override)\n puts(\" -> setting remote ownership on host #{server_ip} folder #{remote_folder}\") if is_verbose or is_dryrun\n $stdout.flush\n output, exit_code1 = ssh_exec(\"chown -R #{ssh_owner_ug} #{remote_folder}\")\n puts(\"ERR: #{output}\") unless exit_code == 0\n\n output, exit_code2 = ssh_exec(\"chmod -R #{ssh_ugw_perm} #{remote_folder}\")\n puts(\"ERR: #{output}\") unless exit_code == 0\n (exit_code1 == 0) and (exit_code2 == 0)\n end",
"def copy(src,target)\n mkdir_p target if ! File.exist?(target)\n sh 'cp ' + src + '/* ' + target\nend",
"def action_chown\n if @tuser == nil\n Chef::Log::fatal \"target user need to be provided to perform chown\"\n elsif (!dir_exists?(@path))\n Chef::Log::Error(\"Directory #{ @path } doesn't exist; chown action not taken\")\n else\n if @tgroup == nil\n @tgroup = @meta_data[\"group\"]\n end\n converge_by(\"chown #{ @new_resource }\") do\n @client.chown(@path, 'owner' => @tuser, 'group' => @tgroup)\n end\n new_resource.updated_by_last_action(true)\n end\n end",
"def destination(base_directory); end",
"def copy_dir(src, dest)\n output = `rsync -r --exclude='.svn' --exclude='.git' --exclude='.gitignore' --filter=':- .gitignore' 2>&1 #{Shellwords.escape(src.to_s)}/ #{Shellwords.escape(dest.to_s)}`\n [output, $?]\n end",
"def move_to_target_directory!\n return if new_record? || !readable?\n\n src = diskfile\n self.disk_directory = target_directory\n dest = diskfile\n\n return if src == dest\n\n if !RedmicaS3::Connection.move_object(src, dest)\n Rails.logger.error \"Could not move attachment from #{src} to #{dest}\"\n return\n end\n\n update_column :disk_directory, disk_directory\n end",
"def overwrite_destination_with!(descriptor, destination)\n raise NotImplementedError, 'Implemented in subclasses. See filesystem_pool for example.'\n end",
"def move_dirs\n \n end",
"def remote_folder= new_folder\n @remote_folder = File.expand_path(new_folder)\n end",
"def dir_upload(*paths); net_scp_transfer!(:upload, true, *paths); end",
"def backup2Drive(src,conf)\n dest = conf[:backupDrive]\n dest = dest + \"/\" unless dest [-1] =~ /[\\/\\\\]/\n dest = dest + src\n puts src\n puts dest\n FileUtils.mkdir_p(File.dirname(dest))\n FileUtils.cp(src, dest)\n puts aktTime()+\" archive copied\"\n cleanUp(conf) if conf[:generations]\n \nend",
"def cp_r(src, dest, options = {})\r\n fu_check_options options, :preserve, :noop, :verbose\r\n fu_output_message \"cp -r#{options[:preserve] ? 'p' : ''} #{[src,dest].flatten.join ' '}\" if options[:verbose]\r\n return if options[:noop]\r\n\r\n fu_each_src_dest(src, dest) do |s,d|\r\n if File.directory?(s)\r\n fu_copy_dir s, d, '.', options[:preserve]\r\n else\r\n fu_p_copy s, d, options[:preserve]\r\n end\r\n end\r\n end",
"def cp_r(src, dest, preserve: nil, noop: nil, verbose: nil,\n dereference_root: true, remove_destination: nil)\n fu_output_message \"cp -r#{preserve ? 'p' : ''}#{remove_destination ? ' --remove-destination' : ''} #{[src,dest].flatten.join ' '}\" if verbose\n return if noop\n fu_each_src_dest(src, dest) do |s, d|\n copy_entry s, d, preserve, dereference_root, remove_destination\n end\n end",
"def rel_copy(full_src, rel_dest, opts={})\n \n dest_path = File.dirname(rel_dest)\n \n fname = Pathname.new(full_src).basename\n \n if !File.directory?(dest_path)\n cmd = \"mkdir -p #{dest_path}\"\n \n if !opts[:mock]\n run cmd\n else\n puts \"mocking #{cmd}\"\n end \n end\n \n cmd = \"cp #{full_src} #{dest_path}/#{fname}\"\n \n if !opts[:mock]\n run cmd\n else\n puts \"mocking #{cmd}\"\n end\n\nend",
"def cp_lr(src, dest, noop: nil, verbose: nil,\n dereference_root: true, remove_destination: false)\n fu_output_message \"cp -lr#{remove_destination ? ' --remove-destination' : ''} #{[src,dest].flatten.join ' '}\" if verbose\n return if noop\n fu_each_src_dest(src, dest) do |s, d|\n link_entry s, d, dereference_root, remove_destination\n end\n end",
"def safe_cp(from, to, owner, group, cwd = '', include_paths = [], exclude_paths = [])\n credentials = ''\n credentials += \"-o #{owner} \" if owner\n credentials += \"-g #{group} \" if group\n excludes = find_command_excludes(from, cwd, exclude_paths).join(' ')\n\n copy_files = proc do |from_, cwd_, path_ = ''|\n cwd_ = File.expand_path(File.join('/', cwd_))\n \"if [[ -d #{File.join(from_, cwd_, path_)} ]]; then \" \\\n \"#{dimg.project.find_path} #{File.join(from_, cwd_, path_)} #{excludes} -type f -exec \" \\\n \"#{dimg.project.bash_path} -ec '#{dimg.project.install_path} -D #{credentials} {} \" \\\n \"#{File.join(to, '$(echo {} | ' \\\n \"#{dimg.project.sed_path} -e \\\"s/#{File.join(from_, cwd_).gsub('/', '\\\\/')}//g\\\")\")}' \\\\; ;\" \\\n 'fi'\n end\n\n commands = []\n commands << [dimg.project.install_path, credentials, '-d', to].join(' ')\n commands.concat(include_paths.empty? ? Array(copy_files.call(from, cwd)) : include_paths.map { |path| copy_files.call(from, cwd, path) })\n commands << \"#{dimg.project.find_path} #{to} -type d -exec \" \\\n \"#{dimg.project.bash_path} -ec '#{dimg.project.install_path} -d #{credentials} {}' \\\\;\"\n commands.join(' && ')\n end",
"def write(dest)\n FileUtils.mkdir_p(File.join(dest, @dir))\n FileUtils.cp(File.join(@base, @dir, @name), File.join(dest, @dir, @name))\n end",
"def chown( owner, group ) File.chown( owner, group, expand_tilde ) end",
"def rsync(local_folder, remote_destination, delete)\n @log.info(\"rsyncing folder '#{local_folder}' to '#{remote_destination}'...\")\n @process_runner.execute!(\"rsync --filter='P *.css' --filter='P apidocs' --filter='P cdn' --filter='P get-started' --partial --archive --checksum --compress --omit-dir-times --quiet#{' --delete' if delete} --chmod=Dg+sx,ug+rw,Do+rx,o+r --protocol=28 --exclude='.snapshot' #{local_folder}/ #{remote_destination}\")\n end",
"def mirror_dirs (source_dir, target_dir)\n # Skip hidden root source dir files by default.\n source_files = Dir.glob File.join(source_dir, '*')\n case RUBY_PLATFORM\n when /linux|darwin/ then\n source_files.each { | source_file | sh 'cp', '-a', source_file, target_dir }\n else\n cp_r source_files, target_dir, :preserve => true\n end\nend",
"def test_moved_file_permissions\n `touch ../harness/test/new/foo;chmod 754 ../harness/test/new/foo`\n permissions = File.stat(\"../harness/test/new/foo\").mode\n nd = TestDirectory.new \"../harness/test/new\"\n @td.move(:foo, :new, :unclassified)\n p1 = File.stat(\"../harness/test/unclassified/foo\").mode\n assert_equal(permissions, p1)\n end",
"def directory(from, to = nil)\n @directories[from.chomp('/')] = to\n end",
"def copyLocalFileToRemoteDirectory(sourcePath, destinationPath, dryRun)\n #N Without this there won't be a description of the copy operation that can be displayed to the user as feedback\n description = \"SCP: copy file #{sourcePath} to #{user}@#{host}:#{destinationPath}\"\n #N Without this the user won't see the echoed description\n puts description\n #N Without this check, the file will be copied even if it is only meant to be a dry run.\n if not dryRun\n #N Without this, the file won't actually be copied.\n scpConnection.upload!(sourcePath, destinationPath)\n end\n end",
"def copy(src, dst)\n\t\tFileUtils.cp_r(src, dst)\n\t\ttrue\n\trescue Errno::ENOENT\n\t\traise Rush::DoesNotExist, File.dirname(dst)\n\trescue RuntimeError\n\t\traise Rush::DoesNotExist, src\n\tend",
"def clone_destination\n @clone_destination ||= Dir.mktmpdir('chef-steel-')\n end",
"def link_to(dest)\n dir = File.dirname(dest)\n FileUtils.makedirs(dir) unless Dir.exist?(dir)\n FileUtils.symlink(@path, dest)\n end",
"def copy(target, copied_folder = nil)\n new_folder = self.dup\n new_folder.parent = target\n new_folder.save!\n\n copied_folder = new_folder if copied_folder.nil?\n\n self.assets.each do |assets|\n assets.copy(new_folder)\n end\n\n self.children.each do |folder|\n unless folder == copied_folder\n folder.copy(new_folder, copied_folder)\n end\n end\n new_folder\n end",
"def copy(source_path, target_path)\n _ensure_directory_exists(target_path)\n target_path.open('wb', @permissions[:file]) do |io|\n lines = source_path.read.split(\"\\n\")\n lines.each do |line|\n\tio.write(line.chomp + @ending)\n end\n end\n puts \"#{source_path.to_s.ljust(25)} -> #{target_path}\"\n end",
"def mirror_missing_destination_files\n # Find the id of the domain we are mirroring\n source_domain = SourceDomain.find_by_namespace(@source_mogile.domain)\n\n # Get the max fid from the mirror db\n # This will only be nonzero if we are doing an incremental\n max_fid = MirrorFile.max_fid\n\n # Process source files in batches.\n Log.instance.info(\"Searching for files in domain [ #{source_domain.namespace} ] whose fid is larger than [ #{max_fid} ].\")\n SourceFile.where('dmid = ? AND fid > ?', source_domain.dmid, max_fid).includes(:domain, :fileclass).find_in_batches(batch_size: 1000) do |batch|\n # Create an array of MirrorFiles which represents files we have mirrored.\n remotefiles = batch.collect { |file| MirrorFile.new(fid: file.fid, dkey: file.dkey, length: file.length, classname: file.classname) }\n\n # Insert the mirror files in a batch format.\n Log.instance.debug('Bulk inserting mirror files.')\n MirrorFile.import remotefiles\n\n # Figure out which files need copied over\n # (either because they are missing or because they have been updated)\n batch_copy_missing_destination_files(remotefiles)\n\n # Show our progress so people know we are working\n summarize\n\n # Quit if program exit has been requested.\n return true if SignalHandler.instance.should_quit\n end\n end",
"def move( rdn )\n\t\tself.log.debug \"Asking the directory to move me to an entry called %p\" % [ rdn ]\n\t\tself.directory.move( self, rdn )\n\t\tself.clear_caches\n\n\t\treturn self\n\tend",
"def copy_permissions_to_new_folder(folder)\r\n # get the 'parent' GroupPermissions\r\n GroupPermission.find_all_by_folder_id(folder_id).each do |parent_group_permissions|\r\n # create the new GroupPermissions\r\n group_permissions = GroupPermission.new\r\n group_permissions.folder = folder\r\n group_permissions.group = parent_group_permissions.group\r\n group_permissions.can_create = parent_group_permissions.can_create\r\n group_permissions.can_read = parent_group_permissions.can_read\r\n group_permissions.can_update = parent_group_permissions.can_update\r\n group_permissions.can_delete = parent_group_permissions.can_delete\r\n group_permissions.save\r\n end\r\n end",
"def copy_dir(origin_path, dest_path)\n \n p origin_path if $DEBUG\n\n real_dir = get_non_linked_dir_path_for_path(origin_path)\n \n unless File.exist?(dest_path) and File.directory?(dest_path) then\n \n Dir.mkdir(dest_path)\n \n end\n \n Dir.foreach(real_dir) do |f|\n \n next if f == \".\" or f == \"..\"\n \n full_path= File.join(real_dir, f)\n \n #check if this is a hard link to a directory\n if File.exist?(full_path) and (not File.directory?(full_path)) and File.stat(full_path).nlink > @min_link_count then\n full_path = get_non_linked_dir_path_for_path(full_path)\n end\n \n if File.directory?(full_path) then\n copy_dir(full_path, File.join(dest_path, f))\n else\n \n if File.exist?(full_path) and not File.symlink?(full_path) then\n \n FileUtils.cp(full_path, dest_path)\n \n end\n \n end\n \n end\n \n nil\n \n end",
"def move_to_folder=(value)\n @move_to_folder = value\n end",
"def chown(owner, group) File.chown(owner, group, path) end",
"def copy_appl_to_dest(file_list, start_dir, dst_dir)\n num_of_files = 0\n file_list.each do |src_file|\n # name without start_dir\n rel_file_name = src_file.gsub(start_dir, \"\")\n log \"Copy #{rel_file_name}\"\n # calculate destination name\n dest_name_full = File.join(dst_dir, rel_file_name)\n dir_dest = File.dirname(dest_name_full)\n num_of_files = num_of_files + 1\n # make sure that a directory destination exist because cp don't create a new dir\n if !@simulate\n FileUtils.mkdir_p(dir_dest) unless File.directory?(dir_dest)\n FileUtils.cp(src_file, dest_name_full)\n end\n end\n log \"Num of files copied #{num_of_files}\"\n end",
"def copy(src, dst)\n\t\tFileUtils.cp_r(src, dst)\n\t\ttrue\n\trescue Errno::ENOENT\n\t\traise Rush::DoesNotExist, src unless File.exist?(src)\n\t\traise Rush::DoesNotExist, File.dirname(dst)\n\tend",
"def write(dest)\n dest_path = destination(dest)\n\n return false if File.exist?(dest_path) and !modified?\n @@mtimes[path] = mtime\n\n FileUtils.mkdir_p(File.dirname(dest_path))\n FileUtils.rm(dest_path) if File.exist?(dest_path)\n FileUtils.ln(path, dest_path)\n\n true\n end",
"def move(dest, overwrite=false)\n @resource.copy(dest, overwrite)\n end",
"def doCopyOperations(sourceContent, destinationContent, dryRun)\n #N Without this loop, we won't copy the directories that are marked for copying\n for dir in sourceContent.dirs\n #N Without this check, we would attempt to copy those directories _not_ marked for copying (but which might still have sub-directories marked for copying)\n if dir.copyDestination != nil\n #N Without this, we won't know what is the full path of the local source directory to be copied\n sourcePath = sourceLocation.getFullPath(dir.relativePath)\n #N Without this, we won't know the full path of the remote destination directory that this source directory is to be copied into\n destinationPath = destinationLocation.getFullPath(dir.copyDestination.relativePath)\n #N Without this, the source directory won't actually get copied\n destinationLocation.contentHost.copyLocalToRemoteDirectory(sourcePath, destinationPath, dryRun)\n else\n #N Without this, we wouldn't copy sub-directories marked for copying of this sub-directory (which is not marked for copying in full)\n doCopyOperations(dir, destinationContent.getDir(dir.name), dryRun)\n end\n end\n #N Without this loop, we won't copy the files that are marked for copying\n for file in sourceContent.files\n #N Without this check, we would attempt to copy those files _not_ marked for copying\n if file.copyDestination != nil\n #N Without this, we won't know what is the full path of the local file to be copied\n sourcePath = sourceLocation.getFullPath(file.relativePath)\n #N Without this, we won't know the full path of the remote destination directory that this source directory is to be copied into\n destinationPath = destinationLocation.getFullPath(file.copyDestination.relativePath)\n #N Without this, the file won't actually get copied\n destinationLocation.contentHost.copyLocalFileToRemoteDirectory(sourcePath, destinationPath, dryRun)\n end\n end\n end",
"def transfer!\n Logger.message(\"#{ self.class } started transferring \\\"#{ remote_file }\\\".\")\n create_local_directories!\n FileUtils.cp(\n File.join(local_path, local_file),\n File.join(remote_path, remote_file)\n )\n end",
"def rsync_from(source, target, dest, port = 22, extra_flags = [])\n rsync = find_program_on_path('rsync')\n flags = \"-rHlv -O --no-perms --no-owner --no-group\"\n unless extra_flags.empty?\n flags << \" \" << extra_flags.join(\" \")\n end\n ex(\"#{rsync} -e '#{ssh_command(port)}' #{flags} #{target}:#{source} #{dest}\")\n end",
"def copy(source, destination, **options); end",
"def move(*args)\n unless(resource.exist?)\n NotFound\n else\n resource.lock_check if resource.supports_locking? && !args.include?(:copy)\n destination = url_unescape(env['HTTP_DESTINATION'].sub(%r{https?://([^/]+)}, ''))\n dest_host = $1\n if(dest_host && dest_host.gsub(/:\\d{2,5}$/, '') != request.host)\n BadGateway\n elsif(destination == resource.public_path)\n Forbidden\n else\n dest = resource_class.new(destination, clean_path(destination), @request, @response, @options.merge(:user => resource.user))\n status = nil\n if(args.include?(:copy))\n status = resource.copy(dest, overwrite)\n else\n return Conflict unless depth.is_a?(Symbol) || depth > 1\n status = resource.move(dest, overwrite)\n end\n response['Location'] = \"#{scheme}://#{host}:#{port}#{url_format(dest)}\" if status == Created\n # RFC 2518\n return_status(dest,status)\n end\n end\n end",
"def copy(destination)\n return unless @converted\n \n puts \"Generating #{Rails.root}/tmp/images/#{@full}\"\n puts \"Generating #{Rails.root}/tmp/images/#{@icon}\"\n \n FileUtils.cp(\"#{Rails.root}/tmp/images/#{@full}\", \n \"#{destination}/#{@full}\")\n puts \"Moving #{destination}/#{@full}\"\n \n FileUtils.chmod(0644, \"#{destination}/#{@full}\")\n FileUtils.cp(\"#{Rails.root}/tmp/images/#{@icon}\",\n \"#{destination}/#{@icon}\")\n puts \"Moving #{destination}/#{@icon}\"\n FileUtils.chmod(0644, \"#{destination}/#{@icon}\")\n end",
"def batch_copy_missing_destination_files(files)\n dest_domain = DestDomain.find_by_namespace(@dest_mogile.domain)\n\n files.each do |file|\n # Quit if no results\n break if file.nil?\n\n # Quit if program exit has been requested.\n break if SignalHandler.instance.should_quit\n\n # Look up the source file's key in the destination domain\n destfile = DestFile.find_by_dkey_and_dmid(file.dkey, dest_domain.dmid)\n if destfile\n # File exists!\n # Check that the source and dest file sizes match\n if file.length != destfile.length\n # File exists but has been modified. Copy it over.\n begin\n Log.instance.debug(\"Key [ #{file.dkey} ] is out of date. Updating.\")\n stream_copy(file)\n @updated += 1\n @copied_bytes += file.length\n rescue => e\n @failed += 1\n Log.instance.error(\"Error updating [ #{file.dkey} ]: #{e.message}\\n#{e.backtrace}\")\n end\n else\n Log.instance.debug(\"key [ #{file.dkey} ] is up to date.\")\n @uptodate += 1\n end\n else\n # File does not exist. Copy it over.\n begin\n Log.instance.debug(\"key [ #{file.dkey} ] does not exist... creating.\")\n stream_copy(file)\n @added += 1\n @copied_bytes += file.length\n rescue => e\n @failed += 1\n Log.instance.error(\"Error adding [ #{file.dkey} ]: #{e.message}\\n#{e.backtrace}\")\n end\n end\n end\n end",
"def cp_r(source, dest)\n FileUtils.cp_r(source, dest)\n puts \" ✔ cp -R #{source} #{dest}\".colorize(:blue).bold\n end",
"def install(src, dest, mode: nil, owner: nil, group: nil, preserve: nil,\n noop: nil, verbose: nil)\n if verbose\n msg = +\"install -c\"\n msg << ' -p' if preserve\n msg << ' -m ' << mode_to_s(mode) if mode\n msg << \" -o #{owner}\" if owner\n msg << \" -g #{group}\" if group\n msg << ' ' << [src,dest].flatten.join(' ')\n fu_output_message msg\n end\n return if noop\n uid = fu_get_uid(owner)\n gid = fu_get_gid(group)\n fu_each_src_dest(src, dest) do |s, d|\n st = File.stat(s)\n unless File.exist?(d) and compare_file(s, d)\n remove_file d, true\n copy_file s, d\n File.utime st.atime, st.mtime, d if preserve\n File.chmod fu_mode(mode, st), d if mode\n File.chown uid, gid, d if uid or gid\n end\n end\n end",
"def copy_dir(source, dest)\n files = Dir.glob(\"#{source}/**\")\n mkdir_p dest\n cp_r files, dest\n end",
"def copy_to(target)\n target.parent.mkdirs\n factory.system.copy_dir(@path, target.path)\n end"
] | [
"0.61730516",
"0.6078995",
"0.5986515",
"0.5841446",
"0.5800374",
"0.5770643",
"0.5669633",
"0.5629317",
"0.5507884",
"0.54967123",
"0.54917204",
"0.5449184",
"0.5449184",
"0.5390665",
"0.53606904",
"0.53490293",
"0.53425914",
"0.5295243",
"0.5292298",
"0.5289558",
"0.5272424",
"0.5271534",
"0.5216293",
"0.5216293",
"0.5216155",
"0.5196963",
"0.5195739",
"0.51931185",
"0.5179319",
"0.5174071",
"0.5171364",
"0.5159107",
"0.5148089",
"0.51455724",
"0.51406866",
"0.5136372",
"0.5129976",
"0.5124423",
"0.51176345",
"0.5113867",
"0.51076835",
"0.51076835",
"0.51072294",
"0.5106455",
"0.5103988",
"0.5088876",
"0.50728136",
"0.5062926",
"0.50613534",
"0.50486064",
"0.5039006",
"0.50348216",
"0.5033891",
"0.5024957",
"0.5004302",
"0.50031364",
"0.50015056",
"0.50007105",
"0.49951324",
"0.49882546",
"0.49868304",
"0.49834466",
"0.4980301",
"0.49743038",
"0.4969511",
"0.49685168",
"0.49681294",
"0.49628553",
"0.49579513",
"0.4945451",
"0.4941963",
"0.49009484",
"0.4884216",
"0.48806497",
"0.48802984",
"0.4870637",
"0.48679084",
"0.4864421",
"0.48612803",
"0.4859836",
"0.4855589",
"0.48459136",
"0.4842748",
"0.48380232",
"0.48370972",
"0.48304164",
"0.48232555",
"0.4822192",
"0.48220637",
"0.48211884",
"0.4820833",
"0.48180848",
"0.4815445",
"0.4815312",
"0.48128003",
"0.48125598",
"0.48058495",
"0.4805694",
"0.4798569",
"0.478949"
] | 0.6880052 | 0 |
mark this directory (on a remote system) to be deleted N Without this we can't mark a directory (on a remote system) to be deleted | def markToDelete
#N Without this it won't be marked for deletion
@toBeDeleted = true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def markToDelete\n #N Without this we won't remember that this file is to be deleted\n @toBeDeleted = true\n end",
"def delete_from_disk; end",
"def delete\n if processable? or unset?\n dir.delete\n else\n raise JobError.cannot_delete(@id, state)\n end\n end",
"def removed_unmarked_paths\n #remove dirs\n dirs_enum = @dirs.each_value\n loop do\n dir_stat = dirs_enum.next rescue break\n if dir_stat.marked\n dir_stat.marked = false # unset flag for next monitoring\\index\\remove phase\n #recursive call\n dir_stat.removed_unmarked_paths\n else\n # directory is not marked. Remove it, since it does not exist.\n write_to_log(\"NON_EXISTING dir: \" + dir_stat.path)\n # remove file with changed checksum\n $local_content_data_lock.synchronize{\n $local_content_data.remove_directory(dir_stat.path, Params['local_server_name'])\n }\n rm_dir(dir_stat)\n end\n end\n\n #remove files\n files_enum = @files.each_value\n loop do\n file_stat = files_enum.next rescue break\n if file_stat.marked\n file_stat.marked = false # unset flag for next monitoring\\index\\remove phase\n else\n # file not marked meaning it is no longer exist. Remove.\n write_to_log(\"NON_EXISTING file: \" + file_stat.path)\n # remove file with changed checksum\n $local_content_data_lock.synchronize{\n $local_content_data.remove_instance(Params['local_server_name'], file_stat.path)\n }\n # remove from tree\n @files.delete(file_stat.path)\n end\n end\n end",
"def update_remotely_deleted(file, node)\n #\n if node != ancestor.file_node(file) && !overwrite?\n if UI.ask(\"local changed #{file} which remote deleted\\n\" +\n \"use (c)hanged version or (d)elete?\") == \"d\"\n then remove file\n else add file\n end\n else\n remove file\n end\n end",
"def atomic_delete_modifier\n atomic_paths.delete_modifier\n end",
"def clear!(confirm = nil, older_than: nil)\n if older_than\n directory.find do |path|\n path.mtime < older_than ? path.rmtree : Find.prune\n end\n else\n raise Shrine::Confirm unless confirm == :confirm\n directory.rmtree\n directory.mkpath\n directory.chmod(permissions) if permissions\n end\n end",
"def destroy\n\t\t@directory = Directory.find(params[:id])\n\t\[email protected]_flag = 'N'\n\t\[email protected]\n\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to(directories_url) }\n\t\t\tformat.xml\t{ head :ok }\n\t\tend\n\tend",
"def delete_dir\n FileUtils.rm_rf(@server_dir)\n @queue = []\n end",
"def destroy\n @folder.destroy\n end",
"def delete\n FileUtils.remove_entry_secure(@directory)\n ObjectSpace.undefine_finalizer(self)\n rescue Errno::ENOENT\n end",
"def rm_rf(z, path)\n z.get_children(:path => path).tap do |h|\n if h[:rc].zero?\n h[:children].each do |child|\n rm_rf(z, File.join(path, child))\n end\n elsif h[:rc] == ZNONODE\n # no-op\n else\n raise \"Oh noes! unexpected return value! #{h.inspect}\"\n end\n end\n\n rv = z.delete(:path => path)\n\n unless (rv[:rc].zero? or rv[:rc] == ZNONODE)\n raise \"oh noes! failed to delete #{path}\" \n end\n\n path\n end",
"def destroy_directory!(directory)\n system(\"trash #{directory}\")\n end",
"def flag_as_deleted!\n set(:deleted, true)\n end",
"def destroy\n run_callbacks :destroy do\n if directory?\n logger.info \"Delete directory at #{absolute_path}\"\n FileUtils.rmdir absolute_path\n else\n logger.info \"Delete file at #{absolute_path}\"\n # TODO if the file has added state (not committed), reset it to HEAD\n if status_file.untracked\n FileUtils.rm absolute_path\n else\n remove\n end\n end\n true\n end\n end",
"def delete( branch )\n\t\tself.log.info \"Deleting %s from the directory.\" % [ branch ]\n\t\tself.conn.delete( branch.dn )\n\tend",
"def action_delete\n if (!dir_exists?(@path))\n Chef::Log::info(\"Directory #{ @path } doesn't exist; delete action not taken\")\n else\n converge_by(\"Delete #{ @new_resource }\") do\n @client.delete(@path)\n end\n new_resource.updated_by_last_action(true)\n end\n end",
"def delete_gdom_disk(options)\n gdom_dir = $ldom_base_dir+\"/\"+options['name']\n client_disk = gdom_dir+\"/vdisk0\"\n message = \"Information:\\tRemoving disk \"+client_disk\n command = \"rm #{client_disk}\"\n execute_command(options,message,command)\n return\nend",
"def rm_rf(path)\n cmd 'rm', '-rf', path\nend",
"def delete\n CMark.node_unlink(@pointer)\n end",
"def rm path\n end",
"def delete\n FileUtils.rm_rf(to_s)\n self\n end",
"def destroy\n temp = @folder_client.destroy(get_id, force)\n if temp[:status]\n flash_message(:notice,\"#{t('folder.folder')} #{t('succesfully_destroyed')}\")\n redirect_to folders_path\n else\n if temp[:code] == 403\n @id = get_id\n @message = temp[:response]['message']\n else\n flash_message(:error, temp[:response]['message'])\n redirect_to root_path\n end\n\n end\n @success = temp[:status]\n end",
"def delete(command)\n pp @client.files.delete(clean_up(command[1]))\n end",
"def rmdir() Dir.rmdir( expand_tilde ) end",
"def mark_deleted!\n mark_deleted\n self.save\n end",
"def rm(path)\n cmd 'rm', path\nend",
"def mark_as_deleted\n update_attribute(:is_deleted, true)\n end",
"def destroy\n self.update_attribute :deleted, true\n end",
"def delete!\n PoolNode.rmdir(@id)\n super\n Address.delete(@id)\n Subnet.delete(@subnet)\n end",
"def mark_for_delete=(value = true)\n @mark_for_delete = value\n end",
"def delete!\n exist!\n File.unlink @path\n @path = nil\n end",
"def delete(rmdir: false)\n # FIXME: rethink this interface... should qdel be idempotent?\n # After first call, no errors thrown after?\n\n if pbsid\n\n @torque.qdel(pbsid, host: @host)\n # FIXME: removing a directory is always a dangerous action.\n # I wonder if we can add more tests to make sure we don't delete\n # something if the script name is munged\n\n # recursively delete the directory after killing the job\n Pathname.new(path).rmtree if path && rmdir && File.exist?(path)\n end\n end",
"def remove_folder\n space = Space.accessible_by(@context).find(params[:id])\n ids = Node.sin_comparison_inputs(unsafe_params[:ids])\n\n if space.contributor_permission(@context)\n nodes = Node.accessible_by(@context).where(id: ids)\n\n UserFile.transaction do\n nodes.update(state: UserFile::STATE_REMOVING)\n\n nodes.where(sti_type: \"Folder\").find_each do |folder|\n folder.all_children.each { |node| node.update!(state: UserFile::STATE_REMOVING) }\n end\n\n Array(nodes.pluck(:id)).in_groups_of(1000, false) do |ids|\n job_args = ids.map do |node_id|\n [node_id, session_auth_params]\n end\n\n Sidekiq::Client.push_bulk(\"class\" => RemoveNodeWorker, \"args\" => job_args)\n end\n end\n\n flash[:success] = \"Object(s) are being removed. This could take a while.\"\n else\n flash[:warning] = \"You have no permission to remove object(s).\"\n end\n\n redirect_to files_space_path(space)\n end",
"def rm_r(path)\n cmd 'rm', '-r', path\nend",
"def delete!\n if new_record?\n raise Errors::FolderNotFound.new(@id, \"Folder does only exist locally\")\n else\n self.class.delete(@conn_id, @location.path)\n @id = nil\n end\n end",
"def delete_node\n delete(@nodename)\n end",
"def after_destroy\n super\n\n # Try our best to remove the directory. If it fails there is little\n # else that we could do to resolve the situation -- we already tried to\n # delete it once...\n self.tmpdir and FileUtils.remove_entry_secure(self.tmpdir, true)\n\n # Remove repo directory.\n if self.iso_url\n # Some files in archives are write-only. Change this property so the\n # delete succeeds.\n remove_directory(iso_location)\n end\n end",
"def deleted\n @is_deleted = true\n end",
"def skip_deletion\n @mark_for_delete = false\n end",
"def delete_directories account\n # Use FileUtils\n fu = FileUtils\n # If we're just running as a simulation\n if $simulate\n # Use ::DryRun, that just echoes the commands, instead of the normal FileUtils\n fu = FileUtils::DryRun # ::DryRun / ::NoWrite\n end\n \n # Tell the user\n puts \"> Tar bort kontot från filsystemet\".green\n\n # Build the paths\n mail_dir = BASE_PATH_MAIL + account['mail']\n home_dir = BASE_PATH_HOME + account['home']\n\n # Remove the directories\n fu.rm_r mail_dir\n fu.rm_r home_dir\nend",
"def rmdir() Dir.rmdir(path) end",
"def delete\n reload!\n if path.start_with?(\"/#{@client.account.name}/Trash\")\n raise Springcm::DeleteRefusedError.new(path)\n end\n unsafe_delete\n end",
"def delete\n stop\n [ @resource['instances_dir'] + \"/\" + @resource[:name],\n @resource['instances_dir'] + \"/\" + \"_\" + @resource[:name]\n ].each do |dir|\n FileUtils.rm_rf(dir) if File.directory?(dir)\n end\n end",
"def delete\n if empty?\n @perforce.run(\"change\", \"-d\", @number)\n end\n end",
"def undelete_tree(directory_key)\n raise MedusaStorage::Error::UnsupportedOperation\n end",
"def delete_directory domain\n # Use FileUtils\n fu = FileUtils\n # If we're just running as a simulation\n if $simulate\n # Use ::DryRun, that just echoes the commands, instead of the normal FileUtils\n fu = FileUtils::DryRun # ::DryRun / ::NoWrite\n end\n\n # Tell the user\n puts \"> Tar bort domänen från filsystemet\".green\n\n # Build the paths\n mail_dir = BASE_PATH_MAIL + domain['domain']\n home_dir = BASE_PATH_HOME + domain['domain']\n\n # Remove the directories\n fu.rm_r mail_dir\n fu.rm_r home_dir\nend",
"def delete\n File::unlink @path+\".lock\" rescue nil\n File::unlink @path+\".new\" rescue nil\n File::unlink @path rescue Errno::ENOENT\n end",
"def rmdir(dirname)\n\t\tvoidcmd(\"RMD \" + dirname)\n\t end",
"def undelete_tree(directory_key)\n check_versioning\n all_versions = s3_bucket.object_versions(prefix: add_prefix(directory_key))\n versions_to_delete = all_versions.select {|version| version.is_latest and delete_marker?(version)}\n Parallel.each(versions_to_delete, in_threads: 10) do |version|\n delete_version(version.key, version.version_id)\n end\n end",
"def delete_path(path)\n @zk.delete(path)\n logger.info(\"Deleted ZK node #{path}\")\n rescue ZK::Exceptions::NoNode => ex\n logger.info(\"Tried to delete missing znode: #{ex.inspect}\")\n end",
"def mark_as_deleted(options = {})\n update_receipts({ deleted: true }, options)\n end",
"def mark_as_deleted(options={})\n update_receipts({:deleted => true}, options)\n end",
"def mark_as_deleted(options={})\n update_receipts({:deleted => true}, options)\n end",
"def action_delete\n if @current_resource.exist?\n converge_by \"Delete #{r.path}\" do\n backup unless ::File.symlink?(r.path)\n ::File.delete(r.path)\n end\n r.updated_by_last_action(true)\n load_new_resource_state\n r.exist = false\n else\n Chef::Log.debug \"#{r.path} does not exists - nothing to do\"\n end\n end",
"def unlink!\n FileUtils.rm_rf(directory)\n end",
"def delete\n if stat.directory?\n FileUtils.rm_rf(file_path)\n else\n ::File.unlink(file_path)\n end\n ::File.unlink(prop_path) if ::File.exist?(prop_path)\n @_prop_hash = nil\n NoContent\n end",
"def delete_from_disk\n thread_local_store.destroy\n end",
"def delete_downloads\n FileUtils.remove_entry_secure(dir) if Dir.exist?(dir)\n end",
"def remove_local_copy\n Dir.chdir(self.study.data_store_path)\n if File.exists?(self.download_location)\n File.delete(self.download_location)\n subdir = self.remote_location.blank? ? self.id : self.remote_location.split('/').first\n if Dir.exist?(subdir) && Dir.entries(subdir).delete_if {|e| e.start_with?('.')}.empty?\n Dir.rmdir(subdir)\n end\n end\n end",
"def destroy\n @folder.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def delete_tree_versions(directory_key)\n raise MedusaStorage::Error::UnsupportedOperation\n end",
"def destroy\n @folder_to_delete = @repository.get_secret_path\n if @repository.destroy\n FileUtils.rm_rf(@folder_to_delete, :secure =>true)\n puts @path\n respond_to do |format|\n format.html { redirect_to repositories_url, notice: 'Repository was successfully destroyed.' }\n format.json { head :no_content }\n end\n else\n format.html { redirect_to @repository, notice: 'Repository was not destroyed.' }\n end\n end",
"def delete(node=nil, root=nil, &block)\n return super(node, root) do | dn | \n block.call(dn) if block\n dn.update_left_size(:deleted, -1) if dn\n end\n end",
"def delete\n File::unlink @path+\".lock\" rescue nil\n File::unlink @path+\".new\" rescue nil\n File::unlink @path rescue nil\n end",
"def delete_directory_contents(options)\n Process::Delete::DirectoryContents.delete(options[:directory_path])\n end",
"def delete(dn)\n @conn.delete :dn => dn\n end",
"def rm_rf path\n execute(\"rm -rf #{path}\")\n end",
"def delete!\n delete(:force => true)\n nil\n end",
"def delete(k, ignored_options = nil)\n handle_fork\n _delete k\n end",
"def rmdir(path)\n raise NotImplemented\n end",
"def delete(name)\n connect { |connection| connection.delete dn(name) }\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 if (exists?)\n list.each do |children|\n children.delete\n end\n factory.system.delete_dir(@path)\n end\n end",
"def delete\n execute_prlctl('delete', @uuid)\n end",
"def rm(key, options = {})\n return 1 unless self.class.subkeys.include?(key)\n begin\n puts \"Removing directory: #{MDT::DataStorage.instance.versioned_base_path}/#{MDT::DataStorage.instance.versioned_releases_dirname}/#{MDT::DataStorage.instance.versioned_version_id}\"\n FileUtils.rm_rf(Dir[\"#{MDT::DataStorage.instance.versioned_base_path}/#{MDT::DataStorage.instance.versioned_releases_dirname}/#{MDT::DataStorage.instance.versioned_version_id}\"].first)\n 0\n rescue\n 1\n end\n end",
"def deleted\n @changed = true\n @deleted = true\n end",
"def safe_delete\n FileUtils.remove_entry_secure(SafeDeletable.path_for(self).to_s)\n rescue Errno::ENOENT\n # noop\n end",
"def rm(*path)\n super; on_success{ nil }\n end",
"def delete_dir!(path)\n # do nothing, because there's no such things as 'empty directory'\n end",
"def destroy(path)\n directory = connection.directories.get(self.bucket)\n directory ||= connection.directories.create(self.permissions.merge(:key => self.bucket))\n\n file = directory.files.get(path)\n file.destroy if file\n end",
"def destroy!\n # Delete the directory to delete the box.\n FileUtils.rm_r(@directory)\n\n # Just return true always\n true\n rescue Errno::ENOENT\n # This means the directory didn't exist. Not a problem.\n return true\n end",
"def deleteDirectory(dirPath, dryRun)\n #N Without this, the required ssh command to recursive remove a directory won't be (optionally) executed. Without the '-r', the attempt to delete the directory won't be successful.\n ssh(\"rm -r #{dirPath}\", dryRun)\n end",
"def rmdir(dirname)\n voidcmd(\"RMD \" + dirname)\n end",
"def delete_gdom_dir(options)\n gdom_dir = $ldom_base_dir+\"/\"+options['name']\n destroy_zfs_fs(gdom_dir)\n return\nend",
"def remove\r\n self.update(deleted: true)\r\n end",
"def delete()\n super(VIRTUAL_CLUSTER_METHODS[:delete])\n end",
"def mark_as_deleted\n update_attributes(:deleted => true)\n end",
"def mark_as_deleted\n update_attributes(:deleted => true)\n end",
"def destroy_file\n start_ssh do |ssh|\n ssh.exec!(\"rm #{e full_filename}\")\n dir = File.dirname(full_filename)\n ssh.exec!(\"find #{e dir} -maxdepth 0 -empty -exec rm -r {} \\\\;\")\n dir = File.dirname(dir)\n ssh.exec!(\"find #{e dir} -maxdepth 0 -empty -exec rm -r {} \\\\;\")\n end\n end",
"def destroy\n self.class.where(:id => self.id).update_all(:is_mirrored => false) if self.is_mirrored?\n super\n end",
"def delete_from_disk!\n if disk_filename.present?\n diskfile_s3 = diskfile\n Rails.logger.debug(\"Deleting #{diskfile_s3}\")\n RedmicaS3::Connection.delete(diskfile_s3)\n end\n\n Redmine::Thumbnail.batch_delete!(\n thumbnail_path('*').sub(/\\*\\.thumb$/, '')\n )\n end",
"def rmdir\n util.rmdir(path)\n end",
"def run_on_deletion(paths)\n end",
"def run_on_deletion(paths)\n end",
"def delete_directory(client, options)\n if !options[:directory].nil?\n directory = client.directories.get options[:directory]\n directory.delete\n puts \"Directory deleted.\"\n return\n else\n puts \"Missing arguments\"\n return nil\n end\nend",
"def ftp_remove path\n return ftp_action(true, path)\n end",
"def delete!\n # delete changes the node.modified_index\n @etcd_node = etcd.delete(etcd_key).node\n end",
"def destroy\n @dirs_created.each { |d| FileUtils.rm_rf(d) }\n self.class.repositories.delete(@name)\n end",
"def soft_delete!\n update_attribute(:mark_as_deleted, true)\n end"
] | [
"0.6357208",
"0.6278554",
"0.6038147",
"0.5936869",
"0.5936011",
"0.5749203",
"0.57407403",
"0.57291937",
"0.5711708",
"0.57000226",
"0.5671138",
"0.56697077",
"0.5645765",
"0.56383324",
"0.5634468",
"0.563188",
"0.5628065",
"0.5579145",
"0.5565366",
"0.5562144",
"0.5549265",
"0.55410635",
"0.55190736",
"0.5493475",
"0.54896146",
"0.547966",
"0.5472016",
"0.5445824",
"0.5443667",
"0.54371655",
"0.5425787",
"0.5420116",
"0.54158443",
"0.5405874",
"0.5390741",
"0.5388779",
"0.5387352",
"0.5380324",
"0.53800744",
"0.5379175",
"0.53768873",
"0.5376311",
"0.53728473",
"0.53668565",
"0.5361564",
"0.5354847",
"0.5354078",
"0.53441983",
"0.533981",
"0.5338329",
"0.53365904",
"0.5332322",
"0.533117",
"0.533117",
"0.53275067",
"0.5325756",
"0.5325749",
"0.53247315",
"0.53197145",
"0.5301634",
"0.5296363",
"0.5296183",
"0.52934194",
"0.52915055",
"0.5289424",
"0.52872074",
"0.5276557",
"0.5274615",
"0.5273756",
"0.5264784",
"0.5264016",
"0.52635485",
"0.5260899",
"0.52584434",
"0.5241597",
"0.52347404",
"0.523137",
"0.5227218",
"0.52190655",
"0.521778",
"0.5209245",
"0.5206417",
"0.5199746",
"0.51962805",
"0.51942414",
"0.5193927",
"0.518988",
"0.51883",
"0.51883",
"0.51875407",
"0.5184848",
"0.5182393",
"0.51812154",
"0.51778185",
"0.51778185",
"0.5175705",
"0.51747125",
"0.5172412",
"0.5165514",
"0.516509"
] | 0.63815486 | 0 |
the path of the directory that this content tree represents, relative to the base directory N Without this we can't know the relative path of the subdirectory within the content tree | def relativePath
#N Without this the path elements won't be joined together with "/" to get the relative path as a single string
return @pathElements.join("/")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relative_directory\n return '' unless @directory_root\n @path - @directory_root - name\n end",
"def containing_directory\n path.dirname\n end",
"def dir\n File.dirname(self.path)\n end",
"def directory\n self.path.directory\n end",
"def directory\n File.dirname(@path) + '/'\n end",
"def directory\n File.dirname @path\n end",
"def dirname\n return File.dirname( self.path )\n end",
"def path\n @directory.path\n end",
"def dir\n calc_dir(@basename)\n end",
"def base_relative_dir\n \t\[email protected](/^\\//,\"\")\n \tend",
"def parent_directory\n File.dirname(@full_path).split('/').last\n end",
"def parent_directory\n File.dirname(@full_path).split('/').last\n end",
"def relative_directory; end",
"def relative_directory\n @relative_directory ||= \"_#{label}\"\n end",
"def dir_path\n File.expand_path(File.dirname(@path))\n end",
"def directory\r\n \[email protected]\r\n end",
"def path_dir\n File.split(path).first\n end",
"def root\n '../' * file.count('/')\n end",
"def relativePath\n return (parentPathElements + [name]).join(\"/\")\n end",
"def a_dir\n self.path.split('/')[0...-1]\n end",
"def base_path\n Dir.pwd + \"/\"\n end",
"def path\n folders = ancestors.reverse + [self]\n folders.shift # Remove the root folder\n path = File.join('/', folders.map(&:name))\n Pathname.new(path)\n end",
"def path\n assignment.path + '/' + directory_num.to_s\n end",
"def dir_base\n File.expand_path(File.dirname(__FILE__)+\"/../..\")\n end",
"def base_dir_for_path_parameters; end",
"def file_dir\n @parent_generator.file_dir\n end",
"def base_directory\n @base_directory\n end",
"def path\n @base\n end",
"def dir\n @dir ||= File.dirname(fullpath)\n end",
"def basedir\n return nil if !file\n File.dirname File.absolute_path @file\n end",
"def basedir\n File.dirname File.absolute_path options[:file]\n end",
"def work\n '/' + File.dirname(file)\n end",
"def ref_path(dir, subdir, path)\n # this stuff is overkill, and doesn't work anyways:\n #depth = dir.split(File::SEPARATOR).reject{ |d| d.empty? }.count\n #parent_dirs = Array.new(depth, '..')\n File.join('..', ContentRepo::ResourceNode::PATHNAME, path )\n end",
"def path\n # FIXME: Do this without exception!\n #\"#{ @parent.path unless @parent == self }##{ ident }\"\n # rescue base path\n \"#{@parent.path rescue ''}##{ident}\"\n end",
"def path()\n\t\t\t\t@basePath + \"/\" + hierarchy().join( \"/\" )\n\t\t\tend",
"def absolute_parent_path\n File.dirname absolute_path\n end",
"def dirname() Path::Name.new(File.dirname(path)) end",
"def root; Pathname(__dir__).parent; end",
"def subdir\n if core_project? or 'profile' == proj_type\n return @local_path.parent.relative_path_from(@platform.local_path + (proj_type + 's'))\n else\n return @local_path.parent.relative_path_from(@platform.local_path + @platform.contrib_path + (proj_type + 's'))\n end\n end",
"def rel_path(file)\n File.dirname(file)\n end",
"def node_files_path()\n return File.join(@base_path, 'pages')\n end",
"def sub_dir_of(file, base = base_directory)\n file = Pathname.new(file) unless file.respond_to?(:relative_path_from)\n base = Pathname.new(base) unless base.respond_to?(:relative_path_from)\n rel = file.relative_path_from(base)\n if file.directory?\n rel\n else\n rel.dirname\n end\n end",
"def relative_path\n @relative_path ||= File.join(*[@dir, @name].map(&:to_s).reject(&:empty?)).delete_prefix(\"/\")\n end",
"def base_dir(dir_name)\n File.expand_path(dir_name)\n end",
"def path\n return @path if instance_variable_defined? :@path\n @path = parent.path + path_components\n end",
"def dir\n @dir ||= self.class.normalize_dir(::File.dirname(@path))\n end",
"def dir\n Rails.root.join(ROOT, type, name).to_s\n end",
"def file_path\n dir\n end",
"def root\n File.dirname __dir__\n end",
"def root\n File.dirname __dir__\n end",
"def path(suffix = nil)\n base = \"#{@parent.path}.#{subregion_directory}\"\n base << \".#{suffix}\" if suffix\n base\n end",
"def basepath; end",
"def root\n File.dirname __dir__\n end",
"def dir\n self.a_dir.join '/'\n end",
"def relroot\n Pathname.new(File.expand_path(path)).\n relative_path_from(Pathname.new(File.expand_path(root))).to_s\n end",
"def dir\n File.expand_path( File.join( File.dirname( File.expand_path(__FILE__) ), '..' ) )\n end",
"def base_directory\n File.expand_path(File.join(File.dirname(__FILE__), '..'))\n end",
"def parent_dir path\r\n\t(File.basename File.dirname path).gsub(/\\s+/, ' ').strip\r\nend",
"def path()\n return ::File.join(@root, @name)\n end",
"def calc_dir(page_base)\n page_full_path = File.join(GIT_REPO, unwiki(page_base))\n end",
"def path\n real_path = Pathname.new(root).realpath.to_s\n full_path.sub(%r{^#{real_path}/}, '')\n end",
"def subdir\n (@subdir) ? Pathname.new(@subdir) : Pathname.new('.')\n end",
"def dir_name\n File.dirname(file_name)\n end",
"def relative_path\n self.path.sub(File.expand_path(options[:root_dir]) + '/', '')\n end",
"def full_defined_path()\n return nil if is_root?\n return name if parent.is_root?\n return \"#{parent.full_defined_path}.#{name}\"\n end",
"def root path\n File.dirname(find_dotjam(path))\n end",
"def eponymous_directory_path\n path.sub(ext, '/').sub(/\\/$/, '') + '/'\n end",
"def location\n return unless exists?\n folder_pathname.relative_path_from(root_path)\n end",
"def base_dir; end",
"def base_dir; end",
"def base_dir; end",
"def base_dir; end",
"def base_dir; end",
"def base_dir; end",
"def base_dir; end",
"def descendent_path\n @descendent_path || @path\n end",
"def descendent_path\n @descendent_path || @path\n end",
"def current_dir\n File.dirname(file_path)\n end",
"def dirname\n File.dirname(filename)\n end",
"def path\n \"%s/%s\" % [dirname, filename]\n end",
"def full_path\n container.root.join(path)\n end",
"def full_path\n container.root.join(path)\n end",
"def absolute_parent_node_path\n absolute_parent_path + \".adoc\"\n end",
"def parent_folder(file)\n Pathname.new(file).dirname.basename.to_s\n end",
"def dirname\n File.dirname(filename)\n end",
"def folder_path\n File.expand_path @folder_path\n end",
"def relative_path\n @relative_path ||= PathManager.join(@dir, @name).delete_prefix(\"/\")\n end",
"def root\n Pathname.new(File.dirname(__dir__))\n end",
"def dirname() self.class.new(File.dirname(@path)) end",
"def project_dir\n File.expand_path(\"#{fetch_dir}/#{relative_path}\")\n end",
"def relative_path\n name\n end",
"def dirname\n transliterate(super).downcase\n end",
"def path\n File.join(@base, @name)\n end",
"def directory_path\n @directory_path ||= url_file_path.sub /([^\\/]*)\\z/, ''\n end",
"def base_path\n @base_path ||= Dir.pwd\n end",
"def base_path\n self.class.base_path\n end",
"def path_name\n str = name.dup\n str << '/' if is_dir\n str = parent.path_name + str if parent\n str\n end",
"def __dir__\n File.expand_path('..', __FILE__)\n end",
"def path(rel)\n File.join(File.dirname(__FILE__), \"..\", rel)\nend",
"def relative_path\n @relative_path ||= File.join(@dir, @name)\n end"
] | [
"0.7396666",
"0.7095777",
"0.6993002",
"0.69723535",
"0.6970938",
"0.69383276",
"0.68717897",
"0.68664604",
"0.6858817",
"0.6816477",
"0.68033266",
"0.68033266",
"0.67954874",
"0.6773204",
"0.67649233",
"0.674438",
"0.67174965",
"0.6704844",
"0.6696508",
"0.66949326",
"0.66905266",
"0.6688959",
"0.6678141",
"0.66604465",
"0.6632192",
"0.6609775",
"0.65647364",
"0.6550599",
"0.65426636",
"0.6537679",
"0.6524232",
"0.65181065",
"0.6505072",
"0.65028816",
"0.6485571",
"0.64839053",
"0.6473222",
"0.6441456",
"0.6427131",
"0.6410178",
"0.6402061",
"0.64008754",
"0.6386089",
"0.63828564",
"0.63547695",
"0.6340601",
"0.6338271",
"0.63138753",
"0.63111764",
"0.63111764",
"0.6296428",
"0.62903047",
"0.6277554",
"0.6274662",
"0.62725013",
"0.6266254",
"0.6264227",
"0.6263686",
"0.6258919",
"0.625684",
"0.6256351",
"0.6253737",
"0.6252034",
"0.62493014",
"0.623713",
"0.6235963",
"0.62358785",
"0.62307864",
"0.62292176",
"0.62292176",
"0.62292176",
"0.62292176",
"0.62292176",
"0.62292176",
"0.62292176",
"0.6227617",
"0.6227617",
"0.62232625",
"0.621376",
"0.6202035",
"0.61995196",
"0.61995196",
"0.61943936",
"0.61860067",
"0.61807793",
"0.6174599",
"0.61722296",
"0.61712325",
"0.61527604",
"0.6150756",
"0.61501765",
"0.61494106",
"0.6145324",
"0.6143365",
"0.6143199",
"0.61336416",
"0.613289",
"0.61261266",
"0.6122937",
"0.61039364"
] | 0.6221629 | 78 |
convert a path string to an array of path elements (or return it as is if it's already an array) N Without this we can't start from a path and decompose it into elements (optionally allowing for the case where the conversion has already been done) | def getPathElements(path)
#N Without this path as a single string won't be decomposed into a list of elements
return path.is_a?(String) ? (path == "" ? [] : path.split("/")) : path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_path(str)\n return str.map(&:to_s) if str.is_a?(::Array)\n @delimiter_handler.split_path(str.to_s)\n end",
"def path_comps path\n path.nil? || path.empty? ? [] : path[1..(path[-1] == \"/\" ? -2 : -1)].split('/')\n end",
"def split_path(path_string)\n path_string.split('->').map! { |element| element.strip }\n end",
"def split_path(path_string)\n path_string.split('->').map! { |element| element.strip }\n end",
"def split(path)\n array = path.kind_of?(String) ? path.split(\"/\") : path.dup\n array.shift if nil_or_empty_string?(array[0])\n array.pop if nil_or_empty_string?(array[-1])\n array\n end",
"def path_array\n a = []\n each_filename { |ea| a << ea }\n a\n end",
"def toPathList(arr); arr.join(File::PATH_SEPARATOR) end",
"def get_array(element, path='.')\n return unless element\n \n result = element/path\n if (result.is_a? Nokogiri::XML::NodeSet) || (result.is_a? Array)\n result.collect { |item| self.get(item) }\n else\n [self.get(result)]\n end\n end",
"def search_and_convert(path)\n elements = self./(path)\n return unless elements\n elements = elements.map{|element| Element.new(element)}\n return elements.first if elements.size == 1\n elements\n end",
"def get_array(path='.')\n Element.get_array(@element, path)\n end",
"def to_a = @paths.dup",
"def split_paths(path)\n dir_list = path.split('/').drop(1) # drops the \"\" because of the first \"/\"\n path_list = ['/'+dir_list.first]\n dir_list.drop(1).each do |dir|\n path = path_list.last + '/' + dir\n path_list.push path\n end\n path_list\nend",
"def get_array(path=\"\")\n Element.get_array(@element, path)\n end",
"def paths_to_array\n [{:paths => paths.collect {|p| p.to_array}}]\n end",
"def string_to_nested_array(str)\n arr1 = str.split(',')\n arr2 = []\n for i in 0..arr1.size - 1\n arr2[i] = arr1[i].split(':')\n end\n return arr2\nend",
"def to_array_form(external_ref_path)\n # TODO: use regexp disjunction\n external_ref_path.gsub(/^node\\[/, '').gsub(/^service\\[/, '').gsub(/\\]$/, '').split('][')\n end",
"def for_array_at_path_enumerate_types_and_paths(array_path:, types_and_paths:)\n array = @params.dig(*array_path)\n\n array.each.with_index.reduce([]) do |acc, (_, index)|\n [\n *acc,\n *self.class.prepend_path_to_paths(\n prepend_path: [*array_path, index],\n types_and_paths: types_and_paths\n )\n ]\n end\n rescue StandardError\n []\n end",
"def split_path(path)\n path.strip.split(/[,;:\\ \\n\\t]/).map{|s| s.strip}\n end",
"def path_arr()\n return @paths\n end",
"def get_property_path(element, path)\n path = path.split('/') unless path.is_a?(Array)\n element = [element] unless element.is_a?(Array)\n unless path.size < 1\n path_piece = path.shift\n results = []\n element.each do |el|\n results << get_property(el, path_piece)\n end\n element = get_property_path(results.flatten, path)\n end\n return element\n end",
"def split_paths(paths)\n (paths || '').split(File::PATH_SEPARATOR).map { |p| to_pathname(p) }\n end",
"def /(path)\n elements = @element/path\n return nil if elements.size == 0\n elements\n end",
"def /(path)\n elements = @element/path\n return nil if elements.size == 0\n elements\n end",
"def /(path)\n elements = @element/path\n return nil if elements.size == 0\n elements\n end",
"def path_parts(input) # :nodoc:\n case input\n when /((?:@{1,2}|\\$|)\\w+(?:\\[[^\\]]+\\])*)([\\[\\/])(['\"])([^\\3]*)$/\n $~.to_a.slice(1, 4).push($~.pre_match)\n when /((?:@{1,2}|\\$|)\\w+(?:\\[[^\\]]+\\])*)(\\.)(\\w*)$/\n $~.to_a.slice(1, 3).push($~.pre_match)\n when /((?:@{1,2}|\\$|)\\w+)$/\n $~.to_a.slice(1, 1).push(nil).push($~.pre_match)\n else\n [ nil, nil, nil ]\n end\n end",
"def path_to_parts(path)\n path.\n downcase.\n split('/').\n map { |part| part.empty? ? nil : part.strip }.\n compact\n end",
"def parse(node_path)\n path = node_path[1..-1] while node_part.start_with '/' # lstrip '/'\n key = []\n for part in @path\n if part.is_a? String\n if path.start_with(part)\n path = path[part.length..-1]\n else\n raise \"Incorrect path for #{self} at #{part}: #{node_path} at #{part}\"\n end\n elsif part.is_a? Symbol\n value, path = path.split('/', 1)\n key << value\n else\n raise \"Invalid path part: #{part}\"\n end\n end\n key\n end",
"def path(*elements) #Create a path from the elements\n#-------------------------------------------------------------------------------\n path=elements.join('/').strip #Remove leading and trailing whitespace\n while path.gsub!('//','/'); end #Remove duplicate slashes\n return path\nend",
"def convert_to_path_params_segments(some_path)\n segs = strip_bookend_slashes(some_path).split('/')\n \n return segs.map{ |seg|\n if ms = seg.match(/(?<=:)\\w+/)\n ms[0].to_sym\n else\n seg\n end\n }\n end",
"def patharray\n return @pathArray\n end",
"def segments_from_path(path)\n # Remove leading ^ and trailing $ from each segment (left-overs from regexp joining)\n strip = proc { |str| str.gsub(/^\\^/, '').gsub(/\\$$/, '') }\n segments = []\n while match = (path.match(SEGMENT_REGEXP))\n segments << strip[match.pre_match] unless match.pre_match.empty?\n segments << match[2].intern\n path = strip[match.post_match]\n end\n segments << strip[path] unless path.empty?\n segments\n end",
"def split_nsh_path(path)\n result = [\"\",path]\n result[0] = path.split(\"/\")[2] if path.start_with?(\"//\")\n result[1] = \"/#{path.split(\"/\")[3..-1].join(\"/\")}\" if path.start_with?(\"//\") \n result\n end",
"def split_all(path)\n head, tail = File.split(path)\n return [tail] if head == '.' || tail == '/'\n return [head, tail] if head == '/'\n return split_all(head) + [tail]\n end",
"def split_all(path)\n head, tail = File.split(path)\n return [tail] if head == '.' || tail == '/'\n return [head, tail] if head == '/'\n return split_all(head) + [tail]\n end",
"def path_array\n path = []\n yield_path do |x, y|\n path << [x,y]\n end\n path.reverse\n end",
"def split() File.split(path).map {|f| Path::Name.new(f) } end",
"def get_path(str)\n child_node = @children[str[0]] || raise(NotFound)\n return [child_node.end_of_word?] if str.length == 1\n [child_node.end_of_word?].concat child_node.get_path(str[1..-1])\n end",
"def split_path(path)\n path.split(\"/\", -1)\n end",
"def parse_path(path_chunks)\n path = path_chunks[1]\n subpath_chunks = path.split(\"/\")\n base_dir = subpath_chunks[1]\n remaining_path = subpath_chunks[2..-1].join(\"/\")\n [base_dir, remaining_path]\n end",
"def split_path(path)\n parts = path.split('/')\n [parts[0..-2].join('/'), parts[-1]]\n end",
"def get_elements(path)\n elements = self./(path)\n return nil unless elements\n elements = elements.map{|element| Element.new(element)}\n end",
"def get_elements(path)\n elements = self./(path)\n return unless elements\n elements = elements.map{|element| Element.new(element)}\n end",
"def to_a\n @file_list.map{ |file| Pathname.new(file) }\n end",
"def to_a\n ::Dir.glob(path + '/*').collect {|pth| UFS::FS::File.new(pth)}\n # Uncomment the following to return File & Dir objects instead of Strings.\n # ::Dir.glob(path + '/*').collect {|pth| UFS::FS.new pth}\n end",
"def normalize_paths(paths)\n paths = [paths] unless paths.is_a?(Array)\n paths.map(&:dup).map do |path|\n raise ArgumentError.new(\"Invalid path: #{path}\") unless valid_path?(path)\n # Strip leading slash from extension path\n path.gsub!(/^\\/(?=\\*.)/, '')\n # Escape some valid special characters\n path.gsub!(/[.+$\"]/) {|s| '\\\\' + s}\n # Replace * wildcards with .* regex fragment\n path.gsub!(/\\*/, '.*')\n \"^#{path}#{END_URL_REGEX}\"\n end\nend",
"def decode_path(goal_node)\n path = []\n until goal_node.nil?\n path.unshift goal_node\n goal_node = goal_node.previous\n end\n return path\nend",
"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 parse_to_array(line_as_string)\n as_array = line_as_string.split(\" \")\nend",
"def validate_paths(paths)\n paths = [paths] unless paths.is_a?(Array)\n raise 'The provided paths must all be Strings' \\\n unless paths.all? { |path| path.is_a?(String) }\n\n Wgit::Utils.process_arr(paths, encode: false)\n raise 'The provided paths cannot be empty' if paths.empty?\n\n paths\n end",
"def split_string_to_array(str)\n @string_as_array = str.split('')\n return @string_as_array\nend",
"def flat_strings\n returning [] do |ary|\n traverse { |str| ary << str }\n end\n end",
"def remove_double_dots_from_path(path_array)\n while i = path_array.index('..')\n if i == 0\n path_array.shift\n else \n path_array.delete_at(i-1) \n path_array.delete_at(i-1)\n end\n end\nend",
"def format_path(str)\n first_format = str[1..str.length - 2].split('|') # => [ \"['ATL', 'EWR'] \", \" ['SFO', 'ATL']\" ]\n second_format = first_format.map { |e| e[1..e.length - 2] } # => [\"'ATL', 'EWR'\", \"'SFO', 'ATL'\"]\n second_format.map { |e| e.strip.split(',') } # [[\"'ATL'\", \" 'EWR'\"], [\"'SFO'\", \" 'ATL'\"]]\n end",
"def unpack(data)\n data.to_s.split(\"/\")\n end",
"def path_with_keys()\n path = []\n\n for part in @path\n if part.is_a? String\n path << part\n elsif part.is_a? Symbol\n path << (yield part)\n else\n raise \"Invalid path part: #{part}\"\n end\n end\n '/' + path.join('/')\n end",
"def normalize_paths(paths)\n # do the hokey-pokey of path normalization...\n paths = paths.collect do |path|\n path = path.\n gsub(\"//\", \"/\"). # replace double / chars with a single\n gsub(\"\\\\\\\\\", \"\\\\\"). # replace double \\ chars with a single\n gsub(%r{(.)[\\\\/]$}, '\\1') # drop final / or \\ if path ends with it\n\n # eliminate .. paths where possible\n re = %r{[^/\\\\]+[/\\\\]\\.\\.[/\\\\]}\n path.gsub!(re, \"\") while path.match(re)\n path\n end\n\n # start with longest path, first\n paths = paths.uniq.sort_by { |path| - path.length }\n end",
"def test_paths_as_arrays\n path = %w{/usr/bin /usr/sbin /sbin}\n exec = nil\n assert_nothing_raised(\"Could not use an array for the path\") do\n exec = Puppet::Type.type(:exec).new(:command => \"echo yay\", :path => path)\n end\n assert_equal(path, exec[:path], \"array-based path did not match\")\n assert_nothing_raised(\"Could not use a string for the path\") do\n exec = Puppet::Type.type(:exec).new(:command => \"echo yay\", :path => path.join(\":\"))\n end\n assert_equal(path, exec[:path], \"string-based path did not match\")\n assert_nothing_raised(\"Could not use a colon-separated strings in an array for the path\") do\n exec = Puppet::Type.type(:exec).new(:command => \"echo yay\", :path => [\"/usr/bin\", \"/usr/sbin:/sbin\"])\n end\n assert_equal(path, exec[:path], \"colon-separated array path did not match\")\n end",
"def paths_s\n \"['#{paths.join(\"','\")}']\"\n end",
"def position_string_to_array(string)\n size = Math.sqrt(string.length).to_i\n array = chunk(string, size).map { |row| chunk(row, 1) }\n array\n end",
"def position_string_to_array(string)\n size = Math.sqrt(string.length).to_i\n array = chunk(string, size).map { |row| chunk(row, 1) }\n array\n end",
"def components\n @components ||= @string.split('/').reject{|x| x == '' || x == nil} rescue []\n end",
"def convert_to_ar(str)\n bgn = 0\n cur = str[bgn]\n ar = []\n unless str.empty?\n str.length.times do |ind|\n next unless str[ind] != cur\n\n ar.append(str[bgn, ind - bgn])\n bgn = ind\n cur = str[ind]\n end\n ar.append(str[bgn, str.length])\n end\n ar\n end",
"def path_segments(path, segments = [])\n if path == '/'\n return segments\n else\n prefix, _ = File.split(path)\n return path_segments(prefix, [path] + segments)\n end\n end",
"def makelist(list)\n case list\n when String\n list = list.split(/[:;]/)\n else\n list = Array(list).map{ |path| path.to_s }\n end\n list.reject{ |path| path.strip.empty? }\n end",
"def makelist(list)\n case list\n when String\n list = list.split(/[:;]/)\n else\n list = Array(list).map{ |path| path.to_s }\n end\n list.reject{ |path| path.strip.empty? }\n end",
"def makelist(list)\n case list\n when String\n list = list.split(/[:;]/)\n else\n list = Array(list).map{ |path| path.to_s }\n end\n list.reject{ |path| path.strip.empty? }\n end",
"def string_to_array(string)\n string.split(\" \")\nend",
"def string_to_array(string)\n string.split(\" \")\nend",
"def scrub_path(p)\n np = \"\"\n for i in 0..(p.size-1)\n c = p[i]\n if c == '/'\n c = '\\\\'\n end\n np += c\n end\n np\nend",
"def config_flatten_order(*path, depth: 0)\n result = []\n path.map! { |p| p.is_a?(Array) ? p.compact_blank : p }.compact_blank!\n while path.present? && !path.first.is_a?(Array)\n part = path.shift\n unless part.is_a?(Symbol) || (part.is_a?(String) && part.include?('.'))\n part = part.to_s.to_sym\n end\n result << part\n end\n if (branches = path.shift)\n down_one = depth + 1\n branches = config_flatten_order(*branches, depth: down_one).flatten(1)\n if path.present?\n remainder = config_flatten_order(*path, depth: down_one).flatten(1)\n branches = branches.product(remainder)\n end\n result = branches.map { |branch| [*result, *branch].flatten }\n else\n result = [result]\n end\n if depth.zero?\n result.uniq!\n result.map! do |entry|\n entry.flat_map do |item|\n if item.is_a?(String)\n item.split('.').compact_blank.map(&:to_sym)\n else\n item\n end\n end\n end\n end\n result\n end",
"def path_parse(path)\n dest = OpenStruct.new\n dest.mach = path.split(\"/\")[3]\n dest.rname = path.split(\"/\")[4]\n dest.sample = path.split(\"/\")[5]\n dest.bc = path.split(\"/\")[8]\n dest\n end",
"def path_to_tags( path )\n return [] if @@no_implicit_tags\n return [] if path.nil? \n if @@split_implicit_tags\n tags_array = path.split(\"/\").find_all { |e| e.size > 0 }\n tags_array.pop # Last item is the entry title\n else\n tags_array = [ File.dirname( path )]\n end\n tags_array.map { |e| e == '.' ? @@root_tag : e }.compact\n end",
"def line_split str\n content = str.split(': ')[1] || ''\n if content.match /\\//\n content.split('/').map(&:strip).reject(&:empty?)\n else\n content\n end\n end",
"def paths_to_json\n JSON.unparse(paths_to_array) \n end",
"def split_paths\n symbols = ox_doc.locate('svg/defs/g/symbol')\n symbols.each do |symbol|\n path = symbol.nodes.first\n parsed_path = Savage::Parser.parse(path[:d])\n subpath_elements = []\n\n parsed_path.subpaths.each do |subpath|\n path_element = Ox::Element.new('path').tap { |prop| prop[:d] = subpath.to_command }\n subpath_elements.push path_element\n end\n\n symbol.nodes.clear\n subpath_elements.each { |pth| symbol << pth }\n end\n end",
"def parse_format(path)\n # format appears after the last period.\n remainder, dot, format = path.rpartition('.')\n return [path, ''] if dot.empty?\n return [remainder, format]\n end",
"def from_pathname(path) # :nodoc:\n path = path.to_path if path.respond_to?(:to_path)\n path = path.to_str if path.respond_to?(:to_str)\n path\n end",
"def [](value)\n return nil if value.nil?\n \n if not value.kind_of? String\n raise ArgumentInvalidTypeError.new 'value', value, String\n end\n \n current_path_part = self\n path_parts = value.split('.')\n counter = 1\n path_parts.each do |part|\n current_path_part = current_path_part.child_path_part(part)\n return nil if current_path_part.nil?\n end\n return current_path_part\n end",
"def parse_directory_name path\n dirname = path.basename.to_s\n dirname.split('.')\n end",
"def split_path(path)\n m = CHEF_OBJECT_RE.match(path)\n unless m\n warn \"Skipping '#{path}' -- it doesn't look like '*cookbooks/**/*', '*roles/*.{rb,json}', '*environments/*.{rb,json}' or '*data_bags/*.{rb,json}'\"\n return\n else\n parent_seg, child_seg = m.captures\n child_seg.gsub!(/\\.(rb|json)$/, \"\")\n extension = $1\n [parent_seg, child_seg, extension]\n end\n end",
"def relative_path(path)\n # replace array referenced IN the path\n first_pass = path.gsub(/\\/([^\\/]+)\\[\\d+\\]\\//i,\"/*/\")\n # replace array references AT THE END of the path too\n first_pass.gsub(/\\/([^\\/]+)\\[\\d+\\]$/,\"/*\")\n end",
"def paths(arr, s, d)\n if invalid?(arr, s, d)\n return\n end\n\n if s == d\n $path_count = $path_count + 1\n return\n end\n\n cells = valid_cells(arr, s)\n cells.each do |cell|\n paths(arr, cell, d)\n end\nend",
"def subtag2array(str)\n sep = \"\\001\"\n str.gsub(/\\n(\\s{1,#{@tagsize-1}}\\S)/, \"\\n#{sep}\\\\1\").split(sep)\n end",
"def path_components\n ENV[\"PATH\"].split(File::PATH_SEPARATOR)\n end",
"def simplify_path(path)\n path_tokens = path.split(\"/\").reject{ |x| x.empty? || x == \".\" }\n stack = []\n path_tokens.each{ |x|\n if x == \"..\"\n stack.pop if stack.any?\n else\n stack.push(x)\n end\n }\n\n \"/\" << stack.join(\"/\")\nend",
"def path_from_start_elements(start, elements = [])\n (start.empty? ? '/' : '') + elements.join('/')\nend",
"def fully_split_pathname(pathname, accumulator = nil)\n accumulator ||= Array.new\n rest, last = pathname.split\n accumulator << last.to_s\n if rest.to_s == '.'\n return accumulator.reverse\n else\n return fully_split_pathname(rest, accumulator)\n end\n end",
"def convert_log_file_time(string)\n\tarray=Array.new(2)\t\n\tarray=string.gsub(/:/,\".\").split(\"/\")\n\t#if (array[1]!=nil or array[1]==\"\") then array[1]=string.split(\"/\")[1].gsub(/:/,\".\") end\n\treturn array\nend",
"def parse(paths = T.unsafe(nil), excluded = T.unsafe(nil), level = T.unsafe(nil)); end",
"def parse_path(d)\n\t\t\tparsed = ''\n\t\t\twhile (off = (d =~ /[A-Za-z]/))\n\t\t\t\tcommand = d[off]\n\t\t\t\td.slice!(0..off)\n\t\t\t\tif @@command_arities.has_key? command.upcase.to_sym\n\t\t\t\t\tarity = @@command_arities[command.upcase.to_sym]\n\t\t\t\t\tarity = [arity] unless arity.is_a? Array\n\t\t\t\t\targs = arity.map do |n|\n\t\t\t\t\t\tnums = []\n\t\t\t\t\t\tn.times do |i|\n\t\t\t\t\t\t\toff = (d =~ /[-0-9]+/)\n\t\t\t\t\t\t\toff += ($~[0].length-1)\n\t\t\t\t\t\t\td.slice!(0..off)\n\t\t\t\t\t\t\tnums << $~[0]\n\t\t\t\t\t\tend\n\t\t\t\t\t\tnums\n\t\t\t\t\tend\n\t\t\t\t\tparsed += \" #{command} #{args.map{|s| s.join(' ')}.join(', ')}\"\n\t\t\t\tend\n\t\t\tend\n\t\t\treturn parsed.slice(1..-1) #cut off initial space\n\t\tend",
"def expand_path(path)\n return [] if path.start_with?('/**')\n\n begin\n if path.include?('*')\n return Dir.glob(path)\n else\n return [path]\n end\n rescue\n Puppet.debug(\"incron_system_table: Error occurred processing '#{path}': #{e}\")\n return []\n end\n end",
"def path_string_to_files(path_string)\n path_args = parse_path_string(path_string.sub(/.js$/, \"\"))\n files = []\n path_args[:include].each {|tag| files += get_associated_files(tag).to_a }\n path_args[:exclude].each {|tag| files -= get_associated_files(tag).to_a }\n files\n end",
"def arrayofpathelements=(thePath)\n unless (@elementHash[:elementtype].eql? :strokepath) ||\n (@elementHash[:elementtype].eql? :fillpath) ||\n (@elementHash[:elementtype].eql? :fillandstrokepath)\n fail \"Allowed elementtype are: strokepath, fillpath, fillandstrokepath\"\n end\n thePath = thePath.patharray if thePath.respond_to? \"patharray\"\n @elementHash[:arrayofpathelements] = thePath\n end",
"def initPaths( path )\n\t\t@path = Array::new(path) # ruby does assignments by reference\n\t\tif @type != 'text'\n\t\t\[email protected]_index { |i|\n\t\t\t\tif i-1 >= 0\n\t\t\t\t\t@content[i-1].next = @content[i]\n\t\t\t\tend\n\t\t\t\tif i+1 < @content.length\n\t\t\t\t\t@content[i+1].prev = @content[i]\n\t\t\t\tend\n\t\t\t\t@content[i].parent = self\n\t\t\t\t@content[i].initPaths( path.push(i) )\n\t\t\t\tpath.pop\n\t\t\t}\n\t\tend\n\tend",
"def toptag2array(str)\n sep = \"\\001\"\n str.gsub(/\\n([A-Za-z\\/\\*])/, \"\\n#{sep}\\\\1\").split(sep)\n end",
"def sentence_to_array (string)\n string_split = string.split('.')\n string_split.map! do |words|\n words.split('!') \n end\n string_split.flatten!\n\n string_split.map! do |words|\n words.split('?') \n end\n string_split.flatten\nend",
"def PathExpr(path, parsed); end",
"def parts\n prefix, parts = split_names(@path)\n prefix.empty? ? parts : [prefix] + parts\n end",
"def get_path_pins(path); end",
"def get_path_pins(path); end"
] | [
"0.66763914",
"0.6372118",
"0.6334941",
"0.6334941",
"0.6324023",
"0.61564857",
"0.6069321",
"0.6066315",
"0.59618604",
"0.5960444",
"0.59602547",
"0.59581316",
"0.59389573",
"0.5933138",
"0.591935",
"0.5890538",
"0.5838689",
"0.579191",
"0.5791829",
"0.5783735",
"0.5760701",
"0.5757362",
"0.5757362",
"0.5757362",
"0.5745845",
"0.56927574",
"0.56849194",
"0.56821716",
"0.5679945",
"0.56262845",
"0.5611984",
"0.5611892",
"0.55994034",
"0.55994034",
"0.5598635",
"0.55887026",
"0.55508596",
"0.54953915",
"0.5485796",
"0.54845494",
"0.5429634",
"0.5414137",
"0.5398872",
"0.53912234",
"0.5381006",
"0.53749794",
"0.53567594",
"0.5355826",
"0.53418446",
"0.5265441",
"0.526251",
"0.5250071",
"0.52342415",
"0.5216907",
"0.51887083",
"0.5187443",
"0.51826745",
"0.5181145",
"0.51730376",
"0.51730376",
"0.5168482",
"0.51579416",
"0.5156264",
"0.5137459",
"0.5137459",
"0.5137459",
"0.51372206",
"0.51372206",
"0.51335245",
"0.5132201",
"0.51253325",
"0.5121477",
"0.51155853",
"0.511238",
"0.5109496",
"0.5106929",
"0.5093178",
"0.507842",
"0.5074481",
"0.5062553",
"0.5058416",
"0.5048214",
"0.50473225",
"0.50472087",
"0.50468975",
"0.5039518",
"0.50381726",
"0.5014283",
"0.5011218",
"0.5002956",
"0.50013566",
"0.4985538",
"0.49846646",
"0.49800417",
"0.49595094",
"0.4958651",
"0.4956846",
"0.4956561",
"0.49410915",
"0.49410915"
] | 0.7467731 | 0 |
get the content tree for a subdirectory (creating it if it doesn't yet exist) N Without this we can't create the content tree for an immediate subdirectory of the directory represented by this content tree (which means we can't recursively create the full content tree for this directory) | def getContentTreeForSubDir(subDir)
#N Without this we won't know if the relevant sub-directory content tree hasn't already been created
dirContentTree = dirByName.fetch(subDir, nil)
#N Without this check, we'll be recreated the sub-directory content tree, even if we know it has already been created
if dirContentTree == nil
#N Without this the new sub-directory content tree won't be created
dirContentTree = ContentTree.new(subDir, @pathElements)
#N Without this the new sub-directory won't be added to the list of sub-directories of this directory
dirs << dirContentTree
#N Without this we won't be able to find the sub-directory content tree by name
dirByName[subDir] = dirContentTree
end
return dirContentTree
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getContentTree(baseDir)\n #N Without this, wouldn't have an empty content tree that we could start filling with dir & file data\n contentTree = ContentTree.new()\n #N Without this, wouldn't record the time of the content tree, and wouldn't be able to determine from a file's modification time that it had been changed since that content tree was recorded.\n contentTree.time = Time.now.utc\n #N Without this, the listed directories won't get included in the content tree\n for dir in listDirectories(baseDir)\n #N Without this, this directory won't get included in the content tree\n contentTree.addDir(dir)\n end\n #N Without this, the listed files and hashes won't get included in the content tree\n for fileHash in listFileHashes(baseDir)\n #N Without this, this file & hash won't get included in the content tree\n contentTree.addFile(fileHash.relativePath, fileHash.hash)\n end\n return contentTree\n end",
"def sub_content \n sub_contents = []\n\n if @is_post == false\n root_regexp = Regexp.new(@root, Regexp::IGNORECASE)\n sub_directories = Dir.glob(@absolute_path + '*');\n\n sub_directories.each do |sub_directory|\n begin\n # Remove the root from the path we pass to the new Content instance.\n # REVIEW: Should we be flexible and allow for the root dir to be present?\n content = Content.new(sub_directory.sub(root_regexp, ''))\n sub_contents.push(content)\n rescue ArgumentError\n next\n end\n end\n end\n\n sub_contents.reverse\n end",
"def getContentTree\n #N Without this we won't have timestamp and the map of file hashes used to efficiently determine the hash of a file which hasn't been modified after the timestamp\n cachedTimeAndMapOfHashes = getCachedContentTreeMapOfHashes\n #N Without this we won't have the timestamp to compare against file modification times\n cachedTime = cachedTimeAndMapOfHashes[0]\n #N Without this we won't have the map of file hashes\n cachedMapOfHashes = cachedTimeAndMapOfHashes[1]\n #N Without this we won't have an empty content tree which can be populated with data describing the files and directories within the base directory\n contentTree = ContentTree.new()\n #N Without this we won't have a record of a time which precedes the recording of directories, files and hashes (which can be used when this content tree is used as a cached for data when constructing some future content tree)\n contentTree.time = Time.now.utc\n #N Without this, we won't record information about all sub-directories within this content tree\n for subDir in @baseDirectory.subDirs\n #N Without this, this sub-directory won't be recorded in the content tree\n contentTree.addDir(subDir.relativePath)\n end\n #N Without this, we won't record information about the names and contents of all files within this content tree\n for file in @baseDirectory.allFiles\n #N Without this, we won't know the digest of this file (if we happen to have it) from the cached content tree\n cachedDigest = cachedMapOfHashes[file.relativePath]\n #N Without this check, we would assume that the cached digest applies to the current file, even if one wasn't available, or if the file has been modified since the time when the cached value was determined.\n # (Extra note: just checking the file's mtime is not a perfect check, because a file can \"change\" when actually it or one of it's enclosing sub-directories has been renamed, which might not reset the mtime value for the file itself.)\n if cachedTime and cachedDigest and File.stat(file.fullPath).mtime < cachedTime\n #N Without this, the digest won't be recorded from the cached digest in those cases where we know the file hasn't changed\n digest = cachedDigest\n else\n #N Without this, a new digest won't be determined from the calculated hash of the file's actual contents\n digest = hashClass.file(file.fullPath).hexdigest\n end\n #N Without this, information about this file won't be added to the content tree\n contentTree.addFile(file.relativePath, digest)\n end\n #N Without this, the files and directories in the content tree might be listed in some indeterminate order\n contentTree.sort!\n #N Without this check, a new version of the cached content file will attempt to be written, even when no name has been specified for the cached content file\n if cachedContentFile != nil\n #N Without this, a new version of the cached content file (ready to be used next time) won't be created\n contentTree.writeToFile(cachedContentFile)\n end\n return contentTree\n end",
"def getContentTree\n #N Without this check we would try to read the cached content file when there isn't one, or alternatively, we would retrieve the content details remotely, when we could have read them for a cached content file\n if cachedContentFile and File.exists?(cachedContentFile)\n #N Without this, the content tree won't be read from the cached content file\n return ContentTree.readFromFile(cachedContentFile)\n else\n #N Without this, we wouldn't retrieve the remote content details\n contentTree = contentHost.getContentTree(baseDir)\n #N Without this, the content tree might be in an arbitrary order\n contentTree.sort!\n #N Without this check, we would try to write a cached content file when no name has been specified for it\n if cachedContentFile != nil\n #N Without this, the cached content file wouldn't be updated from the most recently retrieved details\n contentTree.writeToFile(cachedContentFile)\n end\n #N Without this, the retrieved sorted content tree won't be retrieved\n return contentTree\n end\n end",
"def get_contents \n @contents = []\n\n sub_directory_names = Dir[CONTENT_ROOT_DIRECTORY + \"/*\"]\n\n sub_directory_names.each do |sub_directory_name|\n sub_directory_basename = File.basename(sub_directory_name)\n @contents.push(Content.new(sub_directory_basename))\n end\n end",
"def tree(path)\n root.tree(path)\n end",
"def sub_tree\n files = ProjectFile.where(directory_id: id)\n files = files.nil? ? [] : files \n\n files.sort{|x,y| \n if x.is_directory and not y.is_directory\n -1\n elsif not x.is_directory and y.is_directory\n 1\n else\n x.name <=> y.name\n end\n }\n end",
"def build_tree tree_root=nil\n tree_root ||= self.tree_root\n Dir.mkdir(tree_root) unless File.directory?(tree_root)\n Dir.chdir(tree_root) do\n self.files.each do |entry|\n visit_tree entry do |type, name|\n case type\n when :file\n FileUtils.touch(name)\n when :directory\n Dir.mkdir(name)\n else\n throw \"BAD VISIT TREE TYPE. #{type}\"\n end\n end\n end\n end\n end",
"def get_children(directory)\n file = Pathname.new(directory)\n if file.directory?\n file.children\n else \n []\n end\nend",
"def traverse_and_create path\n root = @folder_cache.values.find{|file| file.name == ROOT_FOLDER and file.parents.nil?}\n\n #DriveV3::File (actually folders)\n files = [root]\n places = path.split '/'\n places.each do |place|\n next if place == ''\n folder = folder_with_name place, files.last\n folder = create_folder(place, files.last) if folder.nil?\n files << folder\n end\n files.last\n end",
"def folder_tree\n parent_folder_id =\n unsafe_params[:parent_folder_id] == \"\" ? nil : unsafe_params[:parent_folder_id].to_i\n scoped_parent_folder_id =\n unsafe_params[:scoped_parent_folder_id] == \"\" ? nil : unsafe_params[:scoped_parent_folder_id].to_i\n\n if unsafe_params[:scopes].present?\n check_scope!\n # exclude 'public' scope\n if unsafe_params[:scopes].first =~ /^space-(\\d+)$/\n spaces_members_ids = Space.spaces_members_ids(unsafe_params[:scopes])\n spaces_params = {\n context: @context,\n spaces_members_ids: spaces_members_ids,\n scopes: unsafe_params[:scopes],\n scoped_parent_folder_id: scoped_parent_folder_id,\n }\n files = UserFile.batch_space_files(spaces_params)\n folders = Folder.batch_space_folders(spaces_params)\n else\n files = UserFile.batch_private_files(@context, [\"private\", nil], parent_folder_id)\n folders = Folder.batch_private_folders(@context, parent_folder_id)\n end\n end\n\n folder_tree = []\n Node.folder_content(files, folders).each do |item|\n folder_tree << {\n id: item[:id],\n name: item[:name],\n type: item[:sti_type],\n uid: item[:uid],\n scope: item[:scope],\n }\n end\n\n render json: folder_tree\n end",
"def build_directory_tree\n\n # Add the user's config directories to the \"ignore_dir\" option because these are all things we won't need printed in a NavTree.\n options.ignore_dir << app.config[:js_dir]\n options.ignore_dir << app.config[:css_dir]\n options.ignore_dir << app.config[:fonts_dir]\n options.ignore_dir << app.config[:images_dir]\n options.ignore_dir << app.config[:helpers_dir]\n options.ignore_dir << app.config[:layouts_dir]\n options.ignore_dir << app.config[:partials_dir]\n\n # Build a hash out of our directory information\n tree_hash = scan_directory(app.config[:source], options)\n\n # Write our directory tree to file as YAML.\n FileUtils.mkdir_p(app.config[:data_dir])\n data_path = app.config[:data_dir] + '/' + options.data_file\n IO.write(data_path, YAML::dump(tree_hash))\n end",
"def file_tree path = false, only_extensions = [], name = nil\n path = @path unless path\n data = { :name => (name || path) }\n data[:children] = children = []\n if(File.directory?(path) && File.exists?(path))\n Dir.foreach(path) do |entry|\n next if entry == '..' or entry == '.' or entry.start_with?(\".\")\n full_path = File.join(path, entry)\n if File.directory?(full_path)\n children << file_tree(full_path, only_extensions, entry)\n else\n if only_extensions.size > 0\n children << { :name => entry } if only_extensions.all? {|extension| true if entry.end_with?(extension) }\n else\n children << { :name => entry }\n end\n end\n end\n end\n return data\n end",
"def expand_tree(path)\n names = path.split('/')\n names.pop\n parent = work_tree\n names.each do |name|\n object = parent[name]\n break if !object\n if object.type == :blob\n parent.move(name, name + CONTENT_EXT)\n break\n end\n parent = object\n end\n end",
"def root_dir\n existing_paths = root_paths.select { |path| File.exist?(path) }\n if existing_paths.size > 0\n MultiplexedDir.new(existing_paths.map do |path|\n dir = FileSystemEntry.new(name, parent, path)\n dir.write_pretty_json = !!write_pretty_json\n dir\n end)\n end\n end",
"def expand_tree(path)\n names = path.split('/')\n names.pop\n parent = @git.root\n names.each do |name|\n object = parent[name]\n break if !object\n if object.type == :blob\n parent.move(name, name + CONTENT_EXT)\n break\n end\n parent = object\n end\n end",
"def getCachedContentTree\n #N Without this, we won't know the name of the specified cached content file (if it is specified)\n file = getExistingCachedContentTreeFile\n #N Without this check, we would attempt to read a non-existent file\n if file\n #N Without this, a content tree that has been cached won't be returned.\n return ContentTree.readFromFile(file)\n else\n return nil\n end\n end",
"def build_subtree(folder, include_files = true)\n folder_metadata = {}\n folder_metadata['subfolders'] = (folder.is_virtual? ?\n folder.subfolders : MaterialFolder.accessible_by(current_ability).where(:parent_folder_id => folder))\n .map { |subfolder|\n build_subtree(subfolder, include_files)\n }\n if (folder.parent_folder == nil) and not (folder.is_virtual?) then\n folder_metadata['subfolders'] += virtual_folders.map { |subfolder|\n build_subtree(subfolder, include_files)\n }\n end\n\n folder_metadata['id'] = folder.id\n folder_metadata['name'] = folder.name\n folder_metadata['url'] = folder.is_virtual? ? course_material_virtual_folder_path(@course, folder) : course_material_folder_path(@course, folder)\n folder_metadata['parent_folder_id'] = folder.parent_folder_id\n folder_metadata['count'] = folder.files.length\n folder_metadata['is_virtual'] = folder.is_virtual?\n if include_files then\n folder_metadata['files'] = (folder.is_virtual? ?\n folder.files : Material.accessible_by(current_ability).where(:folder_id => folder))\n .map { |file|\n current_file = {}\n\n current_file['id'] = file.id\n current_file['name'] = file.filename\n current_file['description'] = file.description\n current_file['folder_id'] = file.folder_id\n current_file['url'] = course_material_file_path(@course, file)\n\n if not(folder.is_virtual? || @curr_user_course.seen_materials.exists?(file.id)) then\n current_file['is_new'] = true\n folder_metadata['contains_new'] = true\n end\n\n current_file\n }\n end\n\n folder_metadata\n end",
"def GetDirectoryTreeFromRelativeBase(baseDirectory, excludePatterns=[], excludeEmpty=false)\n tree = GetDirectoryPathsFromRelativeBase(baseDirectory)\n tree.pop() # remove the base directory which is added again in the GetDirectoryTree call\n \n tree.concat(GetDirectoryTree(baseDirectory, excludePatterns, excludeEmpty))\n \n return tree\n end",
"def mkdir(path)\n names = path.split('/')\n names.shift\n node = @root\n until names.empty?\n name = names.shift\n node.mkdir(name) unless node.children.key?(name)\n node = node.children[name]\n end\n node\n end",
"def init_existing\n return unless current_directory?\n\n FolderTree.for_path linked_path, root: directory, limit: folder_limit\n end",
"def directory_hash(path, name=nil)\n data = {:folder => (name || path.split(\"/\").last)}\n data[:children] = children = []\n Dir.foreach(path) do |entry|\n next if (entry == '..' || entry == '.' || entry == 'yamproject.json' || entry == '.DS_Store')\n full_path = File.join(path, entry)\n if File.directory?(full_path)\n children << directory_hash(full_path, entry)\n else\n children << entry\n end\n end\n return data\nend",
"def content_path\n path = \"esm/#{self.esm.name}/#{self.name}/content\"\n file_path = \"public/#{path}\"\n p = file_path.split('/')\n i=0\n unless FileTest.exist?(file_path)\n while(s = \"public/esm/#{p[2...2+i].join('/')}\" and s!=file_path)\n Dir.mkdir(s) unless FileTest.exist?(s)\n i+=1\n end\n Dir.mkdir(s) unless FileTest.exist?(s)\n end\n return path\n end",
"def dfs(root, target_file, path = root.name)\n return path if root.name == target_file\n\n children = get_children(path)\n children.each do |child_path|\n child_node = Node.new(child_path.basename.to_s)\n root.children << child_node\n result = dfs(child_node, target_file, child_path)\n if result \n return result\n end\n end\n nil\nend",
"def get_sub_folder_contents\n # Convert the object received in parameters to a FolderNode object.\n folder_node = (params[:reactParams2][:nodeType]).constantize.new\n params[:reactParams2][:child_nodes].each do |key, value|\n folder_node[key] = value\n end\n\n # Get all of the children in the sub-folder.\n child_nodes = folder_node.get_children(nil, nil, session[:user].id, nil, nil)\n\n # Serialize the contents of each node so it can be displayed on the UI\n contents = []\n child_nodes.each do |node|\n contents.push(serialize_sub_folder_to_json(node))\n end\n respond_to do |format|\n format.html { render json: contents }\n end\n end",
"def recursive_find_directories_and_files dirname\r\n base_path = self.class.lookup('ExtAdminSection').path + \"/templates/\"\r\n \r\n directories = []\r\n files = []\r\n \r\n Find.find(File.join(base_path, dirname)) do |path|\r\n if FileTest.directory?(path)\r\n directories << path.gsub(base_path, '')\r\n else\r\n files << path.gsub(base_path, '')\r\n end\r\n end\r\n \r\n return directories, files\r\n end",
"def GetDirectoryTree(baseDirectory, excludePatterns=[], excludeEmpty=false)\n subdirs = [baseDirectory]\n baseDirectory.SubPaths().each do |subPath|\n\tpathExcluded = false\n\n excludePatterns.each do |pattern|\n if(subPath.RelativePath.match(pattern) != nil)\n pathExcluded = true\n break\n end\n end\n\n if(pathExcluded)\n #puts \"Excluding path #{subdirPath}\"\n next\n end\n\n if(subPath.directory?() && !(excludeEmpty && subPath.EmptyDirectory?()))\n\t subTree = GetDirectoryTree(subPath, excludePatterns, excludeEmpty)\t \n\t subdirs = subdirs + subTree\n end\n end\n return subdirs\n end",
"def sub_dir\n dir_name = \"Archive #{@t.month}-#{@t.day}-#{@t.year}\"\n sub_dir_name = \"#{@archive_folder}/#{dir_name}\"\n\n Dir.mkdir(sub_dir_name) unless Dir.exist?(sub_dir_name)\n return sub_dir_name\nend",
"def build_partial_navigation_tree(value, depth = Float::INFINITY, key = nil, level = 0)\n navigation_tree = \"\"\n\n if value.is_a?(String)\n\n # This is a file.\n # Get the Sitemap resource for this file.\n # note: sitemap.extensionless_path converts the path to its 'post-build' extension.\n this_resource = resource_from_value(value)\n\n return \"\" if this_resource.nil?\n\n unless extensions[:navtree].options[:directory_index] && this_resource.directory_index?\n navigation_tree << child_li(this_resource) if this_resource\n end\n else\n\n # This is the first level source directory. We treat it special because it has no key and needs no list item.\n if key.nil?\n value.each do |newkey, child|\n navigation_tree << build_partial_navigation_tree(child, depth, newkey, level + 1)\n end\n\n # Continue rendering deeper levels of the tree, unless restricted by depth.\n elsif depth >= (level + 1)\n\n # Loop through all the directory's contents.\n directory_content = \"\"\n value.each do |newkey, child|\n directory_content << build_partial_navigation_tree(child, depth, newkey, level + 1)\n end\n\n directory_content_html = render_partial(extensions[:navtree].options[:navigation_tree_items_container], { :directory_content => directory_content })\n\n # This is a directory.\n # The directory has a key and should be listed in the page hieararcy with HTML.\n navigation_tree << parent_li(key, value, directory_content_html)\n end\n end\n\n return navigation_tree\n end",
"def import_content(directory, parent_folder = nil)\n Dir.new(directory).each do |path|\n next if path.match(/^\\.+/)\n \n # Create a new Webbastic::ContentDir object for every folders\n if FileTest.directory?(File.join(directory, path))\n if parent_folder\n @folder = parent_folder.children.create :name => path\n else\n @folder = self.folders.create :name => path\n end\n import_content(File.join(directory, path), @folder)\n \n # Create a new Webbastic::Page object for every files\n # and read its content to put it in a static widget\n else\n if parent_folder\n @page = parent_folder.pages.create :name => path, :layout => self.default_layout\n else\n @page = self.pages.create :name => path, :layout => self.default_layout\n end\n \n file = File.new(File.join(directory, path), \"r\")\n content = \"\"\n while (line = file.gets)\n content << line\n end\n file.close\n \n @page.add_static_content\n end\n end\n end",
"def subdirs_to_create(dir, user)\n Chef::Log.info(\"Dir to create: #{dir}, user: #{user}\")\n existing_subdirs = []\n remaining_subdirs = dir.split('/')\n remaining_subdirs.shift # get rid of '/'\n\n until remaining_subdirs.empty?\n Chef::Log.debug(\"remaining_subdirs: #{remaining_subdirs.inspect}, existing_subdirs: #{existing_subdirs.inspect}\")\n path = existing_subdirs.push('/' + remaining_subdirs.shift).join\n break unless File.exist?(path)\n raise \"Path #{path} exists and is a file, expecting directory.\" unless File.directory?(path)\n raise \"Directory #{path} exists but is not traversable by #{user}.\" unless can_traverse?(user, path)\n end\n\n new_dirs = [existing_subdirs.join]\n new_dirs.push(new_dirs.last + '/' + remaining_subdirs.shift) until remaining_subdirs.empty?\n new_dirs\n end",
"def tree(root = '')\n build_hash(files(root), root)\n end",
"def build_tree(tree, parts, path)\n path += '/' unless path.empty? || path.end_with?('/')\n parts[0...-1].each do |p|\n path += \"#{p}/\"\n tree[p] ||= { type: :directory, path: path, sub: {} }\n tree = tree[p][:sub]\n end\n fname = parts[-1]\n tree[fname] = { type: :text, path: path + fname }\n end",
"def get_level_children(dirname,level) #:nodoc:\n dir_children = full_entries(dirname)\n @level_children += dir_children\n if level < @max_level\n dir_children.each {|e|\n if File.directory?(e)\n get_level_children(e,level + 1)\n end\n }\n end\n end",
"def subdir\n (@subdir) ? Pathname.new(@subdir) : Pathname.new('.')\n end",
"def create\n @content = Content.new(params[:content])\n\n respond_to do |format|\n if @content.save\n Searcher.open(Const.get('searcher_db')) do |db|\n db.regist(@content)\n end\n flash[:notice] = \"'#{@content.title}'が作成されました。: #{@content.path}\"\n \n @parent = Content.find(params[:parent_id]) if params[:parent_id]\n if @parent != nil\n @parent.children << @content\n format.html { redirect_to(@parent) }\n else\n fid = session[:folder_id]\n fid = params[:content][:folder_id] if fid == nil\n @folder = Folder.find(fid)\n format.html { redirect_to(@folder) }\n end\n format.xml { render :xml => @content, :status => :created, :location => @content }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @content.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def node_at(*path)\n return self if path.empty?\n\n # recursive loop ends when last path_node is shifted off the array\n attributes = {'fs_name' => path.shift}\n\n # create and add the child node if it's not found among the immediate\n # children of self\n child = children.find do |c|\n c.node_name == 'dir' && c.fs_name == attributes['fs_name']\n end\n unless child\n child = Node.new_node('dir', document, attributes)\n add_child(child)\n end\n\n child.node_at(*path)\n end",
"def build_category_tree(n, child = nil)\n amz_node = BrowseNode.parse(n.to_s)\n amz_node.child = child unless child.nil?\n\n if n.search(\"./IsCategoryRoot\").size > 0\n @category_tree[amz_node.name] ||= []\n @category_tree[amz_node.name] << amz_node\n else\n parents = n.search(\"./Ancestors/BrowseNode\")\n if parents.size > 0\n build_category_tree(parents[0], amz_node)\n end\n end\n\n\n end",
"def mkdir(name)\n return self if name == '.'\n name = name[1..-1] if name[0] == '/'\n newdir, *remainder = name.split('/')\n subdir = get(newdir)\n unless subdir.dir?\n result = @od.request(\"#{api_path}/children\",\n name: newdir,\n folder: {},\n '@microsoft.graph.conflictBehavior': 'rename'\n )\n subdir = OneDriveDir.new(@od, result)\n end\n remainder.any? ? subdir.mkdir(remainder.join('/')) : subdir\n end",
"def children\n # Check to see whether dir exists.\n Slimdown::Folder.new(@absolute_path.chomp('.md')).pages\n end",
"def folder_tree\n render :partial => 'folder_tree', :locals => { :site_mapping => SiteMapping.find(params[:site_mapping_id]) }\n end",
"def make_directory_tree\n project_tmp = \"/tmp/#{@package_name}\"\n @scratch = \"#{project_tmp}/#{@title}\"\n @working_tree = {\n 'scripts' => \"#{@scratch}/scripts\",\n 'resources' => \"#{@scratch}/resources\",\n 'working' => \"#{@scratch}/root\",\n 'payload' => \"#{@scratch}/payload\",\n }\n puts \"Cleaning Tree: #{project_tmp}\"\n FileUtils.rm_rf(project_tmp)\n @working_tree.each do |key,val|\n puts \"Creating: #{val}\"\n FileUtils.mkdir_p(val)\n end\n File.open(\"#{@scratch}/#{'prototype.plist'}\", \"w+\") do |f|\n f.write(ERB.new(File.read('tasks/templates/prototype.plist.erb')).result())\n end\n File.open(\"#{@working_tree[\"scripts\"]}/preflight\", \"w+\") do |f|\n f.write(ERB.new(File.read('ext/osx/preflight.erb')).result())\n end\nend",
"def find_or_create_folder(folder_root, name)\n folder_root.childEntity.each do |child|\n if child.instance_of?(RbVmomi::VIM::Folder) &&\n child.name == name\n return child\n end\n end\n\n folder_root.CreateFolder(:name => name)\n end",
"def get_remote_files_hierarchy(files, root = '/', hierarchy = { dirs: [], files: [] })\n files.each do |node|\n case node['node_type']\n when 'directory'\n hierarchy[:dirs] << \"#{root}#{node['name']}\"\n get_remote_files_hierarchy(node['files'], root + node['name'] + '/', hierarchy)\n when 'file'\n hierarchy[:files] << \"#{root}#{node['name']}\"\n end\n end\n\n return hierarchy\nend",
"def subdirs_to_create(dir, user)\n Chef::Log.debug(\"Dir to create: #{dir}, user: #{user}\")\n existing_subdirs = []\n remaining_subdirs = dir.split('/')\n remaining_subdirs.shift # get rid of '/'\n reason = ''\n \n until remaining_subdirs.empty?\n Chef::Log.debug(\"remaining_subdirs: #{remaining_subdirs.inspect}, existing_subdirs: #{existing_subdirs.inspect}\")\n path = existing_subdirs.push('/' + remaining_subdirs.shift).join\n break unless File.exist?(path)\n reason = \"Path \\'#{path}\\' exists and is a file, expecting directory.\" unless File.directory?(path)\n reason = \"Directory \\'#{path}\\' exists but is not traversable by user \\'#{user}\\'.\" unless can_traverse?(user, path)\n end\n\n new_dirs = [existing_subdirs.join]\n new_dirs.push(new_dirs.last + '/' + remaining_subdirs.shift) until remaining_subdirs.empty?\n [new_dirs, reason]\n end",
"def get_remote_files_hierarchy(files, root = '/', hierarchy = { dirs: [], files: [] })\n files.each do |node|\n case node['node_type']\n when 'directory'\n hierarchy[:dirs] << \"#{root}#{node['name']}\"\n get_remote_files_hierarchy(node['files'], root + node['name'] + '/', hierarchy)\n when 'file'\n hierarchy[:files] << \"#{root}#{node['name']}\"\n end\n end\n\n hierarchy\nend",
"def build_directory root\n root += \"/\" if not root.end_with? \"/\" # add backslash for later concatenation\n if not caller[0] =~ /.*build_directory.*/\n puts \"Building in #{root + @name}.\"\n puts \"Warning. No files in this package tree.\" if file_count == 0\n end\n Dir.mkdir(root + @name) if not File.exist? root + @name # make root dir if not already present\n @files.each do |file|\n puts \"Copying file #{File.basename file} to #{root + @name}.\" if @verbose\n begin\n if @verbose and File.exists? root + @name\n puts \"File already present.\"\n end\n cp file, root + @name \n rescue ArgumentError # raised if files are identical\n puts \"Warning: Can't copy #{File.basename file}. Source and destination are identical.\"\n end\n end\n @subpackages.each_value do |p| # recursively build directory tree\n p.build_directory root + @name\n end\n end",
"def list(path, recursive=true, dirs=false)\n # TODO : this might need to be changed as it returns dir and contents\n # if there are contents\n nodes = []\n prune = recursive ? nil : 2\n @content_tree.with_subtree(path, nil, prune, dirs) do |node|\n nodes << node.path\n end\n nodes.sort.uniq\n end",
"def recurse_local\n result = perform_recursion(self[:path])\n return {} unless result\n result.inject({}) do |hash, meta|\n next hash if meta.relative_path == \".\"\n\n hash[meta.relative_path] = newchild(meta.relative_path)\n hash\n end\n end",
"def descend()\n @path.scan(%r{[^/]*/?})[0...-1].inject('') do |path, dir|\n yield self.class.new(path << dir)\n path\n end\n end",
"def make_child_entry(name)\n if CHILDREN.include?(name)\n return nil unless root_dir\n\n return root_dir.child(name)\n end\n\n paths = (child_paths[name] || []).select { |path| File.exist?(path) }\n if paths.size == 0\n return NonexistentFSObject.new(name, self)\n end\n\n case name\n when \"acls\"\n dirs = paths.map { |path| AclsDir.new(name, self, path) }\n when \"client_keys\"\n dirs = paths.map { |path| ClientKeysDir.new(name, self, path) }\n when \"clients\"\n dirs = paths.map { |path| ClientsDir.new(name, self, path) }\n when \"containers\"\n dirs = paths.map { |path| ContainersDir.new(name, self, path) }\n when \"cookbooks\"\n if versioned_cookbooks\n dirs = paths.map { |path| VersionedCookbooksDir.new(name, self, path) }\n else\n dirs = paths.map { |path| CookbooksDir.new(name, self, path) }\n end\n when \"cookbook_artifacts\"\n dirs = paths.map { |path| CookbookArtifactsDir.new(name, self, path) }\n when \"data_bags\"\n dirs = paths.map { |path| DataBagsDir.new(name, self, path) }\n when \"environments\"\n dirs = paths.map { |path| EnvironmentsDir.new(name, self, path) }\n when \"groups\"\n dirs = paths.map { |path| GroupsDir.new(name, self, path) }\n when \"nodes\"\n dirs = paths.map { |path| NodesDir.new(name, self, path) }\n when \"policy_groups\"\n dirs = paths.map { |path| PolicyGroupsDir.new(name, self, path) }\n when \"policies\"\n dirs = paths.map { |path| PoliciesDir.new(name, self, path) }\n when \"roles\"\n dirs = paths.map { |path| RolesDir.new(name, self, path) }\n when \"users\"\n dirs = paths.map { |path| UsersDir.new(name, self, path) }\n else\n raise \"Unknown top level path #{name}\"\n end\n MultiplexedDir.new(dirs)\n end",
"def get_remote_files_hierarchy(files, root = '/', hierarchy = { dirs: [], files: [] })\n files.each do |node|\n case node['node_type']\n when 'branch'\n get_remote_files_hierarchy(node['files'], root + node['name'] + '/', hierarchy)\n when 'directory'\n hierarchy[:dirs] << \"#{root}#{node['name']}\"\n get_remote_files_hierarchy(node['files'], root + node['name'] + '/', hierarchy)\n when 'file'\n hierarchy[:files] << \"#{root}#{node['name']}\"\n end\n end\n\n return hierarchy\nend",
"def read_content_from_file(file_path)\n names = file_path.split('/')\n file_name = names.pop\n directory = self.mkdir(names.join('/'))\n directory.children[file_name].content\n end",
"def subdirectories()\n children.select { |c| c.directory? }\n end",
"def build_collage_folder( collage )\n path = collage.path\n logger.info 'CollagesHelper - build_collage_folder() - path: ' + path.to_s\n FileUtils.mkdir_p( path ) unless File.directory?( path )\n fetch_content( collage )\n end",
"def recursive_mkdir( directory )\n begin\n # Attempt to make the directory\n Dir.mkdir( directory )\n rescue Errno::ENOENT\n # Failed, so let's use recursion on the parent directory\n base_dir = File.dirname( directory )\n recursive_mkdir( base_dir )\n \n # Make the original directory\n Dir.mkdir( directory )\n end\nend",
"def file_tree(root, tree_contents)\n set_pwd = nil\n tree_contents.each do |tree_entry|\n if tree_entry.start_with?('pwd:')\n raise 'Already have a pwd selected' if set_pwd\n tree_entry = tree_entry.sub(/^pwd:/, '')\n raise \"#{tree_entry} is not a directory entry (must end with /), can't use as pwd\" unless tree_entry.end_with?('/')\n set_pwd = true # Set later\n end\n\n # Avoid a simple mistake\n tree_entry = tree_entry[1..-1] if tree_entry[0] == '/'\n\n path = File.absolute_path(tree_entry, root)\n set_pwd = path if set_pwd == true\n\n if tree_entry.end_with?('/')\n FileUtils.mkdir_p(path)\n else\n FileUtils.mkdir_p(File.dirname(path))\n content = if REQUIRABLE_EXTENSIONS[File.extname(path)] == :native_extension\n File.read(SAMPLE_NATIVE_LIB)\n else\n <<-RUBY\n $last_test_tree_file_executed = #{tree_entry.inspect}\n RUBY\n end\n File.write(path, content)\n end\n end\n\n Dir.chdir(set_pwd || '.')\n end",
"def tree(path)\n children = match(\"#{path}/*\").map { |p| tree(p) }\n Node.new(path, get(path), children)\n end",
"def tree\n read_repo\n if @branches.count < 1\n render :template => 'repositories/newrepo'\n return\n end\n\n @files = @repository.files(@branch, @path)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @repository }\n end\n end",
"def tree_root\n repo.tree\n end",
"def lookup(path, ctype=nil, recursive=false, path_only=true, dirs=false)\n # TODO : this might need to be changed as it returns dir and contents\n # if there are contents\n entries = []\n prune = recursive ? nil : 2\n @content_tree.with_subtree(path, ctype, prune, dirs) do |node|\n entries << [node.node_type, (path_only ? node.path : node)]\n end\n entries\n end",
"def root_folder\n if new_record?\n material_folders.find(&:root?) || (raise ActiveRecord::RecordNotFound)\n else\n material_folders.find_by!(parent: nil)\n end\n end",
"def browse_tree(tree = nil, cur = nil)\n return [[], []] if barerepo.empty?\n tree ||= barerepo.head.target.tree\n images = []\n directories = []\n tree.each do |item|\n next if item[:name][0] == '.'\n dest = cur.nil? ? item[:name] : File.join(cur, item[:name])\n if item[:type] == :blob\n images.push({\n data: barerepo.read(item[:oid]).data,\n dest: dest, name: item[:name]\n })\n else\n directories.push({\n dest: dest, name: item[:name]\n })\n end\n end\n [images, directories]\n end",
"def recursive_create_page(page, parent=nil)\n Globalize.locale = @master_locale\n puts \"#{page['title']}\"\n p = Refinery::Page.find_by_title page['title']\n if not p or p.parent != parent\n puts \"+++ Create page #{page['title']} (#{page['type']})\"\n if parent then\n p = parent.children.create :title => page['title'],\n :deletable => false,\n :view_template => page['type']\n else\n p = Refinery::Page.create :title => page['title'],\n :deletable => false,\n :view_template => page['type']\n end\n else\n puts \" === Found existing page #{page['title']} (#{page['type']})\"\n end\n if page.has_key?('skip_to_first_child') and page['skip_to_first_child'] != p.skip_to_first_child\n p.skip_to_first_child = page['skip_to_first_child']\n p.save\n end\n if page['parts'] then\n page['parts'].each_pair do |key, part|\n puts \" ++ create page part #{key}\"\n pp = p.parts.find_by_title(key)\n pp.body = part.strip\n pp.save\n end\n end\n if page['children'] then\n page['children'].each do |child|\n recursive_create_page child, p\n end\n end\n end",
"def tree(name, finder, partial = false, seen = {})\n logical_name = name.gsub(%r|/_|, \"/\")\n interpolated = name.include?(\"#\")\n\n path = TemplatePath.parse(name)\n\n if !interpolated && (template = find_template(finder, path.name, [path.prefix], partial, []))\n if node = seen[template.identifier] # handle cycles in the tree\n node\n else\n node = seen[template.identifier] = Node.create(name, logical_name, template, partial)\n\n deps = DependencyTracker.find_dependencies(name, template, finder.view_paths)\n deps.uniq { |n| n.gsub(%r|/_|, \"/\") }.each do |dep_file|\n node.children << tree(dep_file, finder, true, seen)\n end\n node\n end\n else\n unless interpolated # Dynamic template partial names can never be tracked\n logger.error \" Couldn't find template for digesting: #{name}\"\n end\n\n seen[name] ||= Missing.new(name, logical_name, nil)\n end\n end",
"def append_node(node, parent = nil)\n # Add the node to the parents node list\n add_entry(node, parent)\n\n # Recursively get all filesystem entries contained in the current folder\n if node.is_a? FileSystem::Folder then\n pattern = '/*'\n entries = Dir.glob(node.path + pattern).sort_by { |a| a.downcase }\n files = []\n folders = []\n\n # Store files and folders in different collections\n # because files will be added before folders\n entries.each do |e|\n if File.directory? e\n folders << e\n else\n files << e\n end\n end\n\n # First add contained files\n files.each do |f|\n file = build_entry(:file, @index, f, @left_entry)\n append_node(file, node)\n end\n\n # After add contained folders and its entries\n folders.each do |f|\n folder = build_entry(:folder, @index, f, @left_entry)\n append_node(folder, node)\n end\n end\n end",
"def create_folders_for full_path\n full_path = File.dirname(full_path)\n\n return if File.directory?(full_path) || [\"/\", \".\"].include?(full_path)\n create_folders_for(full_path)\n Dir::mkdir(full_path)\n end",
"def traverse_nav_tree_and_convert_to_xml(node)\n \n # traverse subfolders, go deep\n if node_has_children(node)\n node.children.items.each do |child|\n traverse_nav_tree_and_convert_to_xml(child)\n end\n end\n \n return if node.nav_level == 0\n \n mod = node.dup\n\n link = node.link\n full_link = node.full_link\n \n mod.parent_link = parent_link = node.link[0..(link.rindex(\"/\") - 1)] if node.nav_level > 1\n \n if CONTENT_LINK_PREFIX && CONTENT_LINK_PREFIX.length > 0\n full_link = mod.full_link = \"/\" + CONTENT_LINK_PREFIX + node.full_link unless node.full_link.start_with?(\"/#{CONTENT_LINK_PREFIX}\")\n end\n\n \n mod.delete :source_path\n mod.delete :parent_path\n mod.delete :children\n\n\n #puts \"storing [#{mod.nav_level}][#{mod.nav_order}][#{mod.nav_type}] - #{mod.nav_title}\"\n case mod.nav_type \n \n when \"folder\"\n\t\t# do nothing for these\n when \"markdown\"\n metadata, markdown = parse_markdown_file(node.source_path)\n\t\t\n\t\tfilepath_markdown = node.source_path.dup\t\t\n\t\tfilepath_markdown += \".markdown\"\tunless filepath_markdown.end_with? (\".markdown\")\t\t\n\t\tmod.updated_at = Chronic.parse(File.mtime(filepath_markdown).to_s).utc.to_i\n\t\t\n mod.metadata = metadata if metadata\n mod.markdown = markdown\n \n\t\thtml = MarkdownRender::render(mod.markdown)\n\t\tdoc = Nokogiri::HTML(html) \n\t\txml = doc.css('body')[0].serialize #(save_with: 0)\n\t\txml.gsub!(/^<p><img /, \"<img \")\n\t\txml = Nokogiri::XML(xml)\n\t\tb = xml.at_css \"body\"\n\t\tb.name = \"doc\"\n\t\t\n File.open(\"#{filepath_markdown.gsub(/.markdown/, \".xml\")}\", 'w') { |f| xml.write_xml_to f }\n\n when \"folder+markdown\"\n metadata, markdown = parse_markdown_file(node.source_path)\n\t\t\n\t\tfilepath_markdown = node.source_path.dup\t\t\n\t\tfilepath_markdown += \".markdown\"\tunless filepath_markdown.end_with? (\".markdown\")\t\t\n\t\tmod.updated_at = Chronic.parse(File.mtime(filepath_markdown).to_s).utc.to_i\n\t\t\n mod.metadata = metadata if metadata\n mod.markdown = markdown\n\n\t\thtml = MarkdownRender::render(mod.markdown)\n\t\tdoc = Nokogiri::HTML(html)\n\t\txml = doc.css('body')[0].serialize #(save_with: 0)\n\t\txml.gsub!(/^<p><img /, \"<img \")\n\t\txml = Nokogiri::XML(xml)\n\n img_sizes = {\n \"40%\" => \"min\",\n \"50%\" => \"small\",\n \"65%\" => \"medium\",\n \"100%\" => \"full\",\n \"600px\" => \"large\"\n }\n \n img_sizes.each do |size,name|\n img = xml.at_css \"img[width=\\\"#{size}\\\"]\"\n img['size'] = name if img\n puts img.inspect if img\n end\n\n\t\tb = xml.at_css \"body\"\n\t\tb.name = \"doc\"\n\t\t\n File.open(\"#{filepath_markdown.gsub(/.markdown/, \".xml\")}\", 'w') { |f| xml.write_xml_to f }\n end\n \nend",
"def get_entries(dir, subfolder); end",
"def tree\n @tree ||= build_tree\n end",
"def parent_dirs(file); end",
"def GetLevelDirs()\n directories = Dir.entries($level_folder)\n\n for i in 0...directories.length do\n\n if not directories[i].include? \".\" then\n $current_folder = $level_folder + directories[i] + \"/\"\n GetLevels($current_folder)\n end\n\n end\n\nend",
"def generate_content_paths\n\n # This code for updating the uid field with the id (primary key)\n self.update_attributes(:uid => self.id)\n\n # The first entry with the self parent\n first = ContentPath.new\n first.ancestor = self.id\n first.descendant = self.id\n first.depth = 0\n first.save\n\n # Getting the parent id of the content\n parent_id = ContentData.get_parent_id(self.id)\n\n # If a parent is found then putting all the Content Path Entries\n if parent_id > 0\n\n # Getting the parent id data\n parent = Content.find(parent_id)\n # Getting all the parents of the parent (NOTE: This also contains the current parent id)\n parent_parents = parent.parents\n if(parent_parents.length > 0)\n parent_parents.each do |p|\n\n # Creating the new content paths\n path = ContentPath.new\n path.ancestor = p[\"ancestor\"]\n path.descendant = self.id\n path.depth = p[\"depth\"]+1\n path.save\n end\n end\n end\n\n end",
"def add_page_to_tree(page)\n if !page.root?\n #puts \"page: #{page}\"\n #puts \"page.fullpath: #{page.fullpath}\"\n #puts \"page.parent_id: #{page.parent_id}\"\n page.parent = @remote_pages_by_id[page.parent_id]\n #puts \"page.parent: #{page.parent}\"\n #puts \"page.parent.class: #{page.parent.class}\"\n #puts \"page.parent.children: #{page.parent.children}\"\n page.parent.children << page\n end\n end",
"def build_sub_tree( parent_id, path_names )\n path_name_tokens = path_names.split( \"|\" )\n zone = path_name_tokens[1] \n \n if db_request?( path_name_tokens ) \n sub_tree = build_db_tree( parent_id, zone )\n else\n db_name = path_name_tokens.last \n sub_tree = build_cltn_tree( parent_id, zone, db_name )\n end\n sub_tree\n end",
"def last_folder\n return content_path unless request.params.has_key?(\"page\")\n path = request.params[\"page\"].split('/')\n File.join(content_path, path[0..-2])\n end",
"def last_folder\n return content_path unless request.params.has_key?(\"page\")\n path = request.params[\"page\"].split('/')\n File.join(content_path, path[0..-2])\n end",
"def tree_root\n if (root_id = visibility_path_ids.first)\n return content_model::Page.get(root_id)\n end\n nil\n end",
"def return_content_by_id(id)\n current = nil\n stack = Stack.new\n stack.push(@root)\n until stack.empty?\n current = stack.pop\n return current if current.id.eql?(id)\n unless current.childs.size.zero?\n current.childs.reverse_each { |child| stack.push(child) }\n end\n end\n end",
"def recurse_otml_dirs(&block)\n return unless self.has_otmls\n yield(self)\n self.children.each do |child|\n child.recurse_otml_dirs(&block)\n end\nend",
"def make_directory(rev, full_path)\n if rev.path_exists?(full_path)\n raise Repository::FolderExistsConflict, full_path # raise conflict if path exists\n end\n creation_time = Time.current\n dir = Repository::RevisionDirectory.new(rev.revision_identifier, {\n name: File.basename(full_path),\n path: File.dirname(full_path),\n last_modified_revision: rev.revision_identifier,\n last_modified_date: creation_time,\n submitted_date: creation_time,\n changed: true,\n user_id: rev.user_id\n })\n rev.__add_directory(dir)\n rev\n end",
"def subdir(dir)\n dir = Pathname.new(dir) if dir.instance_of? String\n dir = Pathname.new('.') if dir.to_s =~ /\\.\\./ or dir.to_s =~ /^\\//\n dir = Pathname.new('.') if any_symlinks_in dir\n newdir = @path + dir\n Filesystem.new newdir\n end",
"def get_folder_contents\n # Get all child nodes associated with a top level folder that the logged in user is authorized\n # to view. Top level folders include Questionaires, Courses, and Assignments.\n folders = {}\n FolderNode.includes(:folder).get.each do |folder_node|\n child_nodes = folder_node.get_children(nil, nil, session[:user].id, nil, nil)\n # Serialize the contents of each node so it can be displayed on the UI\n contents = []\n child_nodes.each do |node|\n contents.push(serialize_folder_to_json(folder_node.get_name, node))\n end\n\n # Store contents according to the root level folder.\n folders[folder_node.get_name] = contents\n end\n\n respond_to do |format|\n format.html { render json: folders }\n end\n end",
"def retrieve_dirs(_base, dir, dot_dirs); end",
"def inside(dir = '', &block)\n folder = File.join(root, dir)\n FileUtils.mkdir_p(folder) unless File.exist?(folder)\n FileUtils.cd(folder) { block.arity == 1 ? yield(folder) : yield }\n end",
"def children\n return @children unless @children.nil?\n @children = if exists? && directory?\n Dir.glob( File.join(absolute_path,'*') ).sort.map do |entry|\n git_flow_repo.working_file(\n entry.gsub( /^#{Regexp.escape absolute_path}/, tree )\n )\n end\n else\n false\n end\n end",
"def depthTraversal2(path, parent = nil)\n\tif File.directory?(path)\n\t\tdir = handler.addDirectory(parent, path)\n\n\t\tDir.foreach(path) { |item|\n\t\t\tchild = path +\"/\"+ item\n\t\t\tif File.directory?(child)\n\t\t\t\tif item != '.' && item != '..'\n\t\t\t\t\tdepthTraversal(child, dir)\n\t\t\t\tend\n\t\t\telse\n\t\t\t\thandler.addFile(dir, item)\n\t\t\tend\n\t\t}\n\tend\nend",
"def inside(dir = '', &block)\r\n folder = File.join(root, dir)\r\n FileUtils.mkdir_p(folder) unless File.exist?(folder)\r\n FileUtils.cd(folder) { block.arity == 1 ? yield(folder) : yield }\r\n end",
"def get_children_folders(folder_id)\n url = URI(\"#{$base_url}/api/projects/#{$project_id}/folders/#{folder_id}/children\")\n\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n request = Net::HTTP::Get.new(url)\n request[\"accept\"] = 'application/vnd.api+json; version=1'\n request[\"access-token\"] = $access_token\n request[\"uid\"] = $uid\n request[\"client\"] = $client\n response = http.request(request)\n\n folders_json = ''\n\n if response.code == 200.to_s\n folders_json = JSON.parse(response.read_body)['data']\n else\n puts \"Problem with getting folders. Status: #{response.code}\"\n puts response.body\n end\n folders_json\nend",
"def build_root\n self.class.build_root.join(name)\n end",
"def mkdir_p(path, opts={})\n data = ''\n\n # if we haven't recursed, or we recursed and now we're back at the top\n if !opts.has_key?(:orig_path) or (path == opts[:orig_path])\n data = opts.fetch(:data, '') # only put the data at the leaf node\n end\n\n create(path, data, :mode => :persistent)\n rescue NodeExists\n if !opts.has_key?(:orig_path) or (path == opts[:orig_path]) # we're at the leaf node\n set(path, data)\n end\n\n return\n rescue NoNode\n if File.dirname(path) == '/'\n # ok, we're screwed, blow up\n raise NonExistentRootError, \"could not create '/', are you chrooted into a non-existent path?\", caller\n end\n\n opts[:orig_path] ||= path\n\n mkdir_p(File.dirname(path), opts)\n retry\n end",
"def dirs_until_dodona_dir\n dir = @pwd\n children = [dir]\n loop do\n return [] if dir.root?\n return children if dir == @dodona_dir\n children.unshift dir\n dir = dir.parent\n end\n end",
"def directory_subdirectories(path)\n\tputs ''\n\tfor i in subdir_paths(path)\n\t\tputs i\n\tend\n\tputs ''\n\treturn nil\nend",
"def dirs_from(dir)\r\n unless @dirs[dir].key?(:recursive_dirs)\r\n ensure_dir_data(dir)\r\n recursive_dirs = {}\r\n @dirs[dir][:dirs].keys.each do |subdir|\r\n full_subdir = \"#{dir}/#{subdir}\"\r\n recursive_dirs[full_subdir] = nil\r\n recursive_dirs.merge!(Hash[dirs_from(full_subdir).map { |subsubdir| [subsubdir, nil] }])\r\n end\r\n @dirs[dir][:recursive_dirs] = recursive_dirs\r\n end\r\n @dirs[dir][:recursive_dirs].keys\r\n end",
"def get_subdir_pages( directory )\n Dir[ File.join( directory, \"*.src\" ) ] - Dir[ File.join( directory, \"index.src\" ) ]\n end",
"def children( with_directory = ( self != '.' ) )\n ( Dir.entries( expand_tilde ) - DOTS ).map do | entry |\n with_directory ? join( entry ) : self.class.new( entry )\n end\n end",
"def tree\n # Caution: use only for small projects, don't use in root.\n @title = 'Full Tree'\n # @files = `zsh -c 'print -rl -- **/*(#{@sorto}#{@hidden}M)'`.split(\"\\n\")\n @files = Dir['**/*']\n message \"#{@files.size} files.\"\nend",
"def root\n return @root if @root\n @root = dir = Dir.pwd\n begin\n dir = File.dirname(dir)\n return @root = dir if File.exist?(File.join(dir, \"#{BASENAME}.rb\"))\n end while dir != '/'\n\n @root\n end",
"def make_tree(in_list, pid = self.pid)\n [].tap do |top_level|\n left_over = []\n # Categorize into top level, or not top level\n in_list.each do |node|\n if node['parent_page_id'].blank? || node['parent_page_id'] == pid\n top_level.unshift node\n else\n left_over.unshift node\n end\n end\n\n # For each of the top_level nodes make a subtree with the leftovers.\n top_level.each do |node|\n node['children'] = make_tree(left_over, node['id'])\n end\n end\n end",
"def create_tree(items, rootpage)\n _, tree = visit_nodes(items, rootpage.lft + 1, rootpage.id, rootpage.depth + 1, {}, \"\", rootpage.restricted)\n tree\n end"
] | [
"0.62971216",
"0.62222576",
"0.6052521",
"0.5828611",
"0.58244056",
"0.5779535",
"0.5749211",
"0.57088774",
"0.5687567",
"0.5676394",
"0.56480145",
"0.5604444",
"0.5598129",
"0.5568739",
"0.55377835",
"0.55223143",
"0.5521632",
"0.55180186",
"0.5499369",
"0.5484999",
"0.5451577",
"0.54091525",
"0.5398569",
"0.539074",
"0.5388566",
"0.53630537",
"0.5359791",
"0.534215",
"0.5291218",
"0.52834255",
"0.52796084",
"0.5279306",
"0.5263954",
"0.52564913",
"0.5251893",
"0.5246001",
"0.52452344",
"0.52451795",
"0.5244926",
"0.52292603",
"0.5190089",
"0.5183127",
"0.5180235",
"0.5168403",
"0.51579344",
"0.51472914",
"0.5144618",
"0.5104698",
"0.5104011",
"0.5085342",
"0.5081477",
"0.50697094",
"0.5068457",
"0.505839",
"0.50555885",
"0.50543565",
"0.5048299",
"0.5046884",
"0.5045924",
"0.5043723",
"0.50413644",
"0.5036531",
"0.5032969",
"0.50304294",
"0.50267345",
"0.50217646",
"0.50188667",
"0.501019",
"0.50019073",
"0.4998344",
"0.49812979",
"0.49799684",
"0.49783722",
"0.4977423",
"0.49762857",
"0.49717426",
"0.49717426",
"0.4969526",
"0.49454892",
"0.49361986",
"0.49167",
"0.4897856",
"0.48936966",
"0.4890182",
"0.48867613",
"0.48812315",
"0.4876729",
"0.48720413",
"0.48708662",
"0.48708618",
"0.48704964",
"0.48689482",
"0.48650673",
"0.48645762",
"0.48641694",
"0.4861967",
"0.48604453",
"0.48590216",
"0.48570803",
"0.48464578"
] | 0.7456548 | 0 |
add a subdirectory to this content tree Without this we won't be able to add a subdirectory (given as a path with possibly more than one element) into the content tree | def addDir(dirPath)
#N Without this, the directory path won't be broken up into its elements
pathElements = getPathElements(dirPath)
#N Without this check, it will fail in the case where dirPath has no elements in it
if pathElements.length > 0
#N Without this, we won't know the first element in the path (which is needed to construct the immediate sub-directory content-tree representing the first part of the path)
pathStart = pathElements[0]
#N Without this we won't know the rest of the elements so that we can add that part of the dir path into the content tree we've just created
restOfPath = pathElements[1..-1]
#N Without this the immedate sub-directory content tree and the chain of sub-directories within that won't be created
getContentTreeForSubDir(pathStart).addDir(restOfPath)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(path)\n chdir { super }\n end",
"def add(path); end",
"def add_folder name\n elem = ElemFolder.new(name)\n add_element(elem)\n end",
"def add_directory(directory)\n @directories[directory.name] = directory\n directory.parent = self\n end",
"def add_dir(path)\n Dir.foreach(@new_base + path) do |fname|\n path_fname = path + fname\n next if fname == '.' || fname == '..' || filter_fname(path_fname)\n type = File.ftype(@new_base + path_fname).to_sym\n @entries << [path_fname, type, :added]\n add_dir(path_fname + '/') if type == :directory\n end\n end",
"def add_path(path)\n @tree.add_path(path)\n self\n end",
"def add_directory(path, parent_baton,\n copyfrom_path, copyfrom_revision)\n # Output 'A' to indicate that the directory was added.\n # Also put a trailing slash since it's a directory.\n puts \"A #{path}/\"\n\n # The directory has been printed -- don't print it again.\n [false, path]\n end",
"def add_to_link_hierarchy( title, link, page=nil )\n\t\tnode = DocuBot::LinkTree::Node.new( title, link, page )\n\t\tparent_link = if node.anchor\n\t\t\tnode.file\n\t\telsif File.basename(link)=='index.html'\n\t\t\tFile.dirname(File.dirname(link))/'index.html'\n\t\telse\n\t\t\t(File.dirname(link) / 'index.html')\n\t\tend\n\t\t#puts \"Adding #{title.inspect} (#{link}) to hierarchy under #{parent_link}\"\n\t\tparent = descendants.find{ |n| n.link==parent_link } || self\n\t\tparent << node\n\tend",
"def addDir(basefile)\n\t\tdir = File.dirname(basefile)\n\n\t\t# recurse - add parent dirs also\n\t\tif (dir != \".\") then\n\t\t\t@dirList << dir\n\t\t\taddDir(dir)\n\t\tend\n\tend",
"def add_content_to_file(file_path, content)\n names = file_path.split('/')\n file_name = names.pop\n directory = self.mkdir(names.join('/'))\n directory.add_content_to_file(file_name, content)\n end",
"def append_node(node, parent = nil)\n # Add the node to the parents node list\n add_entry(node, parent)\n\n # Recursively get all filesystem entries contained in the current folder\n if node.is_a? FileSystem::Folder then\n pattern = '/*'\n entries = Dir.glob(node.path + pattern).sort_by { |a| a.downcase }\n files = []\n folders = []\n\n # Store files and folders in different collections\n # because files will be added before folders\n entries.each do |e|\n if File.directory? e\n folders << e\n else\n files << e\n end\n end\n\n # First add contained files\n files.each do |f|\n file = build_entry(:file, @index, f, @left_entry)\n append_node(file, node)\n end\n\n # After add contained folders and its entries\n folders.each do |f|\n folder = build_entry(:folder, @index, f, @left_entry)\n append_node(folder, node)\n end\n end\n end",
"def add_page_to_tree(page)\n if !page.root?\n #puts \"page: #{page}\"\n #puts \"page.fullpath: #{page.fullpath}\"\n #puts \"page.parent_id: #{page.parent_id}\"\n page.parent = @remote_pages_by_id[page.parent_id]\n #puts \"page.parent: #{page.parent}\"\n #puts \"page.parent.class: #{page.parent.class}\"\n #puts \"page.parent.children: #{page.parent.children}\"\n page.parent.children << page\n end\n end",
"def add(path)\n if File.directory?(path)\n add_directory(path)\n elsif File.file?(path)\n add_file(path)\n else\n fail \"#{path} doesn't exist\"\n end\n end",
"def add_child(folder, wawaccess)\n @children[folder] = wawaccess\n end",
"def add_subtree(tree, prefix)\n tree.all_data.each do |entry|\n located_entry = LocatedEntry.new(tree, entry, prefix)\n # universal path that handles also new elements for arrays\n path = \"#{prefix}/#{located_entry.key}[last()+1]\"\n set_new_value(path, located_entry)\n end\n end",
"def add(path)\n raise ComponentDirAlreadyAddedError, path if dirs.key?(path)\n\n dirs[path] = ComponentDir.new(path).tap do |dir|\n yield dir if block_given?\n apply_defaults_to_dir(dir)\n end\n end",
"def add_directory(path, *args)\n puts \"#{@indent}#{basename(path)}/#{id(path)}\"\n @indent << ' '\n end",
"def node_at(*path)\n return self if path.empty?\n\n # recursive loop ends when last path_node is shifted off the array\n attributes = {'fs_name' => path.shift}\n\n # create and add the child node if it's not found among the immediate\n # children of self\n child = children.find do |c|\n c.node_name == 'dir' && c.fs_name == attributes['fs_name']\n end\n unless child\n child = Node.new_node('dir', document, attributes)\n add_child(child)\n end\n\n child.node_at(*path)\n end",
"def add_directory(directories, path)\n target = Pathname(path).each_filename.to_a.first\n if directories.select{|s| Pathname(s).each_filename.to_a.first == target}.empty?\n directories << path\n end\n end",
"def add_directory(name)\n full_path = File.join(path, name)\n\n Dir.mkdir(full_path) unless File.directory?(full_path)\n\n self.class.new(full_path)\n end",
"def add_root(path)\n new_root = FileRoot.new(File, File.expand_path(path))\n\n @roots.unshift new_root\n @overlays.each { |o| o.roots = @roots }\n end",
"def add_dir (dir)\n @dirs[dir.path] = dir\n end",
"def add_child(root, child)\n raise NotImplementedError\n end",
"def addNameToPath(name)\n @root = name if @currentPath.empty?\n @currentPath.addName(name)\n end",
"def add_file entry, content = nil\n path = repo_path.join entry\n dir, filename = path.split unless entry.end_with? \"/\"\n\n FileUtils.mkdir_p dir.to_s == '.' ? repo_path : dir\n FileUtils.touch path if filename\n File.write path, content if filename && content\n end",
"def add(path, data, ctype=DEFAULT_CTYPE)\n # FIXME: determine if ADD or UPDATE EVENT\n # evt = File.exist? @content_tree.node_path(path)\n # FIXME: should this always be create-or-update? what about replace=false?\n n = @content_tree.add(path, data, ctype)\n notify(EVENT_ADD, path, ctype)\n n\n end",
"def add_child(node_or_tags); end",
"def add_child(node_or_tags); end",
"def []=(path, content=nil)\n segments = split(path)\n unless basename = segments.pop\n raise \"invalid path: #{path.inspect}\"\n end\n \n tree = @tree.subtree(segments, true)\n tree[basename] = convert_to_entry(content)\n end",
"def add_dir (dir)\n @dirs[dir.path] = dir\n end",
"def rewrite_path # :nodoc:\n if uri.path[0] != ?/\n prepend_path File.join('/', options[:dir].to_s)\n end\n end",
"def add_child(value)\n @children.unshift(Tree(value))\n end",
"def append_to_path(path)\n @path+= path\n end",
"def append_path(path)\n @paths.push(File.expand_path(path, root))\n end",
"def add_child(value)\n @children.unshift(Tree(value))\n end",
"def add_dir( zipfile, d )\n FileList.new(\"#{d}/**/*\").each { |f| add_file(zipfile, f) if File.file?(f) }\n end",
"def subdir=(d)\n @subdir = d\n end",
"def addDirectory(dir, expression=\".*\")\r\n @directories << URLWatcher::Directory.new(dir, expression)\r\n end",
"def _store_path(root, path, value = nil)\n return if path.nil? || target?(path, root)\n\n value ||= prepare(root, path)\n\n if path.directory?\n _store(Path.rpartition(path, target)[-1], value)\n else\n _store(path, value)\n end\n end",
"def add_path_part(name, rel_path=nil, expected_type=nil)\n if not name.kind_of? String\n raise ArgumentInvalidTypeError.new 'name', name, String\n end\n \n if has_path_part? name\n raise ArgumentError \"path part #{name} has already been added\"\n end\n \n rel_path_parts = (not rel_path.kind_of? String) ? [] : rel_path.split('.')\n \n if (not rel_path_parts.empty?) and has_path_part?(rel_path_parts[0])\n rel_path = \"\"\n rel_path << self[rel_path_parts[0]].full_rel_path\n if (rel_path_parts.length > 1)\n rel_path << \".\" << rel_path_parts.last(rel_path_parts.length - 1).join('.')\n end\n end\n \n path_part = create_path_part(name, self, rel_path, expected_type)\n \n @child_path_parts[path_part.name] = path_part\n return path_part\n end",
"def add_child(node)\n node.build\n nodes << node\n end",
"def path_write path, content = \"\", mode = \"a+\"\n\t\t\tif File.exist?(path)\n\t\t\t\tFile.open(path, mode){|f| f.write content} unless path[-1] == '/'\n\t\t\telse\n\t\t\t\tarrs\t= path.split('/')\n\t\t\t\tcount\t= arrs.count - 1\n\t\t\t\tprve\t= \"\"\n\n \t\t\t\tif arrs[0] == \"\"\n \t\t\t\t\tarrs.delete(\"\")\n\t\t\t\t\tprve = \"/\"\n \t\t\t\tend\n\n\t\t\t\t(0..count).each do | i |\n\t\t\t\t\tsub_path = prve + arrs[0..i].join(\"/\")\n\t\t\t\t\tunless File.exist? sub_path\n\t\t\t\t\t\tsub_path == path ? File.open(path, mode){|f| f.write content} : Dir.mkdir(sub_path)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def add( page )\n ary = @db[page.directory]\n\n # make sure we don't duplicate pages\n ary.delete page if ary.include? page\n ary << page\n\n page\n end",
"def add_child(b)\r\n return unless b\r\n a = @nodes[b.name]\r\n if !a\r\n @nodes[b.name] = b\r\n elsif a.kind_of?(VFSGroup)\r\n # Node is already present, merge children\r\n b.nodes.each_value do |n|\r\n a.add_child(n)\r\n end\r\n end\r\n end",
"def add_directory(dir)\n fail \"#{dir} isn't a directory\" unless File.directory?(dir)\n glob = File.join(dir, '**/*')\n Dir.glob(glob).each do |file|\n add_file_entry(file, dir)\n end\n end",
"def add(path, value)\n\n # Verify.\n path = Path.new(path) unless path.kind_of?(Path)\n meta = meta_walk(path)\n adding_dir = false\n if meta and meta.kind_of?(Hash)\n if meta[:dir]\n value = value.to_s\n raise Error.new(Error::IllegalName, value) if value.include?(?/)\n unless (meta = meta[value]) and meta.kind_of?(Hash) and meta[:dir]\n raise Error.new(Error::WrongType, path)\n end\n adding_dir = true\n else\n raise Error.new(Error::WrongType, path) unless meta[:type] == Array\n if (t = meta[:arraytype])\n value = convert_to(value, t, path) unless value.kind_of?(t)\n else\n value = value.to_s\n end\n end\n else\n raise Error.new(Error::WrongType, path)\n end\n\n # Creating a directory.\n if adding_dir\n mmap, cmap = dir_walk(path, DW_Create)\n return [TypeDirExists, path, value] if cmap.has_key?(value)\n dir = {}\n if (hook = mmap[:on_change])\n dir = d if (d = hook.call(HookSet, cmap, value, nil, dir))\n end\n cmap[value] = dir\n [TypeDirectory, path, value]\n\n # Adding an array item.\n else\n key = path.pop\n mmap, cmap = dir_walk(path, DW_Create)\n ihook = meta[:on_change]\n if (a = cmap[key])\n value = ihook.call(HookArrayAdd, a, value) || value if ihook\n a << value\n else\n a = [value]\n a = ihook.call(HookCreate, a) || a if ihook\n dhook = mmap[:on_change]\n a = dhook.call(HookSet, cmap, key, nil, a) || a if dhook\n cmap[key] = a\n end\n [TypeArray, path + key, value, a]\n\n end\n end",
"def subdirs_to_create(dir, user)\n Chef::Log.info(\"Dir to create: #{dir}, user: #{user}\")\n existing_subdirs = []\n remaining_subdirs = dir.split('/')\n remaining_subdirs.shift # get rid of '/'\n\n until remaining_subdirs.empty?\n Chef::Log.debug(\"remaining_subdirs: #{remaining_subdirs.inspect}, existing_subdirs: #{existing_subdirs.inspect}\")\n path = existing_subdirs.push('/' + remaining_subdirs.shift).join\n break unless File.exist?(path)\n raise \"Path #{path} exists and is a file, expecting directory.\" unless File.directory?(path)\n raise \"Directory #{path} exists but is not traversable by #{user}.\" unless can_traverse?(user, path)\n end\n\n new_dirs = [existing_subdirs.join]\n new_dirs.push(new_dirs.last + '/' + remaining_subdirs.shift) until remaining_subdirs.empty?\n new_dirs\n end",
"def add(child); end",
"def hook_add_directories\n @flavor.class.after_add_directories do |directories|\n directories.each do |dir|\n actions_taken << \"create directory #{dir}\"\n end\n end\n end",
"def append_path(path)\n mutate_config(:paths) do |paths|\n path = File.expand_path(path, root).dup.freeze\n paths.push(path)\n end\n end",
"def just_add_child(node)\n return if @children.member?(node)\n @children << node\n node.parent = self\n update_boxes \n end",
"def path_append(path)\n path_set(path_components + [File.expand_path(path)])\n end",
"def add(key, value)\n #recursive\n @root = add_helper(@root, key, value)\n end",
"def add_category(path, name)\n @list[path] ||= []\n if @list[path].include?(name + \"/\")\n @count[path + name + \"/\"] ||= 1\n @count[path + name + \"/\"] += 1\n name = name + \" (#{@count[path + name + \"/\"]})\"\n end\n @list[path] << name + \"/\"\n @dir << name\n end",
"def add(path, path_from_document_root=nil)\n full_path = Pathname.new(path).expand_path(root)\n path_from_document_root = Pathname.new(path_from_document_root || full_path.relative_path_from(document_root))\n relative_dir = path_from_document_root.dirname\n\n md5 = Digest::MD5.file(full_path).hexdigest\n ext = full_path.extname\n name_without_ext = full_path.basename.to_s.chomp(ext)\n suffix = \"-#{md5}\"\n suffix = \"-#{version}#{suffix}\" if version\n versioned_file = \"#{name_without_ext}#{suffix}#{ext}\"\n\n versioned_path_from_document_root = relative_dir + versioned_file\n versioned_full_path = tmp_document_root + versioned_path_from_document_root\n\n mkdir_p versioned_full_path.dirname\n cp full_path, versioned_full_path\n\n http_path = '/' + path_from_document_root.to_s\n versioned_http_path = '/' + versioned_path_from_document_root.to_s\n\n manifest[http_path] = versioned_http_path\n end",
"def update_path(path)\n return path_nodes(path).insert(1, \"data\").join(\"/\") if path_nodes(path)[1] != \"data\"\n\n path\n end",
"def tree_insert(tree, page)\n node_list = page.path.split(\"/\")\n _tree_insert(tree, page, node_list)\n end",
"def add(word)\n @root.create_final_path(word.chars.reverse + [Path::DELIMITER])\n\n Word.new(word.chars).to_delimited_paths.each do |path|\n @root.create_final_path(path.letters)\n end\n\n self\n end",
"def add_child_path( names )\n components = names.dup\n parent = self\n\n loop do\n break if components.empty?\n child = components.shift\n parent = parent.add_child( child )\n end\n return parent\n end",
"def add(value)\n @root = add_at_node(@root, value)\n end",
"def add(*args)\n helper.glob_to_index(args) do |index, relative_path|\n index.add(relative_path.to_s)\n end\n\n self\n end",
"def add_dir(dir)\n # we chdir into the directory so that file paths will be relative\n pwd = Dir.pwd\n Dir.chdir(dir)\n Find.find('.') do |f|\n if (f =~ /\\.mp3$/ && File.size?(f))\n f.sub!(%r{^./}, '') # remove leading './'\n add_mp3(f)\n end\n end\n # go back to original directory\n Dir.chdir(pwd)\n end",
"def add(directory, path=nil)\n raise \"immutable once used\" if @last_been_run\n if path\n raise \"path must start with /\" unless path =~ %r{^/}\n path = '' if path == '/'\n raise \"path must not end with /\" if path =~ %r{/$}\n raise \"path already exists\" if @sources.find{|s|s[0]==path}\n end\n raise \"directory already exists\" if @sources.find{|s|s[1]==directory}\n @sources << [File.expand_path(directory), path]\n @sources.sort! {|a,b| (b[1]||'') <=> (a[1]||'')}\n self\n end",
"def expand_tree(path)\n names = path.split('/')\n names.pop\n parent = work_tree\n names.each do |name|\n object = parent[name]\n break if !object\n if object.type == :blob\n parent.move(name, name + CONTENT_EXT)\n break\n end\n parent = object\n end\n end",
"def subdir(dir)\n dir = Pathname.new(dir) if dir.instance_of? String\n dir = Pathname.new('.') if dir.to_s =~ /\\.\\./ or dir.to_s =~ /^\\//\n dir = Pathname.new('.') if any_symlinks_in dir\n newdir = @path + dir\n Filesystem.new newdir\n end",
"def add_folder(title)\n perform_post_with_object('/api/1.1/folders/add', {title: title}, Instapaper::Folder)\n end",
"def subdir\n (@subdir) ? Pathname.new(@subdir) : Pathname.new('.')\n end",
"def add(path)\n blob = GitRb::Blob.new(path)\n FileUtils.mkdir_p(blob.directory)\n File.open(blob.object_path, 'w') { |f| f.write(blob.deflated_content) }\n GitRb::Index.new.add(blob)\n end",
"def load_directory(path)\n path.each_child do |child|\n load_one(child)\n end\n end",
"def add_directory(dir)\n unless File.exists?(dir) && File.directory?(dir)\n raise ArgumentError, \"Source directory #{dir} is not valid\"\n end\n timed_section(logger, 'add_directory') do\n pattern = File.join(dir, '**', '*')\n Dir.glob(pattern, File::FNM_DOTMATCH).each do |path|\n add_path(path)\n end\n end\n end",
"def <<(path) = add(path, position: :last)",
"def subdirs_to_create(dir, user)\n Chef::Log.debug(\"Dir to create: #{dir}, user: #{user}\")\n existing_subdirs = []\n remaining_subdirs = dir.split('/')\n remaining_subdirs.shift # get rid of '/'\n reason = ''\n \n until remaining_subdirs.empty?\n Chef::Log.debug(\"remaining_subdirs: #{remaining_subdirs.inspect}, existing_subdirs: #{existing_subdirs.inspect}\")\n path = existing_subdirs.push('/' + remaining_subdirs.shift).join\n break unless File.exist?(path)\n reason = \"Path \\'#{path}\\' exists and is a file, expecting directory.\" unless File.directory?(path)\n reason = \"Directory \\'#{path}\\' exists but is not traversable by user \\'#{user}\\'.\" unless can_traverse?(user, path)\n end\n\n new_dirs = [existing_subdirs.join]\n new_dirs.push(new_dirs.last + '/' + remaining_subdirs.shift) until remaining_subdirs.empty?\n [new_dirs, reason]\n end",
"def add_closesubpath()\n @pathArray.push({ :elementtype => \"pathclosesubpath\" })\n @pathArray\n end",
"def __create_directories(key, value)\n return if value['documentation']\n\n empty_directory @output.join(key)\n create_directory_hierarchy * value.to_a.first\n end",
"def build_folder(attributes = {}, &block)\n node = Nokogiri::XML::Node.new('folder', document)\n assign_to node, attributes\n\n add_child node\n end",
"def ensure_nesting_folder\n if @file_node.is_file?\n redirect_to nodes_path\n end\n end",
"def add_exhibit_root\n sitemap.add sitemap.exhibit_root_path(exhibit)\n end",
"def set_path\n # Ouch\n _ancestors = ancestors.reverse\n _ancestors.delete(parent)\n _ancestors << ::Page.find(parent_id) if parent_id\n\n self.path = (_ancestors << self).map(&:slug).join(\"/\").gsub(%r{^/}, \"\")\n end",
"def add(key, value)\n @root = add_helper(@root, key, value)\n end",
"def add_folder(folder)\n # Remove any copy if we already have it\n @folders.delete_if {|old_folder| old_folder.primary_key == folder.primary_key}\n @folders.push(folder)\n end",
"def addPath(path)\r\n\t\tif @paths.nil?\r\n\t\t\t@paths = [path]\r\n\t\telse\r\n\t\t\t@paths << path\r\n\t\tend\r\n\tend",
"def append_path(path)\n @app.sitemap.rebuild_resource_list!(:sprockets_paths)\n\n super\n end",
"def add(key, value)\n @root = add_helper(@root, key, value)\n end",
"def add(key, value)\n @root = add_helper(@root, key, value)\n end",
"def add(key, value)\n @root = add_helper(@root, key, value)\n end",
"def add(key, value)\n @root = add_helper(@root, key, value)\n end",
"def / aRelativePath\n access_child(aRelativePath)\n end",
"def add_child(child_node) \n child_node.parent = self \n end",
"def in_dirs(dirs_a)\n @dirs += dirs_a\n self\n end",
"def add\n working_repo.add tree\n end",
"def << folder\n @folders << folder && self\n end",
"def add_path(path)\n raise NotImplementedError, \"Implement in each subclass\"\n end",
"def add_directory(directory)\n @zip.put_next_entry(::File.join(directory.path, ''))\n end",
"def add_child(key, child) \n raise \"Leaf nodes don't accept children (request was: #{key.inspect} => #{child.inspect})\"\n end",
"def set_path\n # Ouch\n _ancestors = ancestors.reverse\n _ancestors.delete(self.parent)\n _ancestors << Page.find(self.parent_id) if self.parent_id\n \n self.path = (_ancestors << self).map(&:slug).join(\"/\").gsub(/^\\//, \"\")\n end",
"def will_expand_action node\n path = File.join(*node.user_object_path)\n dirs = _directories path\n ch = node.children\n # add only children that may not be there\n ch.each do |e| \n o = e.user_object\n if dirs.include? o\n dirs.delete o\n else\n # delete this child since its no longer present TODO\n end\n end\n node.add dirs\n path_expanded path\n end",
"def add_child\n category_id = params[:id].gsub('category_', '')\n @category = Category.find(category_id)\n parent_id = params[:parent_id]\n if parent_id\n @parent = Category.find(parent_id)\n @category.parent = @parent \n else\n @category.parent = nil\n end\n @category.save!\n render :update do |page|\n page.remove(\"category_#{@category.id}_row\")\n if @parent\n if @parent.name == ASSOCIATION.short_name\n page.replace_html(\"category_root\", :partial => \"category\", :collection => @parent.children.sort)\n else\n page.call(:expandDisclosure, parent_id)\n end\n end\n if @parent.nil?\n page.replace_html(\"unknown_category_root\", :partial => \"category\", :collection => Category.find_all_unknowns.sort)\n end\n end\n end",
"def mkdir(name)\n return self if name == '.'\n name = name[1..-1] if name[0] == '/'\n newdir, *remainder = name.split('/')\n subdir = get(newdir)\n unless subdir.dir?\n result = @od.request(\"#{api_path}/children\",\n name: newdir,\n folder: {},\n '@microsoft.graph.conflictBehavior': 'rename'\n )\n subdir = OneDriveDir.new(@od, result)\n end\n remainder.any? ? subdir.mkdir(remainder.join('/')) : subdir\n end",
"def add_child(child)\n n = root? ? @nodes : @root.nodes\n n << child\n @children << child\n child\n end",
"def add_directories(listing)\n listing.common_prefixes.each do |prefix|\n new_entry = entry_for(from_base(prefix.prefix), 0, Time.current, true)\n @entries << new_entry unless new_entry.nil?\n end\n end"
] | [
"0.63590306",
"0.62446785",
"0.62136775",
"0.62088394",
"0.61840373",
"0.6160388",
"0.6123743",
"0.61169434",
"0.60914564",
"0.60903114",
"0.6052374",
"0.60452986",
"0.6027106",
"0.60125977",
"0.594964",
"0.5932872",
"0.5915284",
"0.5890606",
"0.5866839",
"0.58628446",
"0.581212",
"0.57071155",
"0.5687458",
"0.56771",
"0.5656714",
"0.56490934",
"0.5648909",
"0.5648909",
"0.5645172",
"0.5639302",
"0.56319773",
"0.55943733",
"0.55931973",
"0.5592868",
"0.55850565",
"0.5560383",
"0.5559404",
"0.5548819",
"0.55148494",
"0.548615",
"0.54795533",
"0.54774594",
"0.54510564",
"0.5432701",
"0.5422549",
"0.54205334",
"0.5408028",
"0.5407319",
"0.54000884",
"0.53938067",
"0.53876716",
"0.538564",
"0.5351324",
"0.53395975",
"0.5338419",
"0.5337201",
"0.5328814",
"0.53258234",
"0.53252226",
"0.5309252",
"0.5308993",
"0.5300504",
"0.52988017",
"0.52970994",
"0.52882904",
"0.52639943",
"0.5245033",
"0.52389395",
"0.52381355",
"0.5237172",
"0.52357125",
"0.52276385",
"0.5227559",
"0.5209266",
"0.5202649",
"0.52009124",
"0.51988095",
"0.5196543",
"0.5194498",
"0.5187092",
"0.51858735",
"0.5180618",
"0.5172818",
"0.5172818",
"0.5172818",
"0.5172818",
"0.5172736",
"0.51687956",
"0.5159686",
"0.5159604",
"0.51563436",
"0.5152125",
"0.5149906",
"0.5141606",
"0.5137477",
"0.5127132",
"0.5126259",
"0.51227355",
"0.5115902",
"0.5115158"
] | 0.6739095 | 0 |
recursively sort the files and subdirectories of this content tree alphabetically N Without this, we will have to put up with subdirectories and filedirectories being listed in whatever order the listing commands happen to list them in, which may not be consisted across different copies of effectively the same content tree on different systems. | def sort!
#N Without this, the immediate sub-directories won't get sorted
dirs.sort_by! {|dir| dir.name}
#N Without this, files contained immediately in this directory won't get sorted
files.sort_by! {|file| file.name}
#N Without this, files and directories contained within sub-directories of this directory won't get sorted
for dir in dirs
#N Without this, this sub-directory won't have its contents sorted
dir.sort!
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_files!\n site.collections.each_value { |c| c.docs.sort! }\n site.pages.sort_by!(&:name)\n site.static_files.sort_by!(&:relative_path)\n end",
"def sort_children\n @children.sort! do |a, b|\n if (a.leaf? && b.leaf?) || (!a.leaf? && !b.leaf?)\n a.name <=> b.name\n elsif a.leaf? && !b.leaf?\n -1\n else\n 1\n end\n end\n @children.each(&:sort_children)\n end",
"def sort_files!\n site.generated_pages.sort_by!(&:name)\n site.static_files.sort_by!(&:relative_path)\n end",
"def sort_children\n @children.sort_by!(&:name)\n @children.map(&:sort_children)\n end",
"def sort_files!; end",
"def sub_tree\n files = ProjectFile.where(directory_id: id)\n files = files.nil? ? [] : files \n\n files.sort{|x,y| \n if x.is_directory and not y.is_directory\n -1\n elsif not x.is_directory and y.is_directory\n 1\n else\n x.name <=> y.name\n end\n }\n end",
"def file_sort_hierarchy(path)\n Dir.glob(path).sort_by { |f| f.split('/').size }\n end",
"def sort\n if children.present?\n node(type, *children.map(&:sort).sort)\n else\n self\n end\n end",
"def traverse_sort_and_add_nav_order_to_nodes(node)\n\t\n\t\t# traverse subfolders, go deep\n\t\tif node_has_children(node)\n\t\t\n\t\t\t node.children.items.each_with_index do |child|\n\t\t\t\t if child.nav_type == \"folder\" || child.nav_type == \"folder+markdown\"\n\t\t\t\t\t items = traverse_sort_and_add_nav_order_to_nodes(child)\n\t\t\t\t\t child.children.items = items if items and items.size > 0\n\t\t\t\t end\n\t\t\t end\n\t\t \n\t\tend\t \n\t\n\t\thas_navig_yml = File.exist?(\"#{node.source_path}/aaaa-navigation.yml\")\n\t\n\t\tif has_navig_yml and node.children and node.children.items?\n\t\n\t\telse\n\t\t\treturn nil\t\t\n\t\tend \n\t\n\t\tsorted_nav_items = nil\n\t\n\t\tif node.children? and node.children.items?\n\t\t\tsorted_nav_items = node.children.items\n\t\tend\n\t\n\t\tif File.exists?(\"#{node.source_path}/aaaa-navigation.yml\")\n\t\t\t# load aaaa-navigation.yml\n\t\t\tnaml = Map.new(YAML.load_file(\"#{node.source_path}/aaaa-navigation.yml\"))\t\t\n\t\n\t\t\t# iterate and re-order navigation.yml\n\t\t\tsorted_nav_items = node.children.items\n\n\t\t\tsorted_nav_items.each_with_index do |sni, i| \n\t\t\t\tsni.nav_order = i + 1000\n\t\t\tend\n\n\t\t\tnaml.nav_items.each_with_index do |naml_item, i|\n\t\t\t\tsorted_nav_items.each do |sni| \n\t\t\t\t\tsni.nav_order = i if sni.source == naml_item.source\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tsorted_nav_items.sort! { |x, y| x.nav_order <=> y.nav_order }\n\n\t\t\tsorted_nav_items.each_with_index do |sni, i| \n\t\t\t\tsni.nav_order = i + 1\n\t\t\tend\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \n\t\tend\n\t\n\t\tsorted_nav_items\n\tend",
"def sorted_files\n sort_file_name_by_semver(all_files.select { |f| semver_file?(f) })\n end",
"def sort!\n return unless has_children?\n sorted_children = children.sort\n self.children = sorted_children\n end",
"def pages_to_list\n # sort by fullpath first\n list = self.pages.values.sort { |a, b| a.fullpath <=> b.fullpath }\n # sort finally by depth\n list.sort { |a, b| a.depth <=> b.depth }\n end",
"def pages_to_list\n # sort by fullpath first\n list = self.pages.values.sort { |a, b| a.fullpath <=> b.fullpath }\n # sort finally by depth\n list.sort { |a, b| a.depth <=> b.depth }\n end",
"def sort_dir_list(dir_list, path)\n order_by ||= session[:order_by]\n order_by ||= 'filename'\n order_desc = session[:order_desc]\n \n if dir_list.first[order_by.to_sym].class == Fixnum\n dir_list.sort! { |a,b| a[order_by.to_sym] <=> b[order_by.to_sym] }\n else\n dir_list.sort! { |a,b| a[order_by.to_sym].to_s.downcase <=> b[order_by.to_sym].to_s.downcase }\n end\n\n dir_list.reverse! if order_desc\n \n # move folders to top\n new_list = []\n new_dir_list = []\n dir_list.each do |element|\n new_list << element if File.directory?(path + '/' + element[:original_name])\n new_dir_list << element if File.file?(path + '/' + element[:original_name])\n end\n new_list.sort! { |a,b| a[:filename].to_s.downcase <=> b[:filename].to_s.downcase }\n new_list.concat new_dir_list\n end",
"def children_sort_by(*args, &blk)\n self.dup{ @contents = @contents.sort_by(*args, &blk) }\n end",
"def tree_sort_order\n if !tree_use_rational_numbers\n \"#{tree_order} #{tree_depth_field}\"\n else\n tree_nv_div_dv_field.asc\n end\n end",
"def sort_by_type!\n children.sort! do |x, y|\n if x.is_a?(PBXGroup) && y.is_a?(PBXFileReference)\n -1\n elsif x.is_a?(PBXFileReference) && y.is_a?(PBXGroup)\n 1\n else\n x.display_name <=> y.display_name\n end\n end\n end",
"def sort_by_type!\n children.sort! do |x, y|\n if x.is_a?(PBXGroup) && y.is_a?(PBXFileReference)\n -1\n elsif x.is_a?(PBXFileReference) && y.is_a?(PBXGroup)\n 1\n else\n x.display_name <=> y.display_name\n end\n end\n end",
"def sort_entries(file_data)\n submodules = []\n file_data.scan(/(^\\[submodule[^\\n]+\\n)((?:\\t[^\\n]+\\n)+)/).each do |head, body|\n path = body.match(/^\\tpath\\s*=\\s*\\K(.+)$/)[0]\n submodules << [path, head + body]\n end\n submodules.sort! { |a,b| a[0] <=> b[0] }\n submodules.collect { |i| i[1] }\nend",
"def sorted_folders\n return @folders if !@retain_order\n @folders.sort_by{|folder| [folder.sort_order]}\n end",
"def TreeView_SortChildren(hwnd, hitem, recurse)\r\n send_treeview_message(hwnd, :SORTCHILDREN, wparam: recurse, lparam: hitem)\r\n end",
"def sort_items_according_to_current_direction\n case @direction\n when nil\n @items = items.shift(2) + items.partition(&:directory?).flat_map(&:sort)\n when 'r'\n @items = items.shift(2) + items.partition(&:directory?).flat_map {|arr| arr.sort.reverse}\n when 'S', 's'\n @items = items.shift(2) + items.partition(&:directory?).flat_map {|arr| arr.sort_by {|i| -i.size}}\n when 'Sr', 'sr'\n @items = items.shift(2) + items.partition(&:directory?).flat_map {|arr| arr.sort_by(&:size)}\n when 't'\n @items = items.shift(2) + items.partition(&:directory?).flat_map {|arr| arr.sort {|x, y| y.mtime <=> x.mtime}}\n when 'tr'\n @items = items.shift(2) + items.partition(&:directory?).flat_map {|arr| arr.sort_by(&:mtime)}\n when 'c'\n @items = items.shift(2) + items.partition(&:directory?).flat_map {|arr| arr.sort {|x, y| y.ctime <=> x.ctime}}\n when 'cr'\n @items = items.shift(2) + items.partition(&:directory?).flat_map {|arr| arr.sort_by(&:ctime)}\n when 'u'\n @items = items.shift(2) + items.partition(&:directory?).flat_map {|arr| arr.sort {|x, y| y.atime <=> x.atime}}\n when 'ur'\n @items = items.shift(2) + items.partition(&:directory?).flat_map {|arr| arr.sort_by(&:atime)}\n when 'e'\n @items = items.shift(2) + items.partition(&:directory?).flat_map {|arr| arr.sort {|x, y| y.extname <=> x.extname}}\n when 'er'\n @items = items.shift(2) + items.partition(&:directory?).flat_map {|arr| arr.sort_by(&:extname)}\n end\n items.each.with_index {|item, index| item.index = index}\n end",
"def list_all_in_current_directory\n Dir.glob('**/*').sort\nend",
"def ordered_topologically\n FolderSort.new(self)\n end",
"def children(options = {})\n children = get_children(\"directory\").collect { |child| Dirk.new(child) }\n children.reject! { |child| child.published == false || child.draft == true }\n children.sort! { |a, b| a.send(options[:sort]).to_s <=> b.send(options[:sort]).to_s } if options[:sort]\n children.reverse if options[:order].to_s.upcase == \"DESC\"\n children\n end",
"def list_files dir='*', sorto=@sorto, hidden=@hidden, _filter=@filterstr\n dir += '/*' if File.directory?(dir)\n dir = dir.gsub('//', '/')\n\n # decide sort method based on second character\n # first char is o or O (reverse)\n # second char is macLn etc (as in zsh glob)\n so = sorto ? sorto[1] : nil\n func = case so\n when 'm'\n :mtime\n when 'a'\n :atime\n when 'c'\n :ctime\n when 'L'\n :size\n when 'n'\n :path\n when 'x'\n :extname\n end\n\n # sort by time and then reverse so latest first.\n sorted_files = if hidden == 'D'\n Dir.glob(dir, File::FNM_DOTMATCH) - %w[. ..]\n else\n Dir.glob(dir)\n end\n\n # WARN: crashes on a deadlink since no mtime\n if func\n sorted_files = sorted_files.sort_by do |f|\n if File.exist? f\n File.send(func, f)\n else\n sys_stat(func, f)\n end\n end\n end\n\n sorted_files.sort! { |w1, w2| w1.casecmp(w2) } if func == :path && @ignore_case\n\n # zsh gives mtime sort with latest first, ruby gives latest last\n sorted_files.reverse! if sorto && sorto[0] == 'O'\n\n # add slash to directories\n sorted_files = add_slash sorted_files\n # return sorted_files\n @files = sorted_files\n calculate_bookmarks_for_dir # we don't want to override those set by others\nend",
"def tree\n # Caution: use only for small projects, don't use in root.\n $title = \"Full Tree\"\n $files = `zsh -c 'print -rl -- **/*(#{$sorto}#{$hidden}M)'`.split(\"\\n\")\nend",
"def order\n \"#{sort} #{dir}\"\n end",
"def directory_sort_order( f1, f2 )\n n1 = File.extname( f1 ).gsub( '.', '' ).to_i\n n2 = File.extname( f2 ).gsub( '.', '' ).to_i\n return -1 if n1 < n2\n return 1 if n1 > n2\n return 0\n end",
"def sort\n @nodes.each { |n| n.sort }\n\n # sort_by lets us build an array of numbers that Ruby then uses\n # to sort the list. Our method here is to simply specify the\n # depth a given class is in a heirarchy, as bigger numbers end\n # up sorted farther down the list\n @nodes =\n @nodes.sort_by do |a|\n if a.is_a?(ClassNode)\n superclass_count(a.code)\n elsif a.is_a?(ImplicitCasterNode) # Hmm, hack\n 1_000_000\n else\n 0\n end\n end\n end",
"def sort\n super { |x, y| x.file_name <=> y.file_name }\n end",
"def sort\n _in_order(@root, @@id_fun) # use Id function\n end",
"def ordered(resource)\n\n children = resource.children\n dir = resource.url\n\n ordered_simple(children, dir)\n end",
"def TreeView_SortChildrenCB(hwnd, psort, recurse)\r\n send_treeview_message(hwnd, :SORTCHILDRENCB, wparam: recurse, lparam: psort)\r\n end",
"def tree\n # Caution: use only for small projects, don't use in root.\n @title = 'Full Tree'\n # @files = `zsh -c 'print -rl -- **/*(#{@sorto}#{@hidden}M)'`.split(\"\\n\")\n @files = Dir['**/*']\n message \"#{@files.size} files.\"\nend",
"def files(options = {})\n resize_images_if_needed \n files = get_children(\"file\").collect do |file| \n Dirk.new(file, { :attr_file => file.basename.to_s.gsub(file.extname, '.txt') })\n end\n \n files.sort! { |a, b| a.send(options[:sort]).to_s <=> b.send(options[:sort]).to_s } if options[:sort]\n files\n end",
"def enhance_file_list\n return unless $enhanced_mode\n # if only one entry and its a dir\n # get its children and maybe the recent mod files a few\n \n # zsh gives errors which stick on stdscr and don't get off!\n # Rather than using N I'll try to convert to ruby, but then we lose\n # similarity to cetus and its tough to redo all the sorting stuff.\n if $files.size == 1\n # its a dir, let give the next level at least\n if $files.first[-1] == \"/\"\n d = $files.first\n #f = `zsh -c 'print -rl -- #{d}*(omM)'`.split(\"\\n\")\n f = get_file_list d\n if f && f.size > 0\n $files.concat f\n $files.concat get_important_files(d)\n return\n end\n else\n # just a file, not dirs here\n return\n end\n end\n # \n # check if a ruby project dir, although it could be a backup file too,\n # if so , expand lib and maby bin, put a couple recent files\n #\n if $files.index(\"Gemfile\") || $files.grep(/\\.gemspec/).size > 0\n # usually the lib dir has only one file and one dir\n flg = false\n $files.concat get_important_files(Dir.pwd)\n if $files.index(\"lib/\")\n f = `zsh -c 'print -rl -- lib/*(om[1,5]MN)'`.split(\"\\n\")\n if f && f.size() > 0\n insert_into_list(\"lib/\", f)\n flg = true\n end\n dd = File.basename(Dir.pwd)\n if f.index(\"lib/#{dd}/\")\n f = `zsh -c 'print -rl -- lib/#{dd}/*(om[1,5]MN)'`.split(\"\\n\")\n if f && f.size() > 0\n insert_into_list(\"lib/#{dd}/\", f)\n flg = true\n end\n end\n end\n if $files.index(\"bin/\")\n f = `zsh -c 'print -rl -- bin/*(om[1,5]MN)'`.split(\"\\n\")\n insert_into_list(\"bin/\", f) if f && f.size() > 0\n flg = true\n end\n return if flg\n\n # lib has a dir in it with the gem name\n\n end\n return if $files.size > 15\n\n ## first check accessed else modified will change accessed\n moda = `zsh -c 'print -rn -- *(/oa[1]MN)'`\n if moda && moda != \"\"\n modf = `zsh -c 'print -rn -- #{moda}*(oa[1]MN)'`\n if modf && modf != \"\"\n insert_into_list moda, modf\n end\n modm = `zsh -c 'print -rn -- #{moda}*(om[1]MN)'`\n if modm && modm != \"\" && modm != modf\n insert_into_list moda, modm\n end\n end\n ## get last modified dir\n modm = `zsh -c 'print -rn -- *(/om[1]MN)'`\n if modm != moda\n modmf = `zsh -c 'print -rn -- #{modm}*(oa[1]MN)'`\n insert_into_list modm, modmf\n modmf1 = `zsh -c 'print -rn -- #{modm}*(om[1]MN)'`\n insert_into_list(modm, modmf1) if modmf1 != modmf\n else\n # if both are same then our options get reduced so we need to get something more\n # If you access the latest mod dir, then come back you get only one, since mod and accessed\n # are the same dir, so we need to find the second modified dir\n end\nend",
"def sort_tree(node)\n if node.left\n @sorted_tree = sort_tree(node.left)\n end\n @sorted_tree << node.data\n if node.right\n @sorted_tree = sort_tree(node.right)\n end\n return @sorted_tree\n end",
"def sort_by_path\n by_path = Hash[@routes[:paths].sort]\n place_readme_first(by_path)\n end",
"def nested_pages(resource)\n children = resource.children.find_all { |r| nav_title(r) }\n Naturally.sort_by(children) do |r|\n [r.data['nav-weight'] || 100, nav_title(r).downcase]\n end\n end",
"def sort_by_ancestry(nodes, &block)\n arranged = nodes if nodes.is_a?(Hash)\n\n unless arranged\n presorted_nodes = nodes.sort do |a, b|\n rank = (a.public_send(ancestry_column) || ' ') <=> (b.public_send(ancestry_column) || ' ')\n rank = yield(a, b) if rank == 0 && block_given?\n rank\n end\n\n arranged = arrange_nodes(presorted_nodes)\n end\n\n flatten_arranged_nodes(arranged)\n end",
"def sort\n @sorted_tree = []\n if @head.nil?\n return nil\n else\n sort_tree(head)\n end\n return @sorted_tree\n end",
"def sort(node = @root)\n if @sorted.count < 2\n if node.left.left \n sort(node.left)\n elsif node.left.left == nil \n @sorted << node.left.value\n if node.left.right == nil\n else @sorted << node.left.right.value\n @sorted << node.value\n sort()\n end\n end\n elsif node.right\n @sorted << node.right.value\n end\n end",
"def sort_entries; end",
"def sort_leafs!\n leafs.sort! { |a, b| a.position.to_i <=> b.position.to_i }\n end",
"def sort(pages, order)\n pages.sort! { |a,b|\n as = order.index(a.basename)\n bs = order.index(b.basename)\n if as.nil?\n bs.nil? ? (a.basename <=> b.basename) : 1\n elsif bs.nil?\n as.nil? ? (a.basename <=> b.basename) : -1\n else\n as <=> bs\n end\n }\n end",
"def sort_files(files)\n files.sort! { |x,y| x[1] <=> y[1] }\n end",
"def order_menu\n # zsh o = order, O = reverse order\n # ruby mtime/atime/ctime come reversed so we have to change o to O\n lo = nil\n h = { m: :modified, a: :accessed, M: :oldest,\n s: :largest, S: :smallest, n: :name, N: :rev_name,\n # d: :dirs,\n c: :inode,\n x: :extension,\n z: :clear }\n _, menu_text = menu 'Sort Menu', h\n case menu_text\n when :modified\n lo = 'Om'\n when :accessed\n lo = 'Oa'\n when :inode\n lo = 'Oc'\n when :oldest\n lo = 'om'\n when :largest\n lo = 'OL'\n when :smallest\n lo = 'oL'\n when :name\n lo = 'on'\n when :extension\n lo = 'ox'\n when :rev_name\n lo = 'On'\n when :dirs\n lo = '/'\n when :clear\n lo = ''\n else\n return\n end\n ## This needs to persist and be a part of all listings, put in change_dir.\n @sorto = lo\n message \"Sorted on #{menu_text}\"\n rescan_required\nend",
"def children\n files = if index?\n # about/index.html => about/*\n File.expand_path('../*', @file)\n else\n # products.html => products/*\n base = File.basename(@file, '.*')\n File.expand_path(\"../#{base}/*\", @file)\n end\n\n Set.new Dir[files].\n reject { |f| f == @file || project.ignored_files.include?(f) }.\n map { |f| self.class[f, project] }.\n compact.sort\n end",
"def sort_contained_files_and_dirs(path)\n dirs, files = [], []\n if path != nil && File.directory?(path)\n Find.find(path) do |x|\n case\n when File.directory?(x)\n x.sub!(path, '')\n dirs << x unless x.length == 0\n when File.file?(x)\n x.sub!(path, '')\n files << x unless x.length == 0\n end\n end\n end\n {:files => files, :dirs => dirs}\n end",
"def sort_by(*args, &blk)\n self.dup{ @contents = @contents.select{|c| c.is_a? XML}.sort_by(*args, &blk) }\n end",
"def sort_name\n sort_constituent\n end",
"def make_inventory\n Dir.glob('**/*').sort.each {|f| puts f}\nend",
"def add_hierarchy_sort(solr_params)\n solr_params[:sort] = 'sort_ii asc' if %w[online_contents collection_context].include? blacklight_params[:view]\n solr_params\n end",
"def apply_blog_time_ordering(pages)\n pages.sort_by { |page| page.path.join('/') }.reverse\n end",
"def sort_files\n # Iterate thru files in @download_path\n cd(@download_path) do\n Find.find(pwd) do |path_to_file|\n @current_file_path = path_to_file\n next if @current_file_path == pwd # don't include the download folder as one of the files\n update_progress\n @file_directory, @file_name = File.split(@current_file_path)\n next if @file_name[0..0] == \".\" # skip any files/directories beginning with .\n # Stop searching this file/directory if it should be skipped, otherwise process the file\n should_skip_folder? ? Find.prune : process_download_file\n end\n end\n end",
"def traverse path\n entries = Dir.glob(\"#{View.expand_path(path)}/*\", File::FNM_DOTMATCH).\n select {|i| i !~ /\\/\\.(\\.*|svn|git)$/}. # Exclude some dirs (exclude entensions here too?)\n sort\n\n # Process dirs\n entries.each{ |f|\n next unless File.directory?(f)\n cleaned = clean f\n @res += \"#{cleaned.sub(/(^ *)/, \"\\\\1- \")}/\\n\"\n traverse f\n }\n\n # Process files\n entries.each{ |f|\n next unless File.file?(f)\n cleaned = clean f\n @res += \"#{cleaned.sub(/(^ *)/, \"\\\\1+ \")}\\n\"\n }\n\n end",
"def findOrdering(neededByHash, leafSet)\n\t\t#this is the stack used to do a DFS\n\t\tpendingStack = Array.new()\n\n\t\t#for each target, this hash will contain an array of it's dependents\n\t\t#that have not yet been visited. The value will be initialized to\n\t\t#the values in neededByHash the first time a target node is visited,\n\t\t#and then decremented one by one as the graph is traversed\n\t\tremainingChildrenHash = Hash.new()\n\n\t\tdef copySetToArray(st)\n\t\t\tnewArr = []\n\t\t\tst.each {|vl| newArr.push(vl)}\n\t\t\treturn newArr\n\t\tend\n\n\t\tpendingStack.concat(leafSet.to_a())\n\t\tpendingStack.each do |trg| \n\t\t\tchildrenSet = neededByHash[trg]\n\t\t\tchildrenArr = copySetToArray(childrenSet)\n\t\t\tremainingChildrenHash[trg] = childrenArr\n\t\tend\n\n\t\t#the output ordering, where every filename is listed after all files\n\t\t#it depends on\n\t\tordering = Array.new()\n\n\t\tuntil(pendingStack.empty?)\n\t\t\t#debug \"\\n\\nfindOrdering:pendingStack: #{arrayString(pendingStack)}\"\n\t\t\tnextTarget = pendingStack.last()\n\t\t\t#debug \"findOrdering:Visiting: #{nextTarget}\"\n\t\t\tif(remainingChildrenHash[nextTarget].empty?)\n\t\t\t\tpendingStack.pop()\n\t\t\t\tordering.unshift(nextTarget)\n\t\t\telse\n\t\t\t\tnextChild = remainingChildrenHash[nextTarget].pop()\n\t\t\t\tunless (remainingChildrenHash.has_key?(nextChild))\n\t\t\t\t\tnextChildsChildrenSet = neededByHash[nextChild]\n\t\t\t\t\tnccArr = copySetToArray(nextChildsChildrenSet)\n\t\t\t\t\tremainingChildrenHash[nextChild] = nccArr\n\t\t\t\t\tpendingStack.push(nextChild)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\treturn ordering\n\t\n\tend",
"def sortFilesFromDirs array, dir #array is elements in current directory: dir\n\n #temp arrays to hold files vs dirs\n dirs = Array.new\n files = Array.new\n\n array.each do |elem|\n\n #path to current entity interested in\n currentPath = dir + \"/\" + elem\n #puts \"currentPath: \" + currentPath\n\n #is dir or no?\n if Dir.exist? currentPath\n dirs << elem\n else\n files << elem\n end\n\n end\n\n #puts \"dirs: \" + dirs.to_s\n #puts \"files: \" + files.to_s\n \n #return concatenated array\n return dirs + files\n\n end",
"def file_list tree_root=nil\n tree_root ||= self.tree_root\n file_list = []\n current_dir = tree_root\n visit_entries self.files do |type, name|\n case type\n when :directory\n current_dir = current_dir + \"/\" + name\n when :file\n file_list.push(current_dir + \"/\" + name)\n else\n throw \"BAD VISIT TYREE TYPE. #{type}\"\n end\n end\n file_list\n end",
"def index(base_path, glob = nil)\n\t\tglob = '*' if glob == '' or glob.nil?\n\t\tdirs = []\n\t\tfiles = []\n\t\t::Dir.chdir(base_path) do\n\t\t\t::Dir.glob(glob).each do |fname|\n\t\t\t\tif ::File.directory?(fname)\n\t\t\t\t\tdirs << fname + '/'\n\t\t\t\telse\n\t\t\t\t\tfiles << fname\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tdirs.sort + files.sort\n\trescue Errno::ENOENT\n\t\traise Rush::DoesNotExist, base_path\n\tend",
"def navigation_children\n sorted_children\n end",
"def sorted_with_order\n # Identify groups of nodes that can be executed concurrently\n groups = tsort_each.slice_when { |a, b| parents(a) != parents(b) }\n\n # Assign order to each node\n i = 0\n groups.flat_map do |group|\n group_with_order = group.product([i])\n i += group.size\n group_with_order\n end\n end",
"def sort_by_tag\n by_tag = Hash[@routes[:paths].sort_by do |_key, value|\n value.first[1]['tags']\n end]\n place_readme_first(by_tag)\n end",
"def sort_categories\n for cat in @all_categories\n if(cat.parent_id == nil)\n @all_categories_hash[0] = [cat]\n else\n if(@all_categories_hash[cat.parent_id] == nil)\n @all_categories_hash[cat.parent_id] = []\n end\n @all_categories_hash[cat.parent_id].push(cat)\n end\n end\n for key in @all_categories_hash.keys\n @all_categories_hash[key].sort!{|x,y| x.name <=> y.name}\n end\n end",
"def topological_sort\n\t\tcount = size\n\t\t@explored_nodes = Array.new(count, false)\n\t\t@current_label = count\n\t\t@topological_order = Array.new(count, nil)\n\t\tcount.times do |label|\n\t\t\tdfs_topological_order(label) unless @explored_nodes[label]\n\t\tend\n\t\ttopological_order\n\tend",
"def everything\n (all + non_analyzed).sort { |a, b| a.filename <=> b.filename }\n end",
"def sort_tree(tree)\n root = tree && tree[:root]\n if root == nil\n return []\n end\n arr1 = sort_tree(tree[:left])\n arr2 = sort_tree(tree[:right])\n return arr1 + [root] + arr2\nend",
"def sort array # This \"wraps\" recursive_sort.\n recursive_sort array, []\nend",
"def gfb dir, func\n dir += '/*' if File.directory?(dir)\n dir = dir.gsub('//', '/')\n\n # sort by time and then reverse so latest first.\n sorted_files = Dir[dir].sort_by { |f|\n if File.exist? f\n File.send(func, f)\n else\n sys_stat(func, f)\n end\n }.reverse\n\n # add slash to directories\n sorted_files = add_slash sorted_files\n return sorted_files\nend",
"def sort_by_ln!\n @entries.sort! { |a,b| a.ln <=> b.ln }\n @entries.reverse!\n end",
"def yaml_parts_in_saving_order\n lang_file_dirs_by_parts = ActiveSupport::OrderedHash.new\n @yaml_parts.each do |lang_file_dir, parts_in_this_dir|\n parts_in_this_dir.each do |part|\n lang_file_dirs_by_parts[part] = (lang_file_dirs_by_parts[part] || []) << lang_file_dir\n end\n end\n \n ordered_yaml_parts = []\n lang_file_dirs_by_parts.keys.sort_by{|key| key.split('.').size}.reverse.each do |part|\n lang_file_dirs_by_parts[part].reverse.each do |lang_file_dir|\n ordered_yaml_parts << File.join(lang_file_dir, part)\n end\n end\n \n ordered_yaml_parts\n end",
"def file_list(group)\n return Dir[File.join(@dir, group, FILE_EXT)].sort\nend",
"def sort\r\n key = params.keys.grep(/m(?:aj|in)ors/).shift # Get DOM ID.\r\n order, parent = params[key], key[/\\d+/] # Filter out category ids.\r\n attrs = order, (1..order.length).map { |p| { :position => p } }\r\n unless parent.nil? # Scope\r\n instance.idea_categories.find(parent).subcategories.update *attrs\r\n else\r\n instance.idea_categories.update *attrs\r\n end\r\n render(:update) { |page| page.visual_effect :highlight, key }\r\n end",
"def list(path, recursive=true, dirs=false)\n # TODO : this might need to be changed as it returns dir and contents\n # if there are contents\n nodes = []\n prune = recursive ? nil : 2\n @content_tree.with_subtree(path, nil, prune, dirs) do |node|\n nodes << node.path\n end\n nodes.sort.uniq\n end",
"def sort_by(tree, col, direction)\n tree.children(nil).map!{|row| [tree.get(row, col), row.id]} .\n sort(&((direction)? proc{|x, y| y <=> x}: proc{|x, y| x <=> y})) .\n each_with_index{|info, idx| tree.move(info[1], nil, idx)}\n\n tree.heading_configure(col, :command=>proc{sort_by(tree, col, ! direction)})\nend",
"def natural_sort_bitstreams\n filenames = self.bitstreams.map(&:filename)\n NaturalSort.sort!(filenames)\n self.bitstreams.each do |bs|\n bs.update!(bundle_position: filenames.index(bs.filename))\n end\n end",
"def walk(path, indent, mode, indentMax)\n list = Dir.entries(path);\n if (mode == \"t\")\n list.delete(\".\")\n list.delete(\"..\")\n list.sort! { |a,b| calcDirSize(path + \"\\\\\" + b) <=> calcDirSize(path + \"\\\\\" + a)}\n end\n for index in 0 ... list.size\n if list[index] != '.' && list[index] != '..'\n str = path + list[index]\n if File.directory?(path + \"\\\\\" + list[index]) && (mode == \"t\" || mode == \"n\")\n visit(path + \"\\\\\" + list[index], indent, mode)\n if mode != \"n\" || indentMax == -1 || indent < indentMax\n walk(path + \"\\\\\" + list[index], indent + 1, mode, indentMax)\n end\n elsif mode == \"d\"\n visit(path + \"\\\\\" + list[index], indent, mode)\n end\n end\n end\nend",
"def sort\n raise l(:todo_sort_no_project_error) if !parent_object\n \n #@todos = Todo.for_project(@project.id)\n @todos = parent_object.todos\n \n params.keys.select{|k| k.include? UL_ID }.each do |key|\n Todo.sort_todos(@todos,params[key])\n end\n \n render :nothing => true\n #render :action => \"sort.rjs\"\n end",
"def show\n old = @post.comments.includes(:user)\n sort_comments_in_tree old\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def container_sort(things)\n things = things.sort do |a,b|\n if a.children.length > 0\n if b.children.length > 0\n a.name < b.name ? -1 : 1\n else\n -1\n end\n else\n if b.children.length > 0\n 1\n else\n a.name < b.name ? -1 : 1\n end\n end\n end\n things\n end",
"def subtree_arranged(*args)\n Relationship.arranged_rels_to_resources(subtree_rels_arranged(*args))\n end",
"def sorted_contents\r\n @contents.keys.sort\r\n end",
"def collect_tree_up_from (foliage,\n parents,\n except_homepage,\n except_page,\n except_with_children)\n ancestry_string = parents.collect {|x| x.id.to_s }.join(\"/\")\n name_prefix = parents.collect {|x| x.title }.join(\" / \")\n name_prefix += \" / \" if name_prefix.present?\n\n our_mans_indexes = []\n foliage.each_index do |indx|\n if foliage[indx].ancestry.to_s == ancestry_string\n our_mans_indexes << indx\n end\n end\n\n leaves = []\n\n our_mans_indexes.reverse!\n our_mans_indexes.each do |indx|\n leaves << foliage.delete_at(indx)\n end\n\n leaves.sort! {|a,b| (a.prior == b.prior) ? a.id <=> b.id : a.prior <=> b.prior }\n result = []\n\n leaves.each do |leaf|\n do_writing = true\n if (except_page && leaf == except_page) || (except_homepage && leaf.home?)\n do_writing = false\n end\n result << [ name_prefix + leaf.title, leaf.id ] if do_writing\n unless do_writing == false && except_with_children\n result += collect_tree_up_from foliage,\n (parents + [ leaf ]),\n except_homepage,\n except_page,\n except_with_children\n end\n end\n\n result\n end",
"def find_all_files\n self.files.order('tag')\n end",
"def rearrange_docs!\n docs_table = {}\n custom_order = {}\n\n # pre-sort to normalize default array across platforms and then proceed to create a Hash\n # from that sorted array.\n docs.sort.each do |doc|\n docs_table[doc.relative_path] = doc\n end\n\n metadata[\"order\"].each do |entry|\n custom_order[File.join(relative_directory, entry)] = nil\n end\n\n result = Jekyll::Utils.deep_merge_hashes(custom_order, docs_table).values\n result.compact!\n self.docs = result\n end",
"def tree_ordered_names\n tree_order_name_ids.collect { |name_id| queried_names[queried_names.index { |name| name[:id] == name_id }] }\n end",
"def tree_list(ref = @ref, pages=true, files=true)\n if (sha = @access.ref_to_sha(ref))\n commit = @access.commit(sha)\n tree_map_for(sha).inject([]) do |list, entry|\n if ::Gollum::Page.valid_page_name?(entry.name)\n list << entry.page(self, commit) if pages\n elsif files && !entry.name.start_with?('_') && !::Gollum::Page.protected_files.include?(entry.name)\n list << entry.file(self, commit)\n end\n list\n end\n else\n []\n end\n end",
"def yaml_parts_in_loading_order\n ordered_yaml_parts = []\n @yaml_parts.each do |lang_file_dir, parts_in_this_dir|\n parts_in_this_dir.sort_by{|part| File.basename(part, '.yml').split('.').size}.each do |part|\n ordered_yaml_parts << File.join(lang_file_dir, part)\n end\n end\n ordered_yaml_parts\n end",
"def file_sort(files)\n models = files.find_all { |file| file =~ Core::Check::MODEL_FILES }\n mailers = files.find_all { |file| file =~ Core::Check::MAILER_FILES }\n helpers = files.find_all { |file| file =~ Core::Check::HELPER_FILES }\n others =\n files.find_all do |file|\n file !~ Core::Check::MAILER_FILES && file !~ Core::Check::MODEL_FILES && file !~ Core::Check::HELPER_FILES\n end\n models + mailers + helpers + others\n end",
"def test_sort_by_ancestry_with_block_paginated_missing_parents_and_children\n AncestryTestDatabase.with_model :extra_columns => {:rank => :integer} do |model|\n _, n2, n3, n4, n5, _ = build_ranked_tree(model)\n\n records = model.sort_by_ancestry(model.all.ordered_by_ancestry_and(:rank).offset(1).take(4), &RANK_SORT)\n if CORRECT\n assert_equal [n3, n2, n4, n5].map(&:id), records.map(&:id)\n else\n assert_equal [n2, n4, n5, n3].map(&:id), records.map(&:id)\n end\n end\n end",
"def get_folders(sort_style = SortStyle::Size)\n\t\tif sort_style.eql?(SortStyle::Name)\n\t\t\treturn @sub_folders.sort\n\t\telse\n\t\t\treturn @sub_folders.sort {|a,b| a[1]<=>b[1]}\n\t\tend\n\tend",
"def sort(*args, &blk)\n self.dup{ @contents = @contents.sort(*args, &blk) }\n end",
"def getContentTree\n #N Without this we won't have timestamp and the map of file hashes used to efficiently determine the hash of a file which hasn't been modified after the timestamp\n cachedTimeAndMapOfHashes = getCachedContentTreeMapOfHashes\n #N Without this we won't have the timestamp to compare against file modification times\n cachedTime = cachedTimeAndMapOfHashes[0]\n #N Without this we won't have the map of file hashes\n cachedMapOfHashes = cachedTimeAndMapOfHashes[1]\n #N Without this we won't have an empty content tree which can be populated with data describing the files and directories within the base directory\n contentTree = ContentTree.new()\n #N Without this we won't have a record of a time which precedes the recording of directories, files and hashes (which can be used when this content tree is used as a cached for data when constructing some future content tree)\n contentTree.time = Time.now.utc\n #N Without this, we won't record information about all sub-directories within this content tree\n for subDir in @baseDirectory.subDirs\n #N Without this, this sub-directory won't be recorded in the content tree\n contentTree.addDir(subDir.relativePath)\n end\n #N Without this, we won't record information about the names and contents of all files within this content tree\n for file in @baseDirectory.allFiles\n #N Without this, we won't know the digest of this file (if we happen to have it) from the cached content tree\n cachedDigest = cachedMapOfHashes[file.relativePath]\n #N Without this check, we would assume that the cached digest applies to the current file, even if one wasn't available, or if the file has been modified since the time when the cached value was determined.\n # (Extra note: just checking the file's mtime is not a perfect check, because a file can \"change\" when actually it or one of it's enclosing sub-directories has been renamed, which might not reset the mtime value for the file itself.)\n if cachedTime and cachedDigest and File.stat(file.fullPath).mtime < cachedTime\n #N Without this, the digest won't be recorded from the cached digest in those cases where we know the file hasn't changed\n digest = cachedDigest\n else\n #N Without this, a new digest won't be determined from the calculated hash of the file's actual contents\n digest = hashClass.file(file.fullPath).hexdigest\n end\n #N Without this, information about this file won't be added to the content tree\n contentTree.addFile(file.relativePath, digest)\n end\n #N Without this, the files and directories in the content tree might be listed in some indeterminate order\n contentTree.sort!\n #N Without this check, a new version of the cached content file will attempt to be written, even when no name has been specified for the cached content file\n if cachedContentFile != nil\n #N Without this, a new version of the cached content file (ready to be used next time) won't be created\n contentTree.writeToFile(cachedContentFile)\n end\n return contentTree\n end",
"def get_legacy_ingest_list(dirname )\n il = TaskHelpers.get_directory_list( dirname, /^extract./ )\n\n # sort by directory order\n return il.sort { |x, y| TaskHelpers.directory_sort_order( x, y ) }\n end",
"def arranged_tree_as_list(hash, options = {}, depth = 0, ul_id = '', &block)\n output = ''\n options = set_options(options)\n\n # sort the hash key based on sort_by options array if :sort_by is given\n unless options[:sort_by].empty?\n hash = Hash[hash.sort_by { |k, _v| options[:sort_by].map { |sort| k.send(sort) } }]\n end\n\n output << create_li_entries(hash, options, depth, block)\n output = create_ul(output, options, depth, ul_id) unless output.blank?\n\n output.html_safe\n end",
"def default_sorter\n lambda { |files|\n files.sort do |a, b|\n if b.container?\n a.container? ? a.name.downcase <=> b.name.downcase : 1\n else\n a.container? ? -1 : a.name.downcase <=> b.name.downcase\n end\n end\n }\n end",
"def print_tree(n, i = 0)\n i.times { print \" \" }\n puts \"+-#{n}\"\n $classtree[n].sort.each { |c| print_tree(c, i+2) }\nend",
"def decorate(files)\n files.sort\n end",
"def reorganize\n list = params[:list]\n prev_page = nil\n last_root = nil\n list.each_with_index do |item, i|\n item_params = item[1]\n\n page = Page.find(item_params['id'].to_i)\n \n # if root of tree on rails side\n if item_params['parent_id'] == ''\n page.parent_id = nil\n if last_root\n page.move_to_right_of(last_root.id)\n end\n last_root = page\n page.save\n\n else\n page.parent_id = item_params['parent_id'].to_i\n page.save\n \n # shift to the right of previous element if parent is the same\n if prev_page.parent_id == page.parent_id\n page.move_to_right_of(prev_page.id)\n else\n\n # iterate backwards to find last sibling\n current_index = i - 1 \n found_sibling = false\n keys = list.keys\n\n while found_sibling == false and current_index > 0 do\n if list[keys[current_index]]['parent_id'] == item_params['parent_id']\n page.move_to_right_of(list[keys[current_index]]['id'])\n found_sibling = true\n else\n current_index -= 1\n end\n end\n\n end\n end\n\n # set previous item\n prev_page = page\n\n end\n\n respond_to do |format|\n format.json { head :ok } \n end\n end"
] | [
"0.6565236",
"0.6553888",
"0.6486574",
"0.6473949",
"0.6463968",
"0.64280075",
"0.63442886",
"0.631743",
"0.6286578",
"0.62236816",
"0.61583024",
"0.6137821",
"0.6137821",
"0.60671806",
"0.60644627",
"0.60512304",
"0.6046765",
"0.60404986",
"0.602944",
"0.6025323",
"0.60016006",
"0.5992479",
"0.59797084",
"0.5941903",
"0.5926865",
"0.59219766",
"0.59188163",
"0.5899769",
"0.5838333",
"0.5817652",
"0.5808788",
"0.576385",
"0.568036",
"0.56791705",
"0.5641188",
"0.562744",
"0.56102926",
"0.5567802",
"0.55312115",
"0.5469445",
"0.54602647",
"0.54585475",
"0.5443921",
"0.5429305",
"0.54231596",
"0.5402205",
"0.5392316",
"0.53789157",
"0.53737473",
"0.53637284",
"0.53514427",
"0.5336567",
"0.53290856",
"0.5318891",
"0.5301869",
"0.52967453",
"0.5282864",
"0.5262424",
"0.52614695",
"0.5256123",
"0.52548",
"0.5250487",
"0.52499986",
"0.5225972",
"0.52095854",
"0.52053833",
"0.5205045",
"0.5199683",
"0.5195747",
"0.51880294",
"0.51857305",
"0.5148149",
"0.51376486",
"0.51373017",
"0.51347345",
"0.5132864",
"0.51303244",
"0.51300156",
"0.5123349",
"0.5117698",
"0.5116128",
"0.5109682",
"0.51041967",
"0.5086118",
"0.50856066",
"0.50839764",
"0.50835156",
"0.5072156",
"0.50671846",
"0.5066454",
"0.5063014",
"0.5058274",
"0.50483596",
"0.5047154",
"0.50438434",
"0.50421363",
"0.50356",
"0.5028949",
"0.50256515",
"0.50189626"
] | 0.7741237 | 0 |
given a relative path, add a file and hash value to this content tree N Without this, we can't add a file description (given as a relative path and a hash value) into the content tree for this directory | def addFile(filePath, hash)
#N Without this the path won't be broken up into elements so that we can start by processing the first element
pathElements = getPathElements(filePath)
#N Without this check, we would attempt to process an invalid path consisting of an empty string or no path elements (since the path should always contain at least one element consisting of the file name)
if pathElements.length == 0
#N Without this, the case of zero path elements will not be treated as an error
raise "Invalid file path: #{filePath.inspect}"
end
#N Without this check, the cases of having the immediate file name (to be added as a file in this directory) and having a file within a sub-directory will not be distinguished
if pathElements.length == 1
#N Without this, the single path element will not be treated as being the immediate file name
fileName = pathElements[0]
#N Without this, we won't have our object representing the file name and a hash of its contents
fileContent = FileContent.new(fileName, hash, @pathElements)
#N Without this, the file&content object won't be added to the list of files contained in this directory
files << fileContent
#N Without this, we won't be able to look up the file&content object by name.
fileByName[fileName] = fileContent
else
#N Without this, we won't have the first part of the file path required to identify the immediate sub-directory that it is found in.
pathStart = pathElements[0]
#N Without this, we won't have the rest of the path which needs to be passed to the content tree in the immediate sub-directory
restOfPath = pathElements[1..-1]
#N Without this, the file & hash won't be added into the sub-directory's content tree
getContentTreeForSubDir(pathStart).addFile(restOfPath, hash)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(path)\n blob = GitRb::Blob.new(path)\n FileUtils.mkdir_p(blob.directory)\n File.open(blob.object_path, 'w') { |f| f.write(blob.deflated_content) }\n GitRb::Index.new.add(blob)\n end",
"def add_file absolute_name, relative_name: absolute_name, parser: nil\n unless top_level = @files_hash[relative_name] then\n top_level = RDoc::TopLevel.new absolute_name, relative_name\n top_level.parser = parser if parser\n top_level.store = self\n @files_hash[relative_name] = top_level\n @text_files_hash[relative_name] = top_level if top_level.text?\n end\n\n top_level\n end",
"def add(path); end",
"def <<( file_path )\n if file_path.is_a?( Array )\n file = file_path.shift\n path = file_path\n else\n file = file_path\n path = []\n end\n File.open( file ) do |file_io|\n while( piece = file_io.read( @contents['info']['piece length'] - ( @carry_over ? @carry_over.length : 0 ) ) ) do\n if @carry_over\n piece = @carry_over + piece\n @carry_over = nil\n end\n if piece.length < @contents['info']['piece length']\n @carry_over = piece\n else\n @contents['info']['pieces'] << Digest::SHA1.digest( piece )\n end\n end\n @contents['info']['files'] << {\n 'path' => [ path, File.basename( file ) ].flatten,\n 'length' => file_io.pos\n }\n end\n self\n end",
"def file_set_append\n # Append the array of file metadata values to any FileSets with new FileNodes being appended\n parent.file_metadata += file_nodes\n file_nodes\n end",
"def add_file entry, content = nil\n path = repo_path.join entry\n dir, filename = path.split unless entry.end_with? \"/\"\n\n FileUtils.mkdir_p dir.to_s == '.' ? repo_path : dir\n FileUtils.touch path if filename\n File.write path, content if filename && content\n end",
"def hash_file path, hash_store\r\n\thexdigest = HASH_DIGEST.hexdigest(open(path, 'rb') { |io| io.read })\r\n\thash_store[hexdigest] << path\r\nend",
"def tree_append(tree_sha, item)\n child = {\n path: full_path(item.path).gsub(/^\\//, ''),\n sha: push_blob(item),\n type: 'blob',\n mode: '100644'\n }\n new_tree = @client.create_tree(repo, [child], base_tree: tree_sha)\n new_tree.sha\n end",
"def add_content_to_file(file_path, content)\n names = file_path.split('/')\n file_name = names.pop\n directory = self.mkdir(names.join('/'))\n directory.add_content_to_file(file_name, content)\n end",
"def add_file(*args)\n context = args.pop\n file_path_hash_or_string, content, commit_msg = args\n file_path_hash = file_path_hash_form(file_path_hash_or_string)\n get_adapter_repo(context).add_file(file_path_hash, content, commit_msg)\n end",
"def _relative(root) # :nodoc:\n return self unless root\n HRX::File._new_without_checks(HRX::Util.relative(root, path), content, comment)\n end",
"def add(path, path_from_document_root=nil)\n full_path = Pathname.new(path).expand_path(root)\n path_from_document_root = Pathname.new(path_from_document_root || full_path.relative_path_from(document_root))\n relative_dir = path_from_document_root.dirname\n\n md5 = Digest::MD5.file(full_path).hexdigest\n ext = full_path.extname\n name_without_ext = full_path.basename.to_s.chomp(ext)\n suffix = \"-#{md5}\"\n suffix = \"-#{version}#{suffix}\" if version\n versioned_file = \"#{name_without_ext}#{suffix}#{ext}\"\n\n versioned_path_from_document_root = relative_dir + versioned_file\n versioned_full_path = tmp_document_root + versioned_path_from_document_root\n\n mkdir_p versioned_full_path.dirname\n cp full_path, versioned_full_path\n\n http_path = '/' + path_from_document_root.to_s\n versioned_http_path = '/' + versioned_path_from_document_root.to_s\n\n manifest[http_path] = versioned_http_path\n end",
"def initialize(relativePath, hash)\n #N Without this, we won't rememeber the relative path value\n @relativePath = relativePath\n #N Without this, we won't remember the file's cryptographic hash of its contents\n @hash = hash\n end",
"def add_file(file)\n @files[file.name] = file\n file.parent = self\n end",
"def add_to_file entry, content\n path = repo_path.join entry\n File.write path, content, :mode => \"a\"\n end",
"def update_tth path, node\n if EventMachine.reactor_thread? || !@update_lock.locked?\n raise 'Should not update tth hashes in reactor thread or without' \\\n ' the local list lock!'\n end\n # Ignore dotfiles\n return if path.basename.to_s.start_with?('.')\n\n # Files might need to have a TTH updated, but only if they've been\n # modified since we last calculated a TTH\n if path.file?\n cached_info = @local_file_info[path]\n child = LibXML::XML::Node.new('File')\n child['Name'] = path.basename.to_s\n if cached_info && path.mtime <= cached_info[:mtime]\n child['TTH'] = cached_info[:tth]\n child['Size'] = cached_info[:size]\n else\n debug 'file-list', \"Hashing: #{path.to_s}\"\n child['TTH'] = file_tth path.to_s\n child['Size'] = path.size.to_s\n end\n @local_file_info[path] = {:mtime => path.mtime,\n :size => child['Size'],\n :tth => child['TTH']}\n node << child\n\n # Directories just need a node and then a recursive update\n elsif path.directory?\n child = LibXML::XML::Node.new('Directory')\n child['Name'] = path.basename.to_s\n path.each_child { |child_path| update_tth child_path, child }\n node << child\n\n # If we're not a file or directory, then we just have to ignore the\n # file for now...\n else\n debug 'file-list', \"Ignoring: #{path}\"\n end\n end",
"def add(path)\n chdir { super }\n end",
"def add_file(rev, full_path, content, _mime_type = 'text/plain')\n if file_exists?(rev, full_path)\n raise Repository::FileExistsConflict, full_path\n end\n # file does not exist, so add it\n creation_time = Time.current\n file = Repository::RevisionFile.new(rev.revision_identifier, {\n name: File.basename(full_path),\n path: File.dirname(full_path),\n last_modified_revision: rev.revision_identifier,\n changed: true,\n user_id: rev.user_id,\n last_modified_date: creation_time,\n submitted_date: creation_time\n })\n rev.__add_file(file, content)\n rev\n end",
"def add(entry, src_path, &continue_on_exists_proc); end",
"def add_file(attrs)\n return if search(\"//ovf:References/ovf:File[@ovf:href='#{attrs[:href]}']\").count == 1\n file = Nokogiri::XML::Node.new 'File', self\n file['ovf:href'] = attrs[:href] if attrs[:href]\n if attrs[:id]\n file['ovf:id'] = attrs[:id]\n else\n n = filecount + 1\n file['ovf:id'] = \"file#{n}\"\n end\n at('//ovf:References').add_child file\n end",
"def add\n working_repo.add tree\n end",
"def add_to_index(wiki, index, sha, files)\n end",
"def new_file_reference(path, sub_group_path = nil)\n ref = project.new(PBXFileReference)\n ref.path = path.to_s\n ref.update_last_known_file_type\n\n parent_group = find_subpath(sub_group_path, true)\n parent_group.children << ref\n set_file_refenrece_name_if_needed(ref, parent_group)\n ref\n end",
"def placeIntoHashTree(hash, path, value)\n splitPath = path.split(%r{\\s*[:;]\\s*})\n deeper(hash, splitPath, value)\n end",
"def add(*args)\n helper.glob_to_index(args) do |index, relative_path|\n index.add(relative_path.to_s)\n end\n\n self\n end",
"def child(relative_path)\n child = @root + relative_path\n child if @initial_contents.include?(child) || !child.exist?\n end",
"def file_hash=(value)\n @file_hash = value\n end",
"def getContentTree\n #N Without this we won't have timestamp and the map of file hashes used to efficiently determine the hash of a file which hasn't been modified after the timestamp\n cachedTimeAndMapOfHashes = getCachedContentTreeMapOfHashes\n #N Without this we won't have the timestamp to compare against file modification times\n cachedTime = cachedTimeAndMapOfHashes[0]\n #N Without this we won't have the map of file hashes\n cachedMapOfHashes = cachedTimeAndMapOfHashes[1]\n #N Without this we won't have an empty content tree which can be populated with data describing the files and directories within the base directory\n contentTree = ContentTree.new()\n #N Without this we won't have a record of a time which precedes the recording of directories, files and hashes (which can be used when this content tree is used as a cached for data when constructing some future content tree)\n contentTree.time = Time.now.utc\n #N Without this, we won't record information about all sub-directories within this content tree\n for subDir in @baseDirectory.subDirs\n #N Without this, this sub-directory won't be recorded in the content tree\n contentTree.addDir(subDir.relativePath)\n end\n #N Without this, we won't record information about the names and contents of all files within this content tree\n for file in @baseDirectory.allFiles\n #N Without this, we won't know the digest of this file (if we happen to have it) from the cached content tree\n cachedDigest = cachedMapOfHashes[file.relativePath]\n #N Without this check, we would assume that the cached digest applies to the current file, even if one wasn't available, or if the file has been modified since the time when the cached value was determined.\n # (Extra note: just checking the file's mtime is not a perfect check, because a file can \"change\" when actually it or one of it's enclosing sub-directories has been renamed, which might not reset the mtime value for the file itself.)\n if cachedTime and cachedDigest and File.stat(file.fullPath).mtime < cachedTime\n #N Without this, the digest won't be recorded from the cached digest in those cases where we know the file hasn't changed\n digest = cachedDigest\n else\n #N Without this, a new digest won't be determined from the calculated hash of the file's actual contents\n digest = hashClass.file(file.fullPath).hexdigest\n end\n #N Without this, information about this file won't be added to the content tree\n contentTree.addFile(file.relativePath, digest)\n end\n #N Without this, the files and directories in the content tree might be listed in some indeterminate order\n contentTree.sort!\n #N Without this check, a new version of the cached content file will attempt to be written, even when no name has been specified for the cached content file\n if cachedContentFile != nil\n #N Without this, a new version of the cached content file (ready to be used next time) won't be created\n contentTree.writeToFile(cachedContentFile)\n end\n return contentTree\n end",
"def add_file(repo_obj,path,content,msg=nil)\n Response.wrap_helper_actions() do\n ret = Hash.new\n repo_obj.add_file(path,content)\n ret[\"message\"] = msg if msg\n ret\n end\n end",
"def add_file!(paginated_file)\n container = @website_file.parent\n container.append_child(paginated_file)\n stash_paginated_file(paginated_file)\n end",
"def add_file(file, line = T.unsafe(nil), has_comments = T.unsafe(nil)); end",
"def add_file(file)\n index = @repo.index\n index.add path: file, oid: (Rugged::Blob.from_workdir @repo, file), mode: 0100644\n index.write\n\n @affected_files << file\n end",
"def append_node(node, parent = nil)\n # Add the node to the parents node list\n add_entry(node, parent)\n\n # Recursively get all filesystem entries contained in the current folder\n if node.is_a? FileSystem::Folder then\n pattern = '/*'\n entries = Dir.glob(node.path + pattern).sort_by { |a| a.downcase }\n files = []\n folders = []\n\n # Store files and folders in different collections\n # because files will be added before folders\n entries.each do |e|\n if File.directory? e\n folders << e\n else\n files << e\n end\n end\n\n # First add contained files\n files.each do |f|\n file = build_entry(:file, @index, f, @left_entry)\n append_node(file, node)\n end\n\n # After add contained folders and its entries\n folders.each do |f|\n folder = build_entry(:folder, @index, f, @left_entry)\n append_node(folder, node)\n end\n end\n end",
"def build_file(repo_rel_path, entry)\n full_path = repo_rel_path.join(entry)\n content = file_content(full_path)\n\n File.write(full_path, content)\n end",
"def create_file_reference\n relative_path = path.relative_path_from(project.path.dirname)\n group = project.main_group\n relative_path.descend do |subpath|\n if subpath == relative_path\n @pbx_file = insert_at_group(group)\n else\n group = find_or_create_relative_group(group, subpath.basename)\n end\n end\n end",
"def create_file_reference\n relative_path = path.relative_path_from(project.path.dirname)\n group = project.main_group\n relative_path.descend do |subpath|\n if subpath == relative_path\n @pbx_file = insert_at_group(group)\n else\n group = find_or_create_relative_group(group, subpath.basename)\n end\n end\n end",
"def file_path(path)\n if path.is_a? Symbol\n path = [path, @node.name]\n end\n actual_path = Path.find_file(path)\n if actual_path.nil?\n Util::log 2, :skipping, \"file_path(\\\"#{path}\\\") because there is no such file.\"\n nil\n else\n if actual_path =~ /^#{Regexp.escape(Path.provider_base)}/\n # if file is under Path.provider_base, we must copy the default file to\n # to Path.provider in order for rsync to be able to sync the file.\n local_provider_path = actual_path.sub(/^#{Regexp.escape(Path.provider_base)}/, Path.provider)\n FileUtils.mkdir_p File.dirname(local_provider_path), :mode => 0700\n FileUtils.install actual_path, local_provider_path, :mode => 0600\n Util.log :created, Path.relative_path(local_provider_path)\n actual_path = local_provider_path\n end\n if File.directory?(actual_path) && actual_path !~ /\\/$/\n actual_path += '/' # ensure directories end with /, important for building rsync command\n end\n relative_path = Path.relative_path(actual_path)\n @node.file_paths << relative_path\n @node.manager.provider.hiera_sync_destination + '/' + relative_path\n end\n end",
"def file_path(path)\n if path.is_a? Symbol\n path = [path, @node.name]\n end\n actual_path = Path.find_file(path)\n if actual_path.nil?\n Util::log 2, :skipping, \"file_path(\\\"#{path}\\\") because there is no such file.\"\n nil\n else\n if actual_path =~ /^#{Regexp.escape(Path.provider_base)}/\n # if file is under Path.provider_base, we must copy the default file to\n # to Path.provider in order for rsync to be able to sync the file.\n local_provider_path = actual_path.sub(/^#{Regexp.escape(Path.provider_base)}/, Path.provider)\n FileUtils.mkdir_p File.dirname(local_provider_path), :mode => 0700\n FileUtils.install actual_path, local_provider_path, :mode => 0600\n Util.log :created, Path.relative_path(local_provider_path)\n actual_path = local_provider_path\n end\n if File.directory?(actual_path) && actual_path !~ /\\/$/\n actual_path += '/' # ensure directories end with /, important for building rsync command\n end\n relative_path = Path.relative_path(actual_path)\n @node.file_paths << relative_path\n @node.manager.provider.hiera_sync_destination + '/' + relative_path\n end\n end",
"def add_to_file(path, contents)\n dir = File.dirname(path)\n\n unless File.directory?(dir)\n FileUtils.mkdir_p(dir)\n end\n\n # Using technique outlined here: http://www.dzone.com/snippets/ruby-open-file-write-it-and\n\n File.open(path, 'a') {|f| f.write(\"#{contents}\\n\") }\n\n \"#{path} updated\"\n end",
"def add_to_file(path, contents)\n dir = File.dirname(path)\n\n unless File.directory?(dir)\n FileUtils.mkdir_p(dir)\n end\n\n # Using technique outlined here: http://www.dzone.com/snippets/ruby-open-file-write-it-and\n\n File.open(path, 'a') {|f| f.write(\"#{contents}\\n\") }\n\n \"#{path} updated\"\n end",
"def build_repo repo_path, file_structure\n file_structure.each do |entry|\n add_file entry\n end\n end",
"def add_file(file)\n raise FileError, 'Piece length must be greater than 0' if @data['info']['piece length'] <= 0\n\n if @data['info'].key?('name') && @data['info'].key?('length')\n @data['info']['files'] = []\n @data['info']['files'] << {\n 'path' => [@data['info']['name']],\n 'length' => @data['info']['length']\n }\n @data['info'].delete('name')\n @data['info'].delete('length')\n end\n\n if @data['info'].key?('files')\n @data['info']['files'] << {\n 'path' => file.split('/'),\n 'length' => ::File.size(file)\n }\n @data['info']['pieces'] += hash_file(file, @data['info']['piece length'])\n return\n end\n\n @data['info']['name'] = ::File.basename(file)\n @data['info']['length'] = ::File.size(file)\n @data['info']['pieces'] = hash_file(file, @data['info']['piece length'])\n end",
"def add_file(file, dsid, file_name) \n return add_external_file(file, file_name) if dsid == 'content'\n super\n end",
"def add_element(user,parent_dagr,file_path,path,hard_name)\n file_name = /([\\w\\-]*\\.\\w*)/.match(file_path)\n return \"\" if !file_name\n file_name = file_name[0]\n \n path_prefix = /(([\\w\\-]+\\/)+)/.match(file_path)\n if path_prefix\n prefix = path_prefix[0]\n prefix = prefix[0..(prefix.length-2)]\n path += \"/\" + prefix\n end\n \n \n parts = file_name.split(\".\")\n \n keywords = \"\"\n parts[0].split(/[,_ ]/).each do |el|\n keywords += \"#{el},\"\n end\n keywords += parts[1]\n \n final_name = \"\"\n final_name = hard_name if hard_name\n final_name = parts[0] if !hard_name\n \n dagr = Dagr.add_dagr(user,file_name,path,0,final_name,keywords)\n dagr.add_parent(user,parent_dagr)\n return file_name\n end",
"def add(path, data, ctype=DEFAULT_CTYPE)\n # FIXME: determine if ADD or UPDATE EVENT\n # evt = File.exist? @content_tree.node_path(path)\n # FIXME: should this always be create-or-update? what about replace=false?\n n = @content_tree.add(path, data, ctype)\n notify(EVENT_ADD, path, ctype)\n n\n end",
"def add_file(file, dsid, file_name) \n return add_external_file(file, dsid, file_name) if dsid == 'content'\n super\n end",
"def initialize(name, hash, parentPathElements)\n #N Without this we won't remember the name of the file\n @name = name\n #N Without this we won't know the hash of the contents of the file\n @hash = hash\n #N Without this we won't know the path elements of the sub-directory (within the directory tree) containing the file\n @parentPathElements = parentPathElements\n #N Without this the file object won't be in a default state of _not_ to be copied\n @copyDestination = nil\n #N Without this the file object won't be in a default state of _not_ to be deleted\n @toBeDeleted = false\n end",
"def update_filepath(_package_id:, _filepath:, _sha1:, _size:); end",
"def add_file (file)\n @files[file.path] = file\n end",
"def /(file)\n Tree.content_by_path(repo, id, file, commit_id, path)\n end",
"def add_file(path)\n File.readlines(path).each { |s| self << s.strip }\n nil\n end",
"def addfile(contents, path, client = nil, clientip = nil)\n contents = Base64.decode64(contents) if client\n bucket = Puppet::FileBucket::File.new(contents)\n Puppet::FileBucket::File.indirection.save(bucket)\n end",
"def append_md5(file, digest, hashless: false)\n return file if hashless\n\n [[file.split(ex = File.extname(file)).first, digest].join('-'), ex].join\n end",
"def recurse_and_hash_tree(node)\n\n ## exit program if given a bunk file/dir\n print_and_exit \"given a bunk file/node\" unless File.exist? node\n\n ## if we have a file then return it's hash\n return Digest::MD5.hexdigest( node + File.read(node) ) if File.file? node\n\n ## we should have a directory now. exit otherwise...\n print_and_exit \"is there a strange device in this dir?\" unless File.directory? node\n\n ## recurse through each element in the directory and remember their hashes\n children_hash = \"\"\n Dir.glob(File.join node, '*' ) { |element| children_hash << recurse_and_hash_tree(element) }\n \n ## return the mashed up hash\n return Digest::MD5.hexdigest( node + children_hash ) \n\n end",
"def add!()\n git \"add #{@path}\"\n end",
"def add_stored(entry, src_path, &continue_on_exists_proc); end",
"def add(file)\n # add file to object db\n return false if !File.exists?(file)\n return false if !File.file?(file)\n \n sha = get_raw_repo.put_raw_object(File.read(file), 'blob')\n \n # add it to the index\n @git_index.add(file, sha)\n end",
"def mkfile(relative_path, content: '')\n mkdir File.dirname(relative_path)\n filename = File.join self.tmpdir, relative_path\n File.open(filename, 'w') {|f| f << content}\n filename\n end",
"def []=(path, content=nil)\n segments = split(path)\n unless basename = segments.pop\n raise \"invalid path: #{path.inspect}\"\n end\n \n tree = @tree.subtree(segments, true)\n tree[basename] = convert_to_entry(content)\n end",
"def add_file (file)\n @files[file.path] = file\n end",
"def edit_file\n @node = Node.new(:name => params[:name], :git_repo_id => params[:git_repo_id], :git_repo_path => params[:git_repo_path])\n end",
"def add(paths)\n paths.each_pair do |path, content|\n self[path] = content\n end\n \n self\n end",
"def add(filepath, attributes = {})\n fullpath = self.filepath_to_fullpath(filepath)\n\n unless self.pages.key?(fullpath)\n attributes[:title] = File.basename(fullpath).humanize\n attributes[:fullpath] = fullpath\n\n page = Locomotive::Mounter::Models::Page.new(attributes)\n page.mounting_point = self.mounting_point\n page.filepath = File.expand_path(filepath)\n\n page.template = OpenStruct.new(raw_source: '') if File.directory?(filepath)\n\n self.pages[fullpath] = page\n end\n\n self.pages[fullpath]\n end",
"def add_path(path)\n @tree.add_path(path)\n self\n end",
"def recursive_file_set(file_expression, label=:default, &block)\n @recursive_file_sets << [file_expression, label, block]\n end",
"def create_node(file)\n attributes = {\n id: SecureRandom.uuid\n }.merge(\n file.try(:node_attributes) || {}\n )\n node = FileMetadata.for(file: file).new(attributes)\n original_filename = file.original_filename\n file = storage_adapter.upload(file: file, resource: node, original_filename: original_filename)\n node.file_identifiers = node.file_identifiers + [file.id]\n node\n rescue StandardError => error\n Valkyrie.logger.error \"#{self.class}: Failed to append the new file #{original_filename} for #{node.id}: #{error}\"\n nil\n end",
"def find_and_update_task_snapshot(previous_file_hash, new_file_hash)\n ::Snapshot.find_each do |snapshot|\n child = find_child_with_file_hash previous_file_hash, snapshot.contents\n if child\n # update snapshot to use new_file_hash instead of the previous_file_hash\n child['value'] = new_file_hash\n\n # we're updating the internals contents of the snaphot above so\n # be sure to save the snapshot\n snapshot.save!\n end\n end\n end",
"def add_to_project(path)\n root_group = find_test_group_containing(path)\n\n # Find or create the group to contain the path.\n dir_rel_path = path.relative_path_from(root_group.real_path).dirname\n group = root_group.find_subpath(dir_rel_path.to_s, true)\n\n mark_change_in_group(relative_path(group))\n\n file_ref = group.new_file(path.to_s)\n\n puts \" #{basename(file_ref)} - added\"\n return file_ref\n end",
"def add_to_link_hierarchy( title, link, page=nil )\n\t\tnode = DocuBot::LinkTree::Node.new( title, link, page )\n\t\tparent_link = if node.anchor\n\t\t\tnode.file\n\t\telsif File.basename(link)=='index.html'\n\t\t\tFile.dirname(File.dirname(link))/'index.html'\n\t\telse\n\t\t\t(File.dirname(link) / 'index.html')\n\t\tend\n\t\t#puts \"Adding #{title.inspect} (#{link}) to hierarchy under #{parent_link}\"\n\t\tparent = descendants.find{ |n| n.link==parent_link } || self\n\t\tparent << node\n\tend",
"def create_node(file)\n attributes = {\n id: SecureRandom.uuid\n }.merge(\n file.try(:node_attributes) || {}\n )\n node = FileMetadata.for(file: file).new(attributes)\n original_filename = file.original_filename\n upload_options = file.try(:upload_options) || {}\n stored_file = storage_adapter.upload(file: file, resource: node, original_filename: original_filename, **upload_options)\n file.try(:close)\n node.file_identifiers = node.file_identifiers + [stored_file.id]\n node\n rescue StandardError => error\n message = \"#{self.class}: Failed to append the new file #{original_filename} for #{node.id} to resource #{parent.id}: #{error}\"\n # For FileSet parents we're likely attaching a derivative, so let the\n # error raise so sidekiq restarts.\n raise FileUploadFailed, message if file_set?(parent)\n # Prevent raising the error for resource file attachments - otherwise if\n # this keeps retrying (e.g this gets called 6 times by file_nodes and fails on the 5th) we'll end up with a bunch of orphan files on disk\n # - they've been uploaded to the storage adapter but not associated to a\n # FileSet.\n Valkyrie.logger.error message\n Honeybadger.notify message\n nil\n end",
"def hash(pathname)\n ext = pathname.extname\n ext = ('' == ext || nil == ext) ? :none : ext.to_sym\n digest = Digest::MD5.hexdigest(File.read(pathname.to_s))\n @scanned[ext] ||= {}\n @scanned[ext][digest] ||= []\n @scanned[ext][digest] << pathname\n end",
"def add(contents, log, author=nil, date=nil)\n\t raise AlreadyExist.new(\"already exist: #{@file.inspect}:#{@head_rev}\") if @state != 'dead'\n\t return mkrev(contents, log, author, date, 'Exp')\n\tend",
"def add_file path\n if File.exist? path\n @files << path\n else\n raise Errno::ENOENT, \"File '#{path}' doesn't exist\"\n end\n end",
"def add(path, data='', on_fs=false)\n self.stage { |idx| idx.add(path, data, on_fs) }\n end",
"def new_file(path, sub_group_path = nil, set_name = true)\n file = project.new(PBXFileReference)\n file.path = path.to_s\n file.update_last_known_file_type\n\n target = find_subpath(sub_group_path, true)\n target.children << file\n\n same_path_of_group = target.path == file.pathname.dirname.to_s\n same_path_project = file.pathname.dirname.to_s == '.' && target.path.nil?\n unless same_path_of_group || same_path_project\n file.name = file.pathname.basename.to_s\n end\n file\n end",
"def add_page_to_tree(page)\n if !page.root?\n #puts \"page: #{page}\"\n #puts \"page.fullpath: #{page.fullpath}\"\n #puts \"page.parent_id: #{page.parent_id}\"\n page.parent = @remote_pages_by_id[page.parent_id]\n #puts \"page.parent: #{page.parent}\"\n #puts \"page.parent.class: #{page.parent.class}\"\n #puts \"page.parent.children: #{page.parent.children}\"\n page.parent.children << page\n end\n end",
"def add(hash, package)\n info = extract_fields(package)\n info.merge!(generate_checksums(package))\n filenames = inject_package(hash, info, package)\n filenames\n end",
"def hash\n Digest::MD5.hexdigest(abs_filepath)[0..5]\n end",
"def add_item_to_index(item, path, update_worktree)\n if item.is_a?(BlobWithMode)\n # Our minimum git version is 1.6.0 and the new --cacheinfo syntax\n # wasn't added until 2.0.0.\n invoke(:update_index, '--add', '--cacheinfo', item.mode, item.hash, path)\n if update_worktree\n # XXX If this fails, we've already updated the index.\n invoke(:checkout_index, path)\n end\n else\n # Yes, if path == '', \"git read-tree --prefix=/\" works. :/\n invoke(:read_tree, \"--prefix=#{path}/\", update_worktree ? '-u' : '-i', item)\n end\n end",
"def add(hash, opts = {})\n uuid = opts[:id] || SecureRandom.uuid\n thash = Treet::Hash.new(hash)\n repos[uuid] = thash.to_repo(\"#{root}/#{uuid}\", opts.merge(:repotype => repotype))\n end",
"def []=(path, entry)\n raise ArgumentError unless entry && (Reference === entry || GitObject === entry)\n path = normalize_path(path)\n if path.empty?\n raise 'Empty path'\n elsif path.size == 1\n raise 'No blob or tree' if entry.type != :tree && entry.type != :blob\n entry.repository = repository\n @modified = true\n @children[path.first] = entry\n else\n tree = @children[path.first]\n if !tree\n tree = @children[path.first] = Tree.new(:repository => repository)\n @modified = true\n end\n raise 'Not a tree' if tree.type != :tree\n tree[path[1..-1]] = entry\n end\n end",
"def tree(root = '')\n build_hash(files(root), root)\n end",
"def build_node(file)\n parent = parent_folder(file)\n category = parent == \".\" ? to_symbol(@directory) : to_symbol(parent)\n basename = basename(file)\n title = basename_to_title(basename)\n html = Renderer.new.render_internal(file)\n\n { title: title,\n basename: basename,\n path: File.realpath(file),\n category: category,\n html: html }\n end",
"def add_metadata(path, ctype, data, mtype)\n n = @metadata_tree.add(path, ctype, data, mtype)\n notify(EVENT_META, path, ctype, mtype)\n n\n end",
"def add(path, data='', on_fs=false)\n exec { index.add(path, data, on_fs) }\n end",
"def cmd_add reference, description = 'TODO description'\n path = reference2path reference\n unless create_if_not_exist reference, path\n return\n end\n puts \"adding content to \" + reference\n open_vim path, :end_of_file, \n :add_line, \n :add_line, \n :append_desc, description, :add_line,\n :append_date,\n :add_line, \n :add_line \n end",
"def add_files(listing, path)\n listing.contents.each do |entry|\n key = from_base(entry.key)\n new_entry = entry_for(key, entry.size, entry.last_modified, false)\n @entries << new_entry unless strip(key) == strip(path) || new_entry.nil?\n end\n end",
"def append_to(resource)\n return [] if files.empty?\n\n # Update the files for the resource if they have already been appended\n updated_files = update_files(resource)\n return updated_files unless updated_files.empty?\n\n # Persist new files for the resource if there are none to update\n file_resources = FileResources.new(build_file_sets || file_nodes)\n\n # Append the array of file metadata values to any FileSets with new FileNodes being appended\n resource.file_metadata += file_resources.file_metadata if file_set?(resource)\n\n # If this resource can be viewed (e. g. has thumbnails), retrieve and set the resource thumbnail ID to the appropriate FileNode\n if viewable_resource?(resource)\n resource.member_ids += file_resources.ids\n # Set the thumbnail id if a valid file resource is found\n thumbnail_id = find_thumbnail_id(resource, file_resources)\n resource.thumbnail_id = thumbnail_id if thumbnail_id\n end\n\n # Update the state of the pending uploads for this resource\n adjust_pending_uploads(resource)\n\n file_resources\n end",
"def add_file(name, content)\n full_path = File.join(path, name)\n file = MirrorFile.new(full_path)\n\n file.write(content)\n\n file\n end",
"def []=(path, entry)\n # ensure an unexpanded tree is removed\n index.delete(path.to_sym)\n \n path = string(path)\n case entry\n when Array\n mode, sha = entry\n index[path] = [mode.to_sym, string(sha)]\n when Tree\n index[path] = entry\n when nil\n index.delete(path)\n else\n raise \"invalid entry: #{entry.inspect}\"\n end\n \n # add/remove content modifies self so\n # the sha can and should be invalidated\n @sha = nil\n end",
"def add(uri, text)\n # if redirect, add to index and keep going\n entry = @@entry.new(uri, @cur_block, @buflocation, text.size)\n\n # calculate the sha1 code, use the first four characters as the index\n entry.sha1, firstfour = sha1_w_sub(entry.uri, @idx_size)\n\n # add this entry to the index in the right place\n @index[firstfour] ||= []\n @index[firstfour] << entry\n\n # add to the buffer, and update the counter\n @buffer << text\n @buflocation += text.size\n\n flush_block if @buffer.size > @blocksize\n end",
"def file_digest(pathname)\n key = pathname.to_s\n if @digests.key?(key)\n @digests[key]\n else\n @digests[key] = super\n end\n end",
"def add(key, value)\n current_and_parent_pair = find_current_and_parent_nodes(key)\n if current_and_parent_pair[:current]\n # update new value if key exists\n current_and_parent_pair[:current].value = value\n else\n new_node = TreeNode.new(key,value)\n parent = current_and_parent_pair[:parent]\n link_node_to_parent(parent, new_node)\n end\n end",
"def add1 fn, pid='NULL', fp='';\n #>! make alg. to fill pid/fp from that other value - to have known boths\n st = File .stat fp+'/'+fn\n #>! if exist update then\n sq = \\\n %Q{ INSERT INTO #{$config.local_disk}_files\n (pid,fileName,st_mode,st_nlink,st_uid,st_gid,\n st_size,st_atime,st_mtime,st_ctime,pathCache)\n VALUES\n (#{pid},'#{fn}',#{st.mode},#{st.nlink},#{st.uid},#{st.gid},\n #{st.size},'#{st.atime}','#{st.mtime}','#{st.ctime}','#{fp}'); }\n puts sq\n @db.execute sq\n check1 fn, pid\n end",
"def file_history_push(file)\n file_history = $file_history.to_h\n file_history.each_pair do |index, file_name|\n if file_name == \"\"\n file_name = file\n $file_history[\"#{index}\"] = \"#{file_name}\"\n break\n end\n end\n end",
"def to_hash(hash = {})\r\n hash[name] ||= attributes_as_hash\r\n\r\n walker = lambda { |memo, parent, child, callback|\r\n next if child.blank? && 'file' != parent['type']\r\n\r\n if child.text?\r\n (memo[CONTENT_ROOT] ||= '') << child.content\r\n next\r\n end\r\n\r\n name = child.name\r\n\r\n child_hash = child.attributes_as_hash\r\n if memo[name]\r\n memo[name] = [memo[name]].flatten\r\n memo[name] << child_hash\r\n else\r\n memo[name] = child_hash\r\n end\r\n\r\n # Recusively walk children\r\n child.children.each { |c|\r\n callback.call(child_hash, child, c, callback)\r\n }\r\n }\r\n\r\n children.each { |c| walker.call(hash[name], self, c, walker) }\r\n hash\r\n end",
"def append(filename)\n return @filemgr.append(filename, @contents)\n end",
"def add(entry, src_path, &continue_on_exists_proc)\n continue_on_exists_proc ||= proc { ::Zip.continue_on_exists_proc }\n check_entry_exists(entry, continue_on_exists_proc, 'add')\n new_entry = entry.kind_of?(::Zip::Entry) ? entry : ::Zip::Entry.new(@name, entry.to_s)\n new_entry.gather_fileinfo_from_srcpath(src_path)\n new_entry.dirty = true\n @entry_set << new_entry\n end",
"def add(path)\n return true unless File.exist?(path)\n\n metadata[path] = {\n \"mtime\" => File.mtime(path),\n \"deps\" => [],\n }\n cache[path] = true\n end",
"def save(record)\n track = MyBiaDJ::Table(:files).create(:name => name, :path => relative_path)\n track.add_parent(record)\n track\n end"
] | [
"0.59910583",
"0.59862834",
"0.5984579",
"0.5936294",
"0.5856249",
"0.580495",
"0.56869835",
"0.5684682",
"0.56463146",
"0.56170005",
"0.55952966",
"0.55853224",
"0.55565417",
"0.5550237",
"0.55163854",
"0.55110806",
"0.5472231",
"0.5436014",
"0.54193217",
"0.5386023",
"0.5369563",
"0.5348097",
"0.53425956",
"0.5327596",
"0.53027564",
"0.5297394",
"0.5279296",
"0.52684164",
"0.52682924",
"0.5256383",
"0.52551174",
"0.52449685",
"0.5234427",
"0.51991314",
"0.51901686",
"0.51901686",
"0.5187752",
"0.5187752",
"0.5183227",
"0.5183227",
"0.5174966",
"0.51652145",
"0.5161971",
"0.5161388",
"0.51606625",
"0.5158641",
"0.5156708",
"0.51420265",
"0.5141479",
"0.5137209",
"0.511825",
"0.51018155",
"0.50971884",
"0.5096768",
"0.5091331",
"0.5085634",
"0.50797063",
"0.5079264",
"0.50784326",
"0.5077933",
"0.5061441",
"0.5061041",
"0.50507945",
"0.5048706",
"0.5048358",
"0.50472593",
"0.5046526",
"0.50305796",
"0.5020084",
"0.50098747",
"0.5007399",
"0.5002656",
"0.49835432",
"0.4981561",
"0.4959823",
"0.49529415",
"0.4948666",
"0.49465564",
"0.49461618",
"0.49143618",
"0.49092552",
"0.49082106",
"0.48986056",
"0.48985323",
"0.48964876",
"0.48929366",
"0.48818523",
"0.48757756",
"0.48676902",
"0.4855117",
"0.48523855",
"0.48499602",
"0.4844562",
"0.484188",
"0.48367003",
"0.48338026",
"0.48322773",
"0.48308343",
"0.4826402",
"0.4818111"
] | 0.6424309 | 0 |
prettyprint this content tree N Without this, we won't have a way to output a nice easytoread description of this content tree object | def showIndented(name = "", indent = " ", currentIndent = "")
#N Without this check, would attempt to output time for directories other than the root directory for which time has not been recorded
if time != nil
#N Without this, any recorded time value wouldn't be output
puts "#{currentIndent}[TIME: #{time.strftime(@@dateTimeFormat)}]"
end
#N Without this check, an empty line would be output for root level (which has no name within the content tree)
if name != ""
#N Without this,non-root sub-directories would not be displayed
puts "#{currentIndent}#{name}"
end
#N Without this check, directories not to be copied would be shown as to be copied
if copyDestination != nil
#N Without this, directories marked to be copied would not be displayed as such
puts "#{currentIndent} [COPY to #{copyDestination.relativePath}]"
end
#N Without this check, directories not be to deleted would be shown as to be deleted
if toBeDeleted
#N Without this, directories marked to be deleted would not be displayed as such
puts "#{currentIndent} [DELETE]"
end
#N Without this, output for sub-directories and files would not be indented further than their parent
nextIndent = currentIndent + indent
#N Without this, sub-directories of this directory won't be included in the output
for dir in dirs
#N Without this, this sub-directory won't be included in the output (suitable indented relative to the parent)
dir.showIndented("#{dir.name}/", indent = indent, currentIndent = nextIndent)
end
#N Without this, files contained immediately in this directory won't be included in the output
for file in files
#N Without this, this file and the hash of its contents won't be shown in the output
puts "#{nextIndent}#{file.name} - #{file.hash}"
#N Without this check, files not to be copied would be shown as to be copied
if file.copyDestination != nil
#N Without this, files marked to be copied would not be displayed as such
puts "#{nextIndent} [COPY to #{file.copyDestination.relativePath}]"
end
#N Without this check, files not to be deleted would be shown as to be deleted
if file.toBeDeleted
#N Without this, files marked to be deleted would not be displayed as such
puts "#{nextIndent} [DELETE]"
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s\n object_identifier = \"#<#{self.class.to_s}:0x#{'%x' % (self.object_id << 1)}\\n\"\n close_object = \">\\n\"\n \n case self\n when RubyBBCode::BBTree\n object_identifier + \"Children: #{count_child_nodes}\\n\" + self.to_v + close_object\n when RubyBBCode::TagNode # when inspecting TagNodes, it's better not to show the tree display\n if self[:is_tag]\n object_identifier + \"Tag: #{self[:tag].to_s}, Children: #{count_child_nodes}\\n\" + close_object\n else\n object_identifier + '\"' + self[:text].to_s + \"\\\"\\n\" + close_object\n end\n end\n end",
"def to_tree() = puts(TTY::Tree.new({ '.' => as_tree }).render)",
"def show_tree\n htmltree = \"\"\n self.each { |node| \n htmltree += \"<li><a href='#{normalize(node.name)}'>\"\n htmltree += ' ' * node.node_depth * 3\n htmltree += \"#{node.name}</a></li>\\n\"\n }\n htmltree\n end",
"def pretty_print(depth = 0)\n depth.times { STDERR.print ' *' }\n STDERR.print ' '\n STDERR.puts \"#{@name} (#{@id})\"\n @contents.each { |obj| obj.pretty_print(depth + 1) }\n end",
"def print_tree\n ''\n end",
"def to_text\n self_and_descendants.map do |node|\n if block_given?\n inspect = yield(node)\n else\n inspect = node.class.inspect\n end\n \"#{'*'*(node.level+1)} #{inspect} (#{node.parent_id.inspect}, #{node.left}, #{node.right})\"\n end.join(\"\\n\")\n end",
"def _display_tree(max_length=20, tabs='')\n\t\tif(@type != '')\n\t\t\tprint(tabs + \"[\" + @type + ((@param != '')? '(' + @param.to_s + ')': '') + \"]\\n\")\n\t\telse\n\t\t\tprint(tabs + \"[TEMPLATE:\" + @template.template_file + \"]\\n\")\n\t\tend\n\n\t\tfor content in @contents\n\t\t\tif(content.is_a?(SifterElement))\n\t\t\t\tcontent._display_tree(max_length, tabs + \"\\t\")\n\t\t\telsif(content.is_a?(SifterTemplate))\n\t\t\t\tcontent._display_tree(max_length, tabs + \"\\t\")\n\t\t\telse\n\t\t\t\tcontent.gsub!(/[\\r\\n]/, ' ')\n\t\t\t\tprint(tabs + \"\\t[TEXT:\" + content[0, max_length] + \"]\\n\")\n\t\t\tend\n\t\tend\n\tend",
"def inspect\r\n line = \"<#{@key.gsub('_', '-')}>\"\r\n if (is_leaf?)\r\n line << @value\r\n else\r\n @children.each do |child|\r\n line << child.inspect\r\n end\r\n end\r\n line << \"</#{@key.gsub('_', '-')}>\"\r\n end",
"def printTree()\n def pTree(node, i)\n puts node.toString i\n node.children.each do|child|\n pTree(child, i+1)\n end\n end\n pTree(@root, 0)\n end",
"def print_tree(indent = 0, lines = [])\n lines << (\" \" * indent) + self.to_s\n @nodes.keys.sort.each do |reference|\n node = @nodes[reference]\n if node.is_a? APISpec::Namespace\n node.print_tree(indent + 1, lines)\n else\n lines << (\" \" * (indent + 1)) + \"#{reference} => #{node.to_s}\"\n end\n end\n lines.join(\"\\n\")\n end",
"def printout\n\t\t\n\t\tindex = 0\n\t\t\n\t\tdef small_loop (node, index)\n\t\t\t\n\t\t\tfor i in 0...index\n\t\t\t\tprint \" \"\n\t\t\tend\n\t\t\t\n\t\t\tputs node.name\n\t\t\tindex += 1\n\t\t\t\n\t\t\tif node.children.length > 0\n\t\t\t\tindex += 1\n\t\t\t\tnode.children.cycle(1) { |child| small_loop(child, index) }\n\t\t\tend\n\t\tend\n\t\t\n\t\tsmall_loop(@root, index)\n\tend",
"def internal_structure(indentation=0)\n node_descr = \"\"\n indentation.times { node_descr.concat \" \" }\n description = self.class.to_s.gsub(\"Node\", \"\")\n node_descr.concat \"#{description}\"\n if(!@node_value.nil?)\n node_descr.concat \" #{@node_value}\"\n end\n node_descr.concat \"\\n\"\n if (!children.nil?)\n children.each do |child| \n node_descr.concat(\"#{child.internal_structure(indentation+1)}\")\n end\n end\n return node_descr\n end",
"def show()\n printed = \"IPv4 Tree\\n---------\\n\"\n list4 = dump_children(@v4_root)\n list6 = dump_children(@v6_root)\n\n list4.each do |entry|\n cidr = entry[:CIDR]\n depth = entry[:Depth]\n\n if (depth == 0)\n indent = \"\"\n else\n indent = \" \" * (depth*3)\n end\n\n printed << \"#{indent}#{cidr.desc}\\n\"\n end\n\n printed << \"\\n\\nIPv6 Tree\\n---------\\n\" if (list6.length != 0)\n\n list6.each do |entry|\n cidr = entry[:CIDR]\n depth = entry[:Depth]\n\n if (depth == 0)\n indent = \"\"\n else\n indent = \" \" * (depth*3)\n end\n\n printed << \"#{indent}#{cidr.desc(:Short => true)}\\n\"\n end\n\n return(printed)\n end",
"def defaultRepresent(theTree)\n return theTree.sym.name unless isNT?(theTree.sym) \n theLine = ''\n spacer = ''\n theTree.children.each do |c|\n theLine << spacer << c.represent(self)\n spacer = ' '\n end\n return theLine\n end",
"def dump_node\n field_sep = self.class.field_sep\n \"#{@name}#{field_sep}#{self.class}#{field_sep}#{root? ? @name : parent.name}\"\n end",
"def print_tree(out = $stdout)\n out.puts \"## Class: #{name}\"\n out.puts \" Visible Name: #{visible_name}\"\n out.puts \" Description : #{description}\"\n tables.each do |table|\n table.print_tree(out)\n end\n end",
"def to_s(depth = 0)\n\t\tind = \" \" * depth\n\t\tind + \"[#{nonTerminal}/#{decision}\" +\n\t\tif(children.size == 0)\n\t\t\t\"]\\n\"\n\t\telse\n\t\t\t\"\\n\" + children.map { |c| if(c.is_a?(String)) then ind + \" \" + c.inspect + \"\\n\" else c.to_s(depth+1) end }.join(\"\") + ind + \"]\\n\"\n\t\tend\n\tend",
"def to_s(depth = 0)\n\t\tind = \" \" * depth\n\t\tind + \"[#{nonTerminal}/#{decision}\" +\n\t\tif(children.size == 0)\n\t\t\t\"]\\n\"\n\t\telse\n\t\t\t\"\\n\" + children.map { |c| if(c.is_a?(String)) then ind + \" \" + c.inspect + \"\\n\" else c.to_s(depth+1) end }.join(\"\") + ind + \"]\\n\"\n\t\tend\n\tend",
"def as_comment_body\n\t\treturn \"Published %d nodes as %s\" % [ self.subnodes.length, self.key ]\n\tend",
"def _dump(depth)\n inject(\"\") { |str, node| str << node.dump_node << self.class.node_sep }\n end",
"def dump(depth = 0)\n print ' ' * depth * 2\n print \"// #{self.to_s}\\n\"\n end",
"def show()\n printed = \"\"\n list = dump_children(@root)\n\n list.each do |entry|\n cidr = entry[:NetStruct].cidr\n depth = entry[:Depth]\n\n if (depth == 0)\n indent = \"\"\n else\n indent = \" \" * (depth*3)\n end\n\n printed << \"#{indent}#{cidr.desc(:Short => true)}\\n\"\n end\n\n return(printed)\n end",
"def render\n\t\t\ttree.flatten.map(&:to_s).join\n\t\tend",
"def inspect\n\t\tcontents = ''\n\t\tif self.parsed?\n\t\t\tcontents = %{\"%s\"/%d linkages/%d nulls} % [\n\t\t\t\tself.to_s,\n\t\t\t\tself.num_linkages_found,\n\t\t\t\tself.null_count,\n\t\t\t]\n\t\telse\n\t\t\tcontents = \"(unparsed)\"\n\t\tend\n\n\t\treturn \"#<%s:0x%x %s>\" % [\n\t\t\tself.class.name,\n\t\t\tself.object_id / 2,\n\t\t\tcontents,\n\t\t]\n\tend",
"def inspect(indent=\"\")\n result = \"\"\n result << indent\n result << self.class.to_s.sub(/.*:/,'')\n result << \" #{to_s} \" unless self.is_a?(Language::Tree) || self.is_a?(Language::Loop)\n \n unless elements.empty?\n result << \":\"\n elements.each do |e|\n result << \"\\n#{e.inspect(indent+\" \")}\" rescue \"\\n#{indent} #{e.inspect}\"\n end\n end\n \n result\n end",
"def to_s(page = nil)\n page ||= self.pages['index']\n\n puts \"#{\" \" * (page.try(:depth) + 1)} #{page.fullpath.inspect} (#{page.title}, position=#{page.position}, template=#{page.template_translations.keys.inspect})\"\n\n (page.children || []).each { |child| self.to_s(child) }\n end",
"def dump\n dump_text = ''\n regions.each do |child|\n dump_text << ' '*child.level << \"[Level: #{child.level}] \" << child.content.to_s << \"\\n\"\n end\n dump_text\n end",
"def printTree(options = {})\n # Set defaults\n options[:name] ||= true\n options[:content] ||= false\n \n result = \"\"\n \n options[:output] = result \n # Traverse tree and modify result by tacking on child names.\n printTraversal(options)\n \n puts result\n end",
"def to_s(page = nil)\n page ||= self.pages['index']\n\n return unless page.translated_in?(Locomotive::Mounter.locale)\n\n puts \"#{\" \" * (page.try(:depth) + 1)} #{page.fullpath.inspect} (#{page.title}, position=#{page.position})\"\n\n (page.children || []).each { |child| self.to_s(child) }\n end",
"def _display_tree(max_length=20, tabs='')\n\t\treturn @contents._display_tree(max_length, tabs)\n\tend",
"def inspect\n return self.class.to_s unless has_children\n \"(#{self.class} #{children.map {|c| c.inspect}.join(' ')})\"\n end",
"def to_s(options = { title: true })\n title_str = root? ? '' : \"#{'#' * level} #{@title}\\n\"\n md_string = \"#{options[:title] ? title_str : ''}#{@content}#{@children.map(&:to_s).join}\"\n md_string << \"\\n\" unless md_string.end_with?(\"\\n\")\n md_string\n end",
"def printtree(n, t)\n if t.question==nil\n n.times {print \" \"}\n puts t.name\n else\n puts t.question\n printtree n+1, t.yes\n printtree n+1, t.no\n end\n end",
"def _to_s(*args)\n result = String.new\n children.each do |child|\n next if child.invisible?\n child_str = child.to_s(1)\n result << child_str + (style == :compressed ? '' : \"\\n\")\n end\n result.rstrip!\n return \"\" if result.empty?\n return result + \"\\n\"\n end",
"def inspect(include_children=0)\n \"<#{@name}\" + @attrs.sort.map{|k,v| \" #{k}='#{v.xml_attr_escape}'\"}.join +\n if @contents.size == 0\n \"/>\"\n elsif include_children == 0\n \">...</#{name}>\"\n else\n \">\" + @contents.map{|x| if x.is_a? String then x.xml_escape else x.inspect(include_children-1) end}.join + \"</#{name}>\"\n end\n end",
"def print_tree(level = 0)\n if is_root?\n print \"\\n*\"\n else\n print \"|\" unless parent.is_root?\n print(' ' * (level - 1) * 4)\n print(is_root? ? \"+\" : \"|\")\n print \"---\"\n print(has_children? ? \"+\" : \">\")\n end\n\n if content\n content_hash = content.split(\"[\").first\n else\n content_hash = nil\n end\n\n puts \" #{content}\" + \" <Type: \" + (@node_type || \"no_type\") + \">\"\n\n children { |child| child.print_tree(level + 1)}\n end",
"def tree_stringify(children = @tree)\n str = \"\"\n\n children.each do |child|\n # - Elements have list of child nodes as content (process recursively)\n # - All other node types have text content\n if child[\"type\"] == \"elt\"\n str << child[\"open_tag\"] +\n tree_stringify(child[\"content\"]) +\n child[\"close_tag\"]\n else\n str << child[\"content\"]\n end\n end\n return str\n end",
"def dump(depth = 0)\n attr = ''\n @attr.each do |a| ## self.attributes do |a|\n attr += a.to_s + \", \"\n end if @attr\n attr.chop!\n attr.chop!\n print ' ' * depth * 2\n print \"#{@name}(#{attr})\\n\"\n @children.each do |child|\n child.dump(depth + 1)\n end if @children\n end",
"def print_tree(n, i = 0)\n i.times { print \" \" }\n puts \"+-#{n}\"\n $classtree[n].sort.each { |c| print_tree(c, i+2) }\nend",
"def to_s\n stringified = \"#{@name}[\"\n @children.each { |kid| stringified += \"#{kid[:link]} -> #{kid[:residue]}\" }\n stringified += \"]\\n\" \n end",
"def inspect\n if @name and [email protected]? then\n str = \"(Node:#{@name.inspect}\"\n else\n str = sprintf('(Node:%x', (self.__id__ << 1) & 0xffffffff)\n end\n if defined?(@bootstrap) and @bootstrap then\n str += \" bootstrap=#{@bootstrap.inspect}\"\n end\n str += \")\"\n str\n end",
"def to_pretty\n to_s(:prettyprint => true)\n end",
"def render(node = nil)\n elt = node | tree\n puts \"\\nNodes: #{elt.body.count}\"\n puts \"\\nAttributes:\"\n elt.attrs.each{ |k, v| puts(\"#{k}: #{v}\") }\n children = elt.body.select{ |i| i.is_a?(Node) }\n puts \"\\nChildren: #{children.each{ |c| render(c) }}\"\n\n\n end",
"def output_tree(element, indent = '')\n\t\t\t\tputs \"#{indent}#{element.class}: #{element.text_value}\"\n\t\t\t\t(element.elements || []).each do |e|\n\t\t\t\t\toutput_tree(e, \"#{indent} \")\n\t\t\t\tend\n\t\t\tend",
"def to_s\n\t\t\"<Node:#{@e}>\"\n\tend",
"def cmd_tree\n print_tree(Editor, 0)\n end",
"def print_tree(tree)\n\t\t\tif tree.is_leaf? and tree.depth > 0\n\t\t\t\tprint_line((\"|\\t\"*(tree.depth-1))+\"+------\"+tree.name)\n\t\t\telse\n\t\t\t\tprint_line((\"|\\t\"*tree.depth)+tree.name)\n\t\t\tend\n\t\t\ttree.children.each_pair do |name,child|\n\t\t\t\t\tprint_tree(child)\n\t\t\tend\n\t\tend",
"def to_graph(indent_level: 0, show_attr: true, out: [])\n\t\t\tmargin = ''\n\t\t\t0.upto(indent_level/STEP-1) { |p| margin += (p==0 ? ' ' : '|') + ' '*(STEP - 1) }\n\t\t\tmargin += '|' + '-'*(STEP - 2)\n\t\t\tout << margin + \"#{to_s(show_attr: show_attr)}\"\n\t\t\[email protected] do |child|\n\t\t\t\tchild.to_graph(indent_level: indent_level+STEP, show_attr: show_attr, out: out)\n\t\t\tend\n\t\t\treturn out\n\t\tend",
"def print_tree(out = $stdout)\n out.puts \" #{long_value} -> #{value}\"\n end",
"def printf(children=nil)\n text = \"\"\n if (self.root)\n queue = Queue.new\n queue.push(self.root)\n while (!queue.empty?)\n temp = queue.pop\n text << temp.title << \":\" << temp.rating.to_s\n if (temp.left)\n queue.push(temp.left)\n end\n if (temp.right)\n queue.push(temp.right)\n end\n text << \"\\n\"\n end\n puts text\n return\n end\n end",
"def inspect\n\t\tparts = []\n\t\tparts += self.tags.map {|t| \"##{t}\" }\n\t\tparts += self.bookmarks.map {|b| \"@#{b}\" }\n\n\t\treturn \"#<%p:#%x %s {%s} %p%s>\" % [\n\t\t\tself.class,\n\t\t\tself.object_id * 2,\n\t\t\tself.changeset,\n\t\t\tself.date,\n\t\t\tself.summary,\n\t\t\tparts.empty? ? '' : \" \" + parts.join(' ')\n\t\t]\n\tend",
"def inspect\n class_name = self.class.to_s.split('::').last\n child_lines = children.map { |child| child.inspect(4) }.join(\"\\n\")\n\n if doctype\n dtd = doctype.inspect(2)\n else\n dtd = doctype.inspect\n end\n\n if xml_declaration\n decl = xml_declaration.inspect(2)\n else\n decl = xml_declaration.inspect\n end\n\n return <<-EOF.strip\n#{class_name}(\n doctype: #{dtd}\n xml_declaration: #{decl}\n children: [\n#{child_lines}\n])\n EOF\n end",
"def print_tree(out = $stdout)\n out.puts \"Resource: #{id} (Key Field: #{key_field})\"\n rets_classes.each do |rets_class|\n rets_class.print_tree(out)\n end\n end",
"def print_tree(stream, indent=0)\n\t\t\tstream.puts summary(\"\\t\"*indent)\n\t\t\[email protected]_by { |child_status|\n\t\t\t\tchild_status.get_rss_total\n\t\t\t}.each { |child_status|\n\t\t\t\t# recursively print trees for child statuses\n\t\t\t\tchild_status.print_tree(stream, indent+1)\n\t\t\t}\n\t\tend",
"def to_string_tree\n if ((@children).nil? || (@children.size).equal?(0))\n return self.to_s\n end\n buf = StringBuffer.new\n if (!is_nil)\n buf.append(\"(\")\n buf.append(self.to_s)\n buf.append(Character.new(?\\s.ord))\n end\n i = 0\n while !(@children).nil? && i < @children.size\n t = @children.get(i)\n if (i > 0)\n buf.append(Character.new(?\\s.ord))\n end\n buf.append(t.to_string_tree)\n i += 1\n end\n if (!is_nil)\n buf.append(\")\")\n end\n return buf.to_s\n end",
"def to_s(indent = 0)\n indent_increment = 2\n child_indent = indent + indent_increment\n res = super\n @files.each_value do |file|\n res += \"\\n\" + file.to_s(child_ident)\n end if @files\n @dirs.each_value do |dir|\n res += \"\\n\" + dir.to_s(child_ident)\n end if @dirs\n res\n end",
"def printf\n output = []\n children = []\n output.push(\"#{@root.title}: #{@root.rating}\")\n if @root.left != nil\n children.push(@root.left)\n end\n if @root.right != nil\n children.push(@root.right)\n end\n children.each do |i|\n output.push(\"#{i.title}: #{i.rating}\")\n if i.left != nil\n children.push(i.left)\n end\n if i.right != nil\n children.push(i.right)\n end\n end\n puts output\n end",
"def pretty_print(pp) # :nodoc:\n if !node_models.empty?\n pp.text \" Node Models\"\n pp.nest(4) do\n pp.breakable\n pp.seplist(node_models.values.sort_by(&:name)) do |t|\n t.pretty_print(pp)\n end\n end\n end\n end",
"def render_tag_tree([email protected])\n string = \" \" * 2 * tree_node.depth\n string += \"<#{tree_node.info.type}\"\n string += \" class=#{tree_node.info.classes}\" unless tree_node.info.classes.nil?\n string += \" id=#{tree_node.info.id}\" unless tree_node.info.id.nil?\n string += \" name=#{tree_node.info.name}\" unless tree_node.info.name.nil?\n string += \">\"\n string += \" #{tree_node.info.text}\"\n puts string\n\n tree_node.children.each do |child|\n render_tag_tree(child)\n end\n end",
"def inspect\n Thread.current[:formatador] ||= Formatador.new\n data = \"#{Thread.current[:formatador].indentation}<#{self.class.name}\"\n Thread.current[:formatador].indent do\n unless self.instance_variables.empty?\n vars = self.instance_variables.clone\n vars.delete(:@client)\n vars.delete(:@page)\n data << \" \"\n data << vars.map { |v| \"#{v}=#{instance_variable_get(v.to_s).inspect}\" }.join(\", \")\n end\n end\n data << \" >\"\n data\n end",
"def pretty_to_s\n left_str = child_to_s(:left)\n right_str = child_to_s(:right)\n \"| \" * self.level + \"#{@feature} = #{@value}:\" + left_str + right_str\n end",
"def trees_to_html(trees)\nend",
"def printf(children=nil)\n toPrint = \"\"\n nextLine = []\n toPrint += \"#{@root.title}: #{@root.rating}\\n\"\n nextLine << @root.left if @root.left\n nextLine << @root.right if @root.right\n while nextLine.length > 0\n placeholder = []\n nextLine.each do |x|\n title = x.title\n rating = x.rating\n toPrint += \"#{title}: #{rating}\\n\"\n placeholder << x.left if x.left\n placeholder << x.right if x.right\n end\n nextLine = placeholder\n end\n print toPrint\n end",
"def show_node(tree, node)\n print \"ID:#{node.id} Parent:#{node.parent} Keys:\"\n node.keys.each { |key| print \"[#{key}]\"}\n print \" Sub trees:\"\n node.sub_trees.each { |sub_tree| print \"-#{sub_tree}-\"}\n print \"\\n\"\n node.sub_trees.compact.each { |sub_tree| show_node(tree, tree.nodes[sub_tree])}\nend",
"def to_s(indent)\n tab = 4\n result = \"#{@value1}\"\n result += \", #{@value2}\" if @type == 3\n result += \"\\n\"\n result += \" \" * indent + \"left tree: \"\n result += @left ? @left.to_s(indent+tab) : \"-\\n\"\n result += \" \" * indent + \"mid tree: \"\n result += @mid ? @mid.to_s(indent+tab) : \"-\\n\"\n if @type == 3\n result += \" \" * indent + \"right tree: \"\n result += @right ? @right.to_s(indent+tab) : \"-\\n\"\n end\n return result\n end",
"def render(params={})\n level = params[:level] || 0\n indent = params[:indent] || 2\n indent_str = \" \" * indent * level\n output = \"\"\n if @comments.length > 0\n output << \"\\n\" + indent_str\n join_str = \"\\n\" + indent_str\n output << \"<!-- \" + @comments.join(join_str) + \" --!>\\n\\n\"\n end\n output << indent_str\n opening_tag = \"<#{@name}\"\n @attrs.each_pair do |k, v|\n opening_tag << \" #{k}=\\\"#{v}\\\" \"\n end\n opening_tag << \"/\" unless @value || @children.length > 0\n opening_tag << \">\"\n output << opening_tag\n if @value\n output << \"\\n\" + \" \" * indent * (level + 1) + @value\n elsif @children.length > 0\n @children.each do |child|\n output << \"\\n\" + child.render(:level => level + 1, :indent => indent)\n end\n end\n output << \"\\n\" + indent_str + \"</#{@name}>\" if @value || @children.length > 0\n output\n end",
"def inspect\n original_inspect = super\n original_inspect.split( ' ' ).first << '>'\n end",
"def inspect\n original_inspect = super\n original_inspect.split( ' ' ).first << '>'\n end",
"def inspect\n original_inspect = super\n original_inspect.split( ' ' ).first << '>'\n end",
"def print_tree\n if root.children\n puts \" - root : #{root.children.length} - \"\n root.children.each(&:print_node)\n puts ''\n end\n end",
"def latex_qtree\n \"\\\\Tree \" + to_s(delim='[]', nonterm_prefix='.')\n end",
"def ascii_tree; end",
"def to_s\n \"#{@loc}: #{@children}\"\n end",
"def printf()\n #node object array\n children = []\n\n #info array\n arr = []\n arr.push(\"#{@root.title}: #{@root.rating}\")\n if @root.left != nil\n children.push(@root.left)\n end\n if @root.right != nil\n children.push(@root.right)\n end\n\n # adds nodes to children array AND pushes data to arr\n children.each do |node|\n if node.left != nil\n children.push(node.left)\n end\n if node.right != nil\n children.push(node.right)\n end\n arr.push(\"#{node.title}: #{node.rating}\")\n end\n\n puts arr\n end",
"def repr\n @nodes.values_at(*@nodes.each_index.reject {|i| @index_nodes.include? i}).join('/')\n end",
"def html\n children.to_s\n end",
"def to_s\n NodePrinter.new(@root).to_s\n end",
"def nodes_to_s\n string = \"\"\n @nodes.each do |name, node|\n string +=\"#{name}:\\n\\t(#{node.name})\\n\"\n end\n string\n end",
"def to_string(indentation)\n connector = '+- '\n selfie = super(indentation)\n prefix = \"\\n\" + (' ' * connector.size * indentation) + connector\n subnodes_repr = subnodes.reduce(+'') do |sub_result, subnode|\n sub_result << (prefix + subnode.to_string(indentation + 1))\n end\n\n selfie + subnodes_repr\n end",
"def to_s(options={})\n if self.is_leaf?\n location = self\n if !options[:without_edits]\n while !location.is_root? && location.parent.class < Natural::Alternative do\n location = location.parent\n end\n end\n location.text\n else\n self.children.inject('') {|result, item| (result += item.to_s + ' ')}.strip\n end\n end",
"def to_s\n @node.content\n end",
"def _dump(depth)\n \"\"\n end",
"def _dump(depth)\n \"\"\n end",
"def printf(children=nil)\n line = [@root]\n\n line.each do |i|\n puts \"#{i.title}: #{i.rating}\"\n if i.left\n line << i.left\n end\n if i.right\n line << i.right\n end\n end\n end",
"def to_s\n nodes.map do |_key, node|\n node.to_s\n end.join(\"\\n\")\n end",
"def print(depth)\n spaces = \" \".freeze * depth\n \"#{left_stats} #{spaces} └── #{@node.name}\"\n end",
"def print_depth(item)\n return if item.hidden?\n print_item item, 0\n list_recur_print item, 2\n end",
"def text\n\t\[email protected]\n\tend",
"def print_tree(tree)\n return \"-\" if tree.nil?\n puts \"#{tree.value}: \"\n print \"Left: \"\n puts \"#{print_tree(tree.children[0])}\"\n print \"Right: \"\n puts \"#{print_tree(tree.children[1])}\"\nend",
"def to_s\n \"Source Node children: #{@children.length}\"\n end",
"def print_tree(id)\n puts \"--------------------- Tree Record: #{NewYorkTrees::Tree.all[id].name} ---------------------\"\n puts \"\"\n puts \"Common Name:\"\n puts \"#{NewYorkTrees::Tree.all[id].name.ljust(25)}\"\n puts \"\"\n puts \"Scientific Name:\"\n puts \"#{NewYorkTrees::Tree.all[id].scientific_name.ljust(25)}\"\n puts \"\"\n puts \"Bark:\"\n puts \"#{NewYorkTrees::Tree.all[id].bark.ljust(25)}\"\n puts \"\"\n puts \"Twigs:\"\n puts \"#{NewYorkTrees::Tree.all[id].twigs.ljust(25)}\"\n puts \"\"\n puts \"Winter Buds:\"\n puts \"#{NewYorkTrees::Tree.all[id].winter_buds.ljust(25)}\"\n puts \"\"\n puts \"Leaves:\"\n puts \"#{NewYorkTrees::Tree.all[id].leaves.ljust(25)}\"\n puts \"\"\n puts \"Fruit:\"\n puts \"#{NewYorkTrees::Tree.all[id].fruit.ljust(25)}\"\n puts \"\"\n puts \"Distinguishing Features:\"\n puts \"#{NewYorkTrees::Tree.all[id].distinguishing_features.ljust(25)}\"\n puts \"\"\n puts \"---------------------Description---------------------\"\n\n puts \"#{NewYorkTrees::Tree.all[id].description}\"\n puts \"\"\n end",
"def show_tree\n\tend",
"def pretty_print(pp)\n Yadriggy::simpler_pretty_print(pp, self, '@parent')\n end",
"def to_s\n css = \"#{@name} {\\n\"\n @properties.each_pair { |k, v| css += \" #{k}: #{v};\\n\" }\n css += \"}\\n\\n\"\n @children.each { |c| css += c.to_s }\n css\n end",
"def inspect\n self.ast.to_s\n end",
"def print_node\n puts \"Value of node #{node_value}. Childs of node: #{node_childs} \"\n end",
"def tree_name_verbose\n %w[inherit enable].each_with_object([name]) do |v, ary|\n ary.append(\"(#{v})\") if v.nil? || v\n end.join(' ')\n end",
"def to_s\n root.to_tree_s\n end",
"def disp_node(node, depth)\n# mon_string = ''\n# depth.times {mon_string+=' '}\n# mon_string += \"- #{node.name}\"\n# `echo \"#{mon_string}\" >> toto.txt`\n\n # depth.times {print ' '}\n # puts \"- #{node.name}\"\n self.graph.each_adjacent node do |adj_node|\n disp_node adj_node, depth+1\n end\n end",
"def inspect_tree(tree_hash=tree, indentation=\"\")\n parts = []\n tree_hash.each do |id, subtree|\n parts << indentation + nodes_by_id[id].to_s\n unless subtree.empty?\n parts << inspect_tree(subtree, indentation + \" \")\n end\n end\n\n unless parts.empty?\n parts.compact.join(\"\\n\")\n end\n end",
"def print()\n puts @node_data.to_s\n end"
] | [
"0.68639475",
"0.6719232",
"0.6704638",
"0.66586185",
"0.6626054",
"0.6588514",
"0.6568514",
"0.6499684",
"0.6474251",
"0.6451705",
"0.6420791",
"0.63706154",
"0.6364939",
"0.63569766",
"0.6339204",
"0.6323295",
"0.6301825",
"0.6301825",
"0.62963414",
"0.62963045",
"0.6294872",
"0.6280217",
"0.6262698",
"0.62489074",
"0.6242069",
"0.62349397",
"0.6200409",
"0.6200234",
"0.6186663",
"0.6184435",
"0.6181679",
"0.6175253",
"0.61624354",
"0.61578876",
"0.6140519",
"0.6139936",
"0.61343616",
"0.6132524",
"0.61290914",
"0.6123355",
"0.6119673",
"0.6116037",
"0.6108679",
"0.6074996",
"0.60539067",
"0.6048056",
"0.60429275",
"0.6020282",
"0.60058355",
"0.6002493",
"0.5996811",
"0.5990026",
"0.5988133",
"0.5972084",
"0.59661925",
"0.59605056",
"0.5959787",
"0.5953672",
"0.5946188",
"0.5944293",
"0.5909315",
"0.590322",
"0.5901728",
"0.5895345",
"0.58869946",
"0.5886688",
"0.58846843",
"0.58846843",
"0.58846843",
"0.5880778",
"0.58807606",
"0.58803636",
"0.5876912",
"0.58704764",
"0.5867743",
"0.5864237",
"0.58634263",
"0.5849058",
"0.58454293",
"0.58434653",
"0.5843465",
"0.5840241",
"0.5840241",
"0.58342934",
"0.58335143",
"0.58136505",
"0.5795694",
"0.5790139",
"0.5785013",
"0.5764617",
"0.5762244",
"0.57610834",
"0.5757431",
"0.5756567",
"0.5755425",
"0.57517725",
"0.57487804",
"0.5745249",
"0.57361716",
"0.57292527",
"0.5725164"
] | 0.0 | -1 |
write this content tree to an open file, indented N Without this, the details for the content tree could not be output to a file in a format that could be read in again (by readFromFile) | def writeLinesToFile(outFile, prefix = "")
#N Without this check, it would attempt to write out a time value when none was available
if time != nil
#N Without this, a line for the time value would not be written to the file
outFile.puts("T #{time.strftime(@@dateTimeFormat)}\n")
end
#N Without this, directory information would not be written to the file (for immediate sub-directories)
for dir in dirs
#N Without this, a line for this sub-directory would not be written to the file
outFile.puts("D #{prefix}#{dir.name}\n")
#N Without this, lines for the sub-directories and files contained with this directory would not be written to the file
dir.writeLinesToFile(outFile, "#{prefix}#{dir.name}/")
end
#N Without this, information for files directly contained within this directory would not be written to the file
for file in files
#N Without this, the line for this file would not be written to the file
outFile.puts("F #{file.hash} #{prefix}#{file.name}\n")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def writeToFile(fileName)\n #N Without this, the user would not have feedback that the content tree is being written to the named file\n puts \"Writing content tree to file #{fileName} ...\"\n #N Without this, the named file cannot be written to\n File.open(fileName, \"w\") do |outFile|\n #N Without this, the lines of information for the content tree will not be written to the open file\n writeLinesToFile(outFile)\n end\n end",
"def writeTree(file)\n file.write toString\n end",
"def writeTree(file)\n file.write @tree.toString\n end",
"def print_to_file\n #f = File.new(\"#{Dir.pwd}/tmp/geoname_tree.txt\", \"wb\")\n File.open(\"geoname_tree.txt\", 'w') do |f|\n nodes.keys.each do |id|\n ts = tree_numbers(id).join(\"|\")\n f.write(\"#{id}|#{ts}\")\n f.write(\"\\n\")\n puts \"#{id}|#{ts}\"\n end\n end\n end",
"def write(f)\n f.puts \"Version: \" + VERSION\n f.puts \"Label: #{@label}\"\n f.puts \"Host: #{@host}\"\n f.puts \"Dir: #{@dir}\"\n f.puts \"Prune: \" + (@prune_leading_dir ? \"true\" : \"false\")\n f.puts\n super(f)\n end",
"def write_tree outfile\n writer = Bio::PhyloXML::Writer.new(outfile)\n writer.write(@tree)\n end",
"def save args={}\n raise ArgumentError, \"No file name provided\" if args[:filename].nil?\n @savable_sgf = \"(\"\n @root.children.each { |child| write_node child }\n @savable_sgf << \")\"\n\n File.open(args[:filename], 'w') { |f| f << @savable_sgf }\n end",
"def write_depths(io, trail_name, trail_sequence, kmer_hash)\n #write header\n io.print %w(trail position).join(\"\\t\")\n io.print \"\\t\"\n kmer_hash.number_of_abundances.times{|i| io.print \"\\tcoverage#{i+1}\"}\n io.puts\n\n #write data\n pos = 1\n Bio::Sequence::NA.new(trail_sequence).window_search(kmer_hash.kmer_length,1) do |kmer|\n io.puts [trail_name, pos, kmer_hash[kmer]].flatten.join(\"\\t\")\n pos += 1\n end\n end",
"def write_tree\n invoke(:write_tree)\n end",
"def write_to(io, *options)\n options = options.first.is_a?(Hash) ? options.shift : {}\n encoding = options[:encoding] || options[0]\n if Nokogiri.jruby?\n save_options = options[:save_with] || options[1]\n indent_times = options[:indent] || 0\n else\n save_options = options[:save_with] || options[1] || SaveOptions::FORMAT\n indent_times = options[:indent] || 2\n end\n indent_text = options[:indent_text] || \" \"\n\n # Any string times 0 returns an empty string. Therefore, use the same\n # string instead of generating a new empty string for every node with\n # zero indentation.\n indentation = indent_times.zero? ? \"\" : (indent_text * indent_times)\n\n config = SaveOptions.new(save_options.to_i)\n yield config if block_given?\n\n native_write_to(io, encoding, indentation, config.options)\n end",
"def write\n filename = \"#{@directory}/label.html\"\n File.open(filename, 'w') do |fp|\n fp.puts(self.to_s)\n end\n puts \"Wrote #{filename}\"\n end",
"def write(output, indent = T.unsafe(nil)); end",
"def save_section(node, writer)\r\n\r\n node.child_nodes.each do |child|\r\n writer.indentation = child.indentation\r\n \r\n case child.type\r\n when TYPE_COMMENT\r\n writer.write_comment child.value\r\n when TYPE_EMPTY\r\n writer.write_empty\r\n when TYPE_SECTION_START\r\n writer.write_start_section child.name, child.value\r\n save_section child, writer\r\n # Force indentation to match the parent\r\n writer.indentation = child.indentation\r\n writer.write_end_section\r\n when TYPE_DIRECTIVE\r\n writer.write_directive child.name, child.value\r\n end\r\n end\r\n end",
"def save_level\n File.open(@file_name, 'w') do |file|\n @blocks_array.each do |block|\n new_block = Block.new block.relative_position\n puts new_block.to_s\n end\n end\n end",
"def write(out, indent = T.unsafe(nil)); end",
"def write(out, indent = T.unsafe(nil)); end",
"def write(output, indent); end",
"def write(node)\r\n dir = folder(node)\r\n src = source(node)\r\n txt = text(node)\r\n unless dir.empty? || Dir.exist?(dir)\r\n Dir.mkdir(dir)\r\n @on_create_dir.call(dir) if @on_create_dir\r\n end\r\n File.write(src, txt)\r\n @on_create_file.call(src) if @on_create_file\r\n node.items.reject{|n| n.items.empty?}.each{|n| write(n)}\r\n end",
"def write_file\n\n File.open(\"rebuild.html\", \"w\") do |file|\n @write_array.each do |tags_and_text|\n file.write tags_and_text\n end\n end\n\n end",
"def storeTree(inTree, filename)\n File.open(filename, \"w\") do |file|\n file.puts YAML::dump(inTree)\n end\n end",
"def writer; end",
"def write\n File.open(@file, 'a') do |w| \n w.write(\"\\n\"+ @name + \" \" + @path)\n end\n end",
"def write_ode_solution(filename, desc=\"\")\n now=Time.now\n # Prepare headers\n comment = \"# #{@model_name} forward integration analysis - #{now} - MX Version: #{MECHATRONIX[:description]}\"\n File.open(filename, 'w') do |f|\n f.puts comment(desc)\n f.puts @ode_solution[:headers].join(\"\\t\")\n @ode_solution[:data][0].length.times do |r|\n f.puts @ode_solution[:data].inject([]) {|a,c| a << c[r]}.join(\"\\t\")\n end\n end\n\n end",
"def write_footer\n @openfile.write(\"\\n</Document>\\n</kml>\")\n end",
"def to_file( filename )\n File.open(filename, 'w') do |f|\n f.puts self.header\n @body.each do |section|\n f.puts section\n end\n f.puts self.footer\n end\n end",
"def write\n make_parent_directory\n generate_file\n end",
"def to_tree() = puts(TTY::Tree.new({ '.' => as_tree }).render)",
"def save_to_file\n File.open(@output, 'w+') do |file|\n file.puts HEADER if @additional_html\n file.puts @data_for_output.join(\"\\n\")\n file.puts FOOTER if @additional_html\n end\n end",
"def create(filename,serialized_tree)\n File.open(File.join(@base_path, filename),\"w\") do |f|\n f.write(serialized_tree)\n end\n end",
"def write_toc\n File.write('epub/OEBPS/toc.ncx', toc_ncx)\n end",
"def write(node, output); end",
"def write_folder(folder)\n @openfile.write \"<Folder>\\n<name>#{folder[:name]}</name>\\n\"\n\n unless folder[:folders].nil?\n folder[:folders].each do |inner_folder|\n write_folder(inner_folder)\n end\n end#else\n \n unless folder[:features].empty?\n folder[:features].each do |feature|\n write_placemark(feature)\n end\n # end\n end\n @openfile.write \"</Folder>\\n\\n\"\n end",
"def write(output = T.unsafe(nil), indent = T.unsafe(nil), transitive = T.unsafe(nil), ie_hack = T.unsafe(nil)); end",
"def write(output = T.unsafe(nil), indent = T.unsafe(nil), transitive = T.unsafe(nil), ie_hack = T.unsafe(nil)); end",
"def print_outline_to_file(outline, file)\n outline_subbed_str = outline.to_s.gsub(/\\:raw_stream_content=\\>\"(?:(?!\"}).)*+\"\\}\\}/, ':raw_stream_content=> RAW STREAM}}')\n brace_cnt = 0\n formatted_outline_str = ''\n outline_subbed_str.each_char do |c|\n if c == '{'\n formatted_outline_str << \"\\n\" << \"\\t\" * brace_cnt << c\n brace_cnt += 1\n elsif c == '}'\n brace_cnt -= 1\n brace_cnt = 0 if brace_cnt < 0\n formatted_outline_str << c << \"\\n\" << \"\\t\" * brace_cnt\n elsif c == '\\n'\n formatted_outline_str << c << \"\\t\" * brace_cnt\n else\n formatted_outline_str << c\n end\n end\n formatted_outline_str << \"\\n\" * 10\n File.open(file, 'w') { |f| f.write(formatted_outline_str) }\n end",
"def save_to_file\n File.open(\"results/#{seq_name}\"+\".txt\", 'w') { |file|\n \n n=1\n \n @actions.each do |a|\n file.puts a.description\n n +=1 \n end\n } \n \n end",
"def to_file( f )\n buf = [@name, @ref.binary_role(), @ref.binary_type(), @ref.name,\n @type, TYPE_SIZES[@type], \n @data.length()].pack(PFORMAT)\n f.write(buf)\n\n fmt_str = \"%s%d\" % [TYPES[@type], data.length]\n buf = data.pack(fmt_str)\n f.write(buf)\n end",
"def write(output, indent = T.unsafe(nil), transitive = T.unsafe(nil), ie_hack = T.unsafe(nil)); end",
"def write(output, indent = T.unsafe(nil), transitive = T.unsafe(nil), ie_hack = T.unsafe(nil)); end",
"def save_content(title, content)\n File.open(\"pages/#{title}.txt\", \"w\") do |file|\n file.print(content)\n end\nend",
"def to_file(filename)\n File.open(filename, 'w') do |f|\n f.puts self.header\n @body.each { |section| f.puts section }\n f.puts self.footer\n end\n end",
"def write(writer, indent = T.unsafe(nil), transitive = T.unsafe(nil), ie_hack = T.unsafe(nil)); end",
"def write(writer, indent = T.unsafe(nil), transitive = T.unsafe(nil), ie_hack = T.unsafe(nil)); end",
"def write(writer, indent = T.unsafe(nil), transitive = T.unsafe(nil), ie_hack = T.unsafe(nil)); end",
"def write_dta_file(io)\n io.print to_dta_file_data\n end",
"def to_file( f )\n size = 0\n @indexes.each { size += Index::FORMAT_SIZE }\n @idata.each do |i| \n size += IntData::FORMAT_SIZE\n size += i.data_size\n end\n\n buf = [@source, @name, @sym, @indexes.length(), @idata.length(), \n size].pack(PFORMAT)\n f.write(buf)\n @indexes.each { |i| i.to_file(f) }\n @idata.each { |i| i.to_file(f) }\n end",
"def write_obj_file output_path\n File.open(output_path, 'w') do |f|\n @vbuffer.each_triple do |a,b,c|\n f.puts \"v #{a} #{b} #{c}\"\n end\n @vnbuffer.each_triple do |a,b,c|\n f.puts \"vn #{a} #{b} #{c}\"\n end\n @fbuffer.each_triple do |a,b,c|\n f.puts \"f #{a+1}//#{a+1} #{b+1}//#{b+1} #{c+1}//#{c+1}\"\n end\n end\n self\n end",
"def write; end",
"def write; end",
"def writeToXML(fileName)\n f = File.new(fileName, \"w\")\n f.puts \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n\"\n f.puts \"<SAFTestBundle \" + \\\n \" xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" + \\\n \" xsi:noNamespaceSchemaLocation=\\\"SAFTestBundle.xsd\\\" \" + \\\n \" schemaVersion=\\\"1\\\">\\n\"\n\n # Initial Cases\n f.puts \"<SAFTestCaseList type=\\\"initial\\\" mode=\\\"sequential\\\">\\n\"\n @cases['initial'].each do |c|\n c.saveToXML(f)\n end\n\n @specCases.keys().each do |specName|\n f.puts \"<!-- Initial Cases for spec %s -->\\n\" % [specName.upcase()]\n @specCases[specName]['initial'].each do |c|\n c.saveToXML(f)\n end\n end\n f.puts \"</SAFTestCaseList>\\n\"\n \n # Main Cases\n f.puts \"<SAFTestCaseList type=\\\"main\\\" mode=\\\"%s\\\">\\n\" % [@mainMode]\n @cases['main'].each do |c|\n c.saveToXML(f)\n end\n\n @specCases.keys().each do |specName|\n f.puts \"<!-- Main Cases for spec %s -->\\n\" % [specName.upcase()]\n @specCases[specName]['main'].each do |c|\n c.saveToXML(f)\n end\n end\n f.puts \"</SAFTestCaseList>\\n\"\n\n # Final Cases\n f.puts \"<SAFTestCaseList type=\\\"final\\\" mode=\\\"sequential\\\">\\n\"\n @specCases.keys().each do |specName|\n f.puts \"<!-- Final Cases for spec %s -->\\n\" % [specName.upcase()]\n @specCases[specName]['final'].each do |c|\n c.saveToXML(f)\n end\n end\n\n @cases['final'].each do |c|\n c.saveToXML(f)\n end\n\n f.puts \"</SAFTestCaseList>\\n\"\n \n f.puts \"</SAFTestBundle>\\n\"\n end",
"def recurse_write(located_entry)\n write(located_entry.path, located_entry.entry_tree, top_level: false)\n end",
"def disp_node(node, depth)\n# mon_string = ''\n# depth.times {mon_string+=' '}\n# mon_string += \"- #{node.name}\"\n# `echo \"#{mon_string}\" >> toto.txt`\n\n # depth.times {print ' '}\n # puts \"- #{node.name}\"\n self.graph.each_adjacent node do |adj_node|\n disp_node adj_node, depth+1\n end\n end",
"def write_to_file\n file = File.open(@filename_erl,\"a\")\n file.puts @head, @erl, @sig_sub\n file.puts @sub if @@sub_struct_flag\n (file.puts @un_arr.uni_def, @un_arr.uni_func, @un_arr.uni_func_2) if @@union_flag\n (file.puts @un_arr.arr_def, @un_arr.arr_func) if @@dyn_array_flag\n file.close\n File.open(@filename_hrl, \"a\") {|f| f.puts @const, @enum, @hrl}\n end",
"def open_new_file_to_write(input, number, region)\n\toutfile = File.new(\"#{region}-per#{number}bp-#{input}.txt\", \"w\")\n\toutfile.puts \"position\\tnumhm\\tnumht\"\n\toutfile\nend",
"def open_new_file_to_write(input, number)\n\toutfile = File.new(\"per-#{number}bp-#{input}.txt\", \"w\")\n\toutfile.puts \"position\\tnumhm\\tnumht\"\n\toutfile\nend",
"def write_contents(filename = \"output.txt\")\n\t\t\tbegin\n\t\t\t\tputs \"Writing contents to file: \" + filename\n\t\t\t\tfile = File.open(filename, 'w')\n\t\t\t\t\n\t\t\t\t#TODO Load data mappings from xml file into the section tree\n\t\t\t\tif !@section_tree.nil? then\n\t\t\t\t\tfile.puts @section_tree.flatten\n\t\t\t\tend\n\t\t\t\t#size = line_count\n\t\t\t\t\n\t\t\t\t#for i in 0..size-1\n\t\t\t\t\t#Retrieve the dirty key from the line\n\t\t\t\t\t#dirtyKey = get_line_matchdata(i).to_s\n\t\t\t\t\t#If the line contains a key\n\t\t\t\t\t#if !dirtyKey.nil? && @replacements.count > 0 then\n\t\t\t\t\t\t#puts \"Dirty key: \" + dirtyKey\n\t\t\t\t\t\t#if @dirty_mappings.has_key? dirtyKey then\n\t\t\t\t\t\t\t#Retrieve the clean key from the dirty_mappings hash\n\t\t\t\t\t\t\t#cleanKey = @dirty_mappings[dirtyKey]\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t#if is_valid_key(cleanKey) > 0 then\n\t\t\t\t\t\t\t\t#puts \"Clean Key: \" + cleanKey\n\t\t\t\t\t\t\t\t#Retrieve the substitution value from the replacements table\n\t\t\t\t\t\t\t\t#value = get cleanKey\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t#Substitute the new value back into the content array\n\t\t\t\t\t\t\t\t#@contents[i] = @contents[i].gsub(dirtyKey, value.to_s)\n\t\t\t\t\t\t\t#end\n\t\t\t\t\t\t#end\n\t\t\t\t\t#end\n\t\t\t\t\n\t\t\t\t\t#Write the line to the file\n\t\t\t\t\t#file.puts @contents[i]\n\t\t\t\tend\n\t\t\t\n\t\t\tensure\n\t\t\t\tputs \"Closing output file: \" + filename\n\t\t\t\tfile.close unless file.nil?\n\t\t\tend",
"def to_file\n \"#{@name};#{@id}\"\n end",
"def save_content(title, content)\n\tFile.open(\"pages/#{title}.txt\" , \"w\") do |file|\n\t file.print(content)\n end \t\t\nend",
"def write(fp)\n @doc.write(fp, 0, false, false)\n fp << \"\\n\"\n end",
"def printf(children=nil)\n fname = \"comparison.txt\"\n comparison_file = File.open(fname, \"w\")\n \n theight = tree_height(@root)\n for i in 1..theight do\n print_given_level(@root, i)\n end\n \n comparison_file.close\n\n end",
"def dump\n dump_text = ''\n regions.each do |child|\n dump_text << ' '*child.level << \"[Level: #{child.level}] \" << child.content.to_s << \"\\n\"\n end\n dump_text\n end",
"def write_to(git)\n self.mode ||= git.default_tree_mode\n self.sha ||= begin\n lines = []\n each_pair(false) do |key, entry|\n mode, sha = case entry\n when Tree then entry.write_to(git)\n when Array then entry\n else [entry.mode, entry.id]\n end\n \n # modes should not begin with zeros (although it is not fatal\n # if they do), otherwise fsck will print warnings like this:\n #\n # warning in tree 980127...: contains zero-padded file modes\n lines << zero_strip(\"#{mode} #{key}\\0#{[sha].pack(\"H*\")}\")\n end\n\n git.set(:tree, lines.join)\n end\n\n [mode, sha]\n end",
"def write_file\n \n # if dirty?\n generate\n \n delete_file\n File.open(absolute_path.gsub(/\\.txt$/, \"\"), 'w+') do |f| \n f.write(generated_header)\n f.write(generated_content)\n end\n # not_dirty\n # end\n end",
"def file_open_puts object, filename\n File.open(filename, 'w') do |f|\n f.puts(object)\n end\n\n end",
"def write(f)\n document.write(f, -1, false, true)\n end",
"def write_to_file\n File.open(config.block_list_path, 'a') do |f|\n block_count = old_newest_block ? (block_list.size - old_newest_block.height - 1) : block_list.size\n block_list = self.block_list.sort{|(k1, v1), (k2, v2)| v1.height <=> v2.height}\n block_list = block_list[(old_newest_block.height + 1)..-1] if old_newest_block\n block_list.each_with_index do |(k, b), index|\n f.write(b.to_payload)\n f.flush\n print \"\\r#{(((index + 1).to_f / block_count) * 100).to_i}% done write parsed block to #{config.block_list_path}.\"\n end\n f.write(newest_block.to_payload)\n puts\n end\n end",
"def write_content(file_out)\n @array.each do |row|\n file_out.puts(' <Row>')\n row.each do |e|\n t = float?(e) ? 'Number' : 'String'\n file_out.puts(\n \" <Cell><Data ss:Type=\\\"#{t}\\\">#{e}</Data></Cell>\"\n )\n end\n file_out.puts(' </Row>')\n end\n end",
"def write_content\n File.open(absolute_path,'w') do |file|\n file << content if content\n end\n # TODO git functionality\n end",
"def dump\n return unless @config_file\n File.open(@config_file,'w') do |fl|\n @todo_container.each do |category,todo_array|\n fl << \"* #{category}\\n\"\n todo_array.each do |todo_item|\n fl << \"#{priority_star(todo_item.priority)} #{todo_item.flag ? 'TODO' : 'DONE'} #{todo_item.text}\\n\"\n end\n end\n end\n end",
"def log(person)\n @file << person.to_markdown\n @file << \"\\n\\n\"\n end",
"def write_hgtags_file(opener, filename, mode, node, names, preamble = nil)\n opener.open(filename, mode) do |file|\n file << preamble if preamble\n write_tags(file, node, names)\n end\n end",
"def write\n case parser_name\n when \"d3mpq_stringlist\"\n write_stringlist\n when \"d3mpq_recipe\"\n write_recipe\n when \"d3mpq_coredata_gamebalance_setitembonuses\"\n @field = nil\n write_recipe\n when \"d3mpq_attributes\"\n write_single_file(\"analyze\")\n when \"d3mpq_coredata_actor\"\n write_single_file(\"analyze\")\n else\n write_game_balance\n end\n end",
"def to_s(options = { title: true })\n title_str = root? ? '' : \"#{'#' * level} #{@title}\\n\"\n md_string = \"#{options[:title] ? title_str : ''}#{@content}#{@children.map(&:to_s).join}\"\n md_string << \"\\n\" unless md_string.end_with?(\"\\n\")\n md_string\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 indent()\n file = Tempfile.new(\"out\")\n infile = Tempfile.new(\"in\")\n file.write(self.to_s)\n file.flush\n bufc = \"FOO\"\n\n tmppos = @pos\n\n message(\"Auto format #{@fname}\")\n\n if [\"chdr\", \"c\", \"cpp\"].include?(get_file_type())\n\n #C/C++/Java/JavaScript/Objective-C/Protobuf code\n system(\"clang-format -style='{BasedOnStyle: LLVM, ColumnLimit: 100, SortIncludes: false}' #{file.path} > #{infile.path}\")\n bufc = IO.read(infile.path)\n elsif get_file_type() == \"Javascript\"\n cmd = \"clang-format #{file.path} > #{infile.path}'\"\n debug cmd\n system(cmd)\n bufc = IO.read(infile.path)\n elsif get_file_type() == \"ruby\"\n cmd = \"rufo #{file.path}\"\n debug cmd\n system(cmd)\n bufc = IO.read(file.path)\n else\n return\n end\n self.update_content(bufc)\n center_on_current_line #TODO: needed?\n file.close; file.unlink\n infile.close; infile.unlink\n end",
"def write item\n @f.write \">\"+item.id+' '+item.descr+\"\\n\"\n @f.write item.seq.strip+\"\\n\"\n end",
"def write(file)\n @file_written = file\n file = Pathname.new(file)\n file.dirname.mkpath\n file.open \"w+\" do |output|\n output << self.build!\n end\n self\n end",
"def update_file\n output = (@blocks[:before] + @blocks[:attributes] + @blocks[:after]).join(\"\\n\").strip + \"\\n\"\n File.open(@filename,'w') { |f| f.write(output) } if output != @file\n end",
"def _display_tree(max_length=20, tabs='')\n\t\tif(@type != '')\n\t\t\tprint(tabs + \"[\" + @type + ((@param != '')? '(' + @param.to_s + ')': '') + \"]\\n\")\n\t\telse\n\t\t\tprint(tabs + \"[TEMPLATE:\" + @template.template_file + \"]\\n\")\n\t\tend\n\n\t\tfor content in @contents\n\t\t\tif(content.is_a?(SifterElement))\n\t\t\t\tcontent._display_tree(max_length, tabs + \"\\t\")\n\t\t\telsif(content.is_a?(SifterTemplate))\n\t\t\t\tcontent._display_tree(max_length, tabs + \"\\t\")\n\t\t\telse\n\t\t\t\tcontent.gsub!(/[\\r\\n]/, ' ')\n\t\t\t\tprint(tabs + \"\\t[TEXT:\" + content[0, max_length] + \"]\\n\")\n\t\t\tend\n\t\tend\n\tend",
"def opx_file_write_tabulator(tab)\n outfile = opx_file_open_write(TABULATOR_DATA_FILE)\n YAML::dump(tab.tabulator_count, outfile)\n opx_file_close(outfile)\n rescue => e\n opx_err(\"Fatal failure of YAML::dump for file: #{TABULATOR_DATA_FILE}\", e)\n end",
"def parse_to_file()\n i = 0\n str_n = \"\"\n\n # generating string with 50 N's\n while i<50\n str_n = \"#{str_n}N\"\n i += 1\n end\n\n seq1 = \"\"\n seq2 = \"\"\n\n line1 = @f1.readline().chomp\n line2 = @f2.readline().chomp\n\n tmp1 = line1.split(\" \")\n tmp2 = line2.split(\" \")\n\n header = \"#{tmp1[0]}::#{tmp2[0]}\"\n\n while [email protected]?()\n\n line2 = @f2.readline().chomp\n line1 = @f1.readline().chomp\n\n unless line1.include?('>')\n seq1 = seq1 + \"#{line1}\"\n seq2 = seq2 + \"#{line2}\"\n\n else\n\n seq = seq1 + str_n + seq2\n seq1 = \"\"\n seq2 = \"\"\n str = \"#{header}\\n#{seq}\"\n @out.write(str+\"\\n\")\n\n tmp1 = line1.split(\" \")\n tmp2 = line2.split(\" \")\n\n header = \"#{tmp1[0]}::#{tmp2[0]}\"\n\n end\n end\n @out.write(header+\"\\n\"+seq1+str_n+seq2+\"\\n\")\n end",
"def process_and_write_to file\n \n return unless @is_relevant\t\n\n # svnadmin: Malformed dumpstream: Revision 0 must not contain node records\n #\n # so discard revision without nodes, _except_ for revision 0\n if @nodes.empty? && @num > 0\n return\n end\n\n file.puts \"# process_and_write #{self}\" if $debug\n\n faked_nodes = []\n\n @nodes.each do |node|\n \n next if node.action == :delete\n\n # check node.path and if we already have all parent dirs\n path = node.path\n if node.kind == :file\n\tpath = File.dirname(path)\n elsif node.kind == :dir\n\tcase node.path\n\twhen \"trunk\", \"branches\", \"tags\"\n\t next\n\tend\n end\n last_relevant, last_path = find_and_write_last_relevant_for path, file\n exit 1 unless last_relevant\n # check if this was an 'extra' path and if we have to add directories\n \n # if the node creates the dir path, then the dirname is missing, not the full path\n # (for the 'file' case, we take the parent dir already above)\n #\n missing_path = (node.kind == :dir) ? File.dirname(path) : path\n if $extra_pathes[node.path] &&\n\t last_path != missing_path # last_relevant was a parent\n missings = []\n\twhile last_path != missing_path\n\t missings << File.basename(missing_path)\n\t missing_path = File.dirname(missing_path)\n\t break if missing_path == \".\"\n\tend\n\t# consistency check. Maybe last_past was no parent ?!\n\tif missing_path == \".\"\n\t STDERR.puts \"Couldn't find missing directories\"\n\t STDERR.puts \"Last directory was #{last_path}\"\n\t STDERR.puts \"Missings #{missings.inspect}\"\n\t exit 1\n\tend\n # add fake nodes to create missing directories\n\twhile !missings.empty?\n\t missing_path = File.join(missing_path, missings.pop)\n\t unless $created_extras[missing_path]\n\t file.puts \"# Create #{missing_path}\" if $debug\n\t faked_nodes << FakeNode.new(:dir, :add, missing_path)\n\t $created_extras[missing_path] = true\n\t end\n\tend\n end\n\n if $extra_pathes[node.path]\n\tunless $created_extras[node.path]\n#\t STDERR.puts \"Cutting history for #{node} at rev #{@num}\"\n\t # the extra file could be a 'change' node. This happens\n\t # if it was created in another directory and then the directory\n\t # was renamed. Instead of backtracking directory renames, we cut\n\t # history here and make it an 'add' node\n\t node.action = :add if node.action == :change\n\t $created_extras[node.path] = true\n\tend\n end\n\n # check for Node-copyfrom-path and evtl. rewrite / backtrack\n\n path = node['Node-copyfrom-path']\n if path\n\t# backtrack, find last relevant revision for this path\n\trevnum = node['Node-copyfrom-rev'].to_i\n\tlast_relevant, last_path = find_and_write_last_relevant_for path, file, revnum\n\texit 1 unless last_relevant\n\tnewnum = @@revision_number_mapping[last_relevant.num]\n\tfile.puts \"# Node-copyfrom-rev #{revnum} -> #{newnum}<#{last_relevant.num}>\" if $debug\n\tnode['Node-copyfrom-rev'] = newnum\n end\n end # nodes.each\n \n # write Revision item\n \n self.copy_to file\n # write nodes\n faked_nodes.each do |node|\n node.copy_to file\n end\n @nodes.each do |node|\n node.copy_to file\n path = node.path\n while path != \".\"\n\t@@last_relevant_for[path] ||= []\n\t@@last_relevant_for[path] << self\n\tpath = File.dirname(path)\n end\n end\n end",
"def save_to_file(file_name = @current_file_name)\n # Loop on all dirline widgets\n File.open(file_name, 'wb') do |file|\n file.write(FILE_HEADER)\n file.write(Zlib::Deflate.deflate(RubySerial::dump({\n :dest_dir_names => @main_widget.get_dest_dirlines.map { |dirline_widget| dirline_widget.get_dir_name },\n :src_dir_names => @main_widget.get_src_dirlines.map { |dirline_widget| dirline_widget.get_dir_name },\n :data => @data\n })))\n end\n notify(\"File #{file_name} saved correctly\")\n @current_file_name = file_name\n invalidate_current_loaded_file\n end",
"def to_file\n file = \"\"\n @fileContent.each do |line|\n file << line\n file << \"\\n\" unless line == @fileContent.last\n end\n file\n end",
"def to_file( f )\n buf = [ MAGIC, VERSION, @timestamp.to_i, @analyses.length() \n ].pack(PFORMAT)\n f.write(buf)\n\n @analyses.each do |a|\n a.to_file(f)\n end\n end",
"def writeAll(filename)\n out = File.new(filename, \"w\")\n @names.keys.sort.each {|num|\n out.printf(\"%d\\t%d\\t%s\\t%s\\n\", num, @parent[num], @names[num],\n @rank[num]) \n }\n out.close\n end",
"def write path\n File.open(path, 'w') do |io|\n io.print serialize\n end\n end",
"def parse(content, open_tags, prev_level, root_level)\n File.open(\"#{file.path}\", \"r\").each_line do |line|\n\n next if /^\\s*$/ === line\n\n line = line.chomp.split(/\\s+/, 3)\n \n level = line.shift.to_i\n \n if prev_level.nil?\n prev_level = root_level = level-1 # not assuming base level is 0\n end\n \n (level..prev_level).to_a.reverse.each do |i|\n content << \"\\t\" * (i - root_level) if content[-1] == ?\\n\n content << \"</#{open_tags.pop}>\\n\"\n end\n \n if line[0][0] == ?@\n xref_id, tag = line\n xref_id.gsub!(/^@(.*)@$/, '\\1')\n id_attr = ' id=\"' + xref_id + '\"'\n value = ''\n else\n tag, value = line\n id_attr = ''\n value ||= ''\n if /^@(\\w+)@$/ === value\n value = \"<xref>#{$1}</xref>\"\n else\n value.gsub!(/&/, '&')\n value.gsub!(/</, '<')\n value.gsub!(/>/, '>')\n end\n end\n \n if tag == 'CONC' || tag == 'CONT'\n content << (tag == 'CONT' ? \"\\n\" : \" \")\n content << value\n level -= 1\n else\n content << \"\\n\" if level > prev_level\n tag.downcase!\n content << \"\\t\" * (level - root_level) + \"<#{tag}#{id_attr}>#{value}\"\n open_tags.push tag\n end\n \n prev_level = level\n end\n content\n end",
"def write( language, nodes )\n FileUtils.makedirs( File.join(@root, language) )\n File.open( file_name(language), 'w+' ) do |file|\n entities = nodes.map { |node| parse_node(node.first, node.last) }\n file << entities.join(\"\\n\\n\")\n end\n end",
"def write_nav\n File.write(\"epub/OEBPS/#{nav_filename}\", nav_html)\n end",
"def save_to_file(obj)\n File.open(@filename, @mode) do |aFile|\n aFile.puts \"#{obj}\"\n end\n end",
"def save!\n Powirb.log.debug(\"[#{wid}] saving on #{@filename}\")\n File.open(@filename, 'w+') {|io| io.puts @doc}\n end",
"def write_to(doc);end",
"def create_HTML_file(loc_name, content, out_dir)\n File.open(\"#{out_dir}/#{loc_name}.html\", 'w') do |f|\n f.write(HEADER_TEXT)\n f.write(\"<h1>Lonely Planet: #{loc_name}</h1>\")\n f.write(NAV_TITLE)\n f.write($navigation_html)\n f.write(BLOCK_TITLE)\n f.write(\"<h1><li class='first'><a href='#'>#{loc_name}</a></li></h1>\")\n f.write(MAIN_BLOCK)\n f.write(content)\n f.write(CLOSE_HTML)\n end\nend",
"def write(data)\n begin\n File.open(@filename, \"w\") { |file| file.puts data.to_html }\n rescue \n puts \"Error: \" + $!.to_s\n end \n end",
"def showIndented(name = \"\", indent = \" \", currentIndent = \"\")\n #N Without this check, would attempt to output time for directories other than the root directory for which time has not been recorded\n if time != nil\n #N Without this, any recorded time value wouldn't be output\n puts \"#{currentIndent}[TIME: #{time.strftime(@@dateTimeFormat)}]\"\n end\n #N Without this check, an empty line would be output for root level (which has no name within the content tree)\n if name != \"\"\n #N Without this,non-root sub-directories would not be displayed\n puts \"#{currentIndent}#{name}\"\n end\n #N Without this check, directories not to be copied would be shown as to be copied\n if copyDestination != nil\n #N Without this, directories marked to be copied would not be displayed as such\n puts \"#{currentIndent} [COPY to #{copyDestination.relativePath}]\"\n end\n #N Without this check, directories not be to deleted would be shown as to be deleted\n if toBeDeleted\n #N Without this, directories marked to be deleted would not be displayed as such\n puts \"#{currentIndent} [DELETE]\"\n end\n #N Without this, output for sub-directories and files would not be indented further than their parent\n nextIndent = currentIndent + indent\n #N Without this, sub-directories of this directory won't be included in the output\n for dir in dirs\n #N Without this, this sub-directory won't be included in the output (suitable indented relative to the parent)\n dir.showIndented(\"#{dir.name}/\", indent = indent, currentIndent = nextIndent)\n end\n #N Without this, files contained immediately in this directory won't be included in the output\n for file in files\n #N Without this, this file and the hash of its contents won't be shown in the output\n puts \"#{nextIndent}#{file.name} - #{file.hash}\"\n #N Without this check, files not to be copied would be shown as to be copied\n if file.copyDestination != nil\n #N Without this, files marked to be copied would not be displayed as such\n puts \"#{nextIndent} [COPY to #{file.copyDestination.relativePath}]\"\n end\n #N Without this check, files not to be deleted would be shown as to be deleted\n if file.toBeDeleted\n #N Without this, files marked to be deleted would not be displayed as such\n puts \"#{nextIndent} [DELETE]\"\n end\n end\n end",
"def to_s(indent = 0)\n indent_increment = 2\n child_indent = indent + indent_increment\n res = super\n @files.each_value do |file|\n res += \"\\n\" + file.to_s(child_ident)\n end if @files\n @dirs.each_value do |dir|\n res += \"\\n\" + dir.to_s(child_ident)\n end if @dirs\n res\n end",
"def open_for_write\n end",
"def save_moves file, tree, player\n # If we have -1, -1 as coordinates, which we just skip\n if tree['x'] != -1 and tree['y'] != -1 then\n # color and coordinates\n file.write \";#{player}[#{sgf_board_position(tree)}]\"\n\n # the other player is to play next\n player = invert_color(player)\n\n # do we have any move comments?\n comment = tree['text']\n\n # Is this the answer (right or wrong) already?\n if tree['correct_answer'] == true then\n comment = \"Correct.\\n#{comment}\"\n elsif tree['wrong_answer'] == true then\n comment = \"Wrong.\\n#{comment}\"\n end\n\n file.write \"C[#{comment.escape_for_sgf}]\" unless comment.nil? or comment.empty?\n end\n\n # do we have any marks?\n unless tree['marks'].nil? or tree['marks'].size == 0\n tree['marks'].each { |mark|\n position = sgf_board_position mark\n type = mark['marks']\n\n file.write \"CR[#{position}]\" unless type['circle'].nil?\n file.write \"TR[#{position}]\" unless type['triangle'].nil?\n file.write \"MA[#{position}]\" unless type['cross'].nil?\n file.write \"SQ[#{position}]\" unless type['square'].nil?\n file.write \"LB[#{position}:#{type['letter']}]\" unless type['letter'].nil?\n }\n end\n\n # do we have follow-ups?\n unless tree['branches'].nil? or tree['branches'].size == 0\n if tree['branches'].size > 1 then\n # multiple possible moves\n tree['branches'].each { |branch|\n file.write '('\n save_moves file, branch, player\n file.write \")\\n\"\n }\n\n elsif tree['branches'].size == 1 then\n # a single follow-up move\n save_moves file, tree['branches'][0], player\n end\n end\n end",
"def write_tags\n open 'TAGS', 'w' do |io|\n io.write <<-INFO\n!_TAG_FILE_FORMAT\\t2\\t/extended format/\n!_TAG_FILE_SORTED\\t1\\t/sorted/\n!_TAG_PROGRAM_AUTHOR\\tEric Hodel\\t/[email protected]/\n!_TAG_PROGRAM_NAME\\trdoc-tags\\t//\n!_TAG_PROGRAM_URL\\thttps://github.com/rdoc/rdoc-tags\\t//\n!_TAG_PROGRAM_VERSION\\t#{VERSION}\\t//\n INFO\n\n @tags.sort.each do |name, definitions|\n definitions.uniq.each do |(file, address, *field)|\n io.write \"#{name}\\t#{file}\\t#{address};\\\"\\t#{field.join \"\\t\"}\\n\"\n end\n end\n end\n end"
] | [
"0.6924604",
"0.68879145",
"0.6607039",
"0.6411231",
"0.6252944",
"0.6021157",
"0.6019684",
"0.60032004",
"0.59965795",
"0.5967358",
"0.5846589",
"0.57522166",
"0.57512265",
"0.57368577",
"0.5684459",
"0.5684459",
"0.56177527",
"0.560796",
"0.56032205",
"0.55842906",
"0.55652416",
"0.5564678",
"0.55345505",
"0.55265766",
"0.55242896",
"0.5513237",
"0.55028003",
"0.5484459",
"0.548183",
"0.54793346",
"0.54677606",
"0.54547435",
"0.5438967",
"0.5438967",
"0.5438687",
"0.54375976",
"0.54316574",
"0.54241264",
"0.54241264",
"0.5423083",
"0.54230016",
"0.54195565",
"0.54195565",
"0.54195565",
"0.5410621",
"0.5409825",
"0.5395757",
"0.5393975",
"0.5393975",
"0.5363588",
"0.5363106",
"0.5353764",
"0.53449005",
"0.53437215",
"0.53430474",
"0.533867",
"0.53300613",
"0.53240883",
"0.52965355",
"0.52774894",
"0.5275605",
"0.5273111",
"0.5270145",
"0.52595043",
"0.52498496",
"0.523885",
"0.52294815",
"0.521488",
"0.52112675",
"0.51980925",
"0.5197024",
"0.5195584",
"0.5192204",
"0.5190875",
"0.5185163",
"0.5177219",
"0.5176222",
"0.5174364",
"0.5171102",
"0.51685226",
"0.5158396",
"0.5151456",
"0.51433855",
"0.51268476",
"0.5126591",
"0.5125677",
"0.51252604",
"0.5121121",
"0.5116136",
"0.51037717",
"0.510222",
"0.5098896",
"0.5098412",
"0.5096353",
"0.50960046",
"0.5089828",
"0.50844634",
"0.5083597",
"0.50797063",
"0.50780225"
] | 0.51267797 | 84 |
write this content tree to a file (in a format which readFromFile can read back in) N Without this, information for a content tree could not be output to a named file in a format that could be read in again (by readFromFile) | def writeToFile(fileName)
#N Without this, the user would not have feedback that the content tree is being written to the named file
puts "Writing content tree to file #{fileName} ..."
#N Without this, the named file cannot be written to
File.open(fileName, "w") do |outFile|
#N Without this, the lines of information for the content tree will not be written to the open file
writeLinesToFile(outFile)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def writeTree(file)\n file.write toString\n end",
"def writeTree(file)\n file.write @tree.toString\n end",
"def save args={}\n raise ArgumentError, \"No file name provided\" if args[:filename].nil?\n @savable_sgf = \"(\"\n @root.children.each { |child| write_node child }\n @savable_sgf << \")\"\n\n File.open(args[:filename], 'w') { |f| f << @savable_sgf }\n end",
"def write_tree outfile\n writer = Bio::PhyloXML::Writer.new(outfile)\n writer.write(@tree)\n end",
"def print_to_file\n #f = File.new(\"#{Dir.pwd}/tmp/geoname_tree.txt\", \"wb\")\n File.open(\"geoname_tree.txt\", 'w') do |f|\n nodes.keys.each do |id|\n ts = tree_numbers(id).join(\"|\")\n f.write(\"#{id}|#{ts}\")\n f.write(\"\\n\")\n puts \"#{id}|#{ts}\"\n end\n end\n end",
"def write_tree\n invoke(:write_tree)\n end",
"def write(node)\r\n dir = folder(node)\r\n src = source(node)\r\n txt = text(node)\r\n unless dir.empty? || Dir.exist?(dir)\r\n Dir.mkdir(dir)\r\n @on_create_dir.call(dir) if @on_create_dir\r\n end\r\n File.write(src, txt)\r\n @on_create_file.call(src) if @on_create_file\r\n node.items.reject{|n| n.items.empty?}.each{|n| write(n)}\r\n end",
"def create(filename,serialized_tree)\n File.open(File.join(@base_path, filename),\"w\") do |f|\n f.write(serialized_tree)\n end\n end",
"def to_file( f )\n buf = [@name, @ref.binary_role(), @ref.binary_type(), @ref.name,\n @type, TYPE_SIZES[@type], \n @data.length()].pack(PFORMAT)\n f.write(buf)\n\n fmt_str = \"%s%d\" % [TYPES[@type], data.length]\n buf = data.pack(fmt_str)\n f.write(buf)\n end",
"def write(file)\n @file_written = file\n file = Pathname.new(file)\n file.dirname.mkpath\n file.open \"w+\" do |output|\n output << self.build!\n end\n self\n end",
"def storeTree(inTree, filename)\n File.open(filename, \"w\") do |file|\n file.puts YAML::dump(inTree)\n end\n end",
"def to_file\n \"#{@name};#{@id}\"\n end",
"def write(node, output); end",
"def process_and_write_to file\n \n return unless @is_relevant\t\n\n # svnadmin: Malformed dumpstream: Revision 0 must not contain node records\n #\n # so discard revision without nodes, _except_ for revision 0\n if @nodes.empty? && @num > 0\n return\n end\n\n file.puts \"# process_and_write #{self}\" if $debug\n\n faked_nodes = []\n\n @nodes.each do |node|\n \n next if node.action == :delete\n\n # check node.path and if we already have all parent dirs\n path = node.path\n if node.kind == :file\n\tpath = File.dirname(path)\n elsif node.kind == :dir\n\tcase node.path\n\twhen \"trunk\", \"branches\", \"tags\"\n\t next\n\tend\n end\n last_relevant, last_path = find_and_write_last_relevant_for path, file\n exit 1 unless last_relevant\n # check if this was an 'extra' path and if we have to add directories\n \n # if the node creates the dir path, then the dirname is missing, not the full path\n # (for the 'file' case, we take the parent dir already above)\n #\n missing_path = (node.kind == :dir) ? File.dirname(path) : path\n if $extra_pathes[node.path] &&\n\t last_path != missing_path # last_relevant was a parent\n missings = []\n\twhile last_path != missing_path\n\t missings << File.basename(missing_path)\n\t missing_path = File.dirname(missing_path)\n\t break if missing_path == \".\"\n\tend\n\t# consistency check. Maybe last_past was no parent ?!\n\tif missing_path == \".\"\n\t STDERR.puts \"Couldn't find missing directories\"\n\t STDERR.puts \"Last directory was #{last_path}\"\n\t STDERR.puts \"Missings #{missings.inspect}\"\n\t exit 1\n\tend\n # add fake nodes to create missing directories\n\twhile !missings.empty?\n\t missing_path = File.join(missing_path, missings.pop)\n\t unless $created_extras[missing_path]\n\t file.puts \"# Create #{missing_path}\" if $debug\n\t faked_nodes << FakeNode.new(:dir, :add, missing_path)\n\t $created_extras[missing_path] = true\n\t end\n\tend\n end\n\n if $extra_pathes[node.path]\n\tunless $created_extras[node.path]\n#\t STDERR.puts \"Cutting history for #{node} at rev #{@num}\"\n\t # the extra file could be a 'change' node. This happens\n\t # if it was created in another directory and then the directory\n\t # was renamed. Instead of backtracking directory renames, we cut\n\t # history here and make it an 'add' node\n\t node.action = :add if node.action == :change\n\t $created_extras[node.path] = true\n\tend\n end\n\n # check for Node-copyfrom-path and evtl. rewrite / backtrack\n\n path = node['Node-copyfrom-path']\n if path\n\t# backtrack, find last relevant revision for this path\n\trevnum = node['Node-copyfrom-rev'].to_i\n\tlast_relevant, last_path = find_and_write_last_relevant_for path, file, revnum\n\texit 1 unless last_relevant\n\tnewnum = @@revision_number_mapping[last_relevant.num]\n\tfile.puts \"# Node-copyfrom-rev #{revnum} -> #{newnum}<#{last_relevant.num}>\" if $debug\n\tnode['Node-copyfrom-rev'] = newnum\n end\n end # nodes.each\n \n # write Revision item\n \n self.copy_to file\n # write nodes\n faked_nodes.each do |node|\n node.copy_to file\n end\n @nodes.each do |node|\n node.copy_to file\n path = node.path\n while path != \".\"\n\t@@last_relevant_for[path] ||= []\n\t@@last_relevant_for[path] << self\n\tpath = File.dirname(path)\n end\n end\n end",
"def 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 write\n make_parent_directory\n generate_file\n end",
"def write( language, nodes )\n FileUtils.makedirs( File.join(@root, language) )\n File.open( file_name(language), 'w+' ) do |file|\n entities = nodes.map { |node| parse_node(node.first, node.last) }\n file << entities.join(\"\\n\\n\")\n end\n end",
"def write\n filename = \"#{@directory}/label.html\"\n File.open(filename, 'w') do |fp|\n fp.puts(self.to_s)\n end\n puts \"Wrote #{filename}\"\n end",
"def to_file( f )\n size = 0\n @indexes.each { size += Index::FORMAT_SIZE }\n @idata.each do |i| \n size += IntData::FORMAT_SIZE\n size += i.data_size\n end\n\n buf = [@source, @name, @sym, @indexes.length(), @idata.length(), \n size].pack(PFORMAT)\n f.write(buf)\n @indexes.each { |i| i.to_file(f) }\n @idata.each { |i| i.to_file(f) }\n end",
"def write_file\n \n # if dirty?\n generate\n \n delete_file\n File.open(absolute_path.gsub(/\\.txt$/, \"\"), 'w+') do |f| \n f.write(generated_header)\n f.write(generated_content)\n end\n # not_dirty\n # end\n end",
"def write path\n File.open(path, 'w') do |io|\n io.print serialize\n end\n end",
"def write(f)\n f.puts \"Version: \" + VERSION\n f.puts \"Label: #{@label}\"\n f.puts \"Host: #{@host}\"\n f.puts \"Dir: #{@dir}\"\n f.puts \"Prune: \" + (@prune_leading_dir ? \"true\" : \"false\")\n f.puts\n super(f)\n end",
"def to_file\n replace_with_tempfile unless @tempfile_in\n flush\n self\n end",
"def recurse_write(located_entry)\n write(located_entry.path, located_entry.entry_tree, top_level: false)\n end",
"def write_content\n File.open(absolute_path,'w') do |file|\n file << content if content\n end\n # TODO git functionality\n end",
"def write\n File.open(@file, 'a') do |w| \n w.write(\"\\n\"+ @name + \" \" + @path)\n end\n end",
"def write_nodes(nodes)\n # open(File.new(cube_class.name + '.dat'), 'w') do |f|\n# \n# end\n end",
"def write_to(io, *options)\n options = options.first.is_a?(Hash) ? options.shift : {}\n encoding = options[:encoding] || options[0]\n if Nokogiri.jruby?\n save_options = options[:save_with] || options[1]\n indent_times = options[:indent] || 0\n else\n save_options = options[:save_with] || options[1] || SaveOptions::FORMAT\n indent_times = options[:indent] || 2\n end\n indent_text = options[:indent_text] || \" \"\n\n # Any string times 0 returns an empty string. Therefore, use the same\n # string instead of generating a new empty string for every node with\n # zero indentation.\n indentation = indent_times.zero? ? \"\" : (indent_text * indent_times)\n\n config = SaveOptions.new(save_options.to_i)\n yield config if block_given?\n\n native_write_to(io, encoding, indentation, config.options)\n end",
"def to_file( f )\n buf = [ MAGIC, VERSION, @timestamp.to_i, @analyses.length() \n ].pack(PFORMAT)\n f.write(buf)\n\n @analyses.each do |a|\n a.to_file(f)\n end\n end",
"def write_to_file(path)\n File.open(path, \"w\") do |f|\n f.print serialize\n end\n end",
"def save_to_file(file_name = @current_file_name)\n # Loop on all dirline widgets\n File.open(file_name, 'wb') do |file|\n file.write(FILE_HEADER)\n file.write(Zlib::Deflate.deflate(RubySerial::dump({\n :dest_dir_names => @main_widget.get_dest_dirlines.map { |dirline_widget| dirline_widget.get_dir_name },\n :src_dir_names => @main_widget.get_src_dirlines.map { |dirline_widget| dirline_widget.get_dir_name },\n :data => @data\n })))\n end\n notify(\"File #{file_name} saved correctly\")\n @current_file_name = file_name\n invalidate_current_loaded_file\n end",
"def write_file\n\n File.open(\"rebuild.html\", \"w\") do |file|\n @write_array.each do |tags_and_text|\n file.write tags_and_text\n end\n end\n\n end",
"def save_and_close( filename = clean_name )\n result.parent.export filename\n end",
"def write_file(file_name)\n File.open(file_name, 'w') { |f| f.write header_build }\n File.write(file_name, @content, mode: 'a')\nend",
"def writer; end",
"def write_file\n\n # file_edited is false when there was no match in the whole file and thus no contents have changed.\n if file_edited\n backup_pathname = original_pathname + \".old\"\n FileUtils.cp(original_pathname, backup_pathname, :preserve => true)\n File.open(original_pathname, \"w\") do |newfile|\n contents.each do |line|\n newfile.puts(line)\n end\n newfile.flush\n end\n end\n self.file_edited = false\n end",
"def write_contents(filename = \"output.txt\")\n\t\t\tbegin\n\t\t\t\tputs \"Writing contents to file: \" + filename\n\t\t\t\tfile = File.open(filename, 'w')\n\t\t\t\t\n\t\t\t\t#TODO Load data mappings from xml file into the section tree\n\t\t\t\tif !@section_tree.nil? then\n\t\t\t\t\tfile.puts @section_tree.flatten\n\t\t\t\tend\n\t\t\t\t#size = line_count\n\t\t\t\t\n\t\t\t\t#for i in 0..size-1\n\t\t\t\t\t#Retrieve the dirty key from the line\n\t\t\t\t\t#dirtyKey = get_line_matchdata(i).to_s\n\t\t\t\t\t#If the line contains a key\n\t\t\t\t\t#if !dirtyKey.nil? && @replacements.count > 0 then\n\t\t\t\t\t\t#puts \"Dirty key: \" + dirtyKey\n\t\t\t\t\t\t#if @dirty_mappings.has_key? dirtyKey then\n\t\t\t\t\t\t\t#Retrieve the clean key from the dirty_mappings hash\n\t\t\t\t\t\t\t#cleanKey = @dirty_mappings[dirtyKey]\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t#if is_valid_key(cleanKey) > 0 then\n\t\t\t\t\t\t\t\t#puts \"Clean Key: \" + cleanKey\n\t\t\t\t\t\t\t\t#Retrieve the substitution value from the replacements table\n\t\t\t\t\t\t\t\t#value = get cleanKey\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t#Substitute the new value back into the content array\n\t\t\t\t\t\t\t\t#@contents[i] = @contents[i].gsub(dirtyKey, value.to_s)\n\t\t\t\t\t\t\t#end\n\t\t\t\t\t\t#end\n\t\t\t\t\t#end\n\t\t\t\t\n\t\t\t\t\t#Write the line to the file\n\t\t\t\t\t#file.puts @contents[i]\n\t\t\t\tend\n\t\t\t\n\t\t\tensure\n\t\t\t\tputs \"Closing output file: \" + filename\n\t\t\t\tfile.close unless file.nil?\n\t\t\tend",
"def write_to_file(path, content)\n directory = File.dirname(path)\n FileUtils.mkdir_p(directory)\n File.write(path, content)\n after_rendering_run(\"rm -rf #{path}\")\n path\n end",
"def write_to_file\n file = File.open(@filename_erl,\"a\")\n file.puts @head, @erl, @sig_sub\n file.puts @sub if @@sub_struct_flag\n (file.puts @un_arr.uni_def, @un_arr.uni_func, @un_arr.uni_func_2) if @@union_flag\n (file.puts @un_arr.arr_def, @un_arr.arr_func) if @@dyn_array_flag\n file.close\n File.open(@filename_hrl, \"a\") {|f| f.puts @const, @enum, @hrl}\n end",
"def save_content(title, content)\n File.open(\"pages/#{title}.txt\", \"w\") do |file|\n file.print(content)\n end\nend",
"def characterize(save: true)\n persister.save(resource: @file_node) if save\n @file_node\n end",
"def save\n save_to_file(@output_file, @contents)\n end",
"def save_to_file\n File.open(@output, 'w+') do |file|\n file.puts HEADER if @additional_html\n file.puts @data_for_output.join(\"\\n\")\n file.puts FOOTER if @additional_html\n end\n end",
"def write()\n f = File.open(\"#{@directory}/#{@filename}\", \"w\")\n f.write(@raw)\n f.close()\n end",
"def write!\n # 1. skip if file already exists.\n if output_file_already_exists?\n RSpec::Scaffold.log(\"- #{@output_file} - already exists\", :puts)\n return\n end\n\n # 2. ensure parent directories exist\n FileUtils.makedirs(@output_file.parent)\n\n # 3. write to file\n File.open(@output_file, 'wb') do |f| # 'wb' originally\n f << @output_text\n end\n\n RSpec::Scaffold.log(\"+ #{@output_file}\")\n\n return @output_file.to_s\n end",
"def sprint_write_file(type, content, file = nil)\n file = sprint_temp_file(type) if file.nil?\n log(\"#{self.class} writing file #{file}\", :info)\n File.open(file,'w'){ |f| f.write(content) }\n return type, file\n end",
"def write\n case parser_name\n when \"d3mpq_stringlist\"\n write_stringlist\n when \"d3mpq_recipe\"\n write_recipe\n when \"d3mpq_coredata_gamebalance_setitembonuses\"\n @field = nil\n write_recipe\n when \"d3mpq_attributes\"\n write_single_file(\"analyze\")\n when \"d3mpq_coredata_actor\"\n write_single_file(\"analyze\")\n else\n write_game_balance\n end\n end",
"def force_to_file\n if @data && ! (@file && File.exist?(@file.to_s))\n fh = Tempfile.new([ \"conconv_force_to_file\", @suffix.to_s ])\n @force_to_file = @file = Pathname.new(fh.path)\n fh.write @data\n fh.close\n $stderr.puts \" force_to_file wrote #{@data.size} => #{fh.path.inspect}\" if @verbose\n end\n @file\n end",
"def write_obj_file output_path\n File.open(output_path, 'w') do |f|\n @vbuffer.each_triple do |a,b,c|\n f.puts \"v #{a} #{b} #{c}\"\n end\n @vnbuffer.each_triple do |a,b,c|\n f.puts \"vn #{a} #{b} #{c}\"\n end\n @fbuffer.each_triple do |a,b,c|\n f.puts \"f #{a+1}//#{a+1} #{b+1}//#{b+1} #{c+1}//#{c+1}\"\n end\n end\n self\n end",
"def to_file\n file = \"\"\n @fileContent.each do |line|\n file << line\n file << \"\\n\" unless line == @fileContent.last\n end\n file\n end",
"def write_content_to_file(file_name, content)\n File.open(file_name, 'w') { |file| file.write(content); file.flush }\nend",
"def write_file(log)\n log[:files_revised] += 1\n File.open(@name, \"w\") {|f| f.write(@content) }\n end",
"def save_to_file(obj)\n File.open(@filename, @mode) do |aFile|\n aFile.puts \"#{obj}\"\n end\n end",
"def write_to_file(f)\n return f.write(self.buffer)\n end",
"def writeAll(filename)\n out = File.new(filename, \"w\")\n @names.keys.sort.each {|num|\n out.printf(\"%d\\t%d\\t%s\\t%s\\n\", num, @parent[num], @names[num],\n @rank[num]) \n }\n out.close\n end",
"def store\n @files.each do |file, lines|\n text = \"\"\n dirty = false\n lines.each do |l|\n if l.is_a?(Section)\n dirty ||= l.dirty?\n text << l.format\n l.mark_clean\n else\n text << l\n end\n end\n if dirty\n Puppet::Util::FileType.filetype(:flat).new(file).write(text)\n return file\n end\n end\n end",
"def save_file \n Grit.debug = true\n contents = params[:contents]\n message = params[:commit_message]\n @node = Node.new(:name => params[:name], :git_repo_id => params[:git_repo_id], :git_repo_path => params[:git_repo_path])\n save_file_to_disk(contents, @node.abspath)\n stage_and_commit_file(@node.repo_base_path, @node.git_repo_path, message)\n flash[:notice] = \"Created New Version\"\n render :action => :file\n end",
"def write; end",
"def write; end",
"def write_to(git)\n self.mode ||= git.default_tree_mode\n self.sha ||= begin\n lines = []\n each_pair(false) do |key, entry|\n mode, sha = case entry\n when Tree then entry.write_to(git)\n when Array then entry\n else [entry.mode, entry.id]\n end\n \n # modes should not begin with zeros (although it is not fatal\n # if they do), otherwise fsck will print warnings like this:\n #\n # warning in tree 980127...: contains zero-padded file modes\n lines << zero_strip(\"#{mode} #{key}\\0#{[sha].pack(\"H*\")}\")\n end\n\n git.set(:tree, lines.join)\n end\n\n [mode, sha]\n end",
"def write_file filename,content\n mkdir_p(File.dirname(filename),:verbose=>false)\n File.open(filename, 'wb') {|f| f.write(content) }\n end",
"def write_tags(file, node, names)\n file.seek(0, IO::SEEK_END)\n # Make sure file currently ends in a newline.\n if file.tell == 0 || file.seek(-1, IO::SEEK_CUR) && file.read(1) != \"\\n\"\n file.write \"\\n\"\n end\n # Write each line.\n names.each do |name|\n if @tags_type_cache && @tags_type_cache[name]\n old = @tags_cache[name] || NULL_ID\n file.write(\"#{old.hexlify} #{name}\\n\")\n end\n file.write(\"#{node.hexlify} #{name}\\n\")\n end\n end",
"def write(file)\n self.files.each { |l| file.puts l }\n end",
"def writeLinesToFile(outFile, prefix = \"\")\n #N Without this check, it would attempt to write out a time value when none was available\n if time != nil\n #N Without this, a line for the time value would not be written to the file\n outFile.puts(\"T #{time.strftime(@@dateTimeFormat)}\\n\")\n end\n #N Without this, directory information would not be written to the file (for immediate sub-directories)\n for dir in dirs\n #N Without this, a line for this sub-directory would not be written to the file\n outFile.puts(\"D #{prefix}#{dir.name}\\n\")\n #N Without this, lines for the sub-directories and files contained with this directory would not be written to the file\n dir.writeLinesToFile(outFile, \"#{prefix}#{dir.name}/\")\n end\n #N Without this, information for files directly contained within this directory would not be written to the file\n for file in files\n #N Without this, the line for this file would not be written to the file\n outFile.puts(\"F #{file.hash} #{prefix}#{file.name}\\n\")\n end\n end",
"def CreateTopoFile\n topo52=\"topo52\"\n topo53=\"topo53\"\n \n if File.exists?(topo53)\n File.delete(topo53)\n end\n if File.exists?(topo52)\n File.delete(topo52)\n end \n \n omf52file=File.open(topo52,\"w\")\n omf53file=File.open(topo53,\"w\")\n \n omf52file.write(\"[\")\n \n @nodes.each do |node|\n \n omf52file.write(\"[#{node.x},#{node.y}]\")\n #omf53file.write(\"\\ttopo.addNode(\\\"#{NodeName(node.x,node.y)}\\\")\\n\")\n omf53file.write(@orbit.NodeName(node.x,node.y))\n \n if @nodes[@nodes.size-1]!=node\n\tomf52file.write(\",\")\n\tomf53file.write(\",\")\n end\n end \n \n omf52file.write(\"]\")\n #omf53file.write(\"\\nend\")\n omf52file.close\n omf53file.close\n \n @orbit.log(\"Created files describing topo: #{topo52}, #{topo53}\")\n \n end",
"def write_feature_file(feature_file, feature_content)\n begin\n file = File.open(feature_file, 'w')\n file.write(feature_content)\n rescue IOError => e\n # some error occur, dir not writable etc.\n pp e\n ensure\n file.close unless file == nil\n end\n end",
"def write_file filename, content\n path = @output_directory + filename\n File.open(path, 'w') {|f| f.write content }\n end",
"def to_file( filename )\n File.open(filename, 'w') do |f|\n f.puts self.header\n @body.each do |section|\n f.puts section\n end\n f.puts self.footer\n end\n end",
"def write\n open(@fname,\"wb\") do |file|\n Marshal.dump(@data,file)\n end\n end",
"def save_to_file\n File.open(\"results/#{seq_name}\"+\".txt\", 'w') { |file|\n \n n=1\n \n @actions.each do |a|\n file.puts a.description\n n +=1 \n end\n } \n \n end",
"def write_toc\n File.write('epub/OEBPS/toc.ncx', toc_ncx)\n end",
"def save_section(node, writer)\r\n\r\n node.child_nodes.each do |child|\r\n writer.indentation = child.indentation\r\n \r\n case child.type\r\n when TYPE_COMMENT\r\n writer.write_comment child.value\r\n when TYPE_EMPTY\r\n writer.write_empty\r\n when TYPE_SECTION_START\r\n writer.write_start_section child.name, child.value\r\n save_section child, writer\r\n # Force indentation to match the parent\r\n writer.indentation = child.indentation\r\n writer.write_end_section\r\n when TYPE_DIRECTIVE\r\n writer.write_directive child.name, child.value\r\n end\r\n end\r\n end",
"def write_file(file_name)\n path = \"#{TARGET_DIRECTORY}/#{file_name}#{FILE_EXTENSION}\"\n unless false# File.exists? path\n \n # clean up front\n found_content = false\n while !found_content && [email protected]? do\n val = @content.shift\n unless val.strip.empty?\n @content.unshift(val)\n found_content = true\n end\n end\n\n # clean up back\n found_content = false\n while !found_content && [email protected]? do\n val = @content.pop\n unless val.strip.empty?\n @content.push(val)\n found_content = true\n end\n end\n\n return if @content.empty?\n\n puts \"Creating #{file_name}\"\n File.open(path, \"w\") {|f| f.puts @content.join(\"\")}\n end\n @content = []\nend",
"def save_content(title, content)\n\tFile.open(\"pages/#{title}.txt\" , \"w\") do |file|\n\t file.print(content)\n end \t\t\nend",
"def export_nodes\n existing_hiera = Dir.glob(Path.named_path([:hiera, '*'], @provider_dir))\n existing_files = Dir.glob(Path.named_path([:node_files_dir, '*'], @provider_dir))\n updated_hiera = []\n updated_files = []\n self.each_node do |node|\n filepath = Path.named_path([:node_files_dir, node.name], @provider_dir)\n updated_files << filepath\n hierapath = Path.named_path([:hiera, node.name], @provider_dir)\n updated_hiera << hierapath\n Util::write_file!(hierapath, node.dump)\n end\n (existing_hiera - updated_hiera).each do |filepath|\n Util::remove_file!(filepath)\n end\n (existing_files - updated_files).each do |filepath|\n Util::remove_directory!(filepath)\n end\n end",
"def write(f)\n document.write(f, -1, false, true)\n end",
"def writeToXML(fileName)\n f = File.new(fileName, \"w\")\n f.puts \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n\"\n f.puts \"<SAFTestBundle \" + \\\n \" xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" \" + \\\n \" xsi:noNamespaceSchemaLocation=\\\"SAFTestBundle.xsd\\\" \" + \\\n \" schemaVersion=\\\"1\\\">\\n\"\n\n # Initial Cases\n f.puts \"<SAFTestCaseList type=\\\"initial\\\" mode=\\\"sequential\\\">\\n\"\n @cases['initial'].each do |c|\n c.saveToXML(f)\n end\n\n @specCases.keys().each do |specName|\n f.puts \"<!-- Initial Cases for spec %s -->\\n\" % [specName.upcase()]\n @specCases[specName]['initial'].each do |c|\n c.saveToXML(f)\n end\n end\n f.puts \"</SAFTestCaseList>\\n\"\n \n # Main Cases\n f.puts \"<SAFTestCaseList type=\\\"main\\\" mode=\\\"%s\\\">\\n\" % [@mainMode]\n @cases['main'].each do |c|\n c.saveToXML(f)\n end\n\n @specCases.keys().each do |specName|\n f.puts \"<!-- Main Cases for spec %s -->\\n\" % [specName.upcase()]\n @specCases[specName]['main'].each do |c|\n c.saveToXML(f)\n end\n end\n f.puts \"</SAFTestCaseList>\\n\"\n\n # Final Cases\n f.puts \"<SAFTestCaseList type=\\\"final\\\" mode=\\\"sequential\\\">\\n\"\n @specCases.keys().each do |specName|\n f.puts \"<!-- Final Cases for spec %s -->\\n\" % [specName.upcase()]\n @specCases[specName]['final'].each do |c|\n c.saveToXML(f)\n end\n end\n\n @cases['final'].each do |c|\n c.saveToXML(f)\n end\n\n f.puts \"</SAFTestCaseList>\\n\"\n \n f.puts \"</SAFTestBundle>\\n\"\n end",
"def write_folder(folder)\n @openfile.write \"<Folder>\\n<name>#{folder[:name]}</name>\\n\"\n\n unless folder[:folders].nil?\n folder[:folders].each do |inner_folder|\n write_folder(inner_folder)\n end\n end#else\n \n unless folder[:features].empty?\n folder[:features].each do |feature|\n write_placemark(feature)\n end\n # end\n end\n @openfile.write \"</Folder>\\n\\n\"\n end",
"def write_ode_solution(filename, desc=\"\")\n now=Time.now\n # Prepare headers\n comment = \"# #{@model_name} forward integration analysis - #{now} - MX Version: #{MECHATRONIX[:description]}\"\n File.open(filename, 'w') do |f|\n f.puts comment(desc)\n f.puts @ode_solution[:headers].join(\"\\t\")\n @ode_solution[:data][0].length.times do |r|\n f.puts @ode_solution[:data].inject([]) {|a,c| a << c[r]}.join(\"\\t\")\n end\n end\n\n end",
"def write(fname=nil, reg=true)\n pp = reg ? @rm : nil\n @mack.write fname, pp\n end",
"def write_to(doc);end",
"def modify_file(path,document) \n File.open(path,'w') do|file|\n file.write(document) if document\n end\nend",
"def to_file( f )\n buf = [@name, @sym, @value].pack(PFORMAT)\n f.write(buf)\n end",
"def to_file(filename)\n File.open(filename, 'w') do |f|\n f.puts self.header\n @body.each { |section| f.puts section }\n f.puts self.footer\n end\n end",
"def write_content(file_out)\n file_out.puts(@array)\n end",
"def export\n @tree\n end",
"def output(filename)\r\n outs = File.new(filename , \"w\")\r\n outs.puts self.to_s\r\n outs.close\r\n end",
"def to_fsl_txt(output_file = 'out.txt')\n puts \"Writing \" + output_file\n open(output_file, 'w') do |file|\n @data.transpose.each do |line|\n file.puts line.join(' ')\n end\n end\n end",
"def save\n pathname.open('w') { |file| file.write(data) }\n end",
"def save!\n begin\n case filename\n when STDOUT_FLAG\n $stdout.write(contents)\n else\n ::File.open(@filename,\"w\") do |f|\n f.write(contents)\n end\n end\n @dirty = false\n rescue => e\n raise FileAccessError, \"Error saving file #{@filename} : #{e.message}\"\n end\n end",
"def write_file(name, data, commit = {})\n write(merge_path_elements(nil, name, nil), data, commit)\n end",
"def update_file\n output = (@blocks[:before] + @blocks[:attributes] + @blocks[:after]).join(\"\\n\").strip + \"\\n\"\n File.open(@filename,'w') { |f| f.write(output) } if output != @file\n end",
"def write(output = T.unsafe(nil), indent = T.unsafe(nil), transitive = T.unsafe(nil), ie_hack = T.unsafe(nil)); end",
"def write(output = T.unsafe(nil), indent = T.unsafe(nil), transitive = T.unsafe(nil), ie_hack = T.unsafe(nil)); end",
"def write_to_file(filename, method)\n\t\t\tFile.open(filename, method) do |file|\n\t\t\t\tfile.write(@doc)\n\t\t\tend\n\t\tend",
"def save(filename)\n SGF::Writer.new.save(@root, filename)\n end",
"def write\n raise \"Nodes must implement #write\"\n end",
"def write!(fname, mode = 'w', what = :prg)\n File.open(fname, mode) do |fd|\n case what\n when :prg\n fd.write(to_binary)\n when :src\n fd.write(to_source.join(\"\\n\"))\n when :dump\n fd.write(dump.join(\"\\n\"))\n else\n raise BlockError, 'Unknown generation mode'\n end\n end\n end",
"def write_file( fname )\n File.open(fname, \"w\") do |f|\n f << TDP.application.result\n end\n TDP.application.result = String.new\n# puts \"...written to #{fname}\"\n end",
"def write!(folder, file_number)\n path = \"#{folder}/sitemap-#{file_number}.xml\"\n File.open(path, 'w') { |f| f.write(self.to_xml) }\n end"
] | [
"0.708938",
"0.6944336",
"0.64942193",
"0.63798296",
"0.6378713",
"0.6258802",
"0.60908926",
"0.6045727",
"0.5970564",
"0.5955621",
"0.59488744",
"0.59364456",
"0.58001804",
"0.57799035",
"0.57076114",
"0.5681749",
"0.565616",
"0.56336623",
"0.56313986",
"0.5617701",
"0.5603799",
"0.558731",
"0.55836767",
"0.5580653",
"0.5565929",
"0.5561421",
"0.5543978",
"0.5527982",
"0.55097353",
"0.5501858",
"0.5498027",
"0.5471538",
"0.5469204",
"0.5451489",
"0.5444322",
"0.5431733",
"0.54315",
"0.543026",
"0.542777",
"0.54150665",
"0.5414177",
"0.5413817",
"0.5397443",
"0.53814673",
"0.53769356",
"0.5375857",
"0.5374553",
"0.5360194",
"0.53586835",
"0.5352158",
"0.5339",
"0.53364104",
"0.5329021",
"0.53234875",
"0.5317402",
"0.5312983",
"0.5305831",
"0.5297192",
"0.5297192",
"0.52836317",
"0.5274866",
"0.5270405",
"0.5266927",
"0.52602756",
"0.52489424",
"0.5246607",
"0.5245102",
"0.52435786",
"0.5239915",
"0.5212077",
"0.5211364",
"0.5195977",
"0.5178426",
"0.5176298",
"0.5173931",
"0.5173382",
"0.5169293",
"0.5166837",
"0.51662076",
"0.51646763",
"0.51641226",
"0.51637363",
"0.5159423",
"0.5150104",
"0.5148161",
"0.51449543",
"0.51381564",
"0.5131973",
"0.5129888",
"0.5115916",
"0.5115503",
"0.51142144",
"0.5112242",
"0.5112242",
"0.51113987",
"0.5110116",
"0.5109791",
"0.5107452",
"0.51062286",
"0.51048523"
] | 0.7386327 | 0 |
Mark operations for this (source) content tree and the destination content tree in order to synch the destination content tree with this one | def markSyncOperationsForDestination(destination)
markCopyOperations(destination)
destination.markDeleteOptions(self)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def markSyncOperations\n #N Without this, the sync operations won't be marked\n @sourceContent.markSyncOperationsForDestination(@destinationContent)\n #N Without these puts statements, the user won't receive feedback about what sync operations (i.e. copies and deletes) are marked for execution\n puts \" ================================================ \"\n puts \"After marking for sync --\"\n puts \"\"\n puts \"Local:\"\n #N Without this, the user won't see what local files and directories are marked for copying (i.e. upload)\n @sourceContent.showIndented()\n puts \"\"\n puts \"Remote:\"\n #N Without this, the user won't see what remote files and directories are marked for deleting\n @destinationContent.showIndented()\n end",
"def doSync(options = {})\n #N Without this, the content files will be cleared regardless of whether :full options is specified\n if options[:full]\n #N Without this, the content files won't be cleared when the :full options is specified\n clearCachedContentFiles()\n end\n #N Without this, the required content information won't be retrieved (be it from cached content files or from the actual locations)\n getContentTrees()\n #N Without this, the required copy and delete operations won't be marked for execution\n markSyncOperations()\n #N Without this, we won't know if only a dry run is intended\n dryRun = options[:dryRun]\n #N Without this check, the destination cached content file will be cleared, even for a dry run\n if not dryRun\n #N Without this check, the destination cached content file will remain there, even though it is stale once an actual (non-dry-run) sync operation is started.\n @destinationLocation.clearCachedContentFile()\n end\n #N Without this, the marked copy operations will not be executed (or in the case of dry-run, they won't be echoed to the user)\n doAllCopyOperations(dryRun)\n #N Without this, the marked delete operations will not be executed (or in the case of dry-run, they won't be echoed to the user)\n doAllDeleteOperations(dryRun)\n #N Without this check, the destination cached content file will be updated from the source content file, even if it was only a dry-run (so the remote location hasn't actually changed)\n if (not dryRun and @destinationLocation.cachedContentFile and @sourceLocation.cachedContentFile and\n File.exists?(@sourceLocation.cachedContentFile))\n #N Without this, the remote cached content file won't be updated from local cached content file (which is a reasonable thing to do assuming the sync operation completed successfully)\n FileUtils::Verbose.cp(@sourceLocation.cachedContentFile, @destinationLocation.cachedContentFile)\n end\n #N Without this, any cached SSH connections will remain unclosed (until the calling application has terminated, which may or may not happen soon after completing the sync).\n closeConnections()\n end",
"def perform_additional_merge_operations!(other)\n end",
"def getContentTrees\n #N Without this, we wouldn't get the content tree for the local source location\n @sourceContent = @sourceLocation.getContentTree()\n #N Without this, we wouldn't get the content tree for the remote destination location\n @destinationContent = @destinationLocation.getContentTree()\n end",
"def markCopyOperations(destinationDir)\n #N Without this we can't loop over the immediate sub-directories to determine how each one needs to be marked for copying\n for dir in dirs\n #N Without this we won't have the corresponding sub-directory in the other directory with the same name as this sub-directory (if it exists)\n destinationSubDir = destinationDir.getDir(dir.name)\n #N Without this check, we won't be able to correctly process a sub-directory based on whether or not one with the same name exists in the other directory\n if destinationSubDir != nil\n #N Without this, files and directories missing or changed from the other sub-directory (which does exist) won't get copied\n dir.markCopyOperations(destinationSubDir)\n else\n #N Without this, the corresponding missing sub-directory in the other directory won't get updated from this sub-directory\n dir.markToCopy(destinationDir)\n end\n end\n #N Without this we can't loop over the files to determine how each one needs to be marked for copying\n for file in files\n #N Without this we won't have the corresponding file in the other directory with the same name as this file (if it exists)\n destinationFile = destinationDir.getFile(file.name)\n #N Without this check, this file will get copied, even if it doesn't need to be (it only needs to be if it is missing, or the hash is different)\n if destinationFile == nil or destinationFile.hash != file.hash\n #N Without this, a file that is missing or changed won't get copied (even though it needs to be)\n file.markToCopy(destinationDir)\n end\n end\n end",
"def transfer_st_ops_to_foreign_file!(foreign_content_at_file, st_ops_for_file)\n from_gc = st_ops_for_file.from_git_commit\n to_gc = st_ops_for_file.to_git_commit\n\n # Get from_subtitles as of from_gc\n from_subtitles = cached_primary_subtitle_data(\n foreign_content_at_file,\n from_gc,\n :at_child_or_ref\n )\n # Get to_subtitles as of the next git commit after to_gc. We have\n # to do this since STM CSV files are updated during st sync,\n # however the changes aren't committed until the next commit\n # after the sync_commit.\n to_subtitles = cached_primary_subtitle_data(\n foreign_content_at_file,\n to_gc,\n :at_child_or_current\n )\n\n # Get new content AT file contents\n fcatf_contents = st_ops_for_file.apply_to_foreign_content_at_file(\n foreign_content_at_file,\n from_subtitles,\n to_subtitles\n )\n\n # Update content AT file with new contents\n foreign_content_at_file.update_contents!(fcatf_contents)\n\n # Update file level st_sync data\n update_foreign_file_level_data(\n foreign_content_at_file,\n st_ops_for_file.to_git_commit,\n st_ops_for_file.subtitles_that_require_review,\n )\n true\n end",
"def adopt(master)\n\n volatiles.merge!(master.volatiles)\n\n source_end.volatiles.merge!(master.source_end.volatiles)\n target_end.volatiles.merge!(master.target_end.volatiles)\n\n self.qualified_id = object_id\n\n self.name = master.name\n\n # edge override\n\n self.origin = master\n\n self.source_role_name = master.source_end.role_name\n self.target_role_name = master.target_end.role_name\n\n self.source_browse = master.source_browse\n self.target_browse = master.target_browse\n\n self.source_multiplicity = master.source_multiplicity\n self.target_multiplicity = master.target_multiplicity\n\n self.polymorphic_source_group_name = master.polymorphic_source_group_name\n self.polymorphic_target_group_name = master.polymorphic_target_group_name\n\n self.source_navigable = master.source_navigable\n self.target_navigable = master.target_navigable\n\n self.source_inhibitive = master.source_inhibitive\n self.target_inhibitive = master.target_inhibitive\n\n self.source_transitive = master.source_transitive\n self.target_transitive = master.target_transitive\n\n self.source_functional = master.source_functional\n self.target_functional = master.target_functional\n\n self.source_multiplicity = master.source_multiplicity\n self.target_multiplicity = master.target_multiplicity\n\n self.source_links_associated = master.source_links_associated\n self.target_links_associated = master.target_links_associated\n\n self.source_builds_associated = master.source_builds_associated\n self.target_builds_associated = master.target_builds_associated\n\n self.source_index = master.source_index\n self.target_index = master.target_index\n\n self.source_internal = master.source_internal\n self.target_internal = master.target_internal\n\n self.source_secure = master.source_secure\n self.target_secure = master.target_secure\n\n self.source_nesting = master.source_nesting\n self.target_nesting = master.target_nesting\n\n self.source_non_nesting = master.source_non_nesting\n self.target_non_nesting = master.target_non_nesting\n\n self.source_final = master.source_final\n self.target_final = master.target_final\n\n self.source_owner_property = master.source_owner_property\n self.target_owner_property = master.target_owner_property\n\n self.source_unique = master.source_unique\n self.target_unique = master.target_unique\n\n self.source_ordered = master.source_ordered\n self.target_ordered = master.target_ordered\n\n self.edge_connectors = master.edge_connectors\n\n self.source_pierced = master.source_pierced\n self.target_pierced = master.target_pierced\n\n self.source_participant = master.source_participant\n self.target_participant = master.target_participant\n\n # *-association override\n\n self.source_required = master.source_required\n self.target_required = master.target_required\n\n end",
"def transfer(node, ins) ; ins ; end",
"def commit_transaction\n # The relation graph handling is a bit tricky. We resolve the graphs\n # exclusively using self (NOT other) because if 'other' was a new\n # task, it has been already moved to the new plan (and its relation\n # graph resolution is using the new plan's new graphs already)\n\n super\n\n if @executable != __getobj__.instance_variable_get(:@executable)\n __getobj__.executable = @executable\n end\n\n finalization_handlers.each do |handler|\n __getobj__.when_finalized(handler.as_options, &handler.block)\n end\n end",
"def transfer_applicable_st_ops_to_foreign_file!(foreign_content_at_file, applicable_st_ops_for_file)\n if applicable_st_ops_for_file.any?\n # An st_ops_for_file exists. That means the file is being synced.\n # NOTE: Not sure why we're passing applicable_st_ops_for_file\n # as an array as there should really be only one.\n\n # Iterate over st_ops and incrementally update both content and data\n found_st_ops = false\n applicable_st_ops_for_file.each do |st_ops_for_file|\n # Detect if there are st_ops for file, or if it's time slice\n # changes only.\n found_st_ops ||= st_ops_for_file.operations.any?\n transfer_st_ops_to_foreign_file!(\n foreign_content_at_file,\n st_ops_for_file\n )\n # We have to reload the file contents as they were changed on\n # disk by #transfer_st_ops_to_foreign_file!\n foreign_content_at_file.reload_contents!\n end\n # We need to manually write the @to_git_commit to st_sync_commit.\n # We can't rely on transfer_st_ops_to_foreign_file! alone since\n # it will only write sync commits that actually contained st_ops\n # for the current file. However we want to record on the file\n # that it has been synced to the current primary st_sync_commit.\n update_foreign_file_level_data(\n foreign_content_at_file,\n @to_git_commit,\n {} # Don't touch sts that require review\n )\n if found_st_ops\n # Actual st ops\n print \" - Synced\".color(:green)\n else\n # Time slice changes only\n print \" - Synced (Time slice changes only)\".color(:green)\n end\n else\n # No applicable st ops, just update file level st_sync data\n update_foreign_file_level_data(\n foreign_content_at_file,\n @to_git_commit,\n {} # Don't touch sts that require review\n )\n print \" - No applicable st_ops\"\n end\n true\n end",
"def doAllCopyOperations(dryRun)\n #N Without this, the copy operations won't be executed\n doCopyOperations(@sourceContent, @destinationContent, dryRun)\n end",
"def pre_sync\n #move\n end",
"def perform_merge\n src_notes = @src.all_notes\n dest_notes = @dest.all_notes\n result = false\n\n # Mergeable if there are no fields which are non-blank in\n # both descriptions.\n if @src.class.all_note_fields.none? \\\n { |f| src_notes[f].present? && dest_notes[f].present? }\n result = true\n\n # Copy over all non-blank descriptive fields.\n src_notes.each do |f, val|\n @dest.send(\"#{f}=\", val) if val.present?\n end\n\n # Save changes to destination.\n @dest.save\n\n # Copy over authors and editors.\n @src.authors.each { |user| @dest.add_author(user) }\n @src.editors.each { |user| @dest.add_editor(user) }\n\n # Delete old description if requested.\n delete_src_description_and_update_parent if @delete_after\n end\n\n result\n end",
"def update_content_paths\n\n # Checking if the parent id has changed for the current content have to change the content paths table only if parent id is changed\n new_parent_id = ContentData.get_parent_id(self.id)\n\n # Getting the old parent data from the content path table\n old_parent_id = 0\n old_parent = ContentPath.where(:descendant => self.id, :depth => 1)\n # If there are any parents found with the getting the old parent id\n if old_parent.length > 0\n old_parent_id = old_parent.first.ancestor\n end\n\n # If the parent id is changed then update the content path structure\n if new_parent_id != old_parent_id\n\n # Refer to the article \"http://www.mysqlperformanceblog.com/2011/02/14/moving-subtrees-in-closure-table/\" for the logic\n # Detach the node from the old parent \n delete_query = \"DELETE a FROM content_paths AS a JOIN content_paths AS d ON a.descendant = d.descendant LEFT JOIN content_paths AS x ON x.ancestor = d.ancestor AND x.descendant = a.ancestor WHERE d.ancestor = '\"+self.id.to_s+\"' AND x.ancestor IS NULL\"\n ActiveRecord::Base.connection.execute(delete_query)\n\n # Attach the node to the new parent\n insert_query = \"INSERT INTO content_paths (ancestor, descendant, depth) SELECT supertree.ancestor, subtree.descendant, supertree.depth+subtree.depth+1 FROM content_paths AS supertree JOIN content_paths AS subtree WHERE subtree.ancestor = '\"+self.id.to_s+\"' AND supertree.descendant = '\"+new_parent_id.to_s+\"'\"\n ActiveRecord::Base.connection.execute(insert_query)\n\n ## The code for changing the childrens data of the edited node with the new parent data\n ## Getting the data of the new parent\n new_parent_data = Content.find(new_parent_id)\n\n ## Board is at the top level no need to change the children data\n if self.type == 'Board'\n\n ## Content year parent is changed update all the children with the current board id\n elsif self.type == 'ContentYear'\n if self.children.map(&:descendant).length > 1\n Content.where(:id => self.children.map(&:descendant)).update_all(:board_id => self.board_id)\n end\n\n ## Subject parent is changed update all the children with the curent board id and content year id\n elsif self.type == 'Subject'\n if self.children.map(&:descendant).length > 1\n Content.where(:id => self.children.map(&:descendant)).update_all(:board_id => self.board_id, :content_year_id => self.content_year_id)\n end\n\n ## Chapter parent is changed update all the children with the current board id , content year id and subject id\n elsif self.type == 'Chapter'\n if self.children.map(&:descendant).length > 1\n Content.where(:id => self.children.map(&:descendant)).update_all(:board_id => self.board_id, :content_year_id => self.content_year_id, :subject_id => self.subject_id)\n end\n\n ## Topic parent is changed update all the children with the current board id, content year id, subject id and chapter id\n elsif self.type == 'Topic'\n if self.children.map(&:descendant).length > 1\n Content.where(:id => self.children.map(&:descendant)).update_all(:board_id => self.board_id, :content_year_id => self.content_year_id, :subject_id => self.subject_id, :chapter_id => self.chapter_id)\n end\n\n ## Subtopic parent is changed update all the children with the current board id, content year id, subject id, chapter id and topic id\n elsif self.type == 'SubTopic'\n if self.children.map(&:descendant).length > 1\n Content.where(:id => self.children.map(&:descendant)).update_all(:board_id => self.board_id, :content_year_id => self.content_year_id, :subject_id => self.subject_id, :chapter_id => self.chapter_id, :topic_id => self.topic_id)\n end\n end\n\n ## End of code for changing the childrens data\n\n end\n end",
"def hand_off_to!(other)\n verify_hand_off_to(other)\n other.children.replace children\n other.parent = parent\n @children = EmptyClass\n @parent = nil\n end",
"def doCopyOperations(sourceContent, destinationContent, dryRun)\n #N Without this loop, we won't copy the directories that are marked for copying\n for dir in sourceContent.dirs\n #N Without this check, we would attempt to copy those directories _not_ marked for copying (but which might still have sub-directories marked for copying)\n if dir.copyDestination != nil\n #N Without this, we won't know what is the full path of the local source directory to be copied\n sourcePath = sourceLocation.getFullPath(dir.relativePath)\n #N Without this, we won't know the full path of the remote destination directory that this source directory is to be copied into\n destinationPath = destinationLocation.getFullPath(dir.copyDestination.relativePath)\n #N Without this, the source directory won't actually get copied\n destinationLocation.contentHost.copyLocalToRemoteDirectory(sourcePath, destinationPath, dryRun)\n else\n #N Without this, we wouldn't copy sub-directories marked for copying of this sub-directory (which is not marked for copying in full)\n doCopyOperations(dir, destinationContent.getDir(dir.name), dryRun)\n end\n end\n #N Without this loop, we won't copy the files that are marked for copying\n for file in sourceContent.files\n #N Without this check, we would attempt to copy those files _not_ marked for copying\n if file.copyDestination != nil\n #N Without this, we won't know what is the full path of the local file to be copied\n sourcePath = sourceLocation.getFullPath(file.relativePath)\n #N Without this, we won't know the full path of the remote destination directory that this source directory is to be copied into\n destinationPath = destinationLocation.getFullPath(file.copyDestination.relativePath)\n #N Without this, the file won't actually get copied\n destinationLocation.contentHost.copyLocalFileToRemoteDirectory(sourcePath, destinationPath, dryRun)\n end\n end\n end",
"def copy_actions\r\n end",
"def updateCoords\n\t\tsc, dc = srcItem.getCenter, destItem.getCenter\n\t\tself.coords( sc[0], sc[1], dc[0], dc[1])\n # handle @src and @dest\n @src.update\n @dest.update\n\n\t\tupdateTextLocation\n\tend",
"def __copy_on_write__(*)\n index = @parent_proxy.instance_variable_get(:@set).index(__getobj__) if @parent_proxy\n super.tap do\n CowProxy.debug { \"replace #{index} with proxy obj in parent #{@parent_proxy.name}\" } if index\n @parent_proxy.instance_variable_get(:@set)[index] = self if index\n new_set = __getobj__.instance_variable_get(:@set).dup\n __getobj__.instance_variable_set(:@set, new_set)\n end\n end",
"def sync!\n\n destfiles = begin \n FsShellProxy.new.ls(@dest, true) \n rescue NoSuchFile \n {}\n end\n results = HSync::compare(LocalFs.new.ls(@source, true), destfiles)\n push_files(results.files_missing_in_b)\n # push_files(results.files_newer_in_a) # todo\n end",
"def merge(other)\n result = super\n\n result.sources = other.sources + self.sources\n result\n end",
"def propagate_acl()\n\n #Propagate to subfolders\n self.children.each do |subfolder|\n if subfolder.acl.inherits\n acl = self.acl.deep_clone()\n acl.inherits = true\n acl.save\n\n subfolder.acl = acl\n subfolder.save\n\n subfolder.propagate_acl()\n end\n end\n\n #Propagate to documents\n self.references.each do |reference|\n if reference.acl.inherits\n acl = self.acl.deep_clone()\n acl.inherits = true\n acl.save\n reference.acl = acl\n reference.save\n end\n end\n\n\n end",
"def graft!(other)\n verify_graft(other)\n other.parent = parent\n parent.children.add other\n parent.children.delete self\n end",
"def apply\n\t\tunless @already_added\n\t\t\[email protected] @clone\n\t\t\t@already_added = true\n\t\tend\n\t\t\n\t\t@move_action.apply\n\tend",
"def _build_shares_and_operations\n if respond_to?(:build_shares, true)\n shares.clear\n build_shares\n end\n operations.reload\n @operation_ids_untouched = operation_ids\n build_operations if amount\n #Rails.logger.debug \"@operation_ids_untouched: \" + @operation_ids_untouched.inspect\n operations.find(@operation_ids_untouched).each(&:mark_for_destruction) unless @operation_ids_untouched.empty?\n end",
"def commit_transaction\n\t real_object = __getobj__\n\t partition_new_old_relations(:parent_objects) do |trsc_objects, rel, new, del, existing|\n\t\tfor other in new\n\t\t other.add_child_object(real_object, rel, trsc_objects[other][self, rel])\n\t\tend\n\t\tfor other in del\n\t\t other.remove_child_object(real_object, rel)\n\t\tend\n for other in existing\n other[real_object, rel] = trsc_objects[other][self, rel]\n end\n\t end\n\n\t partition_new_old_relations(:child_objects) do |trsc_objects, rel, new, del, existing|\n\t\tfor other in new\n\t\t real_object.add_child_object(other, rel, self[trsc_objects[other], rel])\n\t\tend\n\t\tfor other in del\n\t\t real_object.remove_child_object(other, rel)\n\t\tend\n for other in existing\n real_object[other, rel] = self[trsc_objects[other], rel]\n end\n\t end\n\n super\n\n if @executable != __getobj__.instance_variable_get(:@executable)\n __getobj__.executable = @executable\n end\n\n finalization_handlers.each do |handler|\n __getobj__.when_finalized(handler.as_options, &handler.block)\n end\n end",
"def sync\n @cache.flush(true)\n @nodes.sync\n end",
"def rearrange\n yield\n other = Tag.where(id: self.other_id).first\n operation = self.operation\n self.operation = self.other_id = nil\n\n begin\n case operation\n when 'nest_under'\n self.update_attribute :parent_id, other.id\n self.update_attribute :siblings_position, 0\n raise 'Cyclic nesting!' if other.parent_id == id\n when 'move_above'\n self.update_attribute :parent_id, other.parent_id\n self.update_attribute :siblings_position, other.calculated_siblings_position - 1\n when 'move_below'\n self.update_attribute :parent_id, other.parent_id\n self.update_attribute :siblings_position, other.calculated_siblings_position + 1\n end\n rescue\n self.errors.add :other_id, INVALID_TAG_OPERATION\n raise ActiveRecord::Rollback\n end\n end",
"def adopt(other_tile)\n other_tile.operations.each do |op|\n @operations << op.clone\n end\n end",
"def absorb other\n other.toucher_pointers.each { |ref| ref.user.touch self, ref.in_collection }\n super if defined? super\n end",
"def switch_areas\n o = @cursor.area\n @cursor.area = @other_area\n @other_area = o\n end",
"def absorb other\n self.about = other.about if self.about.blank?\n other.touched_pointers.each { |ref| touch ref.entity, ref.in_collection }\n other.followees.each { |followee| self.add_followee followee }\n other.followers.each { |follower| follower.add_followee self }\n other.votings.each { |voting| vote(voting.entity, voting.up) } # Transfer all the other's votes\n super\n end",
"def perform_sync(source, destination, options)\n new_files, new_files_destination = get_new_files_to_sync(source, destination, options)\n sync_new_files(source, new_files, new_files_destination, options)\n cleanup_files_we_dont_want_to_keep(source, new_files, new_files_destination) unless options[:keep].nil?\n end",
"def sync\n #debug 'content sync'\n # We're safe not testing for the 'source' if there's no 'should'\n # because we wouldn't have gotten this far if there weren't at least\n # one valid value somewhere.\n @resource.write(:content)\n end",
"def execute_XCHG(left, right)\n\t\tleft.value, right.value = right.value, left.value\n\tend",
"def perform_merge(src, dest, delete_after)\n src_notes = src.all_notes\n dest_notes = dest.all_notes\n result = false\n\n # Mergeable if there are no fields which are non-blank in both descriptions.\n if src.class.all_note_fields.none? \\\n {|f| !src_notes[f].blank? and !dest_notes[f].blank?}\n result = true\n\n # Copy over all non-blank descriptive fields.\n xargs = {}\n for f, val in src_notes\n if !val.blank?\n dest.send(\"#{f}=\", val)\n xargs[:\"set_#{f}\"] = val\n end\n end\n\n # Store where merge came from in new version of destination.\n dest.merge_source_id = src.versions.latest.id rescue nil\n xargs[:set_merge_source] = src\n\n # Save changes to destination.\n dest.save\n Transaction.send(\"put_#{dest.type_tag}\", xargs)\n\n # Copy over authors and editors.\n src.authors.each {|user| dest.add_author(user)}\n src.editors.each {|user| dest.add_editor(user)}\n\n # Delete old description if requested.\n if delete_after\n if !src.is_admin?(@user)\n flash_warning(:runtime_description_merge_delete_denied.t)\n else\n src_was_default = (src.parent.description_id == src.id)\n Transaction.send(\"delete_#{src.type_tag}\", :id => src)\n flash_notice(:runtime_description_merge_deleted.\n t(:old => src.unique_partial_format_name))\n src.destroy\n\n # Make destination the default if source used to be the default.\n if src_was_default && dest.public\n dest.parent.description = dest\n dest.parent.save\n end\n end\n end\n\n end\n return result\n end",
"def sync\n # We replicate our state to the management node(s)\n management_nodes = find_management_nodes\n management_nodes.each do |mng_node|\n remote_db = mng_node.get_node_db\n from_success = @our_node.replicate_from(local_node_db, mng_node, remote_db)\n to_success = @our_node.replicate_to(local_node_db, mng_node, remote_db)\n if from_success && to_success && !our_node.is_management\n break\n end\n end\n end",
"def merge(source); end",
"def sync()\n group_differ = GroupDiffer.new(@finder)\n group_diffs = group_differ.diff(@test_groups)\n sync_groups(group_diffs)\n\n @targets.each do |target_def|\n sync_target(target_def)\n end\n end",
"def swap_with(other)\n self.class.base_class.transaction do\n old_position = position\n update_attribute(:position, other.position)\n other.update_attribute(:position, old_position)\n end\n end",
"def merge!; end",
"def mark\n @location = @assembler.location\n\n @patch_points.each do |patch_location, source|\n @assembler.patch patch_location, location - source\n end\n end",
"def sync\n contents_sync(resource.parameter(:source) || self)\n end",
"def redo_in_transaction\n self.in_transaction = true\n ActiveRecord::Base.transaction { src_obj.replicate(self) }\n end",
"def __copy_on_write__(*)\n super.tap do\n new_set = __getobj__.instance_variable_get(:@set).dup\n __getobj__.instance_variable_set(:@set, new_set)\n end\n end",
"def perform_or_request_merge(src, dest)\n if in_admin_mode? || src.can_merge_into?(dest)\n perform_merge(src, dest)\n else\n request_merge(src, dest)\n end\n end",
"def set_content\n unless compare_content\n description = []\n description << \"update content in file #{@new_resource.path} from #{short_cksum(@current_resource.checksum)} to #{short_cksum(new_resource_content_checksum)}\"\n description << diff_current_from_content(@new_resource.content) \n converge_by(description) do\n backup @new_resource.path if ::File.exists?(@new_resource.path)\n ::File.open(@new_resource.path, \"w\") {|f| f.write @new_resource.content }\n Chef::Log.info(\"#{@new_resource} contents updated\")\n end\n end\n end",
"def replaced(from, to)\n\t\tsuper if defined? super\n\t\tif (from.distribute? && to.distribute?) && (to.self_owned? || from.self_owned?)\n\t\t unless Distributed.updating?(self) || (Distributed.updating?(from) && Distributed.updating?(to))\n\t\t\tDistributed.each_updated_peer(from) do |peer|\n\t\t\t peer.transmit(:plan_replace, self, from, to)\n\t\t\tend\n\t\t end\n\t\tend\n\t end",
"def adopt(other)\n other.stack = @stack\n other.output = @output\n other.variables = @variables\n end",
"def notify_file_mv(src, dst)\r\n notify_file_cp(src, dst)\r\n notify_file_rm(src)\r\n end",
"def merge(other); end",
"def merge; end",
"def sync(srcDir, dstDir)\n end",
"def <<(resource)\n resource.parent = source\n super(resource)\n end",
"def merge!(other)\n other = other.dup\n other.each_child do |other_child|\n my_child = get_child?(other_child.name)\n # Directly add if a child with the same name does not already exist.\n # Merge if the other child and my child are nodes.\n # Raise an exception otherwise.\n if not my_child\n add_child(other_child)\n elsif my_child.class == other_child.class\n my_child.merge!(other_child)\n else\n source_details = \"#{other_child} (#{other_child.class.name})\"\n target_details = \"#{my_child} (#{my_child.class.name})\"\n raise ConfigurationError.new(\"Cannot merge incompatible types - Source: #{source_details} - Target: #{target_details}\")\n end\n end\n end",
"def post_sync\n reset_movement\n reset_flags\n end",
"def changes(_start_ref, _end_ref)\n fail 'Not implemented'\n end",
"def concat(other)\n @left, @right = Node.new(@left, @right), Rope.Node(other)\n update_size\n update_depth\n end",
"def hand_off_to!(other)\n verify_hand_off_to(other)\n\n other.normal_children.replace normal_children\n other.fallback_child = fallback_child\n @normal_children = []\n @fallback_child = nil\n if parent\n if normal?\n parent.normal_children.delete(self)\n parent.normal_children << other\n else\n parent.fallback_child = other\n end\n other.parent = parent\n @parent = nil\n end\n end",
"def copy_branch_commits(src_repo_path, src_branch, src_branch_point, dest_repo_path)\n `(cd \"#{src_repo_path}\" && git format-patch --stdout #{src_branch_point}..#{src_branch}) | (cd \"#{dest_repo_path}\" && git am)`\n end",
"def action_sync\n assert_target_directory_valid!\n if ::File.exist?(::File.join(@new_resource.destination, 'CVS'))\n Chef::Log.debug \"#{@new_resource} update\"\n converge_by(\"sync #{@new_resource.destination} from #{@new_resource.repository}\") do\n run_command(run_options(:command => sync_command))\n Chef::Log.info \"#{@new_resource} updated\"\n end\n else\n action_checkout\n end\n end",
"def scan_for_merges\n moves = []\n # prescan for merges in the list of actions.\n @actions.select {|act| act.is_a? Action::MergeAction}.each do |a|\n # destructure the list\n file, remote_file, filename_dest, flags, move = a.file, a.remote_file, a.file_dest, a.flags, a.move\n UI.debug(\"preserving #{file} for resolve of #{filename_dest}\")\n # look up our changeset for the merge state entry\n vf_local = working_changeset[file]\n vf_other = target_changeset[remote_file]\n vf_base = vf_local.ancestor(vf_other) || @repo.versioned_file(file, :file_id => Updating::NULL_REV)\n # track this merge!\n @repo.merge_state.add(vf_local, vf_other, vf_base, filename_dest, flags)\n\n moves << file if file != filename_dest && move\n end\n moves\n end",
"def sync\n announcing 'Syncing Portage Tree' do\n chroot 'sync'\n end\n send_to_state('build', 'sync')\n end",
"def perform!\n super\n transfer!\n cycle!\n end",
"def merge\n # we merge only if out-degree(self) = 1 and out-degree(child) = 1\n while children.size == 1 && children[0].parents.size == 1\n c = children[0]\n c.children.each do |cc|\n cc.parents.reject! {|c2| c2.equal?(c) }\n cc.parents << self\n end\n\n # inherit the type and weight of the child\n self.children = c.children\n self.type = c.type\n self.weight += c.weight\n\n # remove the child from the DAG\n c.merged = true\n c.children = []\n end\n end",
"def __connect__(node)\n raise \"Cannot connect to a node which is not on the same graph!\" if node.graph != @this.graph\n node.in.instance_exec(@this) { |n| @others << n }\n @graph.instance_eval { @changed = true }\n end",
"def move\n @node = Node.find(params[:id])\n case params[:to]\n when 'left_of'\n @node.move_to_left_of(params[:dest_id])\n when 'right_of'\n @node.move_to_right_of(params[:dest_id])\n when 'child_of'\n @node.move_to_child_of(params[:dest_id])\n end\n @node.save\n redirect_to(nodes_url)\n end",
"def move(to)\n @moved = true\n super(to)\n end",
"def destroy\n Segment.find_by_guid(source.guid).destroy if source && Segment.find_by_guid(source.guid)\n Segment.find_by_guid(target.guid).destroy if target && Segment.find_by_guid(target.guid)\n successors.each {|successor| NetworkConnection.find_by_guid(successor.guid).destroy if successor}\n super\n end",
"def merge_trees(base_treeish, local_treeish, remote_treeish)\n invoke(:merge_recursive, base_treeish, \"-- #{local_treeish} #{remote_treeish}\")\n true\n rescue ShellExecutionError => error\n # 'CONFLICT' messages go to stdout.\n raise MergeError, error.out\n end",
"def merge(other)\n self.merge_actors(other)\n self.compress_history()\n end",
"def build_xml(builder)\n super(builder)\n builder.tag!(\"FromEntity\", \"xsi:type\" => self.source.class.to_s) {|b| source.build_xml(b)} if source\n builder.tag!(\"ToEntity\", \"xsi:type\" => self.target.class.to_s) {|b| target.build_xml(b)} if target\n successors.each do |s|\n builder.Successor {|b| s.build_xml(b)} if s\n end\n builder.Order order if order\n end",
"def moving_ndt_to_ndt(source, target)\n target_parent_id = target['data-parent-id']\n source_id = source['id']\n before_move_source_parent_id = source['data-parent-id']\n source_sibling_count = get_children_count(before_move_source_parent_id)\n target_sibling_count = get_children_count(target_parent_id)\n\n if source['data-parent-id'] == target_parent_id\n target_sibling_count -= 1\n source_sibling_count += 1\n end\n\n drag_drop_agenda_item(source, target)\n source = find_by_id(source_id)\n after_move_target_sibling_count = get_children_count(target_parent_id)\n after_move_source_prev_parent_children_count = get_children_count(before_move_source_parent_id)\n\n\n expect(target_parent_id).to eq(source['data-parent-id'])\n expect(after_move_target_sibling_count).to be > target_sibling_count\n expect(after_move_source_prev_parent_children_count).to be < source_sibling_count\n end",
"def copy(from, to)\n @parent.gemset_copy(from, to)\n end",
"def finalize_sync_operation\n puts \" - Transferred the following #{ @st_ops_cache_file.keys.count } st_ops versions to foreign repos:\"\n @st_ops_cache_file.keys.each { |from_git_commit, to_git_commit|\n puts \" - #{ from_git_commit } to #{ to_git_commit }\"\n }\n if @successful_files_with_st_ops.any?\n puts \" - The following #{ @successful_files_with_st_ops.count } files with st operations were synced successfully:\".color(:green)\n @successful_files_with_st_ops.each { |file_path| puts \" - #{ file_path }\" }\n else\n puts \" - No files with st operations were synced successfully\".color(:red)\n end\n if @successful_files_with_autosplit.any?\n puts \" - The following #{ @successful_files_with_autosplit.count } files with autosplit were synced successfully:\".color(:green)\n @successful_files_with_autosplit.each { |file_path| puts \" - #{ file_path }\" }\n else\n puts \" - No files with autosplit were synced successfully\".color(:red)\n end\n if @successful_files_without_st_ops.any?\n puts \" - The following #{ @successful_files_without_st_ops.count } files without st operations were synced successfully:\".color(:green)\n @successful_files_without_st_ops.each { |file_path| puts \" - #{ file_path }\" }\n else\n puts \" - No files without st operations were synced successfully\".color(:red)\n end\n if @unprocessable_files.any?\n puts \" - The following #{ @unprocessable_files.count } files could not be synced:\".color(:red)\n @unprocessable_files.each { |f_attrs|\n print \" - #{ f_attrs[:file].repo_relative_path(true) }: \".ljust(52).color(:red)\n puts \"#{ f_attrs[:message] }\".color(:red)\n }\n else\n puts \" - All file syncs were successful!\".color(:green)\n end\n if @files_with_autosplit_exceptions.any?\n puts \" - The following #{ @files_with_autosplit_exceptions.count } files raised an exception during autosplit:\".color(:red)\n @files_with_autosplit_exceptions.each { |f_attrs|\n print \" - #{ f_attrs[:file].repo_relative_path(true) }: \".ljust(52).color(:red)\n puts \"#{ f_attrs[:message] }\".color(:red)\n }\n else\n puts \" - No files raised exceptions during autosplit\".color(:green)\n end\n if @files_with_subtitle_count_mismatch.any?\n puts \" - The following #{ @files_with_subtitle_count_mismatch.count } files were synced, however their subtitle counts don't match:\".color(:red)\n @files_with_subtitle_count_mismatch.each { |f_attrs|\n print \" - #{ f_attrs[:file].repo_relative_path(true) }: \".ljust(52).color(:red)\n puts \"#{ f_attrs[:message] }\".color(:red)\n }\n else\n puts \" - All synced files have matching subtitle counts.\".color(:green)\n end\n true\n end",
"def merge(srcfs)\n @fs.merge!( srcfs.fs )\n @fs = Cleanfs.killdupl(@@loader.source,@fs,srcfs.fs)\n end",
"def do_combine(action)\n if action.range == @range\n merge(action)\n else\n place_in_hierarchy(action)\n end\n end",
"def perform(scope, nodes_ids, session_auth_params)\n @context = Context.build(session_auth_params)\n nodes = Node.where(id: nodes_ids)\n copies = copy_service.copy(nodes, scope)\n notify_user(copies, scope)\n end",
"def transfer_to_otu(otu, delete_from_incoming = true)\n return false if otu.id == self.otu_id\n c = Content.find(:first, :conditions => {:otu_id => otu.id, :content_type_id => self.content_type_id})\n # does the incoming otu have this content_type already\n \n begin\n Content.transaction do\n if c # content already exists for the clone-to OTU \n c.text = c.text + \" [Transfered from OTU #{self.otu_id}: #{self.text}]\" # append content\n c.save! \n # deal with figures\n for f in self.figures\n if found = Figure.find(:first, :conditions => {:addressable_type => 'Content', :addressable_id => c.id , :image_id => f.image_id})\n # append the caption\n found.caption += \" [Transfered from OTU #{self.otu_id}: #{f.caption}]\"\n f.destroy if delete_from_incoming\n else\n if delete_from_incoming\n # transfer the figure\n f.addressable_id = c.id\n f.save!\n else\n # clone the figure\n n = f.clone\n n.addressable_id = c.id\n end\n end\n end\n\n # deal with tags\n for t in self.tags\n if found = Tag.find(:first, :conditions => {:addressable_type => 'Content' , :addressable_id => c.id , :keyword_id => t.keyword_id })\n # append the notes\n \n found.notes += \" [Transfered from OTU #{self.otu_id}: #{t.notes}]\"\n found.save!\n t.destroy if delete_from_incoming\n else\n if delete_from_incoming\n # transfer the tag\n t.addressable_id = c.id\n t.save!\n else\n #clone the tag\n n = t.clone\n n.addressable_id = c.id\n n.save!\n end\n end\n end\n\n self.destroy if delete_from_incoming\n \n else # content in transfer-to OTU doesn't exist\n if delete_from_incoming # just update the otu_id and everything gets transferred\n self.otu_id = otu.id\n self.save!\n else # need to clone everything\n # clone the content\n nc = self.clone\n nc.otu_id = otu.id\n nc.save!\n\n # clone figures\n for f in self.figures\n fn = f.clone\n fn.addressable_id = nc.id\n fn.save!\n end\n\n # clone tags\n for t in self.tags\n tn = t.clone\n tn.addressable_id = nc.id\n tn.save!\n end\n end\n end\n end\n\n rescue\n returns false\n end\n true\n end",
"def push(remote_store, local_branch, remote_branch)\n VCSToolkit::Utils::Sync.sync object_store, local_branch, remote_store, remote_branch\n end",
"def copy\n nodes = Node.accessible_by(@context).where(id: params[:item_ids])\n\n NodeCopyWorker.perform_async(\n params[:scope],\n nodes.pluck(:id),\n session_auth_params,\n )\n\n render json: nodes, root: \"nodes\", adapter: :json,\n meta: {\n messages: [{\n type: \"success\",\n message: I18n.t(\"api.files.copy.files_are_copying\"),\n }],\n }\n end",
"def sync_workspace_permissions(source_user_id, target_user_id)\n source_user = find_user(source_user_id)\n target_user = find_user(target_user_id)\n if source_user.nil? then\n @logger.warn \" Source user: #{source_user_id} Not found. Skipping sync of permissions to #{target_user_id}.\"\n return\n elsif target_user.nil then\n @logger.warn \" Target user: #{target_user_id} Not found. Skipping sync of permissions for #{target_user_id}.\"\n return\n end\n\n # Check to make sure source user has permissions\n permissions_existing = target_user.UserPermissions\n source_permissions = source_user.UserPermissions\n\n if source_permissions.nil? then\n @logger.warn \" Source user: #{source_user_id} does not have any permissions assigned. Skipping sync of permissions to #{target_user_id}.\"\n return\n end \n\n # build permission hashes by Workspace ObjectID\n source_permissions_by_workspace = {}\n source_permissions.each do | this_source_permission |\n if this_source_permission._type == \"WorkspacePermission\" then\n source_permissions_by_workspace[this_source_permission.Workspace.ObjectID.to_s] = this_source_permission\n end\n end\n\n permissions_existing_by_workspace = {}\n permissions_existing.each do | this_permission |\n if this_permission._type == \"WorkspacePermission\" then\n permissions_existing_by_workspace[this_permission.Workspace.ObjectID.to_s] = this_permission\n end\n end\n\n # Prepare arrays of permissions to update, create, or delete\n permissions_to_update = []\n permissions_to_create = []\n permissions_to_delete = []\n\n # Check target permissions list for permissions to create and/or update\n source_permissions_by_workspace.each_pair do | this_source_workspace_oid, this_source_permission |\n\n # If target hash doesn't contain the OID referenced in the source permission set, it's a new\n # permission we need to create\n if !permissions_existing_by_workspace.has_key?(this_source_workspace_oid) then\n permissions_to_create.push(this_source_permission)\n\n # We found the OID key, so there is an existing permission for this Workspace. Is it different\n # from the target permission?\n else\n this_source_role = this_source_permission.Role\n this_source_workspace = find_workspace(this_source_workspace_oid)\n this_source_workspace_name = this_source_workspace[\"Name\"]\n\n if workspace_permissions_different?(this_source_workspace, target_user, this_source_role) then\n existing_permission = permissions_existing_by_workspace[this_source_workspace_oid]\n this_existing_workspace = existing_permission.Workspace\n this_existing_workspace_name = this_existing_workspace[\"Name\"]\n this_existing_role = existing_permission.Role\n @logger.info \"Existing Permission: #{this_existing_workspace_name}: #{this_existing_role}\"\n @logger.info \"Updated Permission: #{this_source_workspace_name}: #{this_source_role}\"\n permissions_to_update.push(this_source_permission)\n end\n end\n end\n\n # Loop through target permissions list and check for Workspace Permissions that don't exist\n # in source permissions template, indicating they need to be removed\n permissions_existing_by_workspace.each_pair do | this_existing_workspace_oid, this_existing_permission |\n if !source_permissions_by_workspace.has_key?(this_existing_workspace_oid) then\n permissions_to_delete.push(this_existing_permission)\n end\n end\n\n # Process creates\n number_new_permissions = 0\n permissions_to_create.each do | this_new_permission |\n this_workspace = find_workspace(this_new_permission.Workspace.ObjectID.to_s)\n if !this_workspace.nil? then\n this_workspace_name = this_workspace[\"Name\"]\n this_role = this_new_permission.Role\n\n @logger.info \"Workspace: #{this_workspace_name}\"\n @logger.info \"Creating #{this_role} permission on #{this_workspace_name} from #{source_user_id} to: #{target_user_id}.\"\n create_workspace_permission(target_user, this_workspace, this_role)\n number_new_permissions += 1\n end\n end\n\n # Process updates\n number_updated_permissions = 0\n permissions_to_update.each do | this_new_permission |\n this_workspace = find_workspace(this_new_permission.Workspace.ObjectID.to_s)\n if !this_workspace.nil? then\n this_workspace_name = this_workspace[\"Name\"]\n this_role = this_new_permission.Role\n\n @logger.info \"Workspace: #{this_workspace_name}\"\n @logger.info \"Updating #{this_role} permission on #{this_workspace_name} from #{source_user_id} to: #{target_user_id}.\"\n create_workspace_permission(target_user, this_workspace, this_role)\n number_updated_permissions += 1\n end\n end\n\n # Process deletes\n number_removed_permissions = 0\n permissions_to_delete.each do | this_deleted_permission |\n this_workspace = find_workspace(this_deleted_permission.Workspace.ObjectID.to_s)\n if !this_workspace.nil? then\n this_workspace_name = this_workspace[\"Name\"]\n this_role = this_deleted_permission.Role\n\n @logger.info \"Workspace: #{this_workspace_name}\"\n @logger.info \"Removing #{this_role} permission to #{this_workspace_name} from #{target_user_id} since it is not present on source: #{source_user_id}.\"\n if !@upgrade_only_mode then\n delete_workspace_permission(target_user, this_workspace)\n number_removed_permissions += 1\n else\n @logger.info \" #{target_user_id} - upgrade_only_mode == true.\"\n @logger.info \" Proposed Permission removal would downgrade permissions. No permission removal applied.\"\n end\n end\n end\n @logger.info \"#{number_new_permissions} Permissions Created; #{number_updated_permissions} Permissions Updated; #{number_removed_permissions} Permissions Removed.\"\n end",
"def merge(other)\n @actions += other.actions\n @errors += other.errors\n @warnings += other.warnings\n @notices += other.notices\n end",
"def union!(other)\n redis.sunionstore key, key, other.key\n ensure\n notify_changed\n end",
"def merge!(src)\n raise ArgumentError.new('Mismatched object') \\\n unless src.objs == @objs\n @deps.push(src.deps).uniq!\n @rules.push(src.rules).flatten!\n @dirs_to_create.push(src.dirs_to_create).flatten!.uniq!\n src.files_to_copy.each do |k,v|\n @files_to_copy[k] ||= []\n @files_to_copy[k].concat(v).uniq!\n end\n end",
"def sync!(source_entry)\n self.sync(source_entry)\n self.save\n end",
"def move_to(x, y)\n super(x, y)\n update_memory!(self.memory)\n end",
"def sync(source_entry)\n [ :entry_status, :entry_author_id, :entry_allow_comments, :entry_allow_pings, \n :entry_convert_breaks, :entry_title, :entry_excerpt, :entry_text, :entry_text_more,\n :entry_to_ping_urls, :entry_pinged_urls, :entry_keywords, :entry_tangent_cache,\n :entry_created_on, :entry_modified_on, :entry_created_by, :entry_modified_by,\n :entry_basename, :entry_week_number ].each do |attribute|\n self[attribute] = source_entry[attribute]\n end\n\n # Sync placements ONLY if this entry has been previously saved.\n unless self.new_record?\n # Add or update placements.\n source_entry.placements.each do |source_placement|\n # Category may not exist yet; copy if so.\n target_category = MovableType::AR::Category.find(:first, :conditions => { :category_blog_id => self.entry_blog_id, :category_label => source_placement.category.category_label })\n target_category = MovableType::AR::Category.create(self.blog, source_placement.category) if target_category.blank?\n target_placement = self.placements.find(:first, :conditions => { :placement_category_id => target_category.category_id })\n target_placement.blank? ?\n self.placements << MovableType::AR::Placement.create(self, source_placement) :\n target_placement.sync!(source_placement)\n end\n \n # Remove old placements.\n if self.placements.size > source_entry.placements.size\n self.placements.each do |target_placement|\n source_category = MovableType::AR::Category.find(:first, :conditions => { :category_blog_id => source_entry.entry_blog_id, :category_label => target_placement.category.category_label })\n if source_category.blank?\n self.placements.delete(target_placement)\n next\n end\n \n source_placement = source_entry.placements.find(:first, :conditions => { :placement_category_id => source_category.category_id })\n self.placements.delete(target_placement) if source_placement.blank?\n end\n end\n \n # Comments need to be synchronized separately (should always flow from production -> beta).\n end\n end",
"def copy_to(other); end",
"def push_objects(objects)\n @source.lock(:md) do |s|\n doc = @source.get_data(:md)\n objects.each do |id,obj|\n doc[id] ||= {}\n doc[id].merge!(obj)\n end \n @source.put_data(:md,doc)\n @source.update_count(:md_size,doc.size)\n end \n end",
"def migrate_content_datastreams\n save\n target.attached_files.keys.each do |ds|\n mover = FedoraMigrate::DatastreamMover.new(source.datastreams[ds.to_s], target.attached_files[ds.to_s], options)\n report.content_datastreams << ContentDatastreamReport.new(ds, mover.migrate)\n end\n end",
"def test_manual_commit_and_merge\n sh(a_path, \"git status\")\n sh(a_path, \"git checkout gitgo\")\n \n method_root.prepare(:tmp, 'a/two') {|io| io << \"two content\" }\n \n sh(a_path, \"git add .\")\n sh(a_path, \"git commit -m 'message'\")\n\n a.reset\n b.reset\n assert_equal \"two content\", a['two']\n assert_equal nil, b['two']\n \n sh(b_path, \"git checkout gitgo\")\n sh(b_path, \"git pull\")\n \n a.reset\n b.reset\n assert_equal \"two content\", a['two']\n assert_equal \"two content\", b['two']\n end",
"def link(x, y)\n y.right = x.left\n x.left = y\n return x\n end",
"def on_postbuild(src_tree, dst_tree, converter)\n current_branch = @git_itf.current_branch\n\n dst_tree.traverse_preorder do |level, dst_node|\n unless dst_node.leaf?\n dst_node.data = DataDelegator.new if dst_node.data.nil?\n dst_node.data.add(FileHistory.new(current_branch))\n next\n end\n\n src_node = dst_node.data.src_node\n next unless src_node.pathname.exist?\n\n # Get the commit history of the doc as an Array of entries\n file_log = FileHistory.new(current_branch)\n @git_itf.file_log(src_node.pathname.to_s).each do |log_entry|\n file_log.history << FileHistory::LogEntry.new(\n log_entry[\"date\"],\n log_entry[\"author\"],\n log_entry[\"message\"],\n log_entry[\"sha\"]\n )\n end\n dst_node.data.add(file_log)\n end\n end",
"def sync!(source_placement)\n self.sync(source_placement)\n self.save\n end",
"def update_inputs_and_outputs\n\t\t\t\t@inputs = Files::State.new(@node.inputs)\n\t\t\t\t\n\t\t\t\tunless @node.inherit_outputs?\n\t\t\t\t\t@outputs = Files::State.new(@node.outputs)\n\t\t\t\tend\n\t\t\tend",
"def atomic_insert_modifier\n atomic_paths.insert_modifier\n end",
"def merge(space, path = nil)\n\n # Follow the path.\n path = Path.new(path) unless path.kind_of?(Path)\n m = meta_walk(path)\n\n # First, verify that we can add. Then add.\n merge_in(m, space, path, true)\n merge_in(m, space, path)\n\n end",
"def shift\n orphan_resource(super)\n end",
"def merge!(other); end"
] | [
"0.70432514",
"0.5568062",
"0.5516127",
"0.5390006",
"0.53412265",
"0.5340595",
"0.53319335",
"0.5282468",
"0.52564025",
"0.5224698",
"0.5191247",
"0.5163606",
"0.5136976",
"0.5121602",
"0.51038164",
"0.5047916",
"0.50231063",
"0.5011603",
"0.50046",
"0.49930847",
"0.49810964",
"0.49561238",
"0.49479777",
"0.49285907",
"0.49219102",
"0.4907543",
"0.4875966",
"0.4863054",
"0.48610646",
"0.48526198",
"0.483728",
"0.48176107",
"0.47992724",
"0.4782002",
"0.4778035",
"0.47654113",
"0.47639844",
"0.47591603",
"0.4758331",
"0.47548193",
"0.4746096",
"0.47263038",
"0.47246265",
"0.4720013",
"0.4715506",
"0.47076845",
"0.47055438",
"0.47035426",
"0.46773654",
"0.4670202",
"0.46685427",
"0.46610287",
"0.46560878",
"0.46545106",
"0.4653773",
"0.46432242",
"0.46369767",
"0.4623178",
"0.46218908",
"0.46212202",
"0.46188337",
"0.4618437",
"0.4617292",
"0.46167284",
"0.46140262",
"0.46122378",
"0.46117896",
"0.4606254",
"0.46046776",
"0.46037495",
"0.4600895",
"0.45951104",
"0.45928854",
"0.45896786",
"0.45851418",
"0.458349",
"0.45739722",
"0.45699358",
"0.45685712",
"0.45594987",
"0.4558873",
"0.4548205",
"0.45458278",
"0.45438546",
"0.45431587",
"0.454298",
"0.45384246",
"0.4537899",
"0.45143098",
"0.45019174",
"0.44984144",
"0.44957003",
"0.44859314",
"0.4484555",
"0.4482047",
"0.44765404",
"0.44764763",
"0.4475864",
"0.44684237",
"0.44674107"
] | 0.62798727 | 1 |
Get the named subdirectory content tree, if it exists N Without this we wouln't have an easy way to get an immediate subdirectory by name, but returning nil for one that doesn't exist (in the case where the name is from a different directory, and that directory doesn't exist in this one) | def getDir(dir)
return dirByName.fetch(dir, nil)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _dir(name, obj = @obj)\n obj[\"dirs\"].reverse.each do |dir|\n return dir[name] if dir[name]\n end\n return nil\n end",
"def find_directory(name, current = Pathname.new('.'))\n raise \"Cannot find directory #{name}\" if current.expand_path.root?\n path = current + name\n current.children.include?(path) ? path.expand_path.to_s : find_directory(name, current.parent)\n end",
"def find_path(path)\n @data.each_pair do |name, dir|\n if dir[:directory] == path\n return Directory::new(name, dir)\n end\n end\n \n return nil\n end",
"def get_children(directory)\n file = Pathname.new(directory)\n if file.directory?\n file.children\n else \n []\n end\nend",
"def subdir\n (@subdir) ? Pathname.new(@subdir) : Pathname.new('.')\n end",
"def find_folder(parent, name)\n # Check that a folder exists. Also check for \"close matches\" on the name.\n # If a match is found, return the path.\n path = nil\n likely_names = name_variations(name)\n likely_names.each do |n|\n path = \"#{parent}/#{n}\"\n puts \"find_folder(#{name}): trying \\'#{path}\\'\" if @opts[:debug]\n break if Pathname.new(path).directory?\n path = nil\n end\n puts \"find_folder(#{name}): returning path of \\'#{path}\\'\" if @opts[:debug]\n return path\nend",
"def subtree(name)\n out = nil\n @subtrees.each { |subtree| out = subtree if subtree.name == name.to_s }\n raise \"Unknown subtree '#{name}'\" if out.nil?\n out\n end",
"def subdirs(*name)\n\t\treturn File.join(name, \"*/\")\n\tend",
"def find_folder(name)\n @storage.nodes.find { |f| f.type == :folder && f.name == name }\n end",
"def recursive_find_directories_and_files dirname\r\n base_path = self.class.lookup('ExtAdminSection').path + \"/templates/\"\r\n \r\n directories = []\r\n files = []\r\n \r\n Find.find(File.join(base_path, dirname)) do |path|\r\n if FileTest.directory?(path)\r\n directories << path.gsub(base_path, '')\r\n else\r\n files << path.gsub(base_path, '')\r\n end\r\n end\r\n \r\n return directories, files\r\n end",
"def find_root_path(path)\n return nil if path.nil?\n filepath = File.expand_path(path)\n\n if dir_exist?(filepath)\n directory = filepath\n elsif file_exist?(filepath)\n directory = File.dirname(filepath)\n else\n return nil\n end\n\n until directory.nil?\n break if file_exist?(File.join(directory, 'metadata.json')) || file_exist?(File.join(directory, 'environment.conf'))\n parent = File.dirname(directory)\n # If the parent is the same as the original, then we've reached the end of the path chain\n if parent == directory\n directory = nil\n else\n directory = parent\n end\n end\n\n directory\n end",
"def getContentTreeForSubDir(subDir)\n #N Without this we won't know if the relevant sub-directory content tree hasn't already been created\n dirContentTree = dirByName.fetch(subDir, nil)\n #N Without this check, we'll be recreated the sub-directory content tree, even if we know it has already been created\n if dirContentTree == nil\n #N Without this the new sub-directory content tree won't be created\n dirContentTree = ContentTree.new(subDir, @pathElements)\n #N Without this the new sub-directory won't be added to the list of sub-directories of this directory\n dirs << dirContentTree\n #N Without this we won't be able to find the sub-directory content tree by name\n dirByName[subDir] = dirContentTree\n end\n return dirContentTree\n end",
"def directory_named(name_pattern)\n @top_level.find do |fso|\n fso['type'] == 'dir' && fso['name'].match(name_pattern)\n end\n end",
"def containing_directory\n path.dirname\n end",
"def path_from_dir_for(dir,filename)\n # Can we do this the easy way?\n file = File.join(dir,filename)\n return file if File.exist?(file)\n \n # Didn't think so\n if File.exist?(dir)\n allFiles = Dir.entries(dir)\n foundDirs = allFiles.select { |f| \n fullPath = File.join(dir,f)\n File.exist?(fullPath) &&\n File.directory?(fullPath) &&\n f != '.' && f != '..' }\n foundDirs.each do | subdir |\n subdir_path = File.join(dir,subdir)\n result = path_from_dir_for( subdir_path, filename)\n return result if result\n end\n end\n return nil\n end",
"def getFile(tree, name, path = '')\n blob = nil\n\n tree.each_blob do |file|\n blob = file if file[:name] == name[/[^\\/]*/]\n blob[:name] = path + blob[:name]\n end\n\n if blob.nil?\n tree.each_tree do |subtree|\n if subtree[:name] == name[/[^\\/]*/]\n path += name.slice! name[/[^\\/]*/]\n name[0] = ''\n return getFile($repo.lookup(subtree[:oid]), name, path + '/')\n end\n end\n end\n\n return blob\nend",
"def get(path)\n unless path.empty?\n root = path.getRoot\n return nil unless self.keys.include? root\n if path.hasChild? then\n return self[root].get(path.getChild)\n else\n return self[root]\n end\n end\n nil\n end",
"def get_child(path)\n children.find { |child| child.name == path } || OneDrive404.new\n end",
"def getCachedContentTree\n #N Without this, we won't know the name of the specified cached content file (if it is specified)\n file = getExistingCachedContentTreeFile\n #N Without this check, we would attempt to read a non-existent file\n if file\n #N Without this, a content tree that has been cached won't be returned.\n return ContentTree.readFromFile(file)\n else\n return nil\n end\n end",
"def dfs(root, target_file, path = root.name)\n return path if root.name == target_file\n\n children = get_children(path)\n children.each do |child_path|\n child_node = Node.new(child_path.basename.to_s)\n root.children << child_node\n result = dfs(child_node, target_file, child_path)\n if result \n return result\n end\n end\n nil\nend",
"def has_directory? name\n File.directory? path / name\n end",
"def just_find_it(here=Pathname.pwd)\n mainfile = here + MAINFILE\n return mainfile if mainfile.exist?\n return nil if here == here.parent\n return just_find_it(here.parent)\nend",
"def sub_dir_of(file, base = base_directory)\n file = Pathname.new(file) unless file.respond_to?(:relative_path_from)\n base = Pathname.new(base) unless base.respond_to?(:relative_path_from)\n rel = file.relative_path_from(base)\n if file.directory?\n rel\n else\n rel.dirname\n end\n end",
"def sub_tree\n files = ProjectFile.where(directory_id: id)\n files = files.nil? ? [] : files \n\n files.sort{|x,y| \n if x.is_directory and not y.is_directory\n -1\n elsif not x.is_directory and y.is_directory\n 1\n else\n x.name <=> y.name\n end\n }\n end",
"def resolve_as_directory name\n [test_dir + name, context.root + name].detect { |dir|\n dir.directory? and handle? dir\n }\n end",
"def find_node(root,path)\n name_array = path.split('.')\n node = root[name_array[0]]\n name_array.each do |n|\n node.children.each do |c|\n if c.name == n\n node = c\n break\n end\n end\n end\n node\n end",
"def get_node_containing(node,path,content)\n if path == \"\" then\n return nil\n end\n name = path.split(\"/\")[0]\n rest = path.split(\"/\")\n rest.delete(name)\n rest = rest.join(\"/\")\n node.each_element do |element|\n if element.name == name\n if rest == \"\" && element.content == content\n return element.parent\n else\n node = get_node_containing(element,rest,content)\n if node == nil\n next\n else\n return node\n end\n end\n end\n end\n end",
"def directory_name\n return @directory_name.to_s if @directory_name\n return local_path.basename.to_s if exist?\n return name\n end",
"def node_at(*path)\n return self if path.empty?\n\n # recursive loop ends when last path_node is shifted off the array\n attributes = {'fs_name' => path.shift}\n\n # create and add the child node if it's not found among the immediate\n # children of self\n child = children.find do |c|\n c.node_name == 'dir' && c.fs_name == attributes['fs_name']\n end\n unless child\n child = Node.new_node('dir', document, attributes)\n add_child(child)\n end\n\n child.node_at(*path)\n end",
"def visit_location(name)\n\t\tif File.exists?(name) \n\t\t\tif (File.directory?(name)) \n\t\t\t\tDir.foreach(name) { |child| visit_location(name + \"/\" + child) if child != \".\" && child != \"..\" }\n\t\t\telse\n\t\t\t\tvisit_file(name)\n\t\t\tend\n\t\telse\n\t\t\tSTDERR.puts \"#{name} doesn't exist.\"\n\t\tend\n\tend",
"def find_root(path)\n path = File.expand_path('..', path) if root?(path) == false\n find_root(path) if root?(path) == false\n return path if root?(path) == true\n end",
"def find_existing(path)\n until File.directory?(path)\n path = File.dirname(path)\n end\n path\n end",
"def dirs_until_dodona_dir\n dir = @pwd\n children = [dir]\n loop do\n return [] if dir.root?\n return children if dir == @dodona_dir\n children.unshift dir\n dir = dir.parent\n end\n end",
"def parent_of( page )\n dir = page.directory\n\n loop do\n if @db.has_key? dir\n parent = @db[dir].find {|p| p.filename == 'index'}\n return parent unless parent.nil? or parent == page\n end\n\n break if dir.empty?\n dir = ::File.dirname(dir)\n dir = '' if dir == '.'\n end\n\n return\n end",
"def lookup_root\n root = nil\n Dir.ascend(Dir.pwd) do |path|\n check = Dir[ROOT_GLOB].first\n if check\n root = path \n break\n end\n end\n root || Dir.pwd\n end",
"def lookUp(name)\n if @currentPath.empty? then\n return nil unless self.keys.include? name\n return self[name]\n else\n entry = nil\n path = @currentPath.clone\n while !(path.empty?)\n cEntry = get(path)\n entry = cEntry.lookUpLocal(name)\n return entry if entry\n path.exitName\n end\n entry = self[name] if self.keys.include? name\n return entry if entry\n end\n nil\n end",
"def relative_directory\n return '' unless @directory_root\n @path - @directory_root - name\n end",
"def [](path)\n first, *rest_path = path.split(\"/\") \n obj = case first\n when nil\n if path == \"/\"\n root\n elsif path == \"\"\n self\n end\n when \"\"\n root\n when \"..\"\n parent\n when \".\"\n self\n else\n children[first.to_sym]\n end\n\n return nil if obj.nil?\n if rest_path.size > 0\n obj[rest_path.join(\"/\")]\n else\n obj\n end\n end",
"def directory_hash(path, name=nil)\n data = {:folder => (name || path.split(\"/\").last)}\n data[:children] = children = []\n Dir.foreach(path) do |entry|\n next if (entry == '..' || entry == '.' || entry == 'yamproject.json' || entry == '.DS_Store')\n full_path = File.join(path, entry)\n if File.directory?(full_path)\n children << directory_hash(full_path, entry)\n else\n children << entry\n end\n end\n return data\nend",
"def last_folder\n return content_path unless request.params.has_key?(\"page\")\n path = request.params[\"page\"].split('/')\n File.join(content_path, path[0..-2])\n end",
"def last_folder\n return content_path unless request.params.has_key?(\"page\")\n path = request.params[\"page\"].split('/')\n File.join(content_path, path[0..-2])\n end",
"def parent_directory\n File.dirname(@full_path).split('/').last\n end",
"def parent_directory\n File.dirname(@full_path).split('/').last\n end",
"def directory_subdirectories(path)\n\tputs ''\n\tfor i in subdir_paths(path)\n\t\tputs i\n\tend\n\tputs ''\n\treturn nil\nend",
"def lookup(path, ctype=nil, recursive=false, path_only=true, dirs=false)\n # TODO : this might need to be changed as it returns dir and contents\n # if there are contents\n entries = []\n prune = recursive ? nil : 2\n @content_tree.with_subtree(path, ctype, prune, dirs) do |node|\n entries << [node.node_type, (path_only ? node.path : node)]\n end\n entries\n end",
"def path(name=nil)\n if name\n return @dir + '/' + name\n else\n return @dir\n end\n end",
"def lookup_root\n pwd = File.expand_path(Dir.pwd)\n home = File.expand_path('~')\n while pwd != '/' && pwd != home\n return pwd if ROOT_INDICATORS.any?{ |r| File.exist?(File.join(pwd, r)) }\n pwd = File.dirname(pwd)\n end\n return nil\n end",
"def tree(name = nil)\n if name.present?\n joins(:curriculum).where('curriculums.name = ? OR curriculums.slug = ?', name, name)\n elsif (default = Curriculum.default)\n where(curriculum_id: default.id)\n else\n where(nil)\n end\n end",
"def resolve_as_directory name\n [test_dir + name, context.root + name].detect { |dir| handle?(dir) }\n end",
"def make_child_entry(name)\n if CHILDREN.include?(name)\n return nil unless root_dir\n\n return root_dir.child(name)\n end\n\n paths = (child_paths[name] || []).select { |path| File.exist?(path) }\n if paths.size == 0\n return NonexistentFSObject.new(name, self)\n end\n\n case name\n when \"acls\"\n dirs = paths.map { |path| AclsDir.new(name, self, path) }\n when \"client_keys\"\n dirs = paths.map { |path| ClientKeysDir.new(name, self, path) }\n when \"clients\"\n dirs = paths.map { |path| ClientsDir.new(name, self, path) }\n when \"containers\"\n dirs = paths.map { |path| ContainersDir.new(name, self, path) }\n when \"cookbooks\"\n if versioned_cookbooks\n dirs = paths.map { |path| VersionedCookbooksDir.new(name, self, path) }\n else\n dirs = paths.map { |path| CookbooksDir.new(name, self, path) }\n end\n when \"cookbook_artifacts\"\n dirs = paths.map { |path| CookbookArtifactsDir.new(name, self, path) }\n when \"data_bags\"\n dirs = paths.map { |path| DataBagsDir.new(name, self, path) }\n when \"environments\"\n dirs = paths.map { |path| EnvironmentsDir.new(name, self, path) }\n when \"groups\"\n dirs = paths.map { |path| GroupsDir.new(name, self, path) }\n when \"nodes\"\n dirs = paths.map { |path| NodesDir.new(name, self, path) }\n when \"policy_groups\"\n dirs = paths.map { |path| PolicyGroupsDir.new(name, self, path) }\n when \"policies\"\n dirs = paths.map { |path| PoliciesDir.new(name, self, path) }\n when \"roles\"\n dirs = paths.map { |path| RolesDir.new(name, self, path) }\n when \"users\"\n dirs = paths.map { |path| UsersDir.new(name, self, path) }\n else\n raise \"Unknown top level path #{name}\"\n end\n MultiplexedDir.new(dirs)\n end",
"def get_hier_cell(pfx, name)\n return get_cell(name) if pfx.empty?\n cell = get_cell(pfx[0])\n ref = cell.ref\n npfx = pfx - pfx[0..0]\n ref.get_hier_cell(npfx, name)\n end",
"def find_directory(working_directory, cache_directory)\n directory = working_directory + \"/\" + cache_directory\n return directory if File.exists?(directory)\n parent_directory = File.dirname(working_directory)\n return nil if parent_directory == working_directory\n return find_directory(parent_directory, cache_directory)\n end",
"def find_single_directory\n roots = Dir.glob(File.join(@app_dir, '*')).select { |f| f != File.join(@app_dir, 'logs') && File.directory?(f) }\n roots.size == 1 ? roots.first : nil\n end",
"def get_directories(src)\n directories = Array.new\n #return directories\n Find.find(src) do |path|\n # not too sure what this was intended to do but its getting in the way\n # and can not be matched correctly.\n #next if File.dirname(path) != src \n next if path == src\n next if not File.directory? path\n directories.push path\n end\n directories.reverse\nend",
"def get_name_folder_from_path(path)\n folder_path_array = path.split('/')\n folder_path_array[folder_path_array.count - 2]\nend",
"def descend()\n @path.scan(%r{[^/]*/?})[0...-1].inject('') do |path, dir|\n yield self.class.new(path << dir)\n path\n end\n end",
"def _find_(type, filename, extnames=nil)\n if type.nil? || filename.nil?\n return nil\n end\n\n if absolute?(filename)\n return File.exists?(filename) ? filename : nil\n end\n\n path(type).each do |dir|\n each_full_path(dir, filename, extnames) do |full_path|\n if File.exists?(full_path) && subpath?(dir, full_path)\n return full_path\n end\n end\n end\n\n nil\n end",
"def findentry(f, name, start)\n f.seek(start)\n myname = getname(f, start)\n if name == myname\n return start\n end\n left = leftchild(f, start)\n right = rightchild(f, start)\n if name < myname\n if left < f.stat.size and left != 0\n res = findentry(f, name, leftchild(f, start))\n else\n res = nil # this should perolate up\n end\n end\n if name > myname\n if right < f.stat.size and right != 0\n res = findentry(f, name, rightchild(f, start))\n else\n res = nil\n end\n end\n return res\n end",
"def get_folder(name, type = \"VIRTUAL_MACHINE\", datacenter = nil)\n folder_api = VSphereAutomation::VCenter::FolderApi.new(api_client)\n raise_if_unauthenticated folder_api, \"checking for folder `#{name}`\"\n\n parent_path, basename = File.split(name)\n filter = { filter_names: basename, filter_type: type }\n filter[:filter_datacenters] = datacenter if datacenter\n filter[:filter_parent_folders] = get_folder(parent_path, type, datacenter) unless parent_path == \".\"\n\n folders = folder_api.list(filter).value\n\n raise_if_missing folders, format(\"Unable to find VM/template folder: `%s`\", basename)\n raise_if_ambiguous folders, format(\"`%s` returned too many VM/template folders\", basename)\n\n folders.first.folder\n end",
"def find(name)\n load_path.each do |path|\n parts = name.split(Command::SEPARATOR)\n file = File.join(path, *parts, Command::FILENAME)\n root = File.dirname(file)\n return build(name, root) if File.exist?(file)\n end\n\n nil\n end",
"def get_non_linked_dir_path_for_path(path)\n \n #check if the directory exists (either as an actual directory or hard link) or whether we need to get the parent first\n \n if File.exist?(path) then\n \n #check first if we can go and get it directly\n \n if File.directory?(path) then\n \n return path\n \n end\n \n #otherwise, find the index from hard link count\n \n index = File.stat(path).nlink\n \n final_dir = File.join(@mount_point, @path_to_dir_entries, Dirlisting_prefix + index.to_s)\n \n return final_dir\n \n end\n \n #recursively get the parent directory\n \n split_path = File.split(path)\n \n parent_path = get_non_linked_dir_path_for_path(split_path[0])\n \n get_non_linked_dir_path_for_path(File.join(parent_path, split_path[1]))\n \n end",
"def find_dir(path)\n return path if path.starts_with?('/') && Dir.exist?(path)\n\n repository_search_paths.each do |search_path|\n combined_path = File.join(search_path, path)\n return combined_path if Dir.exist?(combined_path)\n end\n\n nil\n end",
"def find_dotjam path=FileUtils.pwd\n curr=File.join(path,'.jam')\n if File.directory?(curr)\n curr\n else\n up=File.join(path,'..')\n if File.directory? up\n find_dotjam up\n else\n nil\n end\n end\n end",
"def GetLevelDirs()\n directories = Dir.entries($level_folder)\n\n for i in 0...directories.length do\n\n if not directories[i].include? \".\" then\n $current_folder = $level_folder + directories[i] + \"/\"\n GetLevels($current_folder)\n end\n\n end\n\nend",
"def lookup_path(path, dir)\n dir = ::File.expand_path(dir)\n top = ::File.expand_path(wiki.path)\n home = ::File.expand_path('~')\n\n loop do\n found = Dir[::File.join(dir, path)].first\n return found if found\n return nil if dir == top\n return nil if dir == home # just in case\n return nil if dir == '/' # doubly so\n dir = ::File.dirname(dir)\n end\n end",
"def get_node(node,path)\n name = path.split(\"/\")[0]\n rest = path.split(\"/\")\n rest.delete(name)\n rest = rest.join(\"/\")\n node.each_element do |element|\n if element.name == name\n if rest == \"\"\n return element\n else\n return get_node(element,rest)\n end\n end\n end\n end",
"def find(path, opts = {})\n path = path.to_s\n return self if path.empty?\n\n # remove duplicate slashes\n path = path.gsub(%r{/+}, \"/\")\n\n case path\n # ./foo/...\n when %r{^\\./?} then\n parent ? parent.find($', opts) : root.find($', opts)\n\n # /foo/...\n when %r{^/} then\n root.find($', opts)\n\n # foo/...\n when %r{^([^/]+)/?} then\n # Use the next path part to find a child by that name.\n # If no child can't be found, try to emit a child, but\n # not if the requested name starts with an underscore.\n if child = find_child($1, opts) || (emit_child($1) unless $1.start_with?(\"_\"))\n # Depending on the tail of the requested find expression,\n # either return the found node, or ask it to find the tail.\n $'.empty? ? child : child.find($', opts)\n end\n end\n end",
"def file_tree path = false, only_extensions = [], name = nil\n path = @path unless path\n data = { :name => (name || path) }\n data[:children] = children = []\n if(File.directory?(path) && File.exists?(path))\n Dir.foreach(path) do |entry|\n next if entry == '..' or entry == '.' or entry.start_with?(\".\")\n full_path = File.join(path, entry)\n if File.directory?(full_path)\n children << file_tree(full_path, only_extensions, entry)\n else\n if only_extensions.size > 0\n children << { :name => entry } if only_extensions.all? {|extension| true if entry.end_with?(extension) }\n else\n children << { :name => entry }\n end\n end\n end\n end\n return data\n end",
"def find_repo_dir(here=Pathname.pwd)\n if (here + '.git').exist?\n return here\n else\n find_repo_dir(here.dirname) unless '/' == here.to_s\n end\nend",
"def search_inherited_template\n # Get full ancestry path for current page\n parent_slugs = object.ancestry_path\n\n # Iterate over all parents:\n # 1. Generate template path:\n # ['grandparent', 'parent', 'current_page'] => 'grandparent/parent'\n # 2. Check if template for children exists:\n # 'app/views/pages/templates/grandparent/parent/_children_template.html.slim'\n # 3. Return it's name if exist or iterate again without closest parent\n while (template_dir = parent_slugs.tap(&:pop).join('/')).present?\n if File.exist?(\"#{TEMPLATE_DIR}/#{template_dir}/_#{CHILDREN_TEMPLATE_NAME}.html.slim\")\n inherited_template = \"templates/#{template_dir}/#{CHILDREN_TEMPLATE_NAME}\"\n break\n end\n end\n\n inherited_template\n end",
"def subdirectories()\n children.select { |c| c.directory? }\n end",
"def find_data(path, type: nil)\n if @data_dir\n full_path = ::File.join(@data_dir, path)\n case type\n when :file\n return full_path if ::File.file?(full_path)\n when :directory\n return full_path if ::File.directory?(full_path)\n else\n return full_path if ::File.readable?(full_path)\n end\n end\n parent&.find_data(path, type: type)\n end",
"def get_folder()\n f = Kamelopard::DocumentHolder.instance.current_document.folders.last\n Kamelopard::Folder.new() if f.nil?\n Kamelopard::DocumentHolder.instance.current_document.folders.last\n end",
"def child_get(name)\n child = @children.select{ |elem| name.eql?(elem.name) }\n return nil unless child\n child\n end",
"def find_or_create_folder(folder_root, name)\n folder_root.childEntity.each do |child|\n if child.instance_of?(RbVmomi::VIM::Folder) &&\n child.name == name\n return child\n end\n end\n\n folder_root.CreateFolder(:name => name)\n end",
"def retrieve_dirs(_base, dir, dot_dirs); end",
"def get_child(node, name)\n a = nil\n node.children.each { |child|\n if child.name == name\n a = child\n break\n end\n }\n return a\nend",
"def hiera(key, default = nil)\n @hiera.lookup(key, nil, @scope) || @scope.dig(*key.split('.')) || default\n end",
"def dir\n calc_dir(@basename)\n end",
"def path_for(filename)\n return nil unless filename\n for dir in @dirs\n result = path_from_dir_for(dir,filename)\n return result if result\n end\n @logger.fatal(\"Failed to locate '#{filename}'\")\n return nil\n end",
"def find(root, data)\n node = root\n if !root.nil? && root.title != data # gracefully handle nil, skips if match\n if !root.left.nil? #if left child exists\n node = find(root.left, data) # recursive left as root\n elsif !root.right.nil?\n node = find(root.right, data)\n else\n node = nil # if end of the tree\n end\n end\n return node\n end",
"def sub_content \n sub_contents = []\n\n if @is_post == false\n root_regexp = Regexp.new(@root, Regexp::IGNORECASE)\n sub_directories = Dir.glob(@absolute_path + '*');\n\n sub_directories.each do |sub_directory|\n begin\n # Remove the root from the path we pass to the new Content instance.\n # REVIEW: Should we be flexible and allow for the root dir to be present?\n content = Content.new(sub_directory.sub(root_regexp, ''))\n sub_contents.push(content)\n rescue ArgumentError\n next\n end\n end\n end\n\n sub_contents.reverse\n end",
"def get_asset_dir(path)\n root_paths.each { |root| return root if path.include?(root) }\n nil\n end",
"def find_or_create_child(path)\n path = self.class.name_to_hierarchy(path) if path.kind_of?(String)\n raise \"bad account path\" unless path.kind_of?(Array)\n result = self\n while path.length > 0\n result = result.children[path.shift]\n end\n return result\n end",
"def dirname_up(path)\n path =~ /(.*)\\\\(.*)$/\n\n return $1 || path\n end",
"def parent_dirs(file); end",
"def child(name)\n new_path = @path.dup\n new_path << ?/ unless new_path[-1] == ?/\n new_path << name\n new_for_path new_path\n end",
"def rootname filename\n if (last_dot_idx = filename.rindex '.')\n (filename.index '/', last_dot_idx) ? filename : (filename.slice 0, last_dot_idx)\n else\n filename\n end\n end",
"def getExistingCachedContentTreeFile\n #N Without this check, it would try to find the cached content file when none was specified\n if cachedContentFile == nil\n #N Without this, there will be no feedback to the user that no cached content file is specified\n puts \"No cached content file specified for location\"\n return nil\n #N Without this check, it will try to open the cached content file when it doesn't exist (i.e. because it hasn't been created, or, it has been deleted)\n elsif File.exists?(cachedContentFile)\n #N Without this, it won't return the cached content file when it does exist\n return cachedContentFile\n else\n #N Without this, there won't be feedback to the user that the specified cached content file doesn't exist.\n puts \"Cached content file #{cachedContentFile} does not yet exist.\"\n return nil\n end\n end",
"def [](val)\n case val\n when Numeric\n return @parts[val]\n else\n return @parts.find {|part| part.directory_name == val}\n end\n end",
"def find_exist_first_file\n if !(local_webs = ENV[\"APP_LOCAL_WEBS\"].split.find_all { |dir| File.basename(dir) == params[:level1] }).empty?\n File.join(local_webs.first, \"index.html\")\n else\n params_path = params.map(&:first).grep(/level/).sort.map(¶ms.method(:fetch)).join(\"/\")\n ENV[\"APP_LOCAL_WEBS\"].split.concat([ENV[\"APP_ROOT_PATH\"]])\n .map { |dir| File.join(dir, params_path) }\n .find_all(&File.method(:file?)).first\n end\n end",
"def root_folder\n if new_record?\n material_folders.find(&:root?) || (raise ActiveRecord::RecordNotFound)\n else\n material_folders.find_by!(parent: nil)\n end\n end",
"def find_template_sub(t)\n for path in [File.join(juli_repo, Juli::REPO), Juli::TEMPLATE_PATH] do\n template = File.join(path, t)\n return template if File.exist?(template)\n end\n raise Errno::ENOENT, \"no #{t} found\"\n end",
"def path(name)\n return @paths[''] if name.nil?\n normalized = name.split('/').inject([]) do |path, part|\n case part\n when '.', nil, ''\n path\n when '..'\n path[0...-1]\n else\n path << part\n end\n end.join('/')\n @paths[normalized] ||= Path.new(self, normalized)\n end",
"def child( path )\n\t\tp = path.reverse\n\t\tn = p.pop\n\t\tif (n<0) | (n>content.length)\n\t\t\tnil\n\t\telsif p.length == 0\n\t\t\t@content[ n ] \n\t\telse\n\t\t\t@content[ n ].child( p.reverse )\n\t\tend;\n\tend",
"def lookup_root(dir)\n root = nil\n Dir.ascend(dir || Dir.pwd) do |path|\n check = Dir[ROOT_GLOB].first\n if check\n root = path \n break\n end\n end\n root || Dir.pwd\n end",
"def find(path, dir: nil)\n parts = path_parts(normalize_path(path, dir: dir))\n return fs if parts.empty? # '/'\n\n find_recurser(fs, parts)\n end",
"def dirname() Path::Name.new(File.dirname(path)) end",
"def init_existing\n return unless current_directory?\n\n FolderTree.for_path linked_path, root: directory, limit: folder_limit\n end",
"def child_for_name(name)\n child = child_with_exact_name(name)\n if child\n child\n else\n fallback_child\n end\n end"
] | [
"0.6202693",
"0.5947798",
"0.5773851",
"0.5719538",
"0.5663004",
"0.5662706",
"0.5654844",
"0.5619072",
"0.55437714",
"0.5455498",
"0.54215175",
"0.5388436",
"0.53773755",
"0.5345005",
"0.5333558",
"0.5329629",
"0.53231543",
"0.5316825",
"0.5307021",
"0.52685565",
"0.5262291",
"0.52620506",
"0.5250515",
"0.52269596",
"0.521819",
"0.52160764",
"0.5210491",
"0.51761025",
"0.5135977",
"0.51192707",
"0.5104495",
"0.51027095",
"0.5092599",
"0.5087366",
"0.5087136",
"0.5078529",
"0.5070317",
"0.5068742",
"0.50581324",
"0.50529754",
"0.50529754",
"0.50527877",
"0.50527877",
"0.50520056",
"0.50466424",
"0.5045867",
"0.50428736",
"0.5039686",
"0.5023241",
"0.5021748",
"0.5010289",
"0.50063425",
"0.50063133",
"0.50049114",
"0.5002436",
"0.49954176",
"0.49902895",
"0.49838614",
"0.49819702",
"0.497452",
"0.4973999",
"0.49679437",
"0.495767",
"0.4940108",
"0.49396777",
"0.49392658",
"0.49294996",
"0.49240744",
"0.49224484",
"0.49220067",
"0.4921127",
"0.4913424",
"0.491272",
"0.49080664",
"0.49056876",
"0.48937085",
"0.4889063",
"0.48812348",
"0.48753822",
"0.4869608",
"0.48677078",
"0.4865467",
"0.48621523",
"0.48589435",
"0.485228",
"0.48498774",
"0.48495165",
"0.4842687",
"0.4832309",
"0.48281926",
"0.48281276",
"0.48254296",
"0.4824086",
"0.48199537",
"0.48184827",
"0.48157835",
"0.4812975",
"0.48039454",
"0.48022315",
"0.47990546"
] | 0.50346136 | 48 |
Get the named file & hash value, if it exists N Without this we wouln't have an easy way to get an immediate file & hash by name, but returning nil for one that doesn't exist (in the case where the name is from a different directory, and that file doesn't exist in this one) | def getFile(file)
return fileByName.fetch(file, nil)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_file_named name\n @files_hash[name]\n end",
"def get_value(path, hash)\n path.split('.').each do |key|\n hash = hash[key]\n end\n raise if hash.nil?\n\n hash\n rescue\n \"ValueNotFound\"\n end",
"def try_file(filename)\n return file(filename)\n rescue FileMissing\n return nil\n end",
"def try_file(filename)\n return file(filename)\n rescue FileMissing\n return nil\n end",
"def getExistingCachedContentTreeFile\n #N Without this check, it would try to find the cached content file when none was specified\n if cachedContentFile == nil\n #N Without this, there will be no feedback to the user that no cached content file is specified\n puts \"No cached content file specified for location\"\n return nil\n #N Without this check, it will try to open the cached content file when it doesn't exist (i.e. because it hasn't been created, or, it has been deleted)\n elsif File.exists?(cachedContentFile)\n #N Without this, it won't return the cached content file when it does exist\n return cachedContentFile\n else\n #N Without this, there won't be feedback to the user that the specified cached content file doesn't exist.\n puts \"Cached content file #{cachedContentFile} does not yet exist.\"\n return nil\n end\n end",
"def find filename\n return filename if File.exists? filename\n filename = \"./haml/\"+filename\n return filename if File.exists? filename\n filename = @src_folder+\"/\"+filename\n return filename if File.exists? filename\n throw \"Could not find file: #{filename}\"\nend",
"def get_hash_val(name)\n\t\tfetch(name) if has_key?(name)\n\tend",
"def get_file(key, use_cache = true)\n if use_cache\n db = (@current_site.get_meta(cache_key) || {})[File.dirname(key)] || {}\n else\n db = objects(File.dirname(key)) unless use_cache\n end\n (db[:files][File.basename(key)] || db[:folders][File.basename(key)]) rescue nil\n end",
"def read\n File.read(file_name)\n rescue Errno::ENOENT\n # ignore, will return nil\n end",
"def read_file name, reader = nil\n res = @file_cache[name]\n return (res || nil) unless res.nil?\n @file_cache[name] = false\n return nil unless File.exist?(name)\n reader = @readers[reader] if reader.is_a?(Symbol)\n ignored_errors = []\n (Array(reader) + @readers.values).each do |r|\n begin\n result = r.call(name)\n if result\n @file_cache[name] = result\n return result\n end\n rescue Exception => e\n ignored_errors << e\n end\n end\n raise RuntimeError, \"Error reading #{name}#{ ignored_errors.empty? ? \"\" : \": \" + ignored_errors.inspect }\"\n end",
"def find_file_named name\n @store.find_file_named name\n end",
"def lookUp(name)\n if @currentPath.empty? then\n return nil unless self.keys.include? name\n return self[name]\n else\n entry = nil\n path = @currentPath.clone\n while !(path.empty?)\n cEntry = get(path)\n entry = cEntry.lookUpLocal(name)\n return entry if entry\n path.exitName\n end\n entry = self[name] if self.keys.include? name\n return entry if entry\n end\n nil\n end",
"def get_filename(key)\n\thash = hash(key)\n\n\tif File.exist?(File.join(@cache_dir, hash))\n\t return File.join(@cache_dir, hash)\n\telse\n\t return nil\n\tend\n end",
"def getfile(sum)\n source_path = \"#{@rest_path}md5/#{sum}\"\n file_bucket_file = Puppet::FileBucket::File.indirection.find(source_path, :bucket_path => @local_path)\n\n raise Puppet::Error, \"File not found\" unless file_bucket_file\n file_bucket_file.to_s\n end",
"def file_from_sanitized(sanitized_name)\n current_revision = change['current_revision']\n change['revisions'][current_revision]['files'].keys.find { |k| sanitize(k) == sanitized_name }\n end",
"def _get_file(name)\n File.read(\"%s/%s\" % [uri, name])\n end",
"def find(name)\n storage.fetch(name) { not_found(name) }\n end",
"def find_file( path )\n find_files( path ).first\n end",
"def file\n file_id = @attributes[\"file\"]\n file_node = NodeCache.find(file_id)\n file_node ? file_node.name : nil\n end",
"def find_file_of(element)\n return @metadata['path'] if element == self\n\n name = element.full_name\n candidates = @metadata['includes'].flat_map do |file_name, root_names|\n root_names.map do |n|\n match = (name == n) || name.start_with?(\"#{n}::\")\n [file_name, n] if match\n end.compact\n end\n\n if (match = candidates.max_by { |_, name| name.size })\n match[0]\n else\n @metadata['path']\n end\n end",
"def find(name)\n Forgery.load_paths.reverse.each do |path|\n file = \"#{path}/#{@folder}/#{name}\"\n return file if File.exists?(file)\n end\n raise ArgumentError.new(\"File '#{name}' wasn't found in '#{@folder}' folder. Searched paths: \\n#{Forgery.load_paths.join('\\n')}\")\n end",
"def file_matching_path\n !!container.stored_files.where(file_name: file_name, path: path).first\n end",
"def by_name( name )\n available.each { |addon| return addon if addon['filename'] == name }\n return nil\n end",
"def find_include_file(name)\n to_search = [File.dirname(@input_file_name)].concat @include_path\n to_search.each do |dir|\n full_name = File.join(dir, name)\n stat = File.stat(full_name) rescue next\n return full_name if stat.readable?\n end\n nil\n end",
"def get_entry(entry)\n selected_entry = find_entry(entry)\n raise Errno::ENOENT, entry if selected_entry.nil?\n\n selected_entry\n end",
"def find_include_file(name)\n to_search = [ File.dirname(@input_file_name) ].concat @include_path\n to_search.each do |dir|\n full_name = File.join(dir, name)\n stat = File.stat(full_name) rescue next\n return full_name if stat.readable?\n end\n nil\n end",
"def get_cache_file(key)\n _find_file_key(key)\n end",
"def find_child_with_file_hash(file_hash, node)\n if node['name'] == 'file_hash' && node['value'] == file_hash\n node\n elsif node['children']\n node['children'].detect do |node|\n find_child_with_file_hash file_hash, node\n end\n else\n nil\n end\n end",
"def [](file_name)\n path = absolute_path_to_file(file_name)\n return nil unless File.exist?(path)\n File.read(path)\n end",
"def fetch(name)\n file_path = file_for(name)\n return File.read(file_path).strip.to_i if File.exist?(file_path)\n store(name)\n end",
"def exists?(file_hash)\n !!where(file_hash: file_hash).first\n end",
"def lookup_file_path\n file_path_list.each do |candidate_file_path|\n next unless File.file?(File.expand_path(candidate_file_path))\n return candidate_file_path\n end\n nil\n end",
"def find_file( filename )\r\n dir = @autoload_dirs.find { |dir|\r\n exist?( File.join(dir,filename) )\r\n }\r\n\r\n if dir\r\n return File.join(dir,filename)\r\n else\r\n return nil\r\n end\r\n end",
"def find_file_named(name)\n top_level.class.find_file_named(name)\n end",
"def find_resource( resource_hash )\n return nil unless valid?\n\n Dir.glob(File.join(@cache_path, \"#{resource_hash}.*\")).first\n end",
"def file\n @file ||= find_file\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 get_file_for_url(url, params)\n selected_files = params[\"selected_files\"].values\n return unless selected_files.map { |a| a[\"url\"] }.include?(url)\n selected_files.select { |a| a[\"url\"] == url }.first[\"file_name\"]\n end",
"def get_digest(file, version)\n # Make a hash with each individual file as a key, with the appropriate digest as value.\n inverted = get_state(version).invert\n my_files = {}\n inverted.each do |files, digest|\n files.each do |i_file|\n my_files[i_file] = digest\n end\n end\n # Now see if the requested file is actually here.\n unless my_files.key?(file)\n raise OcflTools::Errors::FileMissingFromVersionState, \"Get_digest can't find requested file #{file} in version #{version}.\"\n end\n\n my_files[file]\n end",
"def filename\n self.class.path(hash)\n end",
"def find(name)\n m = match(name)\n m.count == 1 ? m[0] : nil\n end",
"def [](key)\n File.read(cache_path(key))\n rescue Errno::ENOENT\n nil\n end",
"def file(name, version = nil, try_on_disk = false)\n ::Gollum::File.find(self, name, version.nil? ? @ref : version, try_on_disk)\n end",
"def find_associated(filename)\n assoc = associated_filename(filename)\n File.exists?(assoc) ? assoc : false\n end",
"def read(key)\n File.read(cache_path(key))\n rescue Errno::ENOENT\n nil\n end",
"def filename\n Dir[glob].first if exists?\n end",
"def get_data_by_key(key)\n expected_file_path = File.join(@temp_folder_path, \"#{key}.txt\")\n if FileFetcher::file_exists?(expected_file_path)\n FileFetcher::get_file_contents(expected_file_path)\n else\n nil\n end\n end",
"def find_file_path(filename)\n filepath=\"#{ENV['IMPORT_PATH']}/#{filename}\"\n #filepath = Dir.glob(\"#{ENV['IMPORT_PATH']}/#{filename}\").first\n raise \"Cannot find file #{filename}... Are you sure it has been uploaded and that the filename matches?\" if filepath.nil?\n filepath\n end",
"def fsgetr(name, sname)\n if fexistr name sname\n r = fgetr name sname\n return r\n else\n return \"\"\n end\nend",
"def find_free_name(filename); end",
"def getFile(tree, name, path = '')\n blob = nil\n\n tree.each_blob do |file|\n blob = file if file[:name] == name[/[^\\/]*/]\n blob[:name] = path + blob[:name]\n end\n\n if blob.nil?\n tree.each_tree do |subtree|\n if subtree[:name] == name[/[^\\/]*/]\n path += name.slice! name[/[^\\/]*/]\n name[0] = ''\n return getFile($repo.lookup(subtree[:oid]), name, path + '/')\n end\n end\n end\n\n return blob\nend",
"def get(file)\n binding.pry\n #return the values from cached first\n @cached[file] || \n @file_metadata[file] || \n read_metadata_from_yaml(file) || \n cache(file, read_metadata_from_disk(file)) \n end",
"def hash\r\n # TODO what if file is empty?\r\n @hash ||= Digest::SHA1.file(File.join(@directory, @filename)).hexdigest\r\n end",
"def existing_rd_file\n @rdfile ||= possible_rd_files.select { |file| File.exist? file }.first\n end",
"def get_file_hash(fullPath)\n contents = File.read(fullPath)\n fileHash = Digest::MD5.hexdigest(contents)\n return fileHash\nend",
"def find_header_file(header)\n filename = nil\n header_include_paths.each do |path|\n maybe_filename = \"#{path}/#{header}\"\n if File.exists?(maybe_filename)\n filename = maybe_filename\n break\n end\n end\n filename\nend",
"def lookUpVoid(name)\n path = @currentPath.clone\n globalPath = findGlobalPath\n if ! path.empty? then\n cEntry = get(path)\n entry = checkEntry(cEntry.lookUpLocal(name))\n return entry if entry\n while path != globalPath\n path.exitName\n cEntry = get(path)\n entry = checkEntry(cEntry.lookUpLocal(name)) if entry\n return entry if entry\n end\n if path.empty?\n entry = self[name] if self.keys.include? name\n entry = checkEntry(entry)\n return entry if entry\n end\n else\n entry = self[name] if self.keys.include? name\n entry = checkEntry(entry)\n return entry if entry\n end\n nil\n end",
"def value\n @value ||= basename\n end",
"def path_for(filename)\n return nil unless filename\n for dir in @dirs\n result = path_from_dir_for(dir,filename)\n return result if result\n end\n @logger.fatal(\"Failed to locate '#{filename}'\")\n return nil\n end",
"def find_file(name)\n if (explicit = folder/name.to_s).file?\n explicit\n else\n folder.glob(\"#{name}.*\").find{|f| f.file?}\n end\n end",
"def get name, default: nil\n name_str = name.to_s\n name_sym = name.to_sym\n\n value = nil\n found = false\n @config.each do |configfile|\n if value = configfile[:config][name_str] or value = configfile[:config][name_sym]\n found = true\n break\n end\n end\n value = default if value.nil? and not found\n value\n end",
"def find_resource_entry(filename, opts={}, seen=nil)\n extname = File.extname(filename)\n rootname = filename.gsub(/#{extname}$/,'')\n entry_extname = entry_rootname = nil\n\n ret = entries_for(:resource, opts.merge(:hidden => :none)).reject do |entry|\n entry_extname = File.extname(entry.filename)\n entry_rootname = entry.filename.gsub(/#{entry_extname}$/,'')\n\n ext_match = (extname.nil? || extname.size == 0) || (entry_extname == extname)\n !(ext_match && (/#{rootname}$/ =~ entry_rootname))\n end\n\n ret = ret.first\n\n if ret.nil?\n seen = Set.new if seen.nil?\n seen << self\n all_required_bundles.each do |bundle|\n next if seen.include?(bundle) # avoid recursion\n ret = @bundle.find_resource_entry(filename, opts, seen)\n return ret unless ret.nil?\n end\n end\n return ret\n end",
"def get_entry(path, commit = @commit)\n entry_hash = get_entry_hash(path, commit)\n if entry_hash.nil?\n entry = nil\n else\n entry = @repo.lookup(entry_hash[:oid])\n end\n entry\n end",
"def [](key)\n\thash = hash(key)\n\n\tvalue = nil\n\tif File.exist?(File.join(@cache_dir, hash))\n\t value = ''\n\t File.open(File.join(@cache_dir, hash), 'rb') { |f|\n\t\tvalue += f.read\n\t }\n\tend\n\n\treturn value\n end",
"def get_file(name, env)\n name = name + '.rb' unless name =~ /\\.rb$/\n path = search_directories(env).find { |dir| Puppet::FileSystem.exist?(File.join(dir, name)) }\n path and File.join(path, name)\n end",
"def findentry(f, name, start)\n f.seek(start)\n myname = getname(f, start)\n if name == myname\n return start\n end\n left = leftchild(f, start)\n right = rightchild(f, start)\n if name < myname\n if left < f.stat.size and left != 0\n res = findentry(f, name, leftchild(f, start))\n else\n res = nil # this should perolate up\n end\n end\n if name > myname\n if right < f.stat.size and right != 0\n res = findentry(f, name, rightchild(f, start))\n else\n res = nil\n end\n end\n return res\n end",
"def fgetv(fname,sname)\n pname = \"\"\n if fexists fname, sname\n if eval \"$#{fname}['#{sname},facets'].include? 'ref'\"\n fname2 = eval \"$#{fname}['#{sname},ref']\"\n if eval \"$#{fname}['#{sname},facets'].include? 'ifref'\"\n eval \"eval $#{fname}['#{sname},ifref']\"\n end\n pname = fgetv(fname2,sname)\n else\n if eval \"$#{fname}['#{sname},facets'].include? 'value'\"\n if eval \"$#{fname}['#{sname},facets'].include? 'ifgetv'\"\n eval \"eval $#{fname}['#{sname},ifgetv']\"\n end\n fname = eval \"$#{fname}['#{sname},value']\"\n end\n end\n end\n return pname\nend",
"def knows?(name)\n !find_file(name).nil?\n end",
"def file_info(path)\n if manifest_entry # have we loaded our manifest yet? if so, use that sucker\n result = [manifest_entry[path], manifest_entry.flags[path]]\n if result[0].nil?\n return [NULL_ID, '']\n else\n return result\n end\n end\n if manifest_delta || files[path] # check if it's in the delta... i dunno\n if manifest_delta[path]\n return [manifest_delta[path], manifest_delta.flags[path]]\n end\n end\n # Give us, just look it up the long way in the manifest. not fun. slow.\n node, flag = @repo.manifest.find(raw_changeset[0], path)\n if node.nil?\n return [NULL_ID, '']\n end\n return [node, flag]\n end",
"def value_from_hash(hash, path)\n value = hash\n\n begin\n path.each do |p|\n value = value[p]\n end\n value\n rescue NoMethodError\n nil\n end\n end",
"def read_write_default(name, value)\n filename = File.join(__dir__, \".\" + name)\n if value\n File.write(filename, value)\n value\n elsif File.exists?(filename)\n File.read(filename)\n else\n nil\n end\nend",
"def file\n file_names[x]\n end",
"def find(basename)\n list.include?(basename) ?\n self.read_from_disk(basename) :\n throw('Not Found')\n end",
"def file_or_data\n @file && File.exists?(@file.to_s) ? @file : @data\n end",
"def object_for_hash(given_hash)\n @opener.open(name, \"r\") do |fp|\n given_hash.force_encoding(\"ASCII-8BIT\") if given_hash.respond_to?(:force_encoding)\n entry = nil\n if index\n starting_at = index.offset_for_hash(given_hash)\n return PackFileEntry.at(starting_at, fp).to_raw_object\n else\n starting_at = cached_offset(given_hash) || DATA_START_OFFSET\n fp.seek(starting_at, IO::SEEK_SET)\n while fp.tell < @end_of_data\n entry = PackFileEntry.read(fp)\n cache_entry(entry)\n return entry.to_raw_object if entry.hash_id == given_hash\n end\n end\n end\n nil\n end",
"def get_hash(name)\n file_name = File.join(@db_dir, name + '.json')\n return ::Hash.new unless File.exist?(file_name)\n\n begin\n json = File.read(file_name)\n rescue => e\n PEROBS.log.fatal \"Cannot read hash file '#{file_name}': #{e.message}\"\n end\n JSON.parse(json, :create_additions => true)\n end",
"def access_file_name\n @hash[\"AccessFileName\"]\n end",
"def ppg_cache(digest)\n Global.ppg_cache_directory.entries.each do |entry|\n begin\n if digest == PackageFilename.parse(entry.basename).digest\n return entry\n end\n rescue InvalidPackageFilename\n next\n end\n end\n return nil\n end",
"def _find_(type, filename, extnames=nil)\n if type.nil? || filename.nil?\n return nil\n end\n\n if absolute?(filename)\n return File.exists?(filename) ? filename : nil\n end\n\n path(type).each do |dir|\n each_full_path(dir, filename, extnames) do |full_path|\n if File.exists?(full_path) && subpath?(dir, full_path)\n return full_path\n end\n end\n end\n\n nil\n end",
"def test_file # :nodoc:\n val = test_files and val.first\n end",
"def read_key(key)\n if File.exist?(key.to_s) && File.file?(key.to_s)\n File.read(File.absolute_path(key))\n else\n key\n end\n end",
"def get key\n entry = @keydict[key]\n\n if entry\n if entry[0] == @data_file.path\n pos = @data_file.pos\n @data_file.pos = entry[2]\n value = @data_file.read entry[1]\n @data_file.pos = pos\n value\n else\n data_file = @old_data_files[entry[0]]\n unless data_file\n data_file = File.open(entry[0], \"rb\")\n @old_data_files[entry[0]] = data_file\n end\n\n data_file.pos = entry[2]\n data_file.read entry[1]\n end\n end\n end",
"def find_file(name)\n path = File.join(TEST_FILES, name)\n raise \"Can't find #{path}\" unless File.exist?(path)\n\n yield path if block_given?\n path\n end",
"def file_path(file_name)\n file_map[file_name]['path']\n end",
"def file_path(file_name)\n file_map[file_name]['path']\n end",
"def get!(name)\n case name\n when String, Symbol\n path = @pathname + name #.to_s\n else\n path = name\n end\n\n if path.directory?\n data = FileStore.new(self, path.basename)\n elsif path.file?\n text = path.read.strip\n data = (/\\A^---/ =~ text ? YAML.load(text) : text)\n data = data.to_list if self.class.listings[name]\n else\n data = self.class.defaults[name]\n data = instance_eval(&data) if Proc === data\n end\n data\n end",
"def findSmallHash(f)\r\n return Digest::SHA1.file(f).hexdigest()\r\nend",
"def get_file(filename, branch_or_tag='master') \n\t\tlog = repo.log(branch_or_tag, filename) \n\t\treturn log.first.tree.contents.first.data\n\tend",
"def get_file_with_default(prompt, default)\n file = default\n loop do\n # Get the file\n file = get_with_default(prompt, file)\n\n if(File.exist?(file))\n return file\n end\n\n puts(\"Invalid file!\")\n end\nend",
"def file_hash\n return @file_hash\n end",
"def get_file(path)\n if not @files[path]\n file_not_found(path)\n end\n \n return Chance.get_file(@files[path])\n end",
"def get_config_file\n\t\tconfig_paths =\n\t\t\t[\n\t\t\t\t\"C:\\\\ProgramData\\\\Dyn\\\\Updater\\\\\", #Vista\n\t\t\t\t\"C:\\\\Documents and Settings\\\\All Users\\\\Application Data\\\\Dyn\\\\Updater\\\\\" #XP and else\n\t\t\t]\n\n\t\t# Give me the first match\n\t\tconfig_file = nil\n\t\tconfig_paths.each do |p|\n\t\t\ttmp_path = p + \"config.dyndns\"\n\t\t\tbegin\n\t\t\t\tf = session.fs.file.stat(tmp_path)\n\t\t\t\tconfig_file = tmp_path\n\t\t\t\tbreak #We've found a valid one, break!\n\t\t\trescue\n\t\t\tend\n\t\tend\n\n\t\treturn config_file\n\tend",
"def path_for(name, **options)\n lookup!(name, **options).fetch('file')\n end",
"def find_stemcell_file(release_id, filename, product_name)\n files = JSON.parse(get_product_release_files(product_name, release_id).body).fetch('product_files')\n file = files.select{ |r| r.fetch('aws_object_key') =~ filename }.first\n return file['id'], file['aws_object_key'].split('/')[-1]\n end",
"def select_file(*files)\n files.each do |file|\n if File.exists?(file) then return file end\n end\n return nil\n end",
"def find_text_page file_name\n @text_files_hash.each_value.find do |file|\n file.full_name == file_name\n end\n end",
"def get(path, default: nil, error: false)\n target = self\n\n path.split('.').each() do | key |\n k_sym = key.to_sym()\n if(target.has_key?(k_sym))\n target = target.get_key(k_sym)\n else\n raise ArgumentError.new(\"Value #{path} not found.\") unless !error\n return default\n end\n\n end\n\n return target\n end",
"def path\n return nil if self.hash_string.blank?\n File.join(*self.hash_string.scan(/(.)(.)(.*)/).flatten)\n end",
"def find_manifest_entry(name)\n if dev_server_running?\n { 'file' => prefix_vite_asset(name.to_s) }\n else\n manifest[name.to_s]\n end\n end",
"def get_image_name(user_hash)\n image_name = user_hash[\"image\"][:filename]\nend"
] | [
"0.69655967",
"0.6405222",
"0.59801364",
"0.59801364",
"0.5943641",
"0.5928381",
"0.5913333",
"0.59020627",
"0.58822113",
"0.58430594",
"0.57913065",
"0.57733846",
"0.57731915",
"0.57544047",
"0.57515925",
"0.56894124",
"0.5687003",
"0.5682225",
"0.5659012",
"0.5657253",
"0.5649672",
"0.5632316",
"0.5630869",
"0.5594503",
"0.5568155",
"0.5558134",
"0.5545369",
"0.55297875",
"0.5528872",
"0.5517106",
"0.5508694",
"0.54966486",
"0.54837227",
"0.54657227",
"0.54585004",
"0.54580444",
"0.5447408",
"0.5441064",
"0.5429611",
"0.54038054",
"0.5403788",
"0.54019076",
"0.5399794",
"0.5397144",
"0.53965026",
"0.5387874",
"0.5383463",
"0.53807807",
"0.53806925",
"0.5346578",
"0.53454953",
"0.5345034",
"0.53438115",
"0.53382486",
"0.5336328",
"0.53316295",
"0.53303903",
"0.53259474",
"0.53259057",
"0.5324155",
"0.53230494",
"0.5310442",
"0.53091407",
"0.5304171",
"0.530173",
"0.529944",
"0.528853",
"0.52830863",
"0.52827996",
"0.52816993",
"0.5274566",
"0.5269528",
"0.526436",
"0.5263952",
"0.5258833",
"0.52441454",
"0.52440304",
"0.5242294",
"0.52409077",
"0.52402186",
"0.52394694",
"0.5234327",
"0.5234325",
"0.5226007",
"0.5226007",
"0.5224312",
"0.5219063",
"0.5208511",
"0.5205691",
"0.52024585",
"0.5201024",
"0.51968014",
"0.51855004",
"0.5181865",
"0.51733404",
"0.51629794",
"0.51611054",
"0.51601243",
"0.5156925",
"0.5145347"
] | 0.62720704 | 2 |
Mark copy operations, given that the corresponding destination directory already exists. For files and directories that don't exist in the destination, mark them to be copied. For subdirectories that do exist, recursively mark the corresponding subdirectory copy operations. N Without this we won't know how to mark which subdirectories and files in this (source) directory need to by marked for copying into the other directory, because they don't exist in the other (destination) directory | def markCopyOperations(destinationDir)
#N Without this we can't loop over the immediate sub-directories to determine how each one needs to be marked for copying
for dir in dirs
#N Without this we won't have the corresponding sub-directory in the other directory with the same name as this sub-directory (if it exists)
destinationSubDir = destinationDir.getDir(dir.name)
#N Without this check, we won't be able to correctly process a sub-directory based on whether or not one with the same name exists in the other directory
if destinationSubDir != nil
#N Without this, files and directories missing or changed from the other sub-directory (which does exist) won't get copied
dir.markCopyOperations(destinationSubDir)
else
#N Without this, the corresponding missing sub-directory in the other directory won't get updated from this sub-directory
dir.markToCopy(destinationDir)
end
end
#N Without this we can't loop over the files to determine how each one needs to be marked for copying
for file in files
#N Without this we won't have the corresponding file in the other directory with the same name as this file (if it exists)
destinationFile = destinationDir.getFile(file.name)
#N Without this check, this file will get copied, even if it doesn't need to be (it only needs to be if it is missing, or the hash is different)
if destinationFile == nil or destinationFile.hash != file.hash
#N Without this, a file that is missing or changed won't get copied (even though it needs to be)
file.markToCopy(destinationDir)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def doCopyOperations(sourceContent, destinationContent, dryRun)\n #N Without this loop, we won't copy the directories that are marked for copying\n for dir in sourceContent.dirs\n #N Without this check, we would attempt to copy those directories _not_ marked for copying (but which might still have sub-directories marked for copying)\n if dir.copyDestination != nil\n #N Without this, we won't know what is the full path of the local source directory to be copied\n sourcePath = sourceLocation.getFullPath(dir.relativePath)\n #N Without this, we won't know the full path of the remote destination directory that this source directory is to be copied into\n destinationPath = destinationLocation.getFullPath(dir.copyDestination.relativePath)\n #N Without this, the source directory won't actually get copied\n destinationLocation.contentHost.copyLocalToRemoteDirectory(sourcePath, destinationPath, dryRun)\n else\n #N Without this, we wouldn't copy sub-directories marked for copying of this sub-directory (which is not marked for copying in full)\n doCopyOperations(dir, destinationContent.getDir(dir.name), dryRun)\n end\n end\n #N Without this loop, we won't copy the files that are marked for copying\n for file in sourceContent.files\n #N Without this check, we would attempt to copy those files _not_ marked for copying\n if file.copyDestination != nil\n #N Without this, we won't know what is the full path of the local file to be copied\n sourcePath = sourceLocation.getFullPath(file.relativePath)\n #N Without this, we won't know the full path of the remote destination directory that this source directory is to be copied into\n destinationPath = destinationLocation.getFullPath(file.copyDestination.relativePath)\n #N Without this, the file won't actually get copied\n destinationLocation.contentHost.copyLocalFileToRemoteDirectory(sourcePath, destinationPath, dryRun)\n end\n end\n end",
"def preform_copy_directory\n @destination_directories.each do |destination|\n @sources.each do |source|\n write_mode = 'w'\n new_path = Pathname.new(destination.to_s).join(source.basename)\n # Check if the specified file is a directory\n if new_path.directory?\n return false if get_input(\"Destination path '\" + new_path.to_s + \"' is a directory. (S)kip the file or (C)ancel: \", ['s','c']) == 'c'\n next\n end\n # Copy the file\n return false unless copy_file(source, new_path)\n end\n end\n return true\n end",
"def copy_directory(source, destination)\n FileUtils.cp_r(FileSyncer.glob(\"#{source}/*\"), destination)\n end",
"def copy_directory(source, destination)\n FileUtils.cp_r(FileSyncer.glob(\"#{source}/*\"), destination)\n end",
"def cp_dir(src, dst)\n puts \"#{cmd_color('copying')} #{dir_color(src)}\"\n puts \" -> #{dir_color(dst)}\"\n Find.find(src) do |fn|\n next if fn =~ /\\/\\./\n r = fn[src.size..-1]\n if File.directory? fn\n mkdir File.join(dst,r) unless File.exist? File.join(dst,r)\n else\n cp(fn, File.join(dst,r))\n end\n end\nend",
"def copy_dir(source, dest)\n files = Dir.glob(\"#{source}/**\")\n mkdir_p dest\n cp_r files, dest\n end",
"def copy_to!(dest)\n Pow(dest).parent.create_directory\n copy_to(dest)\n end",
"def markToCopy(destinationDirectory)\n #N Without this it won't be marked for copying\n @copyDestination = destinationDirectory\n end",
"def cp_single_file_or_directory(options={})\n from = options[:from]\n from_path = expand_path(from)\n to = options[:to]\n if to.to_s =~ %r{(.*)/$}\n to = $1\n raise CopyToNonDirectory, \"#{to} is not a directory\" unless File.directory?(to)\n end\n case\n when File.directory?(from_path)\n if to && to != '-'\n if File.exists?(to)\n raise CopyToNonDirectory, \"#{to} is not a directory\" unless File.directory?(to)\n creating_to_directory = false\n else\n creating_to_directory = true\n end\n end\n if options[:recursive]\n Dir.glob(\"#{from_path}/**/*\") do |from_item|\n suffix = File.relative_path(from_item, :relative_to=>from_path)\n suffix = File.join(from, suffix) unless creating_to_directory\n target_dir = File.dirname(File.join(to, suffix))\n FileUtils.mkdir_p(target_dir)\n if File.directory?(from_item)\n new_directory = File.join(target_dir,File.basename(from_item))\n if File.exists?(new_directory)\n raise CopyToNonDirectory \"Can't copy directory #{from_item } to non-directory #{new_directory}\" \\\n unless File.directory?(new_directory)\n else\n FileUtils.mkdir(new_directory)\n end\n else\n cp_single_file(options.merge(:from=>from_item, :to=>target_dir + '/'))\n end\n end\n else\n if options[:tolerant]\n STDERR.puts \"cp: Skipping directory #{from}\" unless options[:quiet]\n else\n raise CopyDirectoryNonRecursive, \"Can't non-recursively copy directory #{from}\"\n end\n end\n when File.exists?(from_path)\n cp_single_file(options.merge(:from=>from_path))\n else\n raise CopyMissingFromFile, \"#{from} does not exist\"\n end\n end",
"def copy_options(options)\n copy_options = { can_copy: false, ancestor_exist: false, locked: false }\n\n destination = copy_destination options\n to_path = join_paths @root_dir, destination\n to_path_exists = File.exist? to_path\n\n copy_options[:ancestor_exist] = File.exist? parent_path destination\n copy_options[:locked] = can_copy_locked_option to_path, to_path_exists\n copy_options = can_copy_option copy_options, options, to_path_exists\n copy_options\n end",
"def copy_files(from, to, options={})\n exceptions = options[:except] || []\n\n puts \"Copying files #{from} => #{to}...\" if ENV['VERBOSE']\n\n Dir[\"#{from}/**/*\"].each do |f|\n next unless File.file?(f)\n next if exceptions.include?(File.basename(f))\n\n target = File.join(to, f.gsub(/^#{Regexp.escape from}/, ''))\n\n FileUtils.mkdir_p File.dirname(target)\n puts \"%20s => %-20s\" % [f, target] if ENV['VERBOSE']\n FileUtils.cp f, target\n end\nend",
"def cp_r(src,dst)\n src_root = Pathname.new(src)\n FileUtils.mkdir_p(dst, :verbose => VERBOSE) unless File.exists? dst\n Dir[\"#{src}/**/**\"].each do |abs_path|\n src_path = Pathname.new(abs_path)\n rel_path = src_path.relative_path_from(src_root)\n dst_path = \"#{dst}/#{rel_path.to_s}\"\n \n next if abs_path.include? '.svn'\n \n if src_path.directory?\n FileUtils.mkdir_p(dst_path, :verbose => VERBOSE)\n elsif src_path.file?\n FileUtils.cp(abs_path, dst_path, :verbose => VERBOSE)\n end\n end\nend",
"def safe_cp(from, to, owner, group, cwd = '', include_paths = [], exclude_paths = [])\n credentials = ''\n credentials += \"-o #{owner} \" if owner\n credentials += \"-g #{group} \" if group\n excludes = find_command_excludes(from, cwd, exclude_paths).join(' ')\n\n copy_files = proc do |from_, cwd_, path_ = ''|\n cwd_ = File.expand_path(File.join('/', cwd_))\n \"if [[ -d #{File.join(from_, cwd_, path_)} ]]; then \" \\\n \"#{dimg.project.find_path} #{File.join(from_, cwd_, path_)} #{excludes} -type f -exec \" \\\n \"#{dimg.project.bash_path} -ec '#{dimg.project.install_path} -D #{credentials} {} \" \\\n \"#{File.join(to, '$(echo {} | ' \\\n \"#{dimg.project.sed_path} -e \\\"s/#{File.join(from_, cwd_).gsub('/', '\\\\/')}//g\\\")\")}' \\\\; ;\" \\\n 'fi'\n end\n\n commands = []\n commands << [dimg.project.install_path, credentials, '-d', to].join(' ')\n commands.concat(include_paths.empty? ? Array(copy_files.call(from, cwd)) : include_paths.map { |path| copy_files.call(from, cwd, path) })\n commands << \"#{dimg.project.find_path} #{to} -type d -exec \" \\\n \"#{dimg.project.bash_path} -ec '#{dimg.project.install_path} -d #{credentials} {}' \\\\;\"\n commands.join(' && ')\n end",
"def copy_files(source_path, destination_path, directory)\n source, destination = File.join(directory, source_path), File.join(Rails.root, destination_path)\n FileUtils.mkdir(destination) unless File.exist?(destination)\n FileUtils.cp_r(Dir.glob(source+'/*.*'), destination)\nend",
"def cp_r(src, dest, options = {})\r\n fu_check_options options, :preserve, :noop, :verbose\r\n fu_output_message \"cp -r#{options[:preserve] ? 'p' : ''} #{[src,dest].flatten.join ' '}\" if options[:verbose]\r\n return if options[:noop]\r\n\r\n fu_each_src_dest(src, dest) do |s,d|\r\n if File.directory?(s)\r\n fu_copy_dir s, d, '.', options[:preserve]\r\n else\r\n fu_p_copy s, d, options[:preserve]\r\n end\r\n end\r\n end",
"def copy(options)\n destination = copy_destination options\n to_path = join_paths @root_dir, destination\n to_path_exists = File.exist? to_path\n\n preserve_existing = false? options[:overwrite]\n\n copy_resource_to_path to_path, preserve_existing\n copy_pstore_to_path to_path, preserve_existing\n\n to_path_exists\n end",
"def execute\n\n copiedCounter = 0\n failedCounter = 0\n skippedCounter = 0\n \n # traverse all srcfiles\n FiRe::filesys.find(@source) { |srcItem|\n \n # give some feedback\n FiRe::log.info \"searching #{srcItem}...\" if FiRe::filesys.directory?(srcItem)\n \n # skip this subtree if it matches ignored-items\n FiRe::filesys.prune if ignore?(srcItem) \n \n # transform srcpath to destpath\n destItem = srcItem.gsub(@source, @destination)\n\n # do not copy if item already exists and looks OK\n if needCopy(destItem,srcItem)\n copyWentWell = copyItem(srcItem, destItem)\n copiedCounter += 1 if copyWentWell\n failedCounter += 1 if !copyWentWell\n else\n skippedCounter += 1 \n end\n \n }\n \n # give some feedback\n FiRe::log.info \"copied #{copiedCounter} items, while #{failedCounter} items failed. #{skippedCounter} items did not need to be copied today.\"\n\n end",
"def copy(target, copied_folder = nil)\n new_folder = self.dup\n new_folder.parent = target\n new_folder.save!\n\n copied_folder = new_folder if copied_folder.nil?\n\n self.assets.each do |assets|\n assets.copy(new_folder)\n end\n\n self.children.each do |folder|\n unless folder == copied_folder\n folder.copy(new_folder, copied_folder)\n end\n end\n new_folder\n end",
"def copy(dest_path, overwrite = false, depth = nil)\n NotImplemented\n end",
"def prepare_copy_folders\n return if config[:copy_folders].nil?\n\n info(\"Preparing to copy specified folders to #{sandbox_module_path}.\")\n kitchen_root_path = config[:kitchen_root]\n config[:copy_folders].each do |folder|\n debug(\"copying #{folder}\")\n folder_to_copy = File.join(kitchen_root_path, folder)\n copy_if_src_exists(folder_to_copy, sandbox_module_path)\n end\n end",
"def markToCopy(destinationDirectory)\n #N Without this we won't remember that the file is to be copied to the destination directory\n @copyDestination = destinationDirectory\n end",
"def cp_r(src, dest, options = {})\r\n fu_check_options options, OPT_TABLE['cp_r']\r\n fu_output_message \"cp -r#{options[:preserve] ? 'p' : ''}#{options[:remove_destination] ? ' --remove-destination' : ''} #{[src,dest].flatten.join ' '}\" if options[:verbose]\r\n return if options[:noop]\r\n options[:dereference_root] = true unless options.key?(:dereference_root)\r\n fu_each_src_dest(src, dest) do |s, d|\r\n copy_entry s, d, options[:preserve], options[:dereference_root], options[:remove_destination]\r\n end\r\n end",
"def cp_r(src, dest, options = {})\r\n fu_check_options options, OPT_TABLE['cp_r']\r\n fu_output_message \"cp -r#{options[:preserve] ? 'p' : ''}#{options[:remove_destination] ? ' --remove-destination' : ''} #{[src,dest].flatten.join ' '}\" if options[:verbose]\r\n return if options[:noop]\r\n options[:dereference_root] = true unless options.key?(:dereference_root)\r\n fu_each_src_dest(src, dest) do |s, d|\r\n copy_entry s, d, options[:preserve], options[:dereference_root], options[:remove_destination]\r\n end\r\n end",
"def copy(copydirs)\n unless path(:source) == path(:destination)\n copydirs = copydirs.split(',') if copydirs.is_a? String\n abort(\"Export filter can't copy #{p option(:copydirs)}\") unless copydirs.is_a? Array\n\n copydirs.each do |src|\n dest_subdirs = src[/\\/\\/(.*)/,1] # regex returns any part of src after '//' separator\n src.gsub!('//','/') # collapse '//' separator in source path\n dest = path(:destination).dup # destination path \n dest << '/'+dest_subdirs if dest_subdirs # append any destination subdirectories\n src.insert(0,path(:source)+'/') # prepend source directory\n src << '*' if src[-1,1] == '/' # append '*' when copying directory contents\n log(\"copying '#{src}' to '#{dest}'\")\n FileUtils.mkdir_p(dest) # ensure dest intermediate dirs exist\n FileUtils.cp_r(Dir[src],dest,preserve: true) # Dir globs '*' added above\n end\n end\n end",
"def copy_file_to_output(source, destination)\n d = dir(File.join(\"output\", destination))\n FileUtils.copy source, d\n @touchedfiles << undir(d)\n end",
"def check_directories\n if File.exist?(source_dir)\n @source_dir = source_dir\n else\n raise DirectoryNotExist, \"Directory not exist\" \n end\n if File.exist?(destination_dir)\n @destination_dir = destination_dir\n else\n raise DirectoryNotExist, \"Directory not exist\" \n end \n end",
"def copy(src,target)\n mkdir_p target if ! File.exist?(target)\n sh 'cp ' + src + '/* ' + target\nend",
"def copy(destdir)\n # Make sure destination is a directory\n File.directory? destdir or raise ArgumentError, \"#{destdir} is not a directory\"\n # Go through files in sorted order\n num_files = self.files.length()\n # These are the files that didn't get copied to the destination dir\n uncopied = []\n self.files.each_index do |i|\n fe = self.files[i]\n # This is the destination filename\n dest = File.join(destdir, fe.archive_filename)\n # If @prune_leading_dir=true, then all files lack the leading\n # directories, so we need to prepend them.\n if @prune_leading_dir\n src = Pathname.new(@dir) + fe.archive_filename\n else\n src = fe.archive_filename\n end\n HDB.verbose and puts \"Copying (##{i+1}/#{num_files}) #{src} to #{dest}\"\n begin\n # Try and copy f to dest\n # NOTE: FileUtils.copy_entry does not work for us since it operates recursively\n # NOTE: FileUtils.copy only works on files\n self.copy_entry(src, dest)\n rescue Errno::ENOSPC\n HDB.verbose and puts \"... out of space\"\n # If the source was a file, we might have a partial copy.\n # If the source was not a file, copying it is likely atomic.\n if File.file?(dest)\n begin\n File.delete(dest)\n rescue Errno::ENOENT\n # None of the file was copied.\n end\n end\n uncopied.push(fe)\n # TODO: This may happen if destination dir doesn't exist\n rescue Errno::ENOENT\n # Src file no longer exists (was removed) - remove from\n # FileSet, as if out of space.\n HDB.verbose and puts \"... deleted before I could copy it!\"\n uncopied.push(fe)\n end\n end\n self.subtract!(uncopied)\n end",
"def copy_if_src_exists(src_to_validate, destination)\n unless Dir.exist?(src_to_validate)\n info(\"The path #{src_to_validate} was not found. Not copying to #{destination}.\")\n return\n end\n\n info(\"Moving #{src_to_validate} to #{destination}\")\n unless Dir.exist?(destination)\n FileUtils.mkdir_p(destination)\n debug(\"Folder '#{destination}' created.\")\n end\n FileUtils.mkdir_p(File.join(destination, \"__bugfix\"))\n FileUtils.cp_r(src_to_validate, destination, preserve: true)\n end",
"def gather\n if File.exist?(@location_dir) && File.directory?(@location_dir)\n if Dir.glob(File.join(@location_dir, '*')).size > 0 # avoid creating the dest directory if the source dir is empty\n unless File.exists? @destination_dir\n FileUtils.mkpath @destination_dir\n end\n @files.each do |f|\n Dir.glob(File.join(@location_dir, f)).each do |file|\n FileUtils.cp_r file, @destination_dir\n end\n end\n end\n else\n puts \"Error: #{@location_dir}, doesn't exist or not a directory\"\n end\n end",
"def copy_file_if_missing(src, dest, opt={})\n unless File.exists? dest\n touch_directory File.dirname(dest), opt\n FileUtils.cp src, dest\n STDOUT.write \"Created #{dest.relative_to_project_root}\\n\".color(:green) unless opt[:quiet]\n end\n end",
"def cp_with_mkdir(src, dst, owner = nil, mode = nil)\n mkdir_if_necessary(File.dirname(dst))\n cp(src, dst, owner, mode)\n end",
"def cp_lr(src, dest, noop: nil, verbose: nil,\n dereference_root: true, remove_destination: false)\n fu_output_message \"cp -lr#{remove_destination ? ' --remove-destination' : ''} #{[src,dest].flatten.join ' '}\" if verbose\n return if noop\n fu_each_src_dest(src, dest) do |s, d|\n link_entry s, d, dereference_root, remove_destination\n end\n end",
"def copy(source_repo_id, destination_repo_id, optional = {})\n criteria = {:type_ids => [content_type], :filters => {}}\n criteria[:filters]['association'] = {'unit_id' => {'$in' => optional[:ids]}} if optional[:ids]\n criteria[:filters] = optional[:filters] if optional[:filters]\n criteria[:fields] = {:unit => optional[:fields]} if optional[:fields]\n\n payload = {:criteria => criteria}\n payload[:override_config] = optional[:override_config] if optional.key?(:override_config)\n\n if optional[:copy_children]\n payload[:override_config] ||= {}\n payload[:override_config][:recursive] = true\n end\n\n Runcible::Extensions::Repository.new(self.config).unit_copy(destination_repo_id, source_repo_id, payload)\n end",
"def copy_dir(origin_path, dest_path)\n \n p origin_path if $DEBUG\n\n real_dir = get_non_linked_dir_path_for_path(origin_path)\n \n unless File.exist?(dest_path) and File.directory?(dest_path) then\n \n Dir.mkdir(dest_path)\n \n end\n \n Dir.foreach(real_dir) do |f|\n \n next if f == \".\" or f == \"..\"\n \n full_path= File.join(real_dir, f)\n \n #check if this is a hard link to a directory\n if File.exist?(full_path) and (not File.directory?(full_path)) and File.stat(full_path).nlink > @min_link_count then\n full_path = get_non_linked_dir_path_for_path(full_path)\n end\n \n if File.directory?(full_path) then\n copy_dir(full_path, File.join(dest_path, f))\n else\n \n if File.exist?(full_path) and not File.symlink?(full_path) then\n \n FileUtils.cp(full_path, dest_path)\n \n end\n \n end\n \n end\n \n nil\n \n end",
"def copy(dest, overwrite = false)\n# if(dest.path == path)\n# Conflict\n# elsif(stat.directory?)\n# dest.make_collection\n# FileUtils.cp_r(\"#{file_path}/.\", \"#{dest.send(:file_path)}/\")\n# OK\n# else\n# exists = File.exists?(file_path)\n# if(exists && !overwrite)\n# PreconditionFailed\n# else\n# open(file_path, \"rb\") do |file|\n# dest.write(file)\n# end\n# exists ? NoContent : Created\n# end\n# end\n\n # ディレクトリなら末尾に「/」をつける。\n # (dstにもともと「/」が付いているかどうか、クライアントに依存している)\n # CarotDAV : 「/」が付いていない\n # TeamFile : 「/」が付いている\n dest.collection! if collection?\n\n src = @bson['filename']\n dst = dest.file_path\n exists = nil\n\n @collection.find({:filename => /^#{Regexp.escape(src)}/}).each do |bson|\n src_name = bson['filename']\n dst_name = dst + src_name.slice(src.length, src_name.length)\n\n exists = @collection.find_one({:filename => dst_name}) rescue nil\n\n return PreconditionFailed if (exists && !overwrite && !collection?)\n\n @filesystem.open(src_name, \"r\") do |src|\n @filesystem.open(dst_name, \"w\") do |dst|\n dst.write(src) if src.file_length > 0\n end\n end\n\n @collection.remove(exists) if exists\n end\n\n collection? ? Created : (exists ? NoContent : Created)\n end",
"def notify_file_cp(src, dst)\r\n if @files.key?(src)\r\n @files[dst] = @files[src].clone\r\n else\r\n @files[src] = { exist: true }\r\n @files[dst] = { exist: true }\r\n end\r\n register_file_in_dirs(dst)\r\n end",
"def mirror_dirs (source_dir, target_dir)\n # Skip hidden root source dir files by default.\n source_files = Dir.glob File.join(source_dir, '*')\n case RUBY_PLATFORM\n when /linux|darwin/ then\n source_files.each { | source_file | sh 'cp', '-a', source_file, target_dir }\n else\n cp_r source_files, target_dir, :preserve => true\n end\nend",
"def cp(src, dst, **_opts)\n full_src = full_path(src)\n full_dst = full_path(dst)\n\n mkdir_p File.dirname(full_dst)\n sh! %(cp -a -f #{Shellwords.escape(full_src)} #{Shellwords.escape(full_dst)})\n rescue CommandError => e\n e.status == 1 ? raise(BFS::FileNotFound, src) : raise\n end",
"def copy(source, destination_path)\n # TODO: Honor file mode\n\n source = Pathname.new(source) unless source.is_a?(Pathname)\n random = random_dir\n\n # Add Dockerfile instruction\n if source.directory?\n self << 'ADD ' + random + ' ' + destination_path\n files = [ [ source, random ] ]\n else\n self << 'ADD ' + random + '/' + source.basename.to_s + ' ' + destination_path\n files = [ [ source, random + '/' ] ]\n end\n\n # Create directory for this instruction\n tar.mkdir(random, 750)\n\n # Add all the files recursively\n while !files.empty? do\n source, destination_path = files.shift\n\n # Directory\n if source.directory?\n source.each_entry do |child|\n next if child.fnmatch?('..') or child.fnmatch?('.')\n @tar.mkdir(\"#{destination_path}/#{child}\", 0750) if child.directory?\n files << [ source + child, \"#{destination_path}/#{child}\" ]\n end\n\n # File\n elsif source.file?\n # If we are adding 'file.txt' to 'dest/': we need to append filename\n destination_path += source.basename.to_s if destination_path.end_with?('/')\n\n # Add file copy\n @tar.add_file(destination_path, 0640) do |out_stream|\n in_stream = source.open('r')\n IO.copy_stream(in_stream, out_stream)\n end\n end\n end\n end",
"def copy_dir(src, dest)\n output = `rsync -r --exclude='.svn' --exclude='.git' --exclude='.gitignore' --filter=':- .gitignore' 2>&1 #{Shellwords.escape(src.to_s)}/ #{Shellwords.escape(dest.to_s)}`\n [output, $?]\n end",
"def recursive_copy(path, to: nil)\n path = Pathname(path)\n to = Pathname(to) if to\n\n if path.to_s =~ %r{\\.\\./} || (to && to.to_s =~ %r{\\.\\./})\n fail StandardError, \"Recursive copy parameters cannot contain '/../'\"\n end\n\n if path.relative?\n parent = root_path\n else\n parent, path = path.split\n end\n\n target = work_path\n target /= to if to\n\n tar_cf_cmd = [\"tar\", \"cf\", \"-\", \"-h\", \"-C\", parent, path].map(&:to_s)\n tar_xf_cmd = [\"tar\", \"xf\", \"-\", \"-C\", target].map(&:to_s)\n\n IO.popen(tar_cf_cmd) do |cf|\n IO.popen(tar_xf_cmd, \"w\") do |xf|\n xf.write cf.read\n end\n\n fail StandardError, \"Error running #{tar_xf_cmd.join(\" \")}\" unless $?.success?\n end\n\n fail StandardError, \"Error running #{tar_cf_cmd.join(\" \")}\" unless $?.success?\n end",
"def copy(dest_path, overwrite, depth = nil)\n\n is_new = true\n\n dest = new_for_path dest_path\n unless dest.parent.exist? and dest.parent.collection?\n return Conflict\n end\n\n if dest.exist?\n if overwrite\n FileUtils.rm_r dest.file_path, secure: true\n else\n return PreconditionFailed\n end\n is_new = false\n end\n\n if collection?\n\n if request.depth == 0\n Dir.mkdir dest.file_path\n else\n FileUtils.cp_r(file_path, dest.file_path)\n end\n\n else\n\n FileUtils.cp(file_path, dest.file_path.sub(/\\/$/, ''))\n FileUtils.cp(prop_path, dest.prop_path) if ::File.exist? prop_path\n\n end\n\n is_new ? Created : NoContent\n end",
"def perform_file_copy\n\t\tretrieve_target_dir do |target_dir|\n\t\t\tFileUtils.mkdir_p target_dir\n\t\t\tcopy_depdencies_to target_dir\n\t\tend\t\n\tend",
"def cp(src, dest)\n unless dest.dirname.exist?\n LOG.info \"MKDIR: #{dest.dirname}\"\n FileUtils.mkdir_p(dest.dirname)\n end\n\n LOG.info \"COPY: #{src} #{dest}\"\n FileUtils.cp_r(src, dest)\n end",
"def copy(src, dst)\n\t\tFileUtils.cp_r(src, dst)\n\t\ttrue\n\trescue Errno::ENOENT\n\t\traise Rush::DoesNotExist, File.dirname(dst)\n\trescue RuntimeError\n\t\traise Rush::DoesNotExist, src\n\tend",
"def copy(src, dst)\n\t\tFileUtils.cp_r(src, dst)\n\t\ttrue\n\trescue Errno::ENOENT\n\t\traise Rush::DoesNotExist, src unless File.exist?(src)\n\t\traise Rush::DoesNotExist, File.dirname(dst)\n\tend",
"def copy_assets src, dest, inclusive=true, missing='exit'\n unless File.file?(src)\n unless inclusive then src = src + \"/.\" end\n end\n src_to_dest = \"#{src} to #{dest}\"\n unless (File.file?(src) || File.directory?(src))\n case missing\n when \"warn\"\n @logger.warn \"Skipping migrate action (#{src_to_dest}); source not found.\"\n return\n when \"skip\"\n @logger.debug \"Skipping migrate action (#{src_to_dest}); source not found.\"\n return\n when \"exit\"\n @logger.error \"Unexpected missing source in migrate action (#{src_to_dest}).\"\n raise \"MissingSourceExit\"\n end\n end\n @logger.debug \"Copying #{src_to_dest}\"\n begin\n FileUtils.mkdir_p(dest) unless File.directory?(dest)\n if File.directory?(src)\n FileUtils.cp_r(src, dest)\n else\n FileUtils.cp(src, dest)\n end\n @logger.info \"Copied #{src} to #{dest}.\"\n rescue Exception => ex\n @logger.error \"Problem while copying assets. #{ex.message}\"\n raise\n end\nend",
"def cp_r(src, dest, preserve: nil, noop: nil, verbose: nil,\n dereference_root: true, remove_destination: nil)\n fu_output_message \"cp -r#{preserve ? 'p' : ''}#{remove_destination ? ' --remove-destination' : ''} #{[src,dest].flatten.join ' '}\" if verbose\n return if noop\n fu_each_src_dest(src, dest) do |s, d|\n copy_entry s, d, preserve, dereference_root, remove_destination\n end\n end",
"def copy(source, destination, **options)\n ensure_same_node(:copy, [source, destination]) do |node|\n node.copy(source, destination, **options)\n end\n end",
"def copy_to(destination, name=nil)\n parent = {'parent' => {'id' => destination.id}}\n parent.merge!('name' => name) if name\n\n RubyBox::Folder.new(@session, post(folder_method(:copy), parent))\n end",
"def cp srcpath, dstpath\n end",
"def copy_files(wildcard, dest_dir)\n for_matching_files(wildcard, dest_dir) { |from, to| copy(from, to) }\n end",
"def copy_files(wildcard, dest_dir)\n for_matching_files(wildcard, dest_dir) { |from, to| copy(from, to) }\n end",
"def doAllCopyOperations(dryRun)\n #N Without this, the copy operations won't be executed\n doCopyOperations(@sourceContent, @destinationContent, dryRun)\n end",
"def cp(source, destination)\n # possibly helpful pieces of information\n\n # if both fs's are the same class a \"cp\" will work in any case\n if @source.class.to_s == @dest.class.to_s\n @source.cp(source, destination)\n return\n end\n\n if same_node?\n case @dest.class.to_s\n when \"MoveIt::FileSystem::Hdfs\"\n @dest.hadoop_fs(\"-copyFromLocal #{source} #{destination}\")\n else\n raise \"cp from same node with different classses is not complete: #{@source.class.to_s} to #{@dest.class.to_s}\"\n end\n else\n raise \"cp from different nodes via proxy is not complete\"\n end\n\n # possible sources:\n # * s3\n # * hdfs\n # * posix\n\n # if same_node?\n # else\n # # tricky!\n # end\n end",
"def copy_to(target)\n target.parent.mkdirs\n factory.system.copy_dir(@path, target.path)\n end",
"def copy_with_path(src, dst)\n\tsrc_folder = File.basename(File.dirname(src))\n\tnewpath = (dst + src_folder)\n\tFileUtils.mkdir_p(newpath)\n \tFileUtils.cp(src, newpath)\nend",
"def copy_files\n source_dir = Item.new(Path.new(params[:source]))\n dest_dir = Item.new(Path.new(params[:dest]))\n type = params[:type]\n response = {}\n response[:source_dir] = source_dir\n response[:dest_dir] = dest_dir\n if source_dir.copy_files_to(dest_dir, type)\n response[:msg] = \"Success\"\n else\n response[:msg] = \"Fail\"\n end\n render json: response\n end",
"def copy from, to\n add \"cp #{from} #{to}\", check_file(to)\n end",
"def copy_files(srcGlob, targetDir, taskSymbol)\n mkdir_p targetDir\n FileList[srcGlob].each do |f|\n target = File.join targetDir, File.basename(f)\n file target => [f] do |t|\n cp f, target\n end\n task taskSymbol => target\n end\nend",
"def initialize_copy(source)\n super\n\n @files = {}\n @directories = {}\n @parent = nil\n\n source.directories.map(&:dup).each do |new_directory|\n add_directory(new_directory)\n end\n\n source.files.map(&:dup).each do |new_file|\n add_file(new_file)\n end\n end",
"def markSyncOperationsForDestination(destination)\n markCopyOperations(destination)\n destination.markDeleteOptions(self)\n end",
"def cp_if_necessary(src, dst, owner = nil, mode = nil)\n if !File.exists?(dst) || different?(src, dst)\n cp(src, dst, owner, mode)\n true\n end\n end",
"def run\n copy_map = copy_map()\n\n mkpath target.to_s\n return false if copy_map.empty?\n\n copy_map.each do |path, source|\n dest = File.expand_path(path, target.to_s)\n if File.directory?(source)\n mkpath dest\n else\n mkpath File.dirname(dest)\n if @mapper.mapper_type\n mapped = @mapper.transform(File.open(source, 'rb') { |file| file.read }, path)\n File.open(dest, 'wb') { |file| file.write mapped }\n else # no mapping\n cp source, dest\n end\n end\n File.chmod(File.stat(source).mode | 0200, dest)\n end\n touch target.to_s\n true\n end",
"def copy(destination, file, folder = './downloads')\n FileUtils.mkdir_p(File.dirname(\"#{destination}/#{file}\"))\n FileUtils.cp_r(\"#{folder}/#{file}\", \"#{destination}/#{file}\")\n end",
"def copyLocalToRemoteDirectory(sourcePath, destinationPath, dryRun)\n #N Without this there won't be a description of the copy operation that can be displayed to the user as feedback\n description = \"SCP: copy directory #{sourcePath} to #{user}@#{host}:#{destinationPath}\"\n #N Without this the user won't see the echoed description\n puts description\n #N Without this check, the files will be copied even if it is only meant to be a dry run.\n if not dryRun\n #N Without this, the files won't actually be copied.\n scpConnection.upload!(sourcePath, destinationPath, :recursive => true)\n end\n end",
"def local_copy(source, target)\n FileUtils.mkpath(File.dirname(target))\n FileUtils.copy(source, \"#{target}.in_progress\")\n FileUtils.move(\"#{target}.in_progress\", target)\n end",
"def rel_copy(full_src, rel_dest, opts={})\n \n dest_path = File.dirname(rel_dest)\n \n fname = Pathname.new(full_src).basename\n \n if !File.directory?(dest_path)\n cmd = \"mkdir -p #{dest_path}\"\n \n if !opts[:mock]\n run cmd\n else\n puts \"mocking #{cmd}\"\n end \n end\n \n cmd = \"cp #{full_src} #{dest_path}/#{fname}\"\n \n if !opts[:mock]\n run cmd\n else\n puts \"mocking #{cmd}\"\n end\n\nend",
"def copyLocalFileToRemoteDirectory(sourcePath, destinationPath, dryRun)\n #N Without this, the copy command won't be run at all\n sshAndScp.copyLocalFileToRemoteDirectory(sourcePath, destinationPath, dryRun)\n end",
"def copy\n actionlist = actionlist(:copy, copylist)\n\n if actionlist.empty?\n report_nothing_to_generate\n return\n end\n\n #logger.report_startup(job, output)\n\n mkdir_p(output) unless File.directory?(output)\n\n backup(actionlist) if backup?\n\n Dir.chdir(output) do\n actionlist.each do |action, fname|\n atime = Time.now\n how = __send__(\"#{action}_item\", Pathname.new(fname))\n report_create(fname, how, atime)\n end\n #logger.report_complete\n #logger.report_fixes(actionlist.map{|a,f|f})\n end\n end",
"def copyPreserveSymlinks(sourceFile, targetFolder)\n\n if File.symlink? sourceFile\n\n linkData = File.readlink sourceFile\n\n targetFile = File.join(targetFolder, File.basename(sourceFile))\n\n if File.symlink? target\n\n existingLink = File.readlink targetFile\n\n if linkData == existingLink\n # Already up to date\n return\n end\n end\n\n FileUtils.ln_sf linkData, targetFile\n \n else\n\n # Recursive copy should work for normal files and directories\n FileUtils.cp_r sourceFile, targetFolder, preserve: true\n \n end\nend",
"def cp(from, to, mode: :default, &block)\n target_file = scope.get(from)\n InvalidStore.raise! {!target_file}\n\n dest_dirname = Utils.dir to\n dest_file = scope.get(to)\n dest_dir = scope.get(dest_dirname) || self.mkdir(dest_dirname)\n\n params = make_params :name => Utils.tokenize(to).last,\n :dir_id => dest_dir.try(:id)\n\n resolve_conflict(params, dest_file, mode) do |params, rename|\n copy = File.new target_file.raw_attributes\n copy.update_attributes params\n block.call(copy) if block_given?\n copy\n end\n end",
"def copy_with_path(src, dst, filename)\n FileUtils.mkdir_p(dst)\n FileUtils.cp(src, dst + filename)\nend",
"def recursive_copy_files dirname, record_object\r\n dirs, files = recursive_find_directories_and_files(dirname)\r\n \r\n dirs.each do |dir|\r\n record_object.directory(dir)\r\n end\r\n \r\n files.each do |filename|\r\n record_object.file(filename, filename)\r\n end\r\n end",
"def scan_dir(from_dir, to_dir)\n Dir.foreach(from_dir) do |file|\n from_path = from_dir + File::SEPARATOR + file\n to_path = to_dir + File::SEPARATOR + file\n if file =~ /^\\./\n next\n elsif FileTest.directory?(from_path)\n scan_dir(from_path, to_path) \n elsif file =~ /\\.java$/\n File.makedirs(to_dir)\n output_file = to_path.sub(/\\.java$/, '.cs')\n print \"Translating #{from_path} to #{output_file}\\n\"\n transmogrify(from_path, output_file)\n else\n File.makedirs(to_dir)\n print \"Copying #{from_path} to #{to_path}\\n\"\n File.copy(from_path, to_path)\n end\n end\nend",
"def copy(from, to, options={})\n expanded_to = File.expand_path(to)\n unless options[:force]\n raise FileOverwriteError, \"File #{expanded_to} already exists\" if File.exists?(expanded_to)\n end\n system(['rm', '-rf', expanded_to].shelljoin)\n system(['cp', '-r', File.expand_path(from) + \"/\", expanded_to + \"/\"].shelljoin)\n end",
"def copy(destination)\n return unless @converted\n \n puts \"Generating #{Rails.root}/tmp/images/#{@full}\"\n puts \"Generating #{Rails.root}/tmp/images/#{@icon}\"\n \n FileUtils.cp(\"#{Rails.root}/tmp/images/#{@full}\", \n \"#{destination}/#{@full}\")\n puts \"Moving #{destination}/#{@full}\"\n \n FileUtils.chmod(0644, \"#{destination}/#{@full}\")\n FileUtils.cp(\"#{Rails.root}/tmp/images/#{@icon}\",\n \"#{destination}/#{@icon}\")\n puts \"Moving #{destination}/#{@icon}\"\n FileUtils.chmod(0644, \"#{destination}/#{@icon}\")\n end",
"def copy(source, destination, **options); end",
"def copyfile from, to\n FileUtils.mkdir_p File.dirname to\n cp from, to\n end",
"def copy_files\n message \"Checking for existing #{@@app_name.capitalize} install in #{install_directory}\"\n files_yml = File.join(install_directory,'installer','files.yml')\n old_files = read_yml(files_yml) rescue Hash.new\n \n message \"Reading files from #{source_directory}\"\n new_files = sha1_hash_directory_tree(source_directory)\n new_files.delete('/config/database.yml') # Never copy this.\n \n # Next, we compare the original install hash to the current hash. For each\n # entry:\n #\n # - in new_file but not in old_files: copy\n # - in old files but not in new_files: delete\n # - in both, but hash different: copy\n # - in both, hash same: don't copy\n #\n # We really should add a third hash (existing_files) and compare against that\n # so we don't overwrite changed files.\n\n added, changed, deleted, same = hash_diff(old_files, new_files)\n \n if added.size > 0\n message \"Copying #{added.size} new files into #{install_directory}\"\n added.keys.sort.each do |file|\n message \" copying #{file}\"\n copy_one_file(file)\n end\n end\n \n if changed.size > 0\n message \"Updating #{changed.size} files in #{install_directory}\"\n changed.keys.sort.each do |file|\n message \" updating #{file}\"\n copy_one_file(file)\n end\n end\n \n if deleted.size > 0\n message \"Deleting #{deleted.size} files from #{install_directory}\"\n \n deleted.keys.sort.each do |file|\n message \" deleting #{file}\"\n rm(File.join(install_directory,file)) rescue nil\n end\n end\n \n write_yml(files_yml,new_files)\n end",
"def ensure_not_in_dest\n dest_pathname = Pathname.new(dest)\n Pathname.new(source).ascend do |path|\n if path == dest_pathname\n raise Errors::FatalException,\n \"Destination directory cannot be or contain the Source directory.\"\n end\n end\n end",
"def cp(options={})\n from = options[:from]\n from = '*' if from == '.'\n from_list = glob(*from).to_a\n to = options[:to]\n to_path = to\n to_path = expand_path(to_path, :from_wd=>true) unless to.nil? || to == '-'\n if from_list.size == 1\n cp_single_file_or_directory(options.merge(:from=>from_list.first, :to=>to_path))\n else\n if to && to != '-'\n to += '/' unless to =~ %r{/$/}\n end\n from_list.each do |from_item|\n cp_single_file_or_directory(options.merge(:from=>from_item, :to=>to_path))\n end\n end\n end",
"def perform_sync(source, destination, options)\n new_files, new_files_destination = get_new_files_to_sync(source, destination, options)\n sync_new_files(source, new_files, new_files_destination, options)\n cleanup_files_we_dont_want_to_keep(source, new_files, new_files_destination) unless options[:keep].nil?\n end",
"def copy(from_path, to_path, ctype=nil, recursive=false, replace=false)\n if to_path.end_with? '/'\n # copy into to_path, not to to_path\n to_path = File.join(to_path, File.basename(from_path))\n end\n\n count = 0\n prune = recursive ? nil : 1\n @content_tree.with_subtree(from_path, ctype, prune) do |node|\n ntype = node.node_type\n basename = node.path.split(from_path, 2)[1]\n dest = basename.empty? ? to_path : File.join(to_path, basename)\n if (! replace) and (@content_tree.exist? dest, ntype)\n raise NodeExists, \"'#{dest}' exists [#{ntype}]\"\n end\n new_node = @content_tree.clone(node, dest)\n copy_doc_resources(from_path, to_path) if ntype == :document\n copy_metadata(node.path, dest, ntype)\n notify(EVENT_CLONE, node.path, ctype, dest)\n count += 1\n end\n\n count\n end",
"def copyLocalToRemoteDirectory(sourcePath, destinationPath, dryRun)\n #N Without this, the copy command won't be run at all\n sshAndScp.copyLocalToRemoteDirectory(sourcePath, destinationPath, dryRun)\n end",
"def copy_to_folder=(value)\n @copy_to_folder = value\n end",
"def copy_file!(f, target)\n # directory?\n if File.directory?(f)\n if File.directory?(target)\n done = 'exists'.green\n else\n FileUtils.mkdir_p target\n done = 'created'.bold.green\n end\n else\n if newer?(f, target)\n target_dir = File.dirname(target)\n FileUtils.mkdir_p target_dir unless File.directory?(target_dir)\n FileUtils.copy f, target\n done = 'copied'.bold.green\n else\n done = 'keep'.white\n end\n end\n done\n end",
"def copy_folders\r\n %w{_includes _layouts _posts _sass assets}.each do |dir|\r\n directory dir\r\n end\r\n end",
"def calculate_copies\n # no copies if we don't have an ancestor.\n # no copies if we're going backwards.\n # no copies if we're overwriting.\n return {} unless ancestor && !(backwards? || overwrite?)\n # no copies if the user says not to follow them.\n return {} unless @repo.config[\"merge\", \"followcopies\", Boolean, true]\n\n \n dirs = @repo.config[\"merge\", \"followdirs\", Boolean, false]\n # calculate dem hoes!\n copy, diverge = Amp::Graphs::Mercurial::CopyCalculator.find_copies(self, local, remote, ancestor, dirs)\n \n # act upon each divergent rename (one branch renames to one name,\n # the other branch renames to a different name)\n diverge.each {|of, fl| divergent_rename of, fl }\n \n copy\n end",
"def markDeleteOptions(sourceDir)\n #N Without this we can't loop over the immediate sub-directories to determine how each one needs to be marked for deleting\n for dir in dirs\n #N Without this we won't have the corresponding sub-directory in the other directory with the same name as this sub-directory (if it exists)\n sourceSubDir = sourceDir.getDir(dir.name)\n #N Without this check, we won't be able to correctly process a sub-directory based on whether or not one with the same name exists in the other directory\n if sourceSubDir == nil\n #N Without this, this directory won't be deleted, even though it doesn't exist at all in the corresponding source directory\n dir.markToDelete()\n else\n #N Without this, files and directories missing from the other source sub-directory (which does exist) won't get deleted\n dir.markDeleteOptions(sourceSubDir)\n end\n end\n #N Without this we can't loop over the files to determine which ones need to be marked for deleting\n for file in files\n #N Without this we won't known if the corresponding file in the source directory with the same name as this file exists\n sourceFile = sourceDir.getFile(file.name)\n #N Without this check, we will incorrectly delete this file whether or not it exists in the source directory\n if sourceFile == nil\n #N Without this, this file which doesn't exist in the source directory won't get deleted from this directory\n file.markToDelete()\n end\n end\n end",
"def check_dest_dir\n FileUtils.mkdir_p(dest_dir) unless Dir.exist?(dest_dir)\n end",
"def install(source, target, options={})\n nest_opts(options[:backup], :mv => true) do |opts|\n only_if _file?(target) do\n backup target, opts\n end\n end\n \n nest_opts(options[:directory]) do |opts|\n directory File.dirname(target), opts\n end\n \n cp source, target\n chmod options[:mode], target\n chown options[:user], options[:group], target\n\nend",
"def create_copy_task srcGlob, targetDir, taskSymbol\n mkdir_p(targetDir, :verbose => false)\n FileList[srcGlob].each do |f|\n target = File.join(targetDir, File.basename(f))\n file target => [f] do |t|\n cp f, target\n end\n task taskSymbol => target\n end\nend",
"def verify_src_dest_dir_paths\n unless File.exists?(@era_root_dir_path) && File.directory?(@era_root_dir_path)\n STDERR.puts \"Source directory does not exist:\\n '#{@era_root_dir_path}'\"\n exit 2\n end\n if File.exists?(@era_root_dir_path_dest)\n STDERR.puts \"Destination directory or file already exists:\\n '#{@era_root_dir_path_dest}'\"\n exit 3\n end\n end",
"def copy_folder_ind\n create_process(process: \"COPY_FOLDER\")\n end",
"def stage_copy(source_dir)\n test_dir = File.dirname(caller[0])\n stage_clear\n srcdir = File.join(test_dir, source_dir)\n Dir[File.join(srcdir, '*')].each do |path|\n FileUtils.cp_r(path, '.')\n end\n end",
"def process_directory(src, dest, ext = nil)\n src_path = '%s/*.%s' % [File.expand_path(src), ext || '*']\n dest_path = File.expand_path dest\n Dir.glob(src_path) do |file|\n dest_file = File.join(dest_path,File.basename(file))\n process_file(file, dest_file)\n end\n end",
"def move_to!(dest)\n Pow(dest).parent.create_directory\n move_to(dest)\n end",
"def copyPreserveSymlinks(source_file, target_folder)\n if File.symlink? source_file\n\n link_data = File.readlink source_file\n\n target_file = File.join(target_folder, File.basename(source_file))\n\n if File.symlink? target\n\n existing_link = File.readlink target_file\n\n if link_data == existing_link\n # Already up to date\n return\n end\n end\n\n FileUtils.ln_sf link_data, target_file\n\n else\n\n # Recursive copy should work for normal files and directories\n FileUtils.cp_r source_file, target_folder, preserve: true\n\n end\nend"
] | [
"0.7002961",
"0.6833688",
"0.6571331",
"0.6571331",
"0.640944",
"0.63271123",
"0.63205224",
"0.63011503",
"0.6075234",
"0.60031825",
"0.59765774",
"0.5961834",
"0.58510214",
"0.58310795",
"0.58217263",
"0.5815152",
"0.5803611",
"0.5789002",
"0.5783199",
"0.5774021",
"0.5773012",
"0.5771954",
"0.5771954",
"0.5754387",
"0.5744632",
"0.5729899",
"0.5718595",
"0.5715899",
"0.5669154",
"0.5662748",
"0.56567913",
"0.5619576",
"0.55986154",
"0.55941075",
"0.55733943",
"0.55641025",
"0.5534312",
"0.5530442",
"0.5521804",
"0.55073535",
"0.54979104",
"0.5490639",
"0.54889876",
"0.5484137",
"0.54775363",
"0.54767245",
"0.54723436",
"0.5462288",
"0.54421824",
"0.54396874",
"0.54281867",
"0.5427664",
"0.54211146",
"0.54211146",
"0.54170215",
"0.5410463",
"0.54005456",
"0.53962904",
"0.5394201",
"0.5393304",
"0.5375624",
"0.5372174",
"0.5364486",
"0.5354248",
"0.5341794",
"0.5336957",
"0.5334386",
"0.53196186",
"0.5310128",
"0.53065526",
"0.53044623",
"0.5303443",
"0.5293236",
"0.5289184",
"0.5280707",
"0.5277894",
"0.5275387",
"0.527141",
"0.5265891",
"0.52636373",
"0.52595997",
"0.5259059",
"0.5256508",
"0.52523917",
"0.52462125",
"0.5242468",
"0.5236616",
"0.52276826",
"0.5219453",
"0.5212285",
"0.5205669",
"0.5201582",
"0.51974815",
"0.5196127",
"0.5189129",
"0.5182777",
"0.5182408",
"0.51790833",
"0.51790434",
"0.5176598"
] | 0.82695365 | 0 |
Mark delete operations, given that the corresponding source directory exists. For files and directories that don't exist in the source, mark them to be deleted. For subdirectories that do exist, recursively mark the corresponding subdirectory delete operations. N Without this we won't know how to mark which subdirectories and files in this (destination) directory need to by marked for deleting (because they don't exist in the other source directory) | def markDeleteOptions(sourceDir)
#N Without this we can't loop over the immediate sub-directories to determine how each one needs to be marked for deleting
for dir in dirs
#N Without this we won't have the corresponding sub-directory in the other directory with the same name as this sub-directory (if it exists)
sourceSubDir = sourceDir.getDir(dir.name)
#N Without this check, we won't be able to correctly process a sub-directory based on whether or not one with the same name exists in the other directory
if sourceSubDir == nil
#N Without this, this directory won't be deleted, even though it doesn't exist at all in the corresponding source directory
dir.markToDelete()
else
#N Without this, files and directories missing from the other source sub-directory (which does exist) won't get deleted
dir.markDeleteOptions(sourceSubDir)
end
end
#N Without this we can't loop over the files to determine which ones need to be marked for deleting
for file in files
#N Without this we won't known if the corresponding file in the source directory with the same name as this file exists
sourceFile = sourceDir.getFile(file.name)
#N Without this check, we will incorrectly delete this file whether or not it exists in the source directory
if sourceFile == nil
#N Without this, this file which doesn't exist in the source directory won't get deleted from this directory
file.markToDelete()
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def doDeleteOperations(destinationContent, dryRun)\n #N Without this loop, we won't delete all sub-directories or files and directories within sub-directories which have been marked for deletion\n for dir in destinationContent.dirs\n #N Without this check, we would delete directories which have not been marked for deletion (which would be incorrect)\n if dir.toBeDeleted\n #N Without this, we won't know the full path of the remote directory to be deleted\n dirPath = destinationLocation.getFullPath(dir.relativePath)\n #N Without this, the remote directory marked for deletion won't get deleted\n destinationLocation.contentHost.deleteDirectory(dirPath, dryRun)\n else\n #N Without this, files and sub-directories within this sub-directory which are marked for deletion (even though the sub-directory as a whole hasn't been marked for deletion) won't get deleted.\n doDeleteOperations(dir, dryRun)\n end\n end\n #N Without this loop, we won't delete files within this directory which have been marked for deletion.\n for file in destinationContent.files\n #N Without this check, we would delete this file even though it's not marked for deletion (and therefore should not be deleted)\n if file.toBeDeleted\n #N Without this, we won't know the full path of the file to be deleted\n filePath = destinationLocation.getFullPath(file.relativePath)\n #N Without this, the file won't actually get deleted\n destinationLocation.contentHost.deleteFile(filePath, dryRun)\n end\n end\n end",
"def removed_unmarked_paths\n #remove dirs\n dirs_enum = @dirs.each_value\n loop do\n dir_stat = dirs_enum.next rescue break\n if dir_stat.marked\n dir_stat.marked = false # unset flag for next monitoring\\index\\remove phase\n #recursive call\n dir_stat.removed_unmarked_paths\n else\n # directory is not marked. Remove it, since it does not exist.\n write_to_log(\"NON_EXISTING dir: \" + dir_stat.path)\n # remove file with changed checksum\n $local_content_data_lock.synchronize{\n $local_content_data.remove_directory(dir_stat.path, Params['local_server_name'])\n }\n rm_dir(dir_stat)\n end\n end\n\n #remove files\n files_enum = @files.each_value\n loop do\n file_stat = files_enum.next rescue break\n if file_stat.marked\n file_stat.marked = false # unset flag for next monitoring\\index\\remove phase\n else\n # file not marked meaning it is no longer exist. Remove.\n write_to_log(\"NON_EXISTING file: \" + file_stat.path)\n # remove file with changed checksum\n $local_content_data_lock.synchronize{\n $local_content_data.remove_instance(Params['local_server_name'], file_stat.path)\n }\n # remove from tree\n @files.delete(file_stat.path)\n end\n end\n end",
"def delete(*wildcards)\n wildcards.each do |wildcard|\n Dir[wildcard].each do |fn|\n if File.directory?(fn)\n log \"Deleting directory #{fn}\"\n Dir.delete(fn)\n else\n log \"Deleting file #{fn}\"\n File.delete(fn)\n end\n end\n end\n end",
"def delete(*wildcards)\n wildcards.each do |wildcard|\n Dir[wildcard].each do |fn|\n if File.directory?(fn)\n log \"Deleting directory #{fn}\"\n Dir.delete(fn)\n else\n log \"Deleting file #{fn}\"\n File.delete(fn)\n end\n end\n end\n end",
"def delete_source_files source\n dir = Conf::directories\n base = File.join(dir.data)\n source.folders.each do |fold|\n url = File.join(dir.store,source.name.to_s,fold)\n delete_files_from url\n url = File.join(dir.backup,source.name.to_s,fold)\n delete_files_from url\n end\n Logger.<<(__FILE__,\"INFO\",\"Deleted files server & backup for #{source.name.to_s}\")\n end",
"def delete_directory_contents(options)\n Process::Delete::DirectoryContents.delete(options[:directory_path])\n end",
"def destroy\n delete_files_and_empty_parent_directories\n end",
"def deleteT(dir1, dir2)\n\t\tFileUtils.rm_rf Dir.glob(\"#{dir1}*\")\n\t\tFileUtils.rm_rf Dir.glob(\"#{dir2}*\")\n\tend",
"def action_delete\n if (!dir_exists?(@path))\n Chef::Log::info(\"Directory #{ @path } doesn't exist; delete action not taken\")\n else\n converge_by(\"Delete #{ @new_resource }\") do\n @client.delete(@path)\n end\n new_resource.updated_by_last_action(true)\n end\n end",
"def markCopyOperations(destinationDir)\n #N Without this we can't loop over the immediate sub-directories to determine how each one needs to be marked for copying\n for dir in dirs\n #N Without this we won't have the corresponding sub-directory in the other directory with the same name as this sub-directory (if it exists)\n destinationSubDir = destinationDir.getDir(dir.name)\n #N Without this check, we won't be able to correctly process a sub-directory based on whether or not one with the same name exists in the other directory\n if destinationSubDir != nil\n #N Without this, files and directories missing or changed from the other sub-directory (which does exist) won't get copied\n dir.markCopyOperations(destinationSubDir)\n else\n #N Without this, the corresponding missing sub-directory in the other directory won't get updated from this sub-directory\n dir.markToCopy(destinationDir)\n end\n end\n #N Without this we can't loop over the files to determine how each one needs to be marked for copying\n for file in files\n #N Without this we won't have the corresponding file in the other directory with the same name as this file (if it exists)\n destinationFile = destinationDir.getFile(file.name)\n #N Without this check, this file will get copied, even if it doesn't need to be (it only needs to be if it is missing, or the hash is different)\n if destinationFile == nil or destinationFile.hash != file.hash\n #N Without this, a file that is missing or changed won't get copied (even though it needs to be)\n file.markToCopy(destinationDir)\n end\n end\n end",
"def delete\n if (exists?)\n list.each do |children|\n children.delete\n end\n factory.system.delete_dir(@path)\n end\n end",
"def delete_dir_contents(target_dir)\n Find.find(target_dir) do |x|\n if File.file?(x)\n FileUtils.rm(x)\n elsif File.directory?(x) && x != target_dir\n FileUtils.remove_dir(x)\n end\n end\n end",
"def delete\n File.delete fullpath\n dirname = File.dirname(fullpath)\n while dirname != root\n Dir.rmdir(dirname)\n dirname = File.dirname(dirname)\n end\n rescue Errno::ENOTEMPTY\n end",
"def delete_files_and_empty_parent_directories\n style_names = reflection.styles.map{|style| style.name} << :original\n # If the attachment was set to nil, we need the original value\n # to work out what to delete.\n if column_name = reflection.column_name_for_stored_attribute(:file_name)\n interpolation_params = {:basename => record.send(\"#{column_name}_was\")}\n else\n interpolation_params = {}\n end\n style_names.each do |style_name|\n path = interpolate_path(style_name, interpolation_params) or\n next\n FileUtils.rm_f(path)\n begin\n loop do\n path = File.dirname(path)\n FileUtils.rmdir(path)\n end\n rescue Errno::EEXIST, Errno::ENOTEMPTY, Errno::ENOENT, Errno::EINVAL, Errno::ENOTDIR\n # Can't delete any further.\n end\n end\n end",
"def delete_empty(directory) \n log_file(\"[START] running empty folder deletion...\")\n\n dir(directory + '**/*').each do |path|\n if (File.directory?(path) && tree_empty?(path)) then\n log_file(\"This folder is empty and will be deleted: \" + path)\n trash(path)\n end\n end\n log_file(\"[COMPLETE] ...empty folder deletion done.\")\n\nend",
"def markSyncOperationsForDestination(destination)\n markCopyOperations(destination)\n destination.markDeleteOptions(self)\n end",
"def delete_all(*wildcards)\n wildcards.each do |wildcard|\n Dir[wildcard].each do |fn|\n next if ! File.exist?(fn)\n if File.directory?(fn)\n Dir[\"#{fn}/*\"].each do |subfn|\n next if subfn=='.' || subfn=='..'\n delete_all(subfn)\n end\n log \"Deleting directory #{fn}\"\n Dir.delete(fn)\n else\n log \"Deleting file #{fn}\"\n File.delete(fn)\n end\n end\n end\n end",
"def delete_all(*wildcards)\n wildcards.each do |wildcard|\n Dir[wildcard].each do |fn|\n next if ! File.exist?(fn)\n if File.directory?(fn)\n Dir[\"#{fn}/*\"].each do |subfn|\n next if subfn=='.' || subfn=='..'\n delete_all(subfn)\n end\n log \"Deleting directory #{fn}\"\n Dir.delete(fn)\n else\n log \"Deleting file #{fn}\"\n File.delete(fn)\n end\n end\n end\n end",
"def delete_dir!(path)\n # do nothing, because there's no such things as 'empty directory'\n end",
"def create_or_delete_directory(path)\n d = ::Chef::Resource::Directory.new(path, run_context)\n d.recursive(true)\n if new_resource.action == :destroy_all\n d.run_action(:delete)\n else\n d.run_action(:create) unless ::File.exists?(path)\n end\n end",
"def clean_directory(path, types=nil, run_context=nil)\n raise 'clean_directory path must be a non-empty string!' if path.nil? or path.empty?\n types ||= [\n Chef::Resource::File,\n Chef::Resource::Link,\n Chef::Resource::CookbookFile,\n Chef::Resource::RemoteFile,\n Chef::Resource::Template,\n ]\n run_context ||= node.run_context\n\n # find the chef files generated\n chef_files_generated = run_context.resource_collection.select { |r|\n types.include?(r.class) and r.path.start_with?(path)\n }.map { |r| r.path }\n\n # find the fileststem files present\n filesystem_files_present = Dir[\"#{path}/**/*\"].select { |f|\n ::File.file?(f) or ::File.symlink?(f)\n }\n\n # calculate the difference, and remove the extraneous files\n (filesystem_files_present - chef_files_generated).each do |f|\n if ::File.symlink?(f)\n link \"clean_directory: #{f}\" do\n target_file f\n action :delete\n end\n else\n file \"clean_directory: #{f}\" do\n path f\n action :delete\n end\n end\n end\nend",
"def delete_files\n return if id.nil?\n return unless File.exist?(directory_path)\n\n FileUtils.rm_rf(directory_path)\n s3_delete_files\n end",
"def delete_completely(root, resource)\n path = File.join(root, resource.path(identifying_sym))\n FileUtils.rm_rf(path)\n\n # removes the empty directories upward\n (resource.identifiers(identifying_sym).size - 1).times do |t|\n path = File.split(path).first\n begin\n FileUtils.rmdir(path)\n rescue Errno::ENOTEMPTY\n break\n end\n end\n end",
"def delete_dir(path)\n Dir.foreach(@old_base + path) do |fname|\n path_fname = path + fname\n next if fname == '.' || fname == '..' || filter_fname(path_fname)\n type = File.ftype(@old_base + path_fname).to_sym\n delete_dir(path_fname + '/') if type == :directory\n @entries << [path_fname, type, :deleted]\n end\n end",
"def scan_dir(path)\n old_files = dir_entries(@old_base, path)\n new_files = dir_entries(@new_base, path)\n old_files.each do |fname, type|\n unless new_files.has_key?(fname) && new_files[fname] == type\n delete_dir(path + fname + '/') if type == :directory && !@options[:shallow]\n @entries << [path + fname, type, :deleted]\n end\n end\n new_files.each do |fname, type|\n if old_files.has_key?(fname) && old_files[fname] == type\n if type == :directory\n scan_dir(path + fname + '/')\n else\n compare_file(path + fname, type)\n end\n else\n @entries << [path + fname, type, :added]\n add_dir(path + fname + '/') if type == :directory && !@options[:shallow]\n end\n end\n end",
"def remove_superfluous_destination_files\n # join mirror_file and dest_file and delete everything from dest_file which isn't in mirror_file\n # because mirror_file should represent the current state of the source mogile files\n Log.instance.info('Joining destination and mirror tables to determine files that have been deleted from source repo.')\n DestFile.where('mirror_file.dkey IS NULL').joins('LEFT OUTER JOIN mirror_file ON mirror_file.dkey = file.dkey').find_in_batches(batch_size: 1000) do |batch|\n batch.each do |file|\n # Quit if program exit has been requested.\n break if SignalHandler.instance.should_quit\n\n # Delete all files from our destination domain which no longer exist in the source domain.\n begin\n Log.instance.debug(\"key [ #{file.dkey} ] should not exist. Deleting.\")\n @dest_mogile.delete(file.dkey)\n @removed += 1\n @freed_bytes += file.length\n rescue => e\n @failed += 1\n Log.instance.error(\"Error deleting [ #{file.dkey} ]: #{e.message}\\n#{e.backtrace}\")\n end\n end\n\n # Print a summary to the user.\n summarize\n\n # Quit if program exit has been requested.\n return true if SignalHandler.instance.should_quit\n end\n end",
"def erase\n HDB.verbose and puts \"Erasing successfully-copied files\"\n unlinkable = @files.collect do |x|\n f = get_real_filename(x)\n File.directory?(f) or File.symlink?(f)\n end\n # TODO: unlink them now.\n # TODO: rmdir directories, starting with child nodes first\n raise \"erase unimplemented\"\n end",
"def delete_branch\n #we'll get all descendants by level descending order. That way we'll make sure deletion will come from children to parents\n children_to_be_deleted = self.class.find(:all, :conditions => \"id_path like '#{self.id_path},%'\", :order => \"level desc\")\n children_to_be_deleted.each {|d| d.destroy}\n #now delete my self :)\n self.destroy\n end",
"def action_delete\n if @current_resource.exist?\n converge_by \"Delete #{r.path}\" do\n backup unless ::File.symlink?(r.path)\n ::File.delete(r.path)\n end\n r.updated_by_last_action(true)\n load_new_resource_state\n r.exist = false\n else\n Chef::Log.debug \"#{r.path} does not exists - nothing to do\"\n end\n end",
"def clean(id)\n path(id).dirname.ascend do |pathname|\n if pathname.children.empty? && pathname != directory\n pathname.rmdir\n else\n break\n end\n end\n end",
"def remove_folder\n space = Space.accessible_by(@context).find(params[:id])\n ids = Node.sin_comparison_inputs(unsafe_params[:ids])\n\n if space.contributor_permission(@context)\n nodes = Node.accessible_by(@context).where(id: ids)\n\n UserFile.transaction do\n nodes.update(state: UserFile::STATE_REMOVING)\n\n nodes.where(sti_type: \"Folder\").find_each do |folder|\n folder.all_children.each { |node| node.update!(state: UserFile::STATE_REMOVING) }\n end\n\n Array(nodes.pluck(:id)).in_groups_of(1000, false) do |ids|\n job_args = ids.map do |node_id|\n [node_id, session_auth_params]\n end\n\n Sidekiq::Client.push_bulk(\"class\" => RemoveNodeWorker, \"args\" => job_args)\n end\n end\n\n flash[:success] = \"Object(s) are being removed. This could take a while.\"\n else\n flash[:warning] = \"You have no permission to remove object(s).\"\n end\n\n redirect_to files_space_path(space)\n end",
"def delete_root\n Dir.chdir(root) do\n Dir.entries('.').each do |entry|\n next if entry == '.' || entry == '..'\n next if entry == FILES_DIR && task.options.copy_files_with_symlink\n\n begin\n FileUtils.remove_entry_secure(entry)\n rescue\n if task.options.copy_files_with_symlink\n print_title('Cannot automatically empty ' + root + '. Please manually empty this directory (except for ' + root + '/' + FILES_DIR + ') and then hit any key to continue...')\n else\n print_title('Cannot automatically empty ' + root + '. Please manually empty this directory and then hit any key to continue...')\n end\n STDIN.getch\n break\n end\n end\n end\n\n logger.info(\"#{root} content was deleted\")\n end",
"def delete_content_paths\n\n # Delete all the paths with the ancestor as the current id\n ContentPath.delete_all(:ancestor => self.id)\n\n # Delete all the paths with the descendant as the current id\n ContentPath.delete_all(:descendant => self.id)\n end",
"def recurse\n children = (self[:recurse] == :remote) ? {} : recurse_local\n\n if self[:target]\n recurse_link(children)\n elsif self[:source]\n recurse_remote(children)\n end\n\n # If we're purging resources, then delete any resource that isn't on the\n # remote system.\n mark_children_for_purging(children) if self.purge?\n\n # REVISIT: sort_by is more efficient?\n result = children.values.sort { |a, b| a[:path] <=> b[:path] }\n remove_less_specific_files(result)\n end",
"def delete_directory_contents(directory, sftp, level)\n level_print(\"Deleting: \" + directory, level)\n sftp.dir.entries(directory).each do |file|\n begin\n sftp.remove!(directory + \"/\" + file.name)\n level_print(\"Deleted File: \" + file.name, level + 1)\n rescue Net::SFTP::StatusException => e\n delete_directory_contents(directory + \"/\" + file.name, sftp, level + 1)\n sftp.rmdir(directory + \"/\" + file.name)\n level_print(\"Deleted Directory: \" + file.name, level + 1)\n # puts \"Error: \" + e.description\n end\n end\nend",
"def remove_target(target)\n if perms_for(target)[:rm] == false\n @response[:error] ||= 'Some files/directories were unable to be removed'\n @response[:errorData][target.basename.to_s] = \"Access Denied\"\n return\n end\n# create trash folder if it doesn't exist\n trash_dir = File.join(@root,'.trash/')\n FileUtils.mkdir(trash_dir) unless File.exist?(trash_dir)\n# \n begin\n FileUtils.mv(target, trash_dir, :force => true )\n if !target.directory?\n if @options[:thumbs] && (thumbnail = thumbnail_for(target)).file?\n FileUtils.mv(thumbnail, trash_dir, :force => true )\n end\n end\n rescue\n @response[:error] ||= 'Some files/directories were unable to be removed'\n @response[:errorData][target.basename.to_s] = \"Remove failed\"\n end\nend",
"def delete_dir dir, pattern\n puts dir\n puts pattern\n Find.find(dir) do |path|\n if FileTest.directory? path\n # ?. means the ascii char of '.' same as '.'.chr, \".\"[0].chr\n # this is to avoid the directory start with \".\"\n if File.basename(path)[0] == ?.\n Find.prune\n else\n if File.basename(path) =~ pattern\n puts \"remove #{path}.\"\n rm_rf path\n else\n next\n end\n end\n end\n end\nend",
"def delete_entry(path, revision, parent_baton)\n # Print out diffs of deleted files, but not\n # deleted directories\n unless @base_root.dir?('/' + path)\n do_diff(path, nil)\n end\n end",
"def undelete_tree(directory_key)\n check_versioning\n all_versions = s3_bucket.object_versions(prefix: add_prefix(directory_key))\n versions_to_delete = all_versions.select {|version| version.is_latest and delete_marker?(version)}\n Parallel.each(versions_to_delete, in_threads: 10) do |version|\n delete_version(version.key, version.version_id)\n end\n end",
"def remove_paths(*args)\n args.each do |item|\n if File.directory?(item)\n puts \"#{item} is a path. removing it now.\"\n # set :noop => true to do a dry run\n FileUtils.rm_rf(item, :verbose => true)\n else\n puts \"#{item} doesn't exist or isn't a directory.\"\n end\n end\n end",
"def move_to_trash\n source_dir = Item.new(Path.new(params[:source_dir]))\n dest_dir_path = Pathname.new(source_dir.path.dirname.to_s + \"/RESTARTED/RESTARTED_\" + source_dir.path.basename.to_s)\n\n dest_dir_string = dest_dir_path.to_s\n dir_found = false\n i = 1\n while(!dir_found)\n dest_dir = Item.new(Path.new(dest_dir_string))\n if dest_dir.exist?\n dest_dir_string = dest_dir_path.to_s + \"_#{i}\"\n i += 1\n else\n dir_found = true\n end\n end\n\n response = {}\n if !source_dir.exist?\n response[:msg] = \"No folder at location, nothing to do\"\n render json: response, status: 200\n elsif source_dir.move_to(dest_dir)\n response[:msg] = \"Success\"\n render json: response, status: 200\n else\n response[:msg] = \"Fail\"\n render json: response, status: 422\n end\n end",
"def delete_folders(directory) \n log_file(\"[START] running folder deletion...\")\n dir(directory + '**/*').each do |path|\n if (File.directory?(path) && DELETE_FOLDERS.include?(File.basename(path))) then\n log_file(\"This folder will be deleted: \" + path)\n puts `rm -rf \"#{path}\"`\n end\n end\n log_file(\"[COMPLETE] ...folder deletion done.\")\nend",
"def delete_tree(key)\n if directory_key?(key)\n Parallel.each(subtree_keys(key), in_threads: 10) do |content_key|\n delete_content(content_key)\n end\n else\n delete_content(key)\n end\n end",
"def remove_structure\n rm_rf target_dir\n end",
"def delete\n if processable? or unset?\n dir.delete\n else\n raise JobError.cannot_delete(@id, state)\n end\n end",
"def rmdir() Dir.rmdir(path) end",
"def clean(&block)\n @target.files.each do |object|\n unless @source.files.include? object.key\n block.call(object)\n object.destroy\n end\n end\n end",
"def delete_file(path, &b)\n path = Pathname.new(path).cleanpath\n dir = path.dirname\n filename = path.basename\n if fs.directory?(dir) and fs.entries(dir).include?(filename)\n fs.delete_file(path)\n yield true\n else\n yield false\n end\n end",
"def clean\n if File.exist?(@destination)\n Monolith.formatter.clean(@cookbook, @destination)\n FileUtils.rm_rf(@destination)\n true\n else\n rel_dest = Monolith.formatter.rel_dir(@destination)\n Monolith.formatter.skip(@cookbook, \"#{rel_dest} doesn't exist\")\n nil\n end\n end",
"def remove(path, ctype, recursive=false, preserve_metadata=false)\n prune = recursive ? nil : 1\n count = 0\n nodes = @content_tree.subtree(path, ctype, prune)\n # NOTE: delete children first, hence the reverse()\n nodes.reverse.each do |node|\n ntype = node.node_type\n # first remove all files, then remove directories\n next if (node.kind_of? ContentRepo::DirNode)\n @content_tree.remove_node(node)\n remove_doc_resources(from_path, to_path) if ntype == :document\n remove_metadata(node.path, ntype, nil) unless preserve_metadata\n notify(EVENT_REMOVE, path, ctype)\n count += 1\n end\n\n # Remove all empty directories under path\n content_tree.remove_empty_dirs(path)\n metadata_tree.remove_empty_dirs(path)\n\n count\n end",
"def scan_dir(source_dir, target_dir)\n @stats.enter_directory(source_dir)\n\n Dir.foreach(File.join(@source_dir, source_dir)) do |filename|\n source_path_relative = File.join(source_dir, filename)\n source_path = File.join(@source_dir, source_path_relative)\n target_path_relative = File.join(target_dir, filename)\n target_path = File.join(@target_dir, target_path_relative)\n\n # What kind of beast is this?\n if filename == '.' || filename == '..'\n is_skipped_directory = true\n else\n if File.directory?(source_path)\n if (path_matches_skipped?(source_path_relative))\n is_skipped_directory = true\n else\n is_directory = true\n end\n else\n if filename_matches_pattern?(filename)\n if path_matches_exception?(source_path_relative)\n is_exception = true\n else\n is_match = true\n end\n else\n is_ignored = true\n end\n end\n end\n\n if is_skipped_directory\n # do nothing\n elsif is_directory\n scan_dir(source_path_relative, target_path_relative)\n elsif is_match\n @stats.record_scan_matching(filename)\n scan_file(source_path, filename)\n elsif is_exception\n @stats.record_known_exception(filename)\n else # not a match\n @stats.record_scan_non_matching(filename)\n end\n end\n end",
"def delete(node=nil, root=nil, &block)\n return super(node, root) do | dn | \n block.call(dn) if block\n dn.update_left_size(:deleted, -1) if dn\n end\n end",
"def rm_rf(z, path)\n z.get_children(:path => path).tap do |h|\n if h[:rc].zero?\n h[:children].each do |child|\n rm_rf(z, File.join(path, child))\n end\n elsif h[:rc] == ZNONODE\n # no-op\n else\n raise \"Oh noes! unexpected return value! #{h.inspect}\"\n end\n end\n\n rv = z.delete(:path => path)\n\n unless (rv[:rc].zero? or rv[:rc] == ZNONODE)\n raise \"oh noes! failed to delete #{path}\" \n end\n\n path\n end",
"def delete_files(options)\n if '' == options['base-dir'].to_s\n raise ArgumentError.new(\"Missing options['base-dir']\")\n end\n if '' == options['file-selector'].to_s\n raise ArgumentError.new(\"Missing options['file-selector']\")\n end\n if '' == options['file-extension'].to_s\n raise ArgumentError.new(\"Missing options['file-extension']\")\n end\n input_base_dir = config.compute_base_dir(options['base-dir'])\n input_file_selector = config.compute_file_selector(options['file-selector'])\n input_file_extension = config.compute_file_extension(options['file-extension'])\n\n Repositext::Cli::Utils.delete_files(\n input_base_dir,\n input_file_selector,\n input_file_extension,\n options['file_filter'],\n \"Deleting files\",\n {}\n )\n end",
"def doAllDeleteOperations(dryRun)\n #N Without this, the delete operations won't be executed\n doDeleteOperations(@destinationContent, dryRun)\n end",
"def delete_all\n objs = target\n source.update_attribute(source_attribute, nil)\n objs.each(&:delete)\n end",
"def destroy_tree_from_leaves\n self.subdirectories.each do |subdirectory|\n subdirectory.destroy_tree_from_leaves\n end\n self.subdirectories.reload\n self.cfs_files.each do |cfs_file|\n cfs_file.destroy!\n end\n self.cfs_files.reload\n self.destroy!\n end",
"def move_opt_chef(src, dest)\n converge_by(\"moving all files under #{src} to #{dest}\") do\n FileUtils.rm_rf dest\n raise \"rm_rf of #{dest} failed\" if ::File.exist?(dest) # detect mountpoints that were not deleted\n FileUtils.mv src, dest\n end\nrescue => e\n # this handles mountpoints\n converge_by(\"caught #{e}, falling back to copying and removing from #{src} to #{dest}\") do\n begin\n FileUtils.rm_rf dest\n rescue\n nil\n end # mountpoints can throw EBUSY\n begin\n FileUtils.mkdir dest\n rescue\n nil\n end # mountpoints can throw EBUSY\n FileUtils.cp_r Dir.glob(\"#{src}/*\"), dest\n FileUtils.rm_rf Dir.glob(\"#{src}/*\")\n end\nend",
"def remove_file_and_clean_directories( path )\n # first, delete the file\n delete_file( path )\n # recursively remove any parent directories, but only if they are empty, stop if they are not\n remove_empty_folders_recursively( path )\n end",
"def delete_tree_versions(directory_key)\n raise MedusaStorage::Error::UnsupportedOperation\n end",
"def deleteDirectory(dirPath, dryRun)\n #N Without this, the deletion command won't be run at all\n sshAndScp.deleteDirectory(dirPath, dryRun)\n end",
"def run_on_deletion(paths)\n end",
"def run_on_deletion(paths)\n end",
"def check_directories\n if File.exist?(source_dir)\n @source_dir = source_dir\n else\n raise DirectoryNotExist, \"Directory not exist\" \n end\n if File.exist?(destination_dir)\n @destination_dir = destination_dir\n else\n raise DirectoryNotExist, \"Directory not exist\" \n end \n end",
"def delete_coffeescript source_path\n if not File.exists?(File.dirname(File.expand_path(source_path, __FILE__)))\n return\n end\n \n generated_directory = File.dirname(File.expand_path(source_path, __FILE__))\n Dir.foreach(generated_directory) do |file|\n if file != generated_directory && file == '.' && file == '..'\n if File.directory?(file)\n FileUtils.rm_rf(file)\n else\n FileUtils.rm(file)\n end\n end\n end\n end",
"def undelete_tree(directory_key)\n raise MedusaStorage::Error::UnsupportedOperation\n end",
"def destroy\n run_callbacks :destroy do\n if directory?\n logger.info \"Delete directory at #{absolute_path}\"\n FileUtils.rmdir absolute_path\n else\n logger.info \"Delete file at #{absolute_path}\"\n # TODO if the file has added state (not committed), reset it to HEAD\n if status_file.untracked\n FileUtils.rm absolute_path\n else\n remove\n end\n end\n true\n end\n end",
"def delete_files_from dir\n Dir[dir+\"/*\"].each do |file|\n File::delete(file)\n end \n rescue => e\n Logger.<<(__FILE__,\"WARNING\",\"Files from #{dir} could not be deleted.\\n#{e.message}\")\n end",
"def require_delete_permission\n unless @folder.is_root? || current_user.can_delete(@folder)\n redirect_to @folder.parent, :alert => t(:no_permissions_for_this_type, :method => t(:delete), :type =>t(:this_folder))\n else\n require_delete_permissions_for(@folder.children)\n end\n end",
"def delete_file_and_folder!( file_path )\n FileUtils.rm_f file_path\n boundary = adapter_path + '/'\n loop do\n file_path = File.dirname file_path\n break unless file_path.index boundary\n FileUtils.rmdir file_path\n end\n end",
"def clean\n cache = Cache.instance\n # remove all built files\n cache.targets(false).each do |target|\n cache.remove_target(target)\n FileUtils.rm_f(target)\n end\n # remove all created directories if they are empty\n cache.directories(false).sort {|a, b| b.size <=> a.size}.each do |directory|\n cache.remove_directory(directory)\n next unless File.directory?(directory)\n if (Dir.entries(directory) - ['.', '..']).empty?\n Dir.rmdir(directory) rescue nil\n end\n end\n cache.write\n end",
"def clean_dir(dir)\n Dir.glob(File.join(dir, '*')).each {|d| clean_dir(d); Dir.rmdir(d) rescue nil}\nend",
"def destroy\n super do\n graph.delete [source.to_term, nil, nil]\n parent.delete [parent, nil, source.to_term]\n end\n end",
"def rmdir() Dir.rmdir( expand_tilde ) end",
"def remove_empty_directories\n base_paths.each do |path|\n command = <<-CMD\n for directory in $(find #{path} -type d); do\n if [ ! -d $directory ]; then\n echo \"Can't find directory $directory, it was probably already deleted, skipping . . .\"\n continue\n fi\n files=$(find $directory -type f)\n if [ -z \"$files\" ]; then\n echo \"No files in directory $directory, deleting . . .\"\n sudo rm -rf $directory\n fi\n done\n CMD\n Pkg::Util::Net.remote_execute(Pkg::Config.staging_server, command)\n end\n end",
"def destroy\n error = nil\n\n if @file.directory_id.nil?\n render_error \"Cannot remove root directory. Delete the project, instead.\"\n else\n begin\n ActiveRecord::Base.transaction do\n delete_file(@file, true);\n render json: \"\", serializer: SuccessSerializer\n end\n rescue\n render_error \"Files could not be deleted.\"\n end\n end\n end",
"def deleteDirectory(dirPath, dryRun)\n #N Without this, the required ssh command to recursive remove a directory won't be (optionally) executed. Without the '-r', the attempt to delete the directory won't be successful.\n ssh(\"rm -r #{dirPath}\", dryRun)\n end",
"def make_output_dir (src_path)\n delete_all_files(src_path) if directory_exists?(src_path) == true\n Dir.mkdir(src_path)\nend",
"def remove_dir path\r\n files = []\r\n dirs = []\r\n\r\n @ftp.list path do |line|\r\n name = line.split(' ', 9)[8] #should be file or dir name\r\n is_dir = line.chars.to_a[0] == 'd' #first character is 'd' for dirs\r\n if is_dir\r\n dirs << name\r\n else\r\n files << name\r\n end\r\n end\r\n\r\n files.each do |file|\r\n remove_file(File.join(path, file))\r\n end\r\n\r\n dirs.each do |dir|\r\n unless dir == '.' || dir == '..'\r\n remove_dir(File.join(path, dir))\r\n end\r\n end\r\n\r\n begin\r\n @ftp.rmdir path\r\n rescue Net::FTPPermError\r\n end\r\n end",
"def delete_with_two_children(target, direction = 'right')\n # starting from target.right, traverse left until there is a node whose left.nil?\n parent = target\n replacement = target.right\n loop do\n break if replacement.left.nil?\n\n direction = 'left'\n parent = replacement\n replacement = replacement.left\n end\n target.value = replacement.value\n delete_helper(parent, replacement, direction)\n # delete_with_one_child this node, then set target.value = node.value\n end",
"def move_directory(directory,target)\n log_new(\"move directory -> #{File.basename(directory)}\")\n \n if File.exists? \"#{target}/#{File.basename(directory)}\"\n log(\"warning dst directory exists: \\'#{File.basename(directory)}\\'\")\n else \n # if the directory does not exist it is created\n FileUtils.mkdir_p(target,$options) if not File.directory? target\n FileUtils.mv(directory,target,$options) if ( (File.dirname directory) != target.gsub(/\\/$/,'')) \n symlink_on_move(directory,target)\n end\nend",
"def delete(conn_id, path, *args)\n options = args.extract_options!\n options.assert_valid_keys(VALID_DELETE_OPTIONS)\n \n timeout = resolve_timeout_option(options[:timeout], 10.seconds)\n path = resolve_folderpath_option(conn_id, path)\n \n with_connection(conn_id, timeout) { |conn|\n conn.folder_delete(path, options[:recursive])\n }\n end",
"def delete_empty_directories(dir)\n return if File.realpath(dir) == File.realpath(@root_path)\n if Dir.entries(dir).reject{ |f| EXCLUDED_DIRS.include?(f) }.empty?\n Dir.delete(dir) rescue nil\n delete_empty_directories(File.dirname(dir))\n end\n end",
"def rm(*args)\n helper.glob_to_index(args) do |index, relative_path, realpath|\n index.remove(relative_path.to_s)\n realpath.delete\n end\n\n self\n end",
"def delete_features_from_hiptest\n puts \"\\nStart deleting...\"\n children_folders_of_root = get_children_folders $root_folder_id\n\n # Delete features from root subfolders\n children_folders_of_root.each do |folder|\n status = delete_folder_children_request folder['id']\n\n if status == 200.to_s\n puts \"Features from '#{folder['attributes']['name']}' folder deleted.\"\n end\n end\n\n # Delete folders from root subfolder\n status = delete_folder_children_request $root_folder_id\n\n if status == 200.to_s\n puts \"Folders from root folder deleted.\"\n end\nend",
"def clean_wiki_folders\n puts \"Trying to clean the wiki\"\n if File.exist?(g('wiki_dest'))\n #puts \"Removing Folder \"+g('wiki_dest')\n removeFolder(\"\") \n end\n #puts \"Creating Folder \"+g('wiki_dest')\n FileUtils.mkdir(g('wiki_dest'))\nend",
"def delete_node(current_node)\n\nend",
"def fileCleanPath(pathName) \n pathName.mkpath()\n begin\n pathName.rmtree()\n rescue\n puts \"Cannot delete: \" + pathName.to_s\n end\n pathName.mkpath()\nend",
"def delete(filename)\n within_source_root do\n FileUtils.mkdir_p File.dirname(filename)\n FileUtils.touch filename\n end\n \n generate { File.should_not exist(filename) }\n end",
"def delete_with_one_child(parent, target, direction)\n # if child's left exists, assign it to parent's left/right, else assign child's right\n parent.send \"#{direction}=\".to_sym, (target.left || target.right)\n end",
"def delete(rmdir: false)\n # FIXME: rethink this interface... should qdel be idempotent?\n # After first call, no errors thrown after?\n\n if pbsid\n\n @torque.qdel(pbsid, host: @host)\n # FIXME: removing a directory is always a dangerous action.\n # I wonder if we can add more tests to make sure we don't delete\n # something if the script name is munged\n\n # recursively delete the directory after killing the job\n Pathname.new(path).rmtree if path && rmdir && File.exist?(path)\n end\n end",
"def verify_src_dest_dir_paths\n unless File.exists?(@era_root_dir_path) && File.directory?(@era_root_dir_path)\n STDERR.puts \"Source directory does not exist:\\n '#{@era_root_dir_path}'\"\n exit 2\n end\n if File.exists?(@era_root_dir_path_dest)\n STDERR.puts \"Destination directory or file already exists:\\n '#{@era_root_dir_path_dest}'\"\n exit 3\n end\n end",
"def move_file(f,target)\n # do nothing if the file does not exist, this can occur\n return 2 if not File.exists? f\n log_new(\"move file -> #{File.basename(f) }\")\n \n target_file = target + \"/\" + File.basename(f) \n stats = {}\n stats[\"src_size\"] = ( not File.size?(f).nil?) ? File.size?(f) : 0\n stats[\"dst_size\"] = ( not File.size?(target_file).nil? ) ? File.size?(target_file) : 0\n \n if File.exists? f \n if stats[\"src_size\"] == 0 \n msg = \"#{@script} -> src file zero bytes: \\'#{File.basename(f) }\\' remove new file ? [y/n] \"\n prompt(f,\"delete\",msg)\n return 2\n end\n if stats[\"src_size\"] < 100000000 and $config[\"settings\"][\"prune_small\"] \n msg = \"#{@script} -> src file less than 100M: \\'#{File.basename(f) }\\' remove new file ? [y/n] \"\n prompt(f,\"delete\", msg)\n return 2\n end\n\n if stats[\"dst_size\"] == 0 and File.exists? target_file\n msg = \"#{@script} -> dst file zero bytes will continue: \\'#{File.basename(target_file) }\\' remove new file ? [y/n] \"\n prompt(target_file,\"delete\",msg)\n end\n if stats[\"dst_size\"] < 100000000 and $config[\"settings\"][\"prune_small\"] and File.exists? target_file\n msg = \"#{@script} -> dst file less than 100M will continue: \\'#{File.basename(target_file) }\\' remove new file ? [y/n] \"\n prompt(target_file,\"delete\", msg)\n end\n end\n \n $config[\"series\"][\"media_extentions\"].split(/,/).each do |ext|\n file_target = File.basename(f).gsub(/.\\w\\w\\w$/,'') + \".\" + ext\n if File.exists? \"#{target}/#{file_target}\"\n # choose which file to delete, we keep in order of the list\n order_target = 1\n order_new = 1\n count = 1\n $config[\"series\"][\"duplicate_priority\"].split(/,/).each do |keep_ext|\n order_target = count if File.extname(file_target) =~ /#{keep_ext}/ \n order_new = count if File.extname(f) =~ /#{keep_ext}/ \n count = count + 1\n end\n delete_file = f\n delete_file = \"#{target}/#{file_target}\" if order_new < order_target\n if order_new != order_target\n msg = \"#{@script} -> current file exist with another extention: \\'#{File.basename(delete_file) }\\' remove dup copy ? [y/n] \"\n prompt(delete_file,\"delete\",msg)\n return 2\n end\n end\n \n end\n \n if File.exists? \"#{target}/#{File.basename(f)}\"\n log(\"warning dst file exists: \\'#{File.basename(f)}\\'\",2) if $config[\"settings\"][\"log_level\"] > 2\n if stats[\"src_size\"] == stats[\"dst_size\"] and $config[\"settings\"][\"prompt_prune_duplicates\"] and f != target_file\n msg = \"duplicate: equal size \\'#{File.basename(f) }\\' remove new copy ? [y/n] \"\n prompt(f,\"delete\",msg)\n return 2\n elsif stats[\"src_size\"] != stats[\"dst_size\"] and f != target_file\n\n if $config[\"settings\"][\"prune_duplicates_choose_larger\"]\n if stats[\"src_size\"] > stats[\"dst_size\"]\n msg = \"duplicate: src larger than current, removing the current #{target_file}\"\n prompt(target_file,\"delete\",msg)\n end\n if stats[\"src_size\"] < stats[\"dst_size\"]\n msg = \"duplicate: src smaller than current, removing the current #{target_file}\"\n prompt(target_file,\"delete\",msg)\n end\n else\n msg = \"duplicate: src \\'#{f}\\' (#{stats[\"src_size\"]}) -> dst \\'#{target_file}\\' (#{stats[\"dst_size\"]}) fix manually\"\n log msg\n end\n\n else\n log \"warning src and dst equal for '#{File.basename(f)}\\' with auto pruning enabled we choose to do nothing\"\n end\n \n if $config[\"settings\"][\"log_level\"] > 2\n if stats[\"src_size\"] == stats[\"dst_size\"]\n log \"warning duplicate equal size: src \\'#{f}\\' -> dst \\'#{target_file}\\'\"\n # should be safe to save some time here and prompt to ask if one wishes to remove src file\n else\n log \"warning duplicate: src \\'#{f}\\' (#{stats[\"src_size\"]}) -> dst \\'#{target_file}\\' (#{stats[\"dst_size\"]})\"\n end\n end\n return 2\n end\n \n is_space = ensure_free_space f, target\n \n if is_space \n # if the directory does not exist it is created\n FileUtils.mkdir_p(target,$options) if not File.directory? target\n begin\n\n FileUtils.mv(f,target,$options) if ( (File.dirname f) != target.gsub(/\\/$/,''))\n symlink_on_move(f,target)\n rescue => e\n log(\"error: problem with target, reason #{e.to_s}\")\n exit 1\n end\n stats[\"dst_size\"] = ( not File.size?(target_file).nil? ) ? File.size?(target_file) : 0\n if (stats[\"src_size\"] != stats[\"dst_size\"]) and not $opt[\"dry\"]\n log(\"error target file not equal to original : \\\"#{File.basename(f)}\\\"\")\n end\n\n else\n log(\"error not enough free space on \\\"#{target}\\\"\")\n exit 2\n end\n \n 1\nend",
"def tell_git_about_empty_directories\n run %{find . -type d \\\\( -name .git -prune -o -empty -print0 \\\\) | \\\n xargs -0 -I arg touch arg/.gitignore}\n end",
"def cleanup_nontarget_files\n\n delete_dir = File.expand_path(File.join(app.build_dir, 'Resources/', 'Base.lproj/', 'assets/', 'images/'))\n\n puts_blue \"Cleaning up excess image files from target '#{options.Target}'\"\n puts_red \"Images for the following targets are being deleted from the build directory:\"\n\n (options.Targets.keys - [options.Target]).each do |target|\n\n puts_red \"#{target.to_s}\"\n Dir.glob(\"#{delete_dir}/**/#{target}-*.{jpg,png,gif}\").each do |f|\n puts_red \" Deleting #{File.basename(f)}\"\n File.delete(f)\n end\n end\n\n puts_red \"\\nImages prefixed all- are being deleted if a corresponding #{options.Target}- exists.\"\n\n Dir.glob(\"#{delete_dir}/**/all-*.{jpg,png,gif}\").each do |f|\n if File.exist?( f.sub(\"all-\", \"#{options.Target}-\") )\n puts_red \" Deleting #{File.basename(f)}\"\n File.delete(f)\n end\n end\n\n\n end",
"def delete\n if stat.directory?\n FileUtils.rm_rf(file_path)\n else\n ::File.unlink(file_path)\n end\n ::File.unlink(prop_path) if ::File.exist?(prop_path)\n @_prop_hash = nil\n NoContent\n end",
"def delete_empty_upstream_dirs\n path = ::File.expand_path(store_dir, root)\n Dir.delete(path) # fails if path not empty dir\n\n path = ::File.expand_path(base_store_dir, root)\n Dir.delete(path) # fails if path not empty dir\n rescue SystemCallError\n true # nothing, the dir is not empty\n end",
"def empty_non_root_directory path\n check_path_for_danger_to_remove path\n\n logger.debug \"Removing content of '#{File.join path, '*'}'\"\n FileUtils.rm_rf Dir.glob(File.join(path, '*'))\n FileUtils.rm_rf Dir.glob(File.join(path, '.*')).select {|f| f !~ /\\/..?$/}\n end",
"def destroy\n Segment.find_by_guid(source.guid).destroy if source && Segment.find_by_guid(source.guid)\n Segment.find_by_guid(target.guid).destroy if target && Segment.find_by_guid(target.guid)\n successors.each {|successor| NetworkConnection.find_by_guid(successor.guid).destroy if successor}\n super\n end",
"def authorize_deleting_for_children(folder)\r\n folder.children.each do |child_folder|\r\n unless @logged_in_user.can_delete(child_folder.id)\r\n error_msg = \"Sorry, you don't have delete permissions for one of the subfolders.\"\r\n if child_folder.parent.id == folder_id\r\n flash.now[:folder_error] = error_msg\r\n else\r\n flash[:folder_error] = error_msg\r\n end\r\n redirect_to :controller => 'folder', :action => 'list', :id => folder_id and return false\r\n else\r\n authorize_deleting_for_children(child_folder) # Checks the permissions of a child's children\r\n end\r\n end\r\n end"
] | [
"0.6534344",
"0.60478157",
"0.5677536",
"0.5677536",
"0.55911976",
"0.5584727",
"0.5559137",
"0.5556352",
"0.5528383",
"0.5495735",
"0.54590863",
"0.5455199",
"0.544853",
"0.5363932",
"0.5359782",
"0.53061295",
"0.5294999",
"0.5294999",
"0.5244365",
"0.52304226",
"0.52049124",
"0.51926845",
"0.5147376",
"0.51343656",
"0.51288235",
"0.51141965",
"0.5086511",
"0.50679064",
"0.5049132",
"0.50451034",
"0.502301",
"0.5014083",
"0.5012218",
"0.50064456",
"0.49838313",
"0.4981902",
"0.49546772",
"0.4950982",
"0.494853",
"0.49374604",
"0.4931622",
"0.49296",
"0.4923465",
"0.49047017",
"0.49021363",
"0.4886127",
"0.48781747",
"0.48731738",
"0.48726907",
"0.48550346",
"0.48454112",
"0.48428193",
"0.48387343",
"0.4829955",
"0.482327",
"0.4808102",
"0.48068875",
"0.4789661",
"0.4789049",
"0.47791538",
"0.47784546",
"0.4778172",
"0.4778172",
"0.47690034",
"0.47649467",
"0.47515482",
"0.4734512",
"0.47311223",
"0.47260478",
"0.4704343",
"0.4703898",
"0.47013056",
"0.46953252",
"0.46894175",
"0.46891034",
"0.4685037",
"0.4684265",
"0.46648675",
"0.46631786",
"0.46617624",
"0.4656421",
"0.46460238",
"0.46252048",
"0.4624816",
"0.462278",
"0.4620034",
"0.4618284",
"0.46164954",
"0.4608186",
"0.46054083",
"0.46039644",
"0.46028516",
"0.45930007",
"0.4590081",
"0.45888737",
"0.4584444",
"0.4576788",
"0.45698574",
"0.45691454",
"0.4568984"
] | 0.7721328 | 0 |
N Without this constructor, there is no way to construct a content location object with readonly cached content file attribute | def initialize(cachedContentFile)
#N Without this the name of the cached content file won't be remembered
@cachedContentFile = cachedContentFile
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(baseDirectory, hashClass, cachedContentFile = nil)\n #N Without this, we won't remember the cached content file name\n super(cachedContentFile)\n #N Without this, we won't remember the base directory\n @baseDirectory = baseDirectory\n #N Without this, we won't remember the hash function\n @hashClass = hashClass\n end",
"def initialize(contentHost, baseDir, cachedContentFile = nil)\n # Without super, we won't remember the cached content file (if specified)\n super(cachedContentFile)\n # Without this we won't remember which remote server to connect to\n @contentHost = contentHost\n # Without this we won't remember which directoy on the remote server to sync to.\n @baseDir = normalisedDir(baseDir)\n end",
"def initialize(path, content)\n @path = path\n @content = content\n end",
"def initialize(full_path, contents = [])\n @contents = contents.to_a.dup.freeze\n super(full_path)\n end",
"def initialize\n @contents = StringIO.new('', 'r+b')\n @filemgr = Server.file_manager\n end",
"def initialize(raw_content, opts = {})\n @id = opts[:id] || SecureRandom.hex(16) # FIXME check that the content id isn't already used / use UUID\n @repo = opts[:repo]\n @type = opts[:type] || DocumentType.get('document')\n\n unless @repo\n @content = Content.new(raw_content)\n end\n end",
"def initialize(content = nil)\n self.content = content\n end",
"def initialize(path)\n @path = path\n @content = File.read(path)\n end",
"def initialize_file_based_cache\n Dir.mkdir(\"cache\")\n @document_cache = ActiveSupport::Cache::FileStore.new(\"cache\")\n @file_based_cache = true\n end",
"def initialize(path, content, symlink: false)\n @path = path\n @content = content\n @symlink = symlink\n end",
"def initialize(contents = nil)\n self.contents = contents\n end",
"def initialize(key, filename, content)\n @key = key\n @filename = filename\n @content = content\n end",
"def initialize\n @file = ''\n @content = Hash.new\n\n @uri = NULL_IP\n\n self.class.count += 1\n # @todo Allow IP version to be changeable based on execution\n end",
"def initialize\r\n @contents = {}\r\n end",
"def initialize(token)\n @token = token\n @file_cache = {}\n end",
"def initialize\n @data = ::Hash.new { |h, k| h[k] = File.new(k, mtime: 0) }\n @mutex = Mutex.new\n end",
"def initialize(filename_or_io, content_type, filename = nil, opts = {})\n io = filename_or_io\n local_path = \"\"\n if io.respond_to? :read\n # in Ruby 1.9.2, StringIOs no longer respond to path\n # (since they respond to :length, so we don't need their local path, see parts.rb:41)\n local_path = filename_or_io.respond_to?(:path) ? filename_or_io.path : \"local.path\"\n else\n io = File.open(filename_or_io)\n local_path = filename_or_io\n end\n filename ||= local_path\n\n @content_type = content_type\n @original_filename = File.basename(filename)\n @local_path = local_path\n @io = io\n @opts = opts\n end",
"def initialize(content); end",
"def initialize(content); end",
"def initialize(name, contents, mime_type = nil)\n @name = name\n @contents = contents\n @mime_type = mime_type\n end",
"def initialize(content = '')\n super(content)\n @source = nil\n end",
"def initialize(params={})\n @url = params[:url]\n @content = params[:content]\n @content_type = params[:content_type] || (@content ? guess_content_type : nil)\n @url_file_path = nil\n @directory_path = nil\n @filename = nil\n end",
"def _initialize_without_checks(path, content, comment) # :nodoc:\n @comment = comment.freeze\n @path = path.freeze\n @content = content.freeze\n end",
"def initialize(content)\n @content = content\n end",
"def initialize(content)\n @content = content\n end",
"def initialize(content)\n @content = content\n end",
"def initialize file_path\n\t\t\t@file_path = file_path\n\t\t\t@meta = {}\n\t\tend",
"def initialize(cache_dir, data)\n @cache_dir = Path.new(cache_dir)\n @data = data\n end",
"def cache!(document) \n if document.is_a?(Hash) && document.has_key?(\"base64\") && document.has_key?(\"filename\")\n raise ArgumentError unless document[\"base64\"].present?\n file = FilelessIO.new(Base64.decode64(document[\"base64\"]))\n file.original_filename = document[\"filename\"]\n file.content_type = document[\"filetype\"] \n super(file)\n else\n super(document)\n end\n end",
"def initialize blob, path\n @blob = blob\n self.content = blob.data\n self.path = path\n end",
"def build_file\n IoDecorator.new(file_stream, original_filename, file_content_type.to_s, use)\n end",
"def create_content_proxy_for(content_descr)\n path = _get_path(content_descr)\n # TODO: Make sure that key is really unique across multiple repositories - why?\n descr = descr ? descr.dup : {}\n url = get_url_for_path(path)\n descr[:url] = url\n descr[:path] = path\n descr[:name] = url # Should be something human digestable\n if (descr[:strictly_new])\n return nil if exist?(path)\n end\n proxy = ContentProxy.create(descr, self)\n return proxy\n end",
"def initialize(content) \r\n @content = content\r\n end",
"def initialize(b_file, cache_path)\n b_file = Utility.clean_path(b_file)\n @cache = cache_path\n super(b_file)\n end",
"def factory(content, private: T.unsafe(nil)); end",
"def cache!(document)\n if document.is_a?(Hash) && document.has_key?(\"base64\") && document.has_key?(\"filename\")\n raise ArgumentError unless document[\"base64\"].present?\n file = FilelessIO.new(Base64.decode64(document[\"base64\"]))\n file.original_filename = document[\"filename\"]\n file.content_type = document[\"filetype\"] \n super(file)\n else\n super(document)\n end\n end",
"def initialize(content)\n @content = content\n end",
"def initialize(content)\n @content = content\n end",
"def internal_file_attributes=(_arg0); end",
"def initialize(filename, mode=\"r\", perm=0) end",
"def initialize(name, content)\n @name = name\n @content = content\n end",
"def initialize(name, content)\n @name = name\n @content = content\n end",
"def content_files\n @cache_content_files ||= cached_datafiles.reject { |df| sip_descriptor == df }\n end",
"def initialize(path, file, storage_name = nil)\n self.path = path\n self.file = file\n self.storage_name = storage_name\n end",
"def initialize(content, attributes, identifier)\n # Content\n if content.nil?\n raise ArgumentError, \"Attempted to create a #{self.class} without content (identifier #{identifier})\"\n elsif content.is_a?(Nanoc::TextualContent) || content.is_a?(Nanoc::BinaryContent)\n @content = content\n else\n # FIXME does it make sense to have a nil path?\n @content = Nanoc::TextualContent.new(content.to_s, nil)\n end\n\n # Attributes\n @attributes = attributes.symbolize_keys_recursively\n\n # Identifier\n if identifier.is_a?(Nanoc::Identifier)\n @identifier = identifier\n else\n @identifier = Nanoc::Identifier.from_string(identifier.to_s)\n end\n end",
"def file\n FileFactory.new(self)\n end",
"def initialize\n @contents = []\n @open = true\n end",
"def create_lock_object\n @bucket.create_file(\n StringIO.new,\n @path,\n acl: @object_acl,\n cache_control: 'no-store',\n metadata: {\n expires_at: (Time.now + @ttl).to_f,\n identity: identity,\n },\n if_generation_match: 0,\n )\n rescue Google::Cloud::FailedPreconditionError\n nil\n end",
"def initialize(path); end",
"def file\n @file ||= Operations::FileFactory.new(self)\n end",
"def initialize(target_subpaths, source_position, content, mtime)\n @target_subpaths = Array(target_subpaths)\n @source_position = source_position\n @content = content\n @mtime = mtime.to_i\n end",
"def initialize(name, metadata = {})\n super\n @files = {}\n end",
"def local_file\n @local_file ||= LocalFile.new self\n end",
"def initialize(file_path)\n @path = Pathname.new(file_path)\n @content = File.read @path\n @meta = Hashie::Mash.new\n read_meta_from_yaml_header\n end",
"def initialize fileLocation, fileName, fileContent, rights, serverSide, user\n @fileLocation = fileLocation\n @fileName = fileName\n @fileContent = splitText fileContent\n @id = SecureRandom.uuid\n @rights = rights\n @serverSide = serverSide\n @workingUsers = [user]\n @diffHistory = []\n @diffHistoryPosition = 0\n end",
"def initialize(href: nil, lastmodified: nil, tag: nil, resourcetype: nil, contenttype: nil, contentlength: nil,\n id: nil, fileid: nil, permissions: nil, size: nil, has_preview: nil, favorite: nil,\n comments_href: nil, comments_count: nil, comments_unread: nil, owner_id: nil,\n owner_display_name: nil, share_types: nil, skip_contents: false)\n\n self.class.params.each do |v|\n instance_variable_set(\"@#{v}\", instance_eval(v.to_s)) if instance_eval(v.to_s)\n end\n\n remove_instance_variable (:@skip_contents) if skip_contents\n end",
"def initialize( fn )\n @path = fn\n @dir = ::Webby::Resources.dirname(@path)\n @name = ::Webby::Resources.basename(@path)\n @ext = ::Webby::Resources.extname(@path)\n @mtime = ::File.mtime @path\n\n @_meta_data = {}\n self._reset\n end",
"def initialize(anything)\n @content = anything\n end",
"def file(path, *args)\n return file_via_connection(path, *args) unless cache_enabled?(:file)\n\n @cache[:file][path] ||= file_via_connection(path, *args)\n end",
"def initialize\n @contents = []\n @open = true\n end",
"def initialize\n @contents = []\n @open = true\n end",
"def initialize\n @contents = []\n @open = true\n end",
"def initialize\n @contents = []\n @open = true\n end",
"def initialize\n @contents = []\n @open = true\n end",
"def initialize\n @contents = []\n @open = true\n end",
"def initialize\n @contents = []\n @open = true\n end",
"def initialize\n @contents = []\n @open = true\n end",
"def initialize\n @contents = []\n @open = true\n end",
"def initialize\n @contents = []\n @open = true\n end",
"def initialize\n @contents = []\n @open = true\n end",
"def initialize(cache_path = Chef::Config[:syntax_check_cache_path])\n @cache_path = cache_path\n @cache_path_created = false\n end",
"def initialize(contents, pos, allowed)\n @contents = contents\n @pos = pos\n @allowed = allowed\n end",
"def initialize(raw_content, attributes, identifier, params=nil)\n # Get mtime and checksum\n params ||= {}\n params = { :mtime => params } if params.is_a?(Time)\n @new_checksum = params[:checksum]\n @mtime = params[:mtime]\n\n @raw_content = raw_content\n @attributes = attributes.symbolize_keys\n @identifier = identifier.cleaned_identifier\n end",
"def getContentCache(theContent)\n\n\ttheChecksum = Digest::SHA256.hexdigest(theContent).insert(2, '/');\n\ttheCache = \"#{PATH_FORMAT_CACHE}/#{theChecksum}\";\n\t\n\treturn theCache;\n\nend",
"def initialize(content)\n @content = content\n super()\n end",
"def initialize(filename, opts = {})\n @filename = filename\n @content = opts[:content] || random_content(opts[:length] || 100)\n end",
"def initialize(params = {})\n @file = params.delete(:filecontents)\n super\n if @file\n self.filename = sanitize_filename(@file.original_filename)\n self.filetype = @file.content_type\n self.filecontents = @file.read\n end\n end",
"def initialize(ref, remote, basedir, dirname = nil)\n @ref = ref\n @remote = remote\n @basedir = basedir\n @dirname = dirname || ref\n\n @full_path = File.join(@basedir, @dirname)\n\n @cache = R10K::Git::Cache.new(@remote)\n end",
"def initialize(url, path)\n memoize [:fetch]\n @store ||= fetch(url, path)\n end",
"def initialize(file = 'cache.yaml')\n @file = file\n @cache = YAML::Store.new(file)\n end",
"def initialize(url, cache_size)\n @url = url\n end",
"def initialize\n\t\t@contents = []\n\t\t@open = true\n\tend",
"def initialize\n\t\t@contents = []\n\t\t@open = true\n\tend",
"def initialize\n\t\t@contents = []\n\t\t@open = true\n\tend",
"def initialize\n\t\t@contents = []\n\t\t@open = true\n\tend",
"def initialize\n\t\t@contents = []\n\t\t@open = true\n\tend",
"def initialize\n\t\t@contents = []\n\t\t@open = true\n\tend",
"def initialize\n\t\t@contents = []\n\t\t@open = true\n\tend",
"def initialize\n\t\t@contents = []\n\t\t@open = true\n\tend",
"def initialize\n\t\t@contents = []\n\t\t@open = true\n\tend",
"def initialize\n\t\t@contents = []\n\t\t@open = true\n\tend",
"def initialize\n\t\t@contents = []\n\t\t@open = true\n\tend",
"def initialize\n\t\t@contents = []\n\t\t@open = true\n\tend",
"def initialize\n\t\t@contents = []\n\t\t@open = true\n\tend",
"def initialize\n\t\t@contents = []\n\t\t@open = true\n\tend",
"def initialize content = nil\n @headers = Header.new\n self.body = content\n self.date = Time.now\n end",
"def initialize\n\t\t@contents = []\n\t\t@open = true\n\tend",
"def initialize\n@contents = []\n@open = true\n@lock = false\nend",
"def base\n\t\t\t\tself.class.new(@path, nil, nil, nil)\n\t\t\tend",
"def store_content(key, klass, content)\n raise MogileFS::ReadOnlyError if readonly?\n\n new_file key, klass do |mfp|\n if content.is_a?(MogileFS::Util::StoreContent)\n mfp.streaming_io = content\n else\n mfp << content\n end\n end\n\n content.length\n end"
] | [
"0.642407",
"0.63396466",
"0.63380396",
"0.62640715",
"0.6249576",
"0.6183083",
"0.6082768",
"0.60645586",
"0.6049961",
"0.6023843",
"0.60098326",
"0.5988599",
"0.5935178",
"0.59269065",
"0.59102565",
"0.5870863",
"0.5849602",
"0.58016145",
"0.58016145",
"0.57950556",
"0.5771377",
"0.5767104",
"0.5734129",
"0.5732695",
"0.5732695",
"0.5732695",
"0.5723307",
"0.5681392",
"0.5679494",
"0.5667373",
"0.5656163",
"0.56517303",
"0.5634469",
"0.5630811",
"0.5617049",
"0.5615364",
"0.56129277",
"0.56129277",
"0.5588181",
"0.55802464",
"0.5577599",
"0.5577599",
"0.556505",
"0.555256",
"0.55502963",
"0.5547104",
"0.55407",
"0.5535411",
"0.5535244",
"0.55334216",
"0.55267924",
"0.5507386",
"0.5507322",
"0.5505208",
"0.54967463",
"0.54937565",
"0.54862374",
"0.5466404",
"0.54643756",
"0.54591286",
"0.54591286",
"0.54591286",
"0.54591286",
"0.54591286",
"0.54591286",
"0.54591286",
"0.54591286",
"0.54591286",
"0.54591286",
"0.54591286",
"0.5448304",
"0.5447684",
"0.54407996",
"0.5436124",
"0.5427835",
"0.5421913",
"0.54090875",
"0.53934264",
"0.53897065",
"0.5388301",
"0.5388135",
"0.5381448",
"0.5381448",
"0.5381448",
"0.5381448",
"0.5381448",
"0.5381448",
"0.5381448",
"0.5381448",
"0.5381448",
"0.5381448",
"0.5381448",
"0.5381448",
"0.5381448",
"0.5381448",
"0.53811496",
"0.5380459",
"0.53718793",
"0.5365981",
"0.5364568"
] | 0.7335866 | 0 |
Get the cached content file name, if specified, and if the file exists N Without this there is no easy way to get the existing cached content tree (if the cached content file is specified, and if the file exists) | def getExistingCachedContentTreeFile
#N Without this check, it would try to find the cached content file when none was specified
if cachedContentFile == nil
#N Without this, there will be no feedback to the user that no cached content file is specified
puts "No cached content file specified for location"
return nil
#N Without this check, it will try to open the cached content file when it doesn't exist (i.e. because it hasn't been created, or, it has been deleted)
elsif File.exists?(cachedContentFile)
#N Without this, it won't return the cached content file when it does exist
return cachedContentFile
else
#N Without this, there won't be feedback to the user that the specified cached content file doesn't exist.
puts "Cached content file #{cachedContentFile} does not yet exist."
return nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getCachedContentTree\n #N Without this, we won't know the name of the specified cached content file (if it is specified)\n file = getExistingCachedContentTreeFile\n #N Without this check, we would attempt to read a non-existent file\n if file\n #N Without this, a content tree that has been cached won't be returned.\n return ContentTree.readFromFile(file)\n else\n return nil\n end\n end",
"def getContentTree\n #N Without this check we would try to read the cached content file when there isn't one, or alternatively, we would retrieve the content details remotely, when we could have read them for a cached content file\n if cachedContentFile and File.exists?(cachedContentFile)\n #N Without this, the content tree won't be read from the cached content file\n return ContentTree.readFromFile(cachedContentFile)\n else\n #N Without this, we wouldn't retrieve the remote content details\n contentTree = contentHost.getContentTree(baseDir)\n #N Without this, the content tree might be in an arbitrary order\n contentTree.sort!\n #N Without this check, we would try to write a cached content file when no name has been specified for it\n if cachedContentFile != nil\n #N Without this, the cached content file wouldn't be updated from the most recently retrieved details\n contentTree.writeToFile(cachedContentFile)\n end\n #N Without this, the retrieved sorted content tree won't be retrieved\n return contentTree\n end\n end",
"def get_cache_file(key)\n _find_file_key(key)\n end",
"def getCachedContentTreeMapOfHashes\n #N Without this, we won't know the name of the specified cached content file (if it is specified)\n file = getExistingCachedContentTreeFile\n #N Without this check, we would attempt to read a non-existent file\n if file\n #N Without this, there won't be feedback to the user that we are reading the cached file hashes\n puts \"Reading cached file hashes from #{file} ...\"\n #N Without this, a map of cached file hashes won't be returned\n return ContentTree.readMapOfHashesFromFile(file)\n else\n #N Without this, the method wouldn't consistently return an array of timestamp + map of hashes in the case where there is no cached content file\n return [nil, {}]\n end\n end",
"def getContentTree\n #N Without this we won't have timestamp and the map of file hashes used to efficiently determine the hash of a file which hasn't been modified after the timestamp\n cachedTimeAndMapOfHashes = getCachedContentTreeMapOfHashes\n #N Without this we won't have the timestamp to compare against file modification times\n cachedTime = cachedTimeAndMapOfHashes[0]\n #N Without this we won't have the map of file hashes\n cachedMapOfHashes = cachedTimeAndMapOfHashes[1]\n #N Without this we won't have an empty content tree which can be populated with data describing the files and directories within the base directory\n contentTree = ContentTree.new()\n #N Without this we won't have a record of a time which precedes the recording of directories, files and hashes (which can be used when this content tree is used as a cached for data when constructing some future content tree)\n contentTree.time = Time.now.utc\n #N Without this, we won't record information about all sub-directories within this content tree\n for subDir in @baseDirectory.subDirs\n #N Without this, this sub-directory won't be recorded in the content tree\n contentTree.addDir(subDir.relativePath)\n end\n #N Without this, we won't record information about the names and contents of all files within this content tree\n for file in @baseDirectory.allFiles\n #N Without this, we won't know the digest of this file (if we happen to have it) from the cached content tree\n cachedDigest = cachedMapOfHashes[file.relativePath]\n #N Without this check, we would assume that the cached digest applies to the current file, even if one wasn't available, or if the file has been modified since the time when the cached value was determined.\n # (Extra note: just checking the file's mtime is not a perfect check, because a file can \"change\" when actually it or one of it's enclosing sub-directories has been renamed, which might not reset the mtime value for the file itself.)\n if cachedTime and cachedDigest and File.stat(file.fullPath).mtime < cachedTime\n #N Without this, the digest won't be recorded from the cached digest in those cases where we know the file hasn't changed\n digest = cachedDigest\n else\n #N Without this, a new digest won't be determined from the calculated hash of the file's actual contents\n digest = hashClass.file(file.fullPath).hexdigest\n end\n #N Without this, information about this file won't be added to the content tree\n contentTree.addFile(file.relativePath, digest)\n end\n #N Without this, the files and directories in the content tree might be listed in some indeterminate order\n contentTree.sort!\n #N Without this check, a new version of the cached content file will attempt to be written, even when no name has been specified for the cached content file\n if cachedContentFile != nil\n #N Without this, a new version of the cached content file (ready to be used next time) won't be created\n contentTree.writeToFile(cachedContentFile)\n end\n return contentTree\n end",
"def cacheFileName(ni)\n @directory_name + \"/\" + ni.path\nend",
"def getContentCache(theContent)\n\n\ttheChecksum = Digest::SHA256.hexdigest(theContent).insert(2, '/');\n\ttheCache = \"#{PATH_FORMAT_CACHE}/#{theChecksum}\";\n\t\n\treturn theCache;\n\nend",
"def get_file(key, use_cache = true)\n if use_cache\n db = (@current_site.get_meta(cache_key) || {})[File.dirname(key)] || {}\n else\n db = objects(File.dirname(key)) unless use_cache\n end\n (db[:files][File.basename(key)] || db[:folders][File.basename(key)]) rescue nil\n end",
"def file\n file_id = @attributes[\"file\"]\n file_node = NodeCache.find(file_id)\n file_node ? file_node.name : nil\n end",
"def file_path\n Dir.glob(config.cache).first || File.join(File.dirname(config.cache),\n File.basename(config.cache).gsub(/_.+\\.txt/, '_0.txt'))\n end",
"def [](key)\n File.read(cache_path(key))\n rescue Errno::ENOENT\n nil\n end",
"def file_name(token)\n FileHelper.file_cache_name(file_cache_dir, token)\n end",
"def get(file)\n binding.pry\n #return the values from cached first\n @cached[file] || \n @file_metadata[file] || \n read_metadata_from_yaml(file) || \n cache(file, read_metadata_from_disk(file)) \n end",
"def load_cached\n content = File.open(self.cache_file_name, \"rb\") { |f| f.read }\n puts(\"[MODEL_FILE] Loaded #{self.cache_file_name} from cache\")\n return content\n end",
"def get_filename(key)\n\thash = hash(key)\n\n\tif File.exist?(File.join(@cache_dir, hash))\n\t return File.join(@cache_dir, hash)\n\telse\n\t return nil\n\tend\n end",
"def read(key)\n File.read(cache_path(key))\n rescue Errno::ENOENT\n nil\n end",
"def content_files\n @cache_content_files ||= cached_datafiles.reject { |df| sip_descriptor == df }\n end",
"def cache_file_path\n raise IOError.new 'Write permission is required for cache directory' unless File.writable?(@args[:cache_directory])\n \"#{@args[:cache_directory]}/#{Digest::SHA1.hexdigest((@args[:cache_ref] || @path).to_s + size.to_s + last_modified.to_s)}.cache\"\n end",
"def data_cache(fpath)\n (@data_caches ||= []) << fpath\n return fpath\n end",
"def cache_path\n File.join @path, 'cache.ri'\n end",
"def get_cache(key)\n treecache.fetch(key)\n end",
"def cache_file key\n File.join( store, key+\".cache\" )\n end",
"def get_from_cache(cache_file, cache_ttl=5)\n if File.exists?(cache_file)\n now = Time.now\n file_mtime = File.mtime(cache_file)\n file_age = now - file_mtime\n if ((cache_ttl < 0) || (file_age <= cache_ttl))\n file = File.open(cache_file, \"r:UTF-8\")\n return file.read\n else\n # Return False if the cache is old\n return false\n end\n else\n # Return False if the cache file doesn't exist\n return false\n end\n end",
"def cache_get(key)\n cache_file = @config[:cache_directory] / \"#{key}.cache\"\n if File.file?(cache_file)\n _data, _expire = Marshal.load(cache_read(cache_file))\n if _expire.nil? || Time.now < _expire\n Merb.logger.info(\"cache: hit (#{key})\")\n return _data\n end\n FileUtils.rm_f(cache_file)\n end\n Merb.logger.info(\"cache: miss (#{key})\")\n nil\n end",
"def get(key = '')\n if key != '' && ::File.exists?(@cache_dir+key)\n # Is the File older than a day?\n if file_age(@cache_dir+key) > 1\n # Delete and return a cache miss\n File.delete(@cache_dir+key)\n return false\n end\n\n puts \"Reading from cache with key: #{key}\" if ENV['DEBUG']\n data = ::File.read(@cache_dir+key)\n return (data.length > 0) ? data : false\n end\n\n return false\n end",
"def cached_file?\n Settings.documents.page_cache && File.exists?(cache_file)\n end",
"def cache_file(input)\n key = Digest.hexencode(Digest::SHA2.digest(input.to_yaml))\n return @directory + \"/\" + key + \".yaml\"\n end",
"def get_cached_gist(gist, file)\n return nil if @cache_disabled\n cache_file = get_cache_file_for gist, file\n File.read cache_file if File.exist? cache_file\n end",
"def read_from_cache\n if config.cache.is_a?(Proc)\n config.cache.call(nil)\n elsif (config.cache.is_a?(String) || config.cache.is_a?(Pathname)) &&\n File.exist?(file_path)\n open(file_path).read\n end\n end",
"def get_content(model_name)\n @_content ||= {}\n\n # return content if it has already been memoized\n return @_content[model_name] unless @_content[model_name].nil?\n\n #get class of content model we are trying to get content for\n model = get_content_model(model_name)\n\n if is_plural?(model_name)\n content = model.find(:all, :path => custom_content_path, :parent => self)\n else\n content = model.find(:first, :path => custom_content_path, :parent => self)\n end\n\n\n # memoize content so we don't parse file again on the same request\n @_content[model_name] = content\n end",
"def getcached(url)\n _cached = instance_variable_get \"@cached_#{hashed(url)}\"\n return _cached unless _cached.nil?\n path = CACHE_FILE + \"#{hashed(url)}.json\"\n if File.exists?(path)\n File.open(path, \"r:UTF-8\") do |f|\n _cached = JSON.parse(f.read)\n instance_variable_set(\"@cached_#{hashed(url)}\", _cached)\n return _cached\n end \n end\n return nil\n end",
"def content\n return @content if application.cache_pages? && @content\n\n @content = if file?\n IO.read(path)\n elsif io?\n path.read\n else\n path\n end\n end",
"def cache_file\n File.join(Rscons.application.build_dir, \".rsconscache\")\n end",
"def cache_file_path\n File.join @homepath, 'cache'\n end",
"def get_cache_file_for(gist, file)\n bad_chars = /[^a-zA-Z0-9\\-_.]/\n gist = gist.gsub bad_chars, ''\n file = file.gsub bad_chars, ''\n md5 = Digest::MD5.hexdigest \"#{gist}-#{file}\"\n File.join @cache_folder, \"#{gist}-#{file}-#{md5}.cache\"\n end",
"def getcached(url)\n _cached = instance_variable_get \"@cached_#{hashed(url)}\"\n return _cached unless _cached.nil?\n path = CACHE_FILE + \"#{hashed(url)}.json\"\n if File.exists?(path)\n f = File.open(path)\n _cached = JSON.parse(f.read)\n instance_variable_set(\"@cached_#{hashed(url)}\", _cached)\n return _cached\n end\n return nil\n end",
"def getcached(url)\n _cached = instance_variable_get \"@cached_#{hashed(url)}\"\n return _cached unless _cached.nil?\n path = CACHE_FILE + \"#{hashed(url)}.json\"\n if File.exists?(path)\n f = File.open(path)\n _cached = JSON.parse(f.read)\n instance_variable_set(\"@cached_#{hashed(url)}\", _cached)\n return _cached\n end\n return nil\n end",
"def getcached(url)\n _cached = instance_variable_get \"@cached_#{hashed(url)}\"\n return _cached unless _cached.nil?\n path = CACHE_FILE + \"#{hashed(url)}.json\"\n if File.exists?(path)\n f = File.open(path)\n _cached = JSON.parse(f.read)\n instance_variable_set(\"@cached_#{hashed(url)}\", _cached)\n return _cached\n end\n return nil\n end",
"def getcached(url)\n _cached = instance_variable_get \"@cached_#{hashed(url)}\"\n return _cached unless _cached.nil?\n path = CACHE_FILE + \"#{hashed(url)}.json\"\n if File.exists?(path)\n f = File.open(path)\n _cached = JSON.parse(f.read)\n instance_variable_set(\"@cached_#{hashed(url)}\", _cached)\n return _cached\n end\n return nil\n end",
"def getcached(url)\n _cached = instance_variable_get \"@cached_#{hashed(url)}\"\n return _cached unless _cached.nil?\n path = CACHE_FILE + \"#{hashed(url)}.json\"\n if File.exists?(path)\n f = File.open(path)\n _cached = JSON.parse(f.read)\n instance_variable_set(\"@cached_#{hashed(url)}\", _cached)\n return _cached\n end\n return nil\n end",
"def getcached(url)\n _cached = instance_variable_get \"@cached_#{hashed(url)}\"\n return _cached unless _cached.nil?\n path = CACHE_FILE + \"#{hashed(url)}.json\"\n if File.exists?(path)\n f = File.open(path)\n _cached = JSON.parse(f.read)\n instance_variable_set(\"@cached_#{hashed(url)}\", _cached)\n return _cached\n end\n return nil\n end",
"def getcached(url)\n _cached = instance_variable_get \"@cached_#{hashed(url)}\"\n return _cached unless _cached.nil?\n path = CACHE_FILE + \"#{hashed(url)}.json\"\n if File.exists?(path)\n f = File.open(path)\n _cached = JSON.parse(f.read)\n instance_variable_set(\"@cached_#{hashed(url)}\", _cached)\n return _cached\n end\n return nil\n end",
"def getcached(url)\n _cached = instance_variable_get \"@cached_#{hashed(url)}\"\n return _cached unless _cached.nil?\n path = CACHE_FILE + \"#{hashed(url)}.json\"\n if File.exists?(path)\n f = File.open(path)\n _cached = JSON.parse(f.read)\n instance_variable_set(\"@cached_#{hashed(url)}\", _cached)\n return _cached\n end\n return nil\n end",
"def getcached(url)\n _cached = instance_variable_get \"@cached_#{hashed(url)}\"\n return _cached unless _cached.nil?\n path = CACHE_FILE + \"#{hashed(url)}.json\"\n if File.exists?(path)\n f = File.open(path)\n _cached = JSON.parse(f.read)\n instance_variable_set(\"@cached_#{hashed(url)}\", _cached)\n return _cached\n end\n return nil\n end",
"def get_cache(url, options = {})\n\t\t\tpath = @@cache_directory_path + options[:lang] + '/' + url_to_filename(url)\n\t\t\t\n\t\t\t# file doesn't exist, make it\n\t\t\tif !File.exists?(path)\n\t\t\t\tif options[:debug]\n\t\t\t\t\tputs 'Cache doesn\\'t exist, making: ' + path\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\t# make sure dir exists\n\t\t\t\tFileUtils.mkdir_p(localised_cache_path(options[:lang])) unless File.directory?(localised_cache_path(options[:lang]))\n\t\t\t\t\n\t\t\t\txml_content = http_request(url, options)\n\t\t\t\t\n\t\t\t\t# write the cache\n\t\t\t\tfile = File.open(path, File::WRONLY|File::TRUNC|File::CREAT)\n\t\t\t\tfile.write(xml_content)\n\t\t\t\tfile.close\n\t\t\t\n\t\t\t# file exists, return the contents\n\t\t\telse\n\t\t\t\tputs 'Cache already exists, read: ' + path if options[:debug]\n\t\t\t\t\n\t\t\t\tfile = File.open(path, 'r')\n\t\t\t\txml_content = file.read\n\t\t\t\tfile.close\n\t\t\tend\n\t\t\treturn xml_content\n\t\tend",
"def cache_path\n Pathname.new(File.expand_path(File.join(ChefCLI::Helpers.package_home, \"cache\")))\n .join(\".cache\", \"git\", Digest::SHA1.hexdigest(uri))\n end",
"def file_cache_path\n Chef::Config[:file_cache_path]\n end",
"def fetch_cache(file, url)\n @path = \"tmp/\" + file + \".html\";\n @temp = @path + \".fetch\"\n @doFetch = !(FileTest.exists?(@path) && (Time.new - File.mtime(@path) < (5 * 60)))\n\n if @doFetch and download_page(@temp,url) then\n File.delete(@path) if File.exists?(@path)\n File.rename(@temp, @path)\n end\n\n if File.exists?(@path) then\n return @path\n else\n @useOnce = @path + \".\" + rand(100000).to_s + \".once\"\n download_page(@useOnce, url)\n return @useOnce\n end\n end",
"def contents(path)\n puts \"#contents(#{path})\" if DEBUG\n results = []\n root_path = zk_path(path)\n zk.find(root_path) do |z_path|\n if (z_path != root_path)\n z_basename = z_path.split('/').last\n stats = zk.stat(z_path)\n results << \"#{z_basename}\" if stats.numChildren > 0\n results << \"#{z_basename}.contents\" if zk.stat(z_path).dataLength > 0\n ZK::Find.prune\n end\n end\n results\n end",
"def cached_location\n dlt = (download_type) ? download_type : 'default'\n Drupid.cache_path + self.class.to_s.split(/::/).last + extended_name + dlt + name\n end",
"def get(base, name, opts)\n self.load if @cache.nil?\n path = Jekyll.sanitized_path(base, name)\n key = path[@site.source.length..-1]\n mtime = File.mtime(path)\n\n if @cache.has_key?(key) && mtime == @cache[key]['modified']\n # file is not modified\n ret_hash(@cache[key]['yaml'], @cache[key]['content'], false, false, false)\n else\n puts \"parsed yaml #{key}...\"\n self.set_content(key, path, mtime, opts)\n end\n end",
"def [](key)\n\thash = hash(key)\n\n\tvalue = nil\n\tif File.exist?(File.join(@cache_dir, hash))\n\t value = ''\n\t File.open(File.join(@cache_dir, hash), 'rb') { |f|\n\t\tvalue += f.read\n\t }\n\tend\n\n\treturn value\n end",
"def filename(uri)\n \"#{URI.escape(uri, '/')}.cached\"\n end",
"def downloaded_file\n filename = source[:cached_name] if source[:cached_name]\n filename ||= File.basename(source[:url], \"?*\")\n File.join(Config.cache_dir, filename)\n end",
"def get_api_cache\n Rails.logger.debug \"get api file cache - #{@@cache_file}, exist?... #{File.exist?(@@cache_file)}\" if $DEBUG == true\n \n a=Time.new.to_i\n \n if File.exist?(@@cache_file)\n b=File.ctime(@@cache_file).to_i\n else\n b=0\n end\n c=a-b\n Rails.logger.debug \"Cache File.ctime(@@cache_file)... #{b}\" if $DEBUG == true\n Rails.logger.debug \"if #{!File.exist?(@@cache_file)} or #{c} > #{@@update_interval}...\" if $DEBUG == true\n\n if !File.exist?(@@cache_file) or c > @@update_interval\n Rails.logger.debug \"file cache does not exist or not up to date...\" if $DEBUG == true\n self.update_cache()\n end\n Rails.logger.debug \"cache get contents...\" if $DEBUG == true\n return self.get_cache_content\n end",
"def getFile(tree, name, path = '')\n blob = nil\n\n tree.each_blob do |file|\n blob = file if file[:name] == name[/[^\\/]*/]\n blob[:name] = path + blob[:name]\n end\n\n if blob.nil?\n tree.each_tree do |subtree|\n if subtree[:name] == name[/[^\\/]*/]\n path += name.slice! name[/[^\\/]*/]\n name[0] = ''\n return getFile($repo.lookup(subtree[:oid]), name, path + '/')\n end\n end\n end\n\n return blob\nend",
"def cache_file\n @cache_file ||= File.join cache_dir, \"#{full_name}.gem\"\n end",
"def get_cache(url, options = {})\n\t\t\tpath = cache_path(url, options)\n\t\t\t\t\n\t\t\t# file doesn't exist, make it\n\t\t\tif !File.exists?(path) ||\n\t\t\t\t\toptions[:refresh_cache] ||\n\t\t\t\t\t(File.mtime(path) < Time.now - @cache_timeout)\n\t\t\t\t\t\n\t\t\t\tif options[:debug]\n\t\t\t\t\tif !File.exists?(path)\n\t\t\t\t\t\tputs 'Cache doesn\\'t exist, making: ' + path\n\t\t\t\t\telsif (File.mtime(path) < Time.now - @cache_timeout)\n\t\t\t\t\t\tputs 'Cache has expired, making again, making: ' + path\n\t\t\t\t\telsif options[:refresh_cache]\n\t\t\t\t\t\tputs 'Forced refresh of cache, making: ' + path\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\t# make sure dir exists\n\t\t\t\tFileUtils.mkdir_p(localised_cache_path(options[:lang])) unless File.directory?(localised_cache_path(options[:lang]))\n\t\t\t\t\n\t\t\t\txml_content = http_request(url, options)\n\t\t\t\t\n\t\t\t\t# write the cache\n\t\t\t\tfile = File.open(path, File::WRONLY|File::TRUNC|File::CREAT)\n\t\t\t\tfile.write(xml_content)\n\t\t\t\tfile.close\n\t\t\t\n\t\t\t# file exists, return the contents\n\t\t\telse\n\t\t\t\tputs 'Cache already exists, read: ' + path if options[:debug]\n\t\t\t\t\n\t\t\t\tfile = File.open(path, 'r')\n\t\t\t\txml_content = file.read\n\t\t\t\tfile.close\n\t\t\tend\n\t\t\treturn xml_content\n\t\tend",
"def cache_exists?\n File.exist?(cached_file)\n end",
"def contents\n File.read(path) if exists?\n end",
"def read_cache_file key\n f = File.open( cache_file(key), \"r\" )\n f.flock(File::LOCK_SH)\n out = f.read\n f.close\n return out\n end",
"def get_cached_forums\n #values = Dir.glob(\"*.yml\").map{|a| a.sub(\".yml\",\"\").gsub(\"__\",\"/\"); }\n cp = File.expand_path $cache_path\n values = Dir.entries(cp).grep(/\\.yml$/).map{|a| a.sub(\".yml\",\"\").gsub(\"__\",\"/\"); }\nend",
"def content_of file:, for_sha:\n result = output_of \"git show #{for_sha}:#{file}\"\n result = '' if result == default_file_content_for(file)\n result\nend",
"def cache_repository_revision\n logger.info cache_repository_path.inspect\n File.exists?(cache_repository_path) ? `cd #{cache_repository_path} && git rev-parse --short #{branch}`.strip : \"<em>uncached</em>\".html_safe\n end",
"def cache_path\n @cache_path ||= File.join(\"\", \"gko\", \"cache\", \"#{self.host}\")\n end",
"def get_data_by_key(key)\n expected_file_path = File.join(@temp_folder_path, \"#{key}.txt\")\n if FileFetcher::file_exists?(expected_file_path)\n FileFetcher::get_file_contents(expected_file_path)\n else\n nil\n end\n end",
"def read_filecache_index(filecache)\n CachedFile.reset_seq\n headers = []\n filecache.syswrite('ls')\n filecache.rewind\n filecache.each_line do |line|\n if line[0] == ?#\n headers = line.split\n headers.shift\n if headers[0] == 'filecache' then\n module_version = headers[1]\n end\n next\n end\n\n fields = {}\n tmp = line.split\n headers.each_index { |index| fields[headers[index]] = tmp[index] }\n\n file = fields['file']\n dev = fields['dev']\n next if file == '(noname)'\n if file.include? ?\\\\\n file.gsub! '\\011', \"\\011\" # ht\n file.gsub! '\\012', \"\\012\" # nl\n file.gsub! '\\040', \"\\040\" # sp\n file.gsub! '\\\\', \"\\\\\" # \\\n end\n\n if file =~ /\\([0-9a-f]{2}:[0-9a-f]{2}\\)/ then\n # handle block device\n # - transform file name from digital form to real ones\n fs = @@fstab[file.delete('(:)').hex]\n next unless fs\n file = fs.device_file\n dev = $BDEV_ID\n else\n # handle normal files\n # - expand file name to full path name\n # - ignore dirs/symlinks\n dev = dev[0,5].delete(':').hex\n fs = @@fstab[dev]\n next unless fs\n file = fs.mount_point + file unless fs.mount_point == '/'\n next unless File.file?(file)\n end\n\n cfile = CachedFile.new file\n cfile.dev = dev\n cfile.state = fields['state']\n cfile.ino = fields['ino'].to_i\n cfile.size = fields['size'].to_i\n cfile.cached = fields['cached'].to_i\n cfile.cachedp = fields['cached%'].to_i\n cfile.refcnt = fields['refcnt'].to_i\n cfile.process = fields['process']\n cfile.uid = fields['uid'].to_i\n cfile.accessed = fields['accessed'].to_i\n @cfile_by_name[file] = cfile\n end # filecache.each_line\n end",
"def read_cache_file()\n #\n # Update to Google Domains may be forced by forgetting cached\n # values. This is controlled by the [-u|--force_update] option\n #\n if options[:force_update]\n if File.exists?(options[:cache_file])\n File.delete(options[:cache_file])\n end\n end\n\n #\n # Load the cache file\n #\n return File.exists?(options[:cache_file]) ? YAML.load_file(options[:cache_file]) : {}\n end",
"def file_cache(token, caching_time_in_minutes=30, &payload)\n file = file_name token\n if FileHelper.not_cached_or_to_old? file, caching_time_in_minutes\n load_from_file_cache file\n else\n write_to_file_cache file, (yield payload)\n end\n end",
"def getcached(url)\n return @cached_json if !@cached_json.nil?\n path = CACHE_FILE + url + \".json\"\n if File.exists?(path)\n f = File.open(path)\n return JSON.parse(f.read)\n end\n return nil\n end",
"def cache_item(file_parsed, _objects_db = nil, custom_cache_key = nil)\n _cache_key = custom_cache_key || cache_key\n objects_db = _objects_db || @current_site.get_meta(_cache_key, {}) || {}\n prefix = File.dirname(file_parsed['key'])\n\n s = prefix.split('/').clean_empty\n return file_parsed if s.last == 'thumb'\n s.each_with_index{|_s, i| k = \"/#{File.join(s.slice(0, i), _s)}\".cama_fix_slash; cache_item(file_parse(k), objects_db) unless objects_db[k].present? } unless ['/', '', '.'].include?(prefix)\n\n objects_db[prefix] = {files: {}, folders: {}} if objects_db[prefix].nil?\n if file_parsed['format'] == 'folder'\n objects_db[prefix][:folders][file_parsed['name']] = file_parsed\n else\n objects_db[prefix][:files][file_parsed['name']] = file_parsed\n end\n @current_site.set_meta(_cache_key, objects_db) if _objects_db.nil?\n file_parsed\n end",
"def cache_filename_for_uri( path )\n uid = Digest::MD5.hexdigest( \"#{@uid}:#{path}\" )\n # NOTE: this path needs to exist with r/w permissions for webserver\n @cache_dir.join( uid )\n end",
"def get(key)\n path = File.join(@root, \"#{key}.cache\")\n\n value = safe_open(path) do |f|\n begin\n EncodingUtils.unmarshaled_deflated(f.read, Zlib::MAX_WBITS)\n rescue Exception => e\n @logger.error do\n \"#{self.class}[#{path}] could not be unmarshaled: \" +\n \"#{e.class}: #{e.message}\"\n end\n nil\n end\n end\n\n if value\n FileUtils.touch(path)\n value\n end\n end",
"def find\n \"#{content_path}#{clean_path}\"\n end",
"def cache_dir\n find /^Writeable cache dir: (.*)$/\n end",
"def src_for(filename, env={})\n @semaphore.synchronize do\n refresh(env)\n file = @files[filename]\n unless file and file.has_key? :path\n raise \"#{filename.dump} is not available from file server\"\n end\n \"#{file[:path]}?#{file[:mtime].to_i}\"\n end\n end",
"def read_cache\n @html = File.read(@cache_file) if cache_exist?\n parse_html unless @html.nil?\n end",
"def caching\n @caching = \"data_update[#{data_path}]\"\n end",
"def caching\n @caching = \"data_update[#{data_path}]\"\n end",
"def caching\n @caching = \"data_update[#{data_path}]\"\n end",
"def caching\n @caching = \"data_update[#{data_path}]\"\n end",
"def initialize(cachedContentFile)\n #N Without this the name of the cached content file won't be remembered\n @cachedContentFile = cachedContentFile\n end",
"def select_cache_file\n try_file(system_cache_file) or\n\ttry_file(user_cache_file) or\n\tfail \"Unable to locate a writable cache file.\"\n end",
"def cache_file_for(klassname)\n File.join cache_file_path, klassname.gsub(/:+/, \"-\")\n 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 cache_exist?\n File.exist?(@cache_file)\n end",
"def get_johnny_cache(name)\n cache = read_fragment(name)\n \n if cache #and options and options[:time_to_live]\n m = cache.match( /(<!-- EXPIRE CACHE: )(\\d+)( -->)/ )\n if m.nil? or (m[2].to_i < Time.now.utc.to_i)\n expire_fragment(name)\n cache = nil\n end\n end\n cache\n end",
"def cache key\n begin\n if expired?(key)\n content = Proc.new { yield }.call\n set( key, content )\n end\n content ||= get( key )\n return content\n rescue LocalJumpError\n return nil\n end\n end",
"def default_file_content_for file_name\n \"#{file_name} content\"\nend",
"def read_cache\n @cache_file = select_cache_file\n begin\n\topen(@cache_file, \"rb\") { |f| load_local_cache(f) } || {}\n rescue StandardError => ex\n\t{}\n end\n end",
"def get first_key, second_key=''\n # TODO: validate inputs\n\n begin\n cache_dirs = Dir[File.join(@dir, first_key + '/*')]\n cache_dirs.each do |cache_dir|\n second_key_filename = cache_dir + '/second_key'\n # If second key filename is bad, we skip this directory\n if (!File.exist?(second_key_filename) || File.directory?(second_key_filename))\n next\n end\n second_key_file = File.open(second_key_filename, \"r\" )\n second_key_file.flock(File::LOCK_SH)\n out = second_key_file.read\n if (second_key.to_s == out && File.exist?(cache_dir + '/valid'))\n FileUtils.touch cache_dir + '/last_used'\n cache_dir = File.join(cache_dir, 'content')\n second_key_file.close\n return cache_dir if File.directory?(cache_dir)\n end\n second_key_file.close\n end\n rescue => e\n log \"ERROR: Could not get cache entry. #{e.to_s}\"\n end\n return nil\n end",
"def look_aside(mutable_file_cache, uri)\n fail \"Buildpack cache not defined. Cannot look up #{uri}.\" unless @buildpack_stashes\n\n key = URI.escape(uri, '/')\n @buildpack_stashes.each do |buildpack_stash|\n stashed = buildpack_stash + \"#{key}.cached\"\n @logger.debug { \"Looking in buildpack cache for file '#{stashed}'\" }\n if stashed.exist?\n mutable_file_cache.persist_file stashed\n @logger.debug { \"Using copy of #{uri} from #{buildpack_stash}.\" }\n return\n end\n end\n\n message = \"Buildpack cache does not contain #{uri}\"\n @logger.error { message }\n @buildpack_stashes.each do |buildpack_stash|\n @logger.debug { \"#{buildpack_stash} contents:\\n#{`ls -lR #{buildpack_stash}`}\" }\n end\n fail message\n end",
"def memo\n return @memo_file\n end",
"def file_contents(full_path)\n\t\t::File.read(full_path)\n\trescue Errno::ENOENT\n\t\traise Rush::DoesNotExist, full_path\n\tend",
"def file_contents(full_path)\n\t\t::File.read(full_path)\n\trescue Errno::ENOENT\n\t\traise Rush::DoesNotExist, full_path\n\tend",
"def read_cache_mtime key\n return nil unless File.exists?(cache_file(key))\n File.mtime( cache_file(key) )\n end",
"def content\n @content ||= @filename ? pathname.read : BLANK_TEMPLATE\n end",
"def cached_command_output(command, cache_time = 86400)\n\n cache_directory = '/var/opt/lib/pe-puppet/facts/cached_command_output'\n Dir.mkdir cache_directory unless File.exist? cache_directory\n\n cache_file = cache_directory + '/' + command.gsub(\"/\", \"_\")\n\n if File.exist?(cache_file) && File.mtime(cache_file) > (Time.now - cache_time) then\n command_output = File.read(cache_file).chomp\n else\n command_output = %x{#{command}}\n f = File.open(cache_file, 'w')\n f.puts command_output\n f.close\n end\n\n return command_output\n\nend",
"def cache_store_type\n \"file\"\n end",
"def get_data(key) \n filename = _find_file_key(key)\n return nil if filename.nil?\n file = File.open(@cache_dir + filename, \"rb\")\n contents = file.read\n return Marshal.load(contents)\n end"
] | [
"0.7655323",
"0.66739684",
"0.6588756",
"0.64611346",
"0.6433945",
"0.637749",
"0.6322822",
"0.6317328",
"0.6283636",
"0.6129526",
"0.6094344",
"0.6058541",
"0.6056393",
"0.6007544",
"0.5934763",
"0.59108925",
"0.5858681",
"0.5827437",
"0.5817149",
"0.5802685",
"0.5795141",
"0.57655025",
"0.57622176",
"0.5736471",
"0.5734172",
"0.571767",
"0.56999123",
"0.5694211",
"0.5679856",
"0.56761855",
"0.56391925",
"0.56166834",
"0.5610569",
"0.5609951",
"0.5602949",
"0.5596014",
"0.5596014",
"0.5596014",
"0.5596014",
"0.5596014",
"0.5596014",
"0.5596014",
"0.5596014",
"0.5596014",
"0.55924034",
"0.5579337",
"0.5567124",
"0.55666924",
"0.556222",
"0.5543196",
"0.5537716",
"0.5533513",
"0.55287814",
"0.55224085",
"0.55129194",
"0.5508593",
"0.5503975",
"0.54986805",
"0.5496512",
"0.54953164",
"0.547994",
"0.5479827",
"0.54723424",
"0.545719",
"0.54440206",
"0.5428883",
"0.54260534",
"0.5424561",
"0.5413493",
"0.5410921",
"0.54098666",
"0.5406085",
"0.5399398",
"0.53972936",
"0.5392983",
"0.53809005",
"0.5378196",
"0.5377417",
"0.5377417",
"0.5377417",
"0.5377417",
"0.5370707",
"0.53700566",
"0.53606534",
"0.5353989",
"0.534967",
"0.5340867",
"0.5326587",
"0.5286437",
"0.52761763",
"0.5273536",
"0.5273356",
"0.5272294",
"0.52706784",
"0.52706784",
"0.5266732",
"0.5266084",
"0.52631867",
"0.5246063",
"0.5245762"
] | 0.79947555 | 0 |
Delete any existing cached content file N Without this, there won't be an easy way to delete the cached content file (if it is specified and it exists) | def clearCachedContentFile
#N Without this check, it will try to delete a cached content file even when it doesn't exist
if cachedContentFile and File.exists?(cachedContentFile)
#N Without this, there will be no feedback to the user that the specified cached content file is being deleted
puts " deleting cached content file #{cachedContentFile} ..."
#N Without this, the specified cached content file won't be deleted
File.delete(cachedContentFile)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_cache_files; end",
"def delete_cache_files; end",
"def delete(key)\n File.unlink cache_path(key)\n rescue Errno::ENOENT\n end",
"def delete key\n File.delete( cache_file(key) ) if File.exists?( cache_file(key) )\n end",
"def delete_cached_file(no_raise: false)\n __debug_items(binding)\n return unless attach_cached\n file_attacher.destroy\n file_attacher.set(nil)\n true\n rescue => error\n log_exception(error, __method__)\n re_raise_if_internal_exception(error)\n raise error unless no_raise\n end",
"def remove(key)\n File.unlink cache_path(key)\n rescue Errno::ENOENT\n end",
"def clearCachedContentFiles\n #N Without this, the (local) source cached content file won't be deleted\n @sourceLocation.clearCachedContentFile()\n #N Without this, the (remote) source cached content file won't be deleted\n @destinationLocation.clearCachedContentFile()\n end",
"def clean_cache!(seconds)\n File.grid.namespace.\n where(filename: /\\d+-\\d+-\\d+(?:-\\d+)?\\/.+/).\n and(:filename.lt => (Time.now.utc - seconds).to_i.to_s).\n delete\n end",
"def delete_cache(url, json: true)\n filename = cache_filename(url, json)\n if File.exist?(filename)\n logger.debug(\"Deleting cache #{filename}\")\n File.delete(filename)\n end\n end",
"def test_cachedel_non_empty_file\n _generic_cachedel_test 4000\n end",
"def remove_content\n File.unlink(filename) if File.exist?(filename)\n end",
"def delete(*args)\n args.each do |arg|\n @cache.delete(\"#{@cache_name}:#{arg}\")\n end\n end",
"def remove_unnecessary_cache_files!\n current_keys = cache_files.map do |file|\n get_cache_key_from_filename(file)\n end\n inmemory_keys = responses.keys\n\n unneeded_keys = current_keys - inmemory_keys\n unneeded_keys.each do |key|\n File.unlink(filepath_for(key))\n end\n end",
"def delete(filename); end",
"def invalidate(blob_access, delete_single=false)\n if delete_single\n FileSystemMetaData.new(cache_file_path(blob_access)).delete\n else\n cache_path(blob_access).entries.each {|cache_file|\n unless cache_file.to_s.match(/\\.meta$/) || cache_file.directory?\n base_name = cache_file.to_s\n FileSystemMetaData.new(cache_path(blob_access).join(cache_file)).delete if base_name.match(cache_file_base(blob_access))\n end\n } if Dir.exist?(cache_path(blob_access))\n end\n end",
"def delete\n @lock.synchronize do\n ::File.unlink(@tmpfile) if ::File.exist?(@tmpfile)\n end\n end",
"def clear\n @pages.clear\n @page_counter = 0\n begin\n @f.truncate(0)\n rescue IOError => e\n raise RuntimeError, \"Cannote truncate cache file #{@file_name}: \" +\n e.message\n end\n end",
"def rm_r_cached(path)\n invoke(:rm, '-r', '--cached', path)\n true\n end",
"def remove_archive_cache\n expire_action(:controller => '/articles', :action => 'index')\n expire_fragment(%r{/articles/page/*})\n expire_fragment(%r{/categories/*})\n articles_folder = ActionController::Base.page_cache_directory + '/articles/'\n FileUtils.rmtree articles_folder if File.exists? articles_folder \n end",
"def destroy\n @file_version.destroy\n head :no_content\n end",
"def delete\n File::unlink @path+\".lock\" rescue nil\n File::unlink @path+\".new\" rescue nil\n File::unlink @path rescue Errno::ENOENT\n end",
"def clear\n FileUtils.rm_f(cache_file)\n initialize!\n end",
"def expire_cache\n cache_dir = ActionController::Base.page_cache_directory\n dirs = [\"articles\", \"tags\"]\n files = [\"index.html\", \"about.html\", \"contact.html\", \"articles.html\", \"tags.html\", \"articles.rss\", \"comments.rss\"]\n (files + dirs).each {|f| FileUtils.rm_r(Dir.glob(cache_dir + \"/#{f}\")) rescue Errno::ENOENT }\n RAILS_DEFAULT_LOGGER.info(\"Cache directory '#{cache_dir}' fully sweeped.\")\n end",
"def expire_cache\n filename = name_changed? ? name_was : name\n FileUtils.rm_rf(File.join(Shapes.cache_dir_path, filename))\n FileUtils.rm_f(File.join(Shapes.cache_dir_path, \"#{filename}.xml\"))\n end",
"def delete\n File::unlink @path+\".lock\" rescue nil\n File::unlink @path+\".new\" rescue nil\n File::unlink @path rescue nil\n end",
"def del\n File.delete(@file)\n end",
"def delete\n File.delete(file_name)\n rescue\n # ignore\n end",
"def delete_file\n File.unlink file\n end",
"def delete_file\n File.unlink file\n end",
"def destroy_file\n File.delete full_file_path\n rescue\n end",
"def clear(path)\n return unless @cache_base\n\n target = (@cache_base + path)\n target.exist? && target.rmtree\n end",
"def invalidate_cache_by_file_type\n cache_key = self.cache_removal_key\n unless cache_key.nil?\n # clear matching caches in background\n CacheRemovalJob.new(cache_key).delay.perform\n end\n end",
"def delete_index_file\n $log.info(\"Deleting old index.html file...\")\n File.delete(\"/home/matt/Documents/programming/ruby/dmsw/index.html\")\nend",
"def remove_cache_path\n cache_path.run_action(:delete)\n end",
"def destroy\n file&.delete\n end",
"def uncache file \n refresh = nil\n begin\n is_a_file = F === file\n path = (is_a_file ? file.path : file.to_s) \n stat = (is_a_file ? file.stat : F.stat(file.to_s)) \n refresh = tmpnam(F.dirname(path))\n ignoring_errors do\n F.link(path, refresh) rescue F.symlink(path, refresh)\n end\n ignoring_errors do\n F.chmod(stat.mode, path)\n end\n ignoring_errors do\n F.utime(stat.atime, stat.mtime, path)\n end\n ignoring_errors do\n open(F.dirname(path)){|d| d.fsync}\n end\n ensure \n ignoring_errors do\n F.unlink(refresh) if refresh\n end\n end\n end",
"def destroy\n pid = @generic_file.noid\n @generic_file.delete\n begin\n Resque.enqueue(ContentDeleteEventJob, pid, current_user.user_key)\n rescue Redis::CannotConnectError\n logger.error \"Redis is down!\"\n end\n redirect_to sufia.dashboard_path, :notice => render_to_string(:partial=>'generic_files/asset_deleted_flash', :locals => { :generic_file => @generic_file })\n end",
"def clear_document_cache(document) \n expire_fragment :recent_posts\n expire_fragment :menu\n\n cache_paths = []\n cache_paths << File.join(RAILS_ROOT, 'public', 'cache', document.path)\n\n cache_paths.each do | cache_path |\n Rails.logger.debug 'Deleting CACHE: ' + cache_path\n FileUtils.rm_rf cache_path if File.exists? cache_path\n end\n end",
"def flush\n Dir[ File.join( store, '*.cache' ) ].each do |file|\n File.delete(file)\n end\n end",
"def remove(filename); end",
"def remove!\n MiGA.DEBUG \"Metadata.remove! #{path}\"\n File.unlink(path)\n nil\n end",
"def remove_deleted_files\n cache_file_hash = {}\n @cookbooks_by_name.each_key do |k|\n cache_file_hash[k] = {}\n end\n\n # First populate files from cache\n cache.find(File.join(%w{cookbooks ** {*,.*}})).each do |cache_file|\n md = cache_file.match(%r{^cookbooks/([^/]+)/([^/]+)/(.*)})\n next unless md\n\n (cookbook_name, segment, file) = md[1..3]\n if have_cookbook?(cookbook_name)\n cache_file_hash[cookbook_name][segment] ||= {}\n cache_file_hash[cookbook_name][segment][\"#{segment}/#{file}\"] = cache_file\n end\n end\n # Determine which files don't match manifest\n @cookbooks_by_name.each_key do |cookbook_name|\n cache_file_hash[cookbook_name].each_key do |segment|\n manifest_segment = cookbook_segment(cookbook_name, segment)\n manifest_record_paths = manifest_segment.map { |manifest_record| manifest_record[\"path\"] }.to_set\n to_be_removed = cache_file_hash[cookbook_name][segment].keys.to_set - manifest_record_paths\n to_be_removed.each do |path|\n cache_file = cache_file_hash[cookbook_name][segment][path]\n\n Chef::Log.info(\"Removing #{cache_file} from the cache; its is no longer in the cookbook manifest.\")\n cache.delete(cache_file)\n @events.removed_cookbook_file(cache_file)\n end\n end\n end\n end",
"def uncache(method, url, params = nil, body = nil)\n status = status(method, url, params, body)\n path = status[:path]\n File.unlink(path) if File.exist?(path)\n end",
"def cache_delete(key: cache_key, **)\n Rails.cache.delete(key, namespace: namespace) if validate_key(key)\n end",
"def destroy\n @cach = Cache.find(params[:id])\n @cach.destroy\n\n respond_to do |format|\n format.html { redirect_to caches_url }\n format.json { head :ok }\n end\n end",
"def cache_delete(key)\n @cache_store.delete(key)\n nil\n end",
"def delete\n cache_delete\n super\n end",
"def delete\n cache_delete\n super\n end",
"def delete\n @file = nil\n # file.delete\n end",
"def remove!\n with_callbacks(:remove) do\n delete_file\n @file = nil\n @cache_id = nil\n end\n end",
"def destroy\n File.unlink(@resource[:path])\n Puppet.debug \"deleted file #{@resource[:path]}\"\n end",
"def destroy_file\n FileUtils.rm(full_filename) if File.exists?(full_filename)\n end",
"def cache_delete\n model.send(:cache_delete, cache_key)\n end",
"def delete_cache_pagination_pictures(picture)\n FileUtils.rm_r(Dir.glob(@cache_dir+\"/pictures/page/*\")) rescue Errno::ENOENT\n FileUtils.rm_r(Dir.glob(@cache_dir+\"/pictures/#{picture.permalink}.html\")) rescue Errno::ENOENT\n end",
"def destroy\n delete!(get, phase: :destroyed) if get && !cache.uploaded?(get)\n end",
"def purge\n ::FileUtils.rm(@fname)\n end",
"def delete\n ::File.unlink(@path)\n end",
"def del(key)\n log(\"remove :Cache, #{key}\")\n connection.remove(:Cache, key)\n end",
"def destroy\n @cached_photo = CachedPhoto.find(params[:id])\n @cached_photo.destroy\n\n respond_to do |format|\n format.html { redirect_to(cached_photos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy_file\n object = self.class.bucket.objects.find(full_filename)\n object.destroy\n end",
"def delete\n FileUtils.remove_entry_secure(@directory)\n ObjectSpace.undefine_finalizer(self)\n rescue Errno::ENOENT\n end",
"def destroy_file\n Qiniu::RS.delete(qiniu_config[:bucket_name], full_filename)\n end",
"def sweep_partial_cache\n cache_dir = RAILS_ROOT+\"/tmp/cache/views/*\"\n FileUtils.rm_r(Dir.glob(cache_dir)) rescue Errno::ENOENT\n logger.debug(\"Cache '#{cache_dir}' delete.\")\n end",
"def rm path\n end",
"def test_delete_existing\n @cache.add('Key', 'Data_to_delete', 0, Time.now.to_i + 60)\n result = @cache.delete('Key')\n retrieval = @cache.get('Key')\n\n assert_true result.success\n assert_equal 'SUCCESS', result.message.chomp.split(\"\\s\")[0]\n assert_false retrieval.success\n assert_equal 'NOT_FOUND', retrieval.message.chomp.split(\"\\s\")[0]\n end",
"def invalidate_all!\n FileUtils.rm_r(@cache_path, force: true, secure: true)\n end",
"def delete!\n exist!\n File.unlink @path\n @path = nil\n end",
"def clean\n cache = Cache.instance\n # remove all built files\n cache.targets(false).each do |target|\n cache.remove_target(target)\n FileUtils.rm_f(target)\n end\n # remove all created directories if they are empty\n cache.directories(false).sort {|a, b| b.size <=> a.size}.each do |directory|\n cache.remove_directory(directory)\n next unless File.directory?(directory)\n if (Dir.entries(directory) - ['.', '..']).empty?\n Dir.rmdir(directory) rescue nil\n end\n end\n cache.write\n end",
"def delete_cache_and_img_and_fingerprint\n self.delete_cache_and_img\n\n # why do we bother clearing our fingerprint if the AssetOutput itself\n # is about to get deleted? If we don't, the after_commit handler will\n # rewrite the same cache we just deleted.\n self.fingerprint = ''\n end",
"def delete_content(title)\n File.delete(\"pages/#{title}.txt\")\nend",
"def delete\n begin\n object = bucket.objects.find(@path)\n object.destroy\n true\n rescue Exception => e\n # If the file's not there, don't panic\n nil\n end\n end",
"def file_delete(node, file)\n _out, _local, _remote, code = node.test_and_store_results_together(\"rm #{file}\", 'root', 500)\n code\nend",
"def file_delete(node, file)\n _out, _local, _remote, code = node.test_and_store_results_together(\"rm #{file}\", 'root', 500)\n code\nend",
"def delete!\n safe_close\n File.delete(@file_path)\n end",
"def delete!\n return true unless File.exist?(path)\n FileUtils.rm(path)\n end",
"def destroy_dirty_file!(file)\n system(\"trashtrash #{file}\")\n end",
"def delete\n FileUtils.rm(self.path) if exists?\n end",
"def delete(key)\n raise NotImplementedError.new 'Implement delete(key) in your CacheManager'\n end",
"def delete_file \n #pp \"deleting file_asset: path is\" + full_filepath\n File.delete(full_filepath) if File.exists?(full_filepath)\n end",
"def delete_cache_and_img\n # -- out with the old -- #\n\n finger = self.fingerprint_changed? ? self.fingerprint_was : self.fingerprint\n imgfinger = self.image_fingerprint_changed? ? self.image_fingerprint_was : self.image_fingerprint\n\n if finger && imgfinger\n # -- delete our old cache -- #\n Rails.cache.delete(\"img:\"+[self.asset.id,imgfinger,self.output.code].join(\":\"))\n\n # -- delete our AssetOutput -- #\n path = self.asset.image.path(self)\n\n if path\n # this path could have our current values in it. make sure we've\n # got old fingerprints\n path = path.gsub(self.asset.image_fingerprint,imgfinger).gsub(self.fingerprint,finger)\n\n self.asset.image.delete_path(path)\n end\n end\n\n true\n end",
"def delete_file\n @file = []\n end",
"def rm_rf_ie file, options = {}\n rm_rf file, options if File.exist?(file)\n end",
"def purge\n purge_file\n cdb_destroy\n end",
"def clear_cache\n FileUtils.rm File.expand_path(\"cms-css/#{self.slug}.css\", Rails.public_path), :force => true\n FileUtils.rm File.expand_path(\"cms-js/#{self.slug}.js\", Rails.public_path), :force => true\n end",
"def remove_old_cache\n # get the model name\n model_name = controller_name.singularize\n # get image instance\n image = params[model_name]\n\n # if there is old cache delete\n if image[:image] && !image[:image_cache].empty?\n cache_name = image[:image_cache]\n # get the cache directory\n cache_dir = cache_name.split('/')[0]\n FileUtils.rm_rf(File.join(\"#{Rails.root}\", '/public/uploads/tmp/', cache_dir))\n end\n end",
"def destroy\n File.delete(temp_path)\n end",
"def delete\n if stat.directory?\n FileUtils.rm_rf(file_path)\n else\n ::File.unlink(file_path)\n end\n ::File.unlink(prop_path) if ::File.exist?(prop_path)\n @_prop_hash = nil\n NoContent\n end",
"def expire_caches\n expired_cache = \"expired_cache.#{Time.now.to_f}\"\n Dir.chdir(\"#{Rails.root}/tmp\") do\n FileUtils.mv('cache', expired_cache, :force => true)\n FileUtils.rm_rf(expired_cache)\n end\n end",
"def cache_delete(ck)\n cache_op(:delete, ck)\n nil\n end",
"def destroy\n @article = Article.find(params[:id])\n @article.destroy\n\n respond_to do |format|\n format.html { redirect_to action: 'myspace' }\n format.json { head :no_content }\n end\n\n #Rails.cache.delete_matched /articles\\/index/\n #Rails.cache.delete_matched Regexp.new(\"#{@article.id}\")\n #Rails.cache.delete_matched /articles\\/content/\n\n end",
"def test_cachedel_etcshadow\n assert_raise(Errno::EACCES) { File.cachedel(\"/etc/shadow\") }\n end",
"def delete(filename)\n File.delete File.join(@base_path, filename)\n end",
"def clear\n # TODO: this is rather brutal, in future need to be able to revert\n Rails.logger.info(\"Clearing OpenbisMedataStore at #{filestore_path}\")\n # cache.delete_matched(/.*/)\n # need to add an entry to empty cache otherwise the clear failes on unexisting deak\n cache.fetch('fake') { '' } unless File.exist?(cache.cache_path)\n cache.clear\n end",
"def delete_all_caching_without_touching_additives\n\t\t\tself.delete_category_menu_fragments\n \t\tself.delete_cache\n \t\tself.delete_shared_item_items\n\t\t\tself.delete_category_browser_fragments\nend",
"def delete\n File.delete(header_file_full_path)\n File.delete(data_file_full_path)\n end",
"def clean_cache(staging_path, metadata)\n actual_file_list = Dir.glob(File.join(staging_path, \"**/*\"))\n expected_file_list = []\n CookbookMetadata.new(metadata).files { |_, path, _| expected_file_list << File.join(staging_path, path) }\n\n extra_files = actual_file_list - expected_file_list\n extra_files.each do |path|\n if File.file?(path)\n FileUtils.rm(path)\n end\n end\n end",
"def expire_cache(path = nil)\n return unless Sinatra.options.cache_enabled\n \n path = (path.nil?) ? cache_page_path(request.path_info) : cache_page_path(path)\n if File.exist?(path)\n File.delete(path)\n #log.info( \"Expired Page deleted at: [#{path}]\")\n else\n #log.info( \"No Expired Page was found at the path: [#{path}]\")\n end\n end",
"def destroy\n remove_files(@path + \"*\")\n end",
"def clear!(resource)\n @cache.delete(resource)\n end",
"def delete(key, options = nil)\n Rails.cache.delete(key, options)\n rescue => exc\n Rails.logger.error { \"MEMCACHE-ERROR: delete: K: #{key.inspect}. M: #{exc.message}, I: #{exc.inspect}\" }\n nil\n end"
] | [
"0.7299269",
"0.7299269",
"0.7096548",
"0.70510894",
"0.66761404",
"0.66008186",
"0.64736533",
"0.6442716",
"0.6430355",
"0.64131874",
"0.6367565",
"0.6352273",
"0.63115203",
"0.62943643",
"0.6253384",
"0.61624074",
"0.6156015",
"0.6105692",
"0.6085801",
"0.6084458",
"0.6058367",
"0.60307866",
"0.5991024",
"0.5988951",
"0.59622455",
"0.5910533",
"0.5855824",
"0.58542573",
"0.58542573",
"0.5851243",
"0.5842753",
"0.58356005",
"0.58329046",
"0.58308476",
"0.58243793",
"0.5822781",
"0.5814562",
"0.5808258",
"0.5805488",
"0.5788991",
"0.5779134",
"0.57748675",
"0.5763595",
"0.5763434",
"0.5756082",
"0.5755917",
"0.5748231",
"0.5748231",
"0.57477033",
"0.5711694",
"0.5686127",
"0.5681161",
"0.56533086",
"0.56499976",
"0.5647156",
"0.5643832",
"0.5633204",
"0.5624471",
"0.56212884",
"0.5620253",
"0.5614812",
"0.5613707",
"0.56014186",
"0.5590218",
"0.5582994",
"0.5581415",
"0.55803037",
"0.5579227",
"0.55774176",
"0.55773497",
"0.55768836",
"0.5567317",
"0.5567317",
"0.5565937",
"0.5564399",
"0.555982",
"0.5559206",
"0.55511326",
"0.5548245",
"0.5538947",
"0.55293804",
"0.5527902",
"0.5520113",
"0.55168766",
"0.55145437",
"0.55142385",
"0.55114573",
"0.55043626",
"0.550432",
"0.5502254",
"0.5478295",
"0.5476572",
"0.54754287",
"0.546988",
"0.54669744",
"0.545653",
"0.545457",
"0.5447699",
"0.5446842",
"0.5439082"
] | 0.73291236 | 0 |
Get the cached content tree (if any), read from the specified cached content file. N Without this method, there won't be an easy way to get the cached content from the cached content file (if the file is specified, and if it exists) | def getCachedContentTree
#N Without this, we won't know the name of the specified cached content file (if it is specified)
file = getExistingCachedContentTreeFile
#N Without this check, we would attempt to read a non-existent file
if file
#N Without this, a content tree that has been cached won't be returned.
return ContentTree.readFromFile(file)
else
return nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getContentTree\n #N Without this check we would try to read the cached content file when there isn't one, or alternatively, we would retrieve the content details remotely, when we could have read them for a cached content file\n if cachedContentFile and File.exists?(cachedContentFile)\n #N Without this, the content tree won't be read from the cached content file\n return ContentTree.readFromFile(cachedContentFile)\n else\n #N Without this, we wouldn't retrieve the remote content details\n contentTree = contentHost.getContentTree(baseDir)\n #N Without this, the content tree might be in an arbitrary order\n contentTree.sort!\n #N Without this check, we would try to write a cached content file when no name has been specified for it\n if cachedContentFile != nil\n #N Without this, the cached content file wouldn't be updated from the most recently retrieved details\n contentTree.writeToFile(cachedContentFile)\n end\n #N Without this, the retrieved sorted content tree won't be retrieved\n return contentTree\n end\n end",
"def load_cached\n content = File.open(self.cache_file_name, \"rb\") { |f| f.read }\n puts(\"[MODEL_FILE] Loaded #{self.cache_file_name} from cache\")\n return content\n end",
"def getCachedContentTreeMapOfHashes\n #N Without this, we won't know the name of the specified cached content file (if it is specified)\n file = getExistingCachedContentTreeFile\n #N Without this check, we would attempt to read a non-existent file\n if file\n #N Without this, there won't be feedback to the user that we are reading the cached file hashes\n puts \"Reading cached file hashes from #{file} ...\"\n #N Without this, a map of cached file hashes won't be returned\n return ContentTree.readMapOfHashesFromFile(file)\n else\n #N Without this, the method wouldn't consistently return an array of timestamp + map of hashes in the case where there is no cached content file\n return [nil, {}]\n end\n end",
"def read_cache\n @html = File.read(@cache_file) if cache_exist?\n parse_html unless @html.nil?\n end",
"def getExistingCachedContentTreeFile\n #N Without this check, it would try to find the cached content file when none was specified\n if cachedContentFile == nil\n #N Without this, there will be no feedback to the user that no cached content file is specified\n puts \"No cached content file specified for location\"\n return nil\n #N Without this check, it will try to open the cached content file when it doesn't exist (i.e. because it hasn't been created, or, it has been deleted)\n elsif File.exists?(cachedContentFile)\n #N Without this, it won't return the cached content file when it does exist\n return cachedContentFile\n else\n #N Without this, there won't be feedback to the user that the specified cached content file doesn't exist.\n puts \"Cached content file #{cachedContentFile} does not yet exist.\"\n return nil\n end\n end",
"def read_cache\n @cache_file = select_cache_file\n begin\n\topen(@cache_file, \"rb\") { |f| load_local_cache(f) } || {}\n rescue StandardError => ex\n\t{}\n end\n end",
"def read_from_cache\n if config.cache.is_a?(Proc)\n config.cache.call(nil)\n elsif (config.cache.is_a?(String) || config.cache.is_a?(Pathname)) &&\n File.exist?(file_path)\n open(file_path).read\n end\n end",
"def get(file)\n binding.pry\n #return the values from cached first\n @cached[file] || \n @file_metadata[file] || \n read_metadata_from_yaml(file) || \n cache(file, read_metadata_from_disk(file)) \n end",
"def cache_read(cache_file)\n _data = nil\n File.open(cache_file, \"r\") do |cache_data|\n cache_data.flock(File::LOCK_EX)\n _data = cache_data.read\n cache_data.flock(File::LOCK_UN)\n end\n _data\n end",
"def getContentTree\n #N Without this we won't have timestamp and the map of file hashes used to efficiently determine the hash of a file which hasn't been modified after the timestamp\n cachedTimeAndMapOfHashes = getCachedContentTreeMapOfHashes\n #N Without this we won't have the timestamp to compare against file modification times\n cachedTime = cachedTimeAndMapOfHashes[0]\n #N Without this we won't have the map of file hashes\n cachedMapOfHashes = cachedTimeAndMapOfHashes[1]\n #N Without this we won't have an empty content tree which can be populated with data describing the files and directories within the base directory\n contentTree = ContentTree.new()\n #N Without this we won't have a record of a time which precedes the recording of directories, files and hashes (which can be used when this content tree is used as a cached for data when constructing some future content tree)\n contentTree.time = Time.now.utc\n #N Without this, we won't record information about all sub-directories within this content tree\n for subDir in @baseDirectory.subDirs\n #N Without this, this sub-directory won't be recorded in the content tree\n contentTree.addDir(subDir.relativePath)\n end\n #N Without this, we won't record information about the names and contents of all files within this content tree\n for file in @baseDirectory.allFiles\n #N Without this, we won't know the digest of this file (if we happen to have it) from the cached content tree\n cachedDigest = cachedMapOfHashes[file.relativePath]\n #N Without this check, we would assume that the cached digest applies to the current file, even if one wasn't available, or if the file has been modified since the time when the cached value was determined.\n # (Extra note: just checking the file's mtime is not a perfect check, because a file can \"change\" when actually it or one of it's enclosing sub-directories has been renamed, which might not reset the mtime value for the file itself.)\n if cachedTime and cachedDigest and File.stat(file.fullPath).mtime < cachedTime\n #N Without this, the digest won't be recorded from the cached digest in those cases where we know the file hasn't changed\n digest = cachedDigest\n else\n #N Without this, a new digest won't be determined from the calculated hash of the file's actual contents\n digest = hashClass.file(file.fullPath).hexdigest\n end\n #N Without this, information about this file won't be added to the content tree\n contentTree.addFile(file.relativePath, digest)\n end\n #N Without this, the files and directories in the content tree might be listed in some indeterminate order\n contentTree.sort!\n #N Without this check, a new version of the cached content file will attempt to be written, even when no name has been specified for the cached content file\n if cachedContentFile != nil\n #N Without this, a new version of the cached content file (ready to be used next time) won't be created\n contentTree.writeToFile(cachedContentFile)\n end\n return contentTree\n end",
"def load_from_file_cache(file)\n puts \"loading stuff from #{file}\"\n File.open(file, 'r') do |input|\n Marshal.load(input.read)\n end\n end",
"def get_from_cache(cache_file, cache_ttl=5)\n if File.exists?(cache_file)\n now = Time.now\n file_mtime = File.mtime(cache_file)\n file_age = now - file_mtime\n if ((cache_ttl < 0) || (file_age <= cache_ttl))\n file = File.open(cache_file, \"r:UTF-8\")\n return file.read\n else\n # Return False if the cache is old\n return false\n end\n else\n # Return False if the cache file doesn't exist\n return false\n end\n end",
"def read(key)\n File.read(cache_path(key))\n rescue Errno::ENOENT\n nil\n end",
"def content\n return @content if application.cache_pages? && @content\n\n @content = if file?\n IO.read(path)\n elsif io?\n path.read\n else\n path\n end\n end",
"def get_cache(key)\n treecache.fetch(key)\n end",
"def from_cache(filename, max_age, options=nil)\r\n\t\toptions ||= {}\r\n\t\tpath = self.get_path filename\r\n\r\n\t\treturn nil if !self.valid_cache(filename, max_age)\r\n\r\n\t\tbegin\r\n\t\t\tdata = self.read(path)\r\n\t\t\treturn data if options[:plain_text] == true\r\n\t\t\tjson_obj = JSON.parse(data, {:symbolize_names => true})\r\n\t\t\treturn json_obj[:data]\r\n\t\trescue StandardError => e\r\n\t\t\t$stderr.puts \"Warning: Could not read cache for #{filename} (#{e})\"\r\n\t\t\treturn nil\r\n\t\tend\r\n\t\r\n\tend",
"def getContentCache(theContent)\n\n\ttheChecksum = Digest::SHA256.hexdigest(theContent).insert(2, '/');\n\ttheCache = \"#{PATH_FORMAT_CACHE}/#{theChecksum}\";\n\t\n\treturn theCache;\n\nend",
"def get_cached_gist(gist, file)\n return nil if @cache_disabled\n cache_file = get_cache_file_for gist, file\n File.read cache_file if File.exist? cache_file\n end",
"def read_cache_file()\n #\n # Update to Google Domains may be forced by forgetting cached\n # values. This is controlled by the [-u|--force_update] option\n #\n if options[:force_update]\n if File.exists?(options[:cache_file])\n File.delete(options[:cache_file])\n end\n end\n\n #\n # Load the cache file\n #\n return File.exists?(options[:cache_file]) ? YAML.load_file(options[:cache_file]) : {}\n end",
"def read_cache_file key\n f = File.open( cache_file(key), \"r\" )\n f.flock(File::LOCK_SH)\n out = f.read\n f.close\n return out\n end",
"def read\n raise MissingFileMapping.new if mapping.blank?\n raise NodesMissing.new if mapping.nodes.blank?\n\n @content ||= self.connection.get(self.nodes.first, self.access_level, self.path)\n\n return @content\n end",
"def [](key)\n File.read(cache_path(key))\n rescue Errno::ENOENT\n nil\n end",
"def read_content(entry)\n entry.rewind if entry.respond_to? :rewind\n case entry\n when File, Tempfile, StringIO then entry.read\n when Dir then (entry.entries - ['.', '..']).collect { |filename| read_content(Pathname.new(File.join(entry.path, filename))) }.compact.sort\n when String then entry\n when Pathname then\n if entry.directory?\n read_content(entry)\n elsif entry.file?\n File.open(entry, 'r:binary').read\n end\n end\nend",
"def read_cache(url, json: true)\n filename = cache_filename(url, json)\n if File.exist?(filename)\n logger.debug(\"Reading cache #{filename}\")\n if json\n JSON.parse(IO.read(filename))\n else\n IO.read(filename)\n end\n end\n end",
"def read_from_cache\n result = if cache.is_a?(Proc)\n cache.call(nil)\n elsif File.exist?(cache.to_s)\n File.read(cache)\n end\n result if valid_rates?(result)\n end",
"def get_cache(url, options = {})\n\t\t\tpath = @@cache_directory_path + options[:lang] + '/' + url_to_filename(url)\n\t\t\t\n\t\t\t# file doesn't exist, make it\n\t\t\tif !File.exists?(path)\n\t\t\t\tif options[:debug]\n\t\t\t\t\tputs 'Cache doesn\\'t exist, making: ' + path\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\t# make sure dir exists\n\t\t\t\tFileUtils.mkdir_p(localised_cache_path(options[:lang])) unless File.directory?(localised_cache_path(options[:lang]))\n\t\t\t\t\n\t\t\t\txml_content = http_request(url, options)\n\t\t\t\t\n\t\t\t\t# write the cache\n\t\t\t\tfile = File.open(path, File::WRONLY|File::TRUNC|File::CREAT)\n\t\t\t\tfile.write(xml_content)\n\t\t\t\tfile.close\n\t\t\t\n\t\t\t# file exists, return the contents\n\t\t\telse\n\t\t\t\tputs 'Cache already exists, read: ' + path if options[:debug]\n\t\t\t\t\n\t\t\t\tfile = File.open(path, 'r')\n\t\t\t\txml_content = file.read\n\t\t\t\tfile.close\n\t\t\tend\n\t\t\treturn xml_content\n\t\tend",
"def get_content(file_path)\n puts \"getting markdown for: #{file_path}.md\\n\\n\"\n file = File.open(\"data/pages/#{file_path}.md\", \"r\")\n return file.read\nend",
"def getcached(url)\n return @cached_json if !@cached_json.nil?\n path = CACHE_FILE + url + \".json\"\n if File.exists?(path)\n f = File.open(path)\n return JSON.parse(f.read)\n end\n return nil\n end",
"def read_cache_file\n return nil unless File.file? @cache_file\n\n cache = YAML.load_file(@cache_file)\n\n return nil unless cache.is_a? Hash\n return nil unless cache[:userid] == @userid\n\n @token = cache[:token]\n @prev_account_info = cache[:account_info]\n @remote_folders = cache[:remote_folders]\n @remote_contexts = cache[:remote_contexts]\n @last_sync = cache[:last_sync]\n end",
"def get_content(model_name)\n @_content ||= {}\n\n # return content if it has already been memoized\n return @_content[model_name] unless @_content[model_name].nil?\n\n #get class of content model we are trying to get content for\n model = get_content_model(model_name)\n\n if is_plural?(model_name)\n content = model.find(:all, :path => custom_content_path, :parent => self)\n else\n content = model.find(:first, :path => custom_content_path, :parent => self)\n end\n\n\n # memoize content so we don't parse file again on the same request\n @_content[model_name] = content\n end",
"def get_cache(url, options = {})\n\t\t\tpath = cache_path(url, options)\n\t\t\t\t\n\t\t\t# file doesn't exist, make it\n\t\t\tif !File.exists?(path) ||\n\t\t\t\t\toptions[:refresh_cache] ||\n\t\t\t\t\t(File.mtime(path) < Time.now - @cache_timeout)\n\t\t\t\t\t\n\t\t\t\tif options[:debug]\n\t\t\t\t\tif !File.exists?(path)\n\t\t\t\t\t\tputs 'Cache doesn\\'t exist, making: ' + path\n\t\t\t\t\telsif (File.mtime(path) < Time.now - @cache_timeout)\n\t\t\t\t\t\tputs 'Cache has expired, making again, making: ' + path\n\t\t\t\t\telsif options[:refresh_cache]\n\t\t\t\t\t\tputs 'Forced refresh of cache, making: ' + path\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\t# make sure dir exists\n\t\t\t\tFileUtils.mkdir_p(localised_cache_path(options[:lang])) unless File.directory?(localised_cache_path(options[:lang]))\n\t\t\t\t\n\t\t\t\txml_content = http_request(url, options)\n\t\t\t\t\n\t\t\t\t# write the cache\n\t\t\t\tfile = File.open(path, File::WRONLY|File::TRUNC|File::CREAT)\n\t\t\t\tfile.write(xml_content)\n\t\t\t\tfile.close\n\t\t\t\n\t\t\t# file exists, return the contents\n\t\t\telse\n\t\t\t\tputs 'Cache already exists, read: ' + path if options[:debug]\n\t\t\t\t\n\t\t\t\tfile = File.open(path, 'r')\n\t\t\t\txml_content = file.read\n\t\t\t\tfile.close\n\t\t\tend\n\t\t\treturn xml_content\n\t\tend",
"def get(key)\n path = File.join(@root, \"#{key}.cache\")\n\n value = safe_open(path) do |f|\n begin\n EncodingUtils.unmarshaled_deflated(f.read, Zlib::MAX_WBITS)\n rescue Exception => e\n @logger.error do\n \"#{self.class}[#{path}] could not be unmarshaled: \" +\n \"#{e.class}: #{e.message}\"\n end\n nil\n end\n end\n\n if value\n FileUtils.touch(path)\n value\n end\n end",
"def getcached(url)\n _cached = instance_variable_get \"@cached_#{hashed(url)}\"\n return _cached unless _cached.nil?\n path = CACHE_FILE + \"#{hashed(url)}.json\"\n if File.exists?(path)\n File.open(path, \"r:UTF-8\") do |f|\n _cached = JSON.parse(f.read)\n instance_variable_set(\"@cached_#{hashed(url)}\", _cached)\n return _cached\n end \n end\n return nil\n end",
"def get_html\n print \"Getting doc...\"\n if File.size?(@cache)\n html = File.read(@cache)\n else\n html = open(URL).read\n IO.write(@cache, html)\n end\n puts \"done.\"\n html\n end",
"def get(path)\n return @contents if path.nil?\n aget(path.split(':'))\n end",
"def load\n if File.exist?(@file_path)\n\n @_cache = JSON File.open(@file_path, &:read).strip\n else\n $stderr.puts \"#{@file_path} does not exist\"\n end\n end",
"def load_cache\n #orig_enc = @encoding\n\n File.open cache_path, 'rb' do |io|\n @cache = Marshal.load io.read\n end\n\n load_enc = @cache[:encoding]\n\n # TODO this feature will be time-consuming to add:\n # a) Encodings may be incompatible but transcodeable\n # b) Need to warn in the appropriate spots, wherever they may be\n # c) Need to handle cross-cache differences in encodings\n # d) Need to warn when generating into a cache with different encodings\n #\n #if orig_enc and load_enc != orig_enc then\n # warn \"Cached encoding #{load_enc} is incompatible with #{orig_enc}\\n\" \\\n # \"from #{path}/cache.ri\" unless\n # Encoding.compatible? orig_enc, load_enc\n #end\n\n @encoding = load_enc unless @encoding\n\n @cache[:pages] ||= []\n @cache[:main] ||= nil\n @cache[:c_class_variables] ||= {}\n @cache[:c_singleton_class_variables] ||= {}\n\n @cache[:c_class_variables].each do |_, map|\n map.each do |variable, name|\n @c_enclosure_names[variable] = name\n end\n end\n\n @cache\n rescue Errno::ENOENT\n end",
"def cached\n @cached ||= Rails.cache.read(self.cache_key, opts_for_cache)\n end",
"def contents\n File.read(path) if exists?\n end",
"def get_contents_for(path)\n out = get_path(path)\n out.css(\"#content\").inner_html\n end",
"def get_data(key) \n filename = _find_file_key(key)\n return nil if filename.nil?\n file = File.open(@cache_dir + filename, \"rb\")\n contents = file.read\n return Marshal.load(contents)\n end",
"def load_cache\n q = @client.caches.get(:name=>name)\n @client.logger.debug \"GOT Q: \" + q.inspect\n @data = q.raw\n q\n end",
"def getcached(url)\n _cached = instance_variable_get \"@cached_#{hashed(url)}\"\n return _cached unless _cached.nil?\n path = CACHE_FILE + \"#{hashed(url)}.json\"\n if File.exists?(path)\n f = File.open(path)\n _cached = JSON.parse(f.read)\n instance_variable_set(\"@cached_#{hashed(url)}\", _cached)\n return _cached\n end\n return nil\n end",
"def getcached(url)\n _cached = instance_variable_get \"@cached_#{hashed(url)}\"\n return _cached unless _cached.nil?\n path = CACHE_FILE + \"#{hashed(url)}.json\"\n if File.exists?(path)\n f = File.open(path)\n _cached = JSON.parse(f.read)\n instance_variable_set(\"@cached_#{hashed(url)}\", _cached)\n return _cached\n end\n return nil\n end",
"def getcached(url)\n _cached = instance_variable_get \"@cached_#{hashed(url)}\"\n return _cached unless _cached.nil?\n path = CACHE_FILE + \"#{hashed(url)}.json\"\n if File.exists?(path)\n f = File.open(path)\n _cached = JSON.parse(f.read)\n instance_variable_set(\"@cached_#{hashed(url)}\", _cached)\n return _cached\n end\n return nil\n end",
"def getcached(url)\n _cached = instance_variable_get \"@cached_#{hashed(url)}\"\n return _cached unless _cached.nil?\n path = CACHE_FILE + \"#{hashed(url)}.json\"\n if File.exists?(path)\n f = File.open(path)\n _cached = JSON.parse(f.read)\n instance_variable_set(\"@cached_#{hashed(url)}\", _cached)\n return _cached\n end\n return nil\n end",
"def getcached(url)\n _cached = instance_variable_get \"@cached_#{hashed(url)}\"\n return _cached unless _cached.nil?\n path = CACHE_FILE + \"#{hashed(url)}.json\"\n if File.exists?(path)\n f = File.open(path)\n _cached = JSON.parse(f.read)\n instance_variable_set(\"@cached_#{hashed(url)}\", _cached)\n return _cached\n end\n return nil\n end",
"def getcached(url)\n _cached = instance_variable_get \"@cached_#{hashed(url)}\"\n return _cached unless _cached.nil?\n path = CACHE_FILE + \"#{hashed(url)}.json\"\n if File.exists?(path)\n f = File.open(path)\n _cached = JSON.parse(f.read)\n instance_variable_set(\"@cached_#{hashed(url)}\", _cached)\n return _cached\n end\n return nil\n end",
"def getcached(url)\n _cached = instance_variable_get \"@cached_#{hashed(url)}\"\n return _cached unless _cached.nil?\n path = CACHE_FILE + \"#{hashed(url)}.json\"\n if File.exists?(path)\n f = File.open(path)\n _cached = JSON.parse(f.read)\n instance_variable_set(\"@cached_#{hashed(url)}\", _cached)\n return _cached\n end\n return nil\n end",
"def getcached(url)\n _cached = instance_variable_get \"@cached_#{hashed(url)}\"\n return _cached unless _cached.nil?\n path = CACHE_FILE + \"#{hashed(url)}.json\"\n if File.exists?(path)\n f = File.open(path)\n _cached = JSON.parse(f.read)\n instance_variable_set(\"@cached_#{hashed(url)}\", _cached)\n return _cached\n end\n return nil\n end",
"def getcached(url)\n _cached = instance_variable_get \"@cached_#{hashed(url)}\"\n return _cached unless _cached.nil?\n path = CACHE_FILE + \"#{hashed(url)}.json\"\n if File.exists?(path)\n f = File.open(path)\n _cached = JSON.parse(f.read)\n instance_variable_set(\"@cached_#{hashed(url)}\", _cached)\n return _cached\n end\n return nil\n end",
"def get(base, name, opts)\n self.load if @cache.nil?\n path = Jekyll.sanitized_path(base, name)\n key = path[@site.source.length..-1]\n mtime = File.mtime(path)\n\n if @cache.has_key?(key) && mtime == @cache[key]['modified']\n # file is not modified\n ret_hash(@cache[key]['yaml'], @cache[key]['content'], false, false, false)\n else\n puts \"parsed yaml #{key}...\"\n self.set_content(key, path, mtime, opts)\n end\n end",
"def load\n @cache = JSON.parse(File.read(file))\n rescue\n @cache = {}\n end",
"def read_content_from_file(file_path)\n names = file_path.split('/')\n file_name = names.pop\n directory = self.mkdir(names.join('/'))\n directory.children[file_name].content\n end",
"def cache_get(key)\n cache_file = @config[:cache_directory] / \"#{key}.cache\"\n if File.file?(cache_file)\n _data, _expire = Marshal.load(cache_read(cache_file))\n if _expire.nil? || Time.now < _expire\n Merb.logger.info(\"cache: hit (#{key})\")\n return _data\n end\n FileUtils.rm_f(cache_file)\n end\n Merb.logger.info(\"cache: miss (#{key})\")\n nil\n end",
"def cache\n store = Moneta.new :File, dir: 'moneta'\n Cachy.cache_store = store\n Cachy\n end",
"def data_cache(fpath)\n (@data_caches ||= []) << fpath\n return fpath\n end",
"def file(path, *args)\n return file_via_connection(path, *args) unless cache_enabled?(:file)\n\n @cache[:file][path] ||= file_via_connection(path, *args)\n end",
"def get_cache_file(key)\n _find_file_key(key)\n end",
"def get_contents \n @contents = []\n\n sub_directory_names = Dir[CONTENT_ROOT_DIRECTORY + \"/*\"]\n\n sub_directory_names.each do |sub_directory_name|\n sub_directory_basename = File.basename(sub_directory_name)\n @contents.push(Content.new(sub_directory_basename))\n end\n end",
"def get_cached_forums\n #values = Dir.glob(\"*.yml\").map{|a| a.sub(\".yml\",\"\").gsub(\"__\",\"/\"); }\n cp = File.expand_path $cache_path\n values = Dir.entries(cp).grep(/\\.yml$/).map{|a| a.sub(\".yml\",\"\").gsub(\"__\",\"/\"); }\nend",
"def cache_read(key: cache_key, **)\n Rails.cache.read(key, namespace: namespace) if validate_key(key)\n end",
"def read\n @contents ||= File.read @src_path if readable?\n end",
"def read(config, force: false, &block)\n # write new data from resolver if forced\n return write(config, &block) if force\n\n cached = cache.read(key)\n\n if cached.nil?\n logger.debug \"Cache miss: (#{key})\"\n write config, &block\n else\n logger.debug \"Cache hit: (#{key})\"\n cached\n end\n end",
"def contents(path)\n puts \"#contents(#{path})\" if DEBUG\n results = []\n root_path = zk_path(path)\n zk.find(root_path) do |z_path|\n if (z_path != root_path)\n z_basename = z_path.split('/').last\n stats = zk.stat(z_path)\n results << \"#{z_basename}\" if stats.numChildren > 0\n results << \"#{z_basename}.contents\" if zk.stat(z_path).dataLength > 0\n ZK::Find.prune\n end\n end\n results\n end",
"def load_cache\n @list = YAML::load_file Settings[:cache_file]\n end",
"def open(key)\n BlockFile.open(cache_path(key), 'rb')\n rescue Errno::ENOENT\n nil\n end",
"def get_file(key, use_cache = true)\n if use_cache\n db = (@current_site.get_meta(cache_key) || {})[File.dirname(key)] || {}\n else\n db = objects(File.dirname(key)) unless use_cache\n end\n (db[:files][File.basename(key)] || db[:folders][File.basename(key)]) rescue nil\n end",
"def bagel_cache_page(content = nil, options = nil)\n return unless perform_caching && caching_allowed && AppConfig[:cache_to_filesytem]\n\n path = case options\n when Hash\n url_for(options.merge(:only_path => true, :skip_relative_url_root => true, :format => params[:format]))\n when String\n options\n else\n request.path\n end\n\n self.class.cache_page(content || response.body, path)\n end",
"def get(key)\n unless @store[key].present?\n path = path_for_key(key)\n if File.exists?(path)\n begin\n data = File.open(path, 'r') { |f| Marshal.load(f) }\n @store[key] = data\n rescue Exception => e\n Honeybadger.notify(\"Something went wrong reading RSSCache file from disk: #{path} #{e}\")\n end\n end\n end\n @store[key]\n end",
"def cache_open(url)\n Cachy.cache(url, hash_key: true) { open(url).read }\nend",
"def get_contents(effective_path)\n raise NotImplementedError.new\n end",
"def getContentsFromFile filetoread\n return File.read(Dir.pwd + '/' + filetoread)\nend",
"def getContentsFromFile filetoread\n return File.read(Dir.pwd + '/' + filetoread)\nend",
"def read_content(name, resource)\n read(name, resource) do |file|\n if file.header.typeflag == \"2\"\n return read_content(name, File.absolute_path(file.header.linkname,File.dirname(resource)))\n end\n if file.header.typeflag != \"0\"\n raise NotAFile.new(\"not a file\", {'path' => resource})\n end\n return file.read\n end\n end",
"def get(slug_url, options = {})\n if configatron.content_o_matic.retrieve(:cache_results, false)\n url = url_from_slug(slug_url, options)\n ContentCache.get(url) do |url|\n content = get_without_cache(slug_url, options)\n if content.success?\n ContentCache.set(url, content)\n end\n return content\n end\n else\n return get_without_cache(slug_url, options)\n end\n end",
"def treecache\n @treecache ||= TaggedCache.new\n end",
"def read_entry(key, options)\n if cache = local_cache\n cache.fetch_entry(key) { super }\n else\n super\n end\n end",
"def local_contents_of(file)\n contents_of(local_branch, file)\n end",
"def cache(content, options={})\n return content unless Sinatra.options.cache_enabled\n \n unless content.nil?\n path = cache_page_path(request.path_info)\n FileUtils.makedirs(File.dirname(path))\n open(path, 'wb+') { |f| f << content } \n content\n end\n end",
"def get_cached_data(uri)\n Rails.cache.fetch(uri, {expires_in: 24.hours, raw: true}) { JSON.parse(RestClient::Resource.new(uri).get) }\n end",
"def get_file_contents(file_path)\n input_file = File.open(file_path, 'r')\n input_file_contents = input_file.read\n input_file.close\n input_file_contents\n end",
"def content_files\n @cache_content_files ||= cached_datafiles.reject { |df| sip_descriptor == df }\n end",
"def cache_item(file_parsed, _objects_db = nil, custom_cache_key = nil)\n _cache_key = custom_cache_key || cache_key\n objects_db = _objects_db || @current_site.get_meta(_cache_key, {}) || {}\n prefix = File.dirname(file_parsed['key'])\n\n s = prefix.split('/').clean_empty\n return file_parsed if s.last == 'thumb'\n s.each_with_index{|_s, i| k = \"/#{File.join(s.slice(0, i), _s)}\".cama_fix_slash; cache_item(file_parse(k), objects_db) unless objects_db[k].present? } unless ['/', '', '.'].include?(prefix)\n\n objects_db[prefix] = {files: {}, folders: {}} if objects_db[prefix].nil?\n if file_parsed['format'] == 'folder'\n objects_db[prefix][:folders][file_parsed['name']] = file_parsed\n else\n objects_db[prefix][:files][file_parsed['name']] = file_parsed\n end\n @current_site.set_meta(_cache_key, objects_db) if _objects_db.nil?\n file_parsed\n end",
"def initialize(cachedContentFile)\n #N Without this the name of the cached content file won't be remembered\n @cachedContentFile = cachedContentFile\n end",
"def get(key = '')\n if key != '' && ::File.exists?(@cache_dir+key)\n # Is the File older than a day?\n if file_age(@cache_dir+key) > 1\n # Delete and return a cache miss\n File.delete(@cache_dir+key)\n return false\n end\n\n puts \"Reading from cache with key: #{key}\" if ENV['DEBUG']\n data = ::File.read(@cache_dir+key)\n return (data.length > 0) ? data : false\n end\n\n return false\n end",
"def cache_content(uri, content)\n clear_cache(uri)\n\n time = Time.now.to_i\n\n cache_store.write(cache_key(uri), time)\n cache_store.write(cache_key([uri, time]), content)\n \n content\n end",
"def cache\n @@cache ||= PStore.new(File.expand_path(@@cache_file))\n end",
"def cache_page(content = nil, options = nil)\n return unless perform_caching && caching_allowed\n\n path = case options\n when Hash\n url_for(options.merge(:only_path => true, :skip_relative_url_root => true, :format => params[:format]))\n when String\n options\n else\n request.path\n end\n\n self.class.cache_page(content || response.body, path)\n end",
"def read_filecache_index(filecache)\n CachedFile.reset_seq\n headers = []\n filecache.syswrite('ls')\n filecache.rewind\n filecache.each_line do |line|\n if line[0] == ?#\n headers = line.split\n headers.shift\n if headers[0] == 'filecache' then\n module_version = headers[1]\n end\n next\n end\n\n fields = {}\n tmp = line.split\n headers.each_index { |index| fields[headers[index]] = tmp[index] }\n\n file = fields['file']\n dev = fields['dev']\n next if file == '(noname)'\n if file.include? ?\\\\\n file.gsub! '\\011', \"\\011\" # ht\n file.gsub! '\\012', \"\\012\" # nl\n file.gsub! '\\040', \"\\040\" # sp\n file.gsub! '\\\\', \"\\\\\" # \\\n end\n\n if file =~ /\\([0-9a-f]{2}:[0-9a-f]{2}\\)/ then\n # handle block device\n # - transform file name from digital form to real ones\n fs = @@fstab[file.delete('(:)').hex]\n next unless fs\n file = fs.device_file\n dev = $BDEV_ID\n else\n # handle normal files\n # - expand file name to full path name\n # - ignore dirs/symlinks\n dev = dev[0,5].delete(':').hex\n fs = @@fstab[dev]\n next unless fs\n file = fs.mount_point + file unless fs.mount_point == '/'\n next unless File.file?(file)\n end\n\n cfile = CachedFile.new file\n cfile.dev = dev\n cfile.state = fields['state']\n cfile.ino = fields['ino'].to_i\n cfile.size = fields['size'].to_i\n cfile.cached = fields['cached'].to_i\n cfile.cachedp = fields['cached%'].to_i\n cfile.refcnt = fields['refcnt'].to_i\n cfile.process = fields['process']\n cfile.uid = fields['uid'].to_i\n cfile.accessed = fields['accessed'].to_i\n @cfile_by_name[file] = cfile\n end # filecache.each_line\n end",
"def load_cache_for(klassname)\n path = cache_file_for klassname\n\n cache = nil\n\n if File.exist? path and\n File.mtime(path) >= File.mtime(class_cache_file_path) and\n @use_cache then\n open path, 'rb' do |fp|\n begin\n cache = Marshal.load fp.read\n rescue\n #\n # The cache somehow is bad. Recreate the cache.\n #\n $stderr.puts \"Error reading the cache for #{klassname}; recreating the cache!\"\n cache = create_cache_for klassname, path\n end\n end\n else\n cache = create_cache_for klassname, path\n end\n\n cache\n end",
"def read_content(repo, ref, file)\n Base64.decode64(connection.contents(\"#{organization}/#{repo}\", path: file, ref: ref).content)\n end",
"def read_cache(obj, options = {})\n k = key(obj)\n\n ret = storage.get(k) || save_cache(obj)\n\n if options[:deserialized]\n serializer.deserialize(ret)\n else\n ret\n end\n end",
"def get(options={})\n res, status = @client.get(\"#{path(options)}/#{URI.escape options[:name]}\")\n return Cache.new(self, res)\n end",
"def read(view)\n return Cache.view[view] ||= ::File.read(view) if View.options.read_cache\n ::File.read(view)\n end",
"def /(file)\n Tree.content_by_path(repo, id, file, commit_id, path)\n end",
"def content\n @content = File.read(path)\n end",
"def cache_page(content, path, extension = nil, gzip = Zlib::BEST_COMPRESSION)\n if perform_caching\n page_cache.cache(content, path, extension, gzip)\n end\n end",
"def get(options={})\n if options.is_a?(String)\n options = {:name=>options}\n end\n options[:name] ||= @client.cache_name\n res = @client.parse_response(@client.get(\"#{path(options)}\"))\n Cache.new(@client, res)\n end",
"def aget(path)\n _aget(path, @contents)\n end"
] | [
"0.74917275",
"0.7052276",
"0.704695",
"0.7043376",
"0.68831205",
"0.67872566",
"0.678021",
"0.6449568",
"0.64164776",
"0.6360816",
"0.6349079",
"0.6342801",
"0.6331629",
"0.63180935",
"0.630582",
"0.6261884",
"0.62607056",
"0.6240054",
"0.6202332",
"0.61656773",
"0.61142474",
"0.6111563",
"0.6103364",
"0.61013865",
"0.60728514",
"0.60626066",
"0.6027815",
"0.59987825",
"0.5986721",
"0.59856874",
"0.59666455",
"0.5945389",
"0.5922004",
"0.5914266",
"0.58953786",
"0.5867183",
"0.58637005",
"0.58385396",
"0.58318865",
"0.58156043",
"0.58007693",
"0.57872784",
"0.5784375",
"0.5784375",
"0.5784375",
"0.5784375",
"0.5784375",
"0.5784375",
"0.5784375",
"0.5784375",
"0.5784375",
"0.5763645",
"0.5745443",
"0.57237625",
"0.5682072",
"0.5661935",
"0.5658776",
"0.56577843",
"0.56556314",
"0.56496996",
"0.5645054",
"0.56440336",
"0.56159425",
"0.56098074",
"0.5600888",
"0.55868053",
"0.55864996",
"0.5578256",
"0.55755687",
"0.5565221",
"0.5557756",
"0.5538366",
"0.55368656",
"0.55368656",
"0.5536793",
"0.5534639",
"0.5533407",
"0.5532298",
"0.55317",
"0.5529577",
"0.5518762",
"0.55107814",
"0.54985875",
"0.5493517",
"0.54868764",
"0.5484938",
"0.54831976",
"0.54794",
"0.54732025",
"0.54576993",
"0.5454167",
"0.5446752",
"0.54270166",
"0.5414211",
"0.54133266",
"0.5412962",
"0.5408917",
"0.5407772",
"0.5402495",
"0.5389215"
] | 0.8271353 | 0 |
Read a map of file hashes (mapping from relative file name to hash value) from the specified cached content file N Without this, there won't be an easy way to get a map of file hashes (keyed by relative file name), for the purpose of getting the hashes of existing files which are known not to have changed (by comparing modification time to timestamp, which is also returned) | def getCachedContentTreeMapOfHashes
#N Without this, we won't know the name of the specified cached content file (if it is specified)
file = getExistingCachedContentTreeFile
#N Without this check, we would attempt to read a non-existent file
if file
#N Without this, there won't be feedback to the user that we are reading the cached file hashes
puts "Reading cached file hashes from #{file} ..."
#N Without this, a map of cached file hashes won't be returned
return ContentTree.readMapOfHashesFromFile(file)
else
#N Without this, the method wouldn't consistently return an array of timestamp + map of hashes in the case where there is no cached content file
return [nil, {}]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def buildCodeFilesHashFromFiles()\n\t\tdir = @cacheDirPath \n\t\tfilesList = Dir.glob(dir + \"**/*\").select{|e| File.file? e}\n\t\tfilesList.map.with_index{|file,index|\n\t\t\t#p \"cacheFile: \" + index.to_s if index % 1000 == 0\n\t\t\tp \"cacheFile: \" + index.to_s \n\t\t\tfilePath = dir + index.to_s + \".yaml\"\n\t\t\tfile = File.read(filePath)\n\t\t\tYAML.load(file)\n\t\t}.to_h\n\tend",
"def read_filecache_index(filecache)\n CachedFile.reset_seq\n headers = []\n filecache.syswrite('ls')\n filecache.rewind\n filecache.each_line do |line|\n if line[0] == ?#\n headers = line.split\n headers.shift\n if headers[0] == 'filecache' then\n module_version = headers[1]\n end\n next\n end\n\n fields = {}\n tmp = line.split\n headers.each_index { |index| fields[headers[index]] = tmp[index] }\n\n file = fields['file']\n dev = fields['dev']\n next if file == '(noname)'\n if file.include? ?\\\\\n file.gsub! '\\011', \"\\011\" # ht\n file.gsub! '\\012', \"\\012\" # nl\n file.gsub! '\\040', \"\\040\" # sp\n file.gsub! '\\\\', \"\\\\\" # \\\n end\n\n if file =~ /\\([0-9a-f]{2}:[0-9a-f]{2}\\)/ then\n # handle block device\n # - transform file name from digital form to real ones\n fs = @@fstab[file.delete('(:)').hex]\n next unless fs\n file = fs.device_file\n dev = $BDEV_ID\n else\n # handle normal files\n # - expand file name to full path name\n # - ignore dirs/symlinks\n dev = dev[0,5].delete(':').hex\n fs = @@fstab[dev]\n next unless fs\n file = fs.mount_point + file unless fs.mount_point == '/'\n next unless File.file?(file)\n end\n\n cfile = CachedFile.new file\n cfile.dev = dev\n cfile.state = fields['state']\n cfile.ino = fields['ino'].to_i\n cfile.size = fields['size'].to_i\n cfile.cached = fields['cached'].to_i\n cfile.cachedp = fields['cached%'].to_i\n cfile.refcnt = fields['refcnt'].to_i\n cfile.process = fields['process']\n cfile.uid = fields['uid'].to_i\n cfile.accessed = fields['accessed'].to_i\n @cfile_by_name[file] = cfile\n end # filecache.each_line\n end",
"def file_ids_hash\n if @file_ids_hash.blank?\n # load the file sha's from cache if possible\n cache_file = File.join(self.path,'.loopoff')\n if File.exists?(cache_file)\n @file_ids_hash = YAML.load(File.read(cache_file))\n else\n # build it\n @file_ids_hash = {}\n self.loopoff_file_names.each do |f|\n @file_ids_hash[File.basename(f)] = Grit::GitRuby::Internal::LooseStorage.calculate_sha(File.read(f),'blob')\n end\n # write the cache\n File.open(cache_file,'w') do |f|\n f.puts YAML.dump(@file_ids_hash) \n end\n end \n end\n @file_ids_hash\n end",
"def cache_buster_hash(*files)\n i = files.map { |f| File.mtime(f).to_i }.max\n (i * 4567).to_s.reverse[0...6]\n end",
"def get(file)\n binding.pry\n #return the values from cached first\n @cached[file] || \n @file_metadata[file] || \n read_metadata_from_yaml(file) || \n cache(file, read_metadata_from_disk(file)) \n end",
"def cache_ids()\n hit_values = File.open(@mzid_file) do |io|\n doc = Nokogiri::XML.parse(io, nil, nil, Nokogiri::XML::ParseOptions::DEFAULT_XML | Nokogiri::XML::ParseOptions::NOBLANKS | Nokogiri::XML::ParseOptions::STRICT)\n doc.remove_namespaces!\n root = doc.root\n \n cache_db_seq_entries(root)\n cache_pep_ev(root)\n \n peptide_lst = root.xpath('//Peptide')\n @pep_h = Hash.new\n @mod_h = Hash.new\n peptide_lst.each do |pnode|\n \n pep_id = pnode['id']\n pep_seq = get_peptide_sequence(pnode)\n mod_line = get_modifications(pnode)\n @pep_h[pep_id] = pep_seq \n @mod_h[pep_id] = mod_line \n end\n \n end\n end",
"def map_files\n file_map = {}\n entry_file = Pathname.new(map_entry)\n entry_found = false\n case @files\n when Hash\n @files.each do |path, file|\n file_map[path.to_s] = File.expand_path(file.to_s)\n entry_found = true if path.to_s==entry_file.to_s\n end\n else\n base_paths = @base_paths.collect {|path| Pathname.new(path).expand_path }\n @files.each do |fn|\n next unless fn\n relpath = strip_path(base_paths, fn) || fn\n file_map[relpath.to_s] = File.expand_path(fn.to_s)\n entry_found = true if relpath==entry_file\n end\n end\n file_map[entry_file.to_s] = File.expand_path(@entry_file.to_s) unless entry_found\n file_map\n end",
"def find_caches\n Dir.glob(File.join(@root, '**/*.cache')).reduce([]) { |stats, filename|\n stat = safe_stat(filename)\n # stat maybe nil if file was removed between the time we called\n # dir.glob and the next stat\n stats << [filename, stat] if stat\n stats\n }.sort_by { |_, stat| stat.mtime.to_i }\n end",
"def [](key)\n File.read(cache_path(key))\n rescue Errno::ENOENT\n nil\n end",
"def get_cache_file(key)\n _find_file_key(key)\n end",
"def read_cache_file key\n f = File.open( cache_file(key), \"r\" )\n f.flock(File::LOCK_SH)\n out = f.read\n f.close\n return out\n end",
"def hash_file path, hash_store\r\n\thexdigest = HASH_DIGEST.hexdigest(open(path, 'rb') { |io| io.read })\r\n\thash_store[hexdigest] << path\r\nend",
"def contents_hash(paths)\n return if paths.nil?\n\n paths = paths.compact.select { |path| File.file?(path) }\n return if paths.empty?\n # rubocop:disable GitHub/InsecureHashAlgorithm\n paths.sort\n .reduce(Digest::XXHash64.new, :file)\n .digest\n .to_s(16) # convert to hex\n # rubocop:enable GitHub/InsecureHashAlgorithm\n end",
"def read_cache\n @cache_file = select_cache_file\n begin\n\topen(@cache_file, \"rb\") { |f| load_local_cache(f) } || {}\n rescue StandardError => ex\n\t{}\n end\n end",
"def load_from_file_cache(file)\n puts \"loading stuff from #{file}\"\n File.open(file, 'r') do |input|\n Marshal.load(input.read)\n end\n end",
"def cache_file(input)\n key = Digest.hexencode(Digest::SHA2.digest(input.to_yaml))\n return @directory + \"/\" + key + \".yaml\"\n end",
"def [](key)\n\thash = hash(key)\n\n\tvalue = nil\n\tif File.exist?(File.join(@cache_dir, hash))\n\t value = ''\n\t File.open(File.join(@cache_dir, hash), 'rb') { |f|\n\t\tvalue += f.read\n\t }\n\tend\n\n\treturn value\n end",
"def read(key)\n File.read(cache_path(key))\n rescue Errno::ENOENT\n nil\n end",
"def digests_for(path)\n\t\t\ttotal = 0\n\n\t\t\[email protected] do |key, digest|\n\t\t\t\tdigest.reset\n\t\t\tend\n\n\t\t\tFile.open(path, \"rb\") do |file|\n\t\t\t\tbuffer = \"\"\n\t\t\t\twhile file.read(1024 * 1024 * 10, buffer)\n\t\t\t\t\ttotal += buffer.bytesize\n\t\t\t\t\t\n\t\t\t\t\[email protected](total) if @progress\n\t\t\t\t\t\n\t\t\t\t\[email protected] do |key, digest|\n\t\t\t\t\t\tdigest << buffer\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tmetadata = {}\n\t\t\t\n\t\t\[email protected] do |key, digest|\n\t\t\t\tmetadata[\"key.\" + key] = digest.hexdigest\n\t\t\tend\n\t\t\t\n\t\t\treturn metadata\n\t\tend",
"def mtimes\n @files.inject({}) do |hash, g|\n Dir[g].each { |file| hash[file] = File.mtime(file) }\n hash\n end\n end",
"def files_map(files)\n files.\n map do |file|\n {\n id: file[:id],\n uid: file[:uid],\n title: file[\"title\"],\n path: file[:file_path],\n }\n end\n end",
"def hash_file(filename)\n file = File.read(filename)\n tlsh_hash(file.bytes)\n end",
"def file_hashes\n @file_hashes ||= file_field_sets.map do |file_field_set|\n instantiation_fields, file_fields = file_field_set.partition do |field|\n instantiation_header?(field.header)\n end\n\n file_hash = fields_to_hash(file_fields)\n file_hash['files'] = [fields_to_hash(instantiation_fields)]\n\n file_hash\n end\n end",
"def get_cache_path_names\n if File.exists?(CachedAssetPackager::Config.send(\"#{self.asset_type}_cache_path_config\"))\n @cache_path_names = YAML::load(File.read(CachedAssetPackager::Config.send(\"#{self.asset_type}_cache_path_config\")))\n else\n @cache_path_names = {}\n each_file_set(:cache_path_name)\n write_cache_path_file\n end\n end",
"def data_cache(fpath)\n (@data_caches ||= []) << fpath\n return fpath\n end",
"def get_file_hash(fullPath)\n contents = File.read(fullPath)\n fileHash = Digest::MD5.hexdigest(contents)\n return fileHash\nend",
"def hash(pathname)\n ext = pathname.extname\n ext = ('' == ext || nil == ext) ? :none : ext.to_sym\n digest = Digest::MD5.hexdigest(File.read(pathname.to_s))\n @scanned[ext] ||= {}\n @scanned[ext][digest] ||= []\n @scanned[ext][digest] << pathname\n end",
"def read\n return unless File.exist?(filename)\n\n name = DEFAULT_NAME\n save = Hash.new{ |h,k| h[k.to_s] = {} }\n\n File.read(filename).lines.each do |line|\n if md = /^\\[(\\w+)\\]$/.match(line)\n name = md[1]\n end\n if md = /^(\\w+)\\s+(.*?)$/.match(line)\n save[name][md[2]] = md[1]\n end\n end\n\n save.each do |name, digest|\n @saved[name] = digest\n end\n end",
"def cache_item(file_parsed, _objects_db = nil, custom_cache_key = nil)\n _cache_key = custom_cache_key || cache_key\n objects_db = _objects_db || @current_site.get_meta(_cache_key, {}) || {}\n prefix = File.dirname(file_parsed['key'])\n\n s = prefix.split('/').clean_empty\n return file_parsed if s.last == 'thumb'\n s.each_with_index{|_s, i| k = \"/#{File.join(s.slice(0, i), _s)}\".cama_fix_slash; cache_item(file_parse(k), objects_db) unless objects_db[k].present? } unless ['/', '', '.'].include?(prefix)\n\n objects_db[prefix] = {files: {}, folders: {}} if objects_db[prefix].nil?\n if file_parsed['format'] == 'folder'\n objects_db[prefix][:folders][file_parsed['name']] = file_parsed\n else\n objects_db[prefix][:files][file_parsed['name']] = file_parsed\n end\n @current_site.set_meta(_cache_key, objects_db) if _objects_db.nil?\n file_parsed\n end",
"def lookup_map\n @lookup_map ||= begin\n gpath = directory.join(\"**/*.#{extension_name}\")\n\n Pathname.glob(gpath).each_with_object({}) do |path, map|\n map[ key_from_path(path) ] = path\n end\n end\n end",
"def load_index_cache(file)\n @indexes = Marshal.load(File.read(file))\n nil\n end",
"def cache_file key\n File.join( store, key+\".cache\" )\n end",
"def cache_files\n Dir.glob(File.join(@cache_dir, '*'))\n .map{|f| f.gsub(/#{@cache_dir}\\/?/, '')}\n .sort\n end",
"def file_map\n @file_map ||= (\n map_file ? YAML.load_file(map_file) : {}\n )\n end",
"def read_cache_mtime key\n return nil unless File.exists?(cache_file(key))\n File.mtime( cache_file(key) )\n end",
"def get_cache_file_for(gist, file)\n bad_chars = /[^a-zA-Z0-9\\-_.]/\n gist = gist.gsub bad_chars, ''\n file = file.gsub bad_chars, ''\n md5 = Digest::MD5.hexdigest \"#{gist}-#{file}\"\n File.join @cache_folder, \"#{gist}-#{file}-#{md5}.cache\"\n end",
"def hash\n return (path + file_id.to_s).hash\n end",
"def look_aside(mutable_file_cache, uri)\n fail \"Buildpack cache not defined. Cannot look up #{uri}.\" unless @buildpack_stashes\n\n key = URI.escape(uri, '/')\n @buildpack_stashes.each do |buildpack_stash|\n stashed = buildpack_stash + \"#{key}.cached\"\n @logger.debug { \"Looking in buildpack cache for file '#{stashed}'\" }\n if stashed.exist?\n mutable_file_cache.persist_file stashed\n @logger.debug { \"Using copy of #{uri} from #{buildpack_stash}.\" }\n return\n end\n end\n\n message = \"Buildpack cache does not contain #{uri}\"\n @logger.error { message }\n @buildpack_stashes.each do |buildpack_stash|\n @logger.debug { \"#{buildpack_stash} contents:\\n#{`ls -lR #{buildpack_stash}`}\" }\n end\n fail message\n end",
"def sort_paths_to_hash(files)\n temp = {}\n files.each do |f|\n run = run_name_from_path(f)\n temp[run] = [f].concat([temp[run]]).flatten.compact\n end\n temp\n end",
"def read_cache_file()\n #\n # Update to Google Domains may be forced by forgetting cached\n # values. This is controlled by the [-u|--force_update] option\n #\n if options[:force_update]\n if File.exists?(options[:cache_file])\n File.delete(options[:cache_file])\n end\n end\n\n #\n # Load the cache file\n #\n return File.exists?(options[:cache_file]) ? YAML.load_file(options[:cache_file]) : {}\n end",
"def file_cache(token, caching_time_in_minutes=30, &payload)\n file = file_name token\n if FileHelper.not_cached_or_to_old? file, caching_time_in_minutes\n load_from_file_cache file\n else\n write_to_file_cache file, (yield payload)\n end\n end",
"def read_cache_fixtures!\n files = cache_files\n files.each do |file|\n cache_key = get_cache_key_from_filename(file)\n responses[cache_key] = Marshal.load(File.read(file))\n end\n end",
"def getHashFromJson(filename)\n File.open( filename, \"r\" ) do |f|\n JSON.load(f)\n end\nend",
"def read_all_dates(src_path) \n hash = {}\n read_pics_filenames(src_path).each { |pic| hash[pic] = read_pic_date(pic).to_f } \n return hash\nend",
"def listFileHashes\n return contentHost.listFileHashes(baseDir)\n end",
"def getContentTree\n #N Without this we won't have timestamp and the map of file hashes used to efficiently determine the hash of a file which hasn't been modified after the timestamp\n cachedTimeAndMapOfHashes = getCachedContentTreeMapOfHashes\n #N Without this we won't have the timestamp to compare against file modification times\n cachedTime = cachedTimeAndMapOfHashes[0]\n #N Without this we won't have the map of file hashes\n cachedMapOfHashes = cachedTimeAndMapOfHashes[1]\n #N Without this we won't have an empty content tree which can be populated with data describing the files and directories within the base directory\n contentTree = ContentTree.new()\n #N Without this we won't have a record of a time which precedes the recording of directories, files and hashes (which can be used when this content tree is used as a cached for data when constructing some future content tree)\n contentTree.time = Time.now.utc\n #N Without this, we won't record information about all sub-directories within this content tree\n for subDir in @baseDirectory.subDirs\n #N Without this, this sub-directory won't be recorded in the content tree\n contentTree.addDir(subDir.relativePath)\n end\n #N Without this, we won't record information about the names and contents of all files within this content tree\n for file in @baseDirectory.allFiles\n #N Without this, we won't know the digest of this file (if we happen to have it) from the cached content tree\n cachedDigest = cachedMapOfHashes[file.relativePath]\n #N Without this check, we would assume that the cached digest applies to the current file, even if one wasn't available, or if the file has been modified since the time when the cached value was determined.\n # (Extra note: just checking the file's mtime is not a perfect check, because a file can \"change\" when actually it or one of it's enclosing sub-directories has been renamed, which might not reset the mtime value for the file itself.)\n if cachedTime and cachedDigest and File.stat(file.fullPath).mtime < cachedTime\n #N Without this, the digest won't be recorded from the cached digest in those cases where we know the file hasn't changed\n digest = cachedDigest\n else\n #N Without this, a new digest won't be determined from the calculated hash of the file's actual contents\n digest = hashClass.file(file.fullPath).hexdigest\n end\n #N Without this, information about this file won't be added to the content tree\n contentTree.addFile(file.relativePath, digest)\n end\n #N Without this, the files and directories in the content tree might be listed in some indeterminate order\n contentTree.sort!\n #N Without this check, a new version of the cached content file will attempt to be written, even when no name has been specified for the cached content file\n if cachedContentFile != nil\n #N Without this, a new version of the cached content file (ready to be used next time) won't be created\n contentTree.writeToFile(cachedContentFile)\n end\n return contentTree\n end",
"def get_digest(file, version)\n # Make a hash with each individual file as a key, with the appropriate digest as value.\n inverted = get_state(version).invert\n my_files = {}\n inverted.each do |files, digest|\n files.each do |i_file|\n my_files[i_file] = digest\n end\n end\n # Now see if the requested file is actually here.\n unless my_files.key?(file)\n raise OcflTools::Errors::FileMissingFromVersionState, \"Get_digest can't find requested file #{file} in version #{version}.\"\n end\n\n my_files[file]\n end",
"def load_data(filename)\n if File.exist? filename\n File.foreach (filename) do |line|\n number = line.chomp.to_i\n next if (@hash1.key?(number) || @hash2.key?(number))\n @hash1[number] = true if number <= 0\n @hash2[number] = true if number > 0\n end\n end\n end",
"def read_file name, reader = nil\n res = @file_cache[name]\n return (res || nil) unless res.nil?\n @file_cache[name] = false\n return nil unless File.exist?(name)\n reader = @readers[reader] if reader.is_a?(Symbol)\n ignored_errors = []\n (Array(reader) + @readers.values).each do |r|\n begin\n result = r.call(name)\n if result\n @file_cache[name] = result\n return result\n end\n rescue Exception => e\n ignored_errors << e\n end\n end\n raise RuntimeError, \"Error reading #{name}#{ ignored_errors.empty? ? \"\" : \": \" + ignored_errors.inspect }\"\n end",
"def entries\n @entries ||= Hash.new do |entries, path|\n path = self.class.path(path).to_s\n entries[path] = if @original_files.include? path\n zip.fopen(path).read\n else\n \"\"\n end\n end\n end",
"def applicable_owners_files_hash\n return @applicable_owners_files_hash if !@applicable_owners_files_hash.nil?\n\n # Make hash of (directory => [files in that directory in this commit]) pairs\n\n puts \"changed files: #{changed_files.inspect}\"\n\n affected_dirs_hash = changed_files.collect_to_reverse_hash do |file|\n File.dirname(file)\n end\n\n puts \"affected_dirs_hash: #{affected_dirs_hash.inspect}\"\n\n affected_dirs = affected_dirs_hash.keys\n\n # Make hash of owners file => [file1, file2, file3]\n res = affected_dirs.inject(Hash.new) do |hash, dir|\n owner = find_owners_file(dir)\n\n # If there's no OWNERS file for this dir, just skip it\n if owner.nil?\n return hash\n end\n\n data = {\n :owner_data => owner,\n :files => affected_dirs_hash[dir]\n }\n\n key = owner[:path]\n\n if (hash.include?(key))\n combined_data = hash[key]\n combined_data[:files] = combined_data[:files] + data[:files]\n\n hash[key] = combined_data\n else\n hash[key] = data\n end\n hash\n end \n\n @applicable_owners_files_hash = res\n end",
"def snapshot_filesystem\n mtimes = {}\n\n files = @files.map { |file| Dir[file] }.flatten.uniq\n\n files.each do |file|\n if File.exists? file\n mtimes[file] = File.stat(file).mtime\n end\n end\n\n mtimes\n end",
"def read_multi(*names)\n options = names.extract_options!\n return {} if names == []\n\n keys = names.map{|name| normalize_key(name, options)}\n args = [keys, options]\n args.flatten!\n\n instrument(:read_multi, names) do |payload|\n failsafe(:read_multi, returning: {}) do\n values = with { |c| c.mget(*args) }\n values.map! { |v| v.is_a?(ActiveSupport::Cache::Entry) ? v.value : v }\n\n Hash[names.zip(values)].reject{|k,v| v.nil?}.tap do |result|\n payload[:hits] = result.keys if payload\n end\n end\n end\n end",
"def read_summary(fname)\n hash={}\n # Read file\n File.open(fname,'r') do |f|\n # Loop over line\n f.each_line do |line|\n line.chomp!\n index,content = line.split(/\\s*==\\s*/)\n hash[index] = content # index:id, content:path\n end\n end\n return hash\nend",
"def write_if_empty\n return if cached_content.present?\n\n @diff_collection.diff_files.each do |diff_file|\n next unless cacheable?(diff_file)\n\n diff_file_id = diff_file.file_identifier\n\n cached_content[diff_file_id] = diff_file.highlighted_diff_lines.map(&:to_hash)\n end\n\n cache.write(key, cached_content, expires_in: 1.week)\n end",
"def hashdump dictfilepath\n @lookup = {}\n IO.foreach(dictfilepath) do |word|\n next unless word.size > 3\n word.chomp!\n @lookup[ word.sort2 ] ||= []\n @lookup[ word.sort2 ] << word\n end\n end",
"def cache_read(cache_file)\n _data = nil\n File.open(cache_file, \"r\") do |cache_data|\n cache_data.flock(File::LOCK_EX)\n _data = cache_data.read\n cache_data.flock(File::LOCK_UN)\n end\n _data\n end",
"def read_cache\n @html = File.read(@cache_file) if cache_exist?\n parse_html unless @html.nil?\n end",
"def files_hash\n @files_hash\n end",
"def getStat(fileName)\n result = Hash.new(0)\n counter = 0\n while((File.size(fileName) == 0) && (counter < 60)) #wait for sixty seconds; ran into situation where file is open but zero sized\n sleep 1\n counter = counter + 1\n end\n File.open(fileName).each do |line|\n next if (line =~/^#/)\n mArray = line.chomp.split(/=|:/).map {|x| x.upcase} \n result[mArray.first] = result[mArray.first] + mArray[-1].to_i \n end\n return result\nend",
"def read_from_cache\n if config.cache.is_a?(Proc)\n config.cache.call(nil)\n elsif (config.cache.is_a?(String) || config.cache.is_a?(Pathname)) &&\n File.exist?(file_path)\n open(file_path).read\n end\n end",
"def create_cache_files\n @cache_path_names = {}\n each_file_set(:create_cache_file)\n write_cache_path_file\n end",
"def get_files(version)\n my_state = get_state(version)\n my_files = {}\n\n my_state.each do |digest, filepaths| # filepaths is [Array]\n filepaths.each do |logical_filepath|\n # look up this file via digest in @manifest.\n physical_filepath = @manifest[digest]\n # physical_filepath is an [Array] of files, but they're all the same so only need 1.\n my_files[logical_filepath] = physical_filepath[0]\n end\n end\n my_files\n end",
"def [] files\n # This stores all our matches\n match_hash = {}\n\n # Go through each file, check if the file basename matches the regexp.\n files.each do |f|\n path, file = File.split(f)\n\n if (m = match_against(file))\n replacement = populate_based_on(m)\n match_hash[f] = if path == '.'\n replacement\n else\n File.join(path, replacement)\n end\n end\n end\n match_hash\n end",
"def get_cached_gist(gist, file)\n return nil if @cache_disabled\n cache_file = get_cache_file_for gist, file\n File.read cache_file if File.exist? cache_file\n end",
"def mtime_snapshot\n snapshot = {}\n filenames = expand_directories(@unexpanded_filenames)\n\n # Remove files in the exclude filenames list\n filenames -= expand_directories(@unexpanded_excluded_filenames)\n\n filenames.each do |filename|\n mtime = File.exist?(filename) ? File.mtime(filename) : Time.new(0)\n snapshot[filename] = mtime\n end\n snapshot\n end",
"def read_multi(*names)\n options = names.extract_options!\n mapping = names.inject({}) { |memo, name| memo[namespaced_key(name, options)] = name; memo }\n instrument_with_log(:read_multi, mapping.keys) do\n results = {}\n if local_cache\n mapping.each_key do |key|\n if value = local_cache.read_entry(key, options)\n results[key] = value\n end\n end\n end\n\n data = with { |c| c.get_multi(mapping.keys - results.keys) }\n results.merge!(data)\n results.inject({}) do |memo, (inner, _)|\n entry = results[inner]\n # NB Backwards data compatibility, to be removed at some point\n value = (entry.is_a?(ActiveSupport::Cache::Entry) ? entry.value : entry)\n memo[mapping[inner]] = value\n local_cache.write_entry(inner, value, options) if local_cache\n memo\n end\n end\n end",
"def memoize(name, file=nil)\n cache = File.open(file, 'rb'){ |io| Marshal.load(io) } rescue {}\n\n (class<<self; self; end).send(:define_method, name) do |*args|\n unless cache.has_key?(args)\n cache[args] = super(*args)\n File.open(file, 'wb'){ |f| Marshal.dump(cache, f) } if file\n end\n cache[args]\n end\n cache\n end",
"def processFile dir\n\tdir.each do |file|\n\t\tif File.directory?(file) then next;\n\t\t\telse \n\t\t\t\th = {File.basename(file) => getHash(file)}\n\t\t\t\[email protected]!(h)\n\t\tend\n\tend\n\t@hash\nend",
"def breakdown_by_file\n @file_breakdown ||= begin\n breakdown = Hash.new { |h,k| h[k] = Array.new }\n cache.each do |filename, (language, _)|\n breakdown[language] << filename.dup.force_encoding(\"UTF-8\").scrub\n end\n breakdown\n end\n end",
"def files_hashs\n @files.map do |file|\n hash = case file\n when String\n { url: file }\n when Hash\n file.dup\n else\n raise ArgumentError, 'files must be an Array of Stings or Hashs'\n end\n\n hash[:local_path] = local_path\n hash\n end\n end",
"def findLargeHash(f)\r\n incr_digest = Digest::SHA1.new()\r\n file = File.open(f, \"rb\")\r\n count = 0\r\n file.each_line do |line|\r\n if count == 1\r\n incr_digest << line\r\n end\r\n count = count + 1\r\n if count >= 2\r\n break\r\n end\r\n end\r\n return incr_digest.hexdigest + File.size(f).to_s(16)\r\nend",
"def get_data(key) \n filename = _find_file_key(key)\n return nil if filename.nil?\n file = File.open(@cache_dir + filename, \"rb\")\n contents = file.read\n return Marshal.load(contents)\n end",
"def load_cache\n #orig_enc = @encoding\n\n File.open cache_path, 'rb' do |io|\n @cache = Marshal.load io.read\n end\n\n load_enc = @cache[:encoding]\n\n # TODO this feature will be time-consuming to add:\n # a) Encodings may be incompatible but transcodeable\n # b) Need to warn in the appropriate spots, wherever they may be\n # c) Need to handle cross-cache differences in encodings\n # d) Need to warn when generating into a cache with different encodings\n #\n #if orig_enc and load_enc != orig_enc then\n # warn \"Cached encoding #{load_enc} is incompatible with #{orig_enc}\\n\" \\\n # \"from #{path}/cache.ri\" unless\n # Encoding.compatible? orig_enc, load_enc\n #end\n\n @encoding = load_enc unless @encoding\n\n @cache[:pages] ||= []\n @cache[:main] ||= nil\n @cache[:c_class_variables] ||= {}\n @cache[:c_singleton_class_variables] ||= {}\n\n @cache[:c_class_variables].each do |_, map|\n map.each do |variable, name|\n @c_enclosure_names[variable] = name\n end\n end\n\n @cache\n rescue Errno::ENOENT\n end",
"def manifested_files\n manifest_files.inject([]) do |acc, mf|\n files = File.open(mf) { |io|\n io.readlines.map do |line|\n _digest, path = line.chomp.split(/\\s+/, 2)\n decode_filename(path)\n end\n }\n\n (acc + files).uniq\n end\n end",
"def _all_files\n dict = {}\n paths.each do |path|\n FileUtils.cd(path) { \n Dir[glob].each { |id|\n next unless File.exist?(id) && FileTest.file?(id)\n dict[id] = {\n \"id\" => id,\n \"realpath\" => File.realpath(id),\n \"resource\" => resource_name,\n }\n }\n }\n end\n\n dict\n end",
"def source(file)\n @_source_cache ||= {}\n @_source_cache[file] ||= (\n File.readlines(file)\n )\n end",
"def get_player_hash(id)\n output = {}\n file_array = []\n File.open(\"#{get_tourney_dir(id)}/playerindex\", \"r\") do |f|\n file_array = f.read.split\n end\n file_array.each_with_index do |name, index|\n output[file_array[index]] = file_array[index+1] if index % 2 == 0\n end\n puts output\n return output\nend",
"def get_cached_forums\n #values = Dir.glob(\"*.yml\").map{|a| a.sub(\".yml\",\"\").gsub(\"__\",\"/\"); }\n cp = File.expand_path $cache_path\n values = Dir.entries(cp).grep(/\\.yml$/).map{|a| a.sub(\".yml\",\"\").gsub(\"__\",\"/\"); }\nend",
"def hashFromFile(file, auth, algo)\n u = URI::NI.buildFromFile(auth, file, nil, algo)\n type=`file --mime-type #{file}`.split[1]\n u.contentType!(type)\n u\nend",
"def get_file_details(file_name)\n fd = {}\n \n # Looping through the file and updating the name and url variable with the new data\n # and then finally adding them to the hash table\n File.readlines(file_name).each do |line|\n \n data = line.split(\" \")\n puts data[2]\n name = data[0]\n url = data[2]\n\n fd[name] = url\n end\n puts fd\n return fd\nend",
"def compute_hash( path )\n res = '0'\n autorelease_pool { res = NSData.sha1FromContentsOfFile(path) }\n res\n end",
"def read_cache_file\n return nil unless File.file? @cache_file\n\n cache = YAML.load_file(@cache_file)\n\n return nil unless cache.is_a? Hash\n return nil unless cache[:userid] == @userid\n\n @token = cache[:token]\n @prev_account_info = cache[:account_info]\n @remote_folders = cache[:remote_folders]\n @remote_contexts = cache[:remote_contexts]\n @last_sync = cache[:last_sync]\n end",
"def get_from_cache(cache_file, cache_ttl=5)\n if File.exists?(cache_file)\n now = Time.now\n file_mtime = File.mtime(cache_file)\n file_age = now - file_mtime\n if ((cache_ttl < 0) || (file_age <= cache_ttl))\n file = File.open(cache_file, \"r:UTF-8\")\n return file.read\n else\n # Return False if the cache is old\n return false\n end\n else\n # Return False if the cache file doesn't exist\n return false\n end\n end",
"def file_hash\n return @file_hash\n end",
"def initialize_input_hash(filename)\n input = {}\n File.open(filename, 'r') do |file|\n while line = file.gets\n input[line.to_i] = true\n end\n end\n input\nend",
"def cache_files(dir, files, cache_file)\n cache_content = files.collect do |f|\n File.read(File.join(dir, f))\n end .join(\"\\n\\n\")\n\n cache_path = File.join(dir, cache_file)\n File.delete(cache_path) if File.exists?(cache_path)\n File.open(cache_path, 'w+') { |f| f.write(cache_content) }\n end",
"def cache_file_path\n raise IOError.new 'Write permission is required for cache directory' unless File.writable?(@args[:cache_directory])\n \"#{@args[:cache_directory]}/#{Digest::SHA1.hexdigest((@args[:cache_ref] || @path).to_s + size.to_s + last_modified.to_s)}.cache\"\n end",
"def info(filename, nohash = nil)\n\tf = filename\n\tif test_file(f)\n\t\th = nohash ? (nil) : (Digest::SHA1.hexdigest(File.read(f)))\n\t\treturn [File.mtime(f), File.stat(f).mode.to_s(8).to_i, h]\n\tend\n\treturn []\nend",
"def map_file(path, identifier)\n path = path.to_s\n file = Chance.has_file(identifier)\n\n return file_not_found(identifier) if not file\n\n # Not overly efficient at the moment; that above is just\n # fact-checking, as we recombine on any update() call, and\n # when we do so, we aren't doing it by keeping references to\n # the individual files; we are doing it by finding them in the\n # files hash.\n @files[path] = identifier\n end",
"def get(keys)\n log(\"get :Cache, #{keys.inspect}\")\n connection.multi_get(:Cache, Array(keys)).values.map { |v| v['blob'] }\n end",
"def to_hash(files)\n data = \"\"\n h = {}\n\n # Load files \n files.each {|fn| data << File.open(fn).read }\n\n # Gets the key values\n data.scan(/^([F3|R3]\\w+): ([,\\w]+)$/).each do |m| \n key, value = m\n unless KEYS_PER_TAG.include?(key.gsub(/R3|F3/, \"XX\"))\n return \"Invalid key found while processing stats\"\n end\n h[key] = value\n end\n\n (h.size == 4 or h.size == 8) ?\n h :\n \"Not the expected # of key/values: #{h.size}. Bailing out.\"\nend",
"def hash\n Digest::MD5.hexdigest(abs_filepath)[0..5]\n end",
"def manifested_files\n\n manifest_files.inject([]) do |acc, mf|\n\n files = open(mf) do |io|\n\n io.readlines.map do |line|\n digest, path = line.chomp.split /\\s+/, 2\n path\n end\n\n end\n\n (acc + files).uniq\n end\n\n end",
"def read_fragment_source_file_to_subpaths_map\n @fragment_source_file_to_subpaths_map = { }\n @subpath_to_fragment_order_map = { }\n\n yaml = read_yaml\n this_set = yaml[yaml_key] || [ ]\n this_set.each do |subpath_to_aggregate_files_map|\n subpath_to_aggregate_files_map.each do |subpath, aggregate_files|\n @subpath_to_fragment_order_map[subpath] = [ ]\n \n aggregate_files.each do |aggregate_file|\n net_file = @component_source_proc.call(yaml_key.to_sym, aggregate_file)\n @fragment_source_file_to_subpaths_map[net_file] ||= [ ]\n @fragment_source_file_to_subpaths_map[net_file] << subpath\n @subpath_to_fragment_order_map[subpath] << net_file\n end\n end\n end\n end",
"def getContentCache(theContent)\n\n\ttheChecksum = Digest::SHA256.hexdigest(theContent).insert(2, '/');\n\ttheCache = \"#{PATH_FORMAT_CACHE}/#{theChecksum}\";\n\t\n\treturn theCache;\n\nend",
"def content_files\n @cache_content_files ||= cached_datafiles.reject { |df| sip_descriptor == df }\n end",
"def load_cachefile(cache_filename, template)\n s = File.read(cache_filename)\n if s.sub!(/\\A\\#\\@ARGS (.*?)\\r?\\n/, '')\n template.args = $1.split(',')\n end\n template.script = s\n end",
"def readIDSFile(filename, char_hash)\n File.open(filename) do |f|\n while (line = f.gets)\n next if line.match(/^;;/) # line commented out?\n a = line.strip.split(\"\\t\")\n char_hash[a[0]] = Hash.new() unless char_hash.has_key? a[0]\n char_hash[a[0]][:ids] = a[2].to_u\n end\n end\nend",
"def find_file_named name\n @files_hash[name]\n end"
] | [
"0.65218055",
"0.64184135",
"0.611738",
"0.60881734",
"0.6085953",
"0.60673094",
"0.5851411",
"0.57640356",
"0.57250535",
"0.5724361",
"0.56876105",
"0.56682676",
"0.562255",
"0.5619828",
"0.55920434",
"0.55652946",
"0.55644053",
"0.55460685",
"0.5538999",
"0.5534997",
"0.5447771",
"0.5411736",
"0.54027903",
"0.5388777",
"0.5383265",
"0.53777623",
"0.53604275",
"0.53472215",
"0.53452605",
"0.53290766",
"0.53045154",
"0.5285391",
"0.5278745",
"0.52724224",
"0.5264712",
"0.52445376",
"0.52372926",
"0.522336",
"0.5205704",
"0.5198537",
"0.5192679",
"0.51716405",
"0.51491606",
"0.514793",
"0.5139806",
"0.5136674",
"0.5134425",
"0.5132297",
"0.5129676",
"0.5127578",
"0.5115981",
"0.51155746",
"0.5114813",
"0.511445",
"0.51086736",
"0.5105033",
"0.5103893",
"0.5102758",
"0.5100256",
"0.50996315",
"0.50993675",
"0.5097563",
"0.5091792",
"0.5090791",
"0.5084611",
"0.5084319",
"0.5074471",
"0.5073701",
"0.5069083",
"0.5068426",
"0.5063738",
"0.5063212",
"0.5052843",
"0.50513196",
"0.50429815",
"0.5038105",
"0.503647",
"0.50307727",
"0.50162804",
"0.50161964",
"0.50107324",
"0.5009093",
"0.4999377",
"0.4978566",
"0.4977551",
"0.4977333",
"0.49616373",
"0.49607873",
"0.4956628",
"0.49565178",
"0.4951989",
"0.49508077",
"0.49474573",
"0.49445924",
"0.4942198",
"0.4924508",
"0.49151823",
"0.49076623",
"0.48952082",
"0.4889818"
] | 0.69449836 | 0 |
N Without this, we won't be able to construct an object representing a local content location, with readonly attributes specifying the directory, the hash function, and, optionally, the name of the cached content file. | def initialize(baseDirectory, hashClass, cachedContentFile = nil)
#N Without this, we won't remember the cached content file name
super(cachedContentFile)
#N Without this, we won't remember the base directory
@baseDirectory = baseDirectory
#N Without this, we won't remember the hash function
@hashClass = hashClass
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(cachedContentFile)\n #N Without this the name of the cached content file won't be remembered\n @cachedContentFile = cachedContentFile\n end",
"def initialize(cache_dir, data)\n @cache_dir = Path.new(cache_dir)\n @data = data\n end",
"def initialize(contentHost, baseDir, cachedContentFile = nil)\n # Without super, we won't remember the cached content file (if specified)\n super(cachedContentFile)\n # Without this we won't remember which remote server to connect to\n @contentHost = contentHost\n # Without this we won't remember which directoy on the remote server to sync to.\n @baseDir = normalisedDir(baseDir)\n end",
"def getContentCache(theContent)\n\n\ttheChecksum = Digest::SHA256.hexdigest(theContent).insert(2, '/');\n\ttheCache = \"#{PATH_FORMAT_CACHE}/#{theChecksum}\";\n\t\n\treturn theCache;\n\nend",
"def cache_dir=(_arg0); end",
"def initialize_file_based_cache\n Dir.mkdir(\"cache\")\n @document_cache = ActiveSupport::Cache::FileStore.new(\"cache\")\n @file_based_cache = true\n end",
"def initialize( fn )\n @path = fn\n @dir = ::Webby::Resources.dirname(@path)\n @name = ::Webby::Resources.basename(@path)\n @ext = ::Webby::Resources.extname(@path)\n @mtime = ::File.mtime @path\n\n @_meta_data = {}\n self._reset\n end",
"def initialize(ref, remote, basedir, dirname = nil)\n @ref = ref\n @remote = remote\n @basedir = basedir\n @dirname = dirname || ref\n\n @full_path = File.join(@basedir, @dirname)\n\n @cache = R10K::Git::Cache.new(@remote)\n end",
"def cached_location\n dlt = (download_type) ? download_type : 'default'\n Drupid.cache_path + self.class.to_s.split(/::/).last + extended_name + dlt + name\n end",
"def cache_dir; end",
"def cache_dir; end",
"def cache_resource(dest_dir=@local_cache_dir, options={})\n unless dest_dir\n raise ArgumentError, \"Must specify destination directory when creating resource\", caller\n end\n self.local_cache_dir=dest_dir\n @size = update_cache(@url, @local_path, options)\n if options[:include_pack_gz]\n @relative_local_path_pack_gz = \"#{@relative_local_path}.pack.gz\"\n @local_path_pack_gz = \"#{dest_dir}/#{@relative_local_path_pack_gz}\"\n @size_pack_gz = update_cache(@url_pack_gz, @local_path_pack_gz, options)\n end\n @signature_verified ? @size : @signature_verified\n end",
"def getContentTree\n #N Without this we won't have timestamp and the map of file hashes used to efficiently determine the hash of a file which hasn't been modified after the timestamp\n cachedTimeAndMapOfHashes = getCachedContentTreeMapOfHashes\n #N Without this we won't have the timestamp to compare against file modification times\n cachedTime = cachedTimeAndMapOfHashes[0]\n #N Without this we won't have the map of file hashes\n cachedMapOfHashes = cachedTimeAndMapOfHashes[1]\n #N Without this we won't have an empty content tree which can be populated with data describing the files and directories within the base directory\n contentTree = ContentTree.new()\n #N Without this we won't have a record of a time which precedes the recording of directories, files and hashes (which can be used when this content tree is used as a cached for data when constructing some future content tree)\n contentTree.time = Time.now.utc\n #N Without this, we won't record information about all sub-directories within this content tree\n for subDir in @baseDirectory.subDirs\n #N Without this, this sub-directory won't be recorded in the content tree\n contentTree.addDir(subDir.relativePath)\n end\n #N Without this, we won't record information about the names and contents of all files within this content tree\n for file in @baseDirectory.allFiles\n #N Without this, we won't know the digest of this file (if we happen to have it) from the cached content tree\n cachedDigest = cachedMapOfHashes[file.relativePath]\n #N Without this check, we would assume that the cached digest applies to the current file, even if one wasn't available, or if the file has been modified since the time when the cached value was determined.\n # (Extra note: just checking the file's mtime is not a perfect check, because a file can \"change\" when actually it or one of it's enclosing sub-directories has been renamed, which might not reset the mtime value for the file itself.)\n if cachedTime and cachedDigest and File.stat(file.fullPath).mtime < cachedTime\n #N Without this, the digest won't be recorded from the cached digest in those cases where we know the file hasn't changed\n digest = cachedDigest\n else\n #N Without this, a new digest won't be determined from the calculated hash of the file's actual contents\n digest = hashClass.file(file.fullPath).hexdigest\n end\n #N Without this, information about this file won't be added to the content tree\n contentTree.addFile(file.relativePath, digest)\n end\n #N Without this, the files and directories in the content tree might be listed in some indeterminate order\n contentTree.sort!\n #N Without this check, a new version of the cached content file will attempt to be written, even when no name has been specified for the cached content file\n if cachedContentFile != nil\n #N Without this, a new version of the cached content file (ready to be used next time) won't be created\n contentTree.writeToFile(cachedContentFile)\n end\n return contentTree\n end",
"def initialize\n @data = ::Hash.new { |h, k| h[k] = File.new(k, mtime: 0) }\n @mutex = Mutex.new\n end",
"def local_file\n @local_file ||= LocalFile.new self\n end",
"def initialize(name, hash, parentPathElements)\n #N Without this we won't remember the name of the file\n @name = name\n #N Without this we won't know the hash of the contents of the file\n @hash = hash\n #N Without this we won't know the path elements of the sub-directory (within the directory tree) containing the file\n @parentPathElements = parentPathElements\n #N Without this the file object won't be in a default state of _not_ to be copied\n @copyDestination = nil\n #N Without this the file object won't be in a default state of _not_ to be deleted\n @toBeDeleted = false\n end",
"def cache_item(file_parsed, _objects_db = nil, custom_cache_key = nil)\n _cache_key = custom_cache_key || cache_key\n objects_db = _objects_db || @current_site.get_meta(_cache_key, {}) || {}\n prefix = File.dirname(file_parsed['key'])\n\n s = prefix.split('/').clean_empty\n return file_parsed if s.last == 'thumb'\n s.each_with_index{|_s, i| k = \"/#{File.join(s.slice(0, i), _s)}\".cama_fix_slash; cache_item(file_parse(k), objects_db) unless objects_db[k].present? } unless ['/', '', '.'].include?(prefix)\n\n objects_db[prefix] = {files: {}, folders: {}} if objects_db[prefix].nil?\n if file_parsed['format'] == 'folder'\n objects_db[prefix][:folders][file_parsed['name']] = file_parsed\n else\n objects_db[prefix][:files][file_parsed['name']] = file_parsed\n end\n @current_site.set_meta(_cache_key, objects_db) if _objects_db.nil?\n file_parsed\n end",
"def initialize \n @dirpath = self.class.dirname\n\n if Dir.exist? @dirpath\n raise \"Directory is not readable\" unless File.readable? @dirpath\n raise \"Directory is not writable\" unless File.writable? @dirpath\n else \n Dir.mdkir @dirpath\n raise \"Directory does not exist and could not be created\" unlesss Dir.exist? @dirpath\n end \n\n refresh_cached_files\n end",
"def cache(uri, obj)\n filename=cacheFileName(uri)\n print(\"Creating #{filename}\\n\")\n File.open(filename, 'w') {|f| f.write(obj) }\nend",
"def cache(file_obj, data_result, url, username, password)\n data_result[:uuid] = UUID.generate\n key = generate_key url, username, password\n\n begin\n data_result[:data_tmp_path] = store_data_to_tmp file_obj, data_result[:uuid]\n data_result[:time_stored] = Time.now\n @@file_cache[key] = data_result\n rescue Exception => e\n @@file_cache[key] = nil\n end\n end",
"def initialize(list, dir, name, max_in_memory, page_size)\n @list = list\n @file_name = File.join(dir, name + '.cache')\n @page_size = page_size\n open\n @pages = PersistentObjectCache.new(max_in_memory, max_in_memory,\n IDListPage, self)\n @page_counter = 0\n end",
"def initialize(relativePath, hash)\n #N Without this, we won't rememeber the relative path value\n @relativePath = relativePath\n #N Without this, we won't remember the file's cryptographic hash of its contents\n @hash = hash\n end",
"def initialize(options = {})\n super options\n \n directory = options.fetch(:directory, DEFAULT_DIR)\n name = options.fetch(:name, DEFAULT_NAME)\n size = options.fetch(:size, DEFAULT_SIZE)\n\n data_store_options = {\n filename: Pathname.new(directory).join(\"#{name}-data.lmc\").to_s,\n size_mb: [DEFAULT_SIZE, size].max / 1.megabyte\n }\n meta_store_options = {\n filename: Pathname.new(directory).join(\"#{name}-meta.lmc\").to_s,\n size_mb: data_store_options[:size_mb]\n }\n\n @data_store = LocalMemCache.new(data_store_options)\n @meta_store = LocalMemCache.new(meta_store_options)\n end",
"def initialize(cache_path = Chef::Config[:syntax_check_cache_path])\n @cache_path = cache_path\n @cache_path_created = false\n end",
"def cached_file(source, checksum = nil)\n if source =~ %r{^(file|ftp|http|https):\\/\\/}\n uri = as_uri(source)\n cache_file_path = \"#{Chef::Config[:file_cache_path]}/#{::File.basename(::CGI.unescape(uri.path))}\"\n Chef::Log.debug(\"Caching a copy of file #{source} at #{cache_file_path}\")\n\n remote_file cache_file_path do\n source source\n backup false\n checksum checksum unless checksum.nil?\n end\n else\n cache_file_path = source\n end\n\n Chef::Util::PathHelper.cleanpath(cache_file_path)\n end",
"def initialize(hash={}, get_size_of_residues=false)\n merge!(hash)\n if get_size_of_residues && File.exist?(@local_path)\n set_size_of_residues!\n end\n end",
"def initialize(path, content, symlink: false)\n @path = path\n @content = content\n @symlink = symlink\n end",
"def initialize stat, location = nil\n @data = Hash.new\n @tags = nil\n if location\n begin\n IO.popen([\"sha256sum\", location]) do |io|\n @hash = io.read.split(' ')[0]\n end\n rescue Exception => e\n logger.error \"Can't hash #{location.inspect}: #{e}\"\n end\n @mimetype = MimeType.detect location\n @location = location\n @ctime = stat.ctime\n @mtime = stat.mtime\n @size = stat.size\n tags = location.split File::SEPARATOR\n tags.shift if tags[0].empty?\n @name = tags.pop\n @tags = tags\n else\n stdin\n end\n end",
"def initialize(path_or_io, create = false, buffer = false, options = {})\n super()\n options = DEFAULT_OPTIONS.merge(options)\n @name = path_or_io.respond_to?(:path) ? path_or_io.path : path_or_io\n @comment = ''\n @create = create ? true : false # allow any truthy value to mean true\n\n if ::File.size?(@name.to_s)\n # There is a file, which exists, that is associated with this zip.\n @create = false\n @file_permissions = ::File.stat(@name).mode\n\n if buffer\n read_from_stream(path_or_io)\n else\n ::File.open(@name, 'rb') do |f|\n read_from_stream(f)\n end\n end\n elsif buffer && path_or_io.size > 0\n # This zip is probably a non-empty StringIO.\n read_from_stream(path_or_io)\n elsif @create\n # This zip is completely new/empty and is to be created.\n @entry_set = EntrySet.new\n elsif ::File.zero?(@name)\n # A file exists, but it is empty.\n raise Error, \"File #{@name} has zero size. Did you mean to pass the create flag?\"\n else\n # Everything is wrong.\n raise Error, \"File #{@name} not found\"\n end\n\n @stored_entries = @entry_set.dup\n @stored_comment = @comment\n @restore_ownership = options[:restore_ownership]\n @restore_permissions = options[:restore_permissions]\n @restore_times = options[:restore_times]\n end",
"def initialize(token)\n @token = token\n @file_cache = {}\n end",
"def create_lock_object\n @bucket.create_file(\n StringIO.new,\n @path,\n acl: @object_acl,\n cache_control: 'no-store',\n metadata: {\n expires_at: (Time.now + @ttl).to_f,\n identity: identity,\n },\n if_generation_match: 0,\n )\n rescue Google::Cloud::FailedPreconditionError\n nil\n end",
"def cache\n store = Moneta.new :File, dir: 'moneta'\n Cachy.cache_store = store\n Cachy\n end",
"def getExistingCachedContentTreeFile\n #N Without this check, it would try to find the cached content file when none was specified\n if cachedContentFile == nil\n #N Without this, there will be no feedback to the user that no cached content file is specified\n puts \"No cached content file specified for location\"\n return nil\n #N Without this check, it will try to open the cached content file when it doesn't exist (i.e. because it hasn't been created, or, it has been deleted)\n elsif File.exists?(cachedContentFile)\n #N Without this, it won't return the cached content file when it does exist\n return cachedContentFile\n else\n #N Without this, there won't be feedback to the user that the specified cached content file doesn't exist.\n puts \"Cached content file #{cachedContentFile} does not yet exist.\"\n return nil\n end\n end",
"def fetch(storage_path, local_path)\n super\n FileUtils.cp absolute_path(storage_path), local_path\n end",
"def initialize(filename, mode=\"r\", perm=0) end",
"def cache_file_path\n raise IOError.new 'Write permission is required for cache directory' unless File.writable?(@args[:cache_directory])\n \"#{@args[:cache_directory]}/#{Digest::SHA1.hexdigest((@args[:cache_ref] || @path).to_s + size.to_s + last_modified.to_s)}.cache\"\n end",
"def data_cache(fpath)\n (@data_caches ||= []) << fpath\n return fpath\n end",
"def initialize(pth=nil, priv=nil, own=nil, grp=nil)\n # duplicat instance if initilize is called with an instance as the first argument\n if pth.is_a?(UFS::FS::File) || pth.is_a?(UFS::FS::Dir)\n priv = pth.permissions\n own = pth.owner\n grp = pth.group\n pth = pth.path\n end\n self.path = ::File.expand_path(pth) unless pth.nil?\n self.permissions = priv unless priv.nil?\n self.owner = own unless own.nil?\n self.group = grp unless grp.nil?\n end",
"def file(path, *args)\n return file_via_connection(path, *args) unless cache_enabled?(:file)\n\n @cache[:file][path] ||= file_via_connection(path, *args)\n end",
"def initialize(path, content)\n @path = path\n @content = content\n end",
"def initialize\n @contents = StringIO.new('', 'r+b')\n @filemgr = Server.file_manager\n end",
"def cache_file(input)\n key = Digest.hexencode(Digest::SHA2.digest(input.to_yaml))\n return @directory + \"/\" + key + \".yaml\"\n end",
"def initialize(full_path, contents = [])\n @contents = contents.to_a.dup.freeze\n super(full_path)\n end",
"def try_load_object(name, cache_path); end",
"def initialize(checksum=nil, couchdb=nil)\n @create_time = Time.now.iso8601\n @checksum = checksum\n @original_committed_file_location = nil\n @storage = Storage::Filesystem.new(Chef::Config.checksum_path, checksum)\n end",
"def initialize(file)\n self.stathash = stat(file) if (file)\n end",
"def load(archive_name, klass) \n filename = \"#{archive_name}-#{klass.name}\"\n if File.exist?(File.join(@cache_dir, filename)) then\n puts \"loading from cache: #{filename}\"\n return Marshal.load(File.new(File.join(@cache_dir, filename)))\n else\n puts \"creating new object: #{filename}\"\n obj = yield(archive_name)\n write(obj, archive_name) if (obj.class == klass) #write only if we got object of the right type\n return obj\n end\n end",
"def initialize(directory, &block)\n @force_recompute = false\n @computation = block\n @directory = find_directory(Dir.pwd, directory)\n if @directory\n class <<self; alias [] :cached_computation; end\n else\n class <<self; alias [] :uncached_computation; end\n $stderr.puts(\"#{$0}: Could not find cache directory: #{directory}.\")\n end\n end",
"def mtime_url(obj, anchor = T.unsafe(nil), relative = T.unsafe(nil)); end",
"def initialize(path); end",
"def cache(input_path, output_path, data=nil)\n path = input_path\n @new_hashes[input_path] = hash(@input_directory, input_path)\n\n if data\n @data[path] = data if data\n @wildcard_dependencies[path] = data[:wildcard_dependencies] if data[:wildcard_dependencies]\n @dependencies[path] = data[:dependencies] if data[:dependencies]\n end\n\n FileUtils.mkdir_p(File.dirname(cached_path_for(path)))\n\n if File.exist? File.join(@output_directory, output_path)\n FileUtils.cp(File.join(@output_directory, output_path), cached_path_for(path))\n else\n FileUtils.cp(File.join(@input_directory, input_path), cached_path_for(input_path))\n end\n end",
"def cache\n if self.cache_store\n self.cache_store\n else\n self.cache_store = :file_store, root.join(\"tmp\").to_s\n self.cache_store\n end\n end",
"def file\r\n LocalFile\r\n end",
"def cache_resource( path )\n resource_hash = compute_hash(path)\n return true if find_resource(resource_hash)\n\n copy_resource(resource_hash, path)\n end",
"def initialize_root\n Utils.create_directory(@cache_root)\n Utils.clear_directory(@cache_root)\n end",
"def create_cache(dir, hostname, cache)\n # Let's create the cache directory if it does exists.\n Dir.mkdir(dir) unless File.exist?(dir)\n\n # Create the file and fill it with the cache\n cachefilename = File.join(dir, \"#{hostname}.yml\")\n cachefile = File.new(cachefilename, 'w+')\n cachefile.write(cache)\n cachefile.close\nend",
"def cache_path\n File.join @path, 'cache.ri'\n end",
"def retrieve_from_cache!(identifier)\n CarrierWave::Storage::GridFS::File.new(uploader, uploader.cache_path(identifier))\n end",
"def local_path\n src = if %i(direct repo).include?(new_resource.source)\n package_metadata[:url]\n else\n new_resource.source.to_s\n end\n ::File.join(Chef::Config[:file_cache_path], ::File.basename(src))\n end",
"def initialize(root_path, id, cache_dir = '.cache', force = true)\n super({}, {}, force)\n\n @cache_dir = cache_dir\n @cache_root = File.join(root_path, cache_dir)\n FileUtils.mkdir_p(base_path) unless File.directory?(base_path)\n\n @cache_id = id.to_sym\n @cache_translator = Nucleon.type_default(:nucleon, :translator)\n @cache_filename = \"#{id}.#{translator}\"\n @cache_path = File.join(@cache_root, @cache_filename)\n\n unless File.exist?(file)\n parser = Nucleon.translator({}, translator)\n Disk.write(file, parser.generate({}))\n end\n load\n end",
"def cache_file_path\n File.join @homepath, 'cache'\n end",
"def initialize(path)\n @path = path\n @name = path.split(\"/\").last\n raise NoRepository.new('no repository for such path') unless check_repo_present? \n Gitlab::Git::CacheHost.set_cache_host(path)\n end",
"def initialize(path)\n @path = path\n @content = File.read(path)\n end",
"def initialize(path)\n super(DIR)\n \n @store = GitStore.new(path)\n @store.handler['md'] = PageHandler.new\n @store.load\n end",
"def cache_skeleton(name)\n repo = config.skeletons[name] or return\n\n path = cache_path(name)\n return path if directory_with_files?(path)\n\n mkdir_p fx(path, '..')\n\n git_clone repo, path\n\n if $?.to_i != 0\n rm_rf path\n return nil\n end\n\n rm_rf File.join(path, '.git')\n\n path\n end",
"def cache_open(url)\n Cachy.cache(url, hash_key: true) { open(url).read }\nend",
"def localize_resource(tag, sym, loader, uri, dir, subdir, h, props)\n rel_url = tag[sym]\n src_url = absolute_url_for(uri, rel_url)\n\n buf = download_resource(loader, src_url)\n return if (! buf) or (buf.empty?)\n\n path = path_for_url(dir, subdir, rel_url)\n # Fix for super-long filenames. wikipedia, for example, has these\n if path.length > 256\n path = path_for_url(dir, subdir, rel_url[0,256])\n end\n\n local_ref = ref_path(dir, subdir, path)\n\n # localize tag ref\n tag[sym.to_s] = local_ref\n\n # store remote contents in Hash under path\n h[path] = buf\n # TODO: mime-type?\n props[path] = { :origin => src_url, :relative_path => local_ref }\n end",
"def initialize(hostname, cache_dir)\n @hostname = hostname\n @cache_dir = ::File.join(cache_dir, @hostname)\n @tag_file = ::File.join(@cache_dir, TAGS_JSON_FILE)\n end",
"def initialize(name, opts)\n @name = name\n @url_prefix = \"#{@name}:\"\n @read_only = (opts[:read_only] == true)\n # Do not expose in search result\n @hidden = (opts[:hidden] == true)\n @no_access = (opts[:no_access] == true)\n\n if @top_dir = opts[:top_dir]\n if @top_dir.start_with?('.') && ContentRepository.reference_dir\n @top_dir = File.join(ContentRepository.reference_dir, @top_dir)\n end\n unless @top_dir =~ /^.+@.+:(.+)\\.git$/\n @top_dir = File.expand_path(@top_dir)\n end\n debug \"Creating repo '#{name} with top dir: #{@top_dir}\"\n\n _create_if_not_exists if opts[:create_if_not_exists]\n end\n end",
"def readlink() self.class.new( File.readlink( expand_tilde ) ) end",
"def local_cache_dir=(dir_path)\n @local_cache_dir = File.expand_path(dir_path)\n @relative_local_path = \"#{@href_path}#{@filename}\"\n @local_path = \"#{@local_cache_dir}/#{@relative_local_path}\"\n end",
"def initialize(key, filename, content)\n @key = key\n @filename = filename\n @content = content\n end",
"def initialize(source , name , cache_entry)\n super(source)\n @name = name\n @cache_entry = cache_entry\n end",
"def initialize(args={})\n @cfg = {\n :path => \"/Users/cremes/dev/mygit/proto-rina/README.md\", \n :id => 25,\n :len => 1024,\n :mode => Shared::IPC_CREAT, \n :access => Shared::IPC_W | Shared::IPC_R\n }\n @cfg.merge! args\n @key = Shared::try(\"ftok\") {Shared::ftok(@cfg[:path], @cfg[:id])}\n @id = Shared::try(\"shmget\") {Shared::shmget(@key, @cfg[:len], 0666 | @cfg[:mode])}\n p @id, @key, @cfg[:len], (0666 | @cfg[:mode])\n @mem = Shared::shmat(@id, 0, @cfg[:access])\n p @mem, @id\n end",
"def cache!(document) \n if document.is_a?(Hash) && document.has_key?(\"base64\") && document.has_key?(\"filename\")\n raise ArgumentError unless document[\"base64\"].present?\n file = FilelessIO.new(Base64.decode64(document[\"base64\"]))\n file.original_filename = document[\"filename\"]\n file.content_type = document[\"filetype\"] \n super(file)\n else\n super(document)\n end\n end",
"def cache_file\n @cache_file ||= File.join cache_dir, \"#{full_name}.gem\"\n end",
"def initialize(raw_content, opts = {})\n @id = opts[:id] || SecureRandom.hex(16) # FIXME check that the content id isn't already used / use UUID\n @repo = opts[:repo]\n @type = opts[:type] || DocumentType.get('document')\n\n unless @repo\n @content = Content.new(raw_content)\n end\n end",
"def initialize(filename_or_io, content_type, filename = nil, opts = {})\n io = filename_or_io\n local_path = \"\"\n if io.respond_to? :read\n # in Ruby 1.9.2, StringIOs no longer respond to path\n # (since they respond to :length, so we don't need their local path, see parts.rb:41)\n local_path = filename_or_io.respond_to?(:path) ? filename_or_io.path : \"local.path\"\n else\n io = File.open(filename_or_io)\n local_path = filename_or_io\n end\n filename ||= local_path\n\n @content_type = content_type\n @original_filename = File.basename(filename)\n @local_path = local_path\n @io = io\n @opts = opts\n end",
"def fetch\n if cached_location.exist?\n @local_path = cached_location\n debug \"#{extended_name} is cached\"\n else\n raise \"No download URL specified for #{extended_name}\" if download_url.nil?\n blah \"Fetching #{extended_name}\"\n downloader = Drupid.makeDownloader self.download_url.to_s,\n self.cached_location.dirname.to_s,\n self.cached_location.basename.to_s,\n self.download_specs\n downloader.fetch\n downloader.stage\n @local_path = downloader.staged_path\n end\n end",
"def check (uri)\n return nil unless @enabled\n\n # FIXME check some time limits around this\n cache_name = translate_uri(uri)\n \n file = File.join(@directory, cache_name)\n File.exist?(file) and File.open(file) do |f|\n return OpenStruct.new(:body => f.read, :cache_file => file)\n end\n end",
"def cache_file_for(klassname)\n File.join cache_file_path, klassname.gsub(/:+/, \"-\")\n end",
"def repository\n @repository ||= Repository::Content.new(@base_dir)\n end",
"def cache_store_type\n \"file\"\n end",
"def initialize!\n @cache = JSON.load(File.read(cache_file)) rescue {}\n unless @cache.is_a?(Hash)\n $stderr.puts \"Warning: #{cache_file} was corrupt. Contents:\\n#{@cache.inspect}\"\n @cache = {}\n end\n @cache[\"targets\"] ||= {}\n @cache[\"directories\"] ||= {}\n @cache[\"configuration_data\"] ||= {}\n @lookup_checksums = {}\n end",
"def initialize(obj)\n if obj.is_a?(VfsRealFile::Stat)\n stat_init(obj)\n else\n hash_init(obj)\n end\n end",
"def open(key)\n BlockFile.open(cache_path(key), 'rb')\n rescue Errno::ENOENT\n nil\n end",
"def get(name)\n path = File.join(@home, name)\n IFolder.new(path)\n end",
"def object_for_hash(given_hash)\n @opener.open(name, \"r\") do |fp|\n given_hash.force_encoding(\"ASCII-8BIT\") if given_hash.respond_to?(:force_encoding)\n entry = nil\n if index\n starting_at = index.offset_for_hash(given_hash)\n return PackFileEntry.at(starting_at, fp).to_raw_object\n else\n starting_at = cached_offset(given_hash) || DATA_START_OFFSET\n fp.seek(starting_at, IO::SEEK_SET)\n while fp.tell < @end_of_data\n entry = PackFileEntry.read(fp)\n cache_entry(entry)\n return entry.to_raw_object if entry.hash_id == given_hash\n end\n end\n end\n nil\n end",
"def create_object(dir_name, content, attributes, identifier)\n # Determine path\n path = dir_name + (identifier == '/' ? '/index.html' : identifier[0..-2] + '.html')\n parent_path = File.dirname(path)\n\n # Notify\n Nanoc3::NotificationCenter.post(:file_created, path)\n\n # Write item\n FileUtils.mkdir_p(parent_path)\n File.open(path, 'w') do |io|\n io.write(YAML.dump(attributes.stringify_keys) + \"\\n\")\n io.write(\"---\\n\")\n io.write(content)\n end\n end",
"def newobj(type, name, hash)\n transport = Puppet::TransObject.new(name, \"file\")\n transport[:path] = path\n transport[:ensure] = \"file\"\n assert_nothing_raised {\n file = transport.to_ral\n }\n end",
"def initialize path\n if !File.directory? path\n raise ArgumentError, 'not a directory'\n elsif File.exists? path + '/index.lock'\n raise IOError, 'index is locked'\n else\n @path = path\n @documents = []\n end\n end",
"def get_cache_file_for(gist, file)\n bad_chars = /[^a-zA-Z0-9\\-_.]/\n gist = gist.gsub bad_chars, ''\n file = file.gsub bad_chars, ''\n md5 = Digest::MD5.hexdigest \"#{gist}-#{file}\"\n File.join @cache_folder, \"#{gist}-#{file}-#{md5}.cache\"\n end",
"def localFile(f)\n fileUri(File::absolute_path(f))\nend",
"def get!(name)\n case name\n when String, Symbol\n path = @pathname + name #.to_s\n else\n path = name\n end\n\n if path.directory?\n data = FileStore.new(self, path.basename)\n elsif path.file?\n text = path.read.strip\n data = (/\\A^---/ =~ text ? YAML.load(text) : text)\n data = data.to_list if self.class.listings[name]\n else\n data = self.class.defaults[name]\n data = instance_eval(&data) if Proc === data\n end\n data\n end",
"def initialize fileLocation, fileName, fileContent, rights, serverSide, user\n @fileLocation = fileLocation\n @fileName = fileName\n @fileContent = splitText fileContent\n @id = SecureRandom.uuid\n @rights = rights\n @serverSide = serverSide\n @workingUsers = [user]\n @diffHistory = []\n @diffHistoryPosition = 0\n end",
"def create_content_proxy_for(content_descr)\n path = _get_path(content_descr)\n # TODO: Make sure that key is really unique across multiple repositories - why?\n descr = descr ? descr.dup : {}\n url = get_url_for_path(path)\n descr[:url] = url\n descr[:path] = path\n descr[:name] = url # Should be something human digestable\n if (descr[:strictly_new])\n return nil if exist?(path)\n end\n proxy = ContentProxy.create(descr, self)\n return proxy\n end",
"def cache_path\n @cache_path ||= File.join(\"\", \"gko\", \"cache\", \"#{self.host}\")\n end",
"def initialize(ref, remote, basedir, dirname = nil)\n\n @remote = remote\n @basedir = basedir\n @dirname = dirname || ref\n\n @full_path = File.join(@basedir, @dirname)\n @git_dir = File.join(@full_path, '.git')\n\n @cache = R10K::Git::Cache.generate(@remote)\n\n if ref.is_a? String\n @ref = R10K::Git::Ref.new(ref, self)\n else\n @ref = ref\n @ref.repository = self\n end\n end",
"def cache!(document)\n if document.is_a?(Hash) && document.has_key?(\"base64\") && document.has_key?(\"filename\")\n raise ArgumentError unless document[\"base64\"].present?\n file = FilelessIO.new(Base64.decode64(document[\"base64\"]))\n file.original_filename = document[\"filename\"]\n file.content_type = document[\"filetype\"] \n super(file)\n else\n super(document)\n end\n end",
"def getCachedContentTree\n #N Without this, we won't know the name of the specified cached content file (if it is specified)\n file = getExistingCachedContentTreeFile\n #N Without this check, we would attempt to read a non-existent file\n if file\n #N Without this, a content tree that has been cached won't be returned.\n return ContentTree.readFromFile(file)\n else\n return nil\n end\n end"
] | [
"0.6595214",
"0.6238965",
"0.617047",
"0.61021125",
"0.60642135",
"0.60487205",
"0.60059464",
"0.59772754",
"0.597332",
"0.5951963",
"0.5951963",
"0.5827734",
"0.58217674",
"0.5810983",
"0.5810289",
"0.57476544",
"0.5727007",
"0.57262546",
"0.56889504",
"0.56822413",
"0.5675908",
"0.56757337",
"0.5632989",
"0.5606589",
"0.5605911",
"0.5603029",
"0.55977947",
"0.5588239",
"0.5587024",
"0.55707145",
"0.55682373",
"0.556336",
"0.55533576",
"0.5540678",
"0.5532232",
"0.5532201",
"0.5530112",
"0.55294263",
"0.55203396",
"0.55029744",
"0.54972076",
"0.54823315",
"0.5480898",
"0.54752046",
"0.54694444",
"0.5415331",
"0.5409116",
"0.54054254",
"0.5394268",
"0.5393416",
"0.53861636",
"0.53853256",
"0.5384013",
"0.5368245",
"0.5354434",
"0.53492683",
"0.5339044",
"0.5337418",
"0.5335608",
"0.5331692",
"0.5329422",
"0.5311231",
"0.53108126",
"0.5306391",
"0.5295923",
"0.5294744",
"0.5289582",
"0.52636915",
"0.52623284",
"0.5255167",
"0.52514255",
"0.5251056",
"0.5250223",
"0.52439773",
"0.52402633",
"0.52385575",
"0.52357334",
"0.52350247",
"0.52291876",
"0.52230304",
"0.5221018",
"0.52191913",
"0.52155936",
"0.52145123",
"0.52139974",
"0.52123696",
"0.5211904",
"0.5207972",
"0.5207052",
"0.5205304",
"0.5201948",
"0.5201622",
"0.52011293",
"0.51985514",
"0.51964796",
"0.5191026",
"0.51874053",
"0.51825166",
"0.5182064",
"0.5180105"
] | 0.65742356 | 1 |
get the full path of a relative path (i.e. of a file/directory within the base directory) N Without this, we won't have an easy way to calculate the full path of a file or directory in the content tree that is specified by its relative path. | def getFullPath(relativePath)
return @baseDirectory.fullPath + relativePath
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relativePath\n #N Without this the path elements won't be joined together with \"/\" to get the relative path as a single string\n return @pathElements.join(\"/\")\n end",
"def relative_path\n must_be File\n Pathname.new(self.full_path).relative_path_from(Pathname.new(Dir.pwd)).to_s\n end",
"def getFullPath(relativePath)\n return baseDir + relativePath\n end",
"def relative_path(path = @pwd, to = @root)\n Pathname.new(path).relative_path_from(Pathname.new(to)).to_s\n end",
"def relative_path\n @relative_path ||= File.join(*[@dir, @name].map(&:to_s).reject(&:empty?)).delete_prefix(\"/\")\n end",
"def relativePath\n return (parentPathElements + [name]).join(\"/\")\n end",
"def relative_path(*relative)\n Pathname.pwd.join(*(relative.flatten.map(&:to_s))).expand_path\n end",
"def relative_path path, base\n (root? path) && (offset = descends_from? path, base) ? (path.slice offset, path.length) : path\n end",
"def full_rel_path()\n return nil if rel_path.nil?\n \n path = nil\n current_part = self\n while not current_part.nil? do\n if (not current_part.rel_path.nil?)\n if path.nil?\n path = current_part.rel_path\n else\n path = \"#{current_part.rel_path}.#{path}\"\n end\n end\n current_part = current_part.parent\n end\n \n return path\n end",
"def relroot\n Pathname.new(File.expand_path(path)).\n relative_path_from(Pathname.new(File.expand_path(root))).to_s\n end",
"def rel relative_path\r\n return File.dirname(__FILE__) + \"/../\" + relative_path\r\nend",
"def relative_path\n @relative_path ||= PathManager.join(@dir, @name).delete_prefix(\"/\")\n end",
"def relative_path(path)\n path.split('/').drop(5).join('/')\nend",
"def relative_path_to(path, relative_to = nil)\n if relative_to\n path = File.expand_path(\n # symlink, e.g. \"../../../../grid5000/environments/etch-x64-base-1.0.json\"\n path,\n # e.g. : File.join(\"/\", File.dirname(\"grid5000/sites/rennes/environments/etch-x64-base-1.0\"))\n File.join('/', File.dirname(relative_to))\n ).gsub(%r{^/}, '')\n end\n path\n end",
"def rel_path(path)\n Pathname(path).expand_path.relative_path_from(Pathname(Dir.pwd))\n end",
"def get_relative_path(path)\n Util::path_rel_to_path(path, recipe_file.path).to_s\n end",
"def relative_path\n @relative_path ||= File.join(@dir, @name)\n end",
"def relative_path(path_to, path_from)\n path_from ||= \"\"\n path_to = Pathname.new(path_to)\n dir_from = Pathname.new(path_from).dirname\n\n path_to.relative_path_from(dir_from).to_s\n end",
"def relative_path\n self.path.sub(File.expand_path(options[:root_dir]) + '/', '')\n end",
"def resolve_relative_path(path, base_path)\n p = Pathname(base_path)\n p = p.dirname unless p.extname.empty?\n p += path\n\n p.cleanpath.to_s\n end",
"def relative_path(from, to); end",
"def relative\n return self if relative?\n @relativized ||= relative_path_from root\n end",
"def relativize_path path\n base_dir = Pathname.new(File.expand_path(DIR))\n other_dir = Pathname.new(File.expand_path(path))\n other_dir.relative_path_from base_dir\n end",
"def relative_path\n name\n end",
"def relativize( path ) # :doc:\n p = Pathname.new( path )\n unless p.relative?\n p = p.relative_path_from( Pathname.pwd ).to_s\n p += '/' if path[-1] == '/'\n path = p if p.length < path.length\n end\n path\n end",
"def relative_path(p = path)\n anchor = p.ftype == \"directory\" ? @root_path : \"public\"\n p.relative_path_from(Pathname.new(anchor).realpath)\n end",
"def relativepath(abspath, relativeto)\n path = abspath.split(File::SEPARATOR)\n rel = relativeto.split(File::SEPARATOR)\n while (path.length > 0) && (path.first == rel.first)\n path.shift\n rel.shift\n end\n ('..' + File::SEPARATOR) * (rel.length - 1) + path.join(File::SEPARATOR)\n end",
"def relative_directory\n return '' unless @directory_root\n @path - @directory_root - name\n end",
"def relative_path; end",
"def relative_path; end",
"def relative_path; end",
"def relative_path; end",
"def relative_path; end",
"def path(rel)\n File.join(File.dirname(__FILE__), \"..\", rel)\nend",
"def relative_path_from(from); end",
"def relative_path_from(entry)\n @path.relative_path_from(entry.path)\n end",
"def determine_path\n if source_line.file == SourceLine::DEFAULT_FILE\n return source_line.file\n end\n\n full_path = File.expand_path(source_line.file)\n pwd = Dir.pwd\n\n if full_path.start_with?(pwd)\n from = Pathname.new(full_path)\n to = Pathname.new(pwd)\n\n return from.relative_path_from(to).to_s\n else\n return full_path\n end\n end",
"def relative_path\n @relative_path ||= File.join(@dir, @target)\n end",
"def ref_path(dir, subdir, path)\n # this stuff is overkill, and doesn't work anyways:\n #depth = dir.split(File::SEPARATOR).reject{ |d| d.empty? }.count\n #parent_dirs = Array.new(depth, '..')\n File.join('..', ContentRepo::ResourceNode::PATHNAME, path )\n end",
"def get_full_path(sub_path)\n File.join(Dir.pwd, sub_path)\nend",
"def relative_path(path)\n path = destination_root.relative_path(path) || path\n path.empty? ? \".\" : path\n end",
"def rel_path(file)\n File.dirname(file)\n end",
"def relative_path(target = '.')\n my_path = Pathname.new(path).expand_path\n target_path = Pathname.new(target.to_s).expand_path\n target_path = target_path.dirname if target_path.file?\n\n new_path = my_path.relative_path_from(target_path).to_s\n\n return new_path if new_path.index('.') == 0\n \"./#{new_path}\"\n end",
"def relative_path(target = '.')\n my_path = Pathname.new(path).expand_path\n target_path = Pathname.new(target.to_s).expand_path\n target_path = target_path.dirname if target_path.file?\n\n new_path = my_path.relative_path_from(target_path).to_s\n\n return new_path if new_path.index('.') == 0\n \"./#{new_path}\"\n end",
"def relative(file)\n if File.directory?(full_path)\n file[full_path.length+1..-1]\n else\n File.basename(file)\n end\n end",
"def relative_path(path)\n path[self.prefix.size..-1].gsub(%r{^/}, '').tap do |pth|\n #puts \"self.prefix=#{self.prefix}, path=#{path}, result=#{pth}\"\n end\n end",
"def relative_file_path(file_path)\n file_path.gsub(/#{pwd}\\//, '')\n end",
"def relative_path(path)\n path = File.expand_path(File.dirname(__FILE__) + '/' + path)\n \"'#{path}'\"\nend",
"def relative_path(pathname)\n pwd = Pathname.new('.').realpath\n pathname.file_ref.real_path.relative_path_from(pwd)\n end",
"def resolvePath(possiblyRelativePath, rootDir)\n\t\tpath = Pathname.new(possiblyRelativePath)\n\t\tif(path.absolute?()) then\n\t\t\treturn path.to_s()\n\t\telse\n\t\t\trootPath = Pathname.new(rootDir)\n\t\t\treturn rootPath.join(path)\n\t\tend\n\tend",
"def relative_path(options = {})\n @relative_path ||= Pathname.new(filename).relative_path_from(Pathname.new(base)).to_s\n path_with_cache_buster(@relative_path, options)\n end",
"def to_relative_path\n File.join('.', to.path(identify).to_s)\n end",
"def relativize_path(path)\n path.to_s.gsub(/^\\/?#{Regexp.escape(root_path.to_s)}\\/?/, '')\n end",
"def path_from(relative_path)\n path.sub(/^#{Regexp.escape(relative_path)}\\/?/, '')\n end",
"def path_from(relative_path)\n path.sub(/^#{Regexp.escape(relative_path)}\\/?/, '')\n end",
"def path\n real_path = Pathname.new(root).realpath.to_s\n full_path.sub(%r{^#{real_path}/}, '')\n end",
"def relative_path(filename)\n pieces = split_filename(File.expand_path(filename))\n File.join(pieces[@mount_dir_pieces.size..-1])\n end",
"def relative_url\n path = nil\n note = self\n while true\n path = \"/#{note.slug}#{path}\"\n return path if !note.parent\n note = Note.first(:id=>note.parent)\n return path if !note\n end\n return nil\n end",
"def relative_path\n @relative_path ||= path.sub(\"#{site.collections_path}/\", \"\")\n end",
"def realpath\n if(self.page)\n return Rails.application.routes.url_helpers.page_path(self.page)\n end\n '/' + self.explicit_path\n end",
"def relative_dir(path, *args)\n relative_path = args ? args.join('/') : ''\n Pathname(path).dirname.join(relative_path)\n end",
"def relative_path\n @local_path.relative_path_from(@platform.local_path)\n end",
"def relative_path(val = NULL)\n if null?(val)\n @relative_path || \".\"\n else\n @relative_path = val\n end\n end",
"def unravel_relative_path(rel_path)\n path_parts = rel_path.split '.'\n \n full_rel_path = \"\"\n defined_path = nil\n counter = path_parts.length\n \n for path_part in path_parts do\n path = defined_path.nil? ? path_part : \"#{defined_path}.#{path_part}\"\n if path_defined? path\n defined_path = path\n else\n break\n end\n counter = counter - 1\n end\n \n full_rel_path << self.defined_path(defined_path).full_rel_path if (not defined_path.nil?)\n if (counter > 0)\n full_rel_path << \".\" if (not defined_path.nil?)\n full_rel_path << path_parts.last(counter).join('.')\n end\n \n return full_rel_path\n end",
"def relative_path_from(other)\n Pathname.new(self).relative_path_from(Pathname.new(other)).to_s\n end",
"def relative_path(filename)\n @mount_dir_pieces ||= @mount_dir.size\n pieces = split_filename(File.expand_path(filename))\n File.join(pieces[@mount_dir_pieces..-1])\n end",
"def getRealPath(path) Pathname.new(path).realpath.to_s; end",
"def getRealPath(path) Pathname.new(path).realpath.to_s; end",
"def root_path(*args)\n relative = File.join(*args)\n return relative if relative.expand_path == relative\n root.expand_path / relative\n end",
"def root_path(*args)\n relative = File.join(*args)\n return relative if relative.expand_path == relative\n root.expand_path / relative\n end",
"def relative_path\n @relative_path ||= File.join(doc.relative_path, \"#excerpt\")\n end",
"def rpath\n if (parent.nil? and domain) or (parent and parent.domain != domain)\n return ''\n else\n if parent\n rp = parent.rpath\n unless rp.blank?\n rp + '/' + path\n else\n path\n end\n else\n path\n end\n end\n end",
"def path\n # FIXME: Do this without exception!\n #\"#{ @parent.path unless @parent == self }##{ ident }\"\n # rescue base path\n \"#{@parent.path rescue ''}##{ident}\"\n end",
"def full_path\n path\n end",
"def relative_path(options = {})\n File.join(self.site.content_dir(options), sanitize_filename(self.name))\n end",
"def relative_src(filename, dir=nil)\n file = expand_src filename, dir\n base = Pathname.new File.dirname path_info\n Pathname.new(file).relative_path_from(base).to_s\n end",
"def relative_pathname\n @relative_pathname ||= Pathname.new(relativize_root_path(pathname))\n end",
"def path\n # TODO: is this trip really necessary?!\n data.fetch(\"path\") { relative_path }\n end",
"def resolve_path(path)\n unless Pathname.new(path).absolute?\n File.join(Dir.pwd, path)\n else\n path\n end\nend",
"def resolve_path(path)\n unless Pathname.new(path).absolute?\n File.join(Dir.pwd, path)\n else\n path\n end\nend",
"def relative(paths, reference_path = Dir.pwd)\n paths = [paths].flatten.collect do |path|\n path = Pathname.new(File.expand_path(path))\n reference_path = Pathname.new(File.expand_path(reference_path))\n path.relative_path_from(reference_path).to_s\n end\n\n paths.length == 1 ? paths.first : paths\n end",
"def relative_path_to(other)\n other.relative_path_from(@root)\n end",
"def expanded_path\n relative_path(dependency.berksfile.filepath)\n end",
"def abs_path() \n if not @abs_path.nil? \n return @abs_path\n end\n\n if @parent.nil? or @parent.abs_path.nil?\n return @rel_path\n end\n\n @abs_path = \"#{@parent.abs_path}.#{rel_path}\"\n\n return @abs_path\n end",
"def path(ref)\n parts = ref.split('/')\n @depth == 0 ? parts[-1] : \"/\" + parts[-(@depth + 1)..-1].join('/')\n end",
"def absolute_parent_path\n File.dirname absolute_path\n end",
"def cleaned_relative_path; end",
"def cleaned_relative_path; end",
"def _wp_get_attachment_relative_path( file )\n dirname = File.dirname( file )\n return '' if dirname == '.'\n\n if dirname.include? 'wp-content/uploads'\n # Get the directory name relative to the upload directory (back compat for pre-2.7 uploads)\n dirname = dirname[dirname.index('wp-content/uploads') + 18 .. -1]\n dirname.gsub!(/^\\//, '')\n end\n dirname\n end",
"def absolute_path(relative_path)\n if relative_path.start_with?(\"/\")\n relative_path\n else\n File.join(@@project_root, relative_path)\n end\n end",
"def abs_path_with(rel_path)\n path = abs_path\n return rel_path if path.nil?\n return \"#{path}.#{rel_path}\"\n end",
"def absolutepath\n if absolute?\n self\n elsif to_s == \".\"\n realpath\n else\n parent.absolutepath + self.basename\n end\n end",
"def relative_path\n File.join(@repo, @bundle)\n end",
"def absolute_path(relative_path)\n quoted_string(File.expand_path(File.join(File.dirname(options[:filename]), relative_path.value)))\n end",
"def path\n Pathname(@path.respond_to?(:to_path) ? @path.to_path : @path.to_s).expand_path\n end",
"def full_path\n @full_path ||= path ? File.join(root, path) : root\n end",
"def full_path_for(path)\n path = \"/#{path}\" unless path[0..0] == '/'\n path\n end",
"def path\n return @path if instance_variable_defined? :@path\n @path = parent.path + path_components\n end",
"def parent_path(path)\n path.chomp('/')[/(.*\\/).*$/, 1]\n end",
"def fullpath\n File.join(@root, @path)\n end"
] | [
"0.7824317",
"0.7762498",
"0.7634046",
"0.75506514",
"0.7499013",
"0.7491094",
"0.7317677",
"0.7282227",
"0.72361356",
"0.7230335",
"0.7229075",
"0.72046477",
"0.71950006",
"0.7169684",
"0.71660477",
"0.71440613",
"0.7143346",
"0.70555377",
"0.70435154",
"0.700468",
"0.69882303",
"0.6970213",
"0.69675994",
"0.69664645",
"0.6953583",
"0.69433194",
"0.6931769",
"0.6924835",
"0.6919074",
"0.6919074",
"0.6919074",
"0.6919074",
"0.6919074",
"0.6909949",
"0.6867276",
"0.6856173",
"0.68540365",
"0.6847527",
"0.6837349",
"0.6812777",
"0.68111795",
"0.6806119",
"0.67987466",
"0.67987466",
"0.6786368",
"0.67572075",
"0.6754373",
"0.6739782",
"0.66712517",
"0.66673774",
"0.6661359",
"0.665993",
"0.66553336",
"0.66440326",
"0.66440326",
"0.6631359",
"0.6626771",
"0.660398",
"0.6586144",
"0.6582315",
"0.6581574",
"0.65553516",
"0.6546713",
"0.6537324",
"0.653728",
"0.6527097",
"0.65169317",
"0.65169317",
"0.6515183",
"0.6515183",
"0.6512111",
"0.6489847",
"0.64862865",
"0.6453771",
"0.64523315",
"0.6432315",
"0.64110136",
"0.6402827",
"0.6389177",
"0.6389177",
"0.63793874",
"0.63641906",
"0.63569146",
"0.6353878",
"0.63499284",
"0.6348011",
"0.6346588",
"0.6346588",
"0.63458985",
"0.63421863",
"0.6342032",
"0.6339933",
"0.63298094",
"0.63257575",
"0.63116294",
"0.6309245",
"0.6308285",
"0.6303317",
"0.629936",
"0.62965137"
] | 0.7330189 | 6 |
get the content tree for this base directory by iterating over all subdirectories and files within the base directory (and excluding the excluded files) and calculating file hashes using the specified Ruby hash class If there is an existing cached content file, use that to get the hash values of files whose modification time is earlier than the time value for the cached content tree. Also, if a cached content file is specified, write the final content tree back out to the cached content file. N Without this we won't have way to get the content tree object describing the contents of the local directory | def getContentTree
#N Without this we won't have timestamp and the map of file hashes used to efficiently determine the hash of a file which hasn't been modified after the timestamp
cachedTimeAndMapOfHashes = getCachedContentTreeMapOfHashes
#N Without this we won't have the timestamp to compare against file modification times
cachedTime = cachedTimeAndMapOfHashes[0]
#N Without this we won't have the map of file hashes
cachedMapOfHashes = cachedTimeAndMapOfHashes[1]
#N Without this we won't have an empty content tree which can be populated with data describing the files and directories within the base directory
contentTree = ContentTree.new()
#N Without this we won't have a record of a time which precedes the recording of directories, files and hashes (which can be used when this content tree is used as a cached for data when constructing some future content tree)
contentTree.time = Time.now.utc
#N Without this, we won't record information about all sub-directories within this content tree
for subDir in @baseDirectory.subDirs
#N Without this, this sub-directory won't be recorded in the content tree
contentTree.addDir(subDir.relativePath)
end
#N Without this, we won't record information about the names and contents of all files within this content tree
for file in @baseDirectory.allFiles
#N Without this, we won't know the digest of this file (if we happen to have it) from the cached content tree
cachedDigest = cachedMapOfHashes[file.relativePath]
#N Without this check, we would assume that the cached digest applies to the current file, even if one wasn't available, or if the file has been modified since the time when the cached value was determined.
# (Extra note: just checking the file's mtime is not a perfect check, because a file can "change" when actually it or one of it's enclosing sub-directories has been renamed, which might not reset the mtime value for the file itself.)
if cachedTime and cachedDigest and File.stat(file.fullPath).mtime < cachedTime
#N Without this, the digest won't be recorded from the cached digest in those cases where we know the file hasn't changed
digest = cachedDigest
else
#N Without this, a new digest won't be determined from the calculated hash of the file's actual contents
digest = hashClass.file(file.fullPath).hexdigest
end
#N Without this, information about this file won't be added to the content tree
contentTree.addFile(file.relativePath, digest)
end
#N Without this, the files and directories in the content tree might be listed in some indeterminate order
contentTree.sort!
#N Without this check, a new version of the cached content file will attempt to be written, even when no name has been specified for the cached content file
if cachedContentFile != nil
#N Without this, a new version of the cached content file (ready to be used next time) won't be created
contentTree.writeToFile(cachedContentFile)
end
return contentTree
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getContentTree\n #N Without this check we would try to read the cached content file when there isn't one, or alternatively, we would retrieve the content details remotely, when we could have read them for a cached content file\n if cachedContentFile and File.exists?(cachedContentFile)\n #N Without this, the content tree won't be read from the cached content file\n return ContentTree.readFromFile(cachedContentFile)\n else\n #N Without this, we wouldn't retrieve the remote content details\n contentTree = contentHost.getContentTree(baseDir)\n #N Without this, the content tree might be in an arbitrary order\n contentTree.sort!\n #N Without this check, we would try to write a cached content file when no name has been specified for it\n if cachedContentFile != nil\n #N Without this, the cached content file wouldn't be updated from the most recently retrieved details\n contentTree.writeToFile(cachedContentFile)\n end\n #N Without this, the retrieved sorted content tree won't be retrieved\n return contentTree\n end\n end",
"def getCachedContentTreeMapOfHashes\n #N Without this, we won't know the name of the specified cached content file (if it is specified)\n file = getExistingCachedContentTreeFile\n #N Without this check, we would attempt to read a non-existent file\n if file\n #N Without this, there won't be feedback to the user that we are reading the cached file hashes\n puts \"Reading cached file hashes from #{file} ...\"\n #N Without this, a map of cached file hashes won't be returned\n return ContentTree.readMapOfHashesFromFile(file)\n else\n #N Without this, the method wouldn't consistently return an array of timestamp + map of hashes in the case where there is no cached content file\n return [nil, {}]\n end\n end",
"def getCachedContentTree\n #N Without this, we won't know the name of the specified cached content file (if it is specified)\n file = getExistingCachedContentTreeFile\n #N Without this check, we would attempt to read a non-existent file\n if file\n #N Without this, a content tree that has been cached won't be returned.\n return ContentTree.readFromFile(file)\n else\n return nil\n end\n end",
"def getContentTree(baseDir)\n #N Without this, wouldn't have an empty content tree that we could start filling with dir & file data\n contentTree = ContentTree.new()\n #N Without this, wouldn't record the time of the content tree, and wouldn't be able to determine from a file's modification time that it had been changed since that content tree was recorded.\n contentTree.time = Time.now.utc\n #N Without this, the listed directories won't get included in the content tree\n for dir in listDirectories(baseDir)\n #N Without this, this directory won't get included in the content tree\n contentTree.addDir(dir)\n end\n #N Without this, the listed files and hashes won't get included in the content tree\n for fileHash in listFileHashes(baseDir)\n #N Without this, this file & hash won't get included in the content tree\n contentTree.addFile(fileHash.relativePath, fileHash.hash)\n end\n return contentTree\n end",
"def find_caches\n Dir.glob(File.join(@root, '**/*.cache')).reduce([]) { |stats, filename|\n stat = safe_stat(filename)\n # stat maybe nil if file was removed between the time we called\n # dir.glob and the next stat\n stats << [filename, stat] if stat\n stats\n }.sort_by { |_, stat| stat.mtime.to_i }\n end",
"def build_cache\n all_files = []\n\n Find.find(@root) do |path|\n if FileTest.directory?(path)\n if File.basename(path)[0] == ?.\n Find.prune\n else\n next\n end\n else\n path.slice!(\"#{@root}/\")\n all_files << path\n end\n end\n\n return all_files\n end",
"def write_if_empty\n return if cached_content.present?\n\n @diff_collection.diff_files.each do |diff_file|\n next unless cacheable?(diff_file)\n\n diff_file_id = diff_file.file_identifier\n\n cached_content[diff_file_id] = diff_file.highlighted_diff_lines.map(&:to_hash)\n end\n\n cache.write(key, cached_content, expires_in: 1.week)\n end",
"def dir_contents(path, &b)\n path = Pathname.new(path).cleanpath\n if fs.directory?(path)\n entries = fs.entries(path).map do |entry|\n entry_path = path + entry\n if fs.directory?(entry_path)\n dir_item(entry)\n else\n file_item(entry, fs.get_size(entry_path))\n end\n end\n yield entries\n else\n yield Set.new\n end\n end",
"def create_class_cache\n class_cache = OpenStructHash.new\n\n if(@use_cache)\n # Dump the documentation directories to a file in the cache, so that\n # we only will use the cache for future instantiations with identical\n # documentation directories.\n File.open @cache_doc_dirs_path, \"wb\" do |fp|\n fp << @doc_dirs.join(\"\\n\")\n end\n end\n\n classes = map_dirs('**/cdesc*.yaml') { |f| Dir[f] }\n warn \"Updating ri class cache with #{classes.size} classes...\"\n populate_class_cache class_cache, classes\n\n write_cache class_cache, class_cache_file_path\n\n class_cache\n end",
"def initialize(baseDirectory, hashClass, cachedContentFile = nil)\n #N Without this, we won't remember the cached content file name\n super(cachedContentFile)\n #N Without this, we won't remember the base directory\n @baseDirectory = baseDirectory\n #N Without this, we won't remember the hash function\n @hashClass = hashClass\n end",
"def to_hash(hash = {})\r\n hash[name] ||= attributes_as_hash\r\n\r\n walker = lambda { |memo, parent, child, callback|\r\n next if child.blank? && 'file' != parent['type']\r\n\r\n if child.text?\r\n (memo[CONTENT_ROOT] ||= '') << child.content\r\n next\r\n end\r\n\r\n name = child.name\r\n\r\n child_hash = child.attributes_as_hash\r\n if memo[name]\r\n memo[name] = [memo[name]].flatten\r\n memo[name] << child_hash\r\n else\r\n memo[name] = child_hash\r\n end\r\n\r\n # Recusively walk children\r\n child.children.each { |c|\r\n callback.call(child_hash, child, c, callback)\r\n }\r\n }\r\n\r\n children.each { |c| walker.call(hash[name], self, c, walker) }\r\n hash\r\n end",
"def to_hash(hash = {})\n hash[name] ||= attributes_as_hash\n\n walker = lambda { |memo, parent, child, callback|\n next if child.blank? && 'file' != parent['type']\n\n if child.text?\n (memo[CONTENT_ROOT] ||= '') << child.content\n next\n end\n\n name = child.name\n\n child_hash = child.attributes_as_hash\n if memo[name]\n memo[name] = [memo[name]].flatten\n memo[name] << child_hash\n else\n memo[name] = child_hash\n end\n\n # Recusively walk children\n child.children.each { |c|\n callback.call(child_hash, child, c, callback)\n }\n }\n\n children.each { |c| walker.call(hash[name], self, c, walker) }\n hash\n end",
"def update_tth path, node\n if EventMachine.reactor_thread? || !@update_lock.locked?\n raise 'Should not update tth hashes in reactor thread or without' \\\n ' the local list lock!'\n end\n # Ignore dotfiles\n return if path.basename.to_s.start_with?('.')\n\n # Files might need to have a TTH updated, but only if they've been\n # modified since we last calculated a TTH\n if path.file?\n cached_info = @local_file_info[path]\n child = LibXML::XML::Node.new('File')\n child['Name'] = path.basename.to_s\n if cached_info && path.mtime <= cached_info[:mtime]\n child['TTH'] = cached_info[:tth]\n child['Size'] = cached_info[:size]\n else\n debug 'file-list', \"Hashing: #{path.to_s}\"\n child['TTH'] = file_tth path.to_s\n child['Size'] = path.size.to_s\n end\n @local_file_info[path] = {:mtime => path.mtime,\n :size => child['Size'],\n :tth => child['TTH']}\n node << child\n\n # Directories just need a node and then a recursive update\n elsif path.directory?\n child = LibXML::XML::Node.new('Directory')\n child['Name'] = path.basename.to_s\n path.each_child { |child_path| update_tth child_path, child }\n node << child\n\n # If we're not a file or directory, then we just have to ignore the\n # file for now...\n else\n debug 'file-list', \"Ignoring: #{path}\"\n end\n end",
"def mtime_snapshot\n snapshot = {}\n filenames = expand_directories(@unexpanded_filenames)\n\n # Remove files in the exclude filenames list\n filenames -= expand_directories(@unexpanded_excluded_filenames)\n\n filenames.each do |filename|\n mtime = File.exist?(filename) ? File.mtime(filename) : Time.new(0)\n snapshot[filename] = mtime\n end\n snapshot\n end",
"def getContentCache(theContent)\n\n\ttheChecksum = Digest::SHA256.hexdigest(theContent).insert(2, '/');\n\ttheCache = \"#{PATH_FORMAT_CACHE}/#{theChecksum}\";\n\t\n\treturn theCache;\n\nend",
"def directory_hash(path, name=nil)\n data = {:folder => (name || path.split(\"/\").last)}\n data[:children] = children = []\n Dir.foreach(path) do |entry|\n next if (entry == '..' || entry == '.' || entry == 'yamproject.json' || entry == '.DS_Store')\n full_path = File.join(path, entry)\n if File.directory?(full_path)\n children << directory_hash(full_path, entry)\n else\n children << entry\n end\n end\n return data\nend",
"def getExistingCachedContentTreeFile\n #N Without this check, it would try to find the cached content file when none was specified\n if cachedContentFile == nil\n #N Without this, there will be no feedback to the user that no cached content file is specified\n puts \"No cached content file specified for location\"\n return nil\n #N Without this check, it will try to open the cached content file when it doesn't exist (i.e. because it hasn't been created, or, it has been deleted)\n elsif File.exists?(cachedContentFile)\n #N Without this, it won't return the cached content file when it does exist\n return cachedContentFile\n else\n #N Without this, there won't be feedback to the user that the specified cached content file doesn't exist.\n puts \"Cached content file #{cachedContentFile} does not yet exist.\"\n return nil\n end\n end",
"def processFile dir\n\tdir.each do |file|\n\t\tif File.directory?(file) then next;\n\t\t\telse \n\t\t\t\th = {File.basename(file) => getHash(file)}\n\t\t\t\[email protected]!(h)\n\t\tend\n\tend\n\t@hash\nend",
"def recurse_local\n result = perform_recursion(self[:path])\n return {} unless result\n result.inject({}) do |hash, meta|\n next hash if meta.relative_path == \".\"\n\n hash[meta.relative_path] = newchild(meta.relative_path)\n hash\n end\n end",
"def get_contents \n @contents = []\n\n sub_directory_names = Dir[CONTENT_ROOT_DIRECTORY + \"/*\"]\n\n sub_directory_names.each do |sub_directory_name|\n sub_directory_basename = File.basename(sub_directory_name)\n @contents.push(Content.new(sub_directory_basename))\n end\n end",
"def recursive_checksum(_path, hash_class, _bit_size, file_object, debugmode, samefolder)\n begin\n # When the file is a directory be recursive\n if File.directory? _path\n # Object to hand the directory\n directory_object = Dir.open _path\n base_path = File.expand_path _path\n # Process all files in directory\n directory_object.each_child do |child|\n # Child to be processed\n child_path = File.join base_path, child\n\n recursive_checksum child_path, hash_class, _bit_size,file_object, debugmode, samefolder\n end\n else\n # path to be used\n if samefolder\n # use ./ for base example ./filename.txt\n file_path = _path.sub(samefolder, './')\n else\n # use complete path to file\n file_path = File.expand_path _path\n end\n # When it is aa file write directly to file_object or print it\n content = \"#{file_path},#{checksum _path, hash_class, _bit_size}\"\n # Debug mode prints every file hash\n if debugmode\n puts content\n end\n # If the user use -o to output\n if file_object\n file_object.write \"#{content}\\n\"\n end\n end\n rescue\n nil\n end\n\nend",
"def get(till = DateTime.now)\n # looking for the latest base file that is earlier than till argument\n base = snapshot_files.inject(nil) do |cur_base, f|\n if (cur_base.nil? || f.same_time_as?(till) ||\n (f.earlier_than?(till) && f.later_than?(cur_base.till)))\n cur_base = f\n end\n cur_base\n end\n base_cd = ContentData::ContentData.new\n base_cd.from_file(base.filename)\n # applying diff files between base timestamp and till argument\n diff_from_base = diff(base.till, till)\n added_content_data = diff_from_base[DiffFile::ADDED_TYPE]\n removed_content_data = diff_from_base[DiffFile::REMOVED_TYPE]\n\n result = base_cd.merge(added_content_data)\n result.remove_instances!(removed_content_data)\n result\n end",
"def buildCodeFilesHashFromFiles()\n\t\tdir = @cacheDirPath \n\t\tfilesList = Dir.glob(dir + \"**/*\").select{|e| File.file? e}\n\t\tfilesList.map.with_index{|file,index|\n\t\t\t#p \"cacheFile: \" + index.to_s if index % 1000 == 0\n\t\t\tp \"cacheFile: \" + index.to_s \n\t\t\tfilePath = dir + index.to_s + \".yaml\"\n\t\t\tfile = File.read(filePath)\n\t\t\tYAML.load(file)\n\t\t}.to_h\n\tend",
"def tree(root = '')\n build_hash(files(root), root)\n end",
"def create_cache_for(klassname, path)\n klass = class_cache[klassname]\n return nil unless klass\n\n method_files = klass[\"sources\"]\n cache = OpenStructHash.new\n\n method_files.each do |f|\n system_file = f.index(@sys_dir) == 0\n Dir[File.join(File.dirname(f), \"*\")].each do |yaml|\n next unless yaml =~ /yaml$/\n next if yaml =~ /cdesc-[^\\/]+yaml$/\n\n method = read_yaml yaml\n\n if system_file then\n method[\"source_path\"] = \"Ruby #{RDoc::RI::Paths::VERSION}\"\n else\n gem = Gem.path.any? do |path|\n pattern = File.join Regexp.escape(path), 'doc', '(.*?)', ''\n\n f =~ /^#{pattern}/\n end\n\n method[\"source_path\"] = if gem then\n \"gem #{$1}\"\n else\n f\n end\n end\n\n name = method[\"full_name\"]\n cache[name] = method\n end\n end\n\n write_cache cache, path\n end",
"def cache(input_path, output_path, data=nil)\n path = input_path\n @new_hashes[input_path] = hash(@input_directory, input_path)\n\n if data\n @data[path] = data if data\n @wildcard_dependencies[path] = data[:wildcard_dependencies] if data[:wildcard_dependencies]\n @dependencies[path] = data[:dependencies] if data[:dependencies]\n end\n\n FileUtils.mkdir_p(File.dirname(cached_path_for(path)))\n\n if File.exist? File.join(@output_directory, output_path)\n FileUtils.cp(File.join(@output_directory, output_path), cached_path_for(path))\n else\n FileUtils.cp(File.join(@input_directory, input_path), cached_path_for(input_path))\n end\n end",
"def applicable_owners_files_hash\n return @applicable_owners_files_hash if !@applicable_owners_files_hash.nil?\n\n # Make hash of (directory => [files in that directory in this commit]) pairs\n\n puts \"changed files: #{changed_files.inspect}\"\n\n affected_dirs_hash = changed_files.collect_to_reverse_hash do |file|\n File.dirname(file)\n end\n\n puts \"affected_dirs_hash: #{affected_dirs_hash.inspect}\"\n\n affected_dirs = affected_dirs_hash.keys\n\n # Make hash of owners file => [file1, file2, file3]\n res = affected_dirs.inject(Hash.new) do |hash, dir|\n owner = find_owners_file(dir)\n\n # If there's no OWNERS file for this dir, just skip it\n if owner.nil?\n return hash\n end\n\n data = {\n :owner_data => owner,\n :files => affected_dirs_hash[dir]\n }\n\n key = owner[:path]\n\n if (hash.include?(key))\n combined_data = hash[key]\n combined_data[:files] = combined_data[:files] + data[:files]\n\n hash[key] = combined_data\n else\n hash[key] = data\n end\n hash\n end \n\n @applicable_owners_files_hash = res\n end",
"def directory_hash(path, name=nil, exclude = [])\n exclude.concat(['..', '.', '.git', '__MACOSX', '.DS_Store'])\n data = {'name' => (name || path), 'type' => 'folder'}\n data[:children] = children = []\n Dir.entries(path).sort.each do |entry|\n # Dir.entries(path).each\n # puts entry\n next if exclude.include?(entry)\n full_path = File.join(path, entry)\n if File.directory?(full_path)\n if entry.include?(\"credit app\")\n kids = Dir.entries(full_path)\n kids.reject! {|x|exclude.include?(x)}\n if kids.length >= 1\n # can add a kids.each loop here if mom ever wants more than one credit app\n child_path = File.join(full_path, kids[0])\n true_path = child_path.partition(\"app/assets/images/\")[2]\n link = ActionController::Base.helpers.image_path(true_path)\n # puts full_path\n # puts link\n entry = entry.split('.')[0]\n if entry.include?('--')\n entry = entry.split('--')[1]\n end\n entry = entry.upcase\n\n children << \"<li class='category'>CREDIT APP<li class='kid'><a href='#{link}'>#{entry}</a></li></li>\"\n else\n # gotta fix these two somehow\n children << \"<li><a href='#'>NO APP</a></li>\"\n end\n elsif entry.include?('flipbook')\n # Dir.entries(full_path).each do |flipbook|\n # next if exclude.include?(flipbook)\n # if File.directory?(full_path)\n name = entry.split(\"-\")[1]\n name = name.upcase\n if @account==\"UNDER ARMOUR\" && full_path.include?('UA GOLF')\n uasub = 'UA GOLF'\n elsif @account==\"UNDER ARMOUR\" && full_path.include?('UA FITNESS')\n uasub = 'UA FITNESS'\n end\n\n linky = view_context.link_to name, controller: 'catalogues', action: 'flipbook', id: @account, subid: entry, :data => { :uaname => uasub }\n children << \"<li class='kid'>#{linky}</li>\"\n # catfolder = full_path.split('/flipbook')[0]\n # end\n\n # end\n elsif entry.include?(\"toplevel\")\n # replace toplevel with a better check, something like if parent = pictures\n entryname=entry.split('-')[0].upcase\n children << \"<li class='kid'><a href='/catalogues/#{@account}/pictures/#{entry}'>#{entryname}</a></li>\"\n\n else\n children << directory_hash(full_path, entry)\n end\n else\n # true_path = full_path.partition(\"app/assets/images/\")[2]\n\n true_path = full_path.partition(\"app/assets/images/\")[2]\n # puts true_path\n link = ActionController::Base.helpers.image_path(true_path)\n\n # puts link\n entry = entry.split('.')[0]\n if entry.include?('--')\n entry = entry.split('--')[1]\n end\n # this is where final kids are created\n entry = entry.upcase\n children << \"<li class='kid'><a href='#{link}'>#{entry}</a></li>\"\n end\n end\n return data\n end",
"def recurse_and_hash_tree(node)\n\n ## exit program if given a bunk file/dir\n print_and_exit \"given a bunk file/node\" unless File.exist? node\n\n ## if we have a file then return it's hash\n return Digest::MD5.hexdigest( node + File.read(node) ) if File.file? node\n\n ## we should have a directory now. exit otherwise...\n print_and_exit \"is there a strange device in this dir?\" unless File.directory? node\n\n ## recurse through each element in the directory and remember their hashes\n children_hash = \"\"\n Dir.glob(File.join node, '*' ) { |element| children_hash << recurse_and_hash_tree(element) }\n \n ## return the mashed up hash\n return Digest::MD5.hexdigest( node + children_hash ) \n\n end",
"def bust(out: nil, preserve_tree: false, preserve_original: true)\n FileUtils.mkdir_p(out) if out\n\n @map = @files.each_with_object({}) do |f, result|\n hash = Digest::MD5.hexdigest File.read f\n basename = File.basename f\n dirname = File.dirname f\n new_name = hash[0...6] + \"_\" + basename\n\n destination = out ? out : dirname\n\n if preserve_tree && destination\n dirname = out ? path_diff(dirname, out) : dirname\n destination = File.join(out, dirname)\n FileUtils.mkdir_p(destination)\n end\n \n # TODO: This will remove a hashed file if it follows the format of\n # 6letters_anything.css\n rm_busted(destination)\n\n FileUtils.cp f, File.join(destination, new_name)\n result[basename] = new_name\n result\n end\n\n FileUtils.rm(@files) if (not preserve_original)\n\n return self\n end",
"def get_contents uri,user,password,recursive=false\n \n found=[]\n\n content = propfind uri,user,password,1\n\n parser = LibXML::XML::Parser.string(content,:encoding => LibXML::XML::Encoding::UTF_8)\n\n document = parser.parse\n\n href_nodes = document.find(\"ns:response\",\"ns:DAV:\")\n \n href_nodes.each do |node|\n unless node == href_nodes.first \n href_node=node.find_first(\"ns:href\",\"ns:DAV:\")\n last_modified_node = node.find_first(\"*/ns:prop\",\"ns:DAV:\").find_first(\"ns:getlastmodified\",\"ns:DAV:\")\n creation_date_node = node.find_first(\"*/ns:prop\",\"ns:DAV:\").find_first(\"ns:creationdate\",\"ns:DAV:\")\n content_type_node = node.find_first(\"*/ns:prop\",\"ns:DAV:\").find_first(\"ns:getcontenttype\",\"ns:DAV:\")\n\n attributes={ \n :containing_path=>uri.to_s,\n :full_path=>uri.merge(href_node.inner_xml).to_s,\n :updated_at=>DateTime.parse(last_modified_node.inner_xml).to_s,\n :created_at=>DateTime.parse(creation_date_node.inner_xml).to_s,\n :is_directory=>is_dir?(href_node,content_type_node)\n }\n found << attributes\n end\n end\n \n found.select{|a| a[:is_directory]}.each do |dir_tuple|\n child_uri=URI.parse(dir_tuple[:full_path])\n children=get_contents child_uri,user,password,true\n dir_tuple[:children]=children\n end if recursive\n \n return found\n \n end",
"def build_subtree(folder, include_files = true)\n folder_metadata = {}\n folder_metadata['subfolders'] = (folder.is_virtual? ?\n folder.subfolders : MaterialFolder.accessible_by(current_ability).where(:parent_folder_id => folder))\n .map { |subfolder|\n build_subtree(subfolder, include_files)\n }\n if (folder.parent_folder == nil) and not (folder.is_virtual?) then\n folder_metadata['subfolders'] += virtual_folders.map { |subfolder|\n build_subtree(subfolder, include_files)\n }\n end\n\n folder_metadata['id'] = folder.id\n folder_metadata['name'] = folder.name\n folder_metadata['url'] = folder.is_virtual? ? course_material_virtual_folder_path(@course, folder) : course_material_folder_path(@course, folder)\n folder_metadata['parent_folder_id'] = folder.parent_folder_id\n folder_metadata['count'] = folder.files.length\n folder_metadata['is_virtual'] = folder.is_virtual?\n if include_files then\n folder_metadata['files'] = (folder.is_virtual? ?\n folder.files : Material.accessible_by(current_ability).where(:folder_id => folder))\n .map { |file|\n current_file = {}\n\n current_file['id'] = file.id\n current_file['name'] = file.filename\n current_file['description'] = file.description\n current_file['folder_id'] = file.folder_id\n current_file['url'] = course_material_file_path(@course, file)\n\n if not(folder.is_virtual? || @curr_user_course.seen_materials.exists?(file.id)) then\n current_file['is_new'] = true\n folder_metadata['contains_new'] = true\n end\n\n current_file\n }\n end\n\n folder_metadata\n end",
"def listFileHashes\n return contentHost.listFileHashes(baseDir)\n end",
"def getContentTreeForSubDir(subDir)\n #N Without this we won't know if the relevant sub-directory content tree hasn't already been created\n dirContentTree = dirByName.fetch(subDir, nil)\n #N Without this check, we'll be recreated the sub-directory content tree, even if we know it has already been created\n if dirContentTree == nil\n #N Without this the new sub-directory content tree won't be created\n dirContentTree = ContentTree.new(subDir, @pathElements)\n #N Without this the new sub-directory won't be added to the list of sub-directories of this directory\n dirs << dirContentTree\n #N Without this we won't be able to find the sub-directory content tree by name\n dirByName[subDir] = dirContentTree\n end\n return dirContentTree\n end",
"def treecache\n @treecache ||= TaggedCache.new\n end",
"def mtimes\n @files.inject({}) do |hash, g|\n Dir[g].each { |file| hash[file] = File.mtime(file) }\n hash\n end\n end",
"def monitor(file_attr_to_checksum=nil)\n\n # Marking/Removing Algorithm:\n # assume that current dir is present\n # ls (glob) the dir path for child dirs and files\n # if child file is not already present, add it as new, mark it and handle its state\n # if file already present, mark it and handle its state.\n # if child dir is not already present, add it as new, mark it and propagates\n # the recursive call\n # if child dir already present, mark it and handle its state\n # marked files will not be remove in next remove phase\n\n # ls (glob) the dir path for child dirs and files\n globed_paths_enum = Dir.glob(@path + \"/*\").to_enum\n \n found_symlinks = {} # Store found symlinks under dir\n loop do\n globed_path = globed_paths_enum.next rescue break\n\n next unless is_globed_path_valid(globed_path)\n if File.symlink?(globed_path)\n add_found_symlinks(globed_path, found_symlinks)\n next\n end\n\n # Get File \\ Dir status\n globed_path_stat = File.lstat(globed_path) rescue next # File or dir removed from OS file system\n if globed_path_stat.file?\n # ----------------------------- FILE -----------------------\n child_stat = @files[globed_path]\n if child_stat\n # Mark that file exists (will not be deleted at end of monitoring)\n child_stat.marked = true\n # Handle existing file If we are not in manual mode.\n # In manual mode do nothing\n handle_existing_file(child_stat, globed_path, globed_path_stat) unless Params['manual_file_changes']\n else\n unless Params['manual_file_changes']\n # Handle regular case of new file.\n handle_new_file(child_stat, globed_path, globed_path_stat)\n else\n # Only create new content data instance based on copied/moved filed.\n handle_moved_file(globed_path, globed_path_stat, file_attr_to_checksum)\n end\n end\n else\n handle_dir(globed_path, file_attr_to_checksum)\n end\n end\n\n remove_not_found_symlinks(found_symlinks)\n\n GC.start\n end",
"def getBuildFiles(directory)\r\n\t# hash key is file name (path to file not included). hash value is contents of file\r\n\tbuildFiles = Hash.new()\r\n\tDir.glob(\"#{directory}\") do |filepath|\r\n\t\tif filepath.split(//).last(10).join(\"\").to_s == \"build.html\"\r\n\t\t\tbuildFile = File.open(filepath, \"rb\")\r\n\t\t\tbuildFileContents = buildFile.readlines\r\n\t\t\tbuildFileContents.map! { |element|\r\n\t\t\t element.gsub(/\\r\\n?/,\"\")\r\n\t\t\t}\r\n\t\t\t# key is everything after final slash\r\n\t\t\tkey = filepath.split('/')[-1]\r\n\t\t\tbuildFiles[key] = buildFileContents\r\n\t\tend\r\n\tend\r\n\treturn buildFiles\r\nend",
"def build_hash_tree(filenames)\n files_tree = filenames.inject({}) { |h, i| t = h; i.split(\"/\").each { |n| t[n] ||= {}; t = t[n] }; h }\nend",
"def getFiles (conf)\n # include even .xxx ( dotted ) files \n\t(Dir.glob(\"*\", File::FNM_DOTMATCH) - %w[. ..]).each do |f|\n\t\tf=File.expand_path(f)\t\t\t# get complete path for file\n ts = File.mtime(f)\n\t\tif File.directory?(f)\n conf[:fsize] += 1 #count dirs as size 1\n conf[:zipFiles]<< f #add even excluded dir as empty folder only\n\t\t\tnext if exclude(f,conf[:exDirs])\n conf[:modTS] = ts if ts > conf[:modTS]\n\t\t\tDir.chdir(f)\n\t\t\tgetFiles(conf)\t# recursively explore subdir\n\t\t\tDir.chdir(\"..\")\n\t\telse\n next if exclude(f,conf[:exFiles])\n\t\t\tconf[:zipFiles]<< f \n conf[:fsize] += File.size(f)\n conf[:modTS] = ts if ts > conf[:modTS]\n\n\t\tend\n\tend\nend",
"def class_cache\n return @class_cache if @class_cache\n\n # Get the documentation directories used to make the cache in order to see\n # whether the cache is valid for the current ri instantiation.\n if(File.readable?(@cache_doc_dirs_path))\n cache_doc_dirs = IO.read(@cache_doc_dirs_path).split(\"\\n\")\n else\n cache_doc_dirs = []\n end\n\n newest = map_dirs('created.rid') do |f|\n File.mtime f if test ?f, f\n end.max\n\n # An up to date cache file must have been created more recently than\n # the last modification of any of the documentation directories. It also\n # must have been created with the same documentation directories\n # as those from which ri currently is sourcing documentation.\n up_to_date = (File.exist?(class_cache_file_path) and\n newest and newest < File.mtime(class_cache_file_path) and\n (cache_doc_dirs == @doc_dirs))\n\n if up_to_date and @use_cache then\n open class_cache_file_path, 'rb' do |fp|\n begin\n @class_cache = Marshal.load fp.read\n rescue\n #\n # This shouldn't be necessary, since the up_to_date logic above\n # should force the cache to be recreated when a new version of\n # rdoc is installed. This seems like a worthwhile enhancement\n # to ri's robustness, however.\n #\n $stderr.puts \"Error reading the class cache; recreating the class cache!\"\n @class_cache = create_class_cache\n end\n end\n else\n @class_cache = create_class_cache\n end\n\n @class_cache\n end",
"def content_files\n @cache_content_files ||= cached_datafiles.reject { |df| sip_descriptor == df }\n end",
"def get_content(folder = nil, sort = nil)\n abs_path = folder ? ROOT + folder : ROOT\n \n # build array if pairs: [filename, :type, is_textfile]\n sorter = case sort\n when 'name' then '| sort -f'\n when 'ctime' then '-c'\n when 'mtime' then '--sort=time'\n when 'size' then '--sort=size'\n else ''\n end\n\n list_files(abs_path, sorter).map do |obj|\n file_path = abs_path + obj\n [obj,\n if file_path.file?; :file\n elsif file_path.directory?; :dir\n elsif file_path.symlink?; :link\n end,\n \n !!`file \"#{file_path.to_s.shellescape}\"`.force_encoding(Encoding::UTF_8).sub(file_path.to_s, '').index(/text/i)\n ]\n end\n end",
"def list\n\t\t\tbegin\n\n\t\t\t\t# Prepare result, array of absolute paths for found files\n # within given directory. Also empty cache\n\t\t\t\tresult = []\n @scan_history = {}\n\n\t\t\t\t# Recursively scan current folder for files\n\t\t\t\tFind.find(@scan_path) do |current_full_path|\n\n\t\t\t\t\t# Get filename, prune if dot\n\t\t\t\t\tfilename = File.basename(current_full_path)\n Find.prune if filename[0] == ?.\n\n # Get extension\n extension = File.extname(current_full_path)\n\n\t\t\t\t\t# Check for file extension, if provided\n\t\t\t\t\tif @scan_extension && extension.eql?(@scan_extension)\n\n # Get foldername\n folder_name = File.dirname(current_full_path)\n\n # Get number of files parsed in current folder, default 0\n folder_depth = @scan_history.fetch(folder_name, nil) || 0\n Logging[self].debug \"At #{folder_name}\" if folder_depth == 0\n\n # If the desired depth hasn't been reached\n unless folder_depth == @scan_depth\n\n # Increase current depth\n folder_depth += 1\n\n # Add and log result\n Logging[self].warn \"Result: '#{current_full_path}'\"\n result << current_full_path\n\n # Update cache, proceed no further in this folder\n @scan_history[folder_name] = folder_depth\n Find.prune\n end\n\t\t\t\t\telse\n\t\t\t\t\t\n\t\t\t\t\t\t# Either move beyond this file, if we're searching\n\t\t\t\t\t\t# for specific files (filtered by extension), or add\n # the path to the result (since no filter applied)\n\t\t\t\t\t\t@scan_extension ? next : (result << current_full_path)\n\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\t\t\n end # find block\n\n # Log final result length\n Logging[self].info \"Retrieved #{result.length} results\"\n\n\t\t\t\t# Return result\n\t\t\t\tresult\n\n\t\t\t# Rescue any exceptions\n\t\t\trescue Exception => e\n\t\t\t\tLogging[self].error e\n nil\n\t\t\tend\n\t\tend",
"def recursive_fetch(path, data, current_path = [], options = {})\n # Split path into head and tail; for the next iteration, we'll look use\n # only head, and pass tail on recursively.\n head = path[0]\n current_path << head\n tail = path.slice(1, path.length)\n\n # For the leaf element, we do nothing because that's where we want to\n # dispatch to.\n if path.length == 1\n return data\n end\n\n # If we're a write function, then we need to create intermediary objects,\n # i.e. what's at head if nothing is there.\n if data[head].nil?\n # If the head is nil, we can't recurse. In create mode that means we\n # want to create hash children, but in read mode we're done recursing.\n # By returning a hash here, we allow the caller to send methods on to\n # this temporary, making a PathedAccess Hash act like any other Hash.\n if not options[:create]\n return {}\n end\n\n data[head] = {}\n end\n\n # Ok, recurse.\n return recursive_fetch(tail, data[head], current_path, options)\n end",
"def find_md5(dir, excludes)\n found = []\n (Dir.entries(dir) - %w[. ..]).map { |e| File.join(dir, e) }.each do |path|\n if File.directory?(path)\n unless exclude?(excludes, path)\n found += find_md5(path, excludes)\n end\n elsif File.file?(path)\n if (file = new(path))\n unless exclude?(excludes, file.path)\n file.md5 = Digest::MD5.file(file.path).hexdigest\n found << file\n end\n end\n end\n end\n found\n end",
"def changed_files_since(root, time, prunes = [ ])\n prunes = prunes.map { |p| File.expand_path(p) }\n \n root = File.expand_path(root)\n key = key_for(root, prunes)\n data = @roots[key]\n \n unless data && data[:up_to_date]\n new_mtimes = { }\n start_time = Time.now\n if @filesystem_impl.exist?(root)\n @filesystem_impl.find(root) do |path|\n if prunes.detect { |p| File.expand_path(path)[0..(p.length - 1)] == p }\n @filesystem_impl.prune\n else\n new_mtimes[path] = @filesystem_impl.mtime(path)\n end\n end\n end\n end_time = Time.now\n \n # Deleted files -- if we don't have a new mtime for it, it doesn't exist;\n # we then say it was modified now, the first time we noticed it was gone.\n if data\n data.keys.each { |path| new_mtimes[path] ||= start_time }\n end\n \n data = new_mtimes\n @roots[key] = data\n @roots[key][:up_to_date] = true\n end\n \n file_list = data.keys - [ :up_to_date ]\n if time\n time = Time.at(time.to_i)\n file_list = file_list.select { |path| data[path] >= time }\n end\n \n file_list\n end",
"def snapshot_filesystem\n mtimes = {}\n\n files = @files.map { |file| Dir[file] }.flatten.uniq\n\n files.each do |file|\n if File.exists? file\n mtimes[file] = File.stat(file).mtime\n end\n end\n\n mtimes\n end",
"def sub_content \n sub_contents = []\n\n if @is_post == false\n root_regexp = Regexp.new(@root, Regexp::IGNORECASE)\n sub_directories = Dir.glob(@absolute_path + '*');\n\n sub_directories.each do |sub_directory|\n begin\n # Remove the root from the path we pass to the new Content instance.\n # REVIEW: Should we be flexible and allow for the root dir to be present?\n content = Content.new(sub_directory.sub(root_regexp, ''))\n sub_contents.push(content)\n rescue ArgumentError\n next\n end\n end\n end\n\n sub_contents.reverse\n end",
"def file_tree path = false, only_extensions = [], name = nil\n path = @path unless path\n data = { :name => (name || path) }\n data[:children] = children = []\n if(File.directory?(path) && File.exists?(path))\n Dir.foreach(path) do |entry|\n next if entry == '..' or entry == '.' or entry.start_with?(\".\")\n full_path = File.join(path, entry)\n if File.directory?(full_path)\n children << file_tree(full_path, only_extensions, entry)\n else\n if only_extensions.size > 0\n children << { :name => entry } if only_extensions.all? {|extension| true if entry.end_with?(extension) }\n else\n children << { :name => entry }\n end\n end\n end\n end\n return data\n end",
"def file_digest(path)\n if stat = self.stat(path)\n # Caveat: Digests are cached by the path's current mtime. Its possible\n # for a files contents to have changed and its mtime to have been\n # negligently reset thus appearing as if the file hasn't changed on\n # disk. Also, the mtime is only read to the nearest second. Its\n # also possible the file was updated more than once in a given second.\n cache.fetch(['file_digest', path, stat.mtime.to_i]) do\n if stat.directory?\n # If its a directive, digest the list of filenames\n digest_class.digest(self.entries(path).join(','))\n elsif stat.file?\n # If its a file, digest the contents\n digest_class.file(path.to_s).digest\n end\n end\n end\n end",
"def file_ids_hash\n if @file_ids_hash.blank?\n # load the file sha's from cache if possible\n cache_file = File.join(self.path,'.loopoff')\n if File.exists?(cache_file)\n @file_ids_hash = YAML.load(File.read(cache_file))\n else\n # build it\n @file_ids_hash = {}\n self.loopoff_file_names.each do |f|\n @file_ids_hash[File.basename(f)] = Grit::GitRuby::Internal::LooseStorage.calculate_sha(File.read(f),'blob')\n end\n # write the cache\n File.open(cache_file,'w') do |f|\n f.puts YAML.dump(@file_ids_hash) \n end\n end \n end\n @file_ids_hash\n end",
"def cache_item(file_parsed, _objects_db = nil, custom_cache_key = nil)\n _cache_key = custom_cache_key || cache_key\n objects_db = _objects_db || @current_site.get_meta(_cache_key, {}) || {}\n prefix = File.dirname(file_parsed['key'])\n\n s = prefix.split('/').clean_empty\n return file_parsed if s.last == 'thumb'\n s.each_with_index{|_s, i| k = \"/#{File.join(s.slice(0, i), _s)}\".cama_fix_slash; cache_item(file_parse(k), objects_db) unless objects_db[k].present? } unless ['/', '', '.'].include?(prefix)\n\n objects_db[prefix] = {files: {}, folders: {}} if objects_db[prefix].nil?\n if file_parsed['format'] == 'folder'\n objects_db[prefix][:folders][file_parsed['name']] = file_parsed\n else\n objects_db[prefix][:files][file_parsed['name']] = file_parsed\n end\n @current_site.set_meta(_cache_key, objects_db) if _objects_db.nil?\n file_parsed\n end",
"def get_important_files dir\n # checks various lists like visited_files and bookmarks\n # to see if files from this dir or below are in it.\n # More to be used in a dir with few files.\n list = []\n l = dir.size + 1\n\n # 2019-03-23 - i think we are getting the basename of the file\n # if it is present in the given directory XXX\n @visited_files.each do |e|\n list << e[l..-1] if e.index(dir) == 0\n end\n list = get_recent(list)\n\n # bookmarks if it starts with this directory then add it\n # FIXME it puts same directory cetus into the list with full path\n # We need to remove the base until this dir. get relative part\n list1 = @bookmarks.values.select do |e|\n e.index(dir) == 0 && e != dir\n end\n\n list.concat list1\n list\nend",
"def initialize(directory, &block)\n @force_recompute = false\n @computation = block\n @directory = find_directory(Dir.pwd, directory)\n if @directory\n class <<self; alias [] :cached_computation; end\n else\n class <<self; alias [] :uncached_computation; end\n $stderr.puts(\"#{$0}: Could not find cache directory: #{directory}.\")\n end\n end",
"def tree_map_for(ref, ignore_page_file_dir = false)\n if ignore_page_file_dir && !@page_file_dir.nil?\n @root_access ||= GitAccess.new(path, nil, @repo_is_bare)\n @root_access.tree(ref)\n else\n @access.tree(ref)\n end\n rescue Gollum::Git::NoSuchShaFound\n []\n end",
"def walk\n FileTreeProfiler.monitor_report(:profile, :dir, path)\n @children = []\n Dir.foreach(path) do |entry|\n next if (entry == '..' || entry == '.')\n full_path = ::File.join(path, entry)\n if ::File.directory?(full_path)\n children.push DirFile.new(self, entry)\n else\n children.push DataFile.new(self, entry)\n end\n end\n end",
"def build_hash(files, root)\n tree = {}\n files.each do |path|\n build_tree(tree, path.split(File::SEPARATOR), root)\n end\n tree\n end",
"def fetch\n position, last_dirname = nil, nil\n\n Dir.glob(File.join(self.root_dir, '**/*')).sort.each do |filepath|\n next unless File.directory?(filepath) || filepath =~ /\\.(#{Locomotive::Mounter::TEMPLATE_EXTENSIONS.join('|')})$/\n\n if last_dirname != File.dirname(filepath)\n position, last_dirname = 100, File.dirname(filepath)\n end\n\n page = self.add(filepath, position: position)\n\n next if File.directory?(filepath) || page.nil?\n\n if locale = self.filepath_locale(filepath)\n Locomotive::Mounter.with_locale(locale) do\n self.set_attributes_from_header(page, filepath)\n end\n else\n Locomotive::Mounter.logger.warn \"Unknown locale in the '#{File.basename(filepath)}' file.\"\n end\n\n position += 1\n end\n end",
"def data_cache(fpath)\n (@data_caches ||= []) << fpath\n return fpath\n end",
"def build\n Dir.chdir(@directory) do\n\n Dir['**/*'].reduce({}) do |result, f|\n if File.file?(f) && is_erb?(f)\n\n node = build_node(f)\n cat = node[:category]\n result[cat] = (result[cat] || []).push(node)\n result\n\n else\n\n result\n\n end\n end\n\n end\n end",
"def each_file_in_tree\n self.directories_in_tree.find_each do |directory|\n next if directory.nil?\n directory.cfs_files.find_each do |cfs_file|\n next if cfs_file.nil?\n\n yield cfs_file if block_given?\n end\n end\n end",
"def sub_tree\n files = ProjectFile.where(directory_id: id)\n files = files.nil? ? [] : files \n\n files.sort{|x,y| \n if x.is_directory and not y.is_directory\n -1\n elsif not x.is_directory and y.is_directory\n 1\n else\n x.name <=> y.name\n end\n }\n end",
"def rebuild\n [\"jpeg\", \"jpg\", \"png\", \"gif\"].each do |type|\n p = \"#{@root}#{@ds}**#{@ds}*.#{type}\"\n Dir[p].each do |path|\n @cached_list[path.split(@ds).last] ||= path\n end\n end\n @cached_list\n end",
"def contents_hash(paths)\n return if paths.nil?\n\n paths = paths.compact.select { |path| File.file?(path) }\n return if paths.empty?\n # rubocop:disable GitHub/InsecureHashAlgorithm\n paths.sort\n .reduce(Digest::XXHash64.new, :file)\n .digest\n .to_s(16) # convert to hex\n # rubocop:enable GitHub/InsecureHashAlgorithm\n end",
"def read_content(entry)\n entry.rewind if entry.respond_to? :rewind\n case entry\n when File, Tempfile, StringIO then entry.read\n when Dir then (entry.entries - ['.', '..']).collect { |filename| read_content(Pathname.new(File.join(entry.path, filename))) }.compact.sort\n when String then entry\n when Pathname then\n if entry.directory?\n read_content(entry)\n elsif entry.file?\n File.open(entry, 'r:binary').read\n end\n end\nend",
"def get_all_file_data(revision, assignment, path)\n full_path = File.join(assignment.repository_folder, path)\n return [] unless revision.path_exists?(full_path)\n\n files = revision.files_at_path(full_path)\n entries = get_files_info(files, assignment.id, revision.revision_identifier, path)\n\n entries.each do |data|\n data[:key] = path.blank? ? data[:raw_name] : File.join(path, data[:raw_name])\n data[:modified] = data[:last_revised_date]\n data[:size] = 1 # Dummy value\n end\n\n revision.directories_at_path(full_path).each do |directory_name, _|\n entries.concat(get_all_file_data(\n revision,\n path.blank? ? directory_name : File.join(path, directory_name)\n ))\n end\n\n entries\n end",
"def file_get_files(directories) \n directory = \"\"\n files = []\n directories.each do |directory| \n unless directory == \"/root\"\n Dir.chdir(\"#{directory}\") \n Dir.foreach(\"#{directory}\") do |d| \n files.push(d) unless d == \".\" || d == \"..\" \n end\n @file_information.store(directory, files)\n files = []\n end\n end\n return @file_information\n end",
"def cache_path\n return @cache_resources unless @cache_resources.nil?\n\n @cache_resources = Chef::Resource::Directory.new(::File.join(new_resource.cache_path), run_context)\n @cache_resources.recursive(true)\n\n return @cache_resources\n end",
"def recurse\n children = (self[:recurse] == :remote) ? {} : recurse_local\n\n if self[:target]\n recurse_link(children)\n elsif self[:source]\n recurse_remote(children)\n end\n\n # If we're purging resources, then delete any resource that isn't on the\n # remote system.\n mark_children_for_purging(children) if self.purge?\n\n # REVISIT: sort_by is more efficient?\n result = children.values.sort { |a, b| a[:path] <=> b[:path] }\n remove_less_specific_files(result)\n end",
"def cache(content, options={})\n return content unless Sinatra.options.cache_enabled\n \n unless content.nil?\n path = cache_page_path(request.path_info)\n FileUtils.makedirs(File.dirname(path))\n open(path, 'wb+') { |f| f << content } \n content\n end\n end",
"def children\n files = if index?\n # about/index.html => about/*\n File.expand_path('../*', @file)\n else\n # products.html => products/*\n base = File.basename(@file, '.*')\n File.expand_path(\"../#{base}/*\", @file)\n end\n\n Set.new Dir[files].\n reject { |f| f == @file || project.ignored_files.include?(f) }.\n map { |f| self.class[f, project] }.\n compact.sort\n end",
"def cnewer path\n time = File.stat(path).ctime\n @files = @files.select { |file| File.stat(file).ctime > time}\n self\n end",
"def contents(path)\n puts \"#contents(#{path})\" if DEBUG\n results = []\n root_path = zk_path(path)\n zk.find(root_path) do |z_path|\n if (z_path != root_path)\n z_basename = z_path.split('/').last\n stats = zk.stat(z_path)\n results << \"#{z_basename}\" if stats.numChildren > 0\n results << \"#{z_basename}.contents\" if zk.stat(z_path).dataLength > 0\n ZK::Find.prune\n end\n end\n results\n end",
"def cache_history\n x = HistoryOldestDayData.fetch; nil\n data = x.as_json; nil\n\n tod_ay = DateTime.now.strftime(\"%Y-%m-%d\")\n json_file = DateTime.now.strftime(\"%Y-%m-%d\") + \".json\"\n nd = NDJSON::Generator.new json_file\n # write each package's data to disk\n # - before writing, remove auto-generated id column\n data.each do |x|; nil\n nd.write(x.except(\"id\")); nil\n end; nil\n\n # compress json file\n compress_file(json_file)\n json_file_gz = json_file + \".gz\"\n\n # upload\n # - set content-type: application/json\n # - set content-encoding: gzip\n obj = $s3_x.bucket(\"cchecks-history\").object(json_file_gz)\n obj.upload_file(json_file_gz,\n :content_type => \"application/json\",\n :content_encoding => \"gzip\")\n\n # delete ndjson file on disk\n File.delete(json_file)\n File.delete(json_file_gz)\nend",
"def hash_from_git(tree)\n ({}).tap do |objs|\n tree.each do |b|\n objs[b.name] = (\n case b\n when Grit::Tree\n hash_from_git(b.contents)\n when Grit::Blob\n b.data\n end\n )\n end\n end\n end",
"def generate_with_cache(checksums)\n changed_files = []\n Registry.checksums.each do |file, hash|\n changed_files << file if checksums[file] != hash\n end\n Registry.load_all\n all_objects.each do |object|\n if object.files.any? {|f, line| changed_files.include?(f) }\n log.info \"Re-generating object #{object.path}...\"\n opts = options.merge(:object => object, :type => :layout)\n Templates::Engine.render(opts)\n end\n end\n end",
"def file_hashes\n @file_hashes ||= file_field_sets.map do |file_field_set|\n instantiation_fields, file_fields = file_field_set.partition do |field|\n instantiation_header?(field.header)\n end\n\n file_hash = fields_to_hash(file_fields)\n file_hash['files'] = [fields_to_hash(instantiation_fields)]\n\n file_hash\n end\n end",
"def files(id=nil, &block)\n return @ruhoh.cache.get(files_cache_key) if @ruhoh.cache.get(files_cache_key)\n\n dict = _all_files\n dict.keep_if do |id, pointer|\n block_given? ? yield(id, self) : valid_file?(id)\n end\n\n @ruhoh.cache.set(files_cache_key, dict)\n dict\n end",
"def dirHash(directory, regexp)\n directory = Pathname.new(directory)\n contents = \"\"\n Dir.foreach(directory) {\n | entry |\n if entry =~ regexp\n contents += IO::read(directory + entry)\n end\n }\n return Digest::SHA1.hexdigest(contents)\nend",
"def get_cache(key)\n treecache.fetch(key)\n end",
"def cache_directory\n File.join(CacheFolder, make_md5(@source))\n end",
"def hash\n return (path + file_id.to_s).hash\n end",
"def files_hash\n @files_hash\n end",
"def contents(id = '')\n folder = id.empty? ? box_client.root_folder : box_client.folder_by_id(id)\n values = []\n\n folder.items(ITEM_LIMIT, 0, %w[name size created_at]).collect do |f|\n values << directory_entry(f)\n end\n @entries = values.compact\n\n @sorter.call(@entries)\n end",
"def cache_files\n Dir.glob(File.join(@cache_dir, '*'))\n .map{|f| f.gsub(/#{@cache_dir}\\/?/, '')}\n .sort\n end",
"def get_files_by_mtime dir='*'\n gfb dir, :mtime\nend",
"def load_breadcrumbs\n @crumbs = {}\n\n loaded_file_mtimes.clear\n breadcrumb_files.each do |file|\n instance_eval open(file).read, file\n loaded_file_mtimes << File.mtime(file)\n end\n\n @loaded = true\n end",
"def children\n return @children unless @children.nil?\n @children = if exists? && directory?\n Dir.glob( File.join(absolute_path,'*') ).sort.map do |entry|\n git_flow_repo.working_file(\n entry.gsub( /^#{Regexp.escape absolute_path}/, tree )\n )\n end\n else\n false\n end\n end",
"def sha1_hash_directory_tree(directory, prefix='', hash={})\n Dir.entries(directory).each do |file|\n next if file =~ /^\\./\n pathname = File.join(directory,file)\n if File.directory?(pathname)\n sha1_hash_directory_tree(pathname, File.join(prefix,file), hash)\n else\n hash[File.join(prefix,file)] = Digest::SHA1.hexdigest(File.read(pathname))\n end\n end\n \n hash\n end",
"def buildArray(localObjCache, increase)\n localDirContents=[] #Array of all items in the cwd\n localDirContents=Dir[Dir.pwd+\"/*\"] #Builds the array of items in cwd\n\n localDirContents.each do |item|\n if File.file?(item)\n fileObj = FileName.new(item)\n localObjCache.push(fileObj)\n n = increase.call #printing every 100 files scanned\n if n % 100 == 0\n puts n\n end\n elsif File.directory?(item)\n Dir.chdir(item)\n buildArray(localObjCache, increase) \n end\n end\n\n return localObjCache\n end",
"def hash \n @hash ||= CobraVsMongoose.xml_to_hash(file_content)\n end",
"def generate_recurse(entry)\n keyword = entry.full_name\n\n if keyword\n puts keyword\n @current_content = service.info(keyword) #lookup(keyword)\n else\n keyword = ''\n @current_content = \"Welcome\"\n end\n\n file = entry.file_name\n file = File.join(output, file)\n\n #file = keyword\n #file = file.gsub('::', '--')\n #file = file.gsub('.' , '--')\n #file = file.gsub('#' , '-')\n #file = File.join(output, file + '.html')\n\n write(file, service.info(keyword))\n\n cmethods = entry.class_methods.map{ |x| x.to_s }.sort\n cmethods.each do |name|\n mname = \"#{entry.full_name}.#{name}\"\n mfile = WebRI.entry_to_path(mname)\n mfile = File.join(output, mfile)\n #mfile = File.join(output, \"#{entry.file_name}/c-#{esc(name)}.html\")\n write(mfile, service.info(mname))\n end\n\n imethods = entry.instance_methods.map{ |x| x.to_s }.sort\n imethods.each do |name|\n mname = \"#{entry.full_name}##{name}\"\n mfile = WebRI.entry_to_path(mname)\n mfile = File.join(output, mfile)\n #mfile = File.join(output, \"#{entry.file_name}/i-#{esc(name)}.html\")\n write(mfile, service.info(mname))\n end\n\n entry.subspaces.each do |child_name, child_entry|\n next if child_entry == entry\n @directory_depth += 1\n generate_recurse(child_entry)\n @directory_depth -= 1\n end\n end",
"def folder_tree\n parent_folder_id =\n unsafe_params[:parent_folder_id] == \"\" ? nil : unsafe_params[:parent_folder_id].to_i\n scoped_parent_folder_id =\n unsafe_params[:scoped_parent_folder_id] == \"\" ? nil : unsafe_params[:scoped_parent_folder_id].to_i\n\n if unsafe_params[:scopes].present?\n check_scope!\n # exclude 'public' scope\n if unsafe_params[:scopes].first =~ /^space-(\\d+)$/\n spaces_members_ids = Space.spaces_members_ids(unsafe_params[:scopes])\n spaces_params = {\n context: @context,\n spaces_members_ids: spaces_members_ids,\n scopes: unsafe_params[:scopes],\n scoped_parent_folder_id: scoped_parent_folder_id,\n }\n files = UserFile.batch_space_files(spaces_params)\n folders = Folder.batch_space_folders(spaces_params)\n else\n files = UserFile.batch_private_files(@context, [\"private\", nil], parent_folder_id)\n folders = Folder.batch_private_folders(@context, parent_folder_id)\n end\n end\n\n folder_tree = []\n Node.folder_content(files, folders).each do |item|\n folder_tree << {\n id: item[:id],\n name: item[:name],\n type: item[:sti_type],\n uid: item[:uid],\n scope: item[:scope],\n }\n end\n\n render json: folder_tree\n end",
"def contents(path = '')\n path = File.join(path, '') unless path.empty?\n @entries = []\n\n generate_listing(path)\n @sorter.call(@entries)\n end",
"def /(file)\n Tree.content_by_path(repo, id, file, commit_id, path)\n end",
"def disk_hash_tree\n tree_size = SpStore::Merkle::HashTreeHelper.full_tree_node_count @blocks\n node_hashes = Array.new(tree_size+1)\n File.open(disk_hash_file, 'rb') do |file|\n file.seek(hash_byte_size, IO::SEEK_SET)\n (1..tree_size).each do |idx|\n node_hashes[idx] = file.read(hash_byte_size)\n end\n end\n node_hashes\n end",
"def load_cache_for(klassname)\n path = cache_file_for klassname\n\n cache = nil\n\n if File.exist? path and\n File.mtime(path) >= File.mtime(class_cache_file_path) and\n @use_cache then\n open path, 'rb' do |fp|\n begin\n cache = Marshal.load fp.read\n rescue\n #\n # The cache somehow is bad. Recreate the cache.\n #\n $stderr.puts \"Error reading the cache for #{klassname}; recreating the cache!\"\n cache = create_cache_for klassname, path\n end\n end\n else\n cache = create_cache_for klassname, path\n end\n\n cache\n end",
"def get_entries(dir, subfolder); end",
"def load_all\n load_cache\n\n module_names.each do |module_name|\n mod = find_class_or_module(module_name) || load_class(module_name)\n\n # load method documentation since the loaded class/module does not have\n # it\n loaded_methods = mod.method_list.map do |method|\n load_method module_name, method.full_name\n end\n\n mod.method_list.replace loaded_methods\n\n loaded_attributes = mod.attributes.map do |attribute|\n load_method module_name, attribute.full_name\n end\n\n mod.attributes.replace loaded_attributes\n end\n\n all_classes_and_modules.each do |mod|\n descendent_re = /^#{mod.full_name}::[^:]+$/\n\n module_names.each do |name|\n next unless name =~ descendent_re\n\n descendent = find_class_or_module name\n\n case descendent\n when RDoc::NormalClass then\n mod.classes_hash[name] = descendent\n when RDoc::NormalModule then\n mod.modules_hash[name] = descendent\n end\n end\n end\n\n @cache[:pages].each do |page_name|\n page = load_page page_name\n @files_hash[page_name] = page\n @text_files_hash[page_name] = page if page.text?\n end\n end"
] | [
"0.6532654",
"0.62289214",
"0.6088277",
"0.58565265",
"0.5744223",
"0.5535684",
"0.5490923",
"0.5486155",
"0.5483177",
"0.545822",
"0.5385174",
"0.5376981",
"0.53395647",
"0.5328105",
"0.5323563",
"0.529577",
"0.5282739",
"0.5270191",
"0.5257498",
"0.5239051",
"0.52177536",
"0.5212734",
"0.5191084",
"0.51883584",
"0.5175468",
"0.5132157",
"0.51130295",
"0.5103825",
"0.51029694",
"0.5101793",
"0.5085016",
"0.50806814",
"0.5078684",
"0.507693",
"0.5072918",
"0.5042935",
"0.5021847",
"0.49961945",
"0.4991193",
"0.49601284",
"0.4948476",
"0.49305865",
"0.4902534",
"0.4895462",
"0.4893358",
"0.4862477",
"0.48567876",
"0.48559684",
"0.48494223",
"0.4830566",
"0.48248476",
"0.4807629",
"0.4806022",
"0.4804193",
"0.47795913",
"0.4774906",
"0.47708926",
"0.4743033",
"0.4742841",
"0.47416273",
"0.4740414",
"0.47370946",
"0.47312224",
"0.47285163",
"0.47268337",
"0.47208372",
"0.47116596",
"0.47083127",
"0.4700185",
"0.46993583",
"0.46979052",
"0.46919623",
"0.4689472",
"0.46719417",
"0.46694928",
"0.46646392",
"0.46583563",
"0.46578068",
"0.46517524",
"0.46449846",
"0.46415326",
"0.4632031",
"0.46202806",
"0.46188423",
"0.46120554",
"0.46120542",
"0.46095464",
"0.46018428",
"0.4596804",
"0.4593526",
"0.45871803",
"0.45835853",
"0.45803502",
"0.45797333",
"0.45776063",
"0.45772704",
"0.45755318",
"0.4566926",
"0.4562336",
"0.45618892"
] | 0.7902518 | 0 |
N Without this we wouldn't be able to create the remote content location object with readonly attributes | def initialize(contentHost, baseDir, cachedContentFile = nil)
# Without super, we won't remember the cached content file (if specified)
super(cachedContentFile)
# Without this we won't remember which remote server to connect to
@contentHost = contentHost
# Without this we won't remember which directoy on the remote server to sync to.
@baseDir = normalisedDir(baseDir)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def location= attrs\n self.location_attributes= attrs\n end",
"def store_location!; end",
"def full_location; end",
"def set_object_origin(content, value)\n content.ox = value\n end",
"def set_object_origin(content, value)\n content.oy = value\n end",
"def location\n attributes.fetch(:location)\n end",
"def location=(loc)\n @location.contents.delete self if @location\n @location = loc\n @location.contents << self if @location\n end",
"def location=(_arg0); end",
"def initialize location=nil\n @location = location\n end",
"def location\n @location\n end",
"def location\n raise NotImplementedError, 'Abstract method, please define `location` in subclass.'\n end",
"def location\n\t\t@location\n\tend",
"def location_insert\n true\n end",
"def resourceType\n 'Location'\n end",
"def generate_new_location_uri\n raise NotImplementedError\n end",
"def use_location_in_checksum\n @attributes[:use_location_in_checksum]\n end",
"def get_location\n\n end",
"def location\n @location\n end",
"def local_address\n super\n end",
"def residential_proxy?; end",
"def residential_proxy?; end",
"def locations\n # blank\n end",
"def create_content_proxy_for(content_descr)\n path = _get_path(content_descr)\n # TODO: Make sure that key is really unique across multiple repositories - why?\n descr = descr ? descr.dup : {}\n url = get_url_for_path(path)\n descr[:url] = url\n descr[:path] = path\n descr[:name] = url # Should be something human digestable\n if (descr[:strictly_new])\n return nil if exist?(path)\n end\n proxy = ContentProxy.create(descr, self)\n return proxy\n end",
"def locations; end",
"def location\n return nil if reference?\n ensure_full_data!\n @gapi_json[:location]\n end",
"def remote_address\n super\n end",
"def api_location\n nil\n end",
"def location_description\n LOCATION_DESCRIPTION\n end",
"def location\n\t\tStructureLocation.new(@db, @id)\n\tend",
"def location\n @location\n end",
"def location\n @location\n end",
"def locationNull \n \"locationNull\" \n end",
"def location\n fetch('hey_arnold.locations')\n end",
"def loc; end",
"def loc; end",
"def loc; end",
"def location(value)\n @ole.Location = value\n nil\n end",
"def origin; end",
"def origin; end",
"def origin; end",
"def locations\n raise NotImplementedError.new(\"Classes including the Api module must provide a locations hash\")\n end",
"def location\n @client.get(\"#{path}/location\")\n end",
"def locations\n self[:locations] ||= default_locations\n end",
"def location=(location)\n @attributes[\"location\"] = location\n end",
"def original_address\n super\n end",
"def set_remote_locations(locations:)\n {\n method: \"Target.setRemoteLocations\",\n params: { locations: locations }.compact\n }\n end",
"def access_info\n super\n end",
"def set_location\n location = flickr.places.findByLatLon(lat: lat, lon: lon)\n location.size >= 1 ? @location = location.first['name'] : @location = \"Unidentifiable location\"\n end",
"def location=(location)\n self.java_element.location = location\n end",
"def test_putpoi_invalid_latlon\n nd = create(:node)\n cs_id = nd.changeset.id\n user = nd.changeset.user\n\n amf_content \"putpoi\", \"/1\", [\"#{user.email}:test\", cs_id, nd.version, nd.id, 200, 100, nd.tags, true]\n post :amf_write\n assert_response :success\n amf_parse_response\n result = amf_result(\"/1\")\n\n assert_equal 2, result.size\n assert_equal -2, result[0]\n assert_match /Node is not in the world/, result[1]\n end",
"def public_proxy?; end",
"def public_proxy?; end",
"def save_location\n location.attachable = self\n location.save!\n end",
"def create_location response\n GeoMagic::Location.new response.parsed_response\n end",
"def set_location\n # byebug\n @location = Location.find(params[:id])\n end",
"def location\n wrap.location\n end",
"def explicit_location?\n true\n end",
"def explicit_location?\n true\n end",
"def location (location)\n self.class.new(@path += \"location=#{location}&\")\n end",
"def address\n self.location.address\n end",
"def location=(data)\n if self.location.present? && !data.is_a?(Hash)\n self.location.destroy\n end\n \n if data.is_a?(Hash)\n if self.location.present?\n self.location.attributes = data\n else\n super(Location.new data)\n end\n else\n super(data)\n end\n end",
"def editable_locations\n if is_super_admin?\n Location.by_name\n elsif self.region\n res = []\n region.locations.each do |lok|\n res += [lok] + lok.locations\n end\n res\n elsif self.location\n [location] + self.location.locations\n else\n []\n end\n end",
"def location; end",
"def location; end",
"def location; end",
"def location; end",
"def location; end",
"def location; end",
"def location; end",
"def location; end",
"def location; end",
"def location; end",
"def location; end",
"def location; end",
"def location; end",
"def location; end",
"def location; end",
"def location; end",
"def location; end",
"def location; end",
"def location; end",
"def location; end",
"def location; end",
"def location; end",
"def location; end",
"def location; end",
"def location; end",
"def location; end",
"def location; end",
"def location; end",
"def location; end",
"def location; end",
"def location; end",
"def location; end",
"def location; end",
"def location; end",
"def location; end",
"def location; end",
"def location; end",
"def location; end",
"def location; end"
] | [
"0.58561534",
"0.5666641",
"0.55912244",
"0.5535023",
"0.5524067",
"0.5522559",
"0.54908633",
"0.5467026",
"0.54587656",
"0.54461074",
"0.54368997",
"0.5426398",
"0.5370556",
"0.5369927",
"0.5359258",
"0.5343393",
"0.5340842",
"0.53316486",
"0.5327592",
"0.5317931",
"0.5317931",
"0.5279769",
"0.5277921",
"0.5252251",
"0.52457494",
"0.5220623",
"0.52141184",
"0.5211845",
"0.5207344",
"0.51950604",
"0.51950604",
"0.5180921",
"0.51728326",
"0.5151252",
"0.5151252",
"0.5151252",
"0.5150992",
"0.5149724",
"0.5149724",
"0.5149724",
"0.51385677",
"0.5137353",
"0.5128097",
"0.51265454",
"0.51252556",
"0.51072615",
"0.51042014",
"0.50872546",
"0.50821364",
"0.5080318",
"0.5075611",
"0.5075611",
"0.5071668",
"0.50583947",
"0.5057378",
"0.50521004",
"0.50379974",
"0.50379974",
"0.5034897",
"0.5031076",
"0.50253195",
"0.5024852",
"0.50230914",
"0.50230914",
"0.50230914",
"0.50230914",
"0.50230914",
"0.50230914",
"0.50230914",
"0.50230914",
"0.50230914",
"0.50230914",
"0.50230914",
"0.50230914",
"0.50230914",
"0.50230914",
"0.50230914",
"0.50230914",
"0.50230914",
"0.50230914",
"0.50230914",
"0.50230914",
"0.50230914",
"0.50230914",
"0.50230914",
"0.50230914",
"0.50230914",
"0.50230914",
"0.50230914",
"0.50230914",
"0.50230914",
"0.50230914",
"0.50230914",
"0.50230914",
"0.50230914",
"0.50230914",
"0.50230914",
"0.50230914",
"0.50230914",
"0.50230914",
"0.50230914"
] | 0.0 | -1 |
N Without this we won't have any way to close cached open connections (and they will leak) | def closeConnections
#N Without this the cached connections won't get closed
@contentHost.closeConnections()
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close\n # by default do nothing - close any cached connections\n end",
"def close_expired_connections\n raise NotImplementedError\n end",
"def connection_pool_maximum_reuse\n super\n end",
"def empty_connection_pools!; end",
"def close_connection; end",
"def connection_closed\n end",
"def close_connections\n @connections.values.each(&:close)\n end",
"def close\n inactive!\n close_connections\n end",
"def __close_connections\n # to be implemented by specific transports\n end",
"def reexecute_connections?\n return true\n end",
"def clear_reloadable_connections!\n @reserved_connections.each do |name, conn|\n checkin conn\n end\n @reserved_connections = {}\n @connections.each do |conn|\n conn.disconnect! if conn.requires_reloading?\n end\n @connections = []\n end",
"def without_reconnect(&block); end",
"def closeConnections()\n #N Without this, the connections won't be closed\n @sshAndScp.close()\n end",
"def close_connections\n @connections ||= {}\n @connections.values.each do |connection|\n begin\n connection.disconnect!\n rescue\n end\n end\n\n @connections = {}\n end",
"def dispose\n return if @connection_pool.nil?\n\n until @connection_pool.empty?\n conn = @connection_pool.pop(true)\n conn&.close\n end\n\n @connection_pool = nil\n end",
"def close_all\n @connections.close_all\n end",
"def close_client_connections\n @pending_data.each_key(&:close)\n @pending_data.clear\n end",
"def close_expired_connections\n # By default the keep alive timeout is 15 sec, which is the HTTP 1.1\n # standard. To change the value, use keep_alive_timeout= method\n # do nothing, handled by HTTPClient\n end",
"def close_expired_connections\n # By default the keep alive timeout is 15 sec, which is the HTTP 1.1\n # standard. To change the value, use keep_alive_timeout= method\n # do nothing, handled by HTTPClient\n end",
"def reap\n stale_connections = @connections.select do |conn|\n conn.in_use? && !conn.owner.alive?\n end\n\n stale_connections.each do |conn|\n if conn.active?\n conn.reset!\n checkin conn\n else\n remove conn\n end\n end\n end",
"def close\n @conn.close\n super\n end",
"def prefork_action! # TODO : refactor\n ActiveRecord::Base.clear_all_connections! rescue nil\n end",
"def reap\n stale_connections = synchronize do\n @connections.select do |conn|\n conn.in_use? && !conn.owner.alive?\n end\n end\n\n stale_connections.each do |conn|\n synchronize do\n if conn.active?\n conn.reset!\n checkin conn\n else\n remove conn\n end\n end\n end\n end",
"def test_double_close()\n rdht = Scalaroid::ReplicatedDHT.new()\n rdht.close_connection()\n rdht.close_connection()\n end",
"def resurrect_dead_connections!\n connections.dead.each { |c| c.resurrect! }\n end",
"def close_conn(spec, h_conn, for_real = false)\n case @handling_mode\n when :cache\n # do nothing i think?\n when :pool\n # return the conn back to the pool\n else\n nil\n end\n end",
"def disconnect!\n clear_cache!(new_connection: true)\n reset_transaction\n @raw_connection_dirty = false\n end",
"def clear_active_connections!\n self.ensure_ready\n self.connection_pool_list.each(&:release_connection)\n end",
"def close\n return if @conn.nil?\n @conn.close\n @conn = nil\n end",
"def close\n pool.checkin self\n end",
"def close\n pool.checkin self\n end",
"def release()\n fiber = Fiber.current\n if fiber[connection_pool_key]\n @busy_connections.delete(fiber)\n @connections << fiber[connection_pool_key]\n fiber[connection_pool_key] = nil\n end\n end",
"def new_connection; end",
"def clear_reloadable_connections!\n @reserved_connections.clear\n @connections.each do |conn|\n checkin conn\n conn.disconnect! if conn.requires_reloading?\n end\n @connections.delete_if do |conn|\n conn.requires_reloading?\n end\n @available.clear\n @connections.each do |conn|\n @available.add conn\n end\n end",
"def clear_reloadable_connections!\n self.ensure_ready\n self.connection_pool_list.each(&:clear_reloadable_connections!)\n end",
"def connection_closed\n close\n end",
"def disconnect!() @connections.each_value(&:disconnect) end",
"def steal! # :nodoc:\n if in_use?\n if @owner != Thread.current\n pool.send :remove_connection_from_thread_cache, self, @owner\n\n @owner = Thread.current\n end\n else\n raise ActiveRecordError, \"Cannot steal connection, it is not currently leased.\"\n end\n end",
"def closeConnections\n #N Without this, cached SSH connections to the remote system won't get closed\n destinationLocation.closeConnections()\n end",
"def release\n chk_conn\n @connected = false\n @db.release(self)\n end",
"def close\n @mutex.synchronize { @conn.close }\n end",
"def close\n @mutex.synchronize { @conn.close }\n end",
"def close\n connection.close if connection\n end",
"def clear_reloadable_connections!\n synchronize do\n @reserved_connections.clear\n @connections.each do |conn|\n checkin conn\n conn.disconnect! if conn.requires_reloading?\n end\n @connections.delete_if do |conn|\n conn.requires_reloading?\n end\n @available.clear\n @connections.each do |conn|\n @available.add conn\n end\n end\n end",
"def clear_reloadable_connections!\n synchronize do\n @reserved_connections.clear\n @connections.each do |conn|\n checkin conn\n end\n\n @connections.delete_if(&:finished?)\n\n @available.clear\n @connections.each do |conn|\n @available.add conn\n end\n end\n end",
"def connection_stale!\n log(:debug, :socket, 'connection is stale.')\n close_connection\n end",
"def clear_reloadable_connections!\n if @@allow_concurrency\n # With concurrent connections @@active_connections is\n # a hash keyed by thread id.\n @@active_connections.each do |thread_id, conns|\n conns.each do |name, conn|\n if conn.requires_reloading?\n conn.disconnect!\n @@active_connections[thread_id].delete(name)\n end\n end\n end\n else\n @@active_connections.each do |name, conn|\n if conn.requires_reloading?\n conn.disconnect!\n @@active_connections.delete(name)\n end\n end\n end\n end",
"def check_out\n @mutex.synchronize do\n begin\n return new_client unless connection_pool_enabled?\n\n client = @connection_pool.pop(true)\n\n client.ping if @options[:reconnect]\n\n client\n rescue ThreadError\n if @created_connections < max_pool_size\n client = new_client\n @created_connections += 1\n return client\n end\n\n MysqlFramework.logger.error { \"[#{self.class}] - Database connection pool depleted.\" }\n\n raise 'Database connection pool depleted.'\n end\n end\n end",
"def disconnect!\n @reserved_connections.each do |name,conn|\n checkin conn\n end\n @reserved_connections = {}\n @connections.each do |conn|\n conn.disconnect!\n end\n @connections = []\n end",
"def close\n #active record should do our connections for us so just set to nil\n @connection = nil\n # Remove this connection from the list of open connections.\n #@@open_connection = @@open_connections.reject { |c| c[:db_url] == @db_url }\n Log.instance.debug \"Disconnected from #@db_url\"\n end",
"def close\n @mutex.lock do\n unless @connection_pool.nil? or @connection_pool.is_closed\n @connection_pool.close\n @connection_pool = nil\n end\n end\n end",
"def close\n\t\[email protected]\n\tend",
"def close\n if self.conn && !self.conn.closed?\n self.conn.shutdown\n self.conn.close\n end\n\n self.conn = nil\n end",
"def connection\n begin\n @connections.hold { |dbh| yield(dbh) }\n rescue Mysql::Error => me\n \n @configuration.log.fatal(me)\n \n @connections.available_connections.each do |sock|\n begin\n sock.close\n rescue => se\n @configuration.log.error(se)\n end\n end\n \n @connections.available_connections.clear\n raise me\n end\n end",
"def set_keep_alive; end",
"def steal! # :nodoc:\n if in_use?\n if @owner != ActiveSupport::IsolatedExecutionState.context\n pool.send :remove_connection_from_thread_cache, self, @owner\n\n @owner = ActiveSupport::IsolatedExecutionState.context\n end\n else\n raise ActiveRecordError, \"Cannot steal connection, it is not currently leased.\"\n end\n end",
"def cleanup_connections\n @connections.keep_if do |thread, conns|\n thread.alive?\n end\n end",
"def reconnect!\n clear_cache!\n reset_transaction\n end",
"def before_fork\n return unless (defined? ::DataObjects::Pooling)\n return if ::DataMapper.repository.adapter.to_s =~ /Sqlite3Adapter/\n ::DataMapper.logger.debug \"+-+-+-+-+ Cleaning up connection pool (#{::DataObjects::Pooling.pools.length}) +-+-+-+-+\"\n ::DataObjects::Pooling.pools.each {|p| p.dispose} \n end",
"def redis_pool; end",
"def disconnect_all\n @cache.values.map(&:clear_all_connections!)\n end",
"def disconnect!\n clear_cache!\n reset_transaction\n end",
"def dispose; end",
"def close\n @connection_manager.close\n end",
"def realize_pending_connections! #:nodoc:\n return unless concurrent_connections\n\n server_list.each do |server|\n server.close if !server.busy?(true)\n server.update_session!\n end\n\n @connect_threads.delete_if { |t| !t.alive? }\n\n count = concurrent_connections ? (concurrent_connections - open_connections) : @pending_sessions.length\n count.times do\n session = @pending_sessions.pop or break\n # Increment the open_connections count here to prevent\n # creation of connection thread again before that is\n # incremented by the thread.\n @session_mutex.synchronize { @open_connections += 1 }\n @connect_threads << Thread.new do\n session.replace_with(next_session(session.server, true))\n end\n end\n end",
"def disconnect; @connection.close end",
"def close() end",
"def close() end",
"def close() end",
"def close() end",
"def pool\n pool_connection = ConnectionPool.new(size: 10, timeout: 5) do \n Redis.new :db=> redis_db_index, :password=> redis_instance.password, :host=> redis_instance.host, :port=> redis_instance.port\n end \n return pool_connection \n end",
"def close() end",
"def reuse_connection\n logger.debug(\"[Dokken] reusing existing connection #{@connection}\")\n yield @connection if block_given?\n @connection\n end",
"def close\n redis.disconnect!\n end",
"def db_cached_connect\n @dbh or db_connect\n end",
"def db_cached_connect\n @dbh or db_connect\n end",
"def testDoubleClose()\n rdht = Scalaris::ReplicatedDHT.new()\n rdht.close_connection()\n rdht.close_connection()\n end",
"def testDoubleClose()\n rdht = Scalaris::ReplicatedDHT.new()\n rdht.close_connection()\n rdht.close_connection()\n end",
"def clear_active_connections!\n clear_cache!(@@active_connections) do |name, conn|\n conn.disconnect!\n end\n end",
"def finalize\n @request_count = @orm_module::Request.count\n ActiveRecord::Base.remove_connection\n end",
"def postgres_keep_alive\n stat = @connection.status()\n rescue PGError => e\n @logger.info(\"Postgresql connection lost: #{e}\")\n @connection = postgres_connect\n if (stat = PGconn.CONNECTION_BAD) then\n @logger.info(\"Postgresql connection lost. Reconnect.\")\n @connection = postgres_connect\n end\n end",
"def set_connection_pool_maximum_reuse(opts)\n opts = check_params(opts,[:reuses])\n super(opts)\n end",
"def expire\n if in_use?\n if @owner != ActiveSupport::IsolatedExecutionState.context\n raise ActiveRecordError, \"Cannot expire connection, \" \\\n \"it is owned by a different thread: #{@owner}. \" \\\n \"Current thread: #{ActiveSupport::IsolatedExecutionState.context}.\"\n end\n\n @idle_since = Process.clock_gettime(Process::CLOCK_MONOTONIC)\n @owner = nil\n else\n raise ActiveRecordError, \"Cannot expire connection, it is not currently leased.\"\n end\n end",
"def close\n @connection.close\n end",
"def close\n @connection.close\n end",
"def keep_alive; end",
"def keep_alive; end",
"def unbind\n ActiveRecord::Base.logger.info \"-- Collector connection closed by a peer\"\n end",
"def clear_cache!(new_connection: false)\n if @statements\n @lock.synchronize do\n if new_connection\n @statements.reset\n else\n @statements.clear\n end\n end\n end\n end",
"def do_close; end",
"def uncached(&block)\n ActiveFedora.fedora.connection.uncached(&block)\n end",
"def release_connection\n conn = @reserved_connections.delete(current_connection_id)\n checkin conn if conn\n end",
"def close\n @pool.close\n end",
"def with_two_connections\n run_without_connection do |original_connection|\n ActiveRecord::Base.establish_connection(original_connection.merge(pool_size: 2))\n begin\n ddl_connection = ActiveRecord::Base.connection_pool.checkout\n begin\n yield original_connection, ddl_connection\n ensure\n ActiveRecord::Base.connection_pool.checkin ddl_connection\n end\n ensure\n ActiveRecord::Base.connection_handler.clear_all_connections!(:all)\n end\n end\n end",
"def close\n @conn.disconnect\n end",
"def evict\n # Peek at the first connection to see if it is still fresh. If so, we can\n # return right away without needing to use `synchronize`.\n first_expires_at, first_conn = connections.first\n return if (first_expires_at.nil? || fresh?(first_expires_at)) && !closed?(first_conn)\n\n connections.synchronize do\n fresh, stale = connections.partition do |expires_at, conn|\n fresh?(expires_at) && !closed?(conn)\n end\n connections.replace(fresh)\n stale.each { |_, conn| closer.call(conn) }\n end\n end",
"def turn_off\n MAX_CONNECTIONS.times do\n connections << Sequel.connect(DATABASE_URL)\n end\n rescue Sequel::DatabaseConnectionError\n end",
"def disconnect\n @conn.close\nend",
"def clear_all_connections!\n disconnect_read_pool!\n @original_handler.clear_all_connections!\n end",
"def finish\n release_read_pool_connection\n end"
] | [
"0.75031",
"0.7004418",
"0.6814353",
"0.6683453",
"0.6613164",
"0.655596",
"0.6445006",
"0.6427194",
"0.6392217",
"0.63802546",
"0.6344764",
"0.633376",
"0.6324023",
"0.6317249",
"0.63168055",
"0.630244",
"0.628612",
"0.6278678",
"0.6278678",
"0.6272998",
"0.62502193",
"0.6205359",
"0.6183369",
"0.61797184",
"0.6175642",
"0.6134668",
"0.6126154",
"0.6125672",
"0.61199725",
"0.610965",
"0.610965",
"0.6109115",
"0.610827",
"0.6099857",
"0.60978407",
"0.60869944",
"0.60798246",
"0.60742867",
"0.60734886",
"0.60559964",
"0.6050401",
"0.6050401",
"0.60381764",
"0.6026341",
"0.6023819",
"0.6015809",
"0.600127",
"0.6001222",
"0.59914386",
"0.5988322",
"0.59817463",
"0.59691787",
"0.5966153",
"0.5966008",
"0.5962039",
"0.5956956",
"0.59561414",
"0.5954068",
"0.5946701",
"0.59319556",
"0.59261096",
"0.5918649",
"0.5912876",
"0.59028614",
"0.58890796",
"0.5879521",
"0.5877795",
"0.5877795",
"0.5877795",
"0.5877795",
"0.58773214",
"0.58772194",
"0.58730006",
"0.58711153",
"0.5870812",
"0.5870812",
"0.58699566",
"0.58699566",
"0.5862375",
"0.5851888",
"0.5840921",
"0.5838402",
"0.58341944",
"0.5825647",
"0.5825647",
"0.58217955",
"0.58217955",
"0.58176917",
"0.58118373",
"0.5811516",
"0.5806746",
"0.58006585",
"0.5799795",
"0.5797629",
"0.5795681",
"0.5786596",
"0.578626",
"0.5784354",
"0.57780874",
"0.5777092"
] | 0.744485 | 1 |
list files within the base directory on the remote contentHost N Without this we won't have an easy way to list all files in the remote directory on the remote system | def listFiles()
#N Without this the files won't get listed
contentHost.listFiles(baseDir)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def listFiles(baseDir)\n #N Without this, the base directory might be missing the final '/', which might cause a one-off error when 'subtracting' the base directory name from the absolute paths to get relative paths\n baseDir = normalisedDir(baseDir)\n #N Without this we wouldn't be executing the command to list all files in the remote directory\n ssh(findFilesCommand(baseDir).join(\" \")) do |line| \n #N Without this we wouldn't be echoing the file name on this line for the user to read\n puts \" #{line}\"\n end\n end",
"def files_remote_list(options = {})\n options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]\n if block_given?\n Pagination::Cursor.new(self, :files_remote_list, options).each do |page|\n yield page\n end\n else\n post('files.remote.list', options)\n end\n end",
"def get_remote_files\n manager = @current_source.file_manager\n manager.start do \n @current_source.folders.each do |folder|\n @files[folder] = manager.find_files folder\n @files[folder] = @files[folder].take(@take) if @take\n Logger.<<(__FILE__,\"INFO\",\"Found #{@files[folder].size} files for #{@current_source.base_dir}/#{folder} at #{@current_source.host.address}\")\n SignalHandler.check\n end\n end\n end",
"def list_files\n [].tap do |files|\n remote_files do |file|\n files << file\n end\n end\n end",
"def test_getfilelist\n server = nil\n testdir, pattern, tmpfile = mktestdir\n\n file = nil\n\n assert_nothing_raised {\n\n server = Puppet::Network::Handler.fileserver.new(\n\n :Local => true,\n\n :Config => false\n )\n }\n\n assert_nothing_raised {\n server.mount(testdir, \"test\")\n }\n\n # get our listing\n list = nil\n sfile = \"/test/tmpfile\"\n assert_nothing_raised {\n list = server.list(sfile, :manage, true, false)\n }\n\n output = \"/\\tfile\"\n\n # verify it got listed as a file\n assert_equal(output, list)\n\n # verify we got all fields\n assert(list !~ /\\t\\t/)\n\n # verify that we didn't get the directory itself\n list.split(\"\\n\").each { |line|\n assert(line !~ %r{remotefile})\n }\n\n # and then verify that the contents match\n contents = File.read(tmpfile)\n\n ret = nil\n assert_nothing_raised {\n ret = server.retrieve(sfile)\n }\n\n assert_equal(contents, ret)\n end",
"def list_files\n files = remote_directory.files.map { |file| file.key }\n\n # The first item in the array is only the path an can be discarded.\n files = files.slice(1, files.length - 1) || []\n\n files\n .map { |file| Pathname.new(file).basename.to_s }\n .sort\n .reverse\n end",
"def list(client, current_path)\n\n\tfiles = Dir.glob(\"#{current_path}/files/*\")\n\tclient.puts \"\\nList of Files:\"\n\tfiles.each{ |file|\n\tfile.slice! \"#{current_path}/files/\"}\n\tclient.puts files\n\nend",
"def list_files_from (path,opts = {})\n safe_fetch do\n list_files = Set.new\n var = \"Search in #{path} at #{@host}... \"\n cmd = \"find #{path}\"\n cmd = \"(cd #{path} && ls \" ### dont know why cd alone doesn't work\n cmd << \"-td */\" if opts[:directories]\n cmd << opts[:regexp] if opts[:regexp]\n cmd << \" 2>/dev/null)\"\n out = @ssh.exec!(cmd)\n list_files = out.split\n list_files = out.split(\"/\\n\") if opts[:directories]\n\n var << \"Found #{list_files.size} entries\\n\"\n Logger.<<(__FILE__,\"INFO\",var)\n list_files\n end\n end",
"def list_files_from path,opts = {}\n unless Dir.exists? path\n Logger.<<(__FILE__,\"ERROR\",\"Local fetcher: path does not exists for listing... #{path} \")\n raise \"Error LocalFileFetcher !\"\n end\n if opts[:directories]\n cmd = \"ls -td #{path}/*/\"\n else\n cmd = \"ls #{path}\"\n cmd += \"/#{opts[:regexp]}\" if opts[:regexp]\n end\n out = `#{cmd}`\n return out.split(\"\\n\")\n end",
"def files_on_remote\n @bucket_contents = nil\n bucket_contents.map {|item| File.basename(item['Key']) }.sort\n end",
"def get_files\n fields = \"next_page_token, files(id, name, owners, parents, mime_type, sharedWithMeTime, modifiedTime, createdTime)\"\n\n folders = []\n @files = []\n\n #Go through pages of files and save files and folders\n next_token = nil\n first_page = true\n while first_page || (!next_token.nil? && !next_token.empty?)\n results = @service.list_files(q: \"not trashed\", fields: fields, page_token: next_token)\n folders += results.files.select{|file| file.mime_type == DRIVE_FOLDER_TYPE and belongs_to_me?(file)}\n @files += results.files.select{|file| !file.mime_type.include?(DRIVE_FILES_TYPE) and belongs_to_me?(file)}\n next_token = results.next_page_token\n first_page = false\n end\n\n #Cache folders\n folders.each {|folder| @folder_cache[folder.id] = folder}\n\n #Resolve file paths and apply ignore list\n @files.each {|file| file.path = resolve_path file}\n @files.reject!{|file| Helper.file_ignored? file.path, @config}\n\n Log.log_notice \"Counted #{@files.count} remote files in #{folders.count} folders\"\n end",
"def get_file_listing\n execute!(drive.files.list).data\n end",
"def pull_files(remote_path,local_path)\n debug_p(\"pull_files from #{remote_path} to #{local_path}\")\n @sftp_session.dir.foreach(remote_path){ |path|\n #unless path.name == \".\" || path.name == \"..\"\n #not directory\n unless /^d/ =~ path.longname\n @sftp_session.download!(remote_path + \"/\" + path.name,local_path + \"/\" + path.name)\n end\n #end\n }\n end",
"def list_files\n User.sync_files!(@context)\n files = user_real_files(params, @context)\n\n if unsafe_params[:limit] && unsafe_params[:offset]\n files = files.limit(unsafe_params[:limit]).offset(unsafe_params[:offset])\n end\n\n search_string = params[:search_string].presence || \"\"\n\n result = files.eager_load(:license, user: :org).\n where(\"nodes.name LIKE ?\", \"%#{search_string}%\").\n order(id: :desc).map do |file|\n describe_for_api(file, unsafe_params[:describe])\n end.compact\n\n render json: unsafe_params[:offset]&.zero? ? { objects: result, count: result.length } : result\n end",
"def pull_files(localpath, remotepath, filelist)\n connect!\n filelist.each do |f|\n localdir = File.join(localpath, File.dirname(f))\n FileUtils.mkdir_p localdir unless File.exist?(localdir)\n @connection.get \"#{remotepath}/#{f}\", File.join(localpath, f)\n log \"Pulled file #{remotepath}/#{f}\"\n end\n close!\n end",
"def list_contents\n {}.tap do |files|\n remote_files do |file|\n ftp.gettextfile(file) do |line, newline|\n content.concat newline ? line + \"\\n\" : line\n end # temporarly downloads the file\n FileUtils.rm file\n files[file] = { data: content }\n end\n end\n end",
"def list_files\n source_dir = Path.new(params[:source_dir])\n if params.has_key?(:show_catalogues)\n show_catalogues = params[:show_catalogues]\n else\n show_catalogues = false\n end\n if params[:ext].present?\n file_type = params[:ext]\n else\n file_type = nil\n end\n render json: source_dir.files(file_type: file_type, show_catalogues: show_catalogues)\n end",
"def ls( *args )\r\n \r\n directory = nil\r\n opts = {}\r\n \r\n case args.count\r\n when 1\r\n if args[0].kind_of? Hash\r\n opts = args[0]\r\n else\r\n directory = args[0]\r\n end\r\n when 2\r\n directory = args[0]\r\n opts = args[1] \r\n end\r\n \r\n # args are the RPC arguments ...\r\n args = {}\r\n args[:path] = directory if directory\r\n args[:recursive] = true if opts[:recurse]\r\n args[:detail] = true if opts[:detail] \r\n args.delete(:detail) if( args[:detail] and args[:recursive])\r\n \r\n # RPC output format, default is XML\r\n outf = { :format => 'text' } if opts[:format] == :text\r\n \r\n got = @ndev.rpc.file_list( args, outf )\r\n return nil unless got\r\n \r\n return got.text if opts[:format] == :text\r\n return got if opts[:format] == :xml\r\n \r\n # if we're here, then we need to conver the output \r\n # to a Hash. Joy!\r\n \r\n collect_detail = args[:detail] || args[:recursive]\r\n \r\n ls_hash = {}\r\n got.xpath('directory').each do |dir|\r\n \r\n dir_name = dir.xpath('directory-name').text.strip\r\n dir_hash = {}\r\n \r\n dir_hash[:fileblocks] = dir.xpath('total-file-blocks').text.to_i\r\n files_info = dir.xpath('file-information')\r\n \r\n dir_hash[:files] = {} \r\n dir_hash[:dirs] = {} # sub-directories\r\n \r\n files_info.each do |file|\r\n f_name = file.xpath('file-name').text.strip\r\n f_h = {} \r\n \r\n if file.xpath('file-directory')[0]\r\n dir_hash[:dirs][f_name] = f_h\r\n else\r\n dir_hash[:files][f_name] = f_h \r\n end\r\n \r\n next unless collect_detail\r\n \r\n f_h[:owner] = file.xpath('file-owner').text.strip\r\n f_h[:group] = file.xpath('file-group').text.strip\r\n f_h[:links] = file.xpath('file-links').text.to_i\r\n f_h[:size] = file.xpath('file-size').text.to_i\r\n \r\n xml_when_item(file.xpath('file-symlink-target')) { |i|\r\n f_h[:symlink] = i.text.strip\r\n }\r\n \r\n fp = file.xpath('file-permissions')[0]\r\n f_h[:permissions_text] = fp.attribute('format').value\r\n f_h[:permissions] = fp.text.to_i\r\n \r\n fd = file.xpath('file-date')[0]\r\n f_h[:date] = fd.attribute('format').value\r\n f_h[:date_epoc] = fd.text.to_i\r\n \r\n end # each directory file\r\n ls_hash[ dir_name ] = dir_hash \r\n end # each directory\r\n \r\n return nil if ls_hash.empty?\r\n ls_hash\r\n end",
"def test_get_files_list\n request = GetFilesListRequest.new(path: remote_data_folder)\n\n result = @words_api.get_files_list(request)\n assert_equal false, result.nil?\n end",
"def list(msg) # :yields: nil\n response \"125 Opening ASCII mode data connection for file list\"\n send_data(`ls -l`.split(\"\\n\").join(LNBR) << LNBR)\n \"226 Transfer complete\"\n end",
"def list\n Lib.list @path, @no_follow\n end",
"def filelist\n puts_message \"filelist start\" \n\n user = current_user\n\n request = params[:request].force_encoding(\"UTF-8\")\n puts_message \"Requested Path: \" + params[:request]\n \n if user and check_existance_of_path(request) \n if request == nil\n @file_names = 'error'\n elsif request_is_directory?(request)\n fire_the_list(request)\n # @file_names = absolute_path(request)\n elsif request_is_file?(request)\n last = request.split('/').last\n path = absolute_path(request)\n send_file_info(last, request) \n else\n @file_names = 'error'\n end\n else \n @file_names = 'error'\n end\n\n puts_message \"filelist end\" \n \n @output = <<-END\n\n END\n \n if request == \"/images/\"\n @folders = Folder.all(:user_id => current_user.id)\n \n @output << \"photo\" + \"\\n\"\n \n @folders.each do |f|\n @output << f.name + \"\\n\"\n end\n \n @file_names = @output\n end\n \n return @file_names\n\n end",
"def files\n return get_result('files')\n end",
"def listFileHashes\n return contentHost.listFileHashes(baseDir)\n end",
"def list(msg)\n response \"125 Opening ASCII mode data connection for file list\"\n send_data(`ls -l`.split(\"\\n\").join(LBRK) << LBRK)\n \"226 Transfer complete\"\n end",
"def listDirectories\n return contentHost.listDirectories(baseDir)\n end",
"def files_for_directory(path)\n directory = find_preferred_file(\n @new_resource.cookbook_name, \n :remote_file, \n path, \n @node[:fqdn],\n @node[:platform],\n @node[:platform_version]\n )\n\n unless (directory && ::File.directory?(directory))\n raise NotFound, \"Cannot find a suitable directory\"\n end\n\n directory_listing = Array.new\n Dir[::File.join(directory, '**', '*')].sort { |a,b| b <=> a }.each do |file|\n next if ::File.directory?(file)\n file =~ /^#{directory}\\/(.+)$/\n directory_listing << $1\n end\n directory_listing\n end",
"def remote_files\n @remote_files ||= local_files\n end",
"def cmd_list(param)\n send_unauthorised and return unless logged_in?\n send_response \"150 Opening ASCII mode data connection for file list\"\n\n param = '' if param.to_s == '-a'\n\n dir = File.join(@name_prefix.to_s, param.to_s)\n\n now = Time.now\n\n items = list_dir(build_path(param))\n lines = items.map do |item|\n \"#{item.directory ? 'd' : '-'}#{item.permissions || 'rwxrwxrwx'} 1 #{item.owner || 'owner'} #{item.group || 'group'} #{item.size || 0} #{(item.time || now).strftime(\"%b %d %H:%M\")} #{item.name}\"\n end\n send_outofband_data(lines)\n # send_action_not_taken\n end",
"def get_remote_files\n raise BucketNotFound.new(\"#{self.config.fog_provider} Bucket: #{self.config.fog_directory} not found.\") unless directory\n files = []\n directory.files.each { |f| files << f if File.extname(f.key).present? }\n return files\n end",
"def listCmd(cmdSock, sock)\n\tputs \"Client sent a list command\"\n\t#get all files from the directory but ignore hidden . and ..\n\tpath = File.expand_path(\"..\", Dir.pwd) + \"/testFiles\"\n\tdirFiles = Dir.entries(path).reject{|entry| entry == \".\" || entry ==\"..\"}\n\t#tell the client how many files there are\n\tnumFiles = dirFiles.length\n\tcmdSock.puts(numFiles)\n\tputs \"Sent # of files to client\"\n\t#for each file in the directoy\n\tfor fileName in dirFiles\n\t\t#send the filename\n\t\tsock.puts(fileName)\n\tend\n\tputs \"Sent all file names\"\nend",
"def download_files_from_vm(host, files)\n return if files.values.all?{|f| File.readable?(f)}\n files.values.each{|f| FileUtils.mkdir_p(File.dirname(f))}\n scp_connect(host) do |scp|\n files.each do |src, dest|\n scp.download(src, dest)\n end\n end\n end",
"def get_list(dir = nil)\n @ftp.ls(dir)[3..-1]\n end",
"def file_list(path='.', include_hidden=false)\n if include_hidden\n Timeout::timeout(@@ftp_timeout) { ftp.nlst(File.join(self.remote_storage_dir, path)) }\n else\n Timeout::timeout(@@ftp_timeout) { ftp.nlst(File.join(self.remote_storage_dir, path)).reject{ |f| f=~ /^\\./ } }\n end\n rescue Net::FTPPermError => nftpe\n return path =~ /\\.#{Recording.mime_ext}$/ ? nil : []\n end",
"def search(command)\n resp = @client.files.search('/', clean_up(command[1]))\n\n for item in resp\n puts item.path\n end\n end",
"def list(directory = nil)\n @ftp.nlst(directory)\n end",
"def list(folder)\n\t\tc = 0\n\t\tfolder = '/' + folder\t\t\t\n\t\tresp = @client.metadata(folder)\n\t\tputs \"\\n List of contents in \" + folder + \"\\n\"\n\t\tfor item in resp['contents']\t\t\n\t\t\tputs item['path']\n\n\t\t\tc=c+1\n\t\tend\t\n\t\t\n\tend",
"def find_files\n @files = []\n\n Dir.foreach(configured_file_path) do |file_name|\n next if file_name == '.' || file_name == '..'\n next if file_name =~ /^\\./ && Ferver.configuration.serve_hidden == false\n\n found_file = FoundFile.new(configured_file_path, file_name)\n @files << found_file if found_file.valid?\n end\n end",
"def downloadRemotefiles\n logger.debug(\"DOWNLOADING FILES.\")\n #sftp= Net::SFTP.start('belkuat.workhorsegroup.us', 'BLKUATUSER', :password => '5ada833014a4c092012ed3f8f82aa0c1')\n #ENV.fetch(\"WORKHORSE_HOST_SERVER\"), ENV.fetch(\"WORKHORSE_HOST_USERNAME\"), :password => ENV.fetch(\"WORKHORSE_HOST_PASSWORD\")\n Net::SFTP.start(ENV.fetch(\"WORKHORSE_HOST_SERVER\"), ENV.fetch(\"WORKHORSE_HOST_USERNAME\"), :password => ENV.fetch(\"WORKHORSE_HOST_PASSWORD\")) do |sftp|\n sftp.dir.glob(WORKHORSE_TO_SALSIFY, \"*\").each do |file|\n fileName = file.name\n sftp.download(File.join(WORKHORSE_TO_SALSIFY, \"/\", fileName), File.join(LOCAL_DIR, fileName))\n if File.extname(fileName).eql?(\".zip\")\n zipFiles.push(fileName)\n end\n end\n end\n logger.debug(\"FILES DOWNLOADED.\")\n end",
"def remote_ls(*args)\n raise NotImplementedError, \"Subclass must implement remote_ls()\"\n end",
"def files_remote_info(options = {})\n post('files.remote.info', options)\n end",
"def get_remotes()\n to_return = {}\n count = 1\n num_dirs = Dir.glob('./*/').size() -2 # exclude . and ..\n Dir.glob('./*/').each() do |dir|\n next if dir == '.' or dir == '..'\n\n print \"Processing directories...#{count}/#{num_dirs}\\r\" if !$verbose\n count += 1\n\n if(File.directory?(dir) and File.exists?(dir + '/.git'))\n Dir.chdir dir\n remotes = `git remote -v`.split(\"\\n\")\n\n vprint(dir.ljust(25))\n remotes.each() do |remote|\n if(remote.index('(fetch)'))\n parts = remote.split(\"\\t\")\n\n remote_name = get_remote_name(parts[1])\n vprint(\"[#{parts[0]} #{remote_name}]\".ljust(20))\n if(remote_name != nil)\n index = parts[0] + ' - ' + remote_name\n if(to_return[index] == nil)\n to_return[index] = Array.new()\n end\n to_return[index].push(dir)\n else\n puts \"\\nDon't know what to do with #{remote} in dir #{dir}\"\n end\n end\n end # end remotes loop\n\n vprint \"\\n\"\n Dir.chdir '..'\n end # end if file.directory\n end\n\n print \"\\n\"\n return to_return\nend",
"def list_files(env, res, tag, path)\n files = []\n git(\"ls-tree\", \"-z\", \"#{tag}:#{path}\") do |io|\n io.each_line(\"\\0\") do |line|\n line.chomp!(\"\\0\")\n #STDERR.puts line\n info, file = line.split(/\\t/, 2)\n mode, type, object = info.split(/ /)\n files << {\n :mode => mode,\n :type => type,\n :object => object,\n :file => file,\n }\n end\n end\n files = files.sort_by{|h| h[:file] }\n E_list_files.result(binding)\n end",
"def files options = {}\n ensure_connection!\n resp = connection.list_files name, options\n if resp.success?\n File::List.from_resp resp, connection\n else\n fail ApiError.from_response(resp)\n end\n end",
"def folder_list(command)\n path = '/' + clean_up(command[1] || '')\n resp = @client.files.folder_list(path)\n\n resp.contents.each do |item|\n puts item.path\n end\n end",
"def log_files\n raise \"no log host specified for #{self}\" unless log_host\n raise \"no log file patterns specified for #{self}\" unless log_file_patterns\n\n redirect_stderr = $DEBUG ? '' : '2>/dev/null'\n command = \"ssh -oClearAllForwardings=yes '#{host}' 'sudo sh -c \\\"ls -1 #{log_file_patterns.join ' '} #{redirect_stderr}\\\"' #{redirect_stderr}\"\n\n `#{command}`.split(\"\\n\")\n end",
"def download_files local_dir, remote_dir,remote_files,opts = {}\n safe_fetch do\n @ssh.sftp.connect do |sftp|\n Logger.<<(__FILE__,\"INFO\",\"Will start download #{remote_dir}/* from #{@host} to #{local_dir}...\")\n dls = remote_files.map do |remote_file|\n local_path = \"#{local_dir}/#{remote_file}\"\n sftp.download(\"#{remote_dir}/#{remote_file}\",local_path)\n end\n dls.each {|d| d.wait}\n Logger.<<(__FILE__,\"INFO\",\"Downloaded #{dls.size} files from #{remote_dir} at #{@host}\")\n end\n end\n end",
"def files\n FileList.new(`#@native.files`)\n end",
"def list\n factory.system.list(@path).collect do |item|\n candidate = dir(item)\n if (not candidate.exists?)\n candidate = file(item)\n end\n candidate\n end\n end",
"def search_in(files, host, options = T.unsafe(nil)); end",
"def test_listedpath\n server = nil\n assert_nothing_raised {\n\n server = Puppet::Network::Handler.fileserver.new(\n\n :Local => true,\n\n :Config => false\n )\n }\n\n\n # create a deep dir\n basedir = tempfile\n testdir = \"#{basedir}/with/some/sub/directories/for/testing\"\n oldfile = File.join(testdir, \"oldfile\")\n assert_nothing_raised {\n system(\"mkdir -p #{testdir}\")\n File.open(oldfile, \"w\") { |f|\n 3.times { f.puts rand(100) }\n }\n @@tmpfiles << basedir\n }\n\n # mounty mounty\n assert_nothing_raised {\n server.mount(basedir, \"localhost\")\n }\n\n list = nil\n # and then check a few dirs\n assert_nothing_raised {\n list = server.list(\"/localhost/with\", :manage, false, false)\n }\n\n assert(list !~ /with/)\n\n assert_nothing_raised {\n list = server.list(\"/localhost/with/some/sub\", :manage, true, false)\n }\n\n assert(list !~ /sub/)\n end",
"def get_files_list(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'FilesList')\n end",
"def readdir(path, fileinfo)\n puts \"#readdir \" + path\n entries = []\n handle = @sftp.opendir(path)\n items = @sftp.readdir(handle)\n items.each do |item|\n entries.push item.filename\n end\n @sftp.close_handle(handle)\n entries\n rescue\n p $!\n false\n end",
"def download_remotefiles\n logger.debug('DOWNLOADING FILES.')\n # sftp= Net::SFTP.start('belkuat.workhorsegroup.us', 'BLKUATUSER', :password => '5ada833014a4c092012ed3f8f82aa0c1')\n # ENV.fetch('WORKHORSE_HOST_SERVER'), ENV.fetch('WORKHORSE_HOST_USERNAME'), :password => ENV.fetch('WORKHORSE_HOST_PASSWORD')\n begin\n Net::SFTP.start(ENV.fetch('WORKHORSE_HOST_SERVER'), ENV.fetch('WORKHORSE_HOST_USERNAME'), :password => ENV.fetch('WORKHORSE_HOST_PASSWORD')) do |sftp|\n sftp.dir.glob(WORKHORSE_TO_SALSIFY, '*').each do |file|\n file_name = file.name\n sftp.download!(File.join(WORKHORSE_TO_SALSIFY, '/', file_name), File.join(LOCAL_DIR, file_name), :progress => CustomDownloadHandler.new)\n zip_files.push(file_name) if File.extname(file_name).eql?('.zip')\n end\n end\n rescue Exception => e\n logger.debug('Error is download file ' + e.message)\n end\n\n logger.debug('FILES DOWNLOADED.')\n end",
"def file_list\n end",
"def files\n i = 0\n @@arr_path.each do |path|\n if path.include?(params[:fold])\n # Remove path from current path\n @@arr_path = @@arr_path[0..i]\n @path = ''\n\n @@arr_path.each do |e| # Put path from array to @path\n @path = @path + e + ' >> '\n end\n @@temp_path = @path\n\n # Get content: folders, file, count\n @content = BrowsingFile.bind_folder params[:fold]\n @file = BrowsingFile.bind_files params[:fold]\n\n render 'index' # Reload index page\n return\n end\n i += 1\n end\n end",
"def files_list(params = {})\n response = @session.do_post \"#{SCOPE}.list\", params\n Slack.parse_response(response)\n end",
"def get_files(remote_folder_path)\n str_url = @str_uri_folder + remote_folder_path\n\n signed_uri = Aspose::Cloud::Common::Utils.sign(str_url)\n response = RestClient.get(signed_uri, :accept => 'application/json')\n\n JSON.parse(response)['Files']\n\n # urlFolder = $product_uri + '/storage/folder'\n # urlFile = ''\n # urlExist = ''\n # urlDisc = ''\n # if not remoteFolderPath.empty?\n # urlFile = $product_uri + '/storage/folder/' + remoteFolderPath \n # end \n # signedURL = Aspose::Cloud::Common::Utils.sign(urlFolder)\n # response = RestClient.get(signedURL, :accept => 'application/json')\n # result = JSON.parse(response.body)\n # apps = Array.new(result['Files'].size)\n #\n # for i in 0..result['Files'].size - 1\n # apps[i] = AppFile.new\n # apps[i].Name = result['Files'][i]['Name']\n # apps[i].IsFolder = result['Files'][i]['IsFolder']\n # apps[i].Size = result['Files'][i]['Size']\n # apps[i].ModifiedDate = Aspose::Cloud::Common::Utils.parse_date(result['Files'][i]['ModifiedDate'])\n # end\n # return apps\t \n end",
"def list\n FileOperations.find_all(self)\n end",
"def listCmd (cmdSock, sock)\n\tcmdSock.puts('LIST')\n\tnumFiles = cmdSock.gets.chomp\n\ti = 0\n\tif numFiles == 0\n\t\tputs \"No files available in the servers current file directory, try sending some files.\"\n\telse\n\t\trun = 1\n\t\twhile run == 1\n\t\t\ti += 1\n\t\t\tfName = sock.gets.chomp\n\t\t\tout = i.to_s + \") \" + fName\n\t\t\tputs out\n\t\t\tif i == numFiles.to_i\n\t\t\t\trun = 0\n\t\t\tend\n\t\tend\n\t\tputs \"End of list\"\n\tend\nend",
"def list_files(paths = T.unsafe(nil), options = T.unsafe(nil)); end",
"def list_files(paths = T.unsafe(nil), options = T.unsafe(nil)); end",
"def create_list_of_files\n @path=find_repository_and_basepath\n @table.window.setTitle(@path)\n files=[]\n Find.find(@path) do |file|\n # we don't want any files from a repository in the list \n next if file=~/(\\.hg|\\.svn|\\.git|\\.pyc)/ \n\n # neither do we want dotfiles in the list\n next if File.basename(file)=~/^\\./ \n \n # file matches, add it to the resulting list\n files << file if FileTest.file?(file)\n\n # wir bauen hier mal einen kleinen Idiotentest ein. Wenn wir mehr\n # als 10000 Dateien gefunden haben dann sind wir vermtl. in einem \n # falschen Verzeichniss und brechen die Suche ab.\n if files.length>10000\n NSRunInformationalAlertPanel('Large directory found!',\n \"Gathered more than 10k files from directory '#{@path}', aborting search!\",'OK',nil,nil)\n NSApp.stop(self)\n raise 'error'\n end\n end\n #@files=files.sort_by { |match| File.basename(match) }\n @files=files.sort\n end",
"def files\n @files ||= begin\n storage = model.storages.first\n return [] unless storage # model didn\"t store anything\n\n path = storage.send(:remote_path)\n unless path == File.expand_path(path)\n path.sub!(%r{(ssh|rsync)-daemon-module}, \"\")\n path = File.expand_path(File.join(\"tmp\", path))\n end\n Dir[File.join(path, \"#{model.trigger}.tar*\")].sort\n end\n end",
"def list(path='root')\n puts \"#list('#{path}')\"\n listed_files =[]\n @drive.folder = path\n children = @drive.children\n list_files_metadata(children)\n raise 'There are no files in directory' if children.count < 1\n children.each do |item|\n listed_files << \"#{item.path.gsub('/drive/', 'drive/')}/#{item.name}\" unless item.folder?\n end\n @logger.info 'Children list acquired.'\n pp listed_files\n end",
"def files(params = {}, &block)\n params = convert_params(params)\n return execute_paged!(\n :api_method => self.drive.files.list,\n :parameters => params,\n :converter => proc(){ |af| wrap_api_file(af) },\n &block)\n end",
"def hostfiles(options, which = T.unsafe(nil)); end",
"def list(current_folder)\n # Ensure API availability\n api.call(\"system\", \"greet\")\n\n api.call(files_project, \"listFolder\", { folder: current_folder, only: 'folders' })\n end",
"def listFileHashLines(baseDir)\n #N Without this, the base directory might be missing the final '/', which might cause a one-off error when 'subtracting' the base directory name from the absolute paths to get relative paths\n baseDir = normalisedDir(baseDir)\n #N Without this, we wouldn't know what command to run remotely to loop over the output of the file-files command and run the hash command on each line of output\n remoteFileHashLinesCommand = findFilesCommand(baseDir) + [\"|\", \"xargs\", \"-r\"] + @hashCommand.command\n #N Without this we wouldn't actually run the command just defined\n ssh(remoteFileHashLinesCommand.join(\" \")) do |line| \n #N Without this the line of output wouldn't be echoed to the user\n puts \" #{line}\"\n #N Without this the line of output (with a file name and a hash value) wouldn't be available to the caller of this method\n yield line \n end\n end",
"def list_packages(path,glob,rel)\n\t# user name and server name\n\tu,s=ENV['PKGSERVER'].split(\"@\")\n # Look for port option\n portOption = ENV['SSH_OPTS'].scan(/-p [0-9]+/)\n # Get port if set\n p = portOption.empty? ? 22 : portOption.first.split(\" \").last\n\n Net::SFTP.start(s,u,:port=>p) do |sftp|\n debs = [];\n sftp.dir.glob(path,glob) { |f| debs << f }\n \n versionRE=/^([^\\d]+[-_])(.*)([-_].+)$/\n\n debs.sort {|x,y| Gem::Version.new(y.name.match(versionRE).captures[1])<=>Gem::Version.new(x.name.match(versionRE).captures[1])}.each do |f|\n puts \"<tr><td><a href='#{rel}/#{f.name}'>#{f.name}</a></td>\"\n \n t=Time.at(f.attributes.mtime).strftime('%Y/%m/%d')\n mb = ((f.attributes.size/(1024.0*1024))*10).floor/10.0\n puts \"<td>#{t}</td><td>#{mb}M</td></tr>\"\n end\n end\n puts \"</table>\"\nend",
"def ftp_scan(ftp, dir, host)\n passdump=@@outdir + host + '-ftp_dump.txt'\n f=File.open(passdump, 'a+')\n ftp.chdir(dir)\n f.puts \"Listing Content for: #{ftp.pwd}\"\n print_status(\"Listing Content for: #{ftp.pwd}\")\n entries = ftp.list('*')\n entries.each do |file| \n print_line(\"#{file.chomp}\") unless file.chomp.nil? or file.chomp == '' \n f.puts file.chomp unless file.chomp.nil? or file.chomp == ''\n end\n f.close\n entries.each do |entry|\n if entry[0] == \"d\" and entry.split(' ')[-1] != '.' and entry.split(' ')[-1] != '..'\n ftp_scan(ftp, entry.chomp, host) #Call self until no more dirs left\n end\n end\n # Since we dipped down a level to scan this directory, lets go back to the parent so we can scan the next directory.\n ftp.chdir(@base)\n end",
"def files(treeish = nil)\n tree_list(treeish || @ref, false, true)\n end",
"def all\n # Requires authorization\n raise PutioError::AuthorizationRequired if authentication_required!\n\n files(-1)\n end",
"def available_response_files\n with_ftp do |ftp|\n # 3) List the *.csv files in the OUTGOING bucket.\n result = if ftp.nlst.include?(DCAS::DEFAULT_OUTGOING_BUCKET)\n ftp.chdir(DCAS::DEFAULT_OUTGOING_BUCKET)\n ftp.nlst.select {|f| f =~ /\\.csv$/}\n else\n []\n end\n end\n end",
"def remote_files(bucket, folders)\n objects = @s3.buckets[bucket].objects.with_prefix(File.join(folders))\n objects.each do |object|\n relative_path = object.key.split(/\\//).drop folders.length\n next if object.content_length.nil? or object.content_length == 0 or relative_path.empty?\n yield remote_item(object, relative_path)\n end\n end",
"def hostfiles(options, which = :all)\n files = []\n\n files += Array(options[:user_known_hosts_file] || %w[~/.ssh/known_hosts ~/.ssh/known_hosts2]) if which == :all || which == :user\n\n if which == :all || which == :global\n files += Array(options[:global_known_hosts_file] || %w[/etc/ssh/ssh_known_hosts /etc/ssh/ssh_known_hosts2])\n end\n\n return files\n end",
"def index(base_path, glob = nil)\n\t\tglob = '*' if glob == '' or glob.nil?\n\t\tdirs = []\n\t\tfiles = []\n\t\t::Dir.chdir(base_path) do\n\t\t\t::Dir.glob(glob).each do |fname|\n\t\t\t\tif ::File.directory?(fname)\n\t\t\t\t\tdirs << fname + '/'\n\t\t\t\telse\n\t\t\t\t\tfiles << fname\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tdirs.sort + files.sort\n\trescue Errno::ENOENT\n\t\traise Rush::DoesNotExist, base_path\n\tend",
"def all_files; end",
"def all_files; end",
"def readRemoteXML\n #sftp= Net::SFTP.start('belkuat.workhorsegroup.us', 'BLKUATUSER', :password => '5ada833014a4c092012ed3f8f82aa0c1')\n Net::SFTP.start('belkuat.workhorsegroup.us', 'BLKUATUSER', :password => '5ada833014a4c092012ed3f8f82aa0c1') do |sftp|\n sftp.dir.glob(WORKHORSE_TO_SALSIFY, FILE_EXTN).each do |file|\n #puts file.name\n sftp.download(File.join(WORKHORSE_TO_SALSIFY, '/', file.name), File.join(LOCAL_DIR, file.name))\n end\n end\n end",
"def list\n call(:get, path)\n end",
"def list_files\n Find.find(path) do |element| yield element end\n end",
"def index\n @ftpfiles = Ftpfile.all\n end",
"def list(path=nil)\n remote_path = list_path(path)\n begin\n folder = @client.folder(remote_path)\n raise Error if folder.nil?\n folder.items.map do |elem|\n {\n name: elem.name,\n path: \"#{remote_path}/#{elem.name}\",\n type: elem.type\n }\n end\n rescue RubyBox::AuthError\n box_error\n end\n end",
"def list_files_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: NsxComponentAdministrationApi.list_files ...\"\n end\n # resource path\n local_var_path = \"/node/file-store\"\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'FilePropertiesListResult')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: NsxComponentAdministrationApi#list_files\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def files(folder = 0)\n # Requires authorization\n raise PutioError::AuthorizationRequired if authentication_required!\n\n make_get_call('/files/list?parent_id=%i' % [folder]).files\n end",
"def download_all_files files,dest,opts = {}\n @ssh.sftp.connect do |sftp|\n ## in case we have too much files !!\n RubyUtil::partition files do |sub|\n dl = []\n sub.each do |file|\n dest_file = ::File.join(dest,file.cname)\n dl << sftp.download(file.full_path,dest_file) \n end\n dl.each { |d| d.wait }\n end\n end\n files.each { |f| f.path = dest; f.downloaded = true }\n files\n end",
"def files_listing path\n cmd = \"find #{path} -type f \"\n cmd += \"-regextype posix-extended \"\n cmd += \"-regex \\\"#{@file_regexp}\\\" \" if @file_regexp\n out = exec_cmd(cmd)\n end",
"def find_files_on_backup conf\n file_matcher = generate_intended_filename_regex conf\n unless BACKUP_SERVERS[conf['backup_hostname']]\n bs = BackupServer.new(conf['backup_hostname'], \n conf['backup_username'], \n conf['backup_destination'])\n BACKUP_SERVERS[conf['backup_hostname']] = bs\n end\n bs = BACKUP_SERVERS[conf['backup_hostname']]\n files = bs.all_files.select {|file| /#{ file_matcher }/ =~ file[:name] }\n return files.reverse()[0,20]\nend",
"def findFilesCommand(baseDir)\n #N Without path prefix, wouldn't work if 'find' is not on path, without baseDir, wouldn't know which directory to start, without '-type f' would list more than just directories, without -print, would not print out the values found (or is that the default anyway?)\n return [\"#{@pathPrefix}find\", baseDir, \"-type\", \"f\", \"-print\"]\n end",
"def get_current_files\n get_files(OcflTools::Utils.version_string_to_int(@head))\n end",
"def get_file_list(sequence_type,site_name)\n\n case sequence_type\n when 'asm'\n ftp_url = \"#{FTP_BASE_URLS['asm']}/#{site_name}/\"\n\n # get a file list from the FTP directory listing\n LOG.info \"Checking file list on FTP server at #{ftp_url} ...\"\n curl_res = `curl -l --progress-bar #{ftp_url}`\n print \"\\n\"\n\n file_list = curl_res.split(/\\n/).map { |f| \"#{ftp_url}#{f}\" }\n when 'rrna'\n require 'csv'\n ftp_url = \"#{FTP_BASE_URLS['rrna']}/\"\n\n # parse sample IDs from TSV sample ID map\n # linked from http://hmpdacc.org/micro_analysis/microbiome_analyses.php\n sample_ids_url = \"#{CONF_DIR}/ppAll_V35_map.txt\"\n file_list = CSV.new(File.open(sample_ids_url), { :headers => :first_row, :col_sep => \"\\t\" })\n .select { |line| line[-3] == site_name.capitalize && line[5] != 'Unavailable' }\n .map { |line| \"#{ftp_url}#{line[7]}.fsa.gz\" }\n .sort\n .uniq\n else\n raise \"Unknown sequence type '#{sequence_type}' requested.\"\n end\n\n file_list\n\nend",
"def send_directory(path, types)\n # TODO: use git ls\n listing = []\n Dir[File.join path, '*'].each { |child|\n stat = File.stat child\n listing << {\n :name => (File.basename child),\n :type => stat.ftype,\n :size => stat.size\n }\n }\n respond listing, types\n end",
"def index\n # Fetches space files.\n respond_with_space_files && return if params[:space_id]\n\n # Fetches all user 'private' files.\n filter_tags = params.dig(:filters, :tags)\n\n files = UserFile.\n real_files.\n editable_by(@context).\n accessible_by_private.\n where.not(parent_type: [\"Comparison\", nil]).\n includes(:taggings).\n eager_load(user: :org).\n search_by_tags(filter_tags)\n\n return render(plain: files.size) if show_count\n\n files = files.where(parent_folder_id: @parent_folder_id)\n files = FileService::FilesFilter.call(files, params[:filters])\n\n folders = private_folders(@parent_folder_id).includes(:taggings).\n eager_load(user: :org).search_by_tags(filter_tags)\n folders = FileService::FilesFilter.call(folders, params[:filters])\n\n user_files = Node.eager_load(user: :org).where(id: (files + folders).map(&:id)).\n order(order_params).page(page_from_params).per(page_size)\n page_dict = pagination_dict(user_files)\n\n render json: user_files, root: \"files\", adapter: :json,\n meta: files_meta.\n merge(count(UserFile.private_count(@context.user))).\n merge({ pagination: page_dict })\n end",
"def ls(path = '/')\n agency = options[:agency]\n ::Taxi::SFTP.new(agency).print_ls(path)\n end",
"def files(*args)\r\n LocalDirectory.current.files(*args)\r\n end",
"def get_remote_files_hierarchy(files, root = '/', hierarchy = { dirs: [], files: [] })\n files.each do |node|\n case node['node_type']\n when 'directory'\n hierarchy[:dirs] << \"#{root}#{node['name']}\"\n get_remote_files_hierarchy(node['files'], root + node['name'] + '/', hierarchy)\n when 'file'\n hierarchy[:files] << \"#{root}#{node['name']}\"\n end\n end\n\n hierarchy\nend",
"def files\n db = Database.find(params[:id])\n @files = Dir.entries(db.path)\n @files.delete_if{|f| !f.include?'.dat'}\n @results = []\n @files.each do |entry|\n @results << {:name=>entry,:version=>db.version}\n end\n respond_to do |format|\n format.html\n format.json { render json: @results }\n end\n end",
"def list_files(logged_in_user, order)\n files = []\n if logged_in_user.can_read(self.id)\n files = self.myfiles.find(:all, :order => order)\n end\n\n # return the files:\n return files\n end",
"def test_listroot\n server = nil\n testdir, pattern, tmpfile = mktestdir\n\n file = nil\n checks = Puppet::Network::Handler.fileserver::CHECKPARAMS\n\n # and make our fileserver\n assert_nothing_raised {\n\n server = Puppet::Network::Handler.fileserver.new(\n\n :Local => true,\n\n :Config => false\n )\n }\n\n # mount the testdir\n assert_nothing_raised {\n server.mount(testdir, \"test\")\n }\n\n # and verify different iterations of 'root' return the same value\n list = nil\n assert_nothing_raised {\n list = server.list(\"/test/\", :manage, true, false)\n }\n\n assert(list =~ pattern)\n\n assert_nothing_raised {\n list = server.list(\"/test\", :manage, true, false)\n }\n assert(list =~ pattern)\n\n end"
] | [
"0.75602233",
"0.7403312",
"0.7333173",
"0.7320576",
"0.70485646",
"0.70335466",
"0.6907107",
"0.6856096",
"0.6570057",
"0.6569688",
"0.6500472",
"0.6461954",
"0.6431847",
"0.6402489",
"0.63706017",
"0.63605845",
"0.6333622",
"0.63274324",
"0.6290226",
"0.62764335",
"0.6269832",
"0.6250316",
"0.6234918",
"0.6219369",
"0.6193995",
"0.6175484",
"0.61726755",
"0.6168577",
"0.615137",
"0.611293",
"0.61128145",
"0.607045",
"0.60624653",
"0.60599136",
"0.6056399",
"0.60394377",
"0.60351723",
"0.60234064",
"0.6000594",
"0.5997145",
"0.5993749",
"0.59890866",
"0.59836245",
"0.5976999",
"0.5969368",
"0.59683865",
"0.5968228",
"0.5948341",
"0.5946935",
"0.59430707",
"0.59421116",
"0.5936615",
"0.5935754",
"0.593523",
"0.59029067",
"0.58768374",
"0.5864793",
"0.58643323",
"0.58599234",
"0.585479",
"0.5853714",
"0.58528906",
"0.58441794",
"0.58216786",
"0.581851",
"0.5818409",
"0.5807727",
"0.5805327",
"0.5804714",
"0.57965827",
"0.5782819",
"0.57749295",
"0.57710344",
"0.5770804",
"0.5765929",
"0.5758095",
"0.5757769",
"0.5750451",
"0.5750451",
"0.5749358",
"0.5735977",
"0.5732159",
"0.5727848",
"0.5721072",
"0.571784",
"0.5695635",
"0.56917435",
"0.568276",
"0.5675074",
"0.5669495",
"0.5668757",
"0.5663415",
"0.566274",
"0.5661209",
"0.5659327",
"0.5654791",
"0.56462085",
"0.56378675",
"0.563662",
"0.56365967"
] | 0.8051429 | 0 |
object required to execute SCP (e.g. "scp" or "pscp", possibly with extra args) N Without this we won't have a handle on the object used to perform SSH/SCP actions | def sshAndScp
return contentHost.sshAndScp
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scp options = {}\n self.__commands << options.merge({:type => :scp})\n end",
"def initialize(shell, scpProgram)\n #N Without this we won't have the remote shell command as an array of executable + arguments\n @shell = shell.is_a?(String) ? [shell] : shell\n #N Without this we won't have the SCP command as an array of executable + arguments\n @scpProgram = scpProgram.is_a?(String) ? [scpProgram] : scpProgram\n #N Without this we won't have the SCP command as single string of white-space separated executable + arguments\n @scpCommandString = @scpProgram.join(\" \")\n end",
"def scpConnection\n return connection.scp\n end",
"def scp_connect\n # Connect to SCP and yield the SCP object\n connect do |connection|\n scp = Net::SCP.new(connection)\n return yield scp\n end\n rescue Net::SCP::Error => e\n # If we get the exit code of 127, then this means SCP is unavailable.\n raise Vagrant::Errors::SCPUnavailable if e.message =~ /\\(127\\)/\n\n # Otherwise, just raise the error up\n raise\n end",
"def exec_ssh(command, args, setting)\n puts \"#{Time.now} call #{self.class}##{__method__}\"\n ssh_options = ssh_option_init(setting)\n\n user = setting[\"ssh\"][\"user\"]\n host = setting[\"ssh\"][\"host\"]\n remote_dir = setting[\"dir\"][\"remote\"]\n\n Net::SSH.start(host, user, ssh_options) do |session|\n case command\n when :scp\n puts \"#{Time.now} scp: from #{args} to #{user}@#{host}:#{remote_dir}\"\n return Net::SCP.new(session).upload!(args, remote_dir, {:verbose => 'useful'})\n when :ssh\n return session.exec!(\"bash -c '#{args}'\").chomp!\n end\n end\n rescue Net::SSH::AuthenticationFailed => ex\n puts \"1\"\n puts \"class:#{ex.class} #{ex.message}\"\n return ex.class\n rescue Errno::ECONNREFUSED => ex\n puts \"2\"\n puts \"class:#{ex.class} #{ex.message}\"\n rescue => ex\n puts \"3\"\n puts \"class:#{ex.class} #{ex.message}\"\n end",
"def scp?\n true\n end",
"def cp(*args, **kwargs)\n queue CopyCommand, args, kwargs\n end",
"def scp(iFileSrc, iFileDst)\n check_expected_call('SCP', :Host => @SSHHost, :Login => @SSHLogin, :FileSrc => iFileSrc, :FileDst => iFileDst) do\n scp_RBPTest(iFileSrc, iFileDst)\n end\n end",
"def remote_clone\n raise CommandNotImplemented\n end",
"def scp(src_file, path_of_servers, dst_file, option = \"\")\n _path_of_servers = path_of_servers.dup\n remove_first_localhost!(_path_of_servers)\n\n #generate session uuid and make temp dir string\n sid = SecureRandom.uuid\n temp_file = \"#{temp_dir(sid)}#{File.basename(src_file)}\"\n\n #first, local src file to edge server's temp dir\n #(/tmp/onion_ssh/<session uuid>/<files>)\n first = _path_of_servers.shift\n ssh([first], \"mkdir -p #{temp_dir(sid)} >& /dev/null\")\n `#{one_scp_str(src_file, first, temp_file)}`\n \n #second to last - 1 , scp temp dir to temp dir\n last = _path_of_servers.pop\n temp_path = [first]\n _second_to_last_minus_one = _path_of_servers\n _second_to_last_minus_one.each do |sv|\n temp_path << sv\n ssh(temp_path,\"mkdir -p #{temp_dir(sid)} >& /dev/null\")\n end\n\n temp_path = [first]\n _second_to_last_minus_one.each do |sv|\n ssh(temp_path, \"#{one_scp_str(temp_file, sv, temp_dir(sid))}\")\n temp_path << sv\n end\n\n #last minus one's path=(temp_path above) and last\n ssh(temp_path, \"#{one_scp_str(temp_file, last, dst_file)}\")\n #delete garbage\n clear_temp([first] + _second_to_last_minus_one, sid)\n end",
"def kind\n :ssh\n end",
"def initialize(userAtHost, hashCommand, sshAndScp = nil)\n #N Without calling super, the hash command won't be configured\n super(hashCommand)\n #N Without this, the SSH & SCP implementation won't be configured\n @sshAndScp = sshAndScp != nil ? sshAndScp : InternalSshScp.new()\n #N Without this, the SSH & SCP implementation won't be configured with the user/host details to connect to.\n @sshAndScp.setUserAtHost(userAtHost)\n end",
"def scp(src, dest, *opts)\n run \"scp #{Array.wrap(src).join(' ')} #{dest}\", *opts\n end",
"def ssh(commandString, dryRun = false)\n contentHost.sshAndScp.ssh(commandString, dryRun)\n end",
"def file_upload(*paths); net_scp_transfer!(:upload, false, *paths); end",
"def uploadViaSSH(host , login , path, files_to_upload)\n\n # on vérifie si le dossier existe\n check_command = \"if [ ! -d \\\"#{path}\\\" ]; then mkdir \\\"#{path}\\\"; fi\"\n \n Net::SSH.start(host, login) do |ssh|\n # capture all stderr and stdout output from a remote process\n output = ssh.exec!(check_command)\n \n puts \"check: #{check_command}\"\n puts \"output : #{output}\"\n end\n\n Net::SCP.start(host, login) do |scp|\n files_to_upload.each do |names|\n puts 'Envoi du fichier ' + names[0] + ' vers ' + names[1]\n scp.upload!(names[0].to_s, names[1])\n end\n end\n\nend",
"def scp_cmd(source_file,destination_dir,backup_options = nil,backup_name = nil)\n backup_options ||= @backup_options\n backup_name ||= @backup_name\n ssh_user = backup_options[:user_name]\n ssh_host = backup_options[:hostname]\n ssh_password = backup_options[:password]\n if ssh_password\n # Need to use expect for the password if certs don't work\n cmd_exe = File.expand_path(File.join(::UBSAFE_ROOT, 'bin','ubsafe_scp_cmd.expect'))\n full_cmd = \"#{cmd_exe} #{ssh_user}@#{ssh_host} \\\"#{ssh_password}\\\" #{source_file} #{destination_dir}\"\n masked_full_cmd = \"#{cmd_exe} #{ssh_user}@#{ssh_host} [PASSWORD] #{source_file} #{destination_dir}\"\n else\n # Certs assumed if no password\n full_cmd = \"scp #{source_file} #{ssh_user}@#{ssh_host}:#{destination_dir}\"\n masked_full_cmd = full_cmd\n end\n #puts \"About to issue \\\"#{full_cmd}\\\"\"\n cmd_output = `#{full_cmd}`\n cmd_status = $?\n @log.debug(\"Executed scp status #{cmd_status} command \\\"#{masked_full_cmd}\\\"\")\n cmd_output_lines = cmd_output.split(\"\\n\").reject {|line| line =~ /spawn/i or line =~ /password/i }\n cmd_output_cleaned = []\n cmd_output_lines.each do |cmd_output_line|\n cmd_output_cleaned << cmd_output_line.strip.chomp\n end\n cmd_status = cmd_status == 0 ? :success : :failure\n return [cmd_status,cmd_output_cleaned]\n end",
"def scp(file)\n\t\tif pull_request_where == \"jackrabbit\"\n\t\t\tNet::SSH.start(pull_request_host, pull_request_user) do |ssh|\n\t\t\t\t# when testing, make sure to use cedar['upload_test_dir'] - this is the sftp user account home directory\n\t\t\t\t# when ready to move into production testing change this to cedar['upload_dir'] - this is the ALF automated ingest directory\n\t\t\t\tsuccess = ssh.scp.upload!(file, pull_request_upload_dir+'/#{file}')\n\t\t\t\traise \"Failed to scp file to #{pull_request_where}\" unless success\n\t\t\t\tlogger.info \"scp.upload! returned #{success}\"\n\t\t\t\tsuccess\n\t\t\tend\n\t\telsif pull_request_where == \"cedar\"\n\t\t\tNet::SCP.start(pull_request_host, pull_request_user, password: ALF_CFG['cedar_password']) do |scp|\n\t\t\t\t# when testing, make sure to use alf['upload_test_dir'] - this is the sftp user account home directory\n\t\t\t\t# when ready to move into production testing change this to alf['upload_dir'] - this is the ALF automated ingest directory\n\t\t\t\tsuccess = scp.upload!(file, \"#{pull_request_upload_dir}\")\n\t\t\t\traise \"Failed to scp file to #{pull_request_where}\" unless success\n\t\t\t\tlogger.info \"scp.upload! returned #{success}\"\n\t\t\t\tsuccess\n\t\t\tend\n\t\telse\n\t\t\traise \"Alf.yml does not have a valid 'where' value defined\"\n\t\tend\n\tend",
"def rcp(opts)\n dest = opts[:d].name\n source = opts[:sp]\n dest_path = opts[:dp]\n\n # Grab a remote path for temp transfer\n tmpdest = tmppath\n\n # Do the copy and print out results for debugging\n cmd = \"scp -r '#{source}' #{dest}:#{tmpdest}\"\n output << bold(color(\"localhost$\", :green)) << \" #{cmd}\\n\"\n ssh = RSpec.configuration.rspec_storage[:nodes][dest][:ssh]\n ssh.scp.upload! source.to_s, tmpdest.to_s, :recursive => true\n\n # Now we move the file into their final destination\n result = shell(:n => opts[:d], :c => \"mv #{tmpdest} #{dest_path}\")\n result[:exit_code] == 0\n end",
"def upload(source, destination, options = {} )\n options = @connection_options.clone\n host = options.delete(:host)\n username = options.delete(:username)\n channel = session.scp.upload(source,destination)\n channel.wait\n end",
"def scp(local_path,remote_path = \"#{dnsName}:\")\n if /([^:]+):(.*)/.match(remote_path)\n host = /([^:]+):(.*)/.match(remote_path)[1]\n remote_path_without_host = /([^:]+):(.*)/.match(remote_path)[2]\n else\n host = dnsName\n remote_path_without_host = remote_path\n end\n HCluster.scp_to(host,local_path,remote_path_without_host)\n end",
"def initialize_ssh; end",
"def copy(src, dst)\n\t\t# TODO: make cp able to handle strings, where it will create an entry based\n\t\t# on the box it's run from.\n\t\t\n\t\tif !(src.kind_of?(Rush::Entry) && dst.kind_of?(Rush::Entry))\n\t\t\traise ArgumentError, \"must operate on Rush::Dir or Rush::File objects\"\n\t\tend\n\t\t\n\t\t# 5 cases:\n\t\t# 1. local-local\n\t\t# 2. local-remote (uploading)\n\t\t# 3. remote-local (downloading)\n\t\t# 4. remote-remote, same server\n\t\t# 5. remote-remote, cross-server\n\t\tif src.box == dst.box # case 1 or 4\n\t\t\tif src.box.remote? # case 4\n\t\t\t\tsrc.box.ssh.exec!(\"cp -r #{src.full_path} #{dst.full_path}\") do |ch, stream, data|\n\t\t\t\t\tif stream == :stderr\n\t\t\t\t\t\traise Rush::DoesNotExist, stream\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\telse # case 1\n\t\t\t\tFileUtils.cp_r(src.full_path, dst.full_path)\n\t\t\tend\n\t\telse # case 2, 3, or 5\n\t\t\tif src.local? && !dst.local? # case 2\n\t\t\t\t# We use the connection on the remote machine to do the upload\n\t\t\t\tdst.box.ssh.scp.upload!(src.full_path, dst.full_path, :recursive => true)\n\t\t\telsif !src.local? && dst.local? # case 3\n\t\t\t\t# We use the connection on the remote machine to do the download\n\t\t\t\tsrc.box.ssh.scp.download!(src.full_path, dst.full_path, :recursive => true)\n\t\t\telse # src and dst not local, case 5\n\t\t\t\tremote_command = \"scp #{src.full_path} #{dst.box.user}@#{dst.box.host}:#{dst.full_path}\"\n\t\t\t\t# doesn't matter whose connection we use\n\t\t\t\tsrc.box.ssh.exec!(remote_command) do |ch, stream, data|\n\t\t\t\t\tif stream == :stderr\n\t\t\t\t\t\traise Rush::DoesNotExist, stream\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\t# TODO: use tar for cross-server transfers.\n\t\t# something like this?:\n\t\t# archive = from.box.read_archive(src)\n\t\t# dst.box.write_archive(archive, dst)\n\n\t\tnew_full_path = dst.dir? ? \"#{dst.full_path}#{src.name}\" : dst.full_path\n\t\tsrc.class.new(new_full_path, dst.box)\n\trescue Errno::ENOENT\n\t\traise Rush::DoesNotExist, File.dirname(to)\n\trescue RuntimeError\n\t\traise Rush::DoesNotExist, from\n\tend",
"def sendTask _obj, _args\n \"_obj sendTask _args;\" \n end",
"def scp(src, dest, hosts=self.hosts)\n Array(hosts).each do |host|\n output = `scp -q #{src} #{\"#{host}:\" unless host == :localhost}#{dest} 2>&1`\n case output\n when /Permission denied/i\n raise Errno::EACCES, output.chomp\n when /No such file or directory/i\n raise Errno::ENOENT, output.chomp\n end unless $?.exitstatus == 0\n end\n\n return nil\n end",
"def ssh_into(instance=nil)\n Kernel.system \"#{ssh_command(instance)}\" if instance\n end",
"def scp(source, destination)\n ssh.scp.upload!(source, destination) do |ch, name, rec, total|\n percentage = format('%.2f', rec.to_f / total.to_f * 100) + '%'\n print \"Saving to #{name}: Received #{rec} of #{total} bytes\" + \" (#{percentage}) \\r\"\n $stdout.flush\n end\n end",
"def scp(name, user, opts={}, &block)\n local_port = open(name, opts[:port] || 22)\n begin\n Net::SCP.start(\"127.0.0.1\", user, opts.merge(:port => local_port), &block)\n ensure\n close(local_port) if block || $!\n end\n end",
"def ssh_cmd(destination_host, cmd)\n\n if strict_host_checking\n [\n 'ssh', '-t',\n '-p', OodCore::Job::Adapters::Helper.ssh_port,\n '-o', 'BatchMode=yes',\n \"#{username}@#{destination_host}\"\n ].concat(cmd)\n else\n [\n 'ssh', '-t',\n '-p', OodCore::Job::Adapters::Helper.ssh_port,\n '-o', 'BatchMode=yes',\n '-o', 'UserKnownHostsFile=/dev/null',\n '-o', 'StrictHostKeyChecking=no',\n \"#{username}@#{destination_host}\"\n ].concat(cmd)\n end\n end",
"def send_blobs(ssh,srcpath,despath)\n if File.exist?srcpath\n #puts srcpath.split('/').inspect+\" srcfile\"\n #puts srcpath.split('/')[-1] + \" src file\"\n #puts ssh.exec!(\"ls\").inspect\n if ssh.exec!(\"ls\").inspect.include? srcpath.split('/')[-1]\n\n#return\n end\n ssh.scp.upload!( srcpath , despath , :recursive => true )do|ch, name, sent, total|\n percent = (sent.to_f*100 / total.to_f).to_i\n print \"\\r#{@host}: #{name}: #{percent}%\"\n end\n print \"\\n\"\n puts \"#{srcpath} upload Done.\"\n else\n abort(\"ERROR: Don't have such File: #{srcpath}\")\n end\n end",
"def local_clone\n raise CommandNotImplemented\n end",
"def net_scp_transfer!(direction, recursive, *files)\n \n unless [:upload, :download].member?(direction.to_sym)\n raise \"Must be one of: upload, download\" \n end\n \n if @rye_current_working_directory\n debug \"CWD (#{@rye_current_working_directory})\"\n end\n \n files = [files].flatten.compact || []\n\n # We allow a single file to be downloaded into a StringIO object\n # but only when no target has been specified. \n if direction == :download \n if files.size == 1\n debug \"Created StringIO for download\"\n target = StringIO.new\n else\n target = files.pop # The last path is the download target.\n end\n \n elsif direction == :upload\n# p :UPLOAD, @rye_templates\n raise \"Cannot upload to a StringIO object\" if target.is_a?(StringIO)\n if files.size == 1\n target = self.getenv['HOME'] || guess_user_home\n debug \"Assuming upload to #{target}\"\n else\n target = files.pop\n end\n \n # Expand fileglobs (e.g. path/*.rb becomes [path/1.rb, path/2.rb]).\n # This should happen after checking files.size to determine the target\n unless @rye_safe\n files.collect! { |file| \n file.is_a?(StringIO) ? file : Dir.glob(File.expand_path(file)) \n }\n files.flatten! \n end\n end\n \n # Fail early. We check whether the StringIO object is available to read\n files.each do |file|\n if file.is_a?(StringIO)\n raise \"Cannot download a StringIO object\" if direction == :download\n raise \"StringIO object not opened for reading\" if file.closed_read?\n # If a StringIO object is at end of file, SCP will hang. (TODO: SCP)\n file.rewind if file.eof?\n end\n end\n \n debug \"FILES: \" << files.join(', ')\n \n # Make sure the target directory exists. We can do this only when\n # there's more than one file because \"target\" could be a file name\n if files.size > 1 && !target.is_a?(StringIO)\n debug \"CREATING TARGET DIRECTORY: #{target}\"\n self.mkdir(:p, target) unless self.file_exists?(target)\n end\n \n Net::SCP.start(@rye_host, @rye_user, @rye_opts || {}) do |scp|\n transfers = []\n prev = \"\"\n files.each do |file|\n debug file.to_s\n prev = \"\"\n line = nil\n transfers << scp.send(direction, file, target, :recursive => recursive) do |ch, n, s, t|\n line = \"%-50s %6d/%-6d bytes\" % [n, s, t]\n spaces = (prev.size > line.size) ? ' '*(prev.size - line.size) : ''\n pinfo \"[%s] %s %s %s\" % [direction, line, spaces, s == t ? \"\\n\" : \"\\r\"] # update line: \"file: sent/total\"\n @rye_info.flush if @rye_info # make sure every line is printed\n prev = line\n end\n end\n transfers.each { |t| t.wait } # Run file transfers in parallel\n end\n \n target.is_a?(StringIO) ? target : nil\n end",
"def sendSimpleCommand _obj, _args\n \"_obj sendSimpleCommand _args;\" \n end",
"def assignAsCommander _obj, _args\n \"_obj assignAsCommander _args;\" \n end",
"def fetch\n scpd_getter = EM::DefaultDeferrable.new\n\n scpd_getter.errback do\n fail \"cannot get SCPD from #@scpd_url\"\n next\n end\n\n scpd_getter.callback do |scpd|\n if bad_description?(scpd)\n fail 'not a UPNP 1.0/1.1 SCPD'\n next\n end\n\n extract_service_state_table scpd\n extract_actions scpd\n\n succeed self\n end\n\n get_description @scpd_url, scpd_getter\n end",
"def scp_post_operations(scp_file_actual, scp_file_target)\n execute(\"mv #{scp_file_actual} #{scp_file_target}\") if self[:platform].include?('cisco_nexus')\n nil\n end",
"def ssh_type; end",
"def ssh_type; end",
"def ssh_type; end",
"def ssh_type; end",
"def fetch_object(file)\n @pool.process do\n dest = Pathname.new(\"#{@options[:destination]}/#{file.key}\")\n if file.key.end_with?(\"/\")\n puts \"Creating s3 subdirectory #{file.key} - #{Time.now}\" if verbose?\n dest.mkpath\n else\n dest.dirname.mkpath\n\n puts \"Copying from s3 #{file.key} - #{Time.now}\" if verbose?\n s3_client.get_object(response_target: \"#{dest}\",\n bucket: @options[:bucket],\n key: file.key,\n version_id: file.version_id)\n end\n\n @fetch_block_mutex.synchronize { yield file } if block_given?\n end\n end",
"def ssh_primary(host, cmd, cf)\n \n user = cf.get_user\n pass = cf.get_passwd\n\n begin\n ssh = Net::SSH.start(host, user, :password => pass)\n out = ssh.exec!(cmd)\n ssh.close\n puts out\n rescue StandardError => e\n puts e.to_s\n end \n\nend",
"def build_remote_cmd(task, cmd_str, input, given_opts, ssh_opts)\n Remote::Cmd.new(cmd_str, ssh_opts)\n end",
"def exec(opts={})\n # Get the SSH information and cache it here\n ssh_info = info\n\n if Util::Platform.windows?\n raise Errors::SSHUnavailableWindows, :host => ssh_info[:host],\n :port => ssh_info[:port],\n :username => ssh_info[:username],\n :key_path => ssh_info[:private_key_path]\n end\n\n raise Errors::SSHUnavailable if !Kernel.system(\"which ssh > /dev/null 2>&1\")\n\n # If plain mode is enabled then we don't do any authentication (we don't\n # set a user or an identity file)\n plain_mode = opts[:plain_mode]\n\n options = {}\n options[:host] = ssh_info[:host]\n options[:port] = ssh_info[:port]\n options[:username] = ssh_info[:username]\n options[:private_key_path] = ssh_info[:private_key_path]\n\n # Command line options\n command_options = [\"-p\", options[:port].to_s, \"-o\", \"UserKnownHostsFile=/dev/null\",\n \"-o\", \"StrictHostKeyChecking=no\", \"-o\", \"LogLevel=FATAL\", \"-p\", options[:password].to_s]\n\n # Solaris/OpenSolaris/Illumos uses SunSSH which doesn't support the IdentitiesOnly option\n # (Also don't use it in plain mode, it'll skip user agents.)\n command_options += [\"-o\", \"IdentitiesOnly=yes\"] if !(Util::Platform.solaris? || plain_mode)\n\n command_options += [\"-i\", options[:private_key_path]] if !plain_mode\n command_options += [\"-o\", \"ForwardAgent=yes\"] if ssh_info[:forward_agent]\n\n # If there are extra options, then we append those\n command_options.concat(opts[:extra_args]) if opts[:extra_args]\n\n if ssh_info[:forward_x11]\n # Both are required so that no warnings are shown regarding X11\n command_options += [\"-o\", \"ForwardX11=yes\"]\n command_options += [\"-o\", \"ForwardX11Trusted=yes\"]\n end\n\n host_string = options[:host]\n host_string = \"#{options[:username]}@#{host_string}\" if !plain_mode\n command_options << host_string\n @logger.info(\"Invoking SSH: #{command_options.inspect}\")\n safe_exec(\"ssh\", *command_options)\n end",
"def cmd_upload\n raise NotImplementedError, \"Subclass must implement cmd_upload()\"\n end",
"def execute_pool\n raise NotImplementedError\n end",
"def ssh(path_of_servers, command)\n _path_of_servers = path_of_servers.dup\n remove_first_localhost!(_path_of_servers)\n Open3.capture3(ssh_str(_path_of_servers, command))\n end",
"def execute\n raise NotImplementedError, 'Generic command has no actions'\n end",
"def ssh_into_instance_number(num=0)\n ssh_into( get_instance_by_number( num || 0 ) )\n end",
"def initialize(cmd, args = [], options = {})\n @usable = true\n @powershell_command = cmd\n @powershell_arguments = args\n\n raise \"Bad configuration for ENV['lib']=#{ENV['lib']} - invalid path\" if Pwsh::Util.invalid_directories?(ENV['lib'])\n\n if Pwsh::Util.on_windows?\n # Named pipes under Windows will automatically be mounted in \\\\.\\pipe\\...\n # https://github.com/dotnet/corefx/blob/a10890f4ffe0fadf090c922578ba0e606ebdd16c/src/System.IO.Pipes/src/System/IO/Pipes/NamedPipeServerStream.Windows.cs#L34\n named_pipe_name = \"#{SecureRandom.uuid}PsHost\"\n # This named pipe path is Windows specific.\n pipe_path = \"\\\\\\\\.\\\\pipe\\\\#{named_pipe_name}\"\n else\n require 'tmpdir'\n # .Net implements named pipes under Linux etc. as Unix Sockets in the filesystem\n # Paths that are rooted are not munged within C# Core.\n # https://github.com/dotnet/corefx/blob/94e9d02ad70b2224d012ac4a66eaa1f913ae4f29/src/System.IO.Pipes/src/System/IO/Pipes/PipeStream.Unix.cs#L49-L60\n # https://github.com/dotnet/corefx/blob/a10890f4ffe0fadf090c922578ba0e606ebdd16c/src/System.IO.Pipes/src/System/IO/Pipes/NamedPipeServerStream.Unix.cs#L44\n # https://github.com/dotnet/corefx/blob/a10890f4ffe0fadf090c922578ba0e606ebdd16c/src/System.IO.Pipes/src/System/IO/Pipes/NamedPipeServerStream.Unix.cs#L298-L299\n named_pipe_name = File.join(Dir.tmpdir, \"#{SecureRandom.uuid}PsHost\")\n pipe_path = named_pipe_name\n end\n pipe_timeout = options[:pipe_timeout] || self.class.default_options[:pipe_timeout]\n debug = options[:debug] || self.class.default_options[:debug]\n native_cmd = Pwsh::Util.on_windows? ? \"\\\"#{cmd}\\\"\" : cmd\n\n ps_args = args + ['-File', self.class.template_path, \"\\\"#{named_pipe_name}\\\"\"]\n ps_args << '\"-EmitDebugOutput\"' if debug\n # @stderr should never be written to as PowerShell host redirects output\n stdin, @stdout, @stderr, @ps_process = Open3.popen3(\"#{native_cmd} #{ps_args.join(' ')}\")\n stdin.close\n\n # TODO: Log a debug for \"#{Time.now} #{cmd} is running as pid: #{@ps_process[:pid]}\"\n\n # Wait up to 180 seconds in 0.2 second intervals to be able to open the pipe.\n # If the pipe_timeout is ever specified as less than the sleep interval it will\n # never try to connect to a pipe and error out as if a timeout occurred.\n sleep_interval = 0.2\n (pipe_timeout / sleep_interval).to_int.times do\n begin # rubocop:disable Style/RedundantBegin\n @pipe = if Pwsh::Util.on_windows?\n # Pipe is opened in binary mode and must always <- always what??\n File.open(pipe_path, 'r+b')\n else\n UNIXSocket.new(pipe_path)\n end\n break\n rescue StandardError\n sleep sleep_interval\n end\n end\n if @pipe.nil?\n # Tear down and kill the process if unable to connect to the pipe; failure to do so\n # results in zombie processes being left after a caller run. We discovered that\n # closing @ps_process via .kill instead of using this method actually kills the\n # watcher and leaves an orphaned process behind. Failing to close stdout and stderr\n # also leaves clutter behind, so explicitly close those too.\n @stdout.close unless @stdout.closed?\n @stderr.close unless @stderr.closed?\n Process.kill('KILL', @ps_process[:pid]) if @ps_process.alive?\n raise \"Failure waiting for PowerShell process #{@ps_process[:pid]} to start pipe server\"\n end\n\n # TODO: Log a debug for \"#{Time.now} PowerShell initialization complete for pid: #{@ps_process[:pid]}\"\n\n at_exit { exit }\n end",
"def ssh(*arguments)\n options = []\n\n # Add the -p option if an alternate destination port is given\n if @uri.port\n options += ['-p', @uri.port.to_s]\n end\n\n # append the SSH URI\n options << ssh_uri\n\n # append the additional arguments\n arguments.each { |arg| options << arg.to_s }\n\n return system('ssh',*options)\n end",
"def raw_send(cmd, nsock = self.sock)\n nsock.put(cmd)\n end",
"def ssh( commands=[], extra_ssh_ops={})\n commands = commands.compact.join(' && ') if commands.is_a?(Array)\n cmd_string = \"ssh #{user}@#{host} #{ssh_options(extra_ssh_ops)} \"\n if commands.empty?\n #TODO: replace this with a IO.popen call with read_nonblocking to show progress, and accept input\n Kernel.system(cmd_string)\n else\n system_run(cmd_string+\"'#{commands}'\")\n end\n end",
"def _cp(obj = Readline::HISTORY.entries[-2], *options)\n if obj.respond_to?(:join) && !options.include?(:a)\n if options.include?(:s)\n obj = obj.map { |element| \":#{element.to_s}\" }\n end\n out = obj.join(\", \")\n elsif obj.respond_to?(:inspect)\n out = obj.is_a?(String) ? obj : obj.inspect\n end\n \n if out\n IO.popen('pbcopy', 'w') { |io| io.write(out) } \n \"copied!\"\n end\nend",
"def remoteControl _obj, _args\n \"_obj remoteControl _args;\" \n end",
"def method_missing(s, *a, &b)\n if shell.respond_to?(s)\n shell.__send__(s, *a, &b)\n else\n super\n end\n end",
"def show\n File.open(\"temp\",\"w\") do |file|\n file.puts @kuaisufenfawenjian.jiaobenneirong\n end\n @cmd=\"\"\n @exe=\"\"\n @kuaisufenfawenjian.diannaos.each { |diannao|\n @cmd1=\"scp -o ConnectTimeout=1 temp root@\"+diannao.ip+\":\"[email protected]\n #cmd.gsub!(/\\0/, '')\n IO.popen(@cmd1, :external_encoding=>\"utf-8\") {|nkf_io|\n @exe1 = nkf_io.read\n }\n @cmd=@cmd+\"\\r\\n\"+@cmd1\n @exe=@exe+\"\\r\\n\"+@exe1\n }\n \n end",
"def construct_cmd\n cmd = \"ssh -i #{@key} \" \\\n \"-o StrictHostKeyChecking=no -o BatchMode=yes \" \\\n \"-o ConnectTimeout=#{@timeout} \" \\\n \"#{@user}@#{@host} \\\"#{@cmd}\\\"\"\n @logger.debug(cmd)\n cmd\n end",
"def execute(cmd, options = T.unsafe(nil)); end",
"def dir_upload(*paths); net_scp_transfer!(:upload, true, *paths); end",
"def sftp\n @_sftp ||= Net::SFTP.start(host, user, options)\n end",
"def command_for_rsync\n args = []\n args << \"-l #{@options[:user]}\" if @options[:user]\n args << \"-p #{@options[:port]}\" if @options[:port]\n if @options[:keys]\n @options[:keys].each { |key| args << \"-i #{key}\" }\n end\n \"ssh #{args.join(' ')}\"\n end",
"def raw_send(cmd, nsock = self.sock)\n\t\tnsock.put(cmd)\n\tend",
"def ssh(commandString, dryRun)\n #N Without this, command being executed won't be echoed to output\n puts \"SSH #{userAtHost} (#{shell.join(\" \")}): executing #{commandString}\"\n #N Without this check, the command will execute even it it's meant to be a dry run\n if not dryRun\n #N Without this, the command won't actually execute and return lines of output\n output = getCommandOutput(shell + [userAtHost, commandString])\n #N Without this loop, the lines of output won't be processed\n while (line = output.gets)\n #N Without this, the lines of output won't be passed to callers iterating over this method\n yield line.chomp\n end\n #N Without closing, the process handle will leak resources\n output.close()\n #N Without a check on status, a failed execution will be treated as a success (yielding however many lines were output before an error occurred)\n checkProcessStatus(\"SSH #{userAtHost} #{commandString}\")\n end\n end",
"def ssh\n @ssh ||= @remote.connect\n @remote\n end",
"def run_instance(o={})\n raise StandardError.new(\"You have no available hosts\") if available_hosts.empty?\n host = available_hosts.first\n new_host = SshInstance.new(instance_options(o.merge(:name=>host)))\n new_host.keypair\n if new_host && new_host.refresh!\n available_hosts.delete host\n new_host\n else\n raise StandardError.new(\"Unable to connect to host #{host}\")\n end\n end",
"def sync(src_object, dest_object=nil) # LOCAL_DIR s3://BUCKET[/PREFIX] or s3://BUCKET[/PREFIX] LOCAL_DIR\n send_command \"sync\", src_object, dest_object\n end",
"def copy_to_cooperative\n space = Space.accessible_by(@context).find(unsafe_params[:id])\n object = item_from_uid(unsafe_params[:object_id])\n\n if space.contributor_permission(@context) && space.member_in_cooperative?(@context.user_id)\n if object && space.shared_space\n ActiveRecord::Base.transaction do\n copy_service.copy(object, space.shared_space.uid).each do |new_object|\n SpaceEventService.call(\n space.shared_space.id,\n @context.user_id,\n nil,\n new_object,\n \"copy_to_cooperative\",\n )\n end\n end\n\n flash[:success] = \"#{object.class} successfully copied\"\n end\n else\n flash[:warning] = \"You have no permission to copy object(s) to cooperative.\"\n end\n\n redirect_back(fallback_location: space_path(space))\n end",
"def initialize(params_obj, options = {})\n @standard_properties = [\"SS_application\", \"SS_component\", \"SS_environment\", \"SS_component_version\", \"request_number\"]\n @p = params_obj\n super @p\n lib_path = @p.get(\"SS_script_support_path\")\n @action_platforms = {\"default\" => {\"transport\" => \"nsh\", \"platform\" => \"linux\", \"language\" => \"bash\", \"comment_char\" => \"#\", \"env_char\" => \"\", \"lb\" => \"\\n\", \"ext\" => \"sh\"}}\n @action_platforms.merge!(ACTION_PLATFORMS) if defined?(ACTION_PLATFORMS)\n @automation_category = get_option(options, \"automation_category\", @p.get(\"SS_automation_category\", \"shell\"))\n @output_dir = get_option(options, \"output_dir\", @p.get(\"SS_output_dir\"))\n action_platform(options)\n @nsh_path = get_option(options,\"nsh_path\", NSH_PATH)\n @debug = get_option(options, \"debug\", false)\n @nsh = NSH.new(@nsh_path)\n set_transfer_properties(options)\n timeout = get_option(options, \"timeout\", @p.get(\"step_estimate\", \"60\"))\n @timeout = timeout.to_i * 60\n end",
"def initialize\n extend(Net::SSH::Transport::PacketStream)\n super \"SSH-2.0-Test\\r\\n\"\n\n @script = Script.new\n\n script.sends(:kexinit)\n script.gets(:kexinit, 1, 2, 3, 4, \"test\", \"ssh-rsa\", \"none\", \"none\", \"none\", \"none\", \"none\", \"none\", \"\", \"\", false)\n script.sends(:newkeys)\n script.gets(:newkeys)\n end",
"def desc\n \"SSH command shell\"\n end",
"def sync_cmd\n warn(\"Legacy call to #sync_cmd cannot be preserved, meaning that \" \\\n \"test files will not be uploaded. \" \\\n \"Code that calls #sync_cmd can now use the transport#upload \" \\\n \"method to transfer files.\")\n end",
"def ssh\n @_ssh ||= Net::SSH.start(host, user, options)\n end",
"def ssh(*args)\n options = []\n\n # Add the -p option if an alternate destination port is given\n if @uri.port\n options += ['-p', @uri.port.to_s]\n end\n\n options << ssh_uri\n options += args\n\n return system('ssh',*options)\n end",
"def perform(*args)\n resource = StashEngine::Resource.where(id: args[0]).first\n return if resource.nil? || resource&.zenodo_copies&.data&.first&.state != 'enqueued' || self.class.should_defer?(resource: resource)\n\n data_copy = resource&.zenodo_copies&.data&.first\n zr = Stash::ZenodoReplicate::Copier.new(copy_id: data_copy.id)\n zr.add_to_zenodo\n end",
"def execute(command, opts = T.unsafe(nil), command_hash = T.unsafe(nil)); end",
"def _ssh(path_of_servers, sshpass_command, user_exec_command)\n if path_of_servers.size == 0\n return \"#{sshpass_command} #{user_exec_command}\"\n end\n\n server = path_of_servers.shift\n #shell command needs double quote's escape\n sshpass_command += \"\\\"#{one_ssh_str(server)}\"\n _ssh(path_of_servers, sshpass_command, user_exec_command)\n end",
"def provision_ssh(args)\n env = config.env.map { |k,v| \"#{k}=#{quote_and_escape(v.to_s)}\" }\n env = env.join(\" \")\n\n command = \"chmod +x '#{config.upload_path}'\"\n command << \" &&\"\n command << \" #{env}\" if !env.empty?\n command << \" #{config.upload_path}#{args}\"\n\n with_script_file do |path|\n # Upload the script to the machine\n @machine.communicate.tap do |comm|\n # Reset upload path permissions for the current ssh user\n info = nil\n retryable(on: Vagrant::Errors::SSHNotReady, tries: 3, sleep: 2) do\n info = @machine.ssh_info\n raise Vagrant::Errors::SSHNotReady if info.nil?\n end\n\n user = info[:username]\n comm.sudo(\"chown -R #{user} #{config.upload_path}\",\n error_check: false)\n\n comm.upload(path.to_s, config.upload_path)\n\n if config.name\n @machine.ui.detail(I18n.t(\"vagrant.provisioners.shell.running\",\n script: \"script: #{config.name}\"))\n elsif config.path\n @machine.ui.detail(I18n.t(\"vagrant.provisioners.shell.running\",\n script: path.to_s))\n else\n @machine.ui.detail(I18n.t(\"vagrant.provisioners.shell.running\",\n script: \"inline script\"))\n end\n\n # Execute it with sudo\n comm.execute(\n command,\n sudo: config.privileged,\n error_key: :ssh_bad_exit_status_muted\n ) do |type, data|\n handle_comm(type, data)\n end\n end\n end\n end",
"def command\n @command ||= case copy_strategy\n when :checkout\n source.checkout(revision, destination)\n when :export\n source.export(revision, destination)\n end\n end",
"def upload!(from, to)\n retryable(:tries => 5, :on => IOError) do\n execute do |ssh|\n scp = Net::SCP.new(ssh.session)\n scp.upload!(from, to)\n end\n end\n end",
"def commandMove _obj, _args\n \"_obj commandMove _args;\" \n end",
"def perform!(resource_name, action, options={})\n raise Copy::AuthenticationError unless session\n resource(resource_name).send(action, options_with_session(options))\n end",
"def execute\n raise NotImplementedError, 'Define `execute` in Command subclass'\n end",
"def ssh(*ssh_args)\n args = ['ssh',\n '-o', 'BatchMode=yes',\n '-o', 'ConnectionAttempts=5',\n '-o', 'ConnectTimeout=30',\n '-o', 'ServerAliveInterval=60',\n '-o', 'TCPKeepAlive=yes',\n '-x', '-a',\n '-i', @ssh_key,\n '-l', @destination_user,\n @destination_host\n ] +\n ssh_args.map { |a| a ? a : '' }\n\n puts args.join(\" \" ) if @verbose\n system(*args)\nend",
"def sendTaskResult _obj, _args\n \"_obj sendTaskResult _args;\" \n end",
"def sendTaskResult _obj, _args\n \"_obj sendTaskResult _args;\" \n end",
"def cutRsc _obj, _args\n \"_obj cutRsc _args;\" \n end",
"def remotes_action(command, id, host, action, remote_dir, std_in=nil)\n super(command,id,host,ACTION[action],remote_dir,std_in)\n end",
"def cutObj _obj, _args\n \"_obj cutObj _args;\" \n end",
"def system_rcp(options)\n ns = rspec_system_node_set\n options = {\n :source_path => options[:sp],\n :destination_path => options[:dp],\n :dp => options[:destination_path],\n :sp => options[:source_path],\n :destination_node => ns.default_node,\n :d => ns.default_node,\n :source_node => nil,\n :s => nil,\n }.merge(options)\n\n d = options[:d]\n sp = options[:sp]\n dp = options[:dp]\n\n log.info(\"system_rcp from #{sp} to #{d.name}:#{dp} executed\")\n ns.rcp(options)\n end",
"def initialize(host, user, comm = nil)\n\n ssh_opts = {\n :port => host.port,\n :config => true,\n :keys => \"~/.ssh/id_rsa\",\n :verbose => :debug,\n :timeout => 20\n #:paranoid => true\n }\n\n ssh_opts.merge!(:password => host.pass) if host.pass && host.pass != \"\"\n p ssh_opts\n Net::SSH.start(host.addr, user, ssh_opts) do |ssh|\n # puts hostname = ssh.exec_with_status(\"hostname\").result\n if comm\n ex = ssh.exec_with_status(comm)\n ssh.loop\n @buffer = ex.result\n\n else\n @result = { }\n for sample in Stat::comm(host)\n puts \"Executing #{sample}\"\n @result[sample[0]] = ssh.exec_with_status(sample[1])\n end\n\n ssh.loop\n @result.map { |k, v| @result[k] = v.result}\n s = host.stats.create(@result)\n end\n\n #s.save!\n end\n end",
"def take_cmd(pool, line, jid = nil)\n command, args = line.split(' ', 2) unless line.nil? \n if command\t\n unless pool[command.to_sym] == nil\n action = lambda { pool[command.to_sym].execute(args, jid) }\n else\n if pool == @cli_cmds\n action = lambda{ cli_fallback(command, args, jid) }\n else\n action = lambda{ xmpp_fallback(command, args, jid) }\n end\n end\n else\n action = proc {}\n end\n action\n end",
"def take_cmd(pool, line, jid = nil)\n command, args = line.split(' ', 2) unless line.nil? \n if command\t\n unless pool[command.to_sym] == nil\n action = lambda { pool[command.to_sym].execute(args, jid) }\n else\n if pool == @cli_cmds\n action = lambda{ cli_fallback(command, args, jid) }\n else\n action = lambda{ xmpp_fallback(command, args, jid) }\n end\n end\n else\n action = proc {}\n end\n action\n end",
"def clone_f(pathname_or_remote_url, options = {})\n clone(pathname_or_remote_url, options.merge(force: true))\n end",
"def exec_new(command, stdin = nil)\n\t exit_status = 0 # define variable so that it will be available in the block at method scope\n\t channel = @ssh_session.open_channel do |ch|\n\t ch.exec(command) do|ch, success|\n\n if success then\n\t @@logger.info(\"SshConnection: starts executing '#{command}'\")\n ch.on_data() do|ch, data|\n #process_stdout(data) unless data\n @stdout_handler.call(data) unless @stdout_handler.nil? or data.nil?\n end\n ch.on_extended_data() do|ch, type, data|\n @stderr_handler.call(data) unless @stderr_handler.nil? or data.nil?\n end\n ch.on_request \"exit-status\" do|ch, data|\n exit_status = data.read_long unless data.nil?\n\t @@logger.info(\"SshConnection.on_request: process terminated with exit-status: #{exit_status}\")\n\t if exit_status != 0\n\t @@logger.error(\"SshConnection.on_request: Remote command execution failed with code: #{exit_status}\")\n\t end\n end\n\t ch.on_request \"exit-signal\" do |ch, data|\n\t @@logger.info(\"SshConnection.on_request: process terminated with exit-signal: #{data.read_string}\")\n\t end\n ch.on_close do |ch|\n\t @@logger.info(\"SshConnection.on_close: remote end is closing!\")\n #@close_handler.call() unless @close_handler.nil?\n end\n ch.on_eof do |ch|\n\t @@logger.info(\"SshConnection.on_eof: remote end is done sending data\")\n #@close_handler.call() unless @close_handler.nil?\n end\n\t ch.on_open_failed do |ch, code, desc|\n\t @@logger.info(\"SshConnection.on_open_failed: code=#{code} desc=#{desc}\")\n\t end\n\t ch.on_process do |ch|\n\t #@@logger.debug(\"SshConnection.on_process; send line-feed/sleep\")\n\t ch.send_data(\"\\n\")\n\t end\n\n #ch.send_data stdin if stdin\n else\n\t @@logger.debug(\"SshConnection: the remote command could not be invoked!\")\n exit_status = 127\n end\n end\n\t #ch.wait\n\t end\n\t channel.wait\n\t return exit_status\n\tend",
"def exec _obj, _args\n \"_obj exec _args;\" \n end",
"def command\n logger.debug(\"#{copy_strategy}\")\n @command ||= case copy_strategy\n when :checkout\n source.checkout(revision, destination)\n when :export\n source.export(revision, destination)\n end\n end",
"def createSimpleTask _obj, _args\n \"_obj createSimpleTask _args;\" \n end",
"def run(*args)\n case args.size\n when 3\n ssh_host, ssh_user, ssh_command = args \n when 2\n ssh_host, ssh_command = args\n ssh_user = self.user\n when 1\n ssh_host, ssh_user = self.host, self.user\n ssh_command = args.first\n else\n raise ArgumentError\n end\n return ssh_host.map{|host| run(host, ssh_user, ssh_command)} if ssh_host.is_a? Array\n \n key = \"#{ssh_user}@#{ssh_host}\"\n puts \" #{key}$ #{ssh_command}\"\n @ssh_sessions[key] ||= Net::SSH.start(ssh_host, ssh_user)\n output = @ssh_sessions[key].exec!(ssh_command)\n puts output.split(\"\\n\").map{|l| \" #{key}> #{l}\"}.join(\"\\n\") if output\n output\n end",
"def copy\n self.public_send('|', 'pbcopy')\n self\n end"
] | [
"0.6245335",
"0.60075974",
"0.5718014",
"0.54305464",
"0.5376445",
"0.5346248",
"0.5294634",
"0.52113396",
"0.5139295",
"0.5126871",
"0.5095302",
"0.5030562",
"0.49899578",
"0.4964725",
"0.49260777",
"0.49208206",
"0.48916313",
"0.48773062",
"0.48633236",
"0.4855343",
"0.48508114",
"0.48263523",
"0.4816472",
"0.478652",
"0.47860184",
"0.47814676",
"0.47698358",
"0.47315803",
"0.4728782",
"0.4706917",
"0.4692045",
"0.46801436",
"0.46295953",
"0.4628237",
"0.46136048",
"0.46058625",
"0.45852774",
"0.45852774",
"0.45852774",
"0.45852774",
"0.45832944",
"0.458124",
"0.45617226",
"0.4548783",
"0.4547826",
"0.4524763",
"0.451945",
"0.44887",
"0.44854188",
"0.44746372",
"0.44552368",
"0.44542688",
"0.44510135",
"0.44411224",
"0.44371054",
"0.44300443",
"0.4427101",
"0.44057062",
"0.44052032",
"0.44029573",
"0.4396645",
"0.43907896",
"0.4386365",
"0.4372712",
"0.43646768",
"0.43638396",
"0.43603408",
"0.43550068",
"0.43504736",
"0.43454742",
"0.4344927",
"0.43355325",
"0.4329407",
"0.43253934",
"0.43249637",
"0.43243074",
"0.43218994",
"0.4316418",
"0.43075106",
"0.43006212",
"0.42995638",
"0.4295935",
"0.42925256",
"0.42897302",
"0.42867112",
"0.42867112",
"0.42803612",
"0.42724472",
"0.42717043",
"0.4268631",
"0.42677468",
"0.4266469",
"0.4266469",
"0.42563987",
"0.42542094",
"0.42539585",
"0.4251006",
"0.42487824",
"0.42470965",
"0.42463613"
] | 0.46920723 | 30 |
get the full path of a relative path N Without this we won't have an easy way to get the full path of a file or directory specified relative the remote directory | def getFullPath(relativePath)
return baseDir + relativePath
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relativePath\n #N Without this the path elements won't be joined together with \"/\" to get the relative path as a single string\n return @pathElements.join(\"/\")\n end",
"def full_path_to_remote_dir\n (remote_dir[0] == ?/ ? remote_dir : \"$(pwd)/#{remote_dir}\").chomp('/')\n end",
"def rel relative_path\r\n return File.dirname(__FILE__) + \"/../\" + relative_path\r\nend",
"def relative_path(from, to); end",
"def relative_path\n @relative_path ||= absolute_path.sub(/^#{Bookshelf::remote_folder}\\/?/,'')\n end",
"def relative_path_to(path, relative_to = nil)\n if relative_to\n path = File.expand_path(\n # symlink, e.g. \"../../../../grid5000/environments/etch-x64-base-1.0.json\"\n path,\n # e.g. : File.join(\"/\", File.dirname(\"grid5000/sites/rennes/environments/etch-x64-base-1.0\"))\n File.join('/', File.dirname(relative_to))\n ).gsub(%r{^/}, '')\n end\n path\n end",
"def relative_path(*relative)\n Pathname.pwd.join(*(relative.flatten.map(&:to_s))).expand_path\n end",
"def relative_path\n @local_path.relative_path_from(@platform.local_path)\n end",
"def relative_path(path = @pwd, to = @root)\n Pathname.new(path).relative_path_from(Pathname.new(to)).to_s\n end",
"def relative_path(path)\n path.split('/').drop(5).join('/')\nend",
"def relative_path_from(from); end",
"def relative_path(filename)\n pieces = split_filename(File.expand_path(filename))\n File.join(pieces[@mount_dir_pieces.size..-1])\n end",
"def relative_path_from(other)\n Pathname.new(self).relative_path_from(Pathname.new(other)).to_s\n end",
"def path(rel)\n File.join(File.dirname(__FILE__), \"..\", rel)\nend",
"def getFullPath(relativePath)\n return @baseDirectory.fullPath + relativePath\n end",
"def relativePath\n return (parentPathElements + [name]).join(\"/\")\n end",
"def rel_path(file)\n File.dirname(file)\n end",
"def relative_path\n @relative_path ||= File.join(*[@dir, @name].map(&:to_s).reject(&:empty?)).delete_prefix(\"/\")\n end",
"def full_rel_path()\n return nil if rel_path.nil?\n \n path = nil\n current_part = self\n while not current_part.nil? do\n if (not current_part.rel_path.nil?)\n if path.nil?\n path = current_part.rel_path\n else\n path = \"#{current_part.rel_path}.#{path}\"\n end\n end\n current_part = current_part.parent\n end\n \n return path\n end",
"def relative_path\n name\n end",
"def find_relative_git_cookbook_path\n\n cb = Pathname.new(find_local_cookbook).realpath()\n git_root = Pathname.new(find_git_root(cb)).realpath()\n relative = cb.relative_path_from(git_root)\n #puts (\"find cb \\n#{cb} relative to path\\n#{git_root} and it is \\n#{relative}\")\n return relative.to_s\n end",
"def relative_path\n must_be File\n Pathname.new(self.full_path).relative_path_from(Pathname.new(Dir.pwd)).to_s\n end",
"def relroot\n Pathname.new(File.expand_path(path)).\n relative_path_from(Pathname.new(File.expand_path(root))).to_s\n end",
"def relative_path; end",
"def relative_path; end",
"def relative_path; end",
"def relative_path; end",
"def relative_path; end",
"def relative_path\n @relative_path ||= PathManager.join(@dir, @name).delete_prefix(\"/\")\n end",
"def relativepath(abspath, relativeto)\n path = abspath.split(File::SEPARATOR)\n rel = relativeto.split(File::SEPARATOR)\n while (path.length > 0) && (path.first == rel.first)\n path.shift\n rel.shift\n end\n ('..' + File::SEPARATOR) * (rel.length - 1) + path.join(File::SEPARATOR)\n end",
"def relative_path(filename)\n @mount_dir_pieces ||= @mount_dir.size\n pieces = split_filename(File.expand_path(filename))\n File.join(pieces[@mount_dir_pieces..-1])\n end",
"def relative_to_mount(remote_file) # :nodoc:\n remote_file\n end",
"def relative_url\n path = nil\n note = self\n while true\n path = \"/#{note.slug}#{path}\"\n return path if !note.parent\n note = Note.first(:id=>note.parent)\n return path if !note\n end\n return nil\n end",
"def relative_path\n @relative_path ||= File.join(@dir, @name)\n end",
"def relative_path\n return self.avatar.match(/http[^|]*/)[0].to_s\n end",
"def relative_path_to(other)\n other.relative_path_from(@root)\n end",
"def relative(paths, reference_path = Dir.pwd)\n paths = [paths].flatten.collect do |path|\n path = Pathname.new(File.expand_path(path))\n reference_path = Pathname.new(File.expand_path(reference_path))\n path.relative_path_from(reference_path).to_s\n end\n\n paths.length == 1 ? paths.first : paths\n end",
"def relative(file)\n if File.directory?(full_path)\n file[full_path.length+1..-1]\n else\n File.basename(file)\n end\n end",
"def relative_path path, base\n (root? path) && (offset = descends_from? path, base) ? (path.slice offset, path.length) : path\n end",
"def relative_path(path)\n path[self.prefix.size..-1].gsub(%r{^/}, '').tap do |pth|\n #puts \"self.prefix=#{self.prefix}, path=#{path}, result=#{pth}\"\n end\n end",
"def resolvePath(possiblyRelativePath, rootDir)\n\t\tpath = Pathname.new(possiblyRelativePath)\n\t\tif(path.absolute?()) then\n\t\t\treturn path.to_s()\n\t\telse\n\t\t\trootPath = Pathname.new(rootDir)\n\t\t\treturn rootPath.join(path)\n\t\tend\n\tend",
"def relative_path\n @relative_path ||= File.join(@dir, @target)\n end",
"def relative_path_from(entry)\n @path.relative_path_from(entry.path)\n end",
"def relative_path(path_to, path_from)\n path_from ||= \"\"\n path_to = Pathname.new(path_to)\n dir_from = Pathname.new(path_from).dirname\n\n path_to.relative_path_from(dir_from).to_s\n end",
"def to_relative_path\n File.join('.', to.path(identify).to_s)\n end",
"def relative\n return self if relative?\n @relativized ||= relative_path_from root\n end",
"def rel_path(path)\n Pathname(path).expand_path.relative_path_from(Pathname(Dir.pwd))\n end",
"def relative_path(options = {})\n @relative_path ||= Pathname.new(filename).relative_path_from(Pathname.new(base)).to_s\n path_with_cache_buster(@relative_path, options)\n end",
"def relative_directory\n return '' unless @directory_root\n @path - @directory_root - name\n end",
"def relative_path\n File.join(@repo, @bundle)\n end",
"def getRealPath(path) Pathname.new(path).realpath.to_s; end",
"def getRealPath(path) Pathname.new(path).realpath.to_s; end",
"def ref_path(dir, subdir, path)\n # this stuff is overkill, and doesn't work anyways:\n #depth = dir.split(File::SEPARATOR).reject{ |d| d.empty? }.count\n #parent_dirs = Array.new(depth, '..')\n File.join('..', ContentRepo::ResourceNode::PATHNAME, path )\n end",
"def full_path(relative_filename)\n File.join(@mount_dir, relative_filename)\n end",
"def get_relative_path(path)\n Util::path_rel_to_path(path, recipe_file.path).to_s\n end",
"def to_relative_url\n to_relative_uri.to_s\n end",
"def relative_path(val = NULL)\n if null?(val)\n @relative_path || \".\"\n else\n @relative_path = val\n end\n end",
"def remote_path\n File.join(path, TRIGGER).sub(/^\\//, '')\n end",
"def local_to_remote_url local\n local.match /#{config[:relative_dir_regex]}/\n subdir = $2\n basename = File.basename local\n File.join(config[:root_path], subdir, basename)\n end",
"def abs_path_with(rel_path)\n path = abs_path\n return rel_path if path.nil?\n return \"#{path}.#{rel_path}\"\n end",
"def relative_path(p = path)\n anchor = p.ftype == \"directory\" ? @root_path : \"public\"\n p.relative_path_from(Pathname.new(anchor).realpath)\n end",
"def require_relative(x)\n REPLSupport.req_rel(x)\nend",
"def relative_path\n self.path.sub(File.expand_path(options[:root_dir]) + '/', '')\n end",
"def resolve_relative_path(path, base_path)\n p = Pathname(base_path)\n p = p.dirname unless p.extname.empty?\n p += path\n\n p.cleanpath.to_s\n end",
"def relative_path(from_str, to_str)\n require 'pathname'\n Pathname.new(to_str).relative_path_from(Pathname.new(from_str)).to_s\n end",
"def relative_path\n @rel_path ||= begin \n date_array = id.split(\"-\")[0..2]\n date_path = date_array.join(\"/\")\n article_id = begin\n str = id.gsub date_array.join(\"-\"), ''\n if str[0] == \"-\"\n str[1..-1] \n else\n str\n end\n end\n \"#{category}/#{date_path}/#{article_id}\"\n end\n end",
"def relative_path(path)\n path = destination_root.relative_path(path) || path\n path.empty? ? \".\" : path\n end",
"def relative_working_dir\n invoke(:rev_parse, '--show-prefix')\n end",
"def path(ref)\n parts = ref.split('/')\n @depth == 0 ? parts[-1] : \"/\" + parts[-(@depth + 1)..-1].join('/')\n end",
"def full_path\n path\n end",
"def relative_path(target = '.')\n my_path = Pathname.new(path).expand_path\n target_path = Pathname.new(target.to_s).expand_path\n target_path = target_path.dirname if target_path.file?\n\n new_path = my_path.relative_path_from(target_path).to_s\n\n return new_path if new_path.index('.') == 0\n \"./#{new_path}\"\n end",
"def relative_path(target = '.')\n my_path = Pathname.new(path).expand_path\n target_path = Pathname.new(target.to_s).expand_path\n target_path = target_path.dirname if target_path.file?\n\n new_path = my_path.relative_path_from(target_path).to_s\n\n return new_path if new_path.index('.') == 0\n \"./#{new_path}\"\n end",
"def relative_src(filename, dir=nil)\n file = expand_src filename, dir\n base = Pathname.new File.dirname path_info\n Pathname.new(file).relative_path_from(base).to_s\n end",
"def determine_path\n if source_line.file == SourceLine::DEFAULT_FILE\n return source_line.file\n end\n\n full_path = File.expand_path(source_line.file)\n pwd = Dir.pwd\n\n if full_path.start_with?(pwd)\n from = Pathname.new(full_path)\n to = Pathname.new(pwd)\n\n return from.relative_path_from(to).to_s\n else\n return full_path\n end\n end",
"def path\n # TODO: is this trip really necessary?!\n data.fetch(\"path\") { relative_path }\n end",
"def find_relative(uri, base, options)\n nil\n end",
"def to_proj_rel pn\n pn.relative_path_from(@dir)\n end",
"def rpath\n if (parent.nil? and domain) or (parent and parent.domain != domain)\n return ''\n else\n if parent\n rp = parent.rpath\n unless rp.blank?\n rp + '/' + path\n else\n path\n end\n else\n path\n end\n end\n end",
"def full_path; end",
"def path_from(relative_path)\n path.sub(/^#{Regexp.escape(relative_path)}\\/?/, '')\n end",
"def path_from(relative_path)\n path.sub(/^#{Regexp.escape(relative_path)}\\/?/, '')\n end",
"def linked_path\n File.readlink current_directory\n end",
"def realpath\n if(self.page)\n return Rails.application.routes.url_helpers.page_path(self.page)\n end\n '/' + self.explicit_path\n end",
"def path(*relative)\n File.join(self.bundle_dir, *relative)\n end",
"def relativize_path path\n base_dir = Pathname.new(File.expand_path(DIR))\n other_dir = Pathname.new(File.expand_path(path))\n other_dir.relative_path_from base_dir\n end",
"def full_path(custom)\n \"#{base_path}/#{custom}\"\n end",
"def to_s\n return (@BasePath || \"\") + \"|\" + (@RelativePath || \"nil\")\n end",
"def GetVsProjectRelativePath(projectRelativePath)\n if(VsPathIsAbsolute(projectRelativePath))\n return projectRelativePath\n end\n \n return JoinXmlPaths([ \"..\", \"..\", projectRelativePath])\n end",
"def relative_directory; end",
"def relative_file_path(file_path)\n file_path.gsub(/#{pwd}\\//, '')\n end",
"def path\n \"%s/%s\" % [dirname, filename]\n end",
"def local_to_remote local\n local.match /#{config[:relative_dir_regex]}/\n subdir = $2\n basename = File.basename local\n File.join(config[:root_dir], subdir, basename)\n end",
"def path\n real_path = Pathname.new(root).realpath.to_s\n full_path.sub(%r{^#{real_path}/}, '')\n end",
"def relative_path(pathname)\n pwd = Pathname.new('.').realpath\n pathname.file_ref.real_path.relative_path_from(pwd)\n end",
"def unravel_relative_path(rel_path)\n path_parts = rel_path.split '.'\n \n full_rel_path = \"\"\n defined_path = nil\n counter = path_parts.length\n \n for path_part in path_parts do\n path = defined_path.nil? ? path_part : \"#{defined_path}.#{path_part}\"\n if path_defined? path\n defined_path = path\n else\n break\n end\n counter = counter - 1\n end\n \n full_rel_path << self.defined_path(defined_path).full_rel_path if (not defined_path.nil?)\n if (counter > 0)\n full_rel_path << \".\" if (not defined_path.nil?)\n full_rel_path << path_parts.last(counter).join('.')\n end\n \n return full_rel_path\n end",
"def relative_path(path)\n path = File.expand_path(File.dirname(__FILE__) + '/' + path)\n \"'#{path}'\"\nend",
"def / aRelativePath\n access_child(aRelativePath)\n end",
"def abspath(file)\n File.absolute_path(file)\nend",
"def fullpath; end",
"def get_remote_dir\n return @resource[:remote_dir]\n end"
] | [
"0.6849355",
"0.67603993",
"0.674682",
"0.67232275",
"0.66965675",
"0.66868615",
"0.6637166",
"0.6484007",
"0.64763343",
"0.64621866",
"0.6461172",
"0.6446828",
"0.6398459",
"0.6398444",
"0.63929063",
"0.6375933",
"0.6336155",
"0.6330845",
"0.63110167",
"0.6292367",
"0.6290987",
"0.6270233",
"0.6223265",
"0.6202223",
"0.6202223",
"0.6202223",
"0.6202223",
"0.6202223",
"0.62010276",
"0.62007004",
"0.6199408",
"0.61873955",
"0.6186412",
"0.6182612",
"0.61715555",
"0.6167122",
"0.613974",
"0.6135358",
"0.61316246",
"0.6131394",
"0.6096292",
"0.60934",
"0.60864943",
"0.6075984",
"0.6068821",
"0.6062757",
"0.6062682",
"0.60579413",
"0.6038018",
"0.60361135",
"0.60324633",
"0.60324633",
"0.59979707",
"0.59653175",
"0.59523016",
"0.5935376",
"0.5890864",
"0.5860476",
"0.5859678",
"0.5855995",
"0.5852626",
"0.584899",
"0.58472747",
"0.584024",
"0.58325195",
"0.5830907",
"0.582794",
"0.58218926",
"0.58151746",
"0.58138204",
"0.5803108",
"0.5803108",
"0.58014745",
"0.5789176",
"0.5788021",
"0.57770205",
"0.5760353",
"0.575325",
"0.57491046",
"0.5739781",
"0.5739781",
"0.57371825",
"0.57288176",
"0.57281905",
"0.57179916",
"0.5716657",
"0.56991816",
"0.5683054",
"0.5677201",
"0.56758255",
"0.566712",
"0.56604666",
"0.56601286",
"0.56577355",
"0.5654355",
"0.56533957",
"0.5647546",
"0.56472516",
"0.5633658",
"0.5633161"
] | 0.66038984 | 7 |
execute an SSH command on the remote host (or just pretend, if dryRun is true) N Without this we won't have a direct method to execute SSH commands on the remote server (with dryrun option) | def ssh(commandString, dryRun = false)
contentHost.sshAndScp.ssh(commandString, dryRun)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remote_run cmd\n ssh = ssh_command(cmd)\n _show_cmd ssh\n system(ssh) unless @opts[:norun] || $norun\n end",
"def ssh(commandString, dryRun)\n #N Without this we won't have a description to display (although the value is only used in the next statement)\n description = \"SSH #{user}@#{host}: executing #{commandString}\"\n #N Without this the command description won't be echoed\n puts description\n #N Without this check, the command will execute even when it's only meant to be a dry run\n if not dryRun\n #N Without this, the command won't execute, and we won't have the output of the command\n outputText = connection.exec!(commandString)\n #N Without this check, there might be a nil exception, because the result of exec! can be nil(?)\n if outputText != nil then\n #N Without this, the output text won't be broken into lines\n for line in outputText.split(\"\\n\") do\n #N Without this, the code iterating over the output of ssh won't receive the lines of output\n yield line\n end\n end\n end\n end",
"def exec(command, options={})\n ssh.exec(command, options)\n end",
"def ssh(commandString, dryRun)\n #N Without this, command being executed won't be echoed to output\n puts \"SSH #{userAtHost} (#{shell.join(\" \")}): executing #{commandString}\"\n #N Without this check, the command will execute even it it's meant to be a dry run\n if not dryRun\n #N Without this, the command won't actually execute and return lines of output\n output = getCommandOutput(shell + [userAtHost, commandString])\n #N Without this loop, the lines of output won't be processed\n while (line = output.gets)\n #N Without this, the lines of output won't be passed to callers iterating over this method\n yield line.chomp\n end\n #N Without closing, the process handle will leak resources\n output.close()\n #N Without a check on status, a failed execution will be treated as a success (yielding however many lines were output before an error occurred)\n checkProcessStatus(\"SSH #{userAtHost} #{commandString}\")\n end\n end",
"def simple_ssh_command(host, user, command, timeout = 300)\n over_ssh(host: host, user: user, timeout: timeout) do |server|\n server.cd '/tmp'\n # Need to use sudo\n server.enable_sudo\n # scary...\n server.disable_safe_mode\n\n server.execute command\n end\n end",
"def ssh!(hostspec, script)\n CommandRunner.instance.ssh! hostspec, script\n end",
"def execute_remote_command(server, cmd)\n ssh(server, cmd).status == 0\n end",
"def exec!(cmd)\n connect! unless @connected\n if using_ssh?\n logger.debug(\"ssh: \" + cmd)\n ssh_session.exec!(cmd)\n else\n logger.debug(cmd)\n `#{cmd}`\n end\n end",
"def ssh_cmd(destination_host, cmd)\n\n if strict_host_checking\n [\n 'ssh', '-t',\n '-p', OodCore::Job::Adapters::Helper.ssh_port,\n '-o', 'BatchMode=yes',\n \"#{username}@#{destination_host}\"\n ].concat(cmd)\n else\n [\n 'ssh', '-t',\n '-p', OodCore::Job::Adapters::Helper.ssh_port,\n '-o', 'BatchMode=yes',\n '-o', 'UserKnownHostsFile=/dev/null',\n '-o', 'StrictHostKeyChecking=no',\n \"#{username}@#{destination_host}\"\n ].concat(cmd)\n end\n end",
"def ssh( commands=[], extra_ssh_ops={})\n commands = commands.compact.join(' && ') if commands.is_a?(Array)\n cmd_string = \"ssh #{user}@#{host} #{ssh_options(extra_ssh_ops)} \"\n if commands.empty?\n #TODO: replace this with a IO.popen call with read_nonblocking to show progress, and accept input\n Kernel.system(cmd_string)\n else\n system_run(cmd_string+\"'#{commands}'\")\n end\n end",
"def ssh(commandString, dryRun = false)\n #N Without this, the command won't actually be executed\n sshAndScp.ssh(commandString, dryRun) do |line|\n #N Without this, this line of output won't be available to the caller\n yield line\n end\n end",
"def command_send(command)\n\t\t# Check target\n\t\traise \"Target machine is not accessible\" if (!@config[\"ssh\"] or !@ip)\n\n\t\t# Prepare command\n\t\tcommand = command.gsub('\"', '\\\\\"')\n\t\tcommand = command.gsub('$', '\\\\$')\n\n\t\t# Execute and return result\n\t\t_ssh = `ssh -oStrictHostKeyChecking=no -oConnectTimeout=8 -i \"#{@config[\"ssh\"][\"key\"]}\" -t #{@config[\"ssh\"][\"username\"]}@#{@ip} \"#{command}\" 2>/dev/null`\n\t\treturn _ssh.strip\n\tend",
"def remote_command command, options={}\n return unless running?\n returning({ :stdout => '', :stderr => '', :exit_status => nil }) do |output|\n remote_stdout, remote_stderr, exit_code = '', '', nil\n Net::SSH.start(public_ip, options[:user] || \"root\", {:paranoid => false}.merge(options)) do |connection|\n connection.open_channel do |channel|\n channel.on_data { |ch, data| output[:stdout] += data }\n channel.on_extended_data { |ch, type, data| output[:stderr] += data }\n channel.on_request(\"exit-status\") do |p, data|\n output[:exit_status] = data.read_long\n end\n channel.exec(command) do |ch, executing|\n raise \"Could not execute: #{command}\" unless executing\n end\n end\n end\n end\n end",
"def execute(command)\n if remote?\n @remote.exec(command)\n else\n rays_exec(command)\n end\n end",
"def ssh_command\n args = domain!\n args = \"#{user}@#{args}\" if user?\n args << \" -i #{identity_file}\" if identity_file?\n args << \" -p #{ssh_port}\" if ssh_port?\n args << \" -t\"\n \"ssh #{args}\"\n end",
"def dispatch(command, return_output = false)\n Vanagon::Utilities.remote_ssh_command(\"#{@target_user}@#{@target}\", command, @target_port, return_command_output: return_output)\n end",
"def remote_command(command)\n return %x(ssh #{self.sar_host} \"#{command}\")\n end",
"def send_command(command)\n begin\n @ssh_connect.exec!(command)\n rescue Exception => error\n @log.error(\"#{error}\")\n end\n end",
"def execute_ssh_command(command)\n\t\tresult = ''\n\t\tNet::SSH.start(ip_string, settings.ssh[\"user\"]) do |ssh|\n\t\t\tresult = ssh.exec!(\"cmd /c #{command}\")\n\t\tend\n\t\tresult\n\tend",
"def execute_interactively(host, command)\n user = host.user\n hostname = host.hostname\n port = host.port || 22\n\n # execute in shell\n exec \"ssh -l #{user} #{hostname} -p #{port} -t '#{command}'\"\nend",
"def vm_ssh(env, cmd)\n puts \">>> '#{cmd}'\"\n env.primary_vm.ssh.execute do |ssh|\n ssh.exec!(cmd) do |channel, stream, data|\n print data\n $stdout.flush\n end\n end\nend",
"def ssh(*command, port: 22)\n runner = Fleetctl::Runner::SSH.new([*command].flatten.compact.join(' '))\n runner.run(host: ip, ssh_options: { port: port })\n runner.output\n end",
"def ssh(*command, port: 22)\n runner = Fleetctl::Runner::SSH.new([*command].flatten.compact.join(' '))\n runner.run(host: ip, ssh_options: { port: port })\n runner.output\n end",
"def _ssh(path_of_servers, sshpass_command, user_exec_command)\n if path_of_servers.size == 0\n return \"#{sshpass_command} #{user_exec_command}\"\n end\n\n server = path_of_servers.shift\n #shell command needs double quote's escape\n sshpass_command += \"\\\"#{one_ssh_str(server)}\"\n _ssh(path_of_servers, sshpass_command, user_exec_command)\n end",
"def exec(*args)\n command = args.shift\n\n arguments = Array.new\n arguments << %(sudo) if (@use_sudo == true)\n arguments << command\n arguments << args\n arguments = arguments.flatten.compact.join(' ')\n\n output = Array.new\n\n if @ssh.is_a?(ZTK::SSH)\n output << @ssh.exec(arguments, :silence => true, :ignore_exit_status => true).output\n else\n if @ssh.respond_to?(:exec!)\n output << @ssh.exec!(arguments)\n else\n raise SSHError, \"The object you assigned to ssh does not respond to #exec!\"\n end\n end\n\n output.join.strip\n end",
"def run_ssh(host, shell_command, ssh_timeout = 60)\n begin\n # define basic query\n ssh_query = {\n :ssh_host => host,\n :ssh_auth_type => :password, # password is set on ssh method (default per os during provisioning)\n :ssh_timeout => ssh_timeout,\n :ssh_debug => @debug,\n :ssh_command => shell_command\n }\n\n # instantiate the ssh method and pull the command status\n $evm.instantiate(SSH_INSTANCE_PATH + '?' + ssh_query.to_query)\n status = $evm.root['ssh_command_status']\n\n # pull and inspect our results if we succeeded\n if status\n results = $evm.root['ssh_results']\n return results\n else\n log(:error, \"run_ssh: Command #{shell_command} failed. Returning nil.\")\n return nil\n end\n rescue => err\n log(:error, \"run_ssh: Unable to run command: #{shell_command}. Returning nil.\")\n return nil\n end\nend",
"def run_ssh(options, command)\n return false, '' if options[:user].nil?\n return false, '' if options[:server].nil?\n return false, '' if options[:user].empty?\n return false, '' if options[:server].empty?\n return false, '' if options[:user].match(/^deny/)\n return false, '' if options[:server].match(/^deny/)\n\n if options[:user].match(/^allow/) and options[:server].match(/^allow/)\n success, output = run_external(command, options, SETTINGS[:project])\n return success, output\n end\n\n raise ArgumentError.new(\"Invalid settings or code - this shouldn't happen.\")\n end",
"def shell_execute(connection, command, **opts)\n opts = {\n sudo: false,\n shell: nil\n }.merge(opts)\n\n sudo = opts[:sudo]\n shell = (opts[:shell] || machine_config_ssh.shell).to_s\n\n @logger.info(\"Execute: #{command} (sudo=#{sudo.inspect})\")\n exit_status = nil\n\n # Open the channel so we can execute or command\n channel = connection.open_channel do |ch|\n marker_found = false\n data_buffer = ''\n stderr_marker_found = false\n stderr_data_buffer = ''\n\n tfile = Tempfile.new('vagrant-ssh')\n remote_ext = shell == \"powershell\" ? \"ps1\" : \"bat\"\n remote_name = \"#{machine_config_ssh.upload_directory}\\\\#{File.basename(tfile.path)}.#{remote_ext}\"\n\n if shell == \"powershell\"\n base_cmd = \"powershell -File #{remote_name}\"\n tfile.puts <<-SCRIPT.force_encoding('ASCII-8BIT')\nRemove-Item #{remote_name}\nWrite-Host #{CMD_GARBAGE_MARKER}\n[Console]::Error.WriteLine(\"#{CMD_GARBAGE_MARKER}\")\n#{command}\nSCRIPT\n else\n base_cmd = remote_name\n tfile.puts <<-SCRIPT.force_encoding('ASCII-8BIT')\nECHO OFF\nECHO #{CMD_GARBAGE_MARKER}\nECHO #{CMD_GARBAGE_MARKER} 1>&2\n#{command}\nSCRIPT\n end\n\n tfile.close\n upload(tfile.path, remote_name)\n tfile.delete\n\n base_cmd = shell_cmd(opts.merge(shell: base_cmd))\n @logger.debug(\"Base SSH exec command: #{base_cmd}\")\n\n ch.exec(base_cmd) do |ch2, _|\n # Setup the channel callbacks so we can get data and exit status\n ch2.on_data do |ch3, data|\n # Filter out the clear screen command\n data = remove_ansi_escape_codes(data)\n\n if !marker_found\n data_buffer << data\n marker_index = data_buffer.index(CMD_GARBAGE_MARKER)\n if marker_index\n marker_found = true\n data_buffer.slice!(0, marker_index + CMD_GARBAGE_MARKER.size)\n data.replace(data_buffer)\n data_buffer = nil\n end\n end\n\n if block_given? && marker_found\n yield :stdout, data\n end\n end\n\n ch2.on_extended_data do |ch3, type, data|\n # Filter out the clear screen command\n data = remove_ansi_escape_codes(data)\n @logger.debug(\"stderr: #{data}\")\n if !stderr_marker_found\n stderr_data_buffer << data\n marker_index = stderr_data_buffer.index(CMD_GARBAGE_MARKER)\n if marker_index\n marker_found = true\n stderr_data_buffer.slice!(0, marker_index + CMD_GARBAGE_MARKER.size)\n data.replace(stderr_data_buffer.lstrip)\n data_buffer = nil\n end\n end\n\n if block_given? && marker_found\n yield :stderr, data\n end\n end\n\n ch2.on_request(\"exit-status\") do |ch3, data|\n exit_status = data.read_long\n @logger.debug(\"Exit status: #{exit_status}\")\n\n # Close the channel, since after the exit status we're\n # probably done. This fixes up issues with hanging.\n ch.close\n end\n\n end\n end\n\n begin\n keep_alive = nil\n\n if @machine.config.ssh.keep_alive\n # Begin sending keep-alive packets while we wait for the script\n # to complete. This avoids connections closing on long-running\n # scripts.\n keep_alive = Thread.new do\n loop do\n sleep 5\n @logger.debug(\"Sending SSH keep-alive...\")\n connection.send_global_request(\"[email protected]\")\n end\n end\n end\n\n # Wait for the channel to complete\n begin\n channel.wait\n rescue Errno::ECONNRESET, IOError\n @logger.info(\n \"SSH connection unexpected closed. Assuming reboot or something.\")\n exit_status = 0\n pty = false\n rescue Net::SSH::ChannelOpenFailed\n raise Vagrant::Errors::SSHChannelOpenFail\n rescue Net::SSH::Disconnect\n raise Vagrant::Errors::SSHDisconnected\n end\n ensure\n # Kill the keep-alive thread\n keep_alive.kill if keep_alive\n end\n\n # Return the final exit status\n return exit_status\n end",
"def ssh_exec(command)\n stdout_data = ''\n stderr_data = ''\n exit_status = nil\n exit_signal = nil\n\n ssh.open_channel do |channel|\n channel.request_pty do |ch, success|\n raise 'Could not obtain pty' unless success\n\n ch.on_data do |ch, data|\n good_info data\n\n if data.match /sudo\\] password/\n unless ssh_options[:password]\n ssh_options[:password] = prompt(\"\\n<ROSH> Enter your password: \", false)\n end\n\n ch.send_data \"#{ssh_options[:password]}\\n\"\n ch.eof!\n end\n\n stdout_data << data\n end\n\n run_info(command)\n r = ch.exec(command)\n channel.close if r\n end\n\n channel.on_extended_data do |_, data|\n bad_info data.to_s\n stderr_data << data\n end\n\n channel.on_request('exit-status') do |_, data|\n exit_status = data.read_long\n end\n\n channel.on_request('exit-signal') do |_, data|\n exit_signal = data.read_long\n end\n end\n\n ssh.loop\n\n SSHResult.new(stdout_data, stderr_data, exit_status, exit_signal)\n end",
"def execute(command, live_stream = false)\n machine = @chef_provisioning.connect_to_machine(name, @current_chef_server)\n machine.execute_always(command, stream: live_stream)\n end",
"def ssh(args, options)\n perform_action(args[0], options, 'SSH') do |vm|\n rc = vm.info\n\n if OpenNebula.is_error?(rc)\n STDERR.puts rc.message\n exit(-1)\n end\n\n if vm.lcm_state_str != 'RUNNING'\n STDERR.puts 'VM is not RUNNING, cannot SSH to it'\n exit(-1)\n end\n\n # Get user to login\n username = vm.retrieve_xmlelements('//TEMPLATE/CONTEXT/USERNAME')[0]\n\n if !username.nil?\n login = username.text\n elsif !args[1].nil?\n login = args[1]\n else\n login = 'root'\n end\n\n # Get CMD to run\n options[:cmd].nil? ? cmd = '' : cmd = options[:cmd]\n\n # Get NIC to connect\n if options[:nic_id]\n nic = vm.retrieve_xmlelements(\n \"//TEMPLATE/NIC[NIC_ID=\\\"#{options[:nic_id]}\\\"]\"\n )[0]\n else\n nic = vm.retrieve_xmlelements('//TEMPLATE/NIC[SSH=\"YES\"]')[0]\n end\n\n nic = vm.retrieve_xmlelements('//TEMPLATE/NIC[1]')[0] if nic.nil?\n\n if nic.nil?\n STDERR.puts 'No NIC found'\n exit(-1)\n end\n\n # If there is node port\n if nic['EXTERNAL_PORT_RANGE']\n ip = vm.to_hash['VM']['HISTORY_RECORDS']['HISTORY']\n ip = [ip].flatten[-1]['HOSTNAME']\n port = Integer(nic['EXTERNAL_PORT_RANGE'].split(':')[0]) + 21\n else\n ip = nic['IP']\n port = 22\n end\n\n options[:ssh_opts].nil? ? opts = '' : opts = options[:ssh_opts]\n\n if opts.empty?\n exec('ssh', \"#{login}@#{ip}\", '-p', port.to_s, cmd.to_s)\n else\n exec('ssh', *opts.split, \"#{login}@#{ip}\", '-p', port.to_s, cmd.to_s)\n end\n end\n\n # rubocop:disable Style/SpecialGlobalVars\n $?.exitstatus\n # rubocop:enable Style/SpecialGlobalVars\n end",
"def exec(argv, options = {}, &block)\n sshcmd = %W( ssh #{@remote} -tS #{controlsocket} )\n\n sshcmd += %W( cd #{options[:chdir]} && ) if options.has_key?(:chdir)\n\n @local.exec(sshcmd + argv, &block)\n end",
"def run(command)\n retried = false\n\n begin\n result = ssh_exec(command)\n Rosh::Shell::CommandResult.new(nil, result.exit_status, result.stdout, result.stderr)\n rescue StandardError => ex\n log \"Error: #{ex.class}\"\n log \"Error: #{ex.message}\"\n log \"Error: #{ex.backtrace.join(\"\\n\")}\"\n\n if ex.class == Net::SSH::AuthenticationFailed\n if retried\n bad_info 'Authentication failed.'\n else\n retried = true\n password = prompt(\"\\n<ROSH> Enter your password: \", false)\n ssh_options.merge! password: password\n log \"Password added. options: #{ssh_options}\"\n @ssh = new_ssh\n retry\n end\n end\n\n if ex.class == Net::SSH::Disconnect\n if retried\n bad_info 'Tried to reconnect to the remote host, but failed.'\n else\n log 'Host disconnected us; retrying to connect...'\n retried = true\n @ssh = new_ssh\n run(command)\n retry\n end\n end\n\n Rosh::Shell::CommandResult.new(ex, 1)\n end\n end",
"def exec_ssh(command, args, setting)\n puts \"#{Time.now} call #{self.class}##{__method__}\"\n ssh_options = ssh_option_init(setting)\n\n user = setting[\"ssh\"][\"user\"]\n host = setting[\"ssh\"][\"host\"]\n remote_dir = setting[\"dir\"][\"remote\"]\n\n Net::SSH.start(host, user, ssh_options) do |session|\n case command\n when :scp\n puts \"#{Time.now} scp: from #{args} to #{user}@#{host}:#{remote_dir}\"\n return Net::SCP.new(session).upload!(args, remote_dir, {:verbose => 'useful'})\n when :ssh\n return session.exec!(\"bash -c '#{args}'\").chomp!\n end\n end\n rescue Net::SSH::AuthenticationFailed => ex\n puts \"1\"\n puts \"class:#{ex.class} #{ex.message}\"\n return ex.class\n rescue Errno::ECONNREFUSED => ex\n puts \"2\"\n puts \"class:#{ex.class} #{ex.message}\"\n rescue => ex\n puts \"3\"\n puts \"class:#{ex.class} #{ex.message}\"\n end",
"def ssh_into(instance=nil)\n Kernel.system \"#{ssh_command(instance)}\" if instance\n end",
"def chef_exec(cmd)\n @ssh.exec! \"#{CHEF_RUBY_INSTANCE_BASE}/bin/#{cmd}\", sudo: true\n end",
"def exec(opts={})\n # Get the SSH information and cache it here\n ssh_info = info\n\n if Util::Platform.windows?\n raise Errors::SSHUnavailableWindows, :host => ssh_info[:host],\n :port => ssh_info[:port],\n :username => ssh_info[:username],\n :key_path => ssh_info[:private_key_path]\n end\n\n raise Errors::SSHUnavailable if !Kernel.system(\"which ssh > /dev/null 2>&1\")\n\n # If plain mode is enabled then we don't do any authentication (we don't\n # set a user or an identity file)\n plain_mode = opts[:plain_mode]\n\n options = {}\n options[:host] = ssh_info[:host]\n options[:port] = ssh_info[:port]\n options[:username] = ssh_info[:username]\n options[:private_key_path] = ssh_info[:private_key_path]\n\n # Command line options\n command_options = [\"-p\", options[:port].to_s, \"-o\", \"UserKnownHostsFile=/dev/null\",\n \"-o\", \"StrictHostKeyChecking=no\", \"-o\", \"LogLevel=FATAL\", \"-p\", options[:password].to_s]\n\n # Solaris/OpenSolaris/Illumos uses SunSSH which doesn't support the IdentitiesOnly option\n # (Also don't use it in plain mode, it'll skip user agents.)\n command_options += [\"-o\", \"IdentitiesOnly=yes\"] if !(Util::Platform.solaris? || plain_mode)\n\n command_options += [\"-i\", options[:private_key_path]] if !plain_mode\n command_options += [\"-o\", \"ForwardAgent=yes\"] if ssh_info[:forward_agent]\n\n # If there are extra options, then we append those\n command_options.concat(opts[:extra_args]) if opts[:extra_args]\n\n if ssh_info[:forward_x11]\n # Both are required so that no warnings are shown regarding X11\n command_options += [\"-o\", \"ForwardX11=yes\"]\n command_options += [\"-o\", \"ForwardX11Trusted=yes\"]\n end\n\n host_string = options[:host]\n host_string = \"#{options[:username]}@#{host_string}\" if !plain_mode\n command_options << host_string\n @logger.info(\"Invoking SSH: #{command_options.inspect}\")\n safe_exec(\"ssh\", *command_options)\n end",
"def run(*args)\n case args.size\n when 3\n ssh_host, ssh_user, ssh_command = args \n when 2\n ssh_host, ssh_command = args\n ssh_user = self.user\n when 1\n ssh_host, ssh_user = self.host, self.user\n ssh_command = args.first\n else\n raise ArgumentError\n end\n return ssh_host.map{|host| run(host, ssh_user, ssh_command)} if ssh_host.is_a? Array\n \n key = \"#{ssh_user}@#{ssh_host}\"\n puts \" #{key}$ #{ssh_command}\"\n @ssh_sessions[key] ||= Net::SSH.start(ssh_host, ssh_user)\n output = @ssh_sessions[key].exec!(ssh_command)\n puts output.split(\"\\n\").map{|l| \" #{key}> #{l}\"}.join(\"\\n\") if output\n output\n end",
"def ssh(iCmd)\n check_expected_call('SSH', :Host => @SSHHost, :Login => @SSHLogin, :Cmd => iCmd) do\n ssh_RBPTest(iCmd)\n end\n end",
"def run_remote_command(command)\n # Finds the remote ip and stores it in \"remote_ip\"\n parse_remote_ip\n \n # Finds the remote ip and stores it in \"remote_app_name\"\n parse_remote_app_name\n \n begin\n remote_command(command)\n rescue Net::SSH::AuthenticationFailed\n HighLine.track_eof = false\n password = ask(\"Enter your password: \") { |q| q.echo = '' }\n remote_command(command, password)\n end\n end",
"def ssh(host, user_name, *commands)\n global_cmd = \"ssh #{SSH_OPTIONS} #{user_name}@#{host} \\\"#{commands.join(';echo -;')}\\\"\"\n @logger.info(\"[SystemGateway][ssh] Executing #{global_cmd}...\")\n out = `#{global_cmd}`\n\n # SSH command failures (host unreachable, authentication errors)\n if $?.to_i != 0\n @logger.error(\"[SystemGateway][ssh] Command terminated abnormally: #{$?}\")\n raise(SSHError)\n end\n\n @logger.info(\"[SystemGateway][ssh] Command ended. Output: #{out}\")\n out\n end",
"def ssh_cmd!(cmd)\n ssh_cmd cmd, false\n end",
"def ssh_script!(hostspec, script, arguments: nil)\n CommandRunner.instance.ssh_script! hostspec, script, arguments: arguments\n end",
"def run(cmd, host_ip)\n user = 'root'\n ip = host_ip\n port = 22\n\n @cmd = system \"ssh -p #{port} #{user}@#{ip} '#{cmd}'\" \n logger.info @cmd\n end",
"def exec_cmd cmd\n t = Time.now\n results = \"\"\n @ssh.open_channel do |channel|\n channel.exec(cmd) do |ch,success|\n unless success\n Logger.<<(__FILE__,\"INFO\",\"Could Not execute command #{cmd}\")\n abort\n end\n # stdout\n channel.on_data do |ch,data|\n results += data\n end\n # stderr\n channel.on_extended_data do |ch,type,data|\n Logger.<<(__FILE__,\"ERROR\",\"Error from the cmd #{cmd} : #{data}\")\n abort\n end\n channel.on_close do |ch|\n end\n end\n end\n # wait for the command to finish\n @ssh.loop\n Logger.<<(__FILE__,\"DEBUG\",\"SFTP Command executed in #{Time.now - t} sec\") if @opts[:v]\n results.split\n end",
"def remote\n log_and_exit read_template('help') if options.empty?\n \n # Attempts to run the specified command\n run_remote_command(options[0])\n end",
"def execute_ssh(commands)\n commands = [commands] unless commands.is_a? Array\n result = \"\"\n Net::SSH.start settings.remote_server, settings.remote_user do |ssh|\n commands.each do |command|\n was_error = false\n logger.info \"ssh: #{command}\"\n ssh.exec! command do |channel, stream, data|\n case stream\n when :stdout\n logger.info data\n result += \"#{data}\\n\" unless data.empty?\n when :stderr\n logger.error data\n was_error = true\n end\n end\n throw \"Exception during ssh, look in log file\" if was_error\n end\n end\n result\n end",
"def run(cmd, port:, user:, password:)\n result = Net::SSH::Simple.ssh(ip, cmd,\n user: user, port: port, password: password, paranoid: false)\n result[:exit_code].zero?\n rescue Net::SSH::Simple::Error => e\n log.info \"Running '#{cmd}' failed: #{e.inspect}\"\n false\n end",
"def ssh(*ssh_args)\n args = ['ssh',\n '-o', 'BatchMode=yes',\n '-o', 'ConnectionAttempts=5',\n '-o', 'ConnectTimeout=30',\n '-o', 'ServerAliveInterval=60',\n '-o', 'TCPKeepAlive=yes',\n '-x', '-a',\n '-i', @ssh_key,\n '-l', @destination_user,\n @destination_host\n ] +\n ssh_args.map { |a| a ? a : '' }\n\n puts args.join(\" \" ) if @verbose\n system(*args)\nend",
"def remote_command(type, command, options)\n # If the VM is not running, then we can't run SSH commands...\n raise Errors::VMNotRunningError if @vm.state != :running\n\n # Initialize the result object, execute, and store the data\n result = OpenStruct.new\n result.stderr = \"\"\n result.stdout = \"\"\n result.exit_code = @vm.channel.send(type, command,\n :error_check => false) do |type, data|\n if type == :stdout\n result.stdout += data\n elsif type == :stderr\n result.stderr += data\n end\n\n # If we're echoing data, then echo it!\n if options[:echo]\n @vm.ui.info(data.to_s,\n :prefix => false,\n :new_line => false)\n end\n end\n\n # Return the result\n result\n end",
"def ssh_exec!(ssh, command)\n stdout_data = ''\n stderr_data = ''\n exit_code = nil\n exit_signal = nil\n ssh.open_channel do |channel|\n channel.exec(command) do |_ch, success|\n unless success\n abort 'FAILED: couldn\\'t execute command (ssh.channel.exec)'\n end\n channel.on_data do |_ch, data|\n stdout_data += data\n puts stdout_data\n end\n\n channel.on_extended_data do |_ch, _type, data|\n stderr_data += data\n puts stderr_data\n end\n\n channel.on_request('exit-status') do |_ch, data|\n exit_code = data.read_long\n end\n\n channel.on_request('exit-signal') do |_ch, data|\n exit_signal = data.read_long\n end\n end\n end\n ssh.loop\n [stdout_data, stderr_data, exit_code, exit_signal]\nend",
"def ssh_exec!(ssh, command)\n\n stdout_data = \"\"\n stderr_data = \"\"\n exit_code = nil\n exit_signal = nil\n\n ssh.open_channel do |channel|\n channel.exec(command) do |ch, success|\n unless success\n abort \"FAILED: couldn't execute command (ssh.channel.exec)\"\n end\n channel.on_data do |ch,data|\n stdout_data+=data\n end\n\n channel.on_extended_data do |ch,type,data|\n stderr_data+=data\n end\n\n channel.on_request(\"exit-status\") do |ch,data|\n exit_code = data.read_long\n end\n\n channel.on_request(\"exit-signal\") do |ch, data|\n exit_signal = data.read_long\n end\n end\n end\n ssh.loop\n\n {\n :out => stdout_data,\n :err => stderr_data,\n :exit_code => exit_code,\n :exit_signal => exit_signal\n }\n end",
"def sh (command, as: user, on: hosts, quiet: false, once: nil)\n self.once once, quiet: quiet do\n log.info \"sh: #{command}\", quiet: quiet do\n hash_map(hosts) do |host|\n host.sh command, as: as, quiet: quiet\n end\n end\n end\n end",
"def ssh_exec!(ssh)\n output_data = ''\n exit_code = nil\n exit_signal = nil\n\n ssh.open_channel do |channel|\n channel.exec(@command) do |ch, success|\n abort \"FAILED: couldn't execute command (ssh.channel.exec)\" unless success\n\n channel.on_data do |_, data|\n output_data += data\n yield data if block_given?\n end\n\n channel.on_extended_data do |_, type, data|\n output_data += data\n yield data if block_given?\n end\n\n channel.on_request('exit-status') { |_, data| exit_code = data.read_long }\n\n channel.on_request('exit-signal') { |_, data| exit_signal = data.read_long }\n end\n end\n\n ssh.loop\n [output_data, exit_code, exit_signal]\n end",
"def remote_command(command, password = nil)\n Net::SSH.start(remote_ip, 'git', :password => password) do |ssh|\n output = ssh.exec!(\"cd #{remote_app_name}\")\n unless output =~ /No such file or directory/\n ssh.exec(\"cd #{remote_app_name} && #{command}\")\n else\n puts \"Your application has not yet been deployed to your Webby.\"\n puts \"To issue remote commands from the Webby, you must first push your application.\"\n end\n end\n end",
"def run!\n ssh commands(:default)\n end",
"def executeCommand(command, dryRun)\n #N Without this, the command won't be echoed to the user\n puts \"EXECUTE: #{command}\"\n #N Without this check, the command will be executed, even though it is intended to be a dry run\n if not dryRun\n #N Without this, the command won't be executed (when it's not a dry run)\n system(command)\n #N Without this, a command that fails with error will be assumed to have completed successfully (which will result in incorrect assumptions in some cases about what has changed as a result of the command, e.g. apparently successful execution of sync commands would result in the assumption that the remote directory now matches the local directory)\n checkProcessStatus(command)\n end\n end",
"def ssh_exec(executable, dir = Rails.application.config.vm_benchmark_dir, log = Rails.application.config.vm_error_log_file)\n shell_cmd = ssh_shell_cmd(executable, dir, log)\n shell(shell_cmd, dir: @vagrant_dir)\n end",
"def run_command(cmd, *options, **shellout_options)\n so = Mixlib::ShellOut.new(create_command(cmd, *options), shellout_options)\n so.run_command\n so.error!\n so\n rescue Mixlib::ShellOut::ShellCommandFailed => e\n # Knife commands can include the password, so show a redacted version\n # of the command line along with the exit code, instead of the mixlib output\n pwd_index = options.index(\"--ssh-password\")\n options[pwd_index+1] = \"(hidden)\" if pwd_index && options.length > pwd_index+1\n redacted_cmd = create_command(cmd, options)\n message = \"#{redacted_cmd} returned #{so.exitstatus}\"\n if so.stderr\n message += \"\\n***********\\n\"\n message += so.stderr\n message += \"***********\\n\"\n end\n raise Runner::Exceptions::KnifeCommandFailed.new(message)\n end",
"def ssh_exec_simple!(ssh, command, print_no_chain) \n out, err, exit_code = ssh_exec!(ssh, command, print_no_chain)\n abort err if exit_code != 0\n\n # try converting the output to prettified JSON.\n begin\n parsed = JSON.parse(out) \n return JSON.pretty_generate(parsed)\n rescue\n # otherwise, just return the string as-is.\n return out\n end\nend",
"def ssh_cmd cmd, options=nil\n options ||= {}\n\n flags = [*options[:flags]].concat @ssh_flags\n\n [\"ssh\", flags, @host, cmd].flatten.compact\n end",
"def !(*commands)\n options = commands.last.is_a?(Hash) ? commands.pop : {}\n\n commands.unshift(\"cd #{options[:base_path]}\") if options[:base_path]\n\n ssh_command = ssh_command(commands, config)\n\n log(:info, ssh_command)\n\n clear_inject\n response = nil\n\n if options.fetch(:interactive, false)\n response = system(ssh_command)\n else\n response = `#{ssh_command}`\n end\n log(:debug, \"SSH Response: #{response.to_s}\")\n\n response\n end",
"def container_ssh_command\n # Get the container's SSH info\n info = @machine.ssh_info\n return nil if !info\n info[:port] ||= 22\n\n # Make sure our private keys are synced over to the host VM\n ssh_args = sync_private_keys(info).map do |path|\n \"-i #{path}\"\n end\n\n # Use ad-hoc SSH options for the hop on the docker proxy \n if info[:forward_agent]\n ssh_args << \"-o ForwardAgent=yes\"\n end\n ssh_args.concat([\"-o Compression=yes\",\n \"-o ConnectTimeout=5\",\n \"-o StrictHostKeyChecking=no\",\n \"-o UserKnownHostsFile=/dev/null\"])\n\n # Build the SSH command\n \"ssh #{info[:username]}@#{info[:host]} -p#{info[:port]} #{ssh_args.join(\" \")}\"\n end",
"def provision_execute(s, commands)\n errors = []\n return errors if (commands.nil? or commands.empty?)\n \n if (!get_field(\"cloud_ips\").nil? and !get_field(\"cloud_ips\").empty?)\n host = get_field(\"cloud_ips\")[0]\n elsif (!get_field(\"cloud_private_ips\").nil? and !get_field(\"cloud_private_ips\").empty?)\n host = get_field(\"cloud_private_ips\")[0]\n else\n msg = \"No IP address associated to the machine #{host} - cannot run SSH command\"\n errors << msg\n log_output(msg, :info)\n return errors\n end\n \n ssh_password = get_field('ssh_password')\n ssh_options = {}\n msg = \"Running SSH Commands On New Machine #{s.username}@#{host}\"\n msg_options = {}\n if (ssh_password and !ssh_password.empty?)\n ssh_options[:password] = ssh_password\n msg_options[:password] = \"*\" * ssh_password.size\n end\n msg_options[:private_key_path] = s.private_key_path if s.private_key_path\n msg_options[:private_key] = mask_private_key(s.private_key.strip) if s.private_key # show only last 5 chars\n log_output(\"#{msg} using #{msg_options}: #{commands.join(\", \")}\", :info)\n\n for i in 1..10\n begin\n log_output(\"[#{host}] Running Commands:\\n #{commands.join(\"\\n \")}\\n\")\n responses = s.ssh(commands, ssh_options) do |data, extended_data|\n write_output(data, :buffer => true) unless data.empty? #stdout\n write_output(extended_data, :buffer => true) unless extended_data.empty? #stderr\n end\n\n responses.each do |result|\n if result.status != 0\n msg = \"[#{host}] Command '#{result.command}' failed with status #{result.status}\"\n errors << msg\n log_output(msg, :info)\n end\n end unless responses.nil?\n break\n rescue Errno::EHOSTUNREACH, Timeout::Error, Errno::ECONNREFUSED, Errno::ETIMEDOUT, Net::SSH::Disconnect => e\n log_output(\"[#{host}] Try #{i} - failed to connect: #{e}, retrying...\", :info)\n if i+1 > 10\n msg = \"[#{host}] Could not connect to remote machine after 10 attempts\"\n errors << msg\n log_output(msg, :warn)\n else\n sleep 5\n next\n end\n rescue Net::SSH::AuthenticationFailed => e\n log_output(\"[#{host}] Try #{i} - failed to connect: authentication failed for user #{e.message}, retrying...\", :info)\n if i+1 > 10\n msg = \"[#{host}] Could not connect to remote machine after 10 attempts, authentication failed for user #{e.message}\"\n errors << msg\n log_output(msg, :warn)\n else\n sleep 5\n next\n end\n end\n end\n return errors\n end",
"def ssh(path_of_servers, command)\n _path_of_servers = path_of_servers.dup\n remove_first_localhost!(_path_of_servers)\n Open3.capture3(ssh_str(_path_of_servers, command))\n end",
"def ssh\n @ssh ||= @remote.connect\n @remote\n end",
"def ssh(*arguments)\n options = []\n\n # Add the -p option if an alternate destination port is given\n if @uri.port\n options += ['-p', @uri.port.to_s]\n end\n\n # append the SSH URI\n options << ssh_uri\n\n # append the additional arguments\n arguments.each { |arg| options << arg.to_s }\n\n return system('ssh',*options)\n end",
"def ssh_execute(server, username, password, key, cmd)\n return lambda {\n exit_status = 0\n result = []\n\n params = {}\n params[:password] = password if password\n params[:keys] = [key] if key\n\n begin\n Net::SSH.start(server, username, params) do |ssh|\n puts \"Connecting to #{server}\"\n ch = ssh.open_channel do |channel|\n # now we request a \"pty\" (i.e. interactive) session so we can send data\n # back and forth if needed. it WILL NOT WORK without this, and it has to\n # be done before any call to exec.\n\n channel.request_pty do |ch_pty, success|\n raise \"Could not obtain pty (i.e. an interactive ssh session)\" if !success\n end\n\n channel.exec(cmd) do |ch_exec, success|\n puts \"Executing #{cmd} on #{server}\"\n # 'success' isn't related to bash exit codes or anything, but more\n # about ssh internals (i think... not bash related anyways).\n # not sure why it would fail at such a basic level, but it seems smart\n # to do something about it.\n abort \"could not execute command\" unless success\n\n # on_data is a hook that fires when the loop that this block is fired\n # in (see below) returns data. This is what we've been doing all this\n # for; now we can check to see if it's a password prompt, and\n # interactively return data if so (see request_pty above).\n channel.on_data do |ch_data, data|\n if data =~ /Password:/\n password = get_sudo_pw unless !password.nil? && password != \"\"\n channel.send_data \"#{password}\\n\"\n elsif data =~ /password/i or data =~ /passphrase/i or\n data =~ /pass phrase/i or data =~ /incorrect passphrase/i\n input = get_input_for_pw_prompt(data)\n channel.send_data \"#{input}\\n\"\n else\n result << data unless data.nil? or data.empty?\n end\n end\n\n channel.on_extended_data do |ch_onextdata, type, data|\n print \"SSH command returned on stderr: #{data}\"\n end\n\n channel.on_request \"exit-status\" do |ch_onreq, data|\n exit_status = data.read_long\n end\n end\n end\n ch.wait\n ssh.loop\n end\n if $debug\n puts \"==================================================\\nResult from #{server}:\"\n puts result.join\n puts \"==================================================\"\n end\n rescue Net::SSH::AuthenticationFailed\n exit_status = 1\n puts \"Bad username/password combination\"\n rescue Exception => e\n exit_status = 1\n puts e.inspect\n puts e.backtrace\n puts \"Can't connect to server\"\n end\n\n return exit_status\n }\n end",
"def remote_shell args\n remote(args) do |ssh|\n command = true\n while command\n print \"> \"\n command = gets\n if command\n result = ssh.exec! command\n puts result.split(\"\\n\").awesome_inspect if not result.nil?\n end\n end\n ssh.exec! \"exit\"\n end\n end",
"def ssh_command(com, username, pass)\n Net::SSH.start(SERVER, username, {:password => pass}) do |ssh|\n ssh.exec! com\n end\n end",
"def ssh_script(hostspec, script, arguments: nil, callback: nil)\n CommandRunner.instance.ssh_script hostspec, script, arguments: arguments, callback: callback\n end",
"def ssh_primary(host, cmd, cf)\n \n user = cf.get_user\n pass = cf.get_passwd\n\n begin\n ssh = Net::SSH.start(host, user, :password => pass)\n out = ssh.exec!(cmd)\n ssh.close\n puts out\n rescue StandardError => e\n puts e.to_s\n end \n\nend",
"def ssh_command(ssh_info)\n command_options = %W[\n -o Compression=yes\n -o DSAAuthentication=yes\n -o LogLevel=#{ssh_info[:log_level] || 'FATAL'}\n -o StrictHostKeyChecking=no\n -o UserKnownHostsFile=/dev/null\n ]\n\n if ssh_info[:forward_x11]\n command_options += %w[\n -o ForwardX11=yes\n -o ForwardX11Trusted=yes\n ]\n end\n\n if ssh_info[:forward_agent]\n command_options += %w[-o ForwardAgent=yes]\n end\n\n ssh_info[:private_key_path].each do |path|\n command_options += ['-i', path]\n end\n\n if ssh_info[:port]\n command_options += ['-p', ssh_info[:port]]\n end\n\n \"ssh #{command_options.join(' ')}\"\n end",
"def run(host, command, options = {})\n execute(__method__, host, command, options)\n end",
"def command(args = {}, escape = true)\n SSH.command compile(args), escape\n end",
"def ssh(*args)\n options = []\n\n # Add the -p option if an alternate destination port is given\n if @uri.port\n options += ['-p', @uri.port.to_s]\n end\n\n options << ssh_uri\n options += args\n\n return system('ssh',*options)\n end",
"def exec(command, stdin = nil)\n\t exit_status = 0 # define variable so that it will be available in the block at method scope\n\t @ssh_session.open_channel do |ch|\n\t @@logger.info(\"Executing command '#{command}'\")\n\t ch.exec(command) do|ch, success|\n\n if success then\n\t @@logger.debug(\"Command sucessfully executed\")\n ch.on_data() do|ch, data|\n #process_stdout(data) unless data\n @stdout_handler.call(data) unless @stdout_handler.nil? or data.nil?\n end\n ch.on_extended_data() do|ch, type, data|\n @stderr_handler.call(data) unless @stderr_handler.nil? or data.nil?\n end\n ch.on_request \"exit-status\" do|ch, data|\n exit_status = data.read_long unless data.nil?\n end\n ch.on_close do |ch|\n @close_handler.call() unless @close_handler.nil?\n end\n ch.on_eof do |ch|\n @close_handler.call() unless @close_handler.nil?\n end\n\n ch.send_data stdin if stdin\n else\n\t @@logger.debug(\"\")\n exit_status = 127\n end\n end\n\t ch.wait\n\t end\n\t\n\t return exit_status\n\tend",
"def exec_new(command, stdin = nil)\n\t exit_status = 0 # define variable so that it will be available in the block at method scope\n\t channel = @ssh_session.open_channel do |ch|\n\t ch.exec(command) do|ch, success|\n\n if success then\n\t @@logger.info(\"SshConnection: starts executing '#{command}'\")\n ch.on_data() do|ch, data|\n #process_stdout(data) unless data\n @stdout_handler.call(data) unless @stdout_handler.nil? or data.nil?\n end\n ch.on_extended_data() do|ch, type, data|\n @stderr_handler.call(data) unless @stderr_handler.nil? or data.nil?\n end\n ch.on_request \"exit-status\" do|ch, data|\n exit_status = data.read_long unless data.nil?\n\t @@logger.info(\"SshConnection.on_request: process terminated with exit-status: #{exit_status}\")\n\t if exit_status != 0\n\t @@logger.error(\"SshConnection.on_request: Remote command execution failed with code: #{exit_status}\")\n\t end\n end\n\t ch.on_request \"exit-signal\" do |ch, data|\n\t @@logger.info(\"SshConnection.on_request: process terminated with exit-signal: #{data.read_string}\")\n\t end\n ch.on_close do |ch|\n\t @@logger.info(\"SshConnection.on_close: remote end is closing!\")\n #@close_handler.call() unless @close_handler.nil?\n end\n ch.on_eof do |ch|\n\t @@logger.info(\"SshConnection.on_eof: remote end is done sending data\")\n #@close_handler.call() unless @close_handler.nil?\n end\n\t ch.on_open_failed do |ch, code, desc|\n\t @@logger.info(\"SshConnection.on_open_failed: code=#{code} desc=#{desc}\")\n\t end\n\t ch.on_process do |ch|\n\t #@@logger.debug(\"SshConnection.on_process; send line-feed/sleep\")\n\t ch.send_data(\"\\n\")\n\t end\n\n #ch.send_data stdin if stdin\n else\n\t @@logger.debug(\"SshConnection: the remote command could not be invoked!\")\n exit_status = 127\n end\n end\n\t #ch.wait\n\t end\n\t channel.wait\n\t return exit_status\n\tend",
"def ssh_shell_cmd(executable, dir, log)\n # NOTE: We cannot use && between cd and nohup because this doesn't work together with non-blocking commands\n \"vagrant ssh -- \\\"cd '#{dir}';\n nohup './#{executable}' >/dev/null 2>>'#{log}' </dev/null &\\\"\"\n end",
"def run( command, expected_exitcode = 0, sudo = self.uses_sudo? )\n\n cmd = {\n :command => command,\n :sudo => sudo,\n :stdout => String.new,\n :stderr => String.new,\n :expected_exitcode => Array( expected_exitcode ),\n :exitcode => nil,\n :final_command => sudo ? sprintf( 'sudo bash -c \"%s\"', command ) : command,\n }\n\n if @ssh.nil?\n self.connect_ssh_tunnel\n end\n\n @logger.info( sprintf( 'vm running: [%s]', cmd[:final_command] ) ) # TODO decide whether this should be changed in light of passthroughs.. 'remotely'?\n\n 0.upto(@retries) do |try|\n begin\n if self.is_passthrough? and self.passthrough[:type].eql?(:local)\n cmd[:stdout] = `#{cmd[:final_command]}`\n cmd[:exitcode] = $?\n else\n cmd = remote_exec( cmd )\n end\n break\n rescue => e\n @logger.error(sprintf('failed to run [%s] with [%s], attempt[%s/%s]', cmd[:final_command], e, try, retries)) if self.retries > 0\n sleep 10 # TODO need to expose this as a variable\n end\n end\n\n if cmd[:stdout].nil?\n cmd[:stdout] = \"error gathering output, last logged output:\\nSTDOUT: [#{self.get_ssh_stdout}]\\nSTDERR: [#{self.get_ssh_stderr}]\"\n cmd[:exitcode] = 256\n elsif cmd[:exitcode].nil?\n cmd[:exitcode] = 255\n end\n\n self.ssh_stdout.push( cmd[:stdout] )\n self.ssh_stderr.push( cmd[:stderr] )\n self.ssh_exitcode.push( cmd[:exitcode] )\n @logger.debug( sprintf( 'ssh_stdout: [%s]', cmd[:stdout] ) )\n @logger.debug( sprintf( 'ssh_stderr: [%s]', cmd[:stderr] ) )\n\n unless cmd[:expected_exitcode].member?( cmd[:exitcode] )\n # TODO technically this could be a 'LocalPassthroughExecutionError' now too if local passthrough.. should we update?\n raise RemoteExecutionError.new(\"stdout[#{cmd[:stdout]}], stderr[#{cmd[:stderr]}], exitcode[#{cmd[:exitcode]}], expected[#{cmd[:expected_exitcode]}]\")\n end\n\n cmd[:stdout]\n end",
"def ssh_action(command, id, host, action)\n command_exe = SSHCommand.run(command, host, log_method(id))\n\n if command_exe.code == 0\n result = :success\n else\n result = :failure\n end\n\n send_message(ACTION[action],RESULT[result],id)\n end",
"def run_remote_script(remote_path, ssh_username, run_as_root)\n sudo = run_as_root ? \"sudo \" : \"\"\n commands = [\n \"chmod +x #{remote_path}\",\n \"bash -lc '#{sudo}/usr/bin/env PATH=$PATH #{remote_path}'\"\n ]\n script_output = \"\"\n results = Fog::SSH.new(host, ssh_username, keys: private_keys).run(commands) do |stdout, stderr|\n [stdout, stderr].flatten.each do |data|\n logfile << data\n script_output << data\n end\n end\n result = results.last\n result_success = result.status == 0\n [script_output, result_success]\n end",
"def exec(command, input = nil)\n result = command_results.build\n result.start! command, input\n exit_code = nil\n ssh_channel = @net_ssh.open_channel do |channel|\n channel.exec command do |_, success|\n if success\n channel.send_data input if input\n channel.eof!\n channel.on_data do |_, data|\n result.append_to_stdout! data\n end\n channel.on_extended_data do |_, type, data|\n result.append_to_stderr! data if type == :stderr\n end\n channel.on_request 'exit-status' do |_, data|\n exit_code = data.read_long\n end\n channel.on_request 'exit-signal' do |_, data|\n # TODO(pwnall): ammend CommandResult to record this properly\n exit_code = data.read_long\n end\n else\n # TODO(pwnall): ammend CommandResult to record this properly\n exit_code = 255\n channel.close\n end\n end\n end\n ssh_channel.wait\n result.completed! exit_code || 0\n end",
"def build_remote_cmd cmd, options={}\n cmd = sh_cmd cmd\n cmd = env_cmd cmd\n cmd = sudo_cmd cmd, options\n cmd = ssh_cmd cmd, options\n end",
"def run_command(machine, command, logger = @log)\n logger.info(\"Running command '#{command}' on the '#{machine['network']}' machine\")\n within_ssh_session(machine) do |connection|\n ssh_exec(connection, command, logger)\n end\n end",
"def run_command(user, host, cmd)\n ping(user, host) do\n my_text = IO.popen(\"ssh #{user}@#{host} 'bash'\", \"w+\")\n my_text.write(cmd)\n my_text.close_write\n my_rtn = my_text.readlines.join('\\n')\n Process.wait(my_text.pid)\n my_text.close\n return my_rtn\n end\n end",
"def exec(command, options={})\n return destination_server.run(command, options)\n end",
"def ssh\n @_ssh ||= Net::SSH.start(host, user, options)\n end",
"def call command_str, options={}, &block\n Sunshine.logger.info @host, \"Running: #{command_str}\" do\n execute build_remote_cmd(command_str, options), &block\n end\n end",
"def psexec(host, command)\n exec = \"psexec \\\\\\\\#{Array(host).join ','}\"\n if @options[:user]\n exec << \" -u \\\"#{@options[:user]}\\\"\"\n @options[:password] = ask(\"--> Enter password for #{@options[:user]}@#{host}: \") {|q| q.echo = '*'} unless @options[:password]\n exec << \" -p \\\"#{@options[:password]}\\\"\"\n end\n exec << \" /accepteula\"\n exec << \" cmd /c \\\"#{command}\\\"\"\n exec << ' > NUL 2>&1' unless logger.debug?\n logger.debug \"--> #{exec}\"\n system exec\n raise \"Failed to execute command \\\"#{command}\\\" on host: #{host}\" if $?.to_i != 0\n end",
"def remote_exec(cmd)\n req = JsonRequest.new(\"remote_exec:exec\", [@agent_id, cmd])\n res = Bixby.client.exec_api(req)\n assert res\n assert_kind_of JsonResponse, res\n assert res.success?\n\n cr = CommandResponse.from_json_response(res)\n assert cr\n assert cr.success?, \"remote exec should succeed\"\n cr\n end",
"def open_ssh([email protected])\n command = ssh_cli_string(id)\n exec(command)\n end",
"def exec(cmd, server_name = \"*\")\n user = 'deploy'\n output = {}\n threads = []\n\n servers.each_pair do |name, server|\n if server_name == \"*\" || (server_name != '*' && server_name == name)\n threads << Thread.new do\n Net::SSH.start(server, user) do |ssh|\n output[name] = ssh.exec!(cmd)\n end\n end\n end\n end\n \n threads.each(&:join)\n output\n end",
"def run_command(*args, &blk)\n debug \"run_command\"\n \n cmd, args = prep_args(*args)\n \n #p [:run_command, cmd, blk.nil?]\n \n connect if !@rye_ssh || @rye_ssh.closed?\n raise Rye::NotConnected, @rye_host unless @rye_ssh && !@rye_ssh.closed?\n \n cmd_clean = Rye.escape(@rye_safe, cmd, args)\n \n # This following is the command we'll actually execute. cmd_clean\n # can be used for logging, otherwise the output is confusing.\n cmd_internal = prepend_env(cmd_clean)\n \n # Add the current working directory before the command if supplied. \n # The command will otherwise run in the user's home directory.\n if @rye_current_working_directory\n cwd = Rye.escape(@rye_safe, 'cd', @rye_current_working_directory)\n cmd_internal = '(%s; %s)' % [cwd, cmd_internal]\n end\n \n # ditto (same explanation as cwd)\n if @rye_current_umask\n cwd = Rye.escape(@rye_safe, 'umask', @rye_current_umask)\n cmd_internal = [cwd, cmd_internal].join(' && ')\n end\n \n ## NOTE: Do not raise a CommandNotFound exception in this method.\n # We want it to be possible to define methods to a single instance\n # of Rye::Box. i.e. def rbox.rm()...\n # can? returns the methods in Rye::Cmd so it would incorrectly\n # return false. We could use self.respond_to? but it's possible\n # to get a name collision. I could write a work around but I think\n # this is good enough for now. \n ## raise Rye::CommandNotFound unless self.can?(cmd)\n \n begin\n debug \"COMMAND: #{cmd_internal}\"\n\n if !@rye_quiet && @rye_pre_command_hook.is_a?(Proc)\n @rye_pre_command_hook.call(cmd_clean, user, host, nickname) \n end\n \n rap = Rye::Rap.new(self)\n rap.cmd = cmd_clean\n \n channel = net_ssh_exec!(cmd_internal, &blk)\n \n if channel[:exception]\n rap = channel[:exception].rap\n else\n rap.add_stdout(channel[:stdout].read || '')\n rap.add_stderr(channel[:stderr].read || '')\n rap.add_exit_status(channel[:exit_status])\n rap.exit_signal = channel[:exit_signal]\n end\n \n debug \"RESULT: %s \" % [rap.inspect]\n \n # It seems a convention for various commands to return -1\n # when something only mildly concerning happens. (ls even \n # returns -1 for apparently no reason sometimes). Anyway,\n # the real errors are the ones that are greater than zero.\n raise Rye::Err.new(rap) if rap.exit_status != 0\n \n rescue Exception => ex\n return rap if @rye_quiet\n choice = nil\n @rye_exception_hook.each_pair do |klass,act|\n next unless ex.kind_of? klass\n choice = act.call(ex, cmd_clean, user, host, nickname)\n break\n end\n if choice == :retry\n retry\n elsif choice == :skip\n # do nothing\n elsif choice == :interactive && !@rye_shell\n @rye_shell = true\n previous_state = @rye_sudo\n disable_sudo\n bash\n @rye_sudo = previous_state\n @rye_shell = false\n elsif !ex.is_a?(Interrupt)\n raise ex, ex.message\n end\n end\n \n if !@rye_quiet && @rye_post_command_hook.is_a?(Proc)\n @rye_post_command_hook.call(rap)\n end\n \n rap\n end",
"def interactive_ssh(run=true)\n debug \"interactive_ssh with keys: #{@rye_opts[:keys].inspect}\"\n run = false unless STDIN.tty?\n args = []\n @rye_opts[:keys].each { |key| args.push *[:i, key] }\n args << \"#{@rye_user}@#{@rye_host}\"\n cmd = Rye.prepare_command(\"ssh\", args)\n return cmd unless run\n system(cmd)\n end",
"def deploy\n system %Q[ssh -lroot \"#{server}\" <<'EOF'\n \tcat >\"#{remote_script_name}\" <<'EOS'\n#{generate}EOS\nchmod +x \"#{remote_script_name}\"\nsource \"#{remote_script_name}\"\nEOF\n ]\n end",
"def over_ssh(opts = {})\n raise 'MissingSSHHost' unless opts[:host]\n raise 'MissingSSHUser' unless opts[:user]\n opts[:timeout] ||= 300 # default to a 5 minute timeout\n\n remote = Rye::Box.new(\n opts[:host],\n user: opts[:user],\n auth_methods: ['publickey'],\n password_prompt: false,\n error: STDOUT # send STDERR to STDOUT for things that actually print\n )\n\n exception = nil\n\n # Getting serious about not crashing Lita...\n output = begin\n # pass our host back to the user to work with\n Timeout.timeout(opts[:timeout]) { yield remote }\n rescue Rye::Err, Timeout::Error => e\n exception = e\n ensure\n remote.disconnect\n end\n\n calculate_result(output, exception)\n end",
"def ssh_ruby(host, username, command, compression=false, request_pty=false, &block)\n debug \"Opening Net::SSH connection to #{host}, #{username}, #{command}\"\n exit_status = 0\n options = {:compression => compression}\n options[:verbose] = :debug if debug?\n Net::SSH.start(host, username, options) do |session|\n #:nocov:\n channel = session.open_channel do |channel|\n if request_pty\n channel.request_pty do |ch, success|\n say \"pty could not be obtained\" unless success\n end\n end\n channel.exec(command) do |ch, success|\n channel.on_data do |ch, data|\n print data\n end\n channel.on_extended_data do |ch, type, data|\n print data\n end\n channel.on_close do |ch|\n debug \"Terminating ... \"\n end\n channel.on_request(\"exit-status\") do |ch, data|\n exit_status = data.read_long\n end\n yield channel if block_given?\n channel.eof!\n end\n end\n session.loop\n #:nocov:\n end\n raise RHC::SSHCommandFailed.new(exit_status) if exit_status != 0\n rescue Errno::ECONNREFUSED => e\n debug_error e\n raise RHC::SSHConnectionRefused.new(host, username)\n rescue Net::SSH::AuthenticationFailed => e\n debug_error e\n raise RHC::SSHAuthenticationFailed.new(host, username)\n rescue SocketError => e\n debug_error e\n raise RHC::ConnectionFailed, \"The connection to #{host} failed: #{e.message}\"\n end",
"def execute(command, options = {})\n options.merge! timeout: 3600, cwd: staging_dir\n shellout!(command, options)\n end",
"def executeCommand(command, dryRun)\n #N Without this, the command won't be echoed\n puts \"EXECUTE: #{command}\"\n #N Without this check, the command will be executed even if it is meant to be a dry run\n if not dryRun\n #N Without this, the command won't actualy be execute even when it is meant to be run\n system(command)\n #N Without this check, a failed command will be treated as if it had executed successfully\n checkProcessStatus(command)\n end\n end"
] | [
"0.7644817",
"0.758081",
"0.7467946",
"0.74653494",
"0.74214137",
"0.7131159",
"0.70903796",
"0.7046067",
"0.69887936",
"0.6958053",
"0.6955614",
"0.6892141",
"0.68638366",
"0.6850241",
"0.6842132",
"0.6804094",
"0.67964673",
"0.6788307",
"0.67848915",
"0.6774967",
"0.67517835",
"0.6733312",
"0.6733312",
"0.6724022",
"0.66528183",
"0.66167647",
"0.6603017",
"0.65805465",
"0.6553167",
"0.6545447",
"0.65427214",
"0.6538518",
"0.6535684",
"0.6521055",
"0.65146536",
"0.6514146",
"0.6512051",
"0.65114385",
"0.64953405",
"0.64911926",
"0.6484235",
"0.6455788",
"0.6441241",
"0.64317244",
"0.64052004",
"0.63906085",
"0.63795847",
"0.63649046",
"0.635332",
"0.634955",
"0.6344921",
"0.63447684",
"0.63278073",
"0.63257074",
"0.63251024",
"0.63193035",
"0.63062364",
"0.62995505",
"0.6298801",
"0.62955046",
"0.6280053",
"0.6247615",
"0.62406695",
"0.6233111",
"0.62275726",
"0.6226709",
"0.62169254",
"0.6197956",
"0.61878455",
"0.6187527",
"0.61743087",
"0.61605036",
"0.614732",
"0.6124327",
"0.6086526",
"0.6081451",
"0.607508",
"0.6067116",
"0.60669",
"0.6058603",
"0.60497063",
"0.6038138",
"0.6037297",
"0.6035669",
"0.60345095",
"0.60162073",
"0.60150135",
"0.59993166",
"0.5986851",
"0.5956221",
"0.5933789",
"0.592261",
"0.588805",
"0.5869506",
"0.5863726",
"0.5863175",
"0.586072",
"0.5855935",
"0.5855127",
"0.5850219"
] | 0.78252125 | 0 |
list all subdirectories of the base directory on the remote host N Without this we won't have a direct method to list all subdirectories within the remote directory | def listDirectories
return contentHost.listDirectories(baseDir)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def listDirectories(baseDir)\n #N if un-normalised, code assuming '/' at the end might be one-off\n baseDir = normalisedDir(baseDir)\n #N without the command, we don't know what command to execute to list the directories\n command = findDirectoriesCommand(baseDir)\n #N without this, the command won't execute, or we it might execute in a way that doesn't let us read the output\n output = getCommandOutput(command)\n #N without initial directories, we would have nowhere to accumulate the directory relative paths\n directories = []\n #N without the base dir length, we don't know how much to chop off the path names to get the relative path names\n baseDirLen = baseDir.length\n #N without this, would not get feedback that we are listing directories (which might be a slow remote command)\n puts \"Listing directories ...\"\n #N without looping over the output, we wouldn't be reading the output of the listing command\n while (line = output.gets)\n #N without chomping, eoln would be included in the directory paths\n line = line.chomp\n #N without this, would not get feedback about each directory listed\n puts \" #{line}\"\n #N without this check, unexpected invalid output not including the base directory would be processed as if nothing had gone wrong\n if line.start_with?(baseDir)\n #N without this, the directory in this line of output wouldn't be recorded\n directories << line[baseDirLen..-1]\n else\n #N if we don't raise the error, an expected result (probably a sign of some important error) would be ignored\n raise \"Directory #{line} is not a sub-directory of base directory #{baseDir}\"\n end\n end\n #N if we don't close the output, then un-opened output stream objects will accumulate (and leak resources)\n output.close()\n #N if we don't check the process status, then a failed command will be treated as if it had succeeded (i.e. as if there were no directories found)\n checkProcessStatus(command)\n return directories\n end",
"def get_remotes()\n to_return = {}\n count = 1\n num_dirs = Dir.glob('./*/').size() -2 # exclude . and ..\n Dir.glob('./*/').each() do |dir|\n next if dir == '.' or dir == '..'\n\n print \"Processing directories...#{count}/#{num_dirs}\\r\" if !$verbose\n count += 1\n\n if(File.directory?(dir) and File.exists?(dir + '/.git'))\n Dir.chdir dir\n remotes = `git remote -v`.split(\"\\n\")\n\n vprint(dir.ljust(25))\n remotes.each() do |remote|\n if(remote.index('(fetch)'))\n parts = remote.split(\"\\t\")\n\n remote_name = get_remote_name(parts[1])\n vprint(\"[#{parts[0]} #{remote_name}]\".ljust(20))\n if(remote_name != nil)\n index = parts[0] + ' - ' + remote_name\n if(to_return[index] == nil)\n to_return[index] = Array.new()\n end\n to_return[index].push(dir)\n else\n puts \"\\nDon't know what to do with #{remote} in dir #{dir}\"\n end\n end\n end # end remotes loop\n\n vprint \"\\n\"\n Dir.chdir '..'\n end # end if file.directory\n end\n\n print \"\\n\"\n return to_return\nend",
"def listFiles(baseDir)\n #N Without this, the base directory might be missing the final '/', which might cause a one-off error when 'subtracting' the base directory name from the absolute paths to get relative paths\n baseDir = normalisedDir(baseDir)\n #N Without this we wouldn't be executing the command to list all files in the remote directory\n ssh(findFilesCommand(baseDir).join(\" \")) do |line| \n #N Without this we wouldn't be echoing the file name on this line for the user to read\n puts \" #{line}\"\n end\n end",
"def folder_list(command)\n path = '/' + clean_up(command[1] || '')\n resp = @client.files.folder_list(path)\n\n resp.contents.each do |item|\n puts item.path\n end\n end",
"def ls( *args )\r\n \r\n directory = nil\r\n opts = {}\r\n \r\n case args.count\r\n when 1\r\n if args[0].kind_of? Hash\r\n opts = args[0]\r\n else\r\n directory = args[0]\r\n end\r\n when 2\r\n directory = args[0]\r\n opts = args[1] \r\n end\r\n \r\n # args are the RPC arguments ...\r\n args = {}\r\n args[:path] = directory if directory\r\n args[:recursive] = true if opts[:recurse]\r\n args[:detail] = true if opts[:detail] \r\n args.delete(:detail) if( args[:detail] and args[:recursive])\r\n \r\n # RPC output format, default is XML\r\n outf = { :format => 'text' } if opts[:format] == :text\r\n \r\n got = @ndev.rpc.file_list( args, outf )\r\n return nil unless got\r\n \r\n return got.text if opts[:format] == :text\r\n return got if opts[:format] == :xml\r\n \r\n # if we're here, then we need to conver the output \r\n # to a Hash. Joy!\r\n \r\n collect_detail = args[:detail] || args[:recursive]\r\n \r\n ls_hash = {}\r\n got.xpath('directory').each do |dir|\r\n \r\n dir_name = dir.xpath('directory-name').text.strip\r\n dir_hash = {}\r\n \r\n dir_hash[:fileblocks] = dir.xpath('total-file-blocks').text.to_i\r\n files_info = dir.xpath('file-information')\r\n \r\n dir_hash[:files] = {} \r\n dir_hash[:dirs] = {} # sub-directories\r\n \r\n files_info.each do |file|\r\n f_name = file.xpath('file-name').text.strip\r\n f_h = {} \r\n \r\n if file.xpath('file-directory')[0]\r\n dir_hash[:dirs][f_name] = f_h\r\n else\r\n dir_hash[:files][f_name] = f_h \r\n end\r\n \r\n next unless collect_detail\r\n \r\n f_h[:owner] = file.xpath('file-owner').text.strip\r\n f_h[:group] = file.xpath('file-group').text.strip\r\n f_h[:links] = file.xpath('file-links').text.to_i\r\n f_h[:size] = file.xpath('file-size').text.to_i\r\n \r\n xml_when_item(file.xpath('file-symlink-target')) { |i|\r\n f_h[:symlink] = i.text.strip\r\n }\r\n \r\n fp = file.xpath('file-permissions')[0]\r\n f_h[:permissions_text] = fp.attribute('format').value\r\n f_h[:permissions] = fp.text.to_i\r\n \r\n fd = file.xpath('file-date')[0]\r\n f_h[:date] = fd.attribute('format').value\r\n f_h[:date_epoc] = fd.text.to_i\r\n \r\n end # each directory file\r\n ls_hash[ dir_name ] = dir_hash \r\n end # each directory\r\n \r\n return nil if ls_hash.empty?\r\n ls_hash\r\n end",
"def index\n\t\t@directories = []\n\t\troot_directory = Jedd::Directory.joins(:v_user).where(:v_users => {:nick => params[:v_user_nick]}).includes(:jedd_file_nodes).first\n\t\t# root_directory = V::User.find_by_nick(params[:v_user_nick]).jedd_directories.where(:jedd_directory_id => nil).joins(:jedd_directories => [:jedd_file_nodes]).first\n\t\tnot_found unless root_directory\n\n\t\tif root_directory\n\t\t\t@directories << root_directory\n\t\tend\n\tend",
"def listFiles()\n #N Without this the files won't get listed\n contentHost.listFiles(baseDir)\n end",
"def get_remote_files_hierarchy(files, root = '/', hierarchy = { dirs: [], files: [] })\n files.each do |node|\n case node['node_type']\n when 'directory'\n hierarchy[:dirs] << \"#{root}#{node['name']}\"\n get_remote_files_hierarchy(node['files'], root + node['name'] + '/', hierarchy)\n when 'file'\n hierarchy[:files] << \"#{root}#{node['name']}\"\n end\n end\n\n hierarchy\nend",
"def dir_list(path, bases, paging)\n items = paging[:items]\n page = paging[:page]\n offset = paging[:offset]\n raise 'Disabling paging is not supported for a directory listing' if paging[:disable_paging]\n\n max_items = 1000\n\n child_paths, total = FileSystems::Combined.directory_list(path, items, offset, max_items)\n\n children = child_paths.map { |full_path|\n if FileSystems::Combined.directory_exists?(full_path)\n dir_info(full_path, bases)\n else\n raise 'File should exist' unless FileSystems::Combined.file_exists?(full_path)\n\n file_info(full_path)\n end\n }\n\n paging[:total] = total\n paging[:warning] = \"Only first #{max_items} results are available\" if total >= max_items\n\n children\n end",
"def list_folders\n http_get(:uri=>\"/folders\", :fields=>x_cookie)\n end",
"def get_remote_files_hierarchy(files, root = '/', hierarchy = { dirs: [], files: [] })\n files.each do |node|\n case node['node_type']\n when 'directory'\n hierarchy[:dirs] << \"#{root}#{node['name']}\"\n get_remote_files_hierarchy(node['files'], root + node['name'] + '/', hierarchy)\n when 'file'\n hierarchy[:files] << \"#{root}#{node['name']}\"\n end\n end\n\n return hierarchy\nend",
"def list_directories(client)\n client.directories.each do |directory|\n puts \"Directory: #{directory.name}\"\n puts \" Description: #{directory.description}\"\n puts \" Status: #{directory.status}\"\n puts \" Href: #{directory.href}\"\n end\nend",
"def paths_to_pull\n sep = mode == :ssh ? \":\" : \"::\"\n directories.map do |dir|\n \"#{sep}'#{dir.sub(%r{^~/}, \"\").sub(%r{/$}, \"\")}'\"\n end.join(\" \").sub(%r{^#{sep}}, \"\")\n end",
"def retrieve_dirs(_base, dir, dot_dirs); end",
"def list_files\n files = remote_directory.files.map { |file| file.key }\n\n # The first item in the array is only the path an can be discarded.\n files = files.slice(1, files.length - 1) || []\n\n files\n .map { |file| Pathname.new(file).basename.to_s }\n .sort\n .reverse\n end",
"def files_remote_list(options = {})\n options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]\n if block_given?\n Pagination::Cursor.new(self, :files_remote_list, options).each do |page|\n yield page\n end\n else\n post('files.remote.list', options)\n end\n end",
"def listDirectories(baseDir)\n #N Without this, the base directory might be missing the final '/', which might cause a one-off error when 'subtracting' the base directory name from the absolute paths to get relative paths\n baseDir = normalisedDir(baseDir)\n #N Without this, we won't know that directories are about to be listed\n puts \"Listing directories ...\"\n #N Without this, we won't have an empty array ready to accumulate directory relative paths\n directories = []\n #N Without this, we won't know the length of the base directory to remove from the beginning of the absolute directory paths\n baseDirLen = baseDir.length\n #N Without this, the directory-listing command won't be executed\n ssh(findDirectoriesCommand(baseDir).join(\" \")) do |line|\n #N Without this, we won't get feedback about which directories were found\n puts \" #{line}\"\n #N Without this check, we might ignore an error that somehow resulted in directories being listed that aren't within the specified base directory\n if line.start_with?(baseDir)\n #N Without this, the relative path of this directory won't be added to the list\n directories << line[baseDirLen..-1]\n else\n #N Without raising this error, an unexpected directory not in the base directory would just be ignored\n raise \"Directory #{line} is not a sub-directory of base directory #{baseDir}\"\n end\n end\n return directories\n end",
"def test_listedpath\n server = nil\n assert_nothing_raised {\n\n server = Puppet::Network::Handler.fileserver.new(\n\n :Local => true,\n\n :Config => false\n )\n }\n\n\n # create a deep dir\n basedir = tempfile\n testdir = \"#{basedir}/with/some/sub/directories/for/testing\"\n oldfile = File.join(testdir, \"oldfile\")\n assert_nothing_raised {\n system(\"mkdir -p #{testdir}\")\n File.open(oldfile, \"w\") { |f|\n 3.times { f.puts rand(100) }\n }\n @@tmpfiles << basedir\n }\n\n # mounty mounty\n assert_nothing_raised {\n server.mount(basedir, \"localhost\")\n }\n\n list = nil\n # and then check a few dirs\n assert_nothing_raised {\n list = server.list(\"/localhost/with\", :manage, false, false)\n }\n\n assert(list !~ /with/)\n\n assert_nothing_raised {\n list = server.list(\"/localhost/with/some/sub\", :manage, true, false)\n }\n\n assert(list !~ /sub/)\n end",
"def get_remote_files\n manager = @current_source.file_manager\n manager.start do \n @current_source.folders.each do |folder|\n @files[folder] = manager.find_files folder\n @files[folder] = @files[folder].take(@take) if @take\n Logger.<<(__FILE__,\"INFO\",\"Found #{@files[folder].size} files for #{@current_source.base_dir}/#{folder} at #{@current_source.host.address}\")\n SignalHandler.check\n end\n end\n end",
"def get_list(dir = nil)\n @ftp.ls(dir)[3..-1]\n end",
"def list_files_from (path,opts = {})\n safe_fetch do\n list_files = Set.new\n var = \"Search in #{path} at #{@host}... \"\n cmd = \"find #{path}\"\n cmd = \"(cd #{path} && ls \" ### dont know why cd alone doesn't work\n cmd << \"-td */\" if opts[:directories]\n cmd << opts[:regexp] if opts[:regexp]\n cmd << \" 2>/dev/null)\"\n out = @ssh.exec!(cmd)\n list_files = out.split\n list_files = out.split(\"/\\n\") if opts[:directories]\n\n var << \"Found #{list_files.size} entries\\n\"\n Logger.<<(__FILE__,\"INFO\",var)\n list_files\n end\n end",
"def team_folder_list(trace: false, &block)\n r = dropbox_query(query: '2/team/team_folder/list', trace: trace)\n r['team_folders'].each(&block)\n while r['has_more']\n r = dropbox_query(query: '2/team/team_folder/list/continue', query_data: \"{\\\"cursor\\\":\\\"#{r['cursor']}\\\"}\", trace: trace)\n r['team_folders'].each(&block)\n end\n end",
"def get_remote_files_hierarchy(files, root = '/', hierarchy = { dirs: [], files: [] })\n files.each do |node|\n case node['node_type']\n when 'branch'\n get_remote_files_hierarchy(node['files'], root + node['name'] + '/', hierarchy)\n when 'directory'\n hierarchy[:dirs] << \"#{root}#{node['name']}\"\n get_remote_files_hierarchy(node['files'], root + node['name'] + '/', hierarchy)\n when 'file'\n hierarchy[:files] << \"#{root}#{node['name']}\"\n end\n end\n\n return hierarchy\nend",
"def get_files\n fields = \"next_page_token, files(id, name, owners, parents, mime_type, sharedWithMeTime, modifiedTime, createdTime)\"\n\n folders = []\n @files = []\n\n #Go through pages of files and save files and folders\n next_token = nil\n first_page = true\n while first_page || (!next_token.nil? && !next_token.empty?)\n results = @service.list_files(q: \"not trashed\", fields: fields, page_token: next_token)\n folders += results.files.select{|file| file.mime_type == DRIVE_FOLDER_TYPE and belongs_to_me?(file)}\n @files += results.files.select{|file| !file.mime_type.include?(DRIVE_FILES_TYPE) and belongs_to_me?(file)}\n next_token = results.next_page_token\n first_page = false\n end\n\n #Cache folders\n folders.each {|folder| @folder_cache[folder.id] = folder}\n\n #Resolve file paths and apply ignore list\n @files.each {|file| file.path = resolve_path file}\n @files.reject!{|file| Helper.file_ignored? file.path, @config}\n\n Log.log_notice \"Counted #{@files.count} remote files in #{folders.count} folders\"\n end",
"def directories\n directory.directoires\n end",
"def list_files\n [].tap do |files|\n remote_files do |file|\n files << file\n end\n end\n end",
"def remote_ls(*args)\n raise NotImplementedError, \"Subclass must implement remote_ls()\"\n end",
"def findDirectoriesCommand(baseDir)\n #N Without path prefix, wouldn't work if 'find' is not on path, without baseDir, wouldn't know which directory to start, without '-type d' would list more than just directories, without -print, would not print out the values found (or is that the default anyway?)\n return [\"#{@pathPrefix}find\", baseDir, \"-type\", \"d\", \"-print\"]\n end",
"def list(directory = nil)\n @ftp.nlst(directory)\n end",
"def find(dirs); end",
"def list\n Dir.glob(\"#{@directory}/**/*\").reject(&File.directory?).map do |p|\n Pathname.new(p).relative_path_from(@directory)\n end\n end",
"def list\n Lib.list @path, @no_follow\n end",
"def index(base_path, glob = nil)\n\t\tglob = '*' if glob == '' or glob.nil?\n\t\tdirs = []\n\t\tfiles = []\n\t\t::Dir.chdir(base_path) do\n\t\t\t::Dir.glob(glob).each do |fname|\n\t\t\t\tif ::File.directory?(fname)\n\t\t\t\t\tdirs << fname + '/'\n\t\t\t\telse\n\t\t\t\t\tfiles << fname\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tdirs.sort + files.sort\n\trescue Errno::ENOENT\n\t\traise Rush::DoesNotExist, base_path\n\tend",
"def directory_subdirectories(path)\n\tputs ''\n\tfor i in subdir_paths(path)\n\t\tputs i\n\tend\n\tputs ''\n\treturn nil\nend",
"def get_ls(path)\n #repo = @repo\n #head = repo.commits.first\n #tree = head.tree @branch\n\n tree = @repo.tree @branch\n\n #strip trailing /\n path.sub! /[\\/]*$/, ''\n\n # find dir\n while !path.empty?\n tdir = tree / path\n break if tdir.is_a?(Grit::Tree)\n # strip last conponent to /\n path.sub! /(^|\\/)[^\\/]*$/, ''\n end\n\n if path.empty?\n tdir = tree\n else\n path += '/'\n end\n print \"path:\", path, \"\\n\"\n print \"tdir:\", tdir, \"\\n\"\n\n files = tdir.blobs.map do |b|\n { path: \"#{path}#{b.name}\", name: b.name, siz: b.size }\n end\n dirs = tdir.trees.map do |t|\n { path: \"#{path}#{t.name}\", name: t.name}\n end\n if !path.empty?\n dirs.push( { path: path.sub(/(^|\\/)[^\\/]*\\/$/, ''),\n name: '..'} )\n end\n\n [files, dirs, path]\n end",
"def folders\n @conn.list(\"#{@full_name}#{@delim}\", '%').map do |f|\n Folder.new(@conn, f.name, f.delim)\n end\n end",
"def folders\n @conn.list('', '%').map do |f|\n Folder.new(@conn, f.name, f.delim)\n end\n end",
"def send_directory(path, types)\n # TODO: use git ls\n listing = []\n Dir[File.join path, '*'].each { |child|\n stat = File.stat child\n listing << {\n :name => (File.basename child),\n :type => stat.ftype,\n :size => stat.size\n }\n }\n respond listing, types\n end",
"def directories; end",
"def directories; end",
"def test_getfilelist\n server = nil\n testdir, pattern, tmpfile = mktestdir\n\n file = nil\n\n assert_nothing_raised {\n\n server = Puppet::Network::Handler.fileserver.new(\n\n :Local => true,\n\n :Config => false\n )\n }\n\n assert_nothing_raised {\n server.mount(testdir, \"test\")\n }\n\n # get our listing\n list = nil\n sfile = \"/test/tmpfile\"\n assert_nothing_raised {\n list = server.list(sfile, :manage, true, false)\n }\n\n output = \"/\\tfile\"\n\n # verify it got listed as a file\n assert_equal(output, list)\n\n # verify we got all fields\n assert(list !~ /\\t\\t/)\n\n # verify that we didn't get the directory itself\n list.split(\"\\n\").each { |line|\n assert(line !~ %r{remotefile})\n }\n\n # and then verify that the contents match\n contents = File.read(tmpfile)\n\n ret = nil\n assert_nothing_raised {\n ret = server.retrieve(sfile)\n }\n\n assert_equal(contents, ret)\n end",
"def ls(path = '/')\n dirlist = []\n @sftp.dir.foreach(path) do |element|\n dirlist << element\n end\n return dirlist\n end",
"def get_entries(dir, subfolder); end",
"def list_files_from path,opts = {}\n unless Dir.exists? path\n Logger.<<(__FILE__,\"ERROR\",\"Local fetcher: path does not exists for listing... #{path} \")\n raise \"Error LocalFileFetcher !\"\n end\n if opts[:directories]\n cmd = \"ls -td #{path}/*/\"\n else\n cmd = \"ls #{path}\"\n cmd += \"/#{opts[:regexp]}\" if opts[:regexp]\n end\n out = `#{cmd}`\n return out.split(\"\\n\")\n end",
"def pull_files(remote_path,local_path)\n debug_p(\"pull_files from #{remote_path} to #{local_path}\")\n @sftp_session.dir.foreach(remote_path){ |path|\n #unless path.name == \".\" || path.name == \"..\"\n #not directory\n unless /^d/ =~ path.longname\n @sftp_session.download!(remote_path + \"/\" + path.name,local_path + \"/\" + path.name)\n end\n #end\n }\n end",
"def list(path='root')\n puts \"#list('#{path}')\"\n listed_files =[]\n @drive.folder = path\n children = @drive.children\n list_files_metadata(children)\n raise 'There are no files in directory' if children.count < 1\n children.each do |item|\n listed_files << \"#{item.path.gsub('/drive/', 'drive/')}/#{item.name}\" unless item.folder?\n end\n @logger.info 'Children list acquired.'\n pp listed_files\n end",
"def list\n require_public = ( params[:user].nil? ? false : true )\n user = ( params[:user].nil? ? session[:user] : User.first(id: params[:user]) )\n raise RequestError.new(:bad_params, \"User does not exist\") unless user\n raise RequestError.new(:bad_params, \"Depth not valid\") if params[:depth].to_i < 0\n depth = (params[:depth] ? params[:depth].to_i : -1)\n xfile = ( params[:id].nil? ? user.root_folder : WFolder.get(params[:id]) )\n raise RequestError.new(:internal_error, \"No root directory. Please contact your administrator\") if xfile.nil? && params[:id].nil?\n raise RequestError.new(:folder_not_found, \"File or folder not found\") if xfile.nil?\n if (require_public && params[:id] && session[:user].admin == false) then\n raise RequestError.new(:folder_not_public, \"Folder is not public\") if xfile.folder == true && xfile.public == false\n raise RequestError.new(:folder_not_public, \"File is not public\") if xfile.folder == false && xfile.public == false\n end\n if xfile.folder then\n @result = { folder: crawl_folder(xfile, require_public, depth), success: true }\n else \n @result = { file: xfile.description(session[:user]) , success: true }\n end\n end",
"def get_dir_listing( sftp, dir)\n list = []\n\n sftp.dir.foreach(dir) do |entry|\n list << entry.name\n end\n\n Set.new(list)\n end",
"def rip_folders()\n if @version >= IOS_VERSION_9\n @database.execute(\"SELECT ZICCLOUDSYNCINGOBJECT.Z_PK \" + \n \"FROM ZICCLOUDSYNCINGOBJECT \" + \n \"WHERE ZICCLOUDSYNCINGOBJECT.ZTITLE2 IS NOT NULL\") do |row|\n rip_folder(row[\"Z_PK\"])\n end\n end\n\n # In legacy Notes the \"folders\" were \"stores\"\n if @version == IOS_LEGACY_VERSION\n @database.execute(\"SELECT ZSTORE.Z_PK FROM ZSTORE\") do |row|\n rip_folder(row[\"Z_PK\"])\n end\n end\n\n # Loop over all folders to do some clean up\n @folders.each_pair do |key, folder|\n if folder.is_orphan?\n tmp_parent_folder = get_folder(folder.parent_id)\n tmp_parent_folder.add_child(folder)\n @logger.debug(\"Rip Folder: Added folder #{folder.full_name} as child to #{tmp_parent_folder.name}\")\n end\n\n @logger.debug(\"Rip Folders final array: #{key} corresponds to #{folder.name}\")\n end\n\n # Sort the folders if we want to retain the order, group each account together\n if @retain_order\n @folders = @folders.sort_by{|folder_id, folder| [folder.account.sort_order_name, folder.sort_order]}.to_h\n\n # Also organize the child folders nicely\n @folders.each do |folder_id, folder|\n folder.sort_children\n end\n end\n\n end",
"def recurse_remote(children)\n sourceselect = self[:sourceselect]\n\n total = self[:source].collect do |source|\n next unless result = perform_recursion(source)\n return if top = result.find { |r| r.relative_path == \".\" } and top.ftype != \"directory\"\n result.each { |data| data.source = \"#{source}/#{data.relative_path}\" }\n break result if result and ! result.empty? and sourceselect == :first\n result\n end.flatten\n\n # This only happens if we have sourceselect == :all\n unless sourceselect == :first\n found = []\n total.reject! do |data|\n result = found.include?(data.relative_path)\n found << data.relative_path unless found.include?(data.relative_path)\n result\n end\n end\n\n total.each do |meta|\n if meta.relative_path == \".\"\n parameter(:source).metadata = meta\n next\n end\n children[meta.relative_path] ||= newchild(meta.relative_path)\n children[meta.relative_path][:source] = meta.source\n children[meta.relative_path][:checksum] = :md5 if meta.ftype == \"file\"\n\n children[meta.relative_path].parameter(:source).metadata = meta\n end\n\n children\n end",
"def test_listroot\n server = nil\n testdir, pattern, tmpfile = mktestdir\n\n file = nil\n checks = Puppet::Network::Handler.fileserver::CHECKPARAMS\n\n # and make our fileserver\n assert_nothing_raised {\n\n server = Puppet::Network::Handler.fileserver.new(\n\n :Local => true,\n\n :Config => false\n )\n }\n\n # mount the testdir\n assert_nothing_raised {\n server.mount(testdir, \"test\")\n }\n\n # and verify different iterations of 'root' return the same value\n list = nil\n assert_nothing_raised {\n list = server.list(\"/test/\", :manage, true, false)\n }\n\n assert(list =~ pattern)\n\n assert_nothing_raised {\n list = server.list(\"/test\", :manage, true, false)\n }\n assert(list =~ pattern)\n\n end",
"def readdir(handle)\n send_request(FXP_READDIR, :string, handle)\n end",
"def files_for_directory(path)\n directory = find_preferred_file(\n @new_resource.cookbook_name, \n :remote_file, \n path, \n @node[:fqdn],\n @node[:platform],\n @node[:platform_version]\n )\n\n unless (directory && ::File.directory?(directory))\n raise NotFound, \"Cannot find a suitable directory\"\n end\n\n directory_listing = Array.new\n Dir[::File.join(directory, '**', '*')].sort { |a,b| b <=> a }.each do |file|\n next if ::File.directory?(file)\n file =~ /^#{directory}\\/(.+)$/\n directory_listing << $1\n end\n directory_listing\n end",
"def dirs; end",
"def dirs; end",
"def list(client, current_path)\n\n\tfiles = Dir.glob(\"#{current_path}/files/*\")\n\tclient.puts \"\\nList of Files:\"\n\tfiles.each{ |file|\n\tfile.slice! \"#{current_path}/files/\"}\n\tclient.puts files\n\nend",
"def listCmd(cmdSock, sock)\n\tputs \"Client sent a list command\"\n\t#get all files from the directory but ignore hidden . and ..\n\tpath = File.expand_path(\"..\", Dir.pwd) + \"/testFiles\"\n\tdirFiles = Dir.entries(path).reject{|entry| entry == \".\" || entry ==\"..\"}\n\t#tell the client how many files there are\n\tnumFiles = dirFiles.length\n\tcmdSock.puts(numFiles)\n\tputs \"Sent # of files to client\"\n\t#for each file in the directoy\n\tfor fileName in dirFiles\n\t\t#send the filename\n\t\tsock.puts(fileName)\n\tend\n\tputs \"Sent all file names\"\nend",
"def index\n @directories = Directory.all\n end",
"def fetch_children\n @children = []\n for item in self.listex\n if item[\"type\"] == \"folder\" and item[\"id\"]!=@id #sharefile API includes self in list\n @children << ShareFolder.new(item[\"id\"], @authid, false, item)\n elsif item[\"type\"] == \"file\"\n @children << ShareFile.new(item[\"id\"], @authid, item)\n end\n end\n end",
"def fetch_children\n @children = []\n for item in self.listex\n if item[\"type\"] == \"folder\" and item[\"id\"]!=@id #sharefile API includes self in list\n @children << Folder.new(item[\"id\"], @authid, @subdomain, false, item)\n elsif item[\"type\"] == \"file\"\n @children << File.new(item[\"id\"], @authid, @subdomain, item)\n end\n end\n end",
"def list(path=nil, sha=nil)\n remote_path = list_path(path).sub(/^\\//, '').sub(/\\/$/, '')\n\n result = @client.tree(repo, sha || source_branch, recursive: true).tree\n result.sort! do |x, y|\n x.path.split('/').size <=> y.path.split('/').size\n end\n\n # Filters for folders containing the specified path\n result.reject! { |elem| !elem.path.match(remote_path + '($|\\/.+)') }\n raise Error, 'Invalid GitHub path specified' if result.empty?\n\n # Filters out lower levels\n result.reject! do |elem|\n filename = elem.path.split('/').last\n File.join(remote_path, filename).sub(/^\\//, '') != elem.path\n end\n\n result.map do |elem|\n {\n name: elem.path.split('/').last,\n path: elem.path,\n type: elem.type == 'tree' ? 'folder' : 'file',\n sha: elem.sha\n }\n end\n end",
"def recurse\n children = (self[:recurse] == :remote) ? {} : recurse_local\n\n if self[:target]\n recurse_link(children)\n elsif self[:source]\n recurse_remote(children)\n end\n\n # If we're purging resources, then delete any resource that isn't on the\n # remote system.\n mark_children_for_purging(children) if self.purge?\n\n # REVISIT: sort_by is more efficient?\n result = children.values.sort { |a, b| a[:path] <=> b[:path] }\n remove_less_specific_files(result)\n end",
"def pull_files(localpath, remotepath, filelist)\n connect!\n filelist.each do |f|\n localdir = File.join(localpath, File.dirname(f))\n FileUtils.mkdir_p localdir unless File.exist?(localdir)\n @connection.get \"#{remotepath}/#{f}\", File.join(localpath, f)\n log \"Pulled file #{remotepath}/#{f}\"\n end\n close!\n end",
"def list_nodes\n nodes = @vcenter['destfolder'].to_s + \"\\n\"\n @components.each do |component, _config|\n (1..@components[component]['count']).each do |i|\n nodes += @components[component]['addresses'][i - 1].ljust(18, ' ') +\n node_name(component, i) + @vcenter['domain'] + ' ' +\n @components[component]['runlist'].to_s + \"\\n\"\n end\n end\n nodes\n end",
"def directory(path, offset = 0, rev = nil)\n begin\n invoke(Request.new(:path => path, :rev => rev, :offset => offset, :verb => Request::Verb::GETDIR))\n rescue RubyDoozer::ResponseError => exc\n raise exc unless exc.message.include?('RANGE')\n nil\n end\n end",
"def getDirs dir\n\t\tFind.find(dir)\t\n\tend",
"def list_children(path)\n path = \"#{Paths::VFS}/#{path}\" unless path.start_with?(Paths::VFS)\n path = sanitize_path(path)\n\n @api.get(path)\n end",
"def rip_folders()\n if @version >= IOS_VERSION_9\n @database.execute(\"SELECT ZICCLOUDSYNCINGOBJECT.Z_PK \" + \n \"FROM ZICCLOUDSYNCINGOBJECT \" + \n \"WHERE ZICCLOUDSYNCINGOBJECT.ZTITLE2 IS NOT NULL\") do |row|\n rip_folder(row[\"Z_PK\"])\n end\n end\n\n # In legacy Notes the \"folders\" were \"stores\"\n if @version == IOS_LEGACY_VERSION\n @database.execute(\"SELECT ZSTORE.Z_PK FROM ZSTORE\") do |row|\n rip_folder(row[\"Z_PK\"])\n end\n end\n end",
"def retrieve_dirs(_base, dir, dot_dirs)\n dot_dirs.each do |file|\n dir_path = site.in_source_dir(dir, file)\n rel_path = PathManager.join(dir, file)\n @site.reader.read_directories(rel_path) unless @site.dest.chomp(\"/\") == dir_path\n end\n end",
"def test_recursionlevels\n server = nil\n assert_nothing_raised {\n\n server = Puppet::Network::Handler.fileserver.new(\n\n :Local => true,\n\n :Config => false\n )\n }\n\n # make our deep recursion\n basedir = File.join(tmpdir, \"recurseremotetesting\")\n testdir = \"#{basedir}/with/some/sub/directories/for/the/purposes/of/testing\"\n oldfile = File.join(testdir, \"oldfile\")\n assert_nothing_raised {\n system(\"mkdir -p #{testdir}\")\n File.open(oldfile, \"w\") { |f|\n 3.times { f.puts rand(100) }\n }\n @@tmpfiles << basedir\n }\n\n assert_nothing_raised {\n server.mount(basedir, \"test\")\n }\n\n # get our list\n list = nil\n assert_nothing_raised {\n list = server.list(\"/test/with\", :manage, false, false)\n }\n\n # make sure we only got one line, since we're not recursing\n assert(list !~ /\\n/)\n\n # for each level of recursion, make sure we get the right list\n [0, 1, 2].each { |num|\n assert_nothing_raised {\n list = server.list(\"/test/with\", :manage, num, false)\n }\n\n count = 0\n while list =~ /\\n/\n list.sub!(/\\n/, '')\n count += 1\n end\n assert_equal(num, count)\n }\n end",
"def list_directories(options = {})\n options = DEFAULTS.merge(options)\n\n path = options[:path]\n all = options[:all]\n\n path = \"#{path}/\" unless path == '' or path.end_with?('/')\n path = path+'**/' if all\n \n\n Dir.glob(\"#{path}*/\")\n end",
"def index\n @winddirs = Winddir.all\n end",
"def find_incoming_roots(remote, opts={:base => nil, :heads => nil,\n :force => false, :base => nil})\n common_nodes(remote, opts)[1]\n end",
"def get_children_folders(folder_id)\n url = URI(\"#{$base_url}/api/projects/#{$project_id}/folders/#{folder_id}/children\")\n\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n request = Net::HTTP::Get.new(url)\n request[\"accept\"] = 'application/vnd.api+json; version=1'\n request[\"access-token\"] = $access_token\n request[\"uid\"] = $uid\n request[\"client\"] = $client\n response = http.request(request)\n\n folders_json = ''\n\n if response.code == 200.to_s\n folders_json = JSON.parse(response.read_body)['data']\n else\n puts \"Problem with getting folders. Status: #{response.code}\"\n puts response.body\n end\n folders_json\nend",
"def synced_folders &thunk\n (self.common_field \"synced_folders\").each &thunk\n ((self.local_field \"synced_folders\") || []).each &thunk\n end",
"def children\n return [] unless directory_index?\n\n base_path = if eponymous_directory?\n eponymous_directory_path\n else\n path.sub(@app.config[:index_file].to_s, '')\n end\n\n prefix = %r{^#{base_path.sub(\"/\", \"\\\\/\")}}\n\n @store.resources.select do |sub_resource|\n if sub_resource.path == path || sub_resource.path !~ prefix\n false\n else\n inner_path = sub_resource.path.sub(prefix, '')\n parts = inner_path.split('/')\n if parts.length == 1\n true\n elsif parts.length == 2\n parts.last == @app.config[:index_file]\n else\n false\n end\n end\n end\n end",
"def LoteDeCarga()\n print \" #=============================================================================#\\n\"\n print \"\\tLote de carga en ejecucion...\\n\"\n print \" #-----------------------------------------------------------------------------#\\n\"\n print \"\\tDetectando Cuits...\\n\"\n print \" #-----------------------------------------------------------------------------#\\n\"\n aux = []\n cont = 0\n Dir.chdir(\"C:\\\\SFTP\\\\Tickets\")\n Dir.foreach('.') do |item|\n next if item == '.' or item == '..'\n if File.directory?(item)\n print \"\\tCuit encontrado -> \" + item + \"...\\n\"\n aux[cont] = item\n cont += 1\n end\n end\n return aux\nend",
"def synced_folders(vm, host, global)\n if folders = get_config_parameter(host, global, 'synced_folders')\n folders.each do |folder|\n vm.synced_folder folder['src'], folder['dest'], folder['options']\n end\n end\nend",
"def cmd_list(param)\n send_unauthorised and return unless logged_in?\n send_response \"150 Opening ASCII mode data connection for file list\"\n\n param = '' if param.to_s == '-a'\n\n dir = File.join(@name_prefix.to_s, param.to_s)\n\n now = Time.now\n\n items = list_dir(build_path(param))\n lines = items.map do |item|\n \"#{item.directory ? 'd' : '-'}#{item.permissions || 'rwxrwxrwx'} 1 #{item.owner || 'owner'} #{item.group || 'group'} #{item.size || 0} #{(item.time || now).strftime(\"%b %d %H:%M\")} #{item.name}\"\n end\n send_outofband_data(lines)\n # send_action_not_taken\n end",
"def directories\n @directories.values\n end",
"def recursive_find_directories_and_files dirname\r\n base_path = self.class.lookup('ExtAdminSection').path + \"/templates/\"\r\n \r\n directories = []\r\n files = []\r\n \r\n Find.find(File.join(base_path, dirname)) do |path|\r\n if FileTest.directory?(path)\r\n directories << path.gsub(base_path, '')\r\n else\r\n files << path.gsub(base_path, '')\r\n end\r\n end\r\n \r\n return directories, files\r\n end",
"def list(path=nil)\n remote_path = list_path(path)\n begin\n folder = @client.folder(remote_path)\n raise Error if folder.nil?\n folder.items.map do |elem|\n {\n name: elem.name,\n path: \"#{remote_path}/#{elem.name}\",\n type: elem.type\n }\n end\n rescue RubyBox::AuthError\n box_error\n end\n end",
"def get_win_server_folder_path(ends_with_slash,starting_path,arr,sep)\n list = []\n if Dir.exists?(app_config(:win_ftp_root)) && Dir.chdir(app_config(:win_ftp_root))\n glob_value = ends_with_slash ? \"#{arr.join(sep)}/*\" : \"#{arr.join(sep)}*\"\n count = starting_path.count \"/\"\n glob_value = \"#{starting_path.split(\"/\").last}*\" if count == 1 and starting_path[0] == \"/\"\n #list=Dir.glob(glob_value)\n glob_value_dc = glob_value.downcase\n glob_value_cc = glob_value.camelcase.split(\"::\").join(\"/\")\n glob_value_uc = glob_value.upcase\n list=Dir.glob(glob_value_dc)\n list=list+Dir.glob(glob_value_cc)\n list=list+Dir.glob(glob_value_uc)\n end\n return list\n end",
"def pull_dir(localpath, remotepath, options = {}, &block)\n connect! unless @connection\n @recursion_level += 1\n\n todelete = Dir.glob(File.join(localpath, '*'))\n \n tocopy = []\n recurse = []\n\n # To trigger error if path doesnt exist since list will\n # just return and empty array\n @connection.chdir(remotepath)\n\n @connection.list(remotepath) do |e|\n entry = Net::FTP::List.parse(e)\n \n paths = [ File.join(localpath, entry.basename), \"#{remotepath}/#{entry.basename}\".gsub(/\\/+/, '/') ]\n\n if entry.dir?\n recurse << paths\n elsif entry.file?\n if options[:since] == :src\n tocopy << paths unless File.exist?(paths[0]) and entry.mtime < File.mtime(paths[0]) and entry.filesize == File.size(paths[0])\n elsif options[:since].is_a?(Time)\n tocopy << paths unless entry.mtime < options[:since] and File.exist?(paths[0]) and entry.filesize == File.size(paths[0])\n else\n tocopy << paths\n end\n end\n todelete.delete paths[0]\n end\n \n tocopy.each do |paths|\n localfile, remotefile = paths\n unless should_ignore?(localfile)\n begin\n @connection.get(remotefile, localfile)\n log \"Pulled file #{remotefile}\"\n rescue Net::FTPPermError\n log \"ERROR READING #{remotefile}\"\n raise Net::FTPPermError unless options[:skip_errors]\n end\n end\n end\n \n recurse.each do |paths|\n localdir, remotedir = paths\n Dir.mkdir(localdir) unless File.exist?(localdir)\n pull_dir(localdir, remotedir, options, &block)\n end\n \n if options[:delete]\n todelete.each do |p|\n block_given? ? yield(p) : FileUtils.rm_rf(p)\n log \"Removed path #{p}\"\n end\n end\n \n @recursion_level -= 1\n close! if @recursion_level == 0\n rescue Net::FTPPermError\n close!\n raise Net::FTPPermError\n end",
"def get_directory_listing_for(params)\n # Get parent folder id\n parent_folder_id = params[:folder_id].present? ? self.get_parent_folder_id(params[:folder_id]) : nil\n \n # Get root folder id if blank\n params[:folder_id] ||= self.get_root_folder_id\n return nil if params[:folder_id].blank?\n \n # Set default params\n result = {:folder_id => params[:folder_id], :parent_folder_id => parent_folder_id, :per_page => 500, :results => []}\n parameters = {}\n parameters['q'] = \"'#{params[:folder_id]}' in parents\"\n parameters['maxResults'] = result[:per_page]\n \n # Make api request\n begin\n drive = @client.discovered_api('drive', 'v2')\n api_result = @client.execute(:api_method => drive.files.list, :parameters => parameters)\n rescue\n return nil\n end\n \n \n if api_result.status == 200\n files = api_result.data\n files.items.each do |item|\n result[:results] << self.item_into_standard_format(item)\n end\n else\n result[:error] = {:code => api_result.status, :message => api_result.data['error']['message']} \n end\n result\n end",
"def rc_dirs; end",
"def list_subfolders(logged_in_user, order)\n folders = []\n if logged_in_user.can_read(self.id)\n self.children.find(:all, :order => order).each do |sub_folder|\n folders << sub_folder if logged_in_user.can_read(sub_folder.id)\n end\n end\n\n # return the folders:\n return folders\n end",
"def sync_available_sibling_repos(hostname, remote_repo_parent_dir=\"/root\", ssh_user=\"root\")\n working_dirs = ''\n clone_commands = ''\n SIBLING_REPOS.each do |repo_name, repo_dirs|\n repo_dirs.each do |repo_dir|\n if sync_sibling_repo(repo_name, repo_dir, hostname, remote_repo_parent_dir, ssh_user)\n working_dirs += \"#{repo_name}-working \"\n clone_commands += \"git clone #{repo_name} #{repo_name}-working; \"\n break # just need the first repo found\n end\n end\n end\n return clone_commands, working_dirs\n end",
"def subfolders\n if new_record?\n raise Errors::FolderNotFound.new(@id, \"Folder does only exist locally\")\n else\n begin\n self.class.some(@conn_id, @location.path)\n rescue Errors::FolderNotFound\n []\n end\n end\n end",
"def list\n call(:get, path)\n end",
"def index\n client = DropboxApi::Client.new(\"C8Eg7_xlTzAAAAAAAAAAMduh226EdjZy_X_pVqXkbOUenDBMOVpQwo0zhF9sr8bC\")\n @result = client.list_folder \"/Yann Doré\"\n pp @result.entries\n @result.has_more? \n end",
"def subdirectories\n path_length - 1\n end",
"def pull_dir(sftp_session, remote_path, local_path, delete, sync_data)\n\n @log.debug(\"Pulling dir #{remote_path}\")\n \n # make sure the local path exists\n if !File.exists?(local_path)\n\n File.makedirs(local_path)\n end\n \n # move our local file pointer to the local path\n FileUtils.cd(local_path)\n\n # get a list of local files\n local_entries = Dir.glob(\"*\")\n\n # list of items in this directory that we have handled\n handled_local_entry_paths = Array.new\n\n # enumerate the remote directory\n sftp_session.dir.foreach(remote_path) do |remote_entry|\n\n # don't sync the link to the local or parent directory or our\n # sync data\n if(remote_entry.name != \".\" && remote_entry.name != \"..\" &&\n remote_entry.name != SYNC_DATA_FILE)\n\n # compute the local path and remote paths\n local_entry_path = local_path + \"/\" + remote_entry.name\n remote_entry_path = remote_path + \"/\" + remote_entry.name\n\n if remote_entry.directory?\n\n pull_dir(sftp_session, remote_entry_path, local_entry_path, delete,\n sync_data)\n else\n\n pull_file(sftp_session, remote_entry_path, local_entry_path,\n sync_data)\n end\n\n # add the local path to our list of handled paths\n handled_local_entry_paths << local_entry_path\n end\n end\n\n # handle deletion of stale local files and directories\n if delete\n\n # loop through the local entries\n local_entries.each do |local_entry|\n\n # compute the local path\n local_entry_path = local_path + \"/\" + local_entry\n\n # check to see if we have handled this path\n if !handled_local_entry_paths.include?(local_entry_path)\n\n # this entry wasn't on the remote side, delete it\n if File.directory?(local_entry_path)\n\n remove_dir(sftp_session, nil, local_entry_path)\n else\n\n remove_file(sftp_session, nil, local_entry_path)\n end\n end\n end\n end\n\n @log.debug(\"Pulled dir #{remote_path}\")\n end",
"def folders\n html = http_request(@uri + '/wato.py', {\n folder: '',\n mode: 'folder',\n }, false)\n html.split(/\\n/).each do |line|\n next unless line =~ /class=\"folderpath\"/\n end\n res = []\n html.split(/\\n/).grep(/mode=editfolder/).each do |line|\n line =~ /folder=(.*?)'/\n res.push $1 unless $1.nil?\n end\n res\n end",
"def list\n factory.system.list(@path).collect do |item|\n candidate = dir(item)\n if (not candidate.exists?)\n candidate = file(item)\n end\n candidate\n end\n end",
"def get_children(directory)\n file = Pathname.new(directory)\n if file.directory?\n file.children\n else \n []\n end\nend",
"def submodule_dirs\n # Implementation is a little hacky; we run a git command and parse the\n # output.\n cmd = %(git submodule)\n %x(#{cmd}).split(/\\n/).map {|line| line.split(\" \")[1] }\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = ListRealFoldersResultSet.new(resp)\n return results\n end",
"def folder_list(opts = {})\n optional_inputs = {\n include_deleted: false,\n include_media_info: false,\n }.merge(opts)\n input_json = {\n id: optional_inputs[:id],\n path: optional_inputs[:path],\n include_deleted: optional_inputs[:include_deleted],\n include_media_info: optional_inputs[:include_media_info],\n }\n response = @session.do_rpc_endpoint(\"/#{ @namespace }/folder_list\", input_json)\n Dropbox::API::FolderAndContents.from_json(Dropbox::API::HTTP.parse_rpc_response(response))\n end",
"def list_dirs(path)\n dir = pathname(path)\n\n Dir.chdir(dir) do\n Dir['*/'].sort\n end\n\n rescue\n raise FileNotFound, \"no such file in repo - #{path}\"\n end"
] | [
"0.6535337",
"0.63889694",
"0.6366609",
"0.6309605",
"0.62799674",
"0.6137568",
"0.61146027",
"0.6108654",
"0.6067611",
"0.60400695",
"0.6033286",
"0.59724987",
"0.595714",
"0.5920253",
"0.58352244",
"0.58130527",
"0.5812346",
"0.581129",
"0.58086365",
"0.5791609",
"0.5789728",
"0.577318",
"0.5768643",
"0.5752359",
"0.5681605",
"0.5636422",
"0.5604136",
"0.5593326",
"0.5574858",
"0.55714214",
"0.5567298",
"0.5560191",
"0.5555284",
"0.5536015",
"0.5531535",
"0.5513166",
"0.55003816",
"0.54797184",
"0.546819",
"0.546819",
"0.54596245",
"0.54305655",
"0.5430202",
"0.5423985",
"0.54232687",
"0.54059774",
"0.53938663",
"0.5387819",
"0.5381189",
"0.53535515",
"0.53509855",
"0.5339713",
"0.5321532",
"0.52977115",
"0.52977115",
"0.5280766",
"0.5273159",
"0.5267481",
"0.52583647",
"0.5251476",
"0.52455837",
"0.524491",
"0.5237388",
"0.5235543",
"0.52341455",
"0.5224915",
"0.52095747",
"0.5203051",
"0.52029485",
"0.51993424",
"0.5194064",
"0.51931775",
"0.5188364",
"0.5180621",
"0.5178218",
"0.516955",
"0.51557034",
"0.5149118",
"0.514705",
"0.5138946",
"0.5136992",
"0.5136626",
"0.5133203",
"0.5122933",
"0.5106941",
"0.51057637",
"0.51021945",
"0.5093661",
"0.50925756",
"0.5091687",
"0.50888",
"0.50751054",
"0.50728005",
"0.50707793",
"0.5068546",
"0.5055259",
"0.5054096",
"0.5051557",
"0.50494653",
"0.50481987"
] | 0.6408531 | 1 |
list all the file hashes of the files within the base directory N Without this we won't have a direct method to list files within the remote directory, together with their hashes | def listFileHashes
return contentHost.listFileHashes(baseDir)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def listFileHashLines(baseDir)\n #N Without this, the base directory might be missing the final '/', which might cause a one-off error when 'subtracting' the base directory name from the absolute paths to get relative paths\n baseDir = normalisedDir(baseDir)\n #N Without this, we wouldn't know what command to run remotely to loop over the output of the file-files command and run the hash command on each line of output\n remoteFileHashLinesCommand = findFilesCommand(baseDir) + [\"|\", \"xargs\", \"-r\"] + @hashCommand.command\n #N Without this we wouldn't actually run the command just defined\n ssh(remoteFileHashLinesCommand.join(\" \")) do |line| \n #N Without this the line of output wouldn't be echoed to the user\n puts \" #{line}\"\n #N Without this the line of output (with a file name and a hash value) wouldn't be available to the caller of this method\n yield line \n end\n end",
"def listFileHashes(baseDir)\n #N Un-normalised, an off-by-one error would occur when 'subtracting' the base dir off the full paths to get relative paths\n baseDir = normalisedDir(baseDir)\n #N Without this, we would have nowhere to accumulate the file hash objects\n fileHashes = []\n #N Without this, we would not be executing and parsing the results of the file-listing command\n listFileHashLines(baseDir) do |fileHashLine|\n #N Without this, we would not be parsing the result line containing this file and its hash value\n fileHash = self.hashCommand.parseFileHashLine(baseDir, fileHashLine)\n #N Without this check we would be accumulating spurious nil values returned from listFileHashLines (even though listFileHashLines doesn't actually do that)\n if fileHash != nil\n #N Without this, we would fail to include this file & hash in the list of file hashes.\n fileHashes << fileHash\n end\n end\n return fileHashes\n end",
"def list_files\n files = remote_directory.files.map { |file| file.key }\n\n # The first item in the array is only the path an can be discarded.\n files = files.slice(1, files.length - 1) || []\n\n files\n .map { |file| Pathname.new(file).basename.to_s }\n .sort\n .reverse\n end",
"def list_files\n [].tap do |files|\n remote_files do |file|\n files << file\n end\n end\n end",
"def listFiles(baseDir)\n #N Without this, the base directory might be missing the final '/', which might cause a one-off error when 'subtracting' the base directory name from the absolute paths to get relative paths\n baseDir = normalisedDir(baseDir)\n #N Without this we wouldn't be executing the command to list all files in the remote directory\n ssh(findFilesCommand(baseDir).join(\" \")) do |line| \n #N Without this we wouldn't be echoing the file name on this line for the user to read\n puts \" #{line}\"\n end\n end",
"def get_remote_files\n manager = @current_source.file_manager\n manager.start do \n @current_source.folders.each do |folder|\n @files[folder] = manager.find_files folder\n @files[folder] = @files[folder].take(@take) if @take\n Logger.<<(__FILE__,\"INFO\",\"Found #{@files[folder].size} files for #{@current_source.base_dir}/#{folder} at #{@current_source.host.address}\")\n SignalHandler.check\n end\n end\n end",
"def files_digest(paths)\n self.digest(paths.map { |path| self.file_digest(path) })\n end",
"def listFiles()\n #N Without this the files won't get listed\n contentHost.listFiles(baseDir)\n end",
"def files_commits(num_commits)\n @repo = Grit::Repo.new(@directory)\n related_files = []\n commits_all(num_commits) do |commits|\n commits.each do |commit|\n paths = []\n begin\n commit.diffs.each do |diff|\n if diff.a_path != diff.b_path\n related_files += [[diff.a_path, diff.b_path]]\n end\n paths += [diff.a_path, diff.b_path]\n end\n rescue Grit::Git::GitTimeout\n puts \"Failed to diff for %s\" % commit.sha\n end\n paths.uniq!\n yield commit, paths, related_files\n end\n end\n end",
"def file_list(hash)\n\nend",
"def file_list(hash)\n\nend",
"def files_digest(paths)\n digest(paths.map { |path| file_digest(path) })\n end",
"def ls( *args )\r\n \r\n directory = nil\r\n opts = {}\r\n \r\n case args.count\r\n when 1\r\n if args[0].kind_of? Hash\r\n opts = args[0]\r\n else\r\n directory = args[0]\r\n end\r\n when 2\r\n directory = args[0]\r\n opts = args[1] \r\n end\r\n \r\n # args are the RPC arguments ...\r\n args = {}\r\n args[:path] = directory if directory\r\n args[:recursive] = true if opts[:recurse]\r\n args[:detail] = true if opts[:detail] \r\n args.delete(:detail) if( args[:detail] and args[:recursive])\r\n \r\n # RPC output format, default is XML\r\n outf = { :format => 'text' } if opts[:format] == :text\r\n \r\n got = @ndev.rpc.file_list( args, outf )\r\n return nil unless got\r\n \r\n return got.text if opts[:format] == :text\r\n return got if opts[:format] == :xml\r\n \r\n # if we're here, then we need to conver the output \r\n # to a Hash. Joy!\r\n \r\n collect_detail = args[:detail] || args[:recursive]\r\n \r\n ls_hash = {}\r\n got.xpath('directory').each do |dir|\r\n \r\n dir_name = dir.xpath('directory-name').text.strip\r\n dir_hash = {}\r\n \r\n dir_hash[:fileblocks] = dir.xpath('total-file-blocks').text.to_i\r\n files_info = dir.xpath('file-information')\r\n \r\n dir_hash[:files] = {} \r\n dir_hash[:dirs] = {} # sub-directories\r\n \r\n files_info.each do |file|\r\n f_name = file.xpath('file-name').text.strip\r\n f_h = {} \r\n \r\n if file.xpath('file-directory')[0]\r\n dir_hash[:dirs][f_name] = f_h\r\n else\r\n dir_hash[:files][f_name] = f_h \r\n end\r\n \r\n next unless collect_detail\r\n \r\n f_h[:owner] = file.xpath('file-owner').text.strip\r\n f_h[:group] = file.xpath('file-group').text.strip\r\n f_h[:links] = file.xpath('file-links').text.to_i\r\n f_h[:size] = file.xpath('file-size').text.to_i\r\n \r\n xml_when_item(file.xpath('file-symlink-target')) { |i|\r\n f_h[:symlink] = i.text.strip\r\n }\r\n \r\n fp = file.xpath('file-permissions')[0]\r\n f_h[:permissions_text] = fp.attribute('format').value\r\n f_h[:permissions] = fp.text.to_i\r\n \r\n fd = file.xpath('file-date')[0]\r\n f_h[:date] = fd.attribute('format').value\r\n f_h[:date_epoc] = fd.text.to_i\r\n \r\n end # each directory file\r\n ls_hash[ dir_name ] = dir_hash \r\n end # each directory\r\n \r\n return nil if ls_hash.empty?\r\n ls_hash\r\n end",
"def files_on_remote\n @bucket_contents = nil\n bucket_contents.map {|item| File.basename(item['Key']) }.sort\n end",
"def get_remotes()\n to_return = {}\n count = 1\n num_dirs = Dir.glob('./*/').size() -2 # exclude . and ..\n Dir.glob('./*/').each() do |dir|\n next if dir == '.' or dir == '..'\n\n print \"Processing directories...#{count}/#{num_dirs}\\r\" if !$verbose\n count += 1\n\n if(File.directory?(dir) and File.exists?(dir + '/.git'))\n Dir.chdir dir\n remotes = `git remote -v`.split(\"\\n\")\n\n vprint(dir.ljust(25))\n remotes.each() do |remote|\n if(remote.index('(fetch)'))\n parts = remote.split(\"\\t\")\n\n remote_name = get_remote_name(parts[1])\n vprint(\"[#{parts[0]} #{remote_name}]\".ljust(20))\n if(remote_name != nil)\n index = parts[0] + ' - ' + remote_name\n if(to_return[index] == nil)\n to_return[index] = Array.new()\n end\n to_return[index].push(dir)\n else\n puts \"\\nDon't know what to do with #{remote} in dir #{dir}\"\n end\n end\n end # end remotes loop\n\n vprint \"\\n\"\n Dir.chdir '..'\n end # end if file.directory\n end\n\n print \"\\n\"\n return to_return\nend",
"def list_files(env, res, tag, path)\n files = []\n git(\"ls-tree\", \"-z\", \"#{tag}:#{path}\") do |io|\n io.each_line(\"\\0\") do |line|\n line.chomp!(\"\\0\")\n #STDERR.puts line\n info, file = line.split(/\\t/, 2)\n mode, type, object = info.split(/ /)\n files << {\n :mode => mode,\n :type => type,\n :object => object,\n :file => file,\n }\n end\n end\n files = files.sort_by{|h| h[:file] }\n E_list_files.result(binding)\n end",
"def files_remote_list(options = {})\n options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]\n if block_given?\n Pagination::Cursor.new(self, :files_remote_list, options).each do |page|\n yield page\n end\n else\n post('files.remote.list', options)\n end\n end",
"def get_files\n fields = \"next_page_token, files(id, name, owners, parents, mime_type, sharedWithMeTime, modifiedTime, createdTime)\"\n\n folders = []\n @files = []\n\n #Go through pages of files and save files and folders\n next_token = nil\n first_page = true\n while first_page || (!next_token.nil? && !next_token.empty?)\n results = @service.list_files(q: \"not trashed\", fields: fields, page_token: next_token)\n folders += results.files.select{|file| file.mime_type == DRIVE_FOLDER_TYPE and belongs_to_me?(file)}\n @files += results.files.select{|file| !file.mime_type.include?(DRIVE_FILES_TYPE) and belongs_to_me?(file)}\n next_token = results.next_page_token\n first_page = false\n end\n\n #Cache folders\n folders.each {|folder| @folder_cache[folder.id] = folder}\n\n #Resolve file paths and apply ignore list\n @files.each {|file| file.path = resolve_path file}\n @files.reject!{|file| Helper.file_ignored? file.path, @config}\n\n Log.log_notice \"Counted #{@files.count} remote files in #{folders.count} folders\"\n end",
"def repo_files\n @vault.sys.auths.select { |_,v| v.type == 'ldap' }\n .keys\n .inject([]) { |acc, elem| acc + group_files(elem) }\n end",
"def all_files\n `git ls-files`.\n split(/\\n/).\n map { |relative_file| File.expand_path(relative_file) }.\n reject { |file| File.directory?(file) } # Exclude submodule directories\n end",
"def all_files\n `git ls-files`.\n split(/\\n/).\n map { |relative_file| File.expand_path(relative_file) }.\n reject { |file| File.directory?(file) } # Exclude submodule directories\n end",
"def create_list_of_files\n @path=find_repository_and_basepath\n @table.window.setTitle(@path)\n files=[]\n Find.find(@path) do |file|\n # we don't want any files from a repository in the list \n next if file=~/(\\.hg|\\.svn|\\.git|\\.pyc)/ \n\n # neither do we want dotfiles in the list\n next if File.basename(file)=~/^\\./ \n \n # file matches, add it to the resulting list\n files << file if FileTest.file?(file)\n\n # wir bauen hier mal einen kleinen Idiotentest ein. Wenn wir mehr\n # als 10000 Dateien gefunden haben dann sind wir vermtl. in einem \n # falschen Verzeichniss und brechen die Suche ab.\n if files.length>10000\n NSRunInformationalAlertPanel('Large directory found!',\n \"Gathered more than 10k files from directory '#{@path}', aborting search!\",'OK',nil,nil)\n NSApp.stop(self)\n raise 'error'\n end\n end\n #@files=files.sort_by { |match| File.basename(match) }\n @files=files.sort\n end",
"def manifested_files\n manifest_files.inject([]) do |acc, mf|\n files = File.open(mf) { |io|\n io.readlines.map do |line|\n _digest, path = line.chomp.split(/\\s+/, 2)\n decode_filename(path)\n end\n }\n\n (acc + files).uniq\n end\n end",
"def manifested_files\n\n manifest_files.inject([]) do |acc, mf|\n\n files = open(mf) do |io|\n\n io.readlines.map do |line|\n digest, path = line.chomp.split /\\s+/, 2\n path\n end\n\n end\n\n (acc + files).uniq\n end\n\n end",
"def contents_hash(paths)\n return if paths.nil?\n\n paths = paths.compact.select { |path| File.file?(path) }\n return if paths.empty?\n # rubocop:disable GitHub/InsecureHashAlgorithm\n paths.sort\n .reduce(Digest::XXHash64.new, :file)\n .digest\n .to_s(16) # convert to hex\n # rubocop:enable GitHub/InsecureHashAlgorithm\n end",
"def files\n return unless git_repo?\n output = Licensed::Shell.execute(\"git\", \"ls-files\", \"--full-name\", \"--recurse-submodules\")\n output.lines.map(&:strip)\n end",
"def find_md5(dir, excludes)\n found = []\n (Dir.entries(dir) - %w[. ..]).map { |e| File.join(dir, e) }.each do |path|\n if File.directory?(path)\n unless exclude?(excludes, path)\n found += find_md5(path, excludes)\n end\n elsif File.file?(path)\n if (file = new(path))\n unless exclude?(excludes, file.path)\n file.md5 = Digest::MD5.file(file.path).hexdigest\n found << file\n end\n end\n end\n end\n found\n end",
"def sha256(files)\n sha = Digest::SHA2.new\n files.each do |f|\n next if File.directory?(f)\n\n content = File.binread(f)\n # work around possible git checkout issues by removing CR and LF from the file\n content.gsub!(\"\\n\", \"\")\n content.gsub!(\"\\r\", \"\")\n sha << content\n end\n sha.hexdigest\n end",
"def list_files(prefix=\"\")\n glob = if prefix.nil? || prefix.empty?\n \"media/**/*\"\n elsif prefix.end_with? '/'\n \"media/#{prefix}**/*\"\n else\n \"media/#{prefix}*\"\n end\n\n puts \"Listing local files matching #{glob}\"\n\n Dir[glob].select{|path| File.file? path }.map do |path|\n {\n path: path,\n size: File.size(path),\n md5: Digest::MD5.hexdigest(File.read(path))\n }\n end\nend",
"def applicable_owners_files_hash\n return @applicable_owners_files_hash if !@applicable_owners_files_hash.nil?\n\n # Make hash of (directory => [files in that directory in this commit]) pairs\n\n puts \"changed files: #{changed_files.inspect}\"\n\n affected_dirs_hash = changed_files.collect_to_reverse_hash do |file|\n File.dirname(file)\n end\n\n puts \"affected_dirs_hash: #{affected_dirs_hash.inspect}\"\n\n affected_dirs = affected_dirs_hash.keys\n\n # Make hash of owners file => [file1, file2, file3]\n res = affected_dirs.inject(Hash.new) do |hash, dir|\n owner = find_owners_file(dir)\n\n # If there's no OWNERS file for this dir, just skip it\n if owner.nil?\n return hash\n end\n\n data = {\n :owner_data => owner,\n :files => affected_dirs_hash[dir]\n }\n\n key = owner[:path]\n\n if (hash.include?(key))\n combined_data = hash[key]\n combined_data[:files] = combined_data[:files] + data[:files]\n\n hash[key] = combined_data\n else\n hash[key] = data\n end\n hash\n end \n\n @applicable_owners_files_hash = res\n end",
"def all_files\n @all_files ||= `git ls-files 2> /dev/null`.split(\"\\n\")\n end",
"def digest_sha2(*files)\n files.flatten.collect { |file| \n File.exists?(file) ? Digest::SHA2.hexdigest(File.read(file)) : nil\n }\n end",
"def get_file_listing\n execute!(drive.files.list).data\n end",
"def list_files_from (path,opts = {})\n safe_fetch do\n list_files = Set.new\n var = \"Search in #{path} at #{@host}... \"\n cmd = \"find #{path}\"\n cmd = \"(cd #{path} && ls \" ### dont know why cd alone doesn't work\n cmd << \"-td */\" if opts[:directories]\n cmd << opts[:regexp] if opts[:regexp]\n cmd << \" 2>/dev/null)\"\n out = @ssh.exec!(cmd)\n list_files = out.split\n list_files = out.split(\"/\\n\") if opts[:directories]\n\n var << \"Found #{list_files.size} entries\\n\"\n Logger.<<(__FILE__,\"INFO\",var)\n list_files\n end\n end",
"def file_get_files(directories) \n directory = \"\"\n files = []\n directories.each do |directory| \n unless directory == \"/root\"\n Dir.chdir(\"#{directory}\") \n Dir.foreach(\"#{directory}\") do |d| \n files.push(d) unless d == \".\" || d == \"..\" \n end\n @file_information.store(directory, files)\n files = []\n end\n end\n return @file_information\n end",
"def hash\n Digest::MD5.hexdigest(abs_filepath)[0..5]\n end",
"def files\n i = 0\n @@arr_path.each do |path|\n if path.include?(params[:fold])\n # Remove path from current path\n @@arr_path = @@arr_path[0..i]\n @path = ''\n\n @@arr_path.each do |e| # Put path from array to @path\n @path = @path + e + ' >> '\n end\n @@temp_path = @path\n\n # Get content: folders, file, count\n @content = BrowsingFile.bind_folder params[:fold]\n @file = BrowsingFile.bind_files params[:fold]\n\n render 'index' # Reload index page\n return\n end\n i += 1\n end\n end",
"def list\n Lib.list @path, @no_follow\n end",
"def get_remote_files\n raise BucketNotFound.new(\"#{self.config.fog_provider} Bucket: #{self.config.fog_directory} not found.\") unless directory\n files = []\n directory.files.each { |f| files << f if File.extname(f.key).present? }\n return files\n end",
"def get_files(version)\n my_state = get_state(version)\n my_files = {}\n\n my_state.each do |digest, filepaths| # filepaths is [Array]\n filepaths.each do |logical_filepath|\n # look up this file via digest in @manifest.\n physical_filepath = @manifest[digest]\n # physical_filepath is an [Array] of files, but they're all the same so only need 1.\n my_files[logical_filepath] = physical_filepath[0]\n end\n end\n my_files\n end",
"def index(base_path, glob = nil)\n\t\tglob = '*' if glob == '' or glob.nil?\n\t\tdirs = []\n\t\tfiles = []\n\t\t::Dir.chdir(base_path) do\n\t\t\t::Dir.glob(glob).each do |fname|\n\t\t\t\tif ::File.directory?(fname)\n\t\t\t\t\tdirs << fname + '/'\n\t\t\t\telse\n\t\t\t\t\tfiles << fname\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tdirs.sort + files.sort\n\trescue Errno::ENOENT\n\t\traise Rush::DoesNotExist, base_path\n\tend",
"def find_similar_files\n \"SELECT * FROM files \n WHERE md5 = md5 AND sha1 = sha1 AND size = size\n GROUP BY md5, sha1, size\"\n end",
"def files\n return get_result('files')\n end",
"def files(count = 5)\n connection.get(room_url_for(:uploads))['uploads'].map { |u| u['full_url'] }\n end",
"def committed_files sha\n array_output_of \"git diff-tree --no-commit-id --name-only -r #{sha}\"\nend",
"def digest_md5(*files)\n files.flatten.collect { |file| \n File.exists?(file) ? Digest::MD5.hexdigest(File.read(file)) : nil\n }\n end",
"def list_files dir='*', sorto=@sorto, hidden=@hidden, _filter=@filterstr\n dir += '/*' if File.directory?(dir)\n dir = dir.gsub('//', '/')\n\n # decide sort method based on second character\n # first char is o or O (reverse)\n # second char is macLn etc (as in zsh glob)\n so = sorto ? sorto[1] : nil\n func = case so\n when 'm'\n :mtime\n when 'a'\n :atime\n when 'c'\n :ctime\n when 'L'\n :size\n when 'n'\n :path\n when 'x'\n :extname\n end\n\n # sort by time and then reverse so latest first.\n sorted_files = if hidden == 'D'\n Dir.glob(dir, File::FNM_DOTMATCH) - %w[. ..]\n else\n Dir.glob(dir)\n end\n\n # WARN: crashes on a deadlink since no mtime\n if func\n sorted_files = sorted_files.sort_by do |f|\n if File.exist? f\n File.send(func, f)\n else\n sys_stat(func, f)\n end\n end\n end\n\n sorted_files.sort! { |w1, w2| w1.casecmp(w2) } if func == :path && @ignore_case\n\n # zsh gives mtime sort with latest first, ruby gives latest last\n sorted_files.reverse! if sorto && sorto[0] == 'O'\n\n # add slash to directories\n sorted_files = add_slash sorted_files\n # return sorted_files\n @files = sorted_files\n calculate_bookmarks_for_dir # we don't want to override those set by others\nend",
"def files\n %x{\n find . -type f ! -path \"./.git/*\" ! -path \"./node_modules/*\"\n }.\n split(\"\\n\").\n map { |p| Pathname.new(p) }\n end",
"def all_files\n @files_hash.values\n end",
"def modified_files\n diff = git.diff(local_branch, remote_branch(local_branch))\n diff.stats[:files].keys\n end",
"def new_files(recursive=false)\n newfiles = Array.new\n list(recursive).each do |file|\n newfiles << file if !stored?(file) \n end\n return newfiles\n end",
"def file_listing(commit)\n # The only reason this doesn't work 100% of the time is because grit doesn't :/\n # if i find a fix, it'll go upstream :D\n count = 0\n out = commit.diffs.map do |diff|\n count = count + 1\n if diff.deleted_file\n %(<li class='file_rm'><a href='#file_#{count}'>#{diff.a_path}</a></li>)\n else\n cla = diff.new_file ? \"add\" : \"diff\"\n %(<li class='file_#{cla}'><a href='#file_#{count}'>#{diff.a_path}</a></li>)\n end\n end\n \"<ul id='files'>#{out.join}</ul>\"\n end",
"def altered_files; `git show --name-only #{node} 2> /dev/null`.split(\"\\n\"); end",
"def files\n page = get_page\n offset = PER_PAGE * page\n get_run_logs(:limit => PER_PAGE, :offset => offset)\n end",
"def list_files\n User.sync_files!(@context)\n files = user_real_files(params, @context)\n\n if unsafe_params[:limit] && unsafe_params[:offset]\n files = files.limit(unsafe_params[:limit]).offset(unsafe_params[:offset])\n end\n\n search_string = params[:search_string].presence || \"\"\n\n result = files.eager_load(:license, user: :org).\n where(\"nodes.name LIKE ?\", \"%#{search_string}%\").\n order(id: :desc).map do |file|\n describe_for_api(file, unsafe_params[:describe])\n end.compact\n\n render json: unsafe_params[:offset]&.zero? ? { objects: result, count: result.length } : result\n end",
"def file_list\n end",
"def list_files(paths = [], options = {})\n ref = options[:ref] || 'HEAD'\n `git ls-tree --name-only #{ref} #{paths.join(' ')}`.\n split(/\\n/).\n map { |relative_file| File.expand_path(relative_file) }.\n reject { |file| File.directory?(file) } # Exclude submodule directories\n end",
"def diff_files\n hsh = {}\n @base.git.diff_files.split(\"\\n\").each do |line|\n (info, file) = line.split(\"\\t\")\n (mode_src, mode_dest, sha_src, sha_dest, status) = info.split\n hsh[file] = {:path => file, :mode_repo => mode_src.to_s[1, 7], :mode_index => mode_dest,\n :sha_repo => sha_src, :sha_index => sha_dest, :status => status}\n end\n hsh\n end",
"def digests_for(path)\n\t\t\ttotal = 0\n\n\t\t\[email protected] do |key, digest|\n\t\t\t\tdigest.reset\n\t\t\tend\n\n\t\t\tFile.open(path, \"rb\") do |file|\n\t\t\t\tbuffer = \"\"\n\t\t\t\twhile file.read(1024 * 1024 * 10, buffer)\n\t\t\t\t\ttotal += buffer.bytesize\n\t\t\t\t\t\n\t\t\t\t\[email protected](total) if @progress\n\t\t\t\t\t\n\t\t\t\t\[email protected] do |key, digest|\n\t\t\t\t\t\tdigest << buffer\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tmetadata = {}\n\t\t\t\n\t\t\[email protected] do |key, digest|\n\t\t\t\tmetadata[\"key.\" + key] = digest.hexdigest\n\t\t\tend\n\t\t\t\n\t\t\treturn metadata\n\t\tend",
"def files\n FileList.new(`#@native.files`)\n end",
"def all\n # Requires authorization\n raise PutioError::AuthorizationRequired if authentication_required!\n\n files(-1)\n end",
"def list_files_from path,opts = {}\n unless Dir.exists? path\n Logger.<<(__FILE__,\"ERROR\",\"Local fetcher: path does not exists for listing... #{path} \")\n raise \"Error LocalFileFetcher !\"\n end\n if opts[:directories]\n cmd = \"ls -td #{path}/*/\"\n else\n cmd = \"ls #{path}\"\n cmd += \"/#{opts[:regexp]}\" if opts[:regexp]\n end\n out = `#{cmd}`\n return out.split(\"\\n\")\n end",
"def pull_files(localpath, remotepath, filelist)\n connect!\n filelist.each do |f|\n localdir = File.join(localpath, File.dirname(f))\n FileUtils.mkdir_p localdir unless File.exist?(localdir)\n @connection.get \"#{remotepath}/#{f}\", File.join(localpath, f)\n log \"Pulled file #{remotepath}/#{f}\"\n end\n close!\n end",
"def generate_hexdigest_indexed_list(size_indexed_list, head_size = nil)\n result = {}\n size_indexed_list.each_pair{|old_key, filename_arr|\n filename_arr.each{|filename|\n if head_size == nil\n $stdout.puts \"SHA512 hash calculation: #{filename}\"\n else\n $stdout.puts \"Header (#{head_size}) SHA512 hash calculation: #{filename}\"\n end\n\n hexdigest = get_file_header_sha512(filename, head_size)\n\n if result.has_key?(hexdigest) == false\n result[hexdigest] = []\n end\n result[hexdigest].push(filename)\n }\n }\n return result\nend",
"def files_list(params = {})\n response = @session.do_post \"#{SCOPE}.list\", params\n Slack.parse_response(response)\n end",
"def file_ids_hash\n if @file_ids_hash.blank?\n # load the file sha's from cache if possible\n cache_file = File.join(self.path,'.loopoff')\n if File.exists?(cache_file)\n @file_ids_hash = YAML.load(File.read(cache_file))\n else\n # build it\n @file_ids_hash = {}\n self.loopoff_file_names.each do |f|\n @file_ids_hash[File.basename(f)] = Grit::GitRuby::Internal::LooseStorage.calculate_sha(File.read(f),'blob')\n end\n # write the cache\n File.open(cache_file,'w') do |f|\n f.puts YAML.dump(@file_ids_hash) \n end\n end \n end\n @file_ids_hash\n end",
"def hashDirectory(directory)\n count = 0\n hash = {}\n Dir.foreach(directory) do |item|\n next if item == '.' || item == '..'\n hash[count] = item\n count = count + 1\n end\n hash\nend",
"def filelist\n puts_message \"filelist start\" \n\n user = current_user\n\n request = params[:request].force_encoding(\"UTF-8\")\n puts_message \"Requested Path: \" + params[:request]\n \n if user and check_existance_of_path(request) \n if request == nil\n @file_names = 'error'\n elsif request_is_directory?(request)\n fire_the_list(request)\n # @file_names = absolute_path(request)\n elsif request_is_file?(request)\n last = request.split('/').last\n path = absolute_path(request)\n send_file_info(last, request) \n else\n @file_names = 'error'\n end\n else \n @file_names = 'error'\n end\n\n puts_message \"filelist end\" \n \n @output = <<-END\n\n END\n \n if request == \"/images/\"\n @folders = Folder.all(:user_id => current_user.id)\n \n @output << \"photo\" + \"\\n\"\n \n @folders.each do |f|\n @output << f.name + \"\\n\"\n end\n \n @file_names = @output\n end\n \n return @file_names\n\n end",
"def list\n\t\t\tbegin\n\n\t\t\t\t# Prepare result, array of absolute paths for found files\n # within given directory. Also empty cache\n\t\t\t\tresult = []\n @scan_history = {}\n\n\t\t\t\t# Recursively scan current folder for files\n\t\t\t\tFind.find(@scan_path) do |current_full_path|\n\n\t\t\t\t\t# Get filename, prune if dot\n\t\t\t\t\tfilename = File.basename(current_full_path)\n Find.prune if filename[0] == ?.\n\n # Get extension\n extension = File.extname(current_full_path)\n\n\t\t\t\t\t# Check for file extension, if provided\n\t\t\t\t\tif @scan_extension && extension.eql?(@scan_extension)\n\n # Get foldername\n folder_name = File.dirname(current_full_path)\n\n # Get number of files parsed in current folder, default 0\n folder_depth = @scan_history.fetch(folder_name, nil) || 0\n Logging[self].debug \"At #{folder_name}\" if folder_depth == 0\n\n # If the desired depth hasn't been reached\n unless folder_depth == @scan_depth\n\n # Increase current depth\n folder_depth += 1\n\n # Add and log result\n Logging[self].warn \"Result: '#{current_full_path}'\"\n result << current_full_path\n\n # Update cache, proceed no further in this folder\n @scan_history[folder_name] = folder_depth\n Find.prune\n end\n\t\t\t\t\telse\n\t\t\t\t\t\n\t\t\t\t\t\t# Either move beyond this file, if we're searching\n\t\t\t\t\t\t# for specific files (filtered by extension), or add\n # the path to the result (since no filter applied)\n\t\t\t\t\t\t@scan_extension ? next : (result << current_full_path)\n\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\t\t\n end # find block\n\n # Log final result length\n Logging[self].info \"Retrieved #{result.length} results\"\n\n\t\t\t\t# Return result\n\t\t\t\tresult\n\n\t\t\t# Rescue any exceptions\n\t\t\trescue Exception => e\n\t\t\t\tLogging[self].error e\n nil\n\t\t\tend\n\t\tend",
"def test_getfilelist\n server = nil\n testdir, pattern, tmpfile = mktestdir\n\n file = nil\n\n assert_nothing_raised {\n\n server = Puppet::Network::Handler.fileserver.new(\n\n :Local => true,\n\n :Config => false\n )\n }\n\n assert_nothing_raised {\n server.mount(testdir, \"test\")\n }\n\n # get our listing\n list = nil\n sfile = \"/test/tmpfile\"\n assert_nothing_raised {\n list = server.list(sfile, :manage, true, false)\n }\n\n output = \"/\\tfile\"\n\n # verify it got listed as a file\n assert_equal(output, list)\n\n # verify we got all fields\n assert(list !~ /\\t\\t/)\n\n # verify that we didn't get the directory itself\n list.split(\"\\n\").each { |line|\n assert(line !~ %r{remotefile})\n }\n\n # and then verify that the contents match\n contents = File.read(tmpfile)\n\n ret = nil\n assert_nothing_raised {\n ret = server.retrieve(sfile)\n }\n\n assert_equal(contents, ret)\n end",
"def files\n @files ||= begin\n storage = model.storages.first\n return [] unless storage # model didn\"t store anything\n\n path = storage.send(:remote_path)\n unless path == File.expand_path(path)\n path.sub!(%r{(ssh|rsync)-daemon-module}, \"\")\n path = File.expand_path(File.join(\"tmp\", path))\n end\n Dir[File.join(path, \"#{model.trigger}.tar*\")].sort\n end\n end",
"def enumerate_scripts\n Dir.glob(\"**/*\").\n reject { |f| File.directory?(f) }.\n select { |f| File.extname(f) == \".rb\" }.\n map do |filename|\n stat = File.stat(filename)\n\n OpenStruct.new(\n id: SecureRandom.uuid,\n path: filename,\n absolute_path: File.expand_path(filename),\n virtual_url: \"#{ROOT_URL}/#{filename}\",\n size: stat.size,\n last_modified_time: stat.mtime\n )\n end\n end",
"def list_files(paths = [], options = {})\n ref = options[:ref] || 'HEAD'\n\n result = Overcommit::Utils.execute(%W[git ls-tree --name-only #{ref}], args: paths)\n unless result.success?\n raise Overcommit::Exceptions::Error,\n \"Error listing files. EXIT STATUS(es): #{result.statuses}.\\n\" \\\n \"STDOUT(s): #{result.stdouts}.\\n\" \\\n \"STDERR(s): #{result.stderrs}.\"\n end\n\n result.stdout.split(/\\n/).\n map { |relative_file| File.expand_path(relative_file) }.\n reject { |file| File.directory?(file) } # Exclude submodule directories\n end",
"def get_file_hash(fullPath)\n contents = File.read(fullPath)\n fileHash = Digest::MD5.hexdigest(contents)\n return fileHash\nend",
"def files\n @files ||= full_files.map {|file| relative(file) }\n end",
"def diff_files\n hsh = {}\n @base.git.diff_files.split(\"\\n\").each do |line|\n (info, file) = line.split(\"\\t\")\n (mode_src, mode_dest, sha_src, sha_dest, type) = info.split\n hsh[file] = {:path => file, :mode_file => mode_src.to_s[1, 7], :mode_index => mode_dest,\n :sha_file => sha_src, :sha_index => sha_dest, :type => type}\n end\n hsh\n end",
"def buildCodeFilesHashFromFiles()\n\t\tdir = @cacheDirPath \n\t\tfilesList = Dir.glob(dir + \"**/*\").select{|e| File.file? e}\n\t\tfilesList.map.with_index{|file,index|\n\t\t\t#p \"cacheFile: \" + index.to_s if index % 1000 == 0\n\t\t\tp \"cacheFile: \" + index.to_s \n\t\t\tfilePath = dir + index.to_s + \".yaml\"\n\t\t\tfile = File.read(filePath)\n\t\t\tYAML.load(file)\n\t\t}.to_h\n\tend",
"def files\n array = []\n @list.each do |k,v|\n array += v.filename\n end\n array\n end",
"def files\n db = Database.find(params[:id])\n @files = Dir.entries(db.path)\n @files.delete_if{|f| !f.include?'.dat'}\n @results = []\n @files.each do |entry|\n @results << {:name=>entry,:version=>db.version}\n end\n respond_to do |format|\n format.html\n format.json { render json: @results }\n end\n end",
"def find_files(base_dir, flags); end",
"def all_files; end",
"def all_files; end",
"def files_in branch:\n array_output_of(\"git ls-tree -r --name-only #{branch}\")\nend",
"def files(treeish = nil)\n tree_list(treeish || @ref, false, true)\n end",
"def getFiles(tree, name)\n files = []\n\n tree.each_tree do |subtree|\n path = name + subtree[:name] + '/'\n subfiles = getFiles($repo.lookup(subtree[:oid]), path)\n files.push(*subfiles)\n end\n\n tree.each_blob do |file|\n file[:name] = name + file[:name]\n files.push(file)\n end\n\n return files\nend",
"def index\n @nthfiles = Nthfile.all\n end",
"def list(path=nil, sha=nil)\n remote_path = list_path(path).sub(/^\\//, '').sub(/\\/$/, '')\n\n result = @client.tree(repo, sha || source_branch, recursive: true).tree\n result.sort! do |x, y|\n x.path.split('/').size <=> y.path.split('/').size\n end\n\n # Filters for folders containing the specified path\n result.reject! { |elem| !elem.path.match(remote_path + '($|\\/.+)') }\n raise Error, 'Invalid GitHub path specified' if result.empty?\n\n # Filters out lower levels\n result.reject! do |elem|\n filename = elem.path.split('/').last\n File.join(remote_path, filename).sub(/^\\//, '') != elem.path\n end\n\n result.map do |elem|\n {\n name: elem.path.split('/').last,\n path: elem.path,\n type: elem.type == 'tree' ? 'folder' : 'file',\n sha: elem.sha\n }\n end\n end",
"def processFile dir\n\tdir.each do |file|\n\t\tif File.directory?(file) then next;\n\t\t\telse \n\t\t\t\th = {File.basename(file) => getHash(file)}\n\t\t\t\[email protected]!(h)\n\t\tend\n\tend\n\t@hash\nend",
"def find(dirs); end",
"def find_files\n find_files_recursive(@build_result_dir, '')\n end",
"def md5_sum(file_name)\n dst_path = \"#{self.path}#{file_name}\"\n cmd = self.class.curr_host == host ?\n \"find #{dst_path.shellescape} -type f -exec md5sum {} \\\\; | awk '{print $1}' | sort | md5sum\" :\n \"ssh -q -oBatchMode=yes -oStrictHostKeyChecking=no #{self.host} \\\"find #{dst_path.shellescape} -type f -exec md5sum {} \\\\; | awk '{print \\\\$1}' | sort | md5sum\\\"\"\n r = `#{cmd} 2>&1`\n raise r if $?.exitstatus != 0\n r.to_s[0..31]\n end",
"def md5_sum(file_name)\n dst_path = \"#{self.path}#{file_name}\"\n cmd = self.class.curr_host == host ?\n \"find #{dst_path.shellescape} -type f -exec md5sum {} \\\\; | awk '{print $1}' | sort | md5sum\" :\n \"ssh -q -oBatchMode=yes -oStrictHostKeyChecking=no #{self.host} \\\"find #{dst_path.shellescape} -type f -exec md5sum {} \\\\; | awk '{print \\\\$1}' | sort | md5sum\\\"\"\n r = `#{cmd} 2>&1`\n raise r if $?.exitstatus != 0\n r.to_s[0..31]\n end",
"def files\n @header.dirindexes.map { |idx|\n @header.dirnames[idx]\n }.zip(@header.basenames).map { |dir, name|\n ::File.join(dir, name)\n }.zip(@header.filesizes).map { |path, size|\n Rupert::RPM::File.new(path, size)\n }\n end",
"def new_files\n db = Database::Mysql.default\n table = Database::GenericTable.new(db,$table)\n # generate the hash structure\n files = Util.folders($type).inject({}) {|col,f| col[f] = []; col}\n puts files.inspect\n db.connect do\n select = [\"*\"]\n where = { processed: 0 }\n res = table.search_and select,where \n res.each_hash do |row|\n files[row[\"switch\"]] << row[\"file_name\"]\n end\n puts \"Found #{res.num_rows} new files to process in #{$table}...\" if $opts[:v]\n end\n files\nend",
"def get_files_modified\r\n\tgit_result = IO.popen('git status -u --porcelain').read\r\n\tgit_result.split(/[\\r\\n]+/).uniq.map!{|file| file.slice 3..-1}\r\nend",
"def get_digest(file, version)\n # Make a hash with each individual file as a key, with the appropriate digest as value.\n inverted = get_state(version).invert\n my_files = {}\n inverted.each do |files, digest|\n files.each do |i_file|\n my_files[i_file] = digest\n end\n end\n # Now see if the requested file is actually here.\n unless my_files.key?(file)\n raise OcflTools::Errors::FileMissingFromVersionState, \"Get_digest can't find requested file #{file} in version #{version}.\"\n end\n\n my_files[file]\n end",
"def list_files repos\n raise \"required repository name\" unless repos\n res = HTTPClient.get_content(\"https://github.com/#{repos}/downloads\", {\n \"login\" => @login,\n \"token\" => @token\n })\n Nokogiri::HTML(res).xpath('id(\"manual_downloads\")/li').map do |fileinfo|\n obj = {\n :description => fileinfo.at_xpath('descendant::h4').text.force_encoding('BINARY').gsub(/.+?\\xe2\\x80\\x94 (.+?)(\\n\\s*)?$/m, '\\1'),\n :date => fileinfo.at_xpath('descendant::p/time').attribute('title').text,\n :size => fileinfo.at_xpath('descendant::p/strong').text,\n :id => /\\d+$/.match(fileinfo.at_xpath('a').attribute('href').text)[0]\n }\n anchor = fileinfo.at_xpath('descendant::h4/a')\n obj[:link] = anchor.attribute('href').text\n obj[:name] = anchor.text\n obj\n end\n end",
"def list_files\n Find.find(path) do |element| yield element end\n end",
"def file_list\n @file_list\n end",
"def index\n fs = FileStore.by_hash(params[:hash])\n\n file_stores = fs.map do |item|\n {\n sha1_hash: item.sha1_hash,\n file_name: File.basename(item.file.path),\n user: {\n id: item.user_id,\n uname: item.user_uname\n }\n }\n end\n render json: file_stores\n end"
] | [
"0.6858345",
"0.65153563",
"0.64512634",
"0.61644745",
"0.60218716",
"0.6014607",
"0.59915817",
"0.5990313",
"0.59625727",
"0.5960861",
"0.5960861",
"0.59424496",
"0.59277815",
"0.591865",
"0.5794828",
"0.57515365",
"0.5734461",
"0.56097907",
"0.5580782",
"0.5576285",
"0.5576285",
"0.55714124",
"0.5489135",
"0.5466171",
"0.5452844",
"0.5446284",
"0.5395767",
"0.5391372",
"0.53785735",
"0.5370128",
"0.5361375",
"0.53552294",
"0.534704",
"0.53425694",
"0.53349286",
"0.5332499",
"0.5324697",
"0.53236586",
"0.52890843",
"0.5288167",
"0.5286001",
"0.5265792",
"0.5263433",
"0.5260826",
"0.52530754",
"0.5246772",
"0.52432454",
"0.524126",
"0.52404726",
"0.5238191",
"0.5236137",
"0.5222219",
"0.5221148",
"0.520967",
"0.52081895",
"0.5207016",
"0.52063406",
"0.5185135",
"0.5183615",
"0.5182585",
"0.51822954",
"0.51814747",
"0.5179037",
"0.5175649",
"0.5173218",
"0.5168979",
"0.51685524",
"0.516348",
"0.51616013",
"0.51602495",
"0.51508397",
"0.5146909",
"0.5137909",
"0.51365644",
"0.51357585",
"0.51328224",
"0.5130665",
"0.5121209",
"0.5118967",
"0.5115224",
"0.5112793",
"0.5112793",
"0.5111932",
"0.51046336",
"0.51030403",
"0.50979006",
"0.5090322",
"0.50896627",
"0.5087975",
"0.5086783",
"0.5076545",
"0.5076545",
"0.5067339",
"0.5062041",
"0.5061374",
"0.5059777",
"0.50562245",
"0.50494915",
"0.5047788",
"0.5047112"
] | 0.70343643 | 0 |
N Without this we won't have an easy way to present a description of this object (for tracing, feedback) | def to_s
return contentHost.locationDescriptor(baseDir)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inspect()\n #This is a stub, used for indexing\n end",
"def inspect\n \"#{self.class}<#{@description.inspect}>\"\n end",
"def inspect() end",
"def inspect() end",
"def inspect() end",
"def inspect() end",
"def inspect() end",
"def inspect() end",
"def inspect() end",
"def inspect() end",
"def inspect() end",
"def inspect() end",
"def inspect() end",
"def inspect() end",
"def inspect() end",
"def inspect() end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect\n # Concise to not dump too much information on the dev\n \"#<#{self.class.name}>\"\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n \"#<#{self.class} @label=#{label} docs=#{docs}>\"\n end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def inspect\n \"#<#{self.class.name}: #{to_s}>\"\n end",
"def inspect\n \"#<#{self.class.name}: #{to_s}>\"\n end",
"def inspect\n \"(#{self.class.name}:#{hexy_object_id}#{inspect_details})\"\n end",
"def base_description(_); end",
"def inspect\n\t\treturn \"#<%s:0x%0x %s(%s) %p -> %p >\" % [\n\t\t\tself.class.name,\n\t\t\tself.object_id / 2,\n\t\t\tself.name,\n\t\t\tself.oid,\n\t\t\tself.desc,\n\t\t\tself.attr_oids,\n\t\t]\n\tend",
"def inspect\n return \"#<#{self.class.name}: #{self.name}>\"\n end",
"def inspect\n \"<#{self.class}:0x#{object_id.to_s(16)}>\"\n end",
"def insp\r\n self.inspect\r\n end",
"def inspect\n +\"#<#{self.class}:#{object_id.to_s(16)}>\"\n end",
"def inspect\n \"#<#{self.class.name}:#{object_id}> @names=#{names}>\"\n end",
"def inspect\n self.to_s\n end",
"def inspect\n self.to_s\n end",
"def desc; end",
"def inspect\n \"#<#{self.class.inspect}(#{@name})>\"\n end",
"def inspect\n \"#<#{self.class.name}:#{self.object_id}, #{inspector(:@messages)}>\"\n end",
"def description\n object[\"description\"]\n end",
"def description\n raise \"not implemented\"\n end",
"def inspect\n return \"#<#{self.class.name}: #{self}>\"\n end",
"def inspect\n \"#<#{self.class.name.split('::').last} - #{@properties}>\"\n end",
"def description\n self.class.desc\n end",
"def inspect\n \"#<#{self.class}:#{type_sym}:#{object_id.to_s(16)}>\"\n end",
"def inspect\n String.new('#<').concat(\n self.class.name, ':',\n object_id.to_s, ' ', to_s, '>'\n )\n end",
"def inspect\n String.new('#<').concat(\n self.class.name, ':',\n object_id.to_s, ' ', to_s, '>'\n )\n end",
"def inspect\n String.new('#<').concat(\n self.class.name, ':',\n object_id.to_s, ' ', to_s, '>'\n )\n end",
"def inspect\n String.new('#<').concat(\n self.class.name, ':',\n object_id.to_s, ' ', to_s, '>'\n )\n end",
"def details; end",
"def describe\n @description\n end",
"def describe\n @description\n end",
"def inspect(*) end"
] | [
"0.78157413",
"0.7709494",
"0.7525486",
"0.7525486",
"0.7525486",
"0.7525486",
"0.7525486",
"0.7525486",
"0.7525486",
"0.7525486",
"0.7525486",
"0.7525486",
"0.7525486",
"0.7525486",
"0.7525486",
"0.7525486",
"0.7507172",
"0.7507172",
"0.7507172",
"0.7507172",
"0.7507172",
"0.7507172",
"0.7507172",
"0.7507172",
"0.7507172",
"0.7507172",
"0.7507172",
"0.7507172",
"0.7507172",
"0.7507172",
"0.7507172",
"0.7507172",
"0.7507172",
"0.7507172",
"0.7507172",
"0.7507172",
"0.7507172",
"0.7507172",
"0.7507172",
"0.7507172",
"0.7507172",
"0.7507172",
"0.7507172",
"0.7507172",
"0.7507172",
"0.7489368",
"0.7473359",
"0.7473359",
"0.7456941",
"0.7456941",
"0.7456941",
"0.7456941",
"0.7456941",
"0.7456941",
"0.7456941",
"0.7456941",
"0.7456941",
"0.7456941",
"0.7456941",
"0.7456941",
"0.7456941",
"0.7441427",
"0.74003375",
"0.74003375",
"0.74003375",
"0.74003375",
"0.74003375",
"0.74003375",
"0.74003375",
"0.74003375",
"0.74003375",
"0.74003375",
"0.73943573",
"0.7330938",
"0.7295049",
"0.7286351",
"0.72803026",
"0.725844",
"0.72384995",
"0.723251",
"0.7227631",
"0.7221255",
"0.72029287",
"0.72029287",
"0.7199614",
"0.7185237",
"0.7181627",
"0.7179865",
"0.71767336",
"0.7171802",
"0.7135102",
"0.7132445",
"0.7129718",
"0.7128682",
"0.7128682",
"0.7128682",
"0.7128682",
"0.7112552",
"0.7109775",
"0.7109775",
"0.70880145"
] | 0.0 | -1 |
Get the content tree, from the cached content file if it exists, otherwise get if from listing directories and files and hash values thereof on the remote host. And also, if the cached content file name is specified, write the content tree out to that file. N Without this we won't have a way to get the content tree representing the contents of the remote directory, possibly using an existing cached content tree file (and if not, possibly saving a cached content tree for next time) | def getContentTree
#N Without this check we would try to read the cached content file when there isn't one, or alternatively, we would retrieve the content details remotely, when we could have read them for a cached content file
if cachedContentFile and File.exists?(cachedContentFile)
#N Without this, the content tree won't be read from the cached content file
return ContentTree.readFromFile(cachedContentFile)
else
#N Without this, we wouldn't retrieve the remote content details
contentTree = contentHost.getContentTree(baseDir)
#N Without this, the content tree might be in an arbitrary order
contentTree.sort!
#N Without this check, we would try to write a cached content file when no name has been specified for it
if cachedContentFile != nil
#N Without this, the cached content file wouldn't be updated from the most recently retrieved details
contentTree.writeToFile(cachedContentFile)
end
#N Without this, the retrieved sorted content tree won't be retrieved
return contentTree
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getCachedContentTree\n #N Without this, we won't know the name of the specified cached content file (if it is specified)\n file = getExistingCachedContentTreeFile\n #N Without this check, we would attempt to read a non-existent file\n if file\n #N Without this, a content tree that has been cached won't be returned.\n return ContentTree.readFromFile(file)\n else\n return nil\n end\n end",
"def getContentTree\n #N Without this we won't have timestamp and the map of file hashes used to efficiently determine the hash of a file which hasn't been modified after the timestamp\n cachedTimeAndMapOfHashes = getCachedContentTreeMapOfHashes\n #N Without this we won't have the timestamp to compare against file modification times\n cachedTime = cachedTimeAndMapOfHashes[0]\n #N Without this we won't have the map of file hashes\n cachedMapOfHashes = cachedTimeAndMapOfHashes[1]\n #N Without this we won't have an empty content tree which can be populated with data describing the files and directories within the base directory\n contentTree = ContentTree.new()\n #N Without this we won't have a record of a time which precedes the recording of directories, files and hashes (which can be used when this content tree is used as a cached for data when constructing some future content tree)\n contentTree.time = Time.now.utc\n #N Without this, we won't record information about all sub-directories within this content tree\n for subDir in @baseDirectory.subDirs\n #N Without this, this sub-directory won't be recorded in the content tree\n contentTree.addDir(subDir.relativePath)\n end\n #N Without this, we won't record information about the names and contents of all files within this content tree\n for file in @baseDirectory.allFiles\n #N Without this, we won't know the digest of this file (if we happen to have it) from the cached content tree\n cachedDigest = cachedMapOfHashes[file.relativePath]\n #N Without this check, we would assume that the cached digest applies to the current file, even if one wasn't available, or if the file has been modified since the time when the cached value was determined.\n # (Extra note: just checking the file's mtime is not a perfect check, because a file can \"change\" when actually it or one of it's enclosing sub-directories has been renamed, which might not reset the mtime value for the file itself.)\n if cachedTime and cachedDigest and File.stat(file.fullPath).mtime < cachedTime\n #N Without this, the digest won't be recorded from the cached digest in those cases where we know the file hasn't changed\n digest = cachedDigest\n else\n #N Without this, a new digest won't be determined from the calculated hash of the file's actual contents\n digest = hashClass.file(file.fullPath).hexdigest\n end\n #N Without this, information about this file won't be added to the content tree\n contentTree.addFile(file.relativePath, digest)\n end\n #N Without this, the files and directories in the content tree might be listed in some indeterminate order\n contentTree.sort!\n #N Without this check, a new version of the cached content file will attempt to be written, even when no name has been specified for the cached content file\n if cachedContentFile != nil\n #N Without this, a new version of the cached content file (ready to be used next time) won't be created\n contentTree.writeToFile(cachedContentFile)\n end\n return contentTree\n end",
"def getExistingCachedContentTreeFile\n #N Without this check, it would try to find the cached content file when none was specified\n if cachedContentFile == nil\n #N Without this, there will be no feedback to the user that no cached content file is specified\n puts \"No cached content file specified for location\"\n return nil\n #N Without this check, it will try to open the cached content file when it doesn't exist (i.e. because it hasn't been created, or, it has been deleted)\n elsif File.exists?(cachedContentFile)\n #N Without this, it won't return the cached content file when it does exist\n return cachedContentFile\n else\n #N Without this, there won't be feedback to the user that the specified cached content file doesn't exist.\n puts \"Cached content file #{cachedContentFile} does not yet exist.\"\n return nil\n end\n end",
"def fetch_file_contents(remote_path)\n result = backend.file(remote_path)\n if result.exist? && result.file?\n result.content\n else\n nil\n end\n end",
"def getCachedContentTreeMapOfHashes\n #N Without this, we won't know the name of the specified cached content file (if it is specified)\n file = getExistingCachedContentTreeFile\n #N Without this check, we would attempt to read a non-existent file\n if file\n #N Without this, there won't be feedback to the user that we are reading the cached file hashes\n puts \"Reading cached file hashes from #{file} ...\"\n #N Without this, a map of cached file hashes won't be returned\n return ContentTree.readMapOfHashesFromFile(file)\n else\n #N Without this, the method wouldn't consistently return an array of timestamp + map of hashes in the case where there is no cached content file\n return [nil, {}]\n end\n end",
"def getContentCache(theContent)\n\n\ttheChecksum = Digest::SHA256.hexdigest(theContent).insert(2, '/');\n\ttheCache = \"#{PATH_FORMAT_CACHE}/#{theChecksum}\";\n\t\n\treturn theCache;\n\nend",
"def remote_contents_of(file)\n contents_of(remote_branch(local_branch), file)\n end",
"def cache # :nodoc:\n return unless @remote\n\n if File.exist? repo_cache_dir\n Dir.chdir repo_cache_dir do\n system @git, 'fetch', '--quiet', '--force', '--tags',\n @repository, 'refs/heads/*:refs/heads/*'\n end\n else\n system @git, 'clone', '--quiet', '--bare', '--no-hardlinks',\n @repository, repo_cache_dir\n end\n end",
"def content\n return @content if application.cache_pages? && @content\n\n @content = if file?\n IO.read(path)\n elsif io?\n path.read\n else\n path\n end\n end",
"def get_contents \n @contents = []\n\n sub_directory_names = Dir[CONTENT_ROOT_DIRECTORY + \"/*\"]\n\n sub_directory_names.each do |sub_directory_name|\n sub_directory_basename = File.basename(sub_directory_name)\n @contents.push(Content.new(sub_directory_basename))\n end\n end",
"def getContentTrees\n #N Without this, we wouldn't get the content tree for the local source location\n @sourceContent = @sourceLocation.getContentTree()\n #N Without this, we wouldn't get the content tree for the remote destination location\n @destinationContent = @destinationLocation.getContentTree()\n end",
"def list_contents\n {}.tap do |files|\n remote_files do |file|\n ftp.gettextfile(file) do |line, newline|\n content.concat newline ? line + \"\\n\" : line\n end # temporarly downloads the file\n FileUtils.rm file\n files[file] = { data: content }\n end\n end\n end",
"def contents(path)\n puts \"#contents(#{path})\" if DEBUG\n results = []\n root_path = zk_path(path)\n zk.find(root_path) do |z_path|\n if (z_path != root_path)\n z_basename = z_path.split('/').last\n stats = zk.stat(z_path)\n results << \"#{z_basename}\" if stats.numChildren > 0\n results << \"#{z_basename}.contents\" if zk.stat(z_path).dataLength > 0\n ZK::Find.prune\n end\n end\n results\n end",
"def cache(content, options={})\n return content unless Sinatra.options.cache_enabled\n \n unless content.nil?\n path = cache_page_path(request.path_info)\n FileUtils.makedirs(File.dirname(path))\n open(path, 'wb+') { |f| f << content } \n content\n end\n end",
"def fetch_remote_template_and_store\n template_body = fetch_template_from_url\n\n if template_body\n store_template_to_local_cache( template_body )\n store_template_to_redis( template_body )\n end\n\n return template_body\n end",
"def get_cache(url, options = {})\n\t\t\tpath = @@cache_directory_path + options[:lang] + '/' + url_to_filename(url)\n\t\t\t\n\t\t\t# file doesn't exist, make it\n\t\t\tif !File.exists?(path)\n\t\t\t\tif options[:debug]\n\t\t\t\t\tputs 'Cache doesn\\'t exist, making: ' + path\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\t# make sure dir exists\n\t\t\t\tFileUtils.mkdir_p(localised_cache_path(options[:lang])) unless File.directory?(localised_cache_path(options[:lang]))\n\t\t\t\t\n\t\t\t\txml_content = http_request(url, options)\n\t\t\t\t\n\t\t\t\t# write the cache\n\t\t\t\tfile = File.open(path, File::WRONLY|File::TRUNC|File::CREAT)\n\t\t\t\tfile.write(xml_content)\n\t\t\t\tfile.close\n\t\t\t\n\t\t\t# file exists, return the contents\n\t\t\telse\n\t\t\t\tputs 'Cache already exists, read: ' + path if options[:debug]\n\t\t\t\t\n\t\t\t\tfile = File.open(path, 'r')\n\t\t\t\txml_content = file.read\n\t\t\t\tfile.close\n\t\t\tend\n\t\t\treturn xml_content\n\t\tend",
"def setup_remote\n if(@cache_file)\n begin\n @cf = File.open(@cache_file, 'w+')\n rescue\n @cf = nil\n end\n end\n @uri = URI.parse(@path)\n @con = Net::HTTP.new(@uri.host, @uri.port)\n @call_path = @uri.path + (@uri.query ? \"?#{@uri.query}\" : '')\n res = @con.request_get(@call_path)\n @heads = res.to_hash\n res.value\n @store = nil\n @redefine_prefix = 'remote'\n end",
"def get_remote_files_hierarchy(files, root = '/', hierarchy = { dirs: [], files: [] })\n files.each do |node|\n case node['node_type']\n when 'directory'\n hierarchy[:dirs] << \"#{root}#{node['name']}\"\n get_remote_files_hierarchy(node['files'], root + node['name'] + '/', hierarchy)\n when 'file'\n hierarchy[:files] << \"#{root}#{node['name']}\"\n end\n end\n\n hierarchy\nend",
"def get_remote_files_hierarchy(files, root = '/', hierarchy = { dirs: [], files: [] })\n files.each do |node|\n case node['node_type']\n when 'branch'\n get_remote_files_hierarchy(node['files'], root + node['name'] + '/', hierarchy)\n when 'directory'\n hierarchy[:dirs] << \"#{root}#{node['name']}\"\n get_remote_files_hierarchy(node['files'], root + node['name'] + '/', hierarchy)\n when 'file'\n hierarchy[:files] << \"#{root}#{node['name']}\"\n end\n end\n\n return hierarchy\nend",
"def write_if_empty\n return if cached_content.present?\n\n @diff_collection.diff_files.each do |diff_file|\n next unless cacheable?(diff_file)\n\n diff_file_id = diff_file.file_identifier\n\n cached_content[diff_file_id] = diff_file.highlighted_diff_lines.map(&:to_hash)\n end\n\n cache.write(key, cached_content, expires_in: 1.week)\n end",
"def get_remote_files_hierarchy(files, root = '/', hierarchy = { dirs: [], files: [] })\n files.each do |node|\n case node['node_type']\n when 'directory'\n hierarchy[:dirs] << \"#{root}#{node['name']}\"\n get_remote_files_hierarchy(node['files'], root + node['name'] + '/', hierarchy)\n when 'file'\n hierarchy[:files] << \"#{root}#{node['name']}\"\n end\n end\n\n return hierarchy\nend",
"def get_contents uri,user,password,recursive=false\n \n found=[]\n\n content = propfind uri,user,password,1\n\n parser = LibXML::XML::Parser.string(content,:encoding => LibXML::XML::Encoding::UTF_8)\n\n document = parser.parse\n\n href_nodes = document.find(\"ns:response\",\"ns:DAV:\")\n \n href_nodes.each do |node|\n unless node == href_nodes.first \n href_node=node.find_first(\"ns:href\",\"ns:DAV:\")\n last_modified_node = node.find_first(\"*/ns:prop\",\"ns:DAV:\").find_first(\"ns:getlastmodified\",\"ns:DAV:\")\n creation_date_node = node.find_first(\"*/ns:prop\",\"ns:DAV:\").find_first(\"ns:creationdate\",\"ns:DAV:\")\n content_type_node = node.find_first(\"*/ns:prop\",\"ns:DAV:\").find_first(\"ns:getcontenttype\",\"ns:DAV:\")\n\n attributes={ \n :containing_path=>uri.to_s,\n :full_path=>uri.merge(href_node.inner_xml).to_s,\n :updated_at=>DateTime.parse(last_modified_node.inner_xml).to_s,\n :created_at=>DateTime.parse(creation_date_node.inner_xml).to_s,\n :is_directory=>is_dir?(href_node,content_type_node)\n }\n found << attributes\n end\n end\n \n found.select{|a| a[:is_directory]}.each do |dir_tuple|\n child_uri=URI.parse(dir_tuple[:full_path])\n children=get_contents child_uri,user,password,true\n dir_tuple[:children]=children\n end if recursive\n \n return found\n \n end",
"def fetch_local(new_dest, fetch_if_missing = true)\n if !File.exists? @repo.cache_path\n if fetch_if_missing\n fetch\n else\n raise \"Source cache #{@repo.cache_path} not readable.\"\n end\n end\n FileUtils.cp_r @repo.cache_path, new_dest\n end",
"def cache # :nodoc:\n if File.exist? repo_cache_dir then\n Dir.chdir repo_cache_dir do\n system @git, 'fetch', '--quiet', '--force', '--tags',\n @repository, 'refs/heads/*:refs/heads/*'\n end\n else\n system @git, 'clone', '--quiet', '--bare', '--no-hardlinks',\n @repository, repo_cache_dir\n end\n end",
"def get_cache(url, options = {})\n\t\t\tpath = cache_path(url, options)\n\t\t\t\t\n\t\t\t# file doesn't exist, make it\n\t\t\tif !File.exists?(path) ||\n\t\t\t\t\toptions[:refresh_cache] ||\n\t\t\t\t\t(File.mtime(path) < Time.now - @cache_timeout)\n\t\t\t\t\t\n\t\t\t\tif options[:debug]\n\t\t\t\t\tif !File.exists?(path)\n\t\t\t\t\t\tputs 'Cache doesn\\'t exist, making: ' + path\n\t\t\t\t\telsif (File.mtime(path) < Time.now - @cache_timeout)\n\t\t\t\t\t\tputs 'Cache has expired, making again, making: ' + path\n\t\t\t\t\telsif options[:refresh_cache]\n\t\t\t\t\t\tputs 'Forced refresh of cache, making: ' + path\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\t# make sure dir exists\n\t\t\t\tFileUtils.mkdir_p(localised_cache_path(options[:lang])) unless File.directory?(localised_cache_path(options[:lang]))\n\t\t\t\t\n\t\t\t\txml_content = http_request(url, options)\n\t\t\t\t\n\t\t\t\t# write the cache\n\t\t\t\tfile = File.open(path, File::WRONLY|File::TRUNC|File::CREAT)\n\t\t\t\tfile.write(xml_content)\n\t\t\t\tfile.close\n\t\t\t\n\t\t\t# file exists, return the contents\n\t\t\telse\n\t\t\t\tputs 'Cache already exists, read: ' + path if options[:debug]\n\t\t\t\t\n\t\t\t\tfile = File.open(path, 'r')\n\t\t\t\txml_content = file.read\n\t\t\t\tfile.close\n\t\t\tend\n\t\t\treturn xml_content\n\t\tend",
"def write_content\n File.open(absolute_path,'w') do |file|\n file << content if content\n end\n # TODO git functionality\n end",
"def getFile(tree, name, path = '')\n blob = nil\n\n tree.each_blob do |file|\n blob = file if file[:name] == name[/[^\\/]*/]\n blob[:name] = path + blob[:name]\n end\n\n if blob.nil?\n tree.each_tree do |subtree|\n if subtree[:name] == name[/[^\\/]*/]\n path += name.slice! name[/[^\\/]*/]\n name[0] = ''\n return getFile($repo.lookup(subtree[:oid]), name, path + '/')\n end\n end\n end\n\n return blob\nend",
"def find\n \"#{content_path}#{clean_path}\"\n end",
"def getContentTree(baseDir)\n #N Without this, wouldn't have an empty content tree that we could start filling with dir & file data\n contentTree = ContentTree.new()\n #N Without this, wouldn't record the time of the content tree, and wouldn't be able to determine from a file's modification time that it had been changed since that content tree was recorded.\n contentTree.time = Time.now.utc\n #N Without this, the listed directories won't get included in the content tree\n for dir in listDirectories(baseDir)\n #N Without this, this directory won't get included in the content tree\n contentTree.addDir(dir)\n end\n #N Without this, the listed files and hashes won't get included in the content tree\n for fileHash in listFileHashes(baseDir)\n #N Without this, this file & hash won't get included in the content tree\n contentTree.addFile(fileHash.relativePath, fileHash.hash)\n end\n return contentTree\n end",
"def cached_wget(url, override_cache=false)\n\tputs \" Fetching #{url}\"\n\tcache_file_name = File.join CACHE_DIR, Digest::MD5.hexdigest(url)\n\tif override_cache or not File.exists? cache_file_name\n\t\tFile.open(cache_file_name, 'w') do |cache_file| \n\t\t\topen(url) do |remote_file|\n\t\t\t\tremote_file.each_line do |remote_line| \n\t\t\t\t\tcache_file.puts remote_line\n\t\t\t\tend\n\t\t\tend\n\t\tend \n\t\tputs \" (downloaded fresh copy to #{cache_file_name})\"\n\telse\n\t\tputs \" (loaded from cache #{cache_file_name})\"\n\tend\n\tcache_file_name\nend",
"def read_content(entry)\n entry.rewind if entry.respond_to? :rewind\n case entry\n when File, Tempfile, StringIO then entry.read\n when Dir then (entry.entries - ['.', '..']).collect { |filename| read_content(Pathname.new(File.join(entry.path, filename))) }.compact.sort\n when String then entry\n when Pathname then\n if entry.directory?\n read_content(entry)\n elsif entry.file?\n File.open(entry, 'r:binary').read\n end\n end\nend",
"def recurse_remote(children)\n sourceselect = self[:sourceselect]\n\n total = self[:source].collect do |source|\n next unless result = perform_recursion(source)\n return if top = result.find { |r| r.relative_path == \".\" } and top.ftype != \"directory\"\n result.each { |data| data.source = \"#{source}/#{data.relative_path}\" }\n break result if result and ! result.empty? and sourceselect == :first\n result\n end.flatten\n\n # This only happens if we have sourceselect == :all\n unless sourceselect == :first\n found = []\n total.reject! do |data|\n result = found.include?(data.relative_path)\n found << data.relative_path unless found.include?(data.relative_path)\n result\n end\n end\n\n total.each do |meta|\n if meta.relative_path == \".\"\n parameter(:source).metadata = meta\n next\n end\n children[meta.relative_path] ||= newchild(meta.relative_path)\n children[meta.relative_path][:source] = meta.source\n children[meta.relative_path][:checksum] = :md5 if meta.ftype == \"file\"\n\n children[meta.relative_path].parameter(:source).metadata = meta\n end\n\n children\n end",
"def save\n Chef::FileCache.store(\"remote_file/#{sanitized_cache_file_basename}\", json_data)\n end",
"def receive_content(message)\n Log.info(\"Backup server received Remote content data\")\n @last_fetch_timestamp = Time.now.to_i\n\n # Update remote content data and write to file if changed ContentData received\n if(message.unique_id != @last_content_data_id)\n path = File.join(@content_server_content_data_path, @last_fetch_timestamp.to_s + '.cd')\n FileUtils.makedirs(@content_server_content_data_path) unless \\\n File.directory?(@content_server_content_data_path)\n $remote_content_data_lock.synchronize{\n $remote_content_data = message\n $remote_content_data.to_file(path)\n @last_content_data_id = message.unique_id # save last content data ID\n }\n Log.debug1(\"Written content data to file:%s.\", path)\n else\n Log.debug1(\"No need to write remote content data, it has not changed.\")\n end\n end",
"def load_cached\n content = File.open(self.cache_file_name, \"rb\") { |f| f.read }\n puts(\"[MODEL_FILE] Loaded #{self.cache_file_name} from cache\")\n return content\n end",
"def show\n cache_control :etag => params[:sha], :validate_only => true\n @resource = Resource.find!(@repo, params[:path], params[:sha])\n\n if @resource.tree?\n root = Tree.find!(@repo, '/', params[:sha])\n cache_control :etag => root.commit.sha, :last_modified => root.commit.date\n\n @children = walk_tree(root, params[:path].to_s.cleanpath.split('/'), 0)\n haml :tree\n else\n cache_control :etag => @resource.latest_commit.sha, :last_modified => @resource.latest_commit.date\n\n engine = Engine.find!(@resource, params[:output])\n @content = engine.render(@resource, params)\n if engine.layout?\n haml :page\n else\n content_type engine.mime(@resource).to_s\n @content\n end\n end\n end",
"def data\n @data ||= file? ?\n repos.file(fs_path, revision) :\n repos.dir(fs_path, revision)\n end",
"def content_files\n @cache_content_files ||= cached_datafiles.reject { |df| sip_descriptor == df }\n end",
"def get_content(folder = nil, sort = nil)\n abs_path = folder ? ROOT + folder : ROOT\n \n # build array if pairs: [filename, :type, is_textfile]\n sorter = case sort\n when 'name' then '| sort -f'\n when 'ctime' then '-c'\n when 'mtime' then '--sort=time'\n when 'size' then '--sort=size'\n else ''\n end\n\n list_files(abs_path, sorter).map do |obj|\n file_path = abs_path + obj\n [obj,\n if file_path.file?; :file\n elsif file_path.directory?; :dir\n elsif file_path.symlink?; :link\n end,\n \n !!`file \"#{file_path.to_s.shellescape}\"`.force_encoding(Encoding::UTF_8).sub(file_path.to_s, '').index(/text/i)\n ]\n end\n end",
"def local_contents_of(file)\n contents_of(local_branch, file)\n end",
"def write_cache(cache, path)\n if @use_cache then\n File.open path, \"wb\" do |cache_file|\n Marshal.dump cache, cache_file\n end\n end\n\n cache\n rescue Errno::EISDIR # HACK toplevel, replace with main\n cache\n end",
"def recursive_fetch(path, data, current_path = [], options = {})\n # Split path into head and tail; for the next iteration, we'll look use\n # only head, and pass tail on recursively.\n head = path[0]\n current_path << head\n tail = path.slice(1, path.length)\n\n # For the leaf element, we do nothing because that's where we want to\n # dispatch to.\n if path.length == 1\n return data\n end\n\n # If we're a write function, then we need to create intermediary objects,\n # i.e. what's at head if nothing is there.\n if data[head].nil?\n # If the head is nil, we can't recurse. In create mode that means we\n # want to create hash children, but in read mode we're done recursing.\n # By returning a hash here, we allow the caller to send methods on to\n # this temporary, making a PathedAccess Hash act like any other Hash.\n if not options[:create]\n return {}\n end\n\n data[head] = {}\n end\n\n # Ok, recurse.\n return recursive_fetch(tail, data[head], current_path, options)\n end",
"def getContents( name, dir )\n if( /^https?:\\/\\// =~ name )\n begin\n response = Excon.get( name, :expects => [200] )\n rescue Exception => e\n puts \"Error - failed to load #{name}, got non-200 code.\"\n return ''\n end\n response.body\n else\n open('public/' + name).read\n end\nend",
"def content\n return @content unless @content.nil?\n @content = if exists?\n File.read absolute_path\n else\n false\n end\n end",
"def content\n unless @content\n # This stat can raise an exception, too.\n raise(ArgumentError, \"Cannot read the contents of links unless following links\") if stat.ftype == \"symlink\"\n\n @content = IO.binread(full_path)\n end\n @content\n end",
"def get_remotes()\n to_return = {}\n count = 1\n num_dirs = Dir.glob('./*/').size() -2 # exclude . and ..\n Dir.glob('./*/').each() do |dir|\n next if dir == '.' or dir == '..'\n\n print \"Processing directories...#{count}/#{num_dirs}\\r\" if !$verbose\n count += 1\n\n if(File.directory?(dir) and File.exists?(dir + '/.git'))\n Dir.chdir dir\n remotes = `git remote -v`.split(\"\\n\")\n\n vprint(dir.ljust(25))\n remotes.each() do |remote|\n if(remote.index('(fetch)'))\n parts = remote.split(\"\\t\")\n\n remote_name = get_remote_name(parts[1])\n vprint(\"[#{parts[0]} #{remote_name}]\".ljust(20))\n if(remote_name != nil)\n index = parts[0] + ' - ' + remote_name\n if(to_return[index] == nil)\n to_return[index] = Array.new()\n end\n to_return[index].push(dir)\n else\n puts \"\\nDon't know what to do with #{remote} in dir #{dir}\"\n end\n end\n end # end remotes loop\n\n vprint \"\\n\"\n Dir.chdir '..'\n end # end if file.directory\n end\n\n print \"\\n\"\n return to_return\nend",
"def getContentTreeForSubDir(subDir)\n #N Without this we won't know if the relevant sub-directory content tree hasn't already been created\n dirContentTree = dirByName.fetch(subDir, nil)\n #N Without this check, we'll be recreated the sub-directory content tree, even if we know it has already been created\n if dirContentTree == nil\n #N Without this the new sub-directory content tree won't be created\n dirContentTree = ContentTree.new(subDir, @pathElements)\n #N Without this the new sub-directory won't be added to the list of sub-directories of this directory\n dirs << dirContentTree\n #N Without this we won't be able to find the sub-directory content tree by name\n dirByName[subDir] = dirContentTree\n end\n return dirContentTree\n end",
"def get_file(path, options={})\n remove_file path\n resource = File.join(prefs[:remote_host], prefs[:remote_branch], 'files', path)\n replace_file path, download_resource(resource, options)\nend",
"def get_content(model_name)\n @_content ||= {}\n\n # return content if it has already been memoized\n return @_content[model_name] unless @_content[model_name].nil?\n\n #get class of content model we are trying to get content for\n model = get_content_model(model_name)\n\n if is_plural?(model_name)\n content = model.find(:all, :path => custom_content_path, :parent => self)\n else\n content = model.find(:first, :path => custom_content_path, :parent => self)\n end\n\n\n # memoize content so we don't parse file again on the same request\n @_content[model_name] = content\n end",
"def content\n return @content unless @content.nil?\n\n @content = @ref\n @opts[:content_path].each do |node|\n @content = @content.send(node)\n end\n @content\n end",
"def sub_content \n sub_contents = []\n\n if @is_post == false\n root_regexp = Regexp.new(@root, Regexp::IGNORECASE)\n sub_directories = Dir.glob(@absolute_path + '*');\n\n sub_directories.each do |sub_directory|\n begin\n # Remove the root from the path we pass to the new Content instance.\n # REVIEW: Should we be flexible and allow for the root dir to be present?\n content = Content.new(sub_directory.sub(root_regexp, ''))\n sub_contents.push(content)\n rescue ArgumentError\n next\n end\n end\n end\n\n sub_contents.reverse\n end",
"def read_content_from_file(file_path)\n names = file_path.split('/')\n file_name = names.pop\n directory = self.mkdir(names.join('/'))\n directory.children[file_name].content\n end",
"def fetch [email protected]_path\n src = @repo.to_s\n if !File.exists? dest\n FileUtils.mkdir_p(dest+'/')\n end \n receiver = Receiver.new S3_STORE\n puts \"fetching from: #{src} at #{S3_STORE}\"\n receiver.receive src, dest, @threads, &REPORTER\n end",
"def get_html\n print \"Getting doc...\"\n if File.size?(@cache)\n html = File.read(@cache)\n else\n html = open(URL).read\n IO.write(@cache, html)\n end\n puts \"done.\"\n html\n end",
"def create_remote_shared_cache\n with_primary_app_server do\n unless Capistrano::Deploy::Dependencies.new(configuration).remote.directory(revision_cache_dir).pass?\n remote_repository_access? ? direct_export_remote_shared_cache : local_export_and_copy_remote_shared_cache\n end\n end\n end",
"def contents\n File.read(path) if exists?\n end",
"def clone\n # We do the clone against the target repo using the `--reference` flag so\n # that doing a normal `git pull` on a directory will work.\n git \"clone --reference #{@cache.path} #{@remote} #{@full_path}\"\n git \"remote add cache #{@cache.path}\", :path => @full_path\n end",
"def local_or_remote_content(ensure_fetch = true)\n return new_record_content if new_record?\n\n return @content if @ds_content.nil? && !ensure_fetch\n\n if remote?\n @content = redirect_content\n else\n @content ||= ensure_fetch ? remote_content : @ds_content\n @content.rewind if behaves_like_io?(@content)\n end\n @content\n end",
"def gets(remote_file)\n output = \"\"\n get(remote_file) {|data| output += data}\n output\n end",
"def get(user_name, repo_name, path, params={})\n normalize! params\n\n get_request(\"/repos/#{user_name}/#{repo_name}/contents/#{path}\", params)\n end",
"def contents\n\tRails.logger.debug {\"getting gridfs content #{@id}\"}\n f=self.class.mongo_client.database.fs.find_one(:_id=>BSON::ObjectId.from_string(@id))\n # read f into buffer, array of chunks is reduced to single buffer and returned to caller.\n # this is how file is broken apart and put together and assembled. Buffer is sent back to browser\n # to disaply on the screen\n if f \n buffer = \"\"\n f.chunks.reduce([]) do |x,chunk| \n buffer << chunk.data.data \n end\n return buffer\n end \n\nend",
"def cached_directory\n case branch\n when 'master'\n Digest::MD5.hexdigest(git_url)[0..6]\n else\n Digest::MD5.hexdigest(git_url + branch)[0..6]\n end\n end",
"def get_cached_forums\n #values = Dir.glob(\"*.yml\").map{|a| a.sub(\".yml\",\"\").gsub(\"__\",\"/\"); }\n cp = File.expand_path $cache_path\n values = Dir.entries(cp).grep(/\\.yml$/).map{|a| a.sub(\".yml\",\"\").gsub(\"__\",\"/\"); }\nend",
"def contents\n\t\tconnection.file_contents(full_path)\n\tend",
"def contents\n\t\tconnection.file_contents(full_path)\n\tend",
"def content_of file:, for_sha:\n result = output_of \"git show #{for_sha}:#{file}\"\n result = '' if result == default_file_content_for(file)\n result\nend",
"def content(path, ctype=DEFAULT_CTYPE)\n node = @content_tree.lookup(path, ctype)\n node ? node.contents : ''\n end",
"def install\n if cached?\n Dir.chdir(cache_path) do\n git %{fetch --force --tags #{uri} \"refs/heads/*:refs/heads/*\"}\n end\n else\n git %{clone #{uri} \"#{cache_path}\" --bare --no-hardlinks}\n end\n\n Dir.chdir(cache_path) do\n @revision ||= git %{rev-parse #{rev_parse}}\n end\n end",
"def get(key)\n path = File.join(@root, \"#{key}.cache\")\n\n value = safe_open(path) do |f|\n begin\n EncodingUtils.unmarshaled_deflated(f.read, Zlib::MAX_WBITS)\n rescue Exception => e\n @logger.error do\n \"#{self.class}[#{path}] could not be unmarshaled: \" +\n \"#{e.class}: #{e.message}\"\n end\n nil\n end\n end\n\n if value\n FileUtils.touch(path)\n value\n end\n end",
"def /(file)\n Tree.content_by_path(repo, id, file, commit_id, path)\n end",
"def get_content_search_paths()\n r = @file_content_search_paths.clone\n p = find_project_dir_of_cur_buffer()\n if p.nil?\n p = vma.buffers.last_dir\n end\n\n if p and !@file_content_search_paths.include?(p)\n r.insert(0, p)\n end\n\n return r\n end",
"def get_file_content(path:, environment:, &block)\n validate_path(path)\n\n headers = add_puppet_headers('Accept' => 'application/octet-stream')\n response = @client.get(\n with_base_url(\"/file_content#{path}\"),\n headers: headers,\n params: {\n environment: environment\n }\n ) do |res|\n if res.success?\n res.read_body(&block)\n end\n end\n\n process_response(response)\n\n response\n end",
"def get_contents\n raise \"can't get a repo without the repo's full_name (eg. 'fubar/ofxTrickyTrick')\" unless full_name\n\n begin\n response = GithubApi::repository_contents(full_name: full_name)\n rescue => ex\n Rails.logger.debug \"Failed to get repository contents: #{ex.message} (#{ex.class})\"\n return\n end\n\n unless response.success?\n Rails.logger.debug response.inspect.to_s.red\n return\n\tend\n\n @repo_contents_json = response.parsed_response\n end",
"def remote_cache_path\n File.join(shared_path, 'bundle', 'cache')\n end",
"def content\n return @content if @content\n raise Puppet::DevError, \"No source for content was stored with the metadata\" unless metadata.source\n\n unless tmp = Puppet::FileServing::Content.indirection.find(metadata.source)\n fail \"Could not find any content at %s\" % metadata.source\n end\n @content = tmp.content\n end",
"def install\n if cached?\n # Update and checkout the correct ref\n Dir.chdir(cache_path) do\n hg %|pull|\n end\n else\n # Ensure the cache directory is present before doing anything\n FileUtils.mkdir_p(cache_path)\n\n Dir.chdir(cache_path) do\n hg %|clone #{uri} .|\n end\n end\n\n Dir.chdir(cache_path) do\n hg %|update --clean --rev #{revision || ref}|\n @revision ||= hg %|id -i|\n end\n\n # Gab the path where we should copy from (since it might be relative to\n # the root).\n copy_path = rel ? cache_path.join(rel) : cache_path\n\n begin \n # Validate the thing we are copying is a Chef cookbook\n validate_cached!(copy_path)\n\n # Remove the current cookbook at this location (this is required or else\n # FileUtils will copy into a subdirectory in the next step)\n FileUtils.rm_rf(install_path)\n\n # Create the containing parent directory\n FileUtils.mkdir_p(install_path.parent)\n\n # Copy whatever is in the current cache over to the store\n FileUtils.cp_r(copy_path, install_path)\n\n ensure\n\n # Remove the .hg directory to save storage space\n # TODO this can have huge performance implications, \n # make it a config option?\n if (hg_path = install_path.join('.hg')).exist?\n FileUtils.rm_r(hg_path)\n end\n\n FileUtils.rm_rf (copy_path)\n end\n end",
"def get_contents_for(path)\n out = get_path(path)\n out.css(\"#content\").inner_html\n end",
"def initialize(contentHost, baseDir, cachedContentFile = nil)\n # Without super, we won't remember the cached content file (if specified)\n super(cachedContentFile)\n # Without this we won't remember which remote server to connect to\n @contentHost = contentHost\n # Without this we won't remember which directoy on the remote server to sync to.\n @baseDir = normalisedDir(baseDir)\n end",
"def file_contents_on(host, file_path)\n file_contents = nil\n\n split_path = win_ads_path(file_path)\n if file_exists_on(host, split_path[:path])\n if host[:platform].include?('windows')\n file_path.tr!('/', '\\\\')\n\n command = %{Get-Content -Raw -Path #{file_path}}\n command += %{ -Stream #{split_path[:ads]}} if split_path[:ads]\n\n file_contents = on(host, powershell(command))&.stdout&.strip\n else\n file_contents = on(host, %(cat \"#{file_path}\"))&.stdout&.strip\n end\n else\n logger.warn(\"File '#{file_path}' on '#{host} does not exist\")\n end\n\n return file_contents\n end",
"def read_content(name, resource)\n read(name, resource) do |file|\n if file.header.typeflag == \"2\"\n return read_content(name, File.absolute_path(file.header.linkname,File.dirname(resource)))\n end\n if file.header.typeflag != \"0\"\n raise NotAFile.new(\"not a file\", {'path' => resource})\n end\n return file.read\n end\n end",
"def get(base, name, opts)\n self.load if @cache.nil?\n path = Jekyll.sanitized_path(base, name)\n key = path[@site.source.length..-1]\n mtime = File.mtime(path)\n\n if @cache.has_key?(key) && mtime == @cache[key]['modified']\n # file is not modified\n ret_hash(@cache[key]['yaml'], @cache[key]['content'], false, false, false)\n else\n puts \"parsed yaml #{key}...\"\n self.set_content(key, path, mtime, opts)\n end\n end",
"def fetch(url, options = {})\n @default_options = @options\n @options = @options.merge(options)\n self.class.verify_options(@options)\n\n begin\n if content = @options[('%s_content' % RAILS_ENV).to_sym]\n return content\n end\n\n uri = @options[:radiant_url] + url\n\n if cache_valid?(uri)\n cached(uri)\n else\n content = ''\n\n begin\n Timeout::timeout(@options[:timeout] || 10) do\n read_options = {}\n\n if @options[:username]\n read_options[:http_basic_authentication] = [@options[:username].to_s, @options[:password].to_s]\n end\n\n content = cache_content(uri, URI.parse(uri).read(read_options))\n end\n rescue Exception => e\n logger.error \"Couldn't fetch content from radiant: %s due to error: %s\" % [url, e.message] if logger\n\n if @options[:error_content]\n content = @options[:error_content]\n else\n content = nil\n end\n\n fail if @options[:raise_errors] == true\n end\n \n content\n end\n ensure\n @options = @default_options\n end\n end",
"def tree\n read_repo\n if @branches.count < 1\n render :template => 'repositories/newrepo'\n return\n end\n\n @files = @repository.files(@branch, @path)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @repository }\n end\n end",
"def read\n raise MissingFileMapping.new if mapping.blank?\n raise NodesMissing.new if mapping.nodes.blank?\n\n @content ||= self.connection.get(self.nodes.first, self.access_level, self.path)\n\n return @content\n end",
"def lookup(path, ctype=nil, recursive=false, path_only=true, dirs=false)\n # TODO : this might need to be changed as it returns dir and contents\n # if there are contents\n entries = []\n prune = recursive ? nil : 2\n @content_tree.with_subtree(path, ctype, prune, dirs) do |node|\n entries << [node.node_type, (path_only ? node.path : node)]\n end\n entries\n end",
"def get_cache(key)\n treecache.fetch(key)\n end",
"def tree_blob(ref, path)\n ref ||= 'master'\n commit = self.commit ref\n tree = commit.tree_rpc\n Tree.content_by_path(self, tree.id, path, commit.id, tree.path)\n end",
"def write_cache(resource, content)\n expanded_path = cache_path_for(resource)\n return false unless expanded_path\n FileUtils.mkdir_p(File.dirname(expanded_path))\n @logger.info(self.class) { \"Caching #{content.length} B for #{resource}\" }\n File.write(expanded_path, content)\n end",
"def dir_contents(path, &b)\n path = Pathname.new(path).cleanpath\n if fs.directory?(path)\n entries = fs.entries(path).map do |entry|\n entry_path = path + entry\n if fs.directory?(entry_path)\n dir_item(entry)\n else\n file_item(entry, fs.get_size(entry_path))\n end\n end\n yield entries\n else\n yield Set.new\n end\n end",
"def cached_command_output(command, cache_time = 86400)\n\n cache_directory = '/var/opt/lib/pe-puppet/facts/cached_command_output'\n Dir.mkdir cache_directory unless File.exist? cache_directory\n\n cache_file = cache_directory + '/' + command.gsub(\"/\", \"_\")\n\n if File.exist?(cache_file) && File.mtime(cache_file) > (Time.now - cache_time) then\n command_output = File.read(cache_file).chomp\n else\n command_output = %x{#{command}}\n f = File.open(cache_file, 'w')\n f.puts command_output\n f.close\n end\n\n return command_output\n\nend",
"def cache\n if self.cache_store\n self.cache_store\n else\n self.cache_store = :file_store, root.join(\"tmp\").to_s\n self.cache_store\n end\n end",
"def cache_page(content, path)\n return unless perform_caching\n\n benchmark \"Cached page: #{page_cache_file(path)}\" do\n FileUtils.makedirs(File.dirname(page_cache_path(path)))\n File.open(page_cache_path(path), \"wb+\") { |f| f.write(content) }\n end\n end",
"def get_content(file_path)\n puts \"getting markdown for: #{file_path}.md\\n\\n\"\n file = File.open(\"data/pages/#{file_path}.md\", \"r\")\n return file.read\nend",
"def ref_dup\n git = ::Git.open(base_path)\n git.checkout(ref)\n git.pull(\"origin\", ref)\n self.ref = git.log.first.sha\n self.path = Utility.join_path(cache_path, \"git\", ref)\n unless File.directory?(path)\n FileUtils.mkdir_p(path)\n FileUtils.cp_r(Utility.join_path(base_path, \".\"), path)\n FileUtils.rm_rf(Utility.join_path(path, \".git\"))\n end\n path\n end",
"def treecache\n @treecache ||= TaggedCache.new\n end",
"def get_gzipped_backup\n safe_run \"ssh #{user}@#{host} gzip -c #{remote_path} > #{local_path}\"\n local_path\n end",
"def find_new_content(tree, options)\n limit = case\n when !options[:limit] || options[:limit] <= 0\n Float::MAX * 2\n when options[:limit] > 0\n options[:limit]\n end\n verbose = (options[:verbose] ? true : false)\n communication = tree.create_communication\n result = get_new_content(communication, root, limit)\n $stdout.puts \"Number of communications (i.e. retrieved hashes): #{communication.cost}\" if verbose\n result\n end",
"def write_cache_file key, content\n f = File.open( cache_file(key), \"w+\" )\n f.flock(File::LOCK_EX)\n f.write( content )\n f.close\n return content\n end",
"def content_path\n path = \"esm/#{self.esm.name}/#{self.name}/content\"\n file_path = \"public/#{path}\"\n p = file_path.split('/')\n i=0\n unless FileTest.exist?(file_path)\n while(s = \"public/esm/#{p[2...2+i].join('/')}\" and s!=file_path)\n Dir.mkdir(s) unless FileTest.exist?(s)\n i+=1\n end\n Dir.mkdir(s) unless FileTest.exist?(s)\n end\n return path\n end",
"def file_content_looker(repo, txn, path)\n @logger.debug(\"UnresolvedMergeChecker checking \"+path)\n `svnlook cat -t #{txn} #{repo} #{path}`\n end"
] | [
"0.7189733",
"0.66510344",
"0.6631559",
"0.6146769",
"0.60231584",
"0.57145214",
"0.57019234",
"0.57004094",
"0.56474715",
"0.5507554",
"0.549098",
"0.5481192",
"0.54659945",
"0.5434707",
"0.5413252",
"0.5395721",
"0.5387818",
"0.533445",
"0.5314144",
"0.5308171",
"0.53073406",
"0.53028196",
"0.52969927",
"0.5262431",
"0.52546287",
"0.52511334",
"0.52358407",
"0.52309096",
"0.52287424",
"0.5217596",
"0.5214329",
"0.5206122",
"0.52057517",
"0.51744777",
"0.5170215",
"0.5162729",
"0.5147488",
"0.5128338",
"0.5124898",
"0.5122783",
"0.5120465",
"0.5117563",
"0.511673",
"0.5113074",
"0.5108101",
"0.5106987",
"0.50973266",
"0.5088733",
"0.5087093",
"0.5072605",
"0.5051832",
"0.5051708",
"0.5050206",
"0.5044167",
"0.50435716",
"0.5041524",
"0.5030241",
"0.5027029",
"0.5022332",
"0.50167954",
"0.5015054",
"0.49834964",
"0.4975716",
"0.49693468",
"0.49693468",
"0.4952173",
"0.4949483",
"0.49414265",
"0.49339658",
"0.49339008",
"0.4930608",
"0.4921087",
"0.49172038",
"0.49061126",
"0.49035326",
"0.49025756",
"0.49019575",
"0.49011862",
"0.48965988",
"0.48958588",
"0.489349",
"0.48919162",
"0.4891379",
"0.48837417",
"0.48741534",
"0.48686853",
"0.48669377",
"0.4856758",
"0.48521072",
"0.4846082",
"0.48356003",
"0.48208964",
"0.48186055",
"0.4815694",
"0.48145384",
"0.48132378",
"0.47997904",
"0.47995716",
"0.47992307",
"0.4795776"
] | 0.7833455 | 0 |
N Without this we wouldn't have an easy way to create the sync operation object with all attributes specified (and with readonly attributes) | def initialize(sourceLocation, destinationLocation)
#N Without this, we wouldn't remember the (local) source location
@sourceLocation = sourceLocation
#N Without this, we wouldn't remember the (remote) destination location
@destinationLocation = destinationLocation
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sync *attributes\n self.class.define_method(:sync_attributes) do\n ActiveSync::Sync.sync_attributes(self, attributes)\n end\n define_method(:sync_record) do\n ActiveSync::Sync.sync_record(self, attributes)\n end\n define_method(:sync_associations) do\n ActiveSync::Sync.sync_associations(self, attributes)\n end\n end",
"def old_sync=(_arg0); end",
"def sync=(arg0)\n end",
"def create_syncer\n if @get || @set\n accessor = BlockAccessor.new(@get, @set)\n elsif @accessor\n accessor = @accessor\n else\n raise Exception.new(\"You have to define an accessor\")\n end\n\n if @validator\n mapper = Mappers::ValidatedMapper.new(\n @mapper,\n Validators::IdentityValidator.new,\n @validator\n )\n else\n mapper = @mapper\n end\n\n mapper = Mappers::SinkingMapper.new(mapper, [@name])\n\n args = {\n source_accessor: accessor,\n mapper: mapper,\n target_accessor: Accessors::HashKeyAccessor.new(@name)\n }\n\n Syncers::CompositeSyncer.new(**args)\n end",
"def old_sync; end",
"def build_operation(options = {})\n double(:operation, {\n execute: true,\n metadata: {},\n trailing_metadata: {},\n deadline: Time.now.to_i + 600,\n cancelled?: false,\n execution_time: rand(1_000..10_000)\n }.merge(options))\n end",
"def build_operation(options = {})\n double(:operation, {\n execute: true,\n metadata: {},\n trailing_metadata: {},\n deadline: Time.now.to_i + 600,\n cancelled?: false,\n execution_time: rand(1_000..10_000)\n }.merge(options))\n end",
"def sync=(p1)\n #This is a stub, used for indexing\n end",
"def initialize(sync: true, dirty: false)\n @hash = {}\n @sync = sync\n @dirty = dirty\n @mutex = Mutex.new\n end",
"def sync_options; @sync_options ||= table_sync.sync_options; end",
"def sync(definition, sync_operation)\n export_address = self.api_domain + sync_operation.assigned_service_id + '/data'\n request_body = sync_operation.mapped_data.map do |row|\n Service.excluded_meta_attrs.each{|attr| row.delete(attr)}\n row\n end\n\n response_body = make_api_call(export_address, 'post', request_body.to_json)\n return nil unless response_body\n\n response_object = response_body.parsed_response\n\n return {\n request: request_body,\n response: response_object,\n assigned_sync_id: response_object['syncedInstanceUrl'],\n pending_count: sync_operation.mapped_data.count\n }\n end",
"def params\n { resource: @resource, sync: @sync }.compact\n end",
"def sync!(options) # semi-public.\n # TODO: merge this into Sync::Run or something and use in Struct, too, so we don't\n # need the representer anymore?\n options_for_sync = sync_options(Options[options])\n\n schema.each(options_for_sync) do |dfn|\n property_value = sync_read(dfn) #\n\n unless dfn[:nested]\n mapper.send(dfn.setter, property_value) # always sync the property\n next\n end\n\n # First, call sync! on nested model(s).\n nested_model = PropertyProcessor.new(dfn, self, property_value).() { |twin| twin.sync!({}) }\n next if nested_model.nil?\n\n # Then, write nested model to parent model, e.g. model.songs = [<Song>]\n mapper.send(dfn.setter, nested_model) # @model.artist = <Artist>\n end\n\n model\n end",
"def sync=\n end",
"def sync\n @sync ||= Sync.new self\n end",
"def sync\n @sync ||= Sync.new self\n end",
"def sync(name, &ruby_block)\n # Create the resulting state.\n result = State.new\n result.name = name.to_sym\n result.code = ruby_block\n # Add it to the lis of extra synchronous states.\n @extra_syncs << result\n # Return it\n return result\n end",
"def sync=(p0) end",
"def sync=(p0) end",
"def sync=(p0) end",
"def transaction_primitive\n raise NotImplementedError\n end",
"def sync(&block)\n queue SyncCommand, [], {}, &block\n end",
"def sync()\n #This is a stub, used for indexing\n end",
"def resource\n resource_klass.new(\n attributes.merge(\n new_record: false,\n Valkyrie::Persistence::Attributes::OPTIMISTIC_LOCK => lock_token\n )\n )\n end",
"def transaction_primitive\n raise NotImplementedError\n end",
"def resource\n resource_klass.new(\n attributes.merge(\n new_record: false,\n Valkyrie::Persistence::Attributes::OPTIMISTIC_LOCK => lock_token\n )\n )\n end",
"def sync(options = {})\n assert_open\n assert_keys(options,\n :supported => [:path, :callback, :callback_context],\n :required => [:path, :callback])\n\n req_id = setup_call(:sync, options)\n\n rc = super(req_id, options[:path]) # we don't pass options[:callback] here as this method is *always* async\n\n { :req_id => req_id, :rc => rc }\n end",
"def initialize(model_class, options = {})\n @model_class = model_class\n @synced_endpoint = options[:synced_endpoint]\n @scope = options[:scope]\n @id_key = options[:id_key]\n @data_key = options[:data_key]\n @only_updated = options[:only_updated]\n @include = options[:include]\n @local_attributes = synced_attributes_as_hash(options[:local_attributes])\n @api = options[:api]\n @mapper = options[:mapper].respond_to?(:call) ?\n options[:mapper].call : options[:mapper]\n @fields = options[:fields]\n @remove = options[:remove]\n @associations = Array.wrap(options[:associations])\n @association_sync = options[:association_sync]\n @perform_request = options[:remote].nil? && !@association_sync\n @remote_objects = Array.wrap(options[:remote]) unless @perform_request\n @globalized_attributes = synced_attributes_as_hash(options[:globalized_attributes])\n @query_params = options[:query_params]\n @auto_paginate = options[:auto_paginate]\n @transaction_per_page = options[:transaction_per_page]\n @handle_processed_objects_proc = options[:handle_processed_objects_proc]\n @remote_objects_ids = []\n end",
"def sync_query_params\n params.require(:sync_query).permit(:name, :created_filter, :created_operator, :last_modified_filter, :last_modified_operator, :local_model, :sobject, :where_conditions, :is_primary, :query_all, :batch_size)\n end",
"def _build_shares_and_operations\n if respond_to?(:build_shares, true)\n shares.clear\n build_shares\n end\n operations.reload\n @operation_ids_untouched = operation_ids\n build_operations if amount\n #Rails.logger.debug \"@operation_ids_untouched: \" + @operation_ids_untouched.inspect\n operations.find(@operation_ids_untouched).each(&:mark_for_destruction) unless @operation_ids_untouched.empty?\n end",
"def gen_sw_sync\n val = wordread(:sync_arm)\n val &= ~0x10 # Turn off desired bit\n wordwrite(:sync_arm, val)\n wordwrite(:sync_arm, val | 0x10)\n wordwrite(:sync_arm, val)\n end",
"def synchronization\n attributes.fetch(:synchronization)\n end",
"def set_sync_token\n self.sync_token = OaUtils::generate_random_key[0..7]\n end",
"def update!(**args)\n @operations = args[:operations] unless args[:operations].nil?\n end",
"def sync() end",
"def sync() end",
"def sync() end",
"def sync(options = {})\n assert_open\n assert_supported_keys(options, [:path, :callback, :callback_context])\n assert_required_keys(options, [:path, :callback])\n\n req_id = setup_call(:sync, options)\n\n rc = super(req_id, options[:path]) # we don't pass options[:callback] here as this method is *always* async\n\n { :req_id => req_id, :rc => rc }\n end",
"def operation(name, opts = {}, &block)\n raise DuplicateOperationException if @operations[name]\n @operations[name] = Operation.new(self, name, opts, &block)\n end",
"def client_sync_params\n params.require(:client_sync).permit(:client_id, :acc_system_id, :time_stamp)\n end",
"def ensure_sync_state\n create_sync_state unless sync_state_exists?\n end",
"def sync\n cached_dataset(:_sync) do\n clone(:async=>false)\n end\n end",
"def create\n sharing(\"-a\", name)\n @property_hash[:ensure] = :present\n\n # Setters for configuring the share are not automatically called on create, so we call them\n resource.properties.each do |property|\n property.sync unless property.name == :ensure\n end\n end",
"def tsync=(value)\n set_attr(:tsync, value ? 1 : 0)\n @tsync = value\n end",
"def create(*args)\n result = super(*args)\n ensure\n readonly! if result\n end",
"def create_method\n :http_put\n end",
"def create_method\n :http_put\n end",
"def create_op\n\t\t\tring = current_ring\n\t\t\top = (self.respond_to?(:op) && self.op || params[:op])\n\t\t\t#op = params[:op] unless self.respond_to? :op\n\t\t\toptions = op[:options] || {}\n\t\t\tresource,id,assoc = op['key'].split_kojac_key\n\t\t\tif model_class = KojacUtils.model_class_for_key(resource)\n\t\t\t\tif assoc # create operation on an association eg. {verb: \"CREATE\", key: \"order.items\"}\n\t\t\t\t\tif model_class.ring_can?(ring,:create_on,assoc.to_sym)\n\t\t\t\t\t\titem = KojacUtils.model_for_key(key_join(resource,id))\n\t\t\t\t\t\tma = model_class.reflect_on_association(assoc.to_sym)\n\t\t\t\t\t\ta_value = op[:value] # get data for this association, assume {}\n\t\t\t\t\t\traise \"create multiple not yet implemented for associations\" unless a_value.is_a?(Hash)\n\n\t\t\t\t\t\ta_model_class = ma.klass\n\t\t\t\t\t\tpolicy = Pundit.policy!(current_user,a_model_class)\n\t\t\t\t\t\tp_fields = policy.permitted_fields(:write)\n\t\t\t\t\t\tfields = a_value.permit( *p_fields )\n\t\t\t\t\t\tnew_sub_item = nil\n\t\t\t\t\t\tcase ma.macro\n\t\t\t\t\t\t\twhen :has_many\n\t\t\t\t\t\t\t\ta_model_class.write_op_filter(current_user,fields,a_value) if a_model_class.respond_to? :write_op_filter\n\t\t\t\t\t\t\t\tnew_sub_item = item.send(assoc.to_sym).create(fields)\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\traise \"#{ma.macro} association unsupported in CREATE\"\n\t\t\t\t\t\tend\n\t\t\t\t\t\tresult_key = op[:result_key] || new_sub_item.kojac_key\n\t\t\t\t\t\tmerge_model_into_results(new_sub_item)\n\t\t\t\t\telse\n\t\t\t\t\t\terror = {\n\t\t\t\t\t\t\tcode: 403,\n\t\t\t\t\t\t\tstatus: \"Forbidden\",\n\t\t\t\t\t\t\tmessage: \"User does not have permission for #{op[:verb]} operation on #{model_class.to_s}.#{assoc}\"\n\t\t\t\t\t\t}\n\t\t\t\t\tend\n\t\t\t\telse # create operation on a resource eg. {verb: \"CREATE\", key: \"order_items\"} but may have embedded association values\n\t\t\t\t\tif model_class.ring_can?(ring,:create)\n\t\t\t\t\t\tpolicy = Pundit.policy!(current_user,model_class)\n\t\t\t\t\t\tp_fields = policy.permitted_fields(:write)\n\n\t\t\t\t\t\t# see the 20171213-Permissions branch for work here\n\t\t\t\t\t\tp_fields = op[:value].reverse_merge!(policy.defaults).permit( *p_fields )\n\t\t\t\t\t\tmodel_class.write_op_filter(current_user,p_fields,op[:value]) if model_class.respond_to? :write_op_filter\n\t\t\t\t\t\titem = model_class.new(p_fields)\n\t\t\t\t\t\tpolicy = Pundit.policy!(current_user,item)\n\t\t\t\t\t\tforbidden! unless policy.create?\n\t\t\t\t\t\titem.save!\n\n\t\t\t\t\t\toptions_include = options['include'] || []\n\t\t\t\t\t\tincluded_assocs = []\n\t\t\t\t\t\tp_assocs = policy.permitted_associations(:write)\n\t\t\t\t\t\tif p_assocs\n\t\t\t\t\t\t\tp_assocs.each do |a|\n\t\t\t\t\t\t\t\tnext unless (a_value = op[:value][a]) || options_include.include?(a.to_s)\n\t\t\t\t\t\t\t\tcreate_on_association(item,a,a_value,ring)\n\t\t\t\t\t\t\t\tincluded_assocs << a.to_sym\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\t\tforbidden! unless policy.create?\n\t\t\t\t\t\titem.save!\n\t\t\t\t\t\tresult_key = op[:result_key] || item.kojac_key\n\t\t\t\t\t\tmerge_model_into_results(item,result_key,:include => included_assocs)\n\t\t\t\t\telse\n\t\t\t\t\t\terror = {\n\t\t\t\t\t\t\tcode: 403,\n\t\t\t\t\t\t\tstatus: \"Forbidden\",\n\t\t\t\t\t\t\tmessage: \"User does not have permission for #{op[:verb]} operation on #{model_class.to_s}\"\n\t\t\t\t\t\t}\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\telse\n\t\t\t\terror = {\n\t\t\t\t\tcode: 501,\n\t\t\t\t\tstatus: \"Not Implemented\",\n\t\t\t\t\tmessage: \"model class not found\"\n\t\t\t\t}\n\t\t\tend\n\t\t\tresponse = {\n\t\t\t\tkey: op[:key],\n\t\t\t verb: op[:verb],\n\t\t\t}\n\t\t\tif error\n\t\t\t\tresponse[:error] = error\n\t\t\telse\n\t\t\t\tresponse[:results] = results\n\t\t\t\tresponse[:result_key] = result_key\n\t\t\tend\n\t\t\tresponse\n\t\tend",
"def sync\n raise NotImplementedError, _(\"%{class} has not implemented method %{method}\") % {class: self.class, method: __method__}\n end",
"def only_create!\n self.operation = :only_create\n end",
"def atomic_sets\n if updateable?\n setters\n elsif settable?\n { atomic_path => as_attributes }\n else\n {}\n end\n end",
"def operation(*_)\n raise 'not implemented'\n end",
"def initialize(enable_post = true)\n @enable_post = true\n @uninteresting_properties = [\n '{DAV:}supportedlock',\n '{DAV:}acl-restrictions',\n '{DAV:}supported-privilege-set',\n '{DAV:}supported-method-set'\n ]\n @enable_post = enable_post\n end",
"def operation_class\n Clowne::Utils::Operation\n end",
"def fsync()\n #This is a stub, used for indexing\n end",
"def create_sync_state\n silence_ddl_notices(:left) do\n table_name = \"#{options[:rep_prefix]}_sync_state\"\n session.left.create_table \"#{options[:rep_prefix]}_sync_state\"\n session.left.add_column table_name, :table_name, :string\n session.left.add_column table_name, :state, :string\n session.left.remove_column table_name, 'id'\n session.left.add_big_primary_key table_name, 'id'\n end\n end",
"def operation(code, size, name, time, desc = nil, &block)\n inst = Operation.new(code, size, name, time, desc, &block)\n @operation_by_code[inst.code] = inst \n @operation_by_name[inst.name.downcase.to_sym] = inst\n end",
"def icloud_sync\n raise \"not yet implemented\"\n end",
"def create(attributes)\n validate_schema!(attributes)\n\n attributes = attributes\n .yield_self(&method(:set_timestamps))\n .yield_self(&method(:set_id))\n\n operations.create attributes\n end",
"def insync?\n unless properties[:ensure] == :absent\n properties.each do |k, v|\n if resource[k].to_s != v\n resource[:ensure] = :modified\n break false\n end\n end\n end\n end",
"def update!(**args)\n @client_operation_id = args[:client_operation_id] if args.key?(:client_operation_id)\n @creation_timestamp = args[:creation_timestamp] if args.key?(:creation_timestamp)\n @description = args[:description] if args.key?(:description)\n @end_time = args[:end_time] if args.key?(:end_time)\n @error = args[:error] if args.key?(:error)\n @http_error_message = args[:http_error_message] if args.key?(:http_error_message)\n @http_error_status_code = args[:http_error_status_code] if args.key?(:http_error_status_code)\n @id = args[:id] if args.key?(:id)\n @insert_time = args[:insert_time] if args.key?(:insert_time)\n @kind = args[:kind] if args.key?(:kind)\n @name = args[:name] if args.key?(:name)\n @operation_type = args[:operation_type] if args.key?(:operation_type)\n @progress = args[:progress] if args.key?(:progress)\n @region = args[:region] if args.key?(:region)\n @self_link = args[:self_link] if args.key?(:self_link)\n @start_time = args[:start_time] if args.key?(:start_time)\n @status = args[:status] if args.key?(:status)\n @status_message = args[:status_message] if args.key?(:status_message)\n @target_id = args[:target_id] if args.key?(:target_id)\n @target_link = args[:target_link] if args.key?(:target_link)\n @user = args[:user] if args.key?(:user)\n @warnings = args[:warnings] if args.key?(:warnings)\n @zone = args[:zone] if args.key?(:zone)\n end",
"def update!(**args)\n @client_operation_id = args[:client_operation_id] if args.key?(:client_operation_id)\n @creation_timestamp = args[:creation_timestamp] if args.key?(:creation_timestamp)\n @description = args[:description] if args.key?(:description)\n @end_time = args[:end_time] if args.key?(:end_time)\n @error = args[:error] if args.key?(:error)\n @http_error_message = args[:http_error_message] if args.key?(:http_error_message)\n @http_error_status_code = args[:http_error_status_code] if args.key?(:http_error_status_code)\n @id = args[:id] if args.key?(:id)\n @insert_time = args[:insert_time] if args.key?(:insert_time)\n @kind = args[:kind] if args.key?(:kind)\n @name = args[:name] if args.key?(:name)\n @operation_type = args[:operation_type] if args.key?(:operation_type)\n @progress = args[:progress] if args.key?(:progress)\n @region = args[:region] if args.key?(:region)\n @self_link = args[:self_link] if args.key?(:self_link)\n @start_time = args[:start_time] if args.key?(:start_time)\n @status = args[:status] if args.key?(:status)\n @status_message = args[:status_message] if args.key?(:status_message)\n @target_id = args[:target_id] if args.key?(:target_id)\n @target_link = args[:target_link] if args.key?(:target_link)\n @user = args[:user] if args.key?(:user)\n @warnings = args[:warnings] if args.key?(:warnings)\n @zone = args[:zone] if args.key?(:zone)\n end",
"def initialize(opts={})\n @options = opts\n @obj_id = @options.delete(:_id)\n # Do not allow to modify the object#base_id\n @obj_id.freeze\n @client = @options.delete(:_client)\n @original_body = @options.delete(:original_body)\n update_instance_variables!(@options)\n end",
"def ensure_sync_state\n unless @ensured_sync_state\n ReplicationInitializer.new(session).ensure_sync_state\n @ensured_sync_state = true\n end\n end",
"def readonly_attributes(*attrs)\n @readonly_attributes ||= [:created_at, :updated_at, :completed_at]\n if attrs.any?\n @readonly_attributes.map!(&:to_sym).concat(attrs).uniq!\n setup_attributes(@readonly_attributes, true)\n end\n @readonly_attributes\n end",
"def initialize\n super\n\n self.callbacks = ::ActiveSupport::HashWithIndifferentAccess.new\n self.callbacks_queue = []\n\n self.responses = ::ActiveSupport::HashWithIndifferentAccess.new\n self.responses_queue = []\n\n self.client = ::Syncano::Clients::Sync.instance\n self.received_data = ''\n end",
"def default_operation_params\n {}\n end",
"def operation_params\n params[:operation].permit!\n end",
"def sync_data(data)\n begin\n operation = create_operation(data)\n sync_categories(operation) if operation.kind\n\n rescue Exception => e\n log_data_invalid_error(data, e)\n end\n end",
"def initialize(attrs={})\n attrs.each {|k,v| send(\"#{k}=\", v)}\n self.command ||= nil\n self.transaction_id ||= self.class.next_transaction_id\n self.values ||= []\n self.version ||= 0x00\n end",
"def sync(params = {})\n params ||= {}\n params[:id] = @attributes[:id]\n raise MissingParameterError.new(\"Current object doesn't have a id\") unless @attributes[:id]\n raise InvalidParameterError.new(\"Bad parameter: id must be an Integer\") if params[:id] and !params[:id].is_a?(Integer)\n raise MissingParameterError.new(\"Parameter missing: id\") unless params[:id]\n\n Api.send_request(\"/sso_strategies/#{@attributes[:id]}/sync\", :post, params, @options)\n end",
"def save_operation\n self.writeable_attributes\n end",
"def sync; end",
"def attributes\n attribute_hash.merge(\"id\" => id,\n internal_resource: internal_resource,\n created_at: created_at,\n updated_at: updated_at,\n Valkyrie::Persistence::Attributes::OPTIMISTIC_LOCK => token)\n end",
"def operation_params\n params.require(:operation).permit(:name, :current_task_id)\n end",
"def arm_sync\n val = wordread(:sync_arm)\n val &= ~1 # Turn off desired bit\n wordwrite(:sync_arm, val)\n wordwrite(:sync_arm, val | 1)\n wordwrite(:sync_arm, val)\n end",
"def attributes_to_sync\n self.class.attributes_to_sync(attributes)\n end",
"def operation_params\n params.require(:operation).permit!\n end",
"def update!(**args)\n @state_sync_method = args[:state_sync_method] if args.key?(:state_sync_method)\n end",
"def reset_sync_flags\n PiLib .dlp_ResetSyncFlags(@sd, @db)\n return self\n end",
"def createonly()\n merge(createonly: 'true')\n end",
"def sync_cmd\n warn(\"Legacy call to #sync_cmd cannot be preserved, meaning that \" \\\n \"test files will not be uploaded. \" \\\n \"Code that calls #sync_cmd can now use the transport#upload \" \\\n \"method to transfer files.\")\n end",
"def initialize(sync_helper)\n self.sync_helper = sync_helper\n self.source = sync_helper.sync_options[:direction] == :left ? :right : :left\n self.target = sync_helper.sync_options[:direction] == :left ? :left : :right\n self.source_record_index = sync_helper.sync_options[:direction] == :left ? 1 : 0\n end",
"def sync\n end",
"def sync\n end",
"def method_missing(method_name, *arguments, **kw_arguments, &block)\n instance_eval <<-End\n def #{method_name} *arguments, **kw_arguments\n @endpoint.sync_call '#{method_name}', *arguments, **kw_arguments\n end\n End\n @endpoint.sync_call method_name, *arguments, **kw_arguments\n end",
"def operations\n operation_classes.each_with_object({}) do |operation, hash|\n hash[operation.key] = operation.new\n end\n end",
"def sync!(hash = {}) # does NOT notify (see saved! for notification)\n # hash.each do |attr, value|\n # @attributes[attr] = convert(attr, value)\n # end\n @synced_attributes = {}\n hash.each { |attr, value| sync_attribute(attr, convert(attr, value)) }\n @changed_attributes = []\n @saving = false\n errors.clear\n # set the vector and clear collections - this only happens when a new record is saved\n initialize_collections if (!vector || vector.empty?) && id && id != ''\n self\n end",
"def exec_sync\n raise \"You must override `exec_sync' in your class\"\n end",
"def sync\n if not cloned?\n clone\n else\n update\n end\n end",
"def operation\n @op_notifier = Notifier.new\n Operation.new(self)\n end",
"def initialize(params={})\n super\n @method = :rsync\n @delete = link_config(:delete).to_s == \"true\"\n end",
"def sync\n TaskwarriorWeb::Command.new(:sync, nil, nil).run\n end",
"def freeze\n freeze!\n attributes.freeze\n super\n end",
"def sync\n current = @resource.stat ? @resource.stat.mode : 0644\n set(desired_mode_from_current(@should[0], current).to_s(8))\n end",
"def touch_sync\n self.lastSyncAt = Time.now if self.respond_to?(:lastSyncAt=)\n end",
"def nolock\n clone(:with => \"(NOLOCK)\")\n end",
"def default_operation_params\n {\n foo: 'bar'\n }\n end",
"def initialize( name, opthash={} )\n\t\toptions = DEFAULT_OPTIONS.merge( opthash )\n\t\treturn super( name, options )\n\tend",
"def atomic_sets\n updateable? ? setters : settable? ? { _path => as_document } : {}\n end",
"def flush\n debug \"Call: flush on cs_resource '#{@resource[:name]}'\"\n return if @property_hash.empty?\n self.class.block_until_ready\n\n unless @property_hash[:operations].empty?\n operations = ''\n @property_hash[:operations].each do |o|\n op_namerole = o[0].to_s.split(':')\n if op_namerole[1]\n o[1]['role'] = o[1]['role'] || op_namerole[1] # Hash['role'] has more priority, than Name\n end\n operations << \"op #{op_namerole[0]} \"\n o[1].each_pair do |k,v|\n operations << \"#{k}=#{v} \"\n end\n end\n end\n\n unless @property_hash[:parameters].empty?\n parameters = 'params '\n @property_hash[:parameters].each_pair do |k,v|\n parameters << \"#{k}=#{v} \"\n end\n end\n\n unless @property_hash[:metadata].empty?\n metadatas = 'meta '\n @property_hash[:metadata].each_pair do |k,v|\n metadatas << \"#{k}=#{v} \"\n end\n end\n\n updated = 'primitive '\n updated << \"#{@property_hash[:name]} #{@property_hash[:primitive_class]}:\"\n updated << \"#{@property_hash[:provided_by]}:\" if @property_hash[:provided_by]\n updated << \"#{@property_hash[:primitive_type]} \"\n updated << \"#{operations} \" unless operations.nil?\n updated << \"#{parameters} \" unless parameters.nil?\n updated << \"#{metadatas} \" unless metadatas.nil?\n\n if @property_hash[:complex_type]\n complex_name = \"#{@property_hash[:complex_type]}_#{@property_hash[:name]}\"\n crm_cmd_type = @property_hash[:complex_type].to_s == 'master' ? 'ms' : 'clone'\n debug \"Creating '#{crm_cmd_type}' parent named '#{complex_name}' for #{@property_hash[:name]} resource\"\n updated << \"\\n\"\n updated << \" #{crm_cmd_type} #{complex_name} #{@property_hash[:name]} \"\n unless @property_hash[:ms_metadata].empty?\n updated << 'meta '\n @property_hash[:ms_metadata].each_pair do |k,v|\n updated << \"#{k}=#{v} \"\n end\n end\n end\n\n debug(\"Will update tmpfile with '#{updated}'\")\n Tempfile.open('puppet_crm_update') do |tmpfile|\n tmpfile.write(updated)\n tmpfile.flush\n apply_changes(@resource[:name], tmpfile, 'resource')\n end\n end"
] | [
"0.62257636",
"0.5998785",
"0.57728297",
"0.5667353",
"0.5642296",
"0.5577635",
"0.5577635",
"0.55185425",
"0.54901296",
"0.5441762",
"0.53627497",
"0.5348261",
"0.53388643",
"0.5336288",
"0.5321299",
"0.5321299",
"0.52901083",
"0.51853997",
"0.51853997",
"0.51853997",
"0.51516044",
"0.51446515",
"0.51403457",
"0.5132613",
"0.5132487",
"0.5130584",
"0.5119698",
"0.50965744",
"0.50611657",
"0.5043263",
"0.5027028",
"0.50090474",
"0.49970546",
"0.4991174",
"0.49879444",
"0.49879444",
"0.49879444",
"0.49872676",
"0.49801213",
"0.4943204",
"0.49371862",
"0.49308172",
"0.4921952",
"0.49141753",
"0.4907364",
"0.49041352",
"0.49041352",
"0.4904033",
"0.48996705",
"0.48994875",
"0.48983353",
"0.48674005",
"0.48641366",
"0.4864076",
"0.4851986",
"0.48484308",
"0.48472708",
"0.48445147",
"0.48404565",
"0.4832848",
"0.48266897",
"0.48266897",
"0.48218715",
"0.48208553",
"0.4818185",
"0.48149958",
"0.4813375",
"0.48119715",
"0.4808377",
"0.48075017",
"0.47873852",
"0.478293",
"0.4773457",
"0.47691676",
"0.47615874",
"0.47559825",
"0.4750784",
"0.47496662",
"0.4743582",
"0.47281662",
"0.4712985",
"0.47126752",
"0.4706881",
"0.47017157",
"0.47017157",
"0.46905506",
"0.46903047",
"0.46870694",
"0.46842206",
"0.4683178",
"0.46829784",
"0.46828672",
"0.46800706",
"0.46781203",
"0.4669025",
"0.46679586",
"0.4667256",
"0.46639177",
"0.46559548",
"0.46455723",
"0.4633458"
] | 0.0 | -1 |
Get the local and remote content trees N Without this, we woulnd't have an way to get the source and destination content trees, which we need so that we can determine what files are present locally and remotely, and therefore which files need to be uploaded or deleted in order to sync the remote file system to the local one. | def getContentTrees
#N Without this, we wouldn't get the content tree for the local source location
@sourceContent = @sourceLocation.getContentTree()
#N Without this, we wouldn't get the content tree for the remote destination location
@destinationContent = @destinationLocation.getContentTree()
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_remote_files_hierarchy(files, root = '/', hierarchy = { dirs: [], files: [] })\n files.each do |node|\n case node['node_type']\n when 'branch'\n get_remote_files_hierarchy(node['files'], root + node['name'] + '/', hierarchy)\n when 'directory'\n hierarchy[:dirs] << \"#{root}#{node['name']}\"\n get_remote_files_hierarchy(node['files'], root + node['name'] + '/', hierarchy)\n when 'file'\n hierarchy[:files] << \"#{root}#{node['name']}\"\n end\n end\n\n return hierarchy\nend",
"def get_remote_files_hierarchy(files, root = '/', hierarchy = { dirs: [], files: [] })\n files.each do |node|\n case node['node_type']\n when 'directory'\n hierarchy[:dirs] << \"#{root}#{node['name']}\"\n get_remote_files_hierarchy(node['files'], root + node['name'] + '/', hierarchy)\n when 'file'\n hierarchy[:files] << \"#{root}#{node['name']}\"\n end\n end\n\n hierarchy\nend",
"def get_remote_files_hierarchy(files, root = '/', hierarchy = { dirs: [], files: [] })\n files.each do |node|\n case node['node_type']\n when 'directory'\n hierarchy[:dirs] << \"#{root}#{node['name']}\"\n get_remote_files_hierarchy(node['files'], root + node['name'] + '/', hierarchy)\n when 'file'\n hierarchy[:files] << \"#{root}#{node['name']}\"\n end\n end\n\n return hierarchy\nend",
"def getContentTree\n #N Without this check we would try to read the cached content file when there isn't one, or alternatively, we would retrieve the content details remotely, when we could have read them for a cached content file\n if cachedContentFile and File.exists?(cachedContentFile)\n #N Without this, the content tree won't be read from the cached content file\n return ContentTree.readFromFile(cachedContentFile)\n else\n #N Without this, we wouldn't retrieve the remote content details\n contentTree = contentHost.getContentTree(baseDir)\n #N Without this, the content tree might be in an arbitrary order\n contentTree.sort!\n #N Without this check, we would try to write a cached content file when no name has been specified for it\n if cachedContentFile != nil\n #N Without this, the cached content file wouldn't be updated from the most recently retrieved details\n contentTree.writeToFile(cachedContentFile)\n end\n #N Without this, the retrieved sorted content tree won't be retrieved\n return contentTree\n end\n end",
"def remote_nodes\n nodes.select { |node| node.namespace != local_namespace }\n end",
"def recurse_remote(children)\n sourceselect = self[:sourceselect]\n\n total = self[:source].collect do |source|\n next unless result = perform_recursion(source)\n return if top = result.find { |r| r.relative_path == \".\" } and top.ftype != \"directory\"\n result.each { |data| data.source = \"#{source}/#{data.relative_path}\" }\n break result if result and ! result.empty? and sourceselect == :first\n result\n end.flatten\n\n # This only happens if we have sourceselect == :all\n unless sourceselect == :first\n found = []\n total.reject! do |data|\n result = found.include?(data.relative_path)\n found << data.relative_path unless found.include?(data.relative_path)\n result\n end\n end\n\n total.each do |meta|\n if meta.relative_path == \".\"\n parameter(:source).metadata = meta\n next\n end\n children[meta.relative_path] ||= newchild(meta.relative_path)\n children[meta.relative_path][:source] = meta.source\n children[meta.relative_path][:checksum] = :md5 if meta.ftype == \"file\"\n\n children[meta.relative_path].parameter(:source).metadata = meta\n end\n\n children\n end",
"def find_images_and_attachments\n @image_content_nodes = []\n @attachment_nodes = []\n\n @node.children.accessible.with_content_type(%w(Image Attachment ContentCopy)).include_content.all.each do |node|\n node = node.content.copied_node if node.content_type == 'ContentCopy'\n if node.content_type == 'Image' && !node.content.is_for_header? && node.content.show_in_listing\n @image_content_nodes << node.content\n elsif node.content_type == 'Attachment'\n @attachment_nodes << node\n end\n end\n end",
"def get_remotes()\n to_return = {}\n count = 1\n num_dirs = Dir.glob('./*/').size() -2 # exclude . and ..\n Dir.glob('./*/').each() do |dir|\n next if dir == '.' or dir == '..'\n\n print \"Processing directories...#{count}/#{num_dirs}\\r\" if !$verbose\n count += 1\n\n if(File.directory?(dir) and File.exists?(dir + '/.git'))\n Dir.chdir dir\n remotes = `git remote -v`.split(\"\\n\")\n\n vprint(dir.ljust(25))\n remotes.each() do |remote|\n if(remote.index('(fetch)'))\n parts = remote.split(\"\\t\")\n\n remote_name = get_remote_name(parts[1])\n vprint(\"[#{parts[0]} #{remote_name}]\".ljust(20))\n if(remote_name != nil)\n index = parts[0] + ' - ' + remote_name\n if(to_return[index] == nil)\n to_return[index] = Array.new()\n end\n to_return[index].push(dir)\n else\n puts \"\\nDon't know what to do with #{remote} in dir #{dir}\"\n end\n end\n end # end remotes loop\n\n vprint \"\\n\"\n Dir.chdir '..'\n end # end if file.directory\n end\n\n print \"\\n\"\n return to_return\nend",
"def get_remote_files\n manager = @current_source.file_manager\n manager.start do \n @current_source.folders.each do |folder|\n @files[folder] = manager.find_files folder\n @files[folder] = @files[folder].take(@take) if @take\n Logger.<<(__FILE__,\"INFO\",\"Found #{@files[folder].size} files for #{@current_source.base_dir}/#{folder} at #{@current_source.host.address}\")\n SignalHandler.check\n end\n end\n end",
"def find_incoming_roots(remote, opts={:base => nil, :heads => nil,\n :force => false, :base => nil})\n common_nodes(remote, opts)[1]\n end",
"def common_nodes(remote, opts={:heads => nil, :force => nil, :base => nil})\n # variable prep!\n node_map = changelog.node_map\n search = []\n unknown = []\n fetch = {}\n seen = {}\n seen_branch = {}\n opts[:base] ||= {}\n opts[:heads] ||= remote.heads\n \n # if we've got nothing...\n if changelog.tip == NULL_ID\n opts[:base][NULL_ID] = true # 1 is stored in the Python\n \n return [NULL_ID], [NULL_ID], opts[:heads].dup unless opts[:heads] == [NULL_ID]\n return [NULL_ID], [], [] # if we didn't trip ^, we're returning this\n end\n \n # assume we're closer to the tip than the root\n # and start by examining heads\n UI::status 'searching for changes'\n \n opts[:heads].each do |head|\n if !node_map.include?(head)\n unknown << head\n else\n opts[:base][head] = true # 1 is stored in the Python\n end\n end\n \n opts[:heads] = unknown # the ol' switcheroo\n return opts[:base].keys, [], [] if unknown.empty? # BAIL\n \n # make a hash with keys of unknown\n requests = Hash.with_keys unknown\n count = 0\n \n # Search through the remote branches\n # a branch here is a linear part of history, with 4 (four)\n # parts:\n #\n # head, root, first parent, second parent\n # (a branch always has two parents (or none) by definition)\n #\n # Here's where we start using the Hashes instead of Arrays\n # trick. Keep an eye out for opts[:base] and opts[:heads]!\n unknown = remote.branches(*unknown)\n until unknown.empty?\n r = []\n \n while node = unknown.shift\n next if seen.include?(node[0])\n UI::debug \"examining #{short node[0]}:#{short node[1]}\"\n \n if node[0] == NULL_ID\n # Do nothing...\n elsif seen_branch.include? node\n UI::debug 'branch already found'\n next\n elsif node_map.include? node[1]\n UI::debug \"found incomplete branch #{short node[0]}:#{short node[1]}\"\n search << node[0..1]\n seen_branch[node] = true # 1 in the python\n else\n unless seen.include?(node[1]) || fetch.include?(node[1])\n if node_map.include?(node[2]) and node_map.include?(node[3])\n UI::debug \"found new changset #{short node[1]}\"\n fetch[node[1]] = true # 1 in the python\n end # end if\n \n node[2..3].each do |p|\n opts[:base][p] = true if node_map.include? p\n end\n end # end unless\n \n node[2..3].each do |p|\n unless requests.include?(p) || node_map.include?(p)\n r << p\n requests[p] = true # 1 in the python\n end # end unless\n end # end each\n end # end if\n \n seen[node[0]] = true # 1 in the python\n end # end while\n \n unless r.empty?\n count += 1\n \n UI::debug \"request #{count}: #{r.map{|i| short i }}\"\n \n (0 .. (r.size-1)).step(10) do |p|\n remote.branches(r[p..(p+9)]).each do |b|\n UI::debug \"received #{short b[0]}:#{short b[1]}\"\n unknown << b\n end\n end\n end # end unless\n end # end until\n \n # sorry for the ambiguous variable names\n # the python doesn't name them either, which\n # means I have no clue what these are\n find_proc = proc do |item1, item2|\n fetch[item1] = true\n opts[:base][item2] = true\n end\n \n # do a binary search on the branches we found\n search, new_count = *binary_search(:find => search,\n :repo => remote,\n :node_map => node_map,\n :on_find => find_proc)\n count += new_count # keep keeping track of the total\n \n # sanity check, because this method is sooooo fucking long\n fetch.keys.each do |f|\n if node_map.include? f\n raise RepoError.new(\"already have changeset #{short f[0..3]}\")\n end\n end\n \n if opts[:base].keys == [NULL_ID]\n if opts[:force]\n UI::warn 'repository is unrelated'\n else\n raise RepoError.new('repository is unrelated')\n end\n end\n \n UI::debug \"found new changesets starting at #{fetch.keys.map{|f| short f }.join ' '}\"\n UI::debug \"#{count} total queries\"\n \n # on with the show!\n [opts[:base].keys, fetch.keys, opts[:heads]]\n end",
"def remote_files\n @remote_files ||= local_files\n end",
"def remote_branches\n @rugged_repository.branches.each_name(:remote).sort\n end",
"def remote_branches\n @remote_branches ||= @project.branches.remote.map(&:full)\n end",
"def find_outgoing_roots(remote, opts={:base => nil, :heads => nil, :force => false})\n base, heads, force = opts[:base], opts[:heads], opts[:force]\n if base.nil?\n base = {}\n find_incoming_roots remote, :base => base, :heads => heads, :force => force\n end\n \n UI::debug(\"common changesets up to \"+base.keys.map {|k| k.short_hex}.join(\" \"))\n \n remain = Hash.with_keys changelog.node_map.keys, nil\n \n # prune everything remote has from the tree\n remain.delete NULL_ID\n remove = base.keys\n while remove.any?\n node = remove.shift\n if remain.include? node\n remain.delete node\n changelog.parents_for_node(node).each {|p| remove << p }\n end\n end\n \n # find every node whose parents have been pruned\n subset = []\n # find every remote head that will get new children\n updated_heads = {}\n remain.keys.each do |n|\n p1, p2 = changelog.parents_for_node n\n subset << n unless remain.include?(p1) || remain.include?(p2)\n if heads && heads.any?\n updated_heads[p1] = true if heads.include? p1\n updated_heads[p2] = true if heads.include? p2\n end\n end\n \n # this is the set of all roots we have to push\n if heads && heads.any?\n return subset, updated_heads.keys\n else\n return subset\n end\n end",
"def known_nodes\n Dir.glob(\"#{@repository_path}/nodes/*.json\").map { |file| File.basename(file, '.json') }\n end",
"def tree\n read_repo\n if @branches.count < 1\n render :template => 'repositories/newrepo'\n return\n end\n\n @files = @repository.files(@branch, @path)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @repository }\n end\n end",
"def nodes\n get_chef_files_absolute_paths nodes_path\n end",
"def sync_remotes_to_local(repo)\n local_branches = {}\n remote_branches = {}\n\n repo.branches.each {|branch|\n before, after = branch.name.split('/')\n if after.nil? # Test if this is a local branch\n local_branches[before] = branch\n else\n if branch.type == :direct # Ignore origin/HEAD etc.\n remote_branches[after] = [] unless remote_branches.key? after\n remote_branches[after].push branch\n end\n end\n }\n\n remote_branches.each {|name, remotes|\n begin\n max = remotes.max {|a, b|\n commit_compare repo, a.target, b.target\n }\n rescue ArgumentError\n raise Exception.new(\"Could not fast-forward sync #{a.name} with #{b.name}\")\n else\n if local_branches.key? name\n if repo.descendant_of? local_branches[name].target, max.target\n max.target = local_branches[name].target\n else\n logged_refupdate(repo, local_branches[name], max)\n end\n else\n puts \"Creating branch: #{name} <= #{max.name}\"\n local_branches[name] = repo.branches.create(name, max.target.oid)\n end\n end\n }\n local_branches\n end",
"def provides_tree!\n tree = Util::Tree.new\n # Provisions\n @normal_sources.each do |file|\n provisions = file.provides\n if replacement = @replacements.detect {|r| provisions.any? {|tag| tag == r.replaces } }\n file = replacement\n end\n provisions.each do |tag|\n tree[tag] = file\n end\n end\n tree\n end",
"def files_in_branches\n result = Mortadella::Horizontal.new headers: %w[BRANCH NAME CONTENT]\n existing_local_branches(order: :main_first).each do |branch|\n files_in(branch: branch).each do |file|\n result << [branch, file, content_of(file: file, for_sha: branch)]\n end\n end\n result.table\nend",
"def nodes\n [master, slaves].flatten.compact\n end",
"def get_files\n fields = \"next_page_token, files(id, name, owners, parents, mime_type, sharedWithMeTime, modifiedTime, createdTime)\"\n\n folders = []\n @files = []\n\n #Go through pages of files and save files and folders\n next_token = nil\n first_page = true\n while first_page || (!next_token.nil? && !next_token.empty?)\n results = @service.list_files(q: \"not trashed\", fields: fields, page_token: next_token)\n folders += results.files.select{|file| file.mime_type == DRIVE_FOLDER_TYPE and belongs_to_me?(file)}\n @files += results.files.select{|file| !file.mime_type.include?(DRIVE_FILES_TYPE) and belongs_to_me?(file)}\n next_token = results.next_page_token\n first_page = false\n end\n\n #Cache folders\n folders.each {|folder| @folder_cache[folder.id] = folder}\n\n #Resolve file paths and apply ignore list\n @files.each {|file| file.path = resolve_path file}\n @files.reject!{|file| Helper.file_ignored? file.path, @config}\n\n Log.log_notice \"Counted #{@files.count} remote files in #{folders.count} folders\"\n end",
"def recurse\n children = (self[:recurse] == :remote) ? {} : recurse_local\n\n if self[:target]\n recurse_link(children)\n elsif self[:source]\n recurse_remote(children)\n end\n\n # If we're purging resources, then delete any resource that isn't on the\n # remote system.\n mark_children_for_purging(children) if self.purge?\n\n # REVISIT: sort_by is more efficient?\n result = children.values.sort { |a, b| a[:path] <=> b[:path] }\n remove_less_specific_files(result)\n end",
"def synced_folders &thunk\n (self.common_field \"synced_folders\").each &thunk\n ((self.local_field \"synced_folders\") || []).each &thunk\n end",
"def browse_tree(tree = nil, cur = nil)\n return [[], []] if barerepo.empty?\n tree ||= barerepo.head.target.tree\n images = []\n directories = []\n tree.each do |item|\n next if item[:name][0] == '.'\n dest = cur.nil? ? item[:name] : File.join(cur, item[:name])\n if item[:type] == :blob\n images.push({\n data: barerepo.read(item[:oid]).data,\n dest: dest, name: item[:name]\n })\n else\n directories.push({\n dest: dest, name: item[:name]\n })\n end\n end\n [images, directories]\n end",
"def node_objects\n raise OSMLib::Error::NoDatabaseError.new(\"can't get node objects if the way is not in a OSMLib::Database\") if @db.nil?\n nodes.collect do |id|\n @db.get_node(id)\n end\n end",
"def repositories\n # TODO : merge with current data\n load_repos\n end",
"def getContentTree\n #N Without this we won't have timestamp and the map of file hashes used to efficiently determine the hash of a file which hasn't been modified after the timestamp\n cachedTimeAndMapOfHashes = getCachedContentTreeMapOfHashes\n #N Without this we won't have the timestamp to compare against file modification times\n cachedTime = cachedTimeAndMapOfHashes[0]\n #N Without this we won't have the map of file hashes\n cachedMapOfHashes = cachedTimeAndMapOfHashes[1]\n #N Without this we won't have an empty content tree which can be populated with data describing the files and directories within the base directory\n contentTree = ContentTree.new()\n #N Without this we won't have a record of a time which precedes the recording of directories, files and hashes (which can be used when this content tree is used as a cached for data when constructing some future content tree)\n contentTree.time = Time.now.utc\n #N Without this, we won't record information about all sub-directories within this content tree\n for subDir in @baseDirectory.subDirs\n #N Without this, this sub-directory won't be recorded in the content tree\n contentTree.addDir(subDir.relativePath)\n end\n #N Without this, we won't record information about the names and contents of all files within this content tree\n for file in @baseDirectory.allFiles\n #N Without this, we won't know the digest of this file (if we happen to have it) from the cached content tree\n cachedDigest = cachedMapOfHashes[file.relativePath]\n #N Without this check, we would assume that the cached digest applies to the current file, even if one wasn't available, or if the file has been modified since the time when the cached value was determined.\n # (Extra note: just checking the file's mtime is not a perfect check, because a file can \"change\" when actually it or one of it's enclosing sub-directories has been renamed, which might not reset the mtime value for the file itself.)\n if cachedTime and cachedDigest and File.stat(file.fullPath).mtime < cachedTime\n #N Without this, the digest won't be recorded from the cached digest in those cases where we know the file hasn't changed\n digest = cachedDigest\n else\n #N Without this, a new digest won't be determined from the calculated hash of the file's actual contents\n digest = hashClass.file(file.fullPath).hexdigest\n end\n #N Without this, information about this file won't be added to the content tree\n contentTree.addFile(file.relativePath, digest)\n end\n #N Without this, the files and directories in the content tree might be listed in some indeterminate order\n contentTree.sort!\n #N Without this check, a new version of the cached content file will attempt to be written, even when no name has been specified for the cached content file\n if cachedContentFile != nil\n #N Without this, a new version of the cached content file (ready to be used next time) won't be created\n contentTree.writeToFile(cachedContentFile)\n end\n return contentTree\n end",
"def tree\n # Caution: use only for small projects, don't use in root.\n $title = \"Full Tree\"\n $files = `zsh -c 'print -rl -- **/*(#{$sorto}#{$hidden}M)'`.split(\"\\n\")\nend",
"def remotes\n @remotes ||= @project.remotes\n end",
"def list_nodes\n nodes = @vcenter['destfolder'].to_s + \"\\n\"\n @components.each do |component, _config|\n (1..@components[component]['count']).each do |i|\n nodes += @components[component]['addresses'][i - 1].ljust(18, ' ') +\n node_name(component, i) + @vcenter['domain'] + ' ' +\n @components[component]['runlist'].to_s + \"\\n\"\n end\n end\n nodes\n end",
"def list_files\n [].tap do |files|\n remote_files do |file|\n files << file\n end\n end\n end",
"def remotes\n select_branches(git.grit.remotes)\n end",
"def repositories_to_fetch\n # Find all .git Repositories - Ignore *.wiki.git\n repos = Dir.glob(\"#{@config['git']['repos']}/*/*{[!.wiki]}.git\")\n\n # Build up array of NOT ignored repositories\n delete_path = []\n @config['ignore'].each do |ignored|\n path = File.join(@config['git']['repos'], ignored)\n delete_path += repos.grep /^#{path}/\n repos.delete(delete_path)\n end\n\n return repos - delete_path\n\n end",
"def nodes\n @nodes ||= list_of_nonterminated_instances.collect_with_index do |inst, i|\n RemoteInstance.new(inst.merge({:number => i}))\n end\n end",
"def all\n return @raw_repos unless @raw_repos.empty?\n return [Template.root.basename.to_s] if Template.project?\n Template.root.join(Meta.new({}).repos_dir).children.map do |path|\n path.basename.to_s\n end\n\n rescue Errno::ENOENT\n then raise(\n Error::RepoNotFound\n )\n end",
"def remotes\n repo.remotes\n end",
"def getContentTree(baseDir)\n #N Without this, wouldn't have an empty content tree that we could start filling with dir & file data\n contentTree = ContentTree.new()\n #N Without this, wouldn't record the time of the content tree, and wouldn't be able to determine from a file's modification time that it had been changed since that content tree was recorded.\n contentTree.time = Time.now.utc\n #N Without this, the listed directories won't get included in the content tree\n for dir in listDirectories(baseDir)\n #N Without this, this directory won't get included in the content tree\n contentTree.addDir(dir)\n end\n #N Without this, the listed files and hashes won't get included in the content tree\n for fileHash in listFileHashes(baseDir)\n #N Without this, this file & hash won't get included in the content tree\n contentTree.addFile(fileHash.relativePath, fileHash.hash)\n end\n return contentTree\n end",
"def files(treeish = nil)\n tree_list(treeish || @ref, false, true)\n end",
"def fetch(remote_store, remote_branch, local_branch)\n VCSToolkit::Utils::Sync.sync remote_store, remote_branch, object_store, local_branch\n end",
"def lfs_objects_relation\n project.lfs_objects_for_repository_types(nil, :project)\n end",
"def list\n storage.transaction {return storage.roots}\n end",
"def getFiles(tree, name)\n files = []\n\n tree.each_tree do |subtree|\n path = name + subtree[:name] + '/'\n subfiles = getFiles($repo.lookup(subtree[:oid]), path)\n files.push(*subfiles)\n end\n\n tree.each_blob do |file|\n file[:name] = name + file[:name]\n files.push(file)\n end\n\n return files\nend",
"def files\n nodes_files = UserFile.where(id: nodes)\n nodes_user_files = UserFile.where(id: user_files)\n nodes_files.or(nodes_user_files).real_files\n end",
"def sync_mirrors\n # create a Default Snippet Group\n self.groups.create({ label: 'Default', grouped_type: 'Cms::Snippet' })\n\n return unless is_mirrored_changed? && is_mirrored?\n\n [self, Cms::Site.mirrored.where(\"id != #{id}\").first].compact.each do |site|\n (site.layouts(:reload).roots + site.layouts.roots.map(&:descendants)).flatten.map(&:sync_mirror)\n (site.pages(:reload).roots + site.pages.roots.map(&:descendants)).flatten.map(&:sync_mirror)\n site.groups(:reload).snippets.map(&:sync_mirror)\n site.snippets(:reload).map(&:sync_mirror)\n end\n\n # set all pages as navigation_root that don't have navigation_root and parent_root set\n # this enables the navigations on new mirrored sites\n self.pages.where(parent_id: nil, navigation_root_id: nil).each do |page|\n page.update_attribute(:navigation_root_id, page.id)\n end\n end",
"def listFiles()\n #N Without this the files won't get listed\n contentHost.listFiles(baseDir)\n end",
"def remote_descs(options = {})\n\t\t\tlkp_src = ENV[\"LKP_SRC\"] || File.dirname(File.dirname File.realpath $PROGRAM_NAME)\n\n\t\t\toptions[:project] ||= '*'\n\t\t\toptions[:remote] ||= '*'\n\n\t\t\tremotes = {}\n\n\t\t\tDir[File.join(lkp_src, \"repo\", options[:project], options[:remote])].each do |file|\n\t\t\t\tremote = File.basename file\n\t\t\t\tnext if remote == 'DEFAULTS'\n\n\t\t\t\tdefaults = File.dirname(file) + '/DEFAULTS'\n\t\t\t\tremotes[remote] = load_yaml_merge [defaults, file]\n\t\t\tend\n\n\t\t\tremotes\n\t\tend",
"def git_refs()\n # This glob pattern matches recursively so we will find a branch named\n # something like 'feature/subfeature/the-cool-feature'.\n # TODO: get remotes also\n git_dir = git_git_dir()\n\n locals = Dir.glob(File.join(git_dir, 'refs', 'heads', '**', '*')).select do |f|\n !File.directory? f\n end.map do |f|\n {\n 'name' => f.split('/refs/heads/')[1],\n 'hash' => File.open(f).read().rstrip\n }\n end\n\n remotes = Dir.glob(File.join(git_dir, 'refs', 'remotes', '**', '*')).select do |f|\n !File.directory?(f) and !f.end_with? \"/HEAD\"\n end.map do |f|\n {\n 'name' => f.split('/refs/remotes/')[1],\n 'hash' => File.open(f).read().rstrip\n }\n end\n\n locals + remotes\nend",
"def destination_files\n if self.destination_connection\n return @destination_files ||= RemoteFile.new(self, self.destination_connection)\n else\n return @destination_files ||= LocalFile.new(self)\n end\n end",
"def tree_list(ref = @ref, pages=true, files=true)\n if (sha = @access.ref_to_sha(ref))\n commit = @access.commit(sha)\n tree_map_for(sha).inject([]) do |list, entry|\n if ::Gollum::Page.valid_page_name?(entry.name)\n list << entry.page(self, commit) if pages\n elsif files && !entry.name.start_with?('_') && !::Gollum::Page.protected_files.include?(entry.name)\n list << entry.file(self, commit)\n end\n list\n end\n else\n []\n end\n end",
"def ls_tree(_tree, namespace=nil)\n files = []\n\n _tree.each do |a|\n name = namespace ? [namespace, a[:name]].join('/') : a[:name]\n\n if a[:type] == :blob\n files << name\n elsif a[:type] == :tree\n files += ls_tree(@repo.lookup(a[:oid]), name)\n end\n end\n\n files\n end",
"def fetch_syncables\n gh_client.repos.list.select{|repo| repo.permissions.admin}.map(&:full_name)\n end",
"def localitems(from)\n debug \"#{self.class.to_s}: Getting local items from: #{from}\"\n searchIn = from.to_s\n sf = searchFor.map{|i| ::File.join(searchIn, i)}\n Dir[*sf].flatten.compact.reject do |p|\n ::File.directory?(p) or ignoring.any? do |i|\n ::File.fnmatch(i,p)\n end\n end.map do |path|\n path = Pathname.new(path).realpath\n item = toRemoteItem(from, path)\n if item.kind_of?(Array) then\n item.compact.map{|i| i[:local_path] = path; i}\n elsif not item.nil? then\n item[:local_path] = path\n item\n end\n end.flatten.compact\n end",
"def remote_pages\n @link_collector.remote_pages\n end",
"def trees\n @trees ||= ApiFactory.new 'GitData::Trees'\n end",
"def check_tree\n @trees = {}\n @blobs = {}\n \n data = @base.lib.ls_tree(@objectish)\n\n data['tree'].each do |key, tree| \n @trees[key] = Git::Object::Tree.new(@base, tree[:sha], tree[:mode]) \n end\n \n data['blob'].each do |key, blob| \n @blobs[key] = Git::Object::Blob.new(@base, blob[:sha], blob[:mode]) \n end\n\n {\n :trees => @trees,\n :blobs => @blobs\n }\n end",
"def find_management_nodes\n management_nodes = Node.by_is_management.reverse\n end",
"def nodes\n core_client.get_nodes\n end",
"def sync!\n\n destfiles = begin \n FsShellProxy.new.ls(@dest, true) \n rescue NoSuchFile \n {}\n end\n results = HSync::compare(LocalFs.new.ls(@source, true), destfiles)\n push_files(results.files_missing_in_b)\n # push_files(results.files_newer_in_a) # todo\n end",
"def get_relationships(clear_cache = false)\n\n\tFile.delete(node_cache_file) if clear_cache && File.exist?(node_cache_file)\n\n\tif File.exist?(node_cache_file)\n\n\t\tcontent_type :json unless is_rake\n\t\tsend_file node_cache_file\n\n\telse\n\n\t\tneo = Neography::Rest.new(ENV['NEO4J_URL'] || 'http://localhost:7474')\n\n\t\tout = {\n\t\t\t:nodes => [],\n\t\t\t:links => [],\n\t\t}\n\n\t\tusers = {}\n\t\trepos = []\n\t\trepo_index = 0\n\t\tuser_index = 0\n\n\t\tget_repos(neo).each do |repo|\n\n\t\t\trelationships = get_relationships_for_repo(neo, repo)\n\n\t\t\trepos << {\n\t\t\t\t:name => repo[1],\n\t\t\t\t:type => :repo,\n\t\t\t\t:id => repo[0],\n\t\t\t\t:group => 1,\n\t\t\t}\n\n\t\t\trelationships.each do |n|\n\n\t\t\t\tunless users.has_key?(n[0])\n\n\t\t\t\t\tusers[n[0]] = {\n\t\t\t\t\t\t:name => n[1],\n\t\t\t\t\t\t:type => :user,\n\t\t\t\t\t\t:id => n[0],\n\t\t\t\t\t\t:group => 2,\n\t\t\t\t\t\t:index => user_index,\n\t\t\t\t\t}\n\n\t\t\t\t\tuser_index = user_index + 1\n\n\t\t\t\tend\n\n\t\t\t\tout[:links] << {\n\t\t\t\t\t:source => repo_index,\n\t\t\t\t\t:target => n[0],\n\t\t\t\t\t:value => 1,\n\t\t\t\t}\n\n\t\t\tend\n\n\t\t\trepo_index = repo_index + 1\n\n\t\tend\n\n\t\t# set the target index correctly for the javascript\n\t\tout[:links].each do |l|\n\n\t\t\tl[:target] = users[l[:target]][:index] + repo_index\n\n\t\tend\n\n\t\tout[:nodes] = repos.concat(users.values.to_a).flatten\n\n\t\tFile.open(node_cache_file, 'w'){ |f| f << out.to_json }\n\n\t\tunless is_rake\n\n\t\t\tcontent_type :json\n\t\t\t#JSON.pretty_generate(out) # pretty print\n\t\t\tout.to_json # normal out\n\n\t\tend\n\n\tend\n\nend",
"def sync\n # We replicate our state to the management node(s)\n management_nodes = find_management_nodes\n management_nodes.each do |mng_node|\n remote_db = mng_node.get_node_db\n from_success = @our_node.replicate_from(local_node_db, mng_node, remote_db)\n to_success = @our_node.replicate_to(local_node_db, mng_node, remote_db)\n if from_success && to_success && !our_node.is_management\n break\n end\n end\n end",
"def remotes_directory\n workspace_manager.remotes_directory\n end",
"def tree_root\n repo.tree\n end",
"def folder_tree\n parent_folder_id =\n unsafe_params[:parent_folder_id] == \"\" ? nil : unsafe_params[:parent_folder_id].to_i\n scoped_parent_folder_id =\n unsafe_params[:scoped_parent_folder_id] == \"\" ? nil : unsafe_params[:scoped_parent_folder_id].to_i\n\n if unsafe_params[:scopes].present?\n check_scope!\n # exclude 'public' scope\n if unsafe_params[:scopes].first =~ /^space-(\\d+)$/\n spaces_members_ids = Space.spaces_members_ids(unsafe_params[:scopes])\n spaces_params = {\n context: @context,\n spaces_members_ids: spaces_members_ids,\n scopes: unsafe_params[:scopes],\n scoped_parent_folder_id: scoped_parent_folder_id,\n }\n files = UserFile.batch_space_files(spaces_params)\n folders = Folder.batch_space_folders(spaces_params)\n else\n files = UserFile.batch_private_files(@context, [\"private\", nil], parent_folder_id)\n folders = Folder.batch_private_folders(@context, parent_folder_id)\n end\n end\n\n folder_tree = []\n Node.folder_content(files, folders).each do |item|\n folder_tree << {\n id: item[:id],\n name: item[:name],\n type: item[:sti_type],\n uid: item[:uid],\n scope: item[:scope],\n }\n end\n\n render json: folder_tree\n end",
"def remotes\n self.lib.remotes.map { |r| Git::Remote.new(self, r) }\n end",
"def remote_images\n @link_collector.remote_images\n end",
"def Files\n deep_copy(@tomerge)\n end",
"def nodes\r\n params = {\r\n method: :get,\r\n url: '/project/nodes',\r\n params: { prjUUID: @uuid }\r\n }\r\n @session.request(**params).perform!['nodes']\r\n end",
"def files_remote_list(options = {})\n options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]\n if block_given?\n Pagination::Cursor.new(self, :files_remote_list, options).each do |page|\n yield page\n end\n else\n post('files.remote.list', options)\n end\n end",
"def file_nodes\n @file_nodes ||= files.map { |file| create_node(file) }.compact\n end",
"def file_nodes\n @file_nodes ||= files.map { |file| create_node(file) }.compact\n end",
"def owned_and_shared_folders\n folders = Folder.includes(:topic_shares).where(\"user_id = ? OR topic_shares.recipient_id = ?\", self.id, self.id).order('folders.updated_at DESC').references(:shares)\n folders\n end",
"def list(path=nil, sha=nil)\n remote_path = list_path(path).sub(/^\\//, '').sub(/\\/$/, '')\n\n result = @client.tree(repo, sha || source_branch, recursive: true).tree\n result.sort! do |x, y|\n x.path.split('/').size <=> y.path.split('/').size\n end\n\n # Filters for folders containing the specified path\n result.reject! { |elem| !elem.path.match(remote_path + '($|\\/.+)') }\n raise Error, 'Invalid GitHub path specified' if result.empty?\n\n # Filters out lower levels\n result.reject! do |elem|\n filename = elem.path.split('/').last\n File.join(remote_path, filename).sub(/^\\//, '') != elem.path\n end\n\n result.map do |elem|\n {\n name: elem.path.split('/').last,\n path: elem.path,\n type: elem.type == 'tree' ? 'folder' : 'file',\n sha: elem.sha\n }\n end\n end",
"def check_tree\n unless @trees\n @trees = {}\n @blobs = {}\n @base.ls_tree(@objectish).each do |hash|\n if hash[:type] == 'tree'\n @trees[hash[:path]] = TinyGit::Object::Tree.new(@base, hash[:sha], hash[:mode])\n elsif hash[:type] == 'blob'\n @blobs[hash[:path]] = TinyGit::Object::Blob.new(@base, hash[:sha], hash[:mode])\n end\n end\n end\n end",
"def sync_available_sibling_repos(hostname, remote_repo_parent_dir=\"/root\", ssh_user=\"root\")\n working_dirs = ''\n clone_commands = ''\n SIBLING_REPOS.each do |repo_name, repo_dirs|\n repo_dirs.each do |repo_dir|\n if sync_sibling_repo(repo_name, repo_dir, hostname, remote_repo_parent_dir, ssh_user)\n working_dirs += \"#{repo_name}-working \"\n clone_commands += \"git clone #{repo_name} #{repo_name}-working; \"\n break # just need the first repo found\n end\n end\n end\n return clone_commands, working_dirs\n end",
"def get_next_remote_node\n all_nodes = remote_nodes.dup\n all_nodes |= [@local_node]\n all_nodes = all_nodes.sort\n local_node_index = all_nodes.index(@local_node)\n all_nodes[(local_node_index + 1) % all_nodes.size]\n end",
"def files\n @files ||= begin\n storage = model.storages.first\n return [] unless storage # model didn\"t store anything\n\n path = storage.send(:remote_path)\n unless path == File.expand_path(path)\n path.sub!(%r{(ssh|rsync)-daemon-module}, \"\")\n path = File.expand_path(File.join(\"tmp\", path))\n end\n Dir[File.join(path, \"#{model.trigger}.tar*\")].sort\n end\n end",
"def merge_trees(base_treeish, local_treeish, remote_treeish)\n invoke(:merge_recursive, base_treeish, \"-- #{local_treeish} #{remote_treeish}\")\n true\n rescue ShellExecutionError => error\n # 'CONFLICT' messages go to stdout.\n raise MergeError, error.out\n end",
"def get_content_search_paths()\n r = @file_content_search_paths.clone\n p = find_project_dir_of_cur_buffer()\n if p.nil?\n p = vma.buffers.last_dir\n end\n\n if p and !@file_content_search_paths.include?(p)\n r.insert(0, p)\n end\n\n return r\n end",
"def nodes\n request.get(path: node_index_path, auth_token: auth_token)\n end",
"def get_remote_dir\n return @resource[:remote_dir]\n end",
"def nodes\n @conn.nodes\n end",
"def file_connections_weighted_graph\n read_all_git_repos('files')\n graph_links_between_git_objects('files')\n end",
"def tree_objects(tree_sha)\n git_tree = tree(tree_sha)\n return [] if git_tree.blank?\n git_tree.tree\n end",
"def local_branches\n @local_branches ||= begin\n branches = []\n if not git.branches.local.empty?\n branches << git.branches.local.select{ |b| b.current }[0].name\n branches << git.branches.local.select{ |b| not b.current }.map{ |b| b.name }\n end\n branches.flatten\n end\n end",
"def repos\n @client.repos.all.collect(&:clone_url)\n end",
"def synced_folders(vm, host, global)\n if folders = get_config_parameter(host, global, 'synced_folders')\n folders.each do |folder|\n vm.synced_folder folder['src'], folder['dest'], folder['options']\n end\n end\nend",
"def remote_node_bags\n bags = []\n bag_query = { admin_node: remote_node.namespace }\n local_client.bags(bag_query) do |response|\n bags << response.body if response.success?\n end\n bags.flatten\n end",
"def bfs\n return bfs_helper(@root, [])\n end",
"def rest__list\n diff = ret_request_params(:diff)\n project = get_default_project()\n datatype = :module\n remote_repo_base = ret_remote_repo_base()\n\n opts = Opts.new(project_idh: project.id_handle())\n if detail = ret_request_params(:detail_to_include)\n opts.merge!(detail_to_include: detail.map(&:to_sym))\n end\n\n opts.merge!(remote_repo_base: remote_repo_base, diff: diff)\n datatype = :module_diff if diff\n\n rest_ok_response NodeModule.list(opts), datatype: datatype\n end",
"def tree\n # Caution: use only for small projects, don't use in root.\n @title = 'Full Tree'\n # @files = `zsh -c 'print -rl -- **/*(#{@sorto}#{@hidden}M)'`.split(\"\\n\")\n @files = Dir['**/*']\n message \"#{@files.size} files.\"\nend",
"def x_get_tree_roots\n objects = []\n objects.push(:id => \"xx-system\",\n :text => _(\"Examples (read only)\"),\n :icon => \"pficon pficon-folder-close\",\n :tip => _(\"Examples (read only)\"))\n PxeImageType.all.sort.each do |item, _idx|\n objects.push(item)\n end\n objects\n end",
"def synced_folders\n @__synced_folders\n end",
"def listDirectories\n return contentHost.listDirectories(baseDir)\n end",
"def getCachedContentTree\n #N Without this, we won't know the name of the specified cached content file (if it is specified)\n file = getExistingCachedContentTreeFile\n #N Without this check, we would attempt to read a non-existent file\n if file\n #N Without this, a content tree that has been cached won't be returned.\n return ContentTree.readFromFile(file)\n else\n return nil\n end\n end",
"def tree\n @stack = @rpn.clone\n get_tree\n end",
"def available_managed_paths_for_site_creation\n return @available_managed_paths_for_site_creation\n end",
"def get_local_files_hierarchy(files, hierarchy = { dirs: [], files: [] })\n hierarchy[:files] = files\n\n dirs = files.inject([]) do |res, a|\n res << a.split('/').drop(1).inject([]) do |res, s|\n res << res.last.to_s + '/' + s\n end\n end\n dirs.map(&:pop) # delete last element from each array\n hierarchy[:dirs] = dirs.flatten.uniq\n\n return hierarchy\nend",
"def modified_files\n diff = git.diff(local_branch, remote_branch(local_branch))\n diff.stats[:files].keys\n end"
] | [
"0.60094804",
"0.59638125",
"0.595711",
"0.5803146",
"0.5629192",
"0.55500877",
"0.55458045",
"0.54757345",
"0.54165083",
"0.5400852",
"0.5381941",
"0.53772426",
"0.53558654",
"0.53524566",
"0.52339834",
"0.52116674",
"0.51814115",
"0.5152623",
"0.51410717",
"0.5110208",
"0.5063102",
"0.5010687",
"0.49663857",
"0.4954511",
"0.4928642",
"0.49220034",
"0.49195704",
"0.49050805",
"0.48884806",
"0.48812318",
"0.48748153",
"0.4853869",
"0.48453003",
"0.48346707",
"0.48167285",
"0.48123443",
"0.48093107",
"0.48047203",
"0.4802599",
"0.48011434",
"0.47968388",
"0.4796118",
"0.47900233",
"0.47855496",
"0.47852966",
"0.47837245",
"0.47831032",
"0.47706053",
"0.4767651",
"0.4765974",
"0.47637758",
"0.4762149",
"0.47318718",
"0.47289923",
"0.472538",
"0.47243538",
"0.47084484",
"0.47036025",
"0.4701464",
"0.46950686",
"0.46820557",
"0.46709436",
"0.4670234",
"0.46640426",
"0.46617708",
"0.4661472",
"0.46570146",
"0.46465337",
"0.46416834",
"0.46363744",
"0.4635747",
"0.4635747",
"0.46271336",
"0.4622427",
"0.46140555",
"0.4613168",
"0.4611643",
"0.46077293",
"0.4600373",
"0.4599182",
"0.45965874",
"0.4589413",
"0.45815253",
"0.45666343",
"0.45628116",
"0.4560972",
"0.45591998",
"0.45582265",
"0.45575583",
"0.45480978",
"0.4547606",
"0.45413944",
"0.4539044",
"0.45377478",
"0.45343465",
"0.4531916",
"0.4526811",
"0.45258415",
"0.45247743",
"0.4522245"
] | 0.73691565 | 0 |
On the local and remote content trees, mark the copy and delete operations required to sync the remote location to the local location. N Without this, we woundn't have an easy way to mark the content trees for operations required to perform the sync | def markSyncOperations
#N Without this, the sync operations won't be marked
@sourceContent.markSyncOperationsForDestination(@destinationContent)
#N Without these puts statements, the user won't receive feedback about what sync operations (i.e. copies and deletes) are marked for execution
puts " ================================================ "
puts "After marking for sync --"
puts ""
puts "Local:"
#N Without this, the user won't see what local files and directories are marked for copying (i.e. upload)
@sourceContent.showIndented()
puts ""
puts "Remote:"
#N Without this, the user won't see what remote files and directories are marked for deleting
@destinationContent.showIndented()
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def doSync(options = {})\n #N Without this, the content files will be cleared regardless of whether :full options is specified\n if options[:full]\n #N Without this, the content files won't be cleared when the :full options is specified\n clearCachedContentFiles()\n end\n #N Without this, the required content information won't be retrieved (be it from cached content files or from the actual locations)\n getContentTrees()\n #N Without this, the required copy and delete operations won't be marked for execution\n markSyncOperations()\n #N Without this, we won't know if only a dry run is intended\n dryRun = options[:dryRun]\n #N Without this check, the destination cached content file will be cleared, even for a dry run\n if not dryRun\n #N Without this check, the destination cached content file will remain there, even though it is stale once an actual (non-dry-run) sync operation is started.\n @destinationLocation.clearCachedContentFile()\n end\n #N Without this, the marked copy operations will not be executed (or in the case of dry-run, they won't be echoed to the user)\n doAllCopyOperations(dryRun)\n #N Without this, the marked delete operations will not be executed (or in the case of dry-run, they won't be echoed to the user)\n doAllDeleteOperations(dryRun)\n #N Without this check, the destination cached content file will be updated from the source content file, even if it was only a dry-run (so the remote location hasn't actually changed)\n if (not dryRun and @destinationLocation.cachedContentFile and @sourceLocation.cachedContentFile and\n File.exists?(@sourceLocation.cachedContentFile))\n #N Without this, the remote cached content file won't be updated from local cached content file (which is a reasonable thing to do assuming the sync operation completed successfully)\n FileUtils::Verbose.cp(@sourceLocation.cachedContentFile, @destinationLocation.cachedContentFile)\n end\n #N Without this, any cached SSH connections will remain unclosed (until the calling application has terminated, which may or may not happen soon after completing the sync).\n closeConnections()\n end",
"def pre_sync\n #move\n end",
"def markSyncOperationsForDestination(destination)\n markCopyOperations(destination)\n destination.markDeleteOptions(self)\n end",
"def sync\n # We replicate our state to the management node(s)\n management_nodes = find_management_nodes\n management_nodes.each do |mng_node|\n remote_db = mng_node.get_node_db\n from_success = @our_node.replicate_from(local_node_db, mng_node, remote_db)\n to_success = @our_node.replicate_to(local_node_db, mng_node, remote_db)\n if from_success && to_success && !our_node.is_management\n break\n end\n end\n end",
"def sync\n each_difference(local_resources, true) { |name, diffs| sync_difference(name, diffs) }\n end",
"def sync_mirrors\n # create a Default Snippet Group\n self.groups.create({ label: 'Default', grouped_type: 'Cms::Snippet' })\n\n return unless is_mirrored_changed? && is_mirrored?\n\n [self, Cms::Site.mirrored.where(\"id != #{id}\").first].compact.each do |site|\n (site.layouts(:reload).roots + site.layouts.roots.map(&:descendants)).flatten.map(&:sync_mirror)\n (site.pages(:reload).roots + site.pages.roots.map(&:descendants)).flatten.map(&:sync_mirror)\n site.groups(:reload).snippets.map(&:sync_mirror)\n site.snippets(:reload).map(&:sync_mirror)\n end\n\n # set all pages as navigation_root that don't have navigation_root and parent_root set\n # this enables the navigations on new mirrored sites\n self.pages.where(parent_id: nil, navigation_root_id: nil).each do |page|\n page.update_attribute(:navigation_root_id, page.id)\n end\n end",
"def sync!\n\n destfiles = begin \n FsShellProxy.new.ls(@dest, true) \n rescue NoSuchFile \n {}\n end\n results = HSync::compare(LocalFs.new.ls(@source, true), destfiles)\n push_files(results.files_missing_in_b)\n # push_files(results.files_newer_in_a) # todo\n end",
"def sync\n announcing 'Syncing Portage Tree' do\n chroot 'sync'\n end\n send_to_state('build', 'sync')\n end",
"def sync_local\n sync_hash = {\n ['~/Library/Application\\\\ Support/Firefox', '~/Library/Application\\\\ Support/Quicksilver',\n '~/Library/Preferences' ] =>'library/',\n ['~/.boson', '~/.sake', '~/.cronrc', '~/.gemrc', '~/.gitconfig', '~/.gem/specs']=>'dotfiles/',\n }\n sync_hash.each do |src, dest|\n src.each do |e| \n cmd = \"rsync -av #{e} #{File.join('~/backup', dest)}\"\n system cmd\n end\n end\n end",
"def fetch(remote_store, remote_branch, local_branch)\n VCSToolkit::Utils::Sync.sync remote_store, remote_branch, object_store, local_branch\n end",
"def old_sync; end",
"def sync_code_dir\n fs_commands = { 'commit': '{\"commit-all\": true}', 'force-sync': \"\" }\n fs_commands.each do |fs_cmd, data|\n curl = %W[\n curl\n -X POST\n --cert $(puppet config print hostcert)\n --key $(puppet config print hostprivkey)\n --cacert $(puppet config print localcacert)\n -H \"Content-type: application/json\"\n https://#{master}:8140/file-sync/v1/#{fs_cmd}\n -d '#{data}'\n ].join(\" \")\n\n on(master, curl)\n end\n end",
"def sync() end",
"def sync() end",
"def sync() end",
"def action_sync\n assert_target_directory_valid!\n if ::File.exist?(::File.join(@new_resource.destination, 'CVS'))\n Chef::Log.debug \"#{@new_resource} update\"\n converge_by(\"sync #{@new_resource.destination} from #{@new_resource.repository}\") do\n run_command(run_options(:command => sync_command))\n Chef::Log.info \"#{@new_resource} updated\"\n end\n else\n action_checkout\n end\n end",
"def fsync() end",
"def fsync() end",
"def fsync() end",
"def push(remote_store, local_branch, remote_branch)\n VCSToolkit::Utils::Sync.sync object_store, local_branch, remote_store, remote_branch\n end",
"def getContentTrees\n #N Without this, we wouldn't get the content tree for the local source location\n @sourceContent = @sourceLocation.getContentTree()\n #N Without this, we wouldn't get the content tree for the remote destination location\n @destinationContent = @destinationLocation.getContentTree()\n end",
"def execute_sync\n @env.primary_vm.run_action(Vagrant::Mirror::Middleware::Sync)\n end",
"def sync\n end",
"def sync\n end",
"def sync\n @cache.flush(true)\n @nodes.sync\n end",
"def sync!\n local_book = File.join(Bookshelf::local_folder, relative_path)\n\n if File.exists?(local_book) && !FileUtils.cmp(absolute_path, local_book)\n if File.mtime(absolute_path) > File.mtime(local_book)\n cp absolute_path, local_book\n return :pull\n else\n cp local_book, absolute_path\n return :push\n end\n else\n return nil\n end\n end",
"def perform_sync(source, destination, options)\n new_files, new_files_destination = get_new_files_to_sync(source, destination, options)\n sync_new_files(source, new_files, new_files_destination, options)\n cleanup_files_we_dont_want_to_keep(source, new_files, new_files_destination) unless options[:keep].nil?\n end",
"def sync()\n #This is a stub, used for indexing\n end",
"def fsync\n end",
"def fsync\n end",
"def sync\n # preparation\n check_remote_path_valid\n check_git_repo\n reset_remote_repo\n\n diff_text = local_diff\n apply_diff_to_remote diff_text\n\n # output = @ssh.exec! 'hostname'\n # puts output\n end",
"def sync; end",
"def fsync()\n #This is a stub, used for indexing\n end",
"def iosync\n @tc_storage.sync\n @tc_log.sync\n @tc_heads.sync\n nil\n end",
"def sync\n pull && push\n end",
"def synced_folders &thunk\n (self.common_field \"synced_folders\").each &thunk\n ((self.local_field \"synced_folders\") || []).each &thunk\n end",
"def sync(_location_conf, _sync_existing)\n return false\n end",
"def update_content_paths\n\n # Checking if the parent id has changed for the current content have to change the content paths table only if parent id is changed\n new_parent_id = ContentData.get_parent_id(self.id)\n\n # Getting the old parent data from the content path table\n old_parent_id = 0\n old_parent = ContentPath.where(:descendant => self.id, :depth => 1)\n # If there are any parents found with the getting the old parent id\n if old_parent.length > 0\n old_parent_id = old_parent.first.ancestor\n end\n\n # If the parent id is changed then update the content path structure\n if new_parent_id != old_parent_id\n\n # Refer to the article \"http://www.mysqlperformanceblog.com/2011/02/14/moving-subtrees-in-closure-table/\" for the logic\n # Detach the node from the old parent \n delete_query = \"DELETE a FROM content_paths AS a JOIN content_paths AS d ON a.descendant = d.descendant LEFT JOIN content_paths AS x ON x.ancestor = d.ancestor AND x.descendant = a.ancestor WHERE d.ancestor = '\"+self.id.to_s+\"' AND x.ancestor IS NULL\"\n ActiveRecord::Base.connection.execute(delete_query)\n\n # Attach the node to the new parent\n insert_query = \"INSERT INTO content_paths (ancestor, descendant, depth) SELECT supertree.ancestor, subtree.descendant, supertree.depth+subtree.depth+1 FROM content_paths AS supertree JOIN content_paths AS subtree WHERE subtree.ancestor = '\"+self.id.to_s+\"' AND supertree.descendant = '\"+new_parent_id.to_s+\"'\"\n ActiveRecord::Base.connection.execute(insert_query)\n\n ## The code for changing the childrens data of the edited node with the new parent data\n ## Getting the data of the new parent\n new_parent_data = Content.find(new_parent_id)\n\n ## Board is at the top level no need to change the children data\n if self.type == 'Board'\n\n ## Content year parent is changed update all the children with the current board id\n elsif self.type == 'ContentYear'\n if self.children.map(&:descendant).length > 1\n Content.where(:id => self.children.map(&:descendant)).update_all(:board_id => self.board_id)\n end\n\n ## Subject parent is changed update all the children with the curent board id and content year id\n elsif self.type == 'Subject'\n if self.children.map(&:descendant).length > 1\n Content.where(:id => self.children.map(&:descendant)).update_all(:board_id => self.board_id, :content_year_id => self.content_year_id)\n end\n\n ## Chapter parent is changed update all the children with the current board id , content year id and subject id\n elsif self.type == 'Chapter'\n if self.children.map(&:descendant).length > 1\n Content.where(:id => self.children.map(&:descendant)).update_all(:board_id => self.board_id, :content_year_id => self.content_year_id, :subject_id => self.subject_id)\n end\n\n ## Topic parent is changed update all the children with the current board id, content year id, subject id and chapter id\n elsif self.type == 'Topic'\n if self.children.map(&:descendant).length > 1\n Content.where(:id => self.children.map(&:descendant)).update_all(:board_id => self.board_id, :content_year_id => self.content_year_id, :subject_id => self.subject_id, :chapter_id => self.chapter_id)\n end\n\n ## Subtopic parent is changed update all the children with the current board id, content year id, subject id, chapter id and topic id\n elsif self.type == 'SubTopic'\n if self.children.map(&:descendant).length > 1\n Content.where(:id => self.children.map(&:descendant)).update_all(:board_id => self.board_id, :content_year_id => self.content_year_id, :subject_id => self.subject_id, :chapter_id => self.chapter_id, :topic_id => self.topic_id)\n end\n end\n\n ## End of code for changing the childrens data\n\n end\n end",
"def sync_cmd\n warn(\"Legacy call to #sync_cmd cannot be preserved, meaning that \" \\\n \"test files will not be uploaded. \" \\\n \"Code that calls #sync_cmd can now use the transport#upload \" \\\n \"method to transfer files.\")\n end",
"def local\n db_dump\n sync_local\n system_lists\n commit_git_repo(\"~/backup\")\n end",
"def sync\n callback = Proc.new do |modified, added, removed|\n added && added.each do |add_file|\n @store.add(@local_directory + \"/\" + add_file)\n end\n modified && modified.each do |modified_file|\n @store.modify(@local_directory + \"/\" + modified_file)\n end\n removed && removed.each do |remove_file|\n @store.remove(@local_directory + \"/\" + remove_file)\n end\n end\n @listener.change(&callback) # convert the callback to a block and register it\n @listener.start! # have to use !\n end",
"def sync_dir dir\n # TODO: think of a better name scheme\n # maybe the title should include the relative path?\n calculated_photoset_name = \"[ruphy-backup] #{dir}\"\n Dir.chdir @root + '/' + dir\n\n if photoset_exist? calculated_photoset_name\n #sync\n flickr_list = get_file_list calculated_photoset_name\n local_list = Dir[\"*\"]\n remotely_missing = []\n locally_missing = []\n \n local_list.each do |f|\n remotely_missing << f unless flickr_list.include? f\n end\n# puts \"remotely missing files: \" + remotely_missing.join(',')\n \n remotely_missing.each do |f|\n upload f, calculated_photoset_name\n end\n \n \n flickr_list.each do |f|\n locally_missing << f unless local_list.include? f\n end\n puts \"we're locally missing: \" + locally_missing.join(', ')\n \n # TODO: really perform sync\n \n else\n # set not existing: just upload\n Dir[\"*\"].each do |f|\n upload f, calculated_photoset_name\n end\n end\n end",
"def sync_mirrors_with_regulated_box\n if respond_to?(:mirrors) && is_mirrored_with_regulated_box\n mirrors.each { |mirror| mirror.update_attributes(regulated: self.regulated) }\n end\n end",
"def post_sync\n reset_movement\n reset_flags\n end",
"def remote_sync_if_necessary(options={})\n false\n end",
"def sync\n if not cloned?\n clone\n else\n update\n end\n end",
"def sync_folders (vm_config)\n\n synced_folders = list_synced_folders\n synced_folders.each do |synced_folder|\n synced_folder.sync(vm_config)\n end\n\n end",
"def sync_to_provider #:nodoc:\n self.cache_writehandle do # when the block ends, it will trigger the provider upload\n self.erase_cache_symlinks unless self.archived?\n end\n self.make_cache_symlinks unless self.archived?\n true\n end",
"def sync()\n group_differ = GroupDiffer.new(@finder)\n group_diffs = group_differ.diff(@test_groups)\n sync_groups(group_diffs)\n\n @targets.each do |target_def|\n sync_target(target_def)\n end\n end",
"def finalize_sync_operation\n puts \" - Transferred the following #{ @st_ops_cache_file.keys.count } st_ops versions to foreign repos:\"\n @st_ops_cache_file.keys.each { |from_git_commit, to_git_commit|\n puts \" - #{ from_git_commit } to #{ to_git_commit }\"\n }\n if @successful_files_with_st_ops.any?\n puts \" - The following #{ @successful_files_with_st_ops.count } files with st operations were synced successfully:\".color(:green)\n @successful_files_with_st_ops.each { |file_path| puts \" - #{ file_path }\" }\n else\n puts \" - No files with st operations were synced successfully\".color(:red)\n end\n if @successful_files_with_autosplit.any?\n puts \" - The following #{ @successful_files_with_autosplit.count } files with autosplit were synced successfully:\".color(:green)\n @successful_files_with_autosplit.each { |file_path| puts \" - #{ file_path }\" }\n else\n puts \" - No files with autosplit were synced successfully\".color(:red)\n end\n if @successful_files_without_st_ops.any?\n puts \" - The following #{ @successful_files_without_st_ops.count } files without st operations were synced successfully:\".color(:green)\n @successful_files_without_st_ops.each { |file_path| puts \" - #{ file_path }\" }\n else\n puts \" - No files without st operations were synced successfully\".color(:red)\n end\n if @unprocessable_files.any?\n puts \" - The following #{ @unprocessable_files.count } files could not be synced:\".color(:red)\n @unprocessable_files.each { |f_attrs|\n print \" - #{ f_attrs[:file].repo_relative_path(true) }: \".ljust(52).color(:red)\n puts \"#{ f_attrs[:message] }\".color(:red)\n }\n else\n puts \" - All file syncs were successful!\".color(:green)\n end\n if @files_with_autosplit_exceptions.any?\n puts \" - The following #{ @files_with_autosplit_exceptions.count } files raised an exception during autosplit:\".color(:red)\n @files_with_autosplit_exceptions.each { |f_attrs|\n print \" - #{ f_attrs[:file].repo_relative_path(true) }: \".ljust(52).color(:red)\n puts \"#{ f_attrs[:message] }\".color(:red)\n }\n else\n puts \" - No files raised exceptions during autosplit\".color(:green)\n end\n if @files_with_subtitle_count_mismatch.any?\n puts \" - The following #{ @files_with_subtitle_count_mismatch.count } files were synced, however their subtitle counts don't match:\".color(:red)\n @files_with_subtitle_count_mismatch.each { |f_attrs|\n print \" - #{ f_attrs[:file].repo_relative_path(true) }: \".ljust(52).color(:red)\n puts \"#{ f_attrs[:message] }\".color(:red)\n }\n else\n puts \" - All synced files have matching subtitle counts.\".color(:green)\n end\n true\n end",
"def sync\n local_directories.each do |local_directory|\n if settings[:dry_run]\n log.info(sync_command(local_directory))\n else\n IO.popen(sync_command(local_directory)).each { |line| handle_output(line) }\n end\n end\n end",
"def sync\n contents_sync(resource.parameter(:source) || self)\n end",
"def sync=\n end",
"def sync_remotes_to_local(repo)\n local_branches = {}\n remote_branches = {}\n\n repo.branches.each {|branch|\n before, after = branch.name.split('/')\n if after.nil? # Test if this is a local branch\n local_branches[before] = branch\n else\n if branch.type == :direct # Ignore origin/HEAD etc.\n remote_branches[after] = [] unless remote_branches.key? after\n remote_branches[after].push branch\n end\n end\n }\n\n remote_branches.each {|name, remotes|\n begin\n max = remotes.max {|a, b|\n commit_compare repo, a.target, b.target\n }\n rescue ArgumentError\n raise Exception.new(\"Could not fast-forward sync #{a.name} with #{b.name}\")\n else\n if local_branches.key? name\n if repo.descendant_of? local_branches[name].target, max.target\n max.target = local_branches[name].target\n else\n logged_refupdate(repo, local_branches[name], max)\n end\n else\n puts \"Creating branch: #{name} <= #{max.name}\"\n local_branches[name] = repo.branches.create(name, max.target.oid)\n end\n end\n }\n local_branches\n end",
"def transfer_applicable_st_ops_to_foreign_file!(foreign_content_at_file, applicable_st_ops_for_file)\n if applicable_st_ops_for_file.any?\n # An st_ops_for_file exists. That means the file is being synced.\n # NOTE: Not sure why we're passing applicable_st_ops_for_file\n # as an array as there should really be only one.\n\n # Iterate over st_ops and incrementally update both content and data\n found_st_ops = false\n applicable_st_ops_for_file.each do |st_ops_for_file|\n # Detect if there are st_ops for file, or if it's time slice\n # changes only.\n found_st_ops ||= st_ops_for_file.operations.any?\n transfer_st_ops_to_foreign_file!(\n foreign_content_at_file,\n st_ops_for_file\n )\n # We have to reload the file contents as they were changed on\n # disk by #transfer_st_ops_to_foreign_file!\n foreign_content_at_file.reload_contents!\n end\n # We need to manually write the @to_git_commit to st_sync_commit.\n # We can't rely on transfer_st_ops_to_foreign_file! alone since\n # it will only write sync commits that actually contained st_ops\n # for the current file. However we want to record on the file\n # that it has been synced to the current primary st_sync_commit.\n update_foreign_file_level_data(\n foreign_content_at_file,\n @to_git_commit,\n {} # Don't touch sts that require review\n )\n if found_st_ops\n # Actual st ops\n print \" - Synced\".color(:green)\n else\n # Time slice changes only\n print \" - Synced (Time slice changes only)\".color(:green)\n end\n else\n # No applicable st ops, just update file level st_sync data\n update_foreign_file_level_data(\n foreign_content_at_file,\n @to_git_commit,\n {} # Don't touch sts that require review\n )\n print \" - No applicable st_ops\"\n end\n true\n end",
"def setSyncFolder(vm)\n # do nothing\n end",
"def sync_special_fat32_files\n Dir[File.join(@path_source, '**/*\\./')].sort.each do |source_dir|\n # Syncing files from source and dest\n dest_dir = get_dest_filepath(source_dir)\n\n puts \"Manually syncing files to #{File.basename(dest_dir)}\"\n rsync_dirs(source_dir, dest_dir, true)\n end\n end",
"def sync_files\n User.sync_files!(@context)\n end",
"def perform!\n exclude_filter = ''\n @excludes.each { |e| exclude_filter << \" --exclude '#{e}' \" }\n \n @tasks.each do |task|\n prepared_source = prepare_path(task[:source], @source_base_path)\n prepared_target = prepare_path(task[:target], @target_base_path)\n Logger.message \"Perform One-Way-Mirror:\"\n Logger.message \" - Source: #{prepared_source}\"\n Logger.message \" - Target: #{prepared_target}\"\n\n create_dir_if_missing(prepared_target)\n \n `rsync --archive -u -v --delete #{exclude_filter} \"#{prepared_source}\" \"#{prepared_target}\"`\n end\n end",
"def before_sync(chdir: true, &block)\n @before_sync_hook = Hook.new(block, chdir)\n end",
"def sync(srcDir, dstDir)\n end",
"def callback(paths, modified, added, removed)\n @logger.info(\"File change callback called!\")\n @logger.info(\" - Modified: #{modified.inspect}\")\n @logger.info(\" - Added: #{added.inspect}\")\n @logger.info(\" - Removed: #{removed.inspect}\")\n\n tosync = []\n paths.each do |hostpath, folders|\n # Find out if this path should be synced\n found = catch(:done) do\n [modified, added, removed].each do |changed|\n changed.each do |listenpath|\n throw :done, true if listenpath.start_with?(hostpath)\n end\n end\n\n # Make sure to return false if all else fails so that we\n # don't sync to this machine.\n false\n end\n\n # If it should be synced, store it for later\n tosync << folders if found\n end\n\n # Sync all the folders that need to be synced\n tosync.each do |folders|\n folders.each do |opts|\n # Reload so we get the latest ID\n opts[:machine].reload\n if !opts[:machine].id || opts[:machine].id == \"\"\n # Skip since we can't get SSH info without an ID\n next\n end\n\n begin\n rsync_helper = rsync_helper(opts[:machine], opts[:id], opts[:opts])\n\n unless rsync_helper\n # couldn't find SSH info for that machine\n raise Vagrant::Errors::MachineGuestNotReady\n end\n\n start = Time.now\n rsync_helper.rsync_single\n finish = Time.now\n time_spent_msg = \"Time spent in rsync: #{finish-start} (in seconds)\"\n @logger.info(time_spent_msg)\n opts[:machine].ui.info(time_spent_msg)\n rescue Vagrant::Errors::MachineGuestNotReady\n # Error communicating to the machine, probably a reload or\n # halt is happening. Just notify the user but don't fail out.\n opts[:machine].ui.error(I18n.t(\n \"vagrant.rsync_communicator_not_ready_callback\"))\n rescue Vagrant::Errors::RSyncError => e\n # Error executing rsync, so show an error\n opts[:machine].ui.error(I18n.t(\n \"vagrant.rsync_auto_rsync_error\", message: e.to_s))\n end\n end\n end\n end",
"def sync( options = {} )\n options = { :local => \".\", :remote => \".\" , :passive => false}.merge( options )\n local, remote , passive = options[:local], options[:remote], options[:passive]\n \n tmpname = tmpfilename\n connect do |ftp|\n ftp.passive = passive\n # Read remote .syncftp\n begin\n ftp.gettextfile( remote+\"/\"+\".syncftp\", tmpname )\n @remote_md5s = YAML.load( File.open( tmpname ).read )\n rescue Net::FTPPermError => e\n raise Net::FTPPermError, e.message, caller if ftp.remote_file_exist?( remote+\"/\"+\".syncftp\" )\n end\n \n # Do the job Bob !\n send_dir( ftp, local, remote )\n \n # Write new .syncftp\n File.open( tmpname, 'w' ) do |out|\n YAML.dump( @local_md5s, out )\n end\n \n # Delete files\n @delete_dirs = []\n @delete_files = []\n @remote_md5s.keys.clone.delete_if{ |f| @local_md5s.keys.include?(f) }.each do |f|\n if @remote_md5s[f] == \"*\"\n @delete_dirs << f\n else\n @delete_files << f\n end\n end\n @delete_files.each do |f|\n @log.info \"Delete ftp://#{@host}:#{@port}/#{f}\"\n begin\n ftp.delete( f )\n rescue => e\n @log.info \"ftp://#{@host}:#{@port}/#{f} does not exist\"\n end\n end \n @delete_dirs.each do |f|\n @log.info \"Delete ftp://#{@host}:#{@port}/#{f}\"\n begin\n ftp.delete( f )\n rescue => e\n @log.info \"ftp://#{@host}:#{@port}/#{f} does not exist\"\n end\n end \n \n ftp.puttextfile( tmpname, remote+\"/\"+\".syncftp\" )\n end\n File.delete( tmpname )\n end",
"def sync_child_pages\n children.each{ |p| p.save! } if full_path_changed?\n end",
"def sync(local_dir, remote_dir)\n ftp.login(@user, @password)\n ftp.passive = @passive\n puts 'FTP => Logged in, start syncing...'\n\n sync_folder(local_dir, remote_dir, ftp)\n\n puts 'FTP => Sync finished.'\n\n rescue Net::FTPPermError => e\n puts \"Failed: #{e.message}\"\n ensure\n ftp.close\n puts 'FTP => Closed.'\n end",
"def sync\n run 'sync', :quiet => true\n end",
"def sync_ro_folder(ro_path, dropbox_session, ro_model, version_srs, parent=ro_model)\n exists_in_dropbox = []\n dropbox_session.list(ro_path).each do |dbox_file|\n\n entry = parent.children.find_or_create_by_path(dbox_file.path)\n \n entry.research_object = ro_model\n\n relative_path = dbox_file.path[ro_model.path.length+1..-1]\n exists_in_dropbox << relative_path\n\n entry.name = relative_path.split('/').last\n\n\t if dbox_file.directory?\n entry.entry_type = :directory\n entry.hash = \"-1\"\n entry.revision = \"-1\"\n entry.save!\n\t sync_ro_folder(dbox_file.path, dropbox_session, ro_model, version_srs, entry)\n entry.hash = dbox_file.hash\n elsif relative_path == \"manifest.rdf\"\n entry.entry_type = :manifest\n else\n if entry.revision == dbox_file.revision || parent.hash == dbox_file.hash\n next\n end\n entry.entry_type = :file\n content = dropbox_session.download(dbox_file.path)\n resource = version_srs[relative_path]\n if resource\n # update the resource\n resource.content = content\n else\n puts \"Uploading \" + relative_path\n resource = version_srs.upload_resource(relative_path, APPLICATION_OCTET_STREAM, content)\n end\n end\n entry.revision = dbox_file.revision\n entry.save!\n end\n\n\n for existing_model in parent.children\n\n relative_path = existing_model.path[ro_model.path.length+1..-1]\n\n if exists_in_dropbox.include?(relative_path)\n puts \"Not deleting \" + relative_path\n next\n end\n\n resource = version_srs[relative_path]\n if resource\n puts \"(Should have been) deleting \" + relative_path\n # FIXME: This sometimes wants to delete manifest.rdf -> disabled\n #resource.delete!\n end\n #existing_model.delete\n end\n \n # Sync back again anything added on ROSRS which we did not put there\n version_srs.each do |resource| \n if exists_in_dropbox.include?(relative_path)\n puts \"Not uploading \" + relative_path\n next\n end\n \n dropbox_path = ro_model.path + \"/\" + resource.name \n is_folder = resource.name.ends_with? \"/\"\n \n file_path = dropbox_path.sub(/(.*)\\/.*/, \"\\\\1\")\n file_name = resource.name.split(\"/\")[-1]\n \n make_dropbox_folders(dropbox_session, file_path)\n # TODO: Stream from ROSRS? \n\n if not is_folder\n # Make sure we can deal with binaries\n temp_file = Tempfile.new(\"robox-sync\", :encoding => 'ascii-8bit')\n begin\n resource.download(temp_file)\n temp_file.seek(0)\n dropbox_session.upload(temp_file, file_path, :as => file_name)\n dbox_file = dropbox_session.metadata(dropbox_path)\n puts \"Uploaded to Dropbox: \" + dropbox_path\n ensure\n temp_file.unlink\n temp_file.close\n end\n end\n ## Put into database\n entry = parent.children.find_or_create_by_path(dropbox_path)\n entry.research_object = ro_model\n entry.name = file_name\n entry.entry_type = :file\n if is_folder\n puts \"Added folder \" + dropbox_path\n entry.entry_type = :directory\n entry.revision = -1\n entry.hash = -1\n else\n entry.revision = dbox_file.revision\n end\n entry.save!\n end\n \n end",
"def propagate_acl()\n\n #Propagate to subfolders\n self.children.each do |subfolder|\n if subfolder.acl.inherits\n acl = self.acl.deep_clone()\n acl.inherits = true\n acl.save\n\n subfolder.acl = acl\n subfolder.save\n\n subfolder.propagate_acl()\n end\n end\n\n #Propagate to documents\n self.references.each do |reference|\n if reference.acl.inherits\n acl = self.acl.deep_clone()\n acl.inherits = true\n acl.save\n reference.acl = acl\n reference.save\n end\n end\n\n\n end",
"def after_sync\n end",
"def sync\n TaskwarriorWeb::Command.new(:sync, nil, nil).run\n end",
"def sync\n #debug 'content sync'\n # We're safe not testing for the 'source' if there's no 'should'\n # because we wouldn't have gotten this far if there weren't at least\n # one valid value somewhere.\n @resource.write(:content)\n end",
"def sync_sf_to_local(sync_query, sync_fields, remote_sobject, force = false)\n # local_object = sync_query.local_model.constantize.find_or_initialize_by(:sf_id => remote_sobject.Id)\n select_object = @local_objects.select {|lo| lo.sf_id == remote_sobject.Id} \n if select_object.empty?\n local_object = sync_query.local_model.constantize.new(:sf_id => remote_sobject.Id)\n else\n local_object = select_object.first\n end\n # Sync only if the Salesforce object is newer than the local object \n unless force == true\n diff = different?(local_object, remote_sobject, sync_fields)\n sf_newer = sobject_newer?(remote_sobject, local_object)\n print \"Different? #{diff}\\n\"\n end\n \n if (diff && sf_newer) || force == true \n sync_fields.each do |field|\n # Update the local field if it's value is different from the value in Salesforce\n local_object[\"#{field.local_field_name}\"] != remote_sobject[\"#{field.sf_field_name}\"] ? local_object[\"#{field.local_field_name}\"] = remote_sobject[\"#{field.sf_field_name}\"] : nil\n # If Model has a last_sync_at column add the current timestamp\n if local_object.has_attribute?(:last_sync_at) && local_object.has_changes_to_save?\n local_object.last_sync_at = Time.now\n end \n end\n if local_object.has_changes_to_save?\n local_object.save(:validate => false) ? puts(local_object.to_s) : 'error' \n end\n end \n end",
"def reshare dir, host\n if File.exist? \"#{dir}/#{host}/.completed\"\n `share -F nfs -o ro=#{host},anon=0 #{dir}/#{host} > /dev/null 2>&1`\n end\nend",
"def sync(src_object, dest_object=nil) # LOCAL_DIR s3://BUCKET[/PREFIX] or s3://BUCKET[/PREFIX] LOCAL_DIR\n send_command \"sync\", src_object, dest_object\n end",
"def synced_folders(vm, host, global)\n if folders = get_config_parameter(host, global, 'synced_folders')\n folders.each do |folder|\n vm.synced_folder folder['src'], folder['dest'], folder['options']\n end\n end\nend",
"def sync_to_cache(deep=true) #:nodoc:\n syncstat = self.local_sync_status(:refresh)\n return true if syncstat && syncstat.status == 'InSync'\n super()\n if deep && ! self.archived?\n self.sync_civet_outputs\n self.update_cache_symlinks\n end\n @cbfl = @civet_outs = nil # flush internal cache\n true\n end",
"def sync!(other)\n allowed_envs = deploy_groups.map(&:environment).map(&:permalink) << 'global'\n allowed_groups = deploy_groups.map(&:permalink) << 'global'\n\n keys = other.client.kv.list_recursive\n\n # we can only write the keys that are allowed to live in this server\n keys.select! do |key|\n scope = Samson::Secrets::Manager.parse_id(key)\n allowed_envs.include?(scope.fetch(:environment_permalink)) &&\n allowed_groups.include?(scope.fetch(:deploy_group_permalink))\n end\n\n Samson::Parallelizer.map(keys.each_slice(100).to_a) do |keys|\n # create new clients to avoid any kind of blocking or race conditions\n other_client = other.create_client\n local_client = create_client\n\n keys.each do |key|\n secret = other_client.kv.read(key).data\n local_client.kv.write(key, secret)\n end\n end\n end",
"def sync(&block)\n queue SyncCommand, [], {}, &block\n end",
"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 sync_to_cache_for_archiving\n result = sync_to_cache(false)\n self.erase_cache_symlinks rescue nil\n result\n end",
"def sync_datas_process\n SyncDatas.sync(self)\n # user = self\n end",
"def push(remote_path, local_path, delete)\n\n # load our sync data\n sync_data = load_sync_data(local_path)\n \n Net::SFTP.start(@remote_host,\n @remote_username,\n :password => @remote_password) do |sftp|\n\n push_dir(sftp, remote_path, local_path, delete, sync_data)\n end\n\n # save our sync data\n save_sync_data(local_path, sync_data)\n end",
"def icloud_sync\n raise \"not yet implemented\"\n end",
"def sync\n folders = get_gfolders(:refresh => true)\n folders or return\n\n by_title = gdocs_by_title(folders)\n\n @messages = []\n\n top = by_title['CMS']\n unless top\n flash[:error] = 'No CMS folder in your FixNix Docs'\n return render 'document/sync'\n end\n\n client = get_gdata_client\n return unless client\n\n unless by_title[cycle_gfolder(@cycle)]\n folder = client.create_folder(@cycle.slug, :parent => top)\n by_title[cycle_gfolder(@cycle)] = folder\n session[:gfolders] = {} # clear cache\n @messages << \"Created #{folder.full_title}\"\n end\n\n cycle_folder = by_title[\"#{top.full_title}/#{@cycle.slug}\"]\n\n ['Systems', 'Accepted'].each do |name|\n unless by_title[\"#{cycle_folder.full_title}/#{name}\"]\n folder = client.create_folder(name, :parent => cycle_folder)\n by_title[\"#{cycle_folder.full_title}/#{name}\"] = folder\n session[:gfolders] = {} # clear cache\n @messages << \"Created #{folder.full_title}\"\n end\n end\n\n systems = by_title[\"#{cycle_folder.full_title}/Systems\"]\n\n System.all.each do |sys|\n path = system_gfolder(@cycle, sys)\n unless by_title[path]\n folder = client.create_folder(sys.slug, :parent => systems)\n session[:gfolders] = {} # clear cache\n @messages << \"Created #{folder.full_title}\"\n end\n end\n end",
"def do_local_checkout_and_rsync(svn_username, actor)\n configuration.logger.debug(\"++++ LOCAL CHECKOUT AND RSYNC ++++\")\n rsync_username = configuration[:rsync_username] ? \"#{configuration[:rsync_username]}@\" : \"\"\n local_rsync_cache= configuration[:local_rsync_cache]\n remote_rsync_cache= configuration[:remote_rsync_cache]\n if local_rsync_cache.nil? || remote_rsync_cache.nil?\n throw \"to use rsync local_rsync_cache and remote_rsync_cache must be set\"\n end\n\n configuration.logger.debug \"rm -rf #{local_rsync_cache} && #{svn} export #{svn_username} -q -r#{configuration[:revision]} #{rep_path} #{local_rsync_cache}\"\n\n # update the local svn cache\n run_local(\n \n \"rm -rf #{local_rsync_cache}&& #{svn} export #{svn_username} -q -r#{configuration[:revision]} #{rep_path} #{local_rsync_cache}\"\n )\n\n # rsync with the remote machine(s)\n rcmd = 'rsync '\n # add rsync options\n %w{\n archive\n compress\n copy-links\n cvs-exclude\n delete-after\n no-blocking-io\n stats\n }.each { | opt | rcmd << \"--#{opt} \" }\n\n # excluded files and directories\n excludes= configuration[:rsync_excludes] || []\n excludes.each { |e| rcmd << \" --exclude \\\"#{e}\\\" \" }\n\n # for each server in current task\n actor.current_task.servers.each do |server|\n configuration.logger.debug \"RSyncing deployment cache for #{server}\"\n configuration.logger.debug \"#{rcmd} -e ssh #{local_rsync_cache}/ #{rsync_username}#{server}:#{remote_rsync_cache}/\"\n run_local(\"#{rcmd} -e ssh #{local_rsync_cache}/ #{rsync_username}#{server}:#{remote_rsync_cache}/\")\n end\n\n # copy the remote_rsync_cache on the remote machine as if it has been checked out there\n cmd=\"cp -a #{remote_rsync_cache}/ #{actor.release_path} && \"\n run_remote(actor, cmd)\n end",
"def pre_push(remote, opts={})\n common = {}\n remote_heads = remote.heads\n inc = common_nodes remote, :base => common, :heads => remote_heads, :force => true\n inc = inc[1]\n update, updated_heads = find_outgoing_roots remote, :base => common, :heads => remote_heads\n \n if opts[:revs]\n btw = changelog.nodes_between(update, opts[:revs])\n missing_cl, bases, heads = btw[:between], btw[:roots], btw[:heads]\n else\n bases, heads = update, changelog.heads\n end\n if bases.empty?\n UI::status 'no changes found'\n return nil, 1\n elsif !opts[:force]\n # check if we're creating new remote heads\n # to be a remote head after push, node must be either\n # - unknown locally\n # - a local outgoing head descended from update\n # - a remote head that's known locally and not\n # ancestral to an outgoing head\n \n warn = false\n if remote_heads == [NULL_ID]\n warn = false\n elsif (opts[:revs].nil? || opts[:revs].empty?) and heads.size > remote_heads.size\n warn = true\n else\n new_heads = heads\n remote_heads.each do |r|\n if changelog.node_map.include? r\n desc = changelog.heads r, heads\n l = heads.select {|h| desc.include? h }\n \n new_heads << r if l.empty?\n else\n new_heads << r\n end\n end\n \n warn = true if new_heads.size > remote_heads.size\n end\n \n if warn\n UI::status 'abort: push creates new remote heads!'\n UI::status '(did you forget to merge? use push -f to forge)'\n return nil, 0\n elsif inc.any?\n UI::note 'unsynced remote changes!'\n end\n end\n \n if opts[:revs].nil?\n # use the fast path, no race possible on push\n cg = get_changegroup common.keys, :push\n else\n cg = changegroup_subset update, revs, :push\n end\n \n [cg, remote_heads]\n end",
"def auto_sync_transaction\n prev = Device.current\n Device.current = self\n yield\n Device.current = prev\n end",
"def sync_data(class_name)\n sync_class = class_name.constantize\n sync_results = []\n threads = remote_nodes.collect do |node|\n # Thread the sync for each node so that one node failure does\n # not interfere with other nodes.\n Thread.fork do\n sync_results << begin\n sync_class.new(local_node, node).sync\n rescue\n # allow sync_class to log exception details\n false\n end\n end\n end\n threads.each(&:join)\n sync_results.all?\n end",
"def sync (vm_config)\n vm_config.synced_folder @host_path, guest_path\n end",
"def _synced\n @_synced ||= {}\n end",
"def removed_unmarked_paths\n #remove dirs\n dirs_enum = @dirs.each_value\n loop do\n dir_stat = dirs_enum.next rescue break\n if dir_stat.marked\n dir_stat.marked = false # unset flag for next monitoring\\index\\remove phase\n #recursive call\n dir_stat.removed_unmarked_paths\n else\n # directory is not marked. Remove it, since it does not exist.\n write_to_log(\"NON_EXISTING dir: \" + dir_stat.path)\n # remove file with changed checksum\n $local_content_data_lock.synchronize{\n $local_content_data.remove_directory(dir_stat.path, Params['local_server_name'])\n }\n rm_dir(dir_stat)\n end\n end\n\n #remove files\n files_enum = @files.each_value\n loop do\n file_stat = files_enum.next rescue break\n if file_stat.marked\n file_stat.marked = false # unset flag for next monitoring\\index\\remove phase\n else\n # file not marked meaning it is no longer exist. Remove.\n write_to_log(\"NON_EXISTING file: \" + file_stat.path)\n # remove file with changed checksum\n $local_content_data_lock.synchronize{\n $local_content_data.remove_instance(Params['local_server_name'], file_stat.path)\n }\n # remove from tree\n @files.delete(file_stat.path)\n end\n end\n end",
"def sync\n unlock if locked?\n lock\n PATH()\n end",
"def test_move_under_single_lock\n setup_hr\n\n lock = lock 'httplock/hr', :depth => RubyDav::INFINITY\n\n response = @request.move('httplock/hr/recruiting/resumes', 'httplock/hr/archives/resumes')\n assert_equal '423', response.status\n assert_exists 'httplock/hr/recruiting/resumes/'\n assert_does_not_exist 'httplock/hr/archives/resumes/'\n\n if_hdr = lock.token\n response = @request.move('httplock/hr/recruiting/resumes', 'httplock/hr/archives/resumes', false, :if => if_hdr)\n assert_equal '201', response.status\n assert_does_not_exist 'httplock/hr/recruiting/resumes/'\n assert_exists 'httplock/hr/archives/resumes/'\n\n # cleanup\n unlock('httplock/hr', lock.token)\n delete_coll('httplock')\n end",
"def sync_disks(machine)\n @logger.info \"Syncing disks for #{machine.name}...\"\n machine.disks.each do |disk|\n begin\n disk.remote_id ? update_disk(disk) : create_disk(disk)\n rescue StandardError => e\n message = e.is_a?(RestClient::Exception) ? e.response : e\n raise Exceptions::OnPremiseException, message\n end\n end\n end",
"def ready_remix() end",
"def sync_data\n\t\tSYNC_TABLES.each do |sync|\n\t\t\tself.sync_table(sync)\n\t\tend\n\tend",
"def atomic_insert_modifier\n atomic_paths.insert_modifier\n end",
"def sync(source_entry)\n [ :entry_status, :entry_author_id, :entry_allow_comments, :entry_allow_pings, \n :entry_convert_breaks, :entry_title, :entry_excerpt, :entry_text, :entry_text_more,\n :entry_to_ping_urls, :entry_pinged_urls, :entry_keywords, :entry_tangent_cache,\n :entry_created_on, :entry_modified_on, :entry_created_by, :entry_modified_by,\n :entry_basename, :entry_week_number ].each do |attribute|\n self[attribute] = source_entry[attribute]\n end\n\n # Sync placements ONLY if this entry has been previously saved.\n unless self.new_record?\n # Add or update placements.\n source_entry.placements.each do |source_placement|\n # Category may not exist yet; copy if so.\n target_category = MovableType::AR::Category.find(:first, :conditions => { :category_blog_id => self.entry_blog_id, :category_label => source_placement.category.category_label })\n target_category = MovableType::AR::Category.create(self.blog, source_placement.category) if target_category.blank?\n target_placement = self.placements.find(:first, :conditions => { :placement_category_id => target_category.category_id })\n target_placement.blank? ?\n self.placements << MovableType::AR::Placement.create(self, source_placement) :\n target_placement.sync!(source_placement)\n end\n \n # Remove old placements.\n if self.placements.size > source_entry.placements.size\n self.placements.each do |target_placement|\n source_category = MovableType::AR::Category.find(:first, :conditions => { :category_blog_id => source_entry.entry_blog_id, :category_label => target_placement.category.category_label })\n if source_category.blank?\n self.placements.delete(target_placement)\n next\n end\n \n source_placement = source_entry.placements.find(:first, :conditions => { :placement_category_id => source_category.category_id })\n self.placements.delete(target_placement) if source_placement.blank?\n end\n end\n \n # Comments need to be synchronized separately (should always flow from production -> beta).\n end\n end",
"def synchronize\n\n # individual settings are done e.g. in customers_controller.rb#deprovision\n @partentTargets = nil if @partentTargets.nil? \n\n @async_all = true if @async && @async_all.nil?\n @async_individual = true if @async && @async_individual.nil?\n\n @recursive_all = false if @recursive_all.nil?\n @recursive_individual = true if @recursive_individual.nil?\n\n if @async_all\n being_all = \"being \"\n else\n being_all = \"\"\n end\n\n if @async_individual\n being_individual = \"being \"\n else\n being_individual = \"\"\n end\n \n #raise ENV[\"WEBPORTAL_SYNCHRONIZE_ALL_ABORT_ON_ABORT\"].inspect\n #raise (!@async_all).inspect\n if ENV[\"WEBPORTAL_SYNCHRONIZE_ALL_ABORT_ON_ABORT\"] == \"true\" || @async_all\n # in case of asynchronous synchronization, we always allow to abort on abort, since this will trigger delayed_job to retry\n # in case of synchronous synchronization, we allow to abort on abort only, if WEBPORTAL_SYNCHRONIZE_ALL_ABORT_ON_ABORT is set to \"true\"\n @abortOnAbort = true\n else\n # in case of synchronous synchronization and WEBPORTAL_SYNCHRONIZE_ALL_ABORT_ON_ABORT is not set to \"true\", we proceed even after an abort (e.g. if a target is unreachable, other targets will still be synchronized)\n @abortOnAbort = false\n end\n #raise @abortOnAbort.inspect\n\n # note: @id needs to be set in the individual child classes (e.g. Customer/Site/User)\n if @id.nil?\n #\n # PATCH /customers/synchronize\n #\n # if @id is nil, we assume that all Customers/Sites/Users needs to be synchronized:\n\n @myClass.synchronizeAll(@partentTargets, @async_all, @recursive_all, @abortOnAbort)\n redirect_to :back, notice: \"All #{@myClass.name.pluralize} are #{being_all}synchronized.\"\n else\n #\n # PATCH /customers/1/synchronize\n #\n # if @id is not nil, an individual Customer/Site/User with id==@id is synchronized:\n \n @provisioningobject = @myClass.find(@id)\n @provisioningobject.synchronize(@async_individual, @recursive_individual)\n redirect_to :back, notice: \"#{@provisioningobject.class.name} #{@provisioningobject.name} is #{being_individual}synchronized.\"\n end\n end",
"def test_multi_resource_lock_child_locked\n response = @request.delete('coll')\n\n response = @request.mkcol('coll')\n assert_equal '201', response.status\n\n response = @request.mkcol('coll/subcoll')\n assert_equal '201', response.status\n\n response = @request.put('coll/file', @stream)\n assert_equal '201', response.status\n\n lock = lock 'coll/subcoll'\n\n response = @request.lock 'coll'\n assert_equal '207', response.status\n resps = response.responses\n assert_equal '424', resps[@uri.path + 'coll'].status\n assert_equal '423', resps[@uri.path + 'coll/subcoll'].status\n\n response = @request.delete('coll', :depth => RubyDav::INFINITY,\n :if => { 'coll/subcoll' => lock.token })\n end"
] | [
"0.6713701",
"0.65546894",
"0.60874045",
"0.60850275",
"0.5955627",
"0.5849162",
"0.5838915",
"0.5838877",
"0.57865703",
"0.5759823",
"0.57272893",
"0.5712779",
"0.5710553",
"0.5710553",
"0.5710553",
"0.569446",
"0.5648276",
"0.56463933",
"0.56463933",
"0.5644414",
"0.5634724",
"0.56212944",
"0.55979073",
"0.55979073",
"0.5591871",
"0.55800253",
"0.55624515",
"0.5548217",
"0.5540241",
"0.5540241",
"0.5539162",
"0.5539124",
"0.5518178",
"0.54881984",
"0.5487717",
"0.5485817",
"0.547127",
"0.54698354",
"0.54566234",
"0.54545695",
"0.5445232",
"0.5438726",
"0.5392841",
"0.53922683",
"0.539056",
"0.5379165",
"0.5368925",
"0.5359487",
"0.53478813",
"0.53342175",
"0.5319257",
"0.5313998",
"0.5307475",
"0.5284521",
"0.5283798",
"0.52773017",
"0.5275857",
"0.5258051",
"0.52413166",
"0.52306044",
"0.5229551",
"0.52278805",
"0.52272224",
"0.522559",
"0.5223918",
"0.5217236",
"0.520114",
"0.51987404",
"0.5174082",
"0.51649135",
"0.51576453",
"0.51480013",
"0.5132911",
"0.5131049",
"0.5127613",
"0.50956315",
"0.50926995",
"0.5089822",
"0.5083511",
"0.5083413",
"0.50677925",
"0.50601256",
"0.5059514",
"0.5056175",
"0.5046151",
"0.50440085",
"0.50428677",
"0.50427717",
"0.5031785",
"0.50279367",
"0.5024674",
"0.5013924",
"0.50100076",
"0.50095695",
"0.5005085",
"0.5004799",
"0.5004428",
"0.5002111",
"0.49937335",
"0.49924198"
] | 0.7346809 | 0 |
Delete the local and remote cached content files (which will force a full recalculation of both content trees next time) N Without this, there won't be an easy way to delete all cached content files (thus forcing details for both content trees to be retrieved directly from the source & destination locations) | def clearCachedContentFiles
#N Without this, the (local) source cached content file won't be deleted
@sourceLocation.clearCachedContentFile()
#N Without this, the (remote) source cached content file won't be deleted
@destinationLocation.clearCachedContentFile()
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear_remote\n execute(:rm, '-rf', File.join(remote_cache_path, '*')) if test!(\"[ -d #{remote_cache_path} ]\")\n end",
"def delete_cache_files; end",
"def delete_cache_files; end",
"def clean_remote\n to_delete = remote_assets - local_compiled_assets\n to_delete.each do |f|\n delete_remote_asset(bucket.files.get(f))\n end\n end",
"def remove_superfluous_destination_files\n # join mirror_file and dest_file and delete everything from dest_file which isn't in mirror_file\n # because mirror_file should represent the current state of the source mogile files\n Log.instance.info('Joining destination and mirror tables to determine files that have been deleted from source repo.')\n DestFile.where('mirror_file.dkey IS NULL').joins('LEFT OUTER JOIN mirror_file ON mirror_file.dkey = file.dkey').find_in_batches(batch_size: 1000) do |batch|\n batch.each do |file|\n # Quit if program exit has been requested.\n break if SignalHandler.instance.should_quit\n\n # Delete all files from our destination domain which no longer exist in the source domain.\n begin\n Log.instance.debug(\"key [ #{file.dkey} ] should not exist. Deleting.\")\n @dest_mogile.delete(file.dkey)\n @removed += 1\n @freed_bytes += file.length\n rescue => e\n @failed += 1\n Log.instance.error(\"Error deleting [ #{file.dkey} ]: #{e.message}\\n#{e.backtrace}\")\n end\n end\n\n # Print a summary to the user.\n summarize\n\n # Quit if program exit has been requested.\n return true if SignalHandler.instance.should_quit\n end\n end",
"def clean_remote!\n resp = @connection.get_bucket(\n @storage.bucket, prefix: File.dirname(@remote_path)\n )\n keys = resp.body['Contents'].map {|item| item['Key'] }\n\n @connection.delete_multiple_objects(@storage.bucket, keys) unless keys.empty?\n end",
"def delete_source_files source\n dir = Conf::directories\n base = File.join(dir.data)\n source.folders.each do |fold|\n url = File.join(dir.store,source.name.to_s,fold)\n delete_files_from url\n url = File.join(dir.backup,source.name.to_s,fold)\n delete_files_from url\n end\n Logger.<<(__FILE__,\"INFO\",\"Deleted files server & backup for #{source.name.to_s}\")\n end",
"def clearCachedContentFile\n #N Without this check, it will try to delete a cached content file even when it doesn't exist\n if cachedContentFile and File.exists?(cachedContentFile)\n #N Without this, there will be no feedback to the user that the specified cached content file is being deleted\n puts \" deleting cached content file #{cachedContentFile} ...\"\n #N Without this, the specified cached content file won't be deleted\n File.delete(cachedContentFile)\n end\n end",
"def flush\n Dir[ File.join( store, '*.cache' ) ].each do |file|\n File.delete(file)\n end\n end",
"def delete_collection\n FileUtils.rm_r @src_path\n FileUtils.rm_r @store_path if store_exist?\n end",
"def purge\n self.files.each do |f|\n f.destroy\n end\n self.commits.each do |c|\n c.destroy\n end\n end",
"def remove!\n messages = []\n transferred_files do |local_file, remote_file|\n messages << \"#{storage_name} started removing '#{ local_file }'.\"\n end\n Logger.message messages.join(\"\\n\")\n\n FileUtils.rm_r(remote_path)\n end",
"def files_remote_remove(options = {})\n post('files.remote.remove', options)\n end",
"def remove_local_copy\n Dir.chdir(self.study.data_store_path)\n if File.exists?(self.download_location)\n File.delete(self.download_location)\n subdir = self.remote_location.blank? ? self.id : self.remote_location.split('/').first\n if Dir.exist?(subdir) && Dir.entries(subdir).delete_if {|e| e.start_with?('.')}.empty?\n Dir.rmdir(subdir)\n end\n end\n end",
"def remove!\n FileUtils.rm(File.join(remote_path, remote_file))\n end",
"def cleanup_old_files\n # make a local copy of to_delete while simultaneously clearing the original (atomicity)\n # local_to_delete = $to_delete.slice!(0..-1).to_a\n local_to_delete = []\n $to_delete.delete_if { |v| local_to_delete << v; true }\n\n $files.each_pair do |uuid, file|\n if file.nil?\n $files.delete uuid\n elsif local_to_delete.include?(uuid) || (Time.now - 60*60) > file.ctime\n file.close # Close it\n file.unlink if file.respond_to? :unlink # Unlink it if we can\n $files.delete uuid\n end\n end\n GC.start\nend",
"def close_files\n [self.source, self.original, self.destination].each do |f|\n next unless f\n begin\n f.close\n File.unlink(f) if SystemInformation.env == 'production'\n rescue\n nil\n end\n end\n end",
"def remove!\n begin\n connection.sync_clock\n connection.delete_object(bucket, File.join(remote_path, remote_file))\n rescue Excon::Errors::SocketError; end\n end",
"def delete_files()\n\n puts \"Deleting cloud files on all machines...\"\n \n # Create an MCollective client so that we avoid errors that appear\n # when you create more than one client in a short time\n mcc = MCollectiveFilesClient.new(\"files\")\n \n # Delete leader, id, last_id and last_mac files on all machines\n # (leader included)\n mcc.delete_file(CloudLeader::LEADER_FILE) # Leader ID\n mcc.delete_file(CloudLeader::ID_FILE) # ID\n mcc.delete_file(CloudLeader::LAST_ID_FILE) # Last ID\n mcc.delete_file(CloudVM::LAST_MAC_FILE) # Last MAC address\n mcc.disconnect # Now it can be disconnected\n \n # Delete rest of regular files on leader machine\n files = [CloudInfrastructure::DOMAINS_FILE, # Domains file\n \"/tmp/cloud-#{@resource[:name]}\"] # Cloud file\n files.each do |file|\n if File.exists?(file)\n File.delete(file)\n else\n puts \"File #{file} does not exist\"\n end\n end\n\n end",
"def clean\n cache = Cache.instance\n # remove all built files\n cache.targets(false).each do |target|\n cache.remove_target(target)\n FileUtils.rm_f(target)\n end\n # remove all created directories if they are empty\n cache.directories(false).sort {|a, b| b.size <=> a.size}.each do |directory|\n cache.remove_directory(directory)\n next unless File.directory?(directory)\n if (Dir.entries(directory) - ['.', '..']).empty?\n Dir.rmdir(directory) rescue nil\n end\n end\n cache.write\n end",
"def file_delete(node, file)\n _out, _local, _remote, code = node.test_and_store_results_together(\"rm #{file}\", 'root', 500)\n code\nend",
"def file_delete(node, file)\n _out, _local, _remote, code = node.test_and_store_results_together(\"rm #{file}\", 'root', 500)\n code\nend",
"def postSync(options = {})\n deleteLocalDataDir(options)\n end",
"def remove_unnecessary_cache_files!\n current_keys = cache_files.map do |file|\n get_cache_key_from_filename(file)\n end\n inmemory_keys = responses.keys\n\n unneeded_keys = current_keys - inmemory_keys\n unneeded_keys.each do |key|\n File.unlink(filepath_for(key))\n end\n end",
"def clear_local\n execute(:rm, '-rf', File.join(local_cache_path, '*')) if test!(\"[ -d #{local_cache_path} ]\")\n File.unlink(cached_gemfile_md5_path)\n end",
"def destroy(remote_path)\n get_adapter.delete_file(remote_path)\n end",
"def clear_diff_cache\n if Dor::Config.stacks.local_workspace_root.nil?\n raise ArgumentError, 'Missing Dor::Config.stacks.local_workspace_root' \n end\n druid = DruidTools::Druid.new(self.pid, Dor::Config.stacks.local_workspace_root)\n diff_pattern = File.join(druid.temp_dir, DIFF_FILENAME + '.*')\n FileUtils.rm_f Dir.glob(diff_pattern)\n end",
"def cleanup\n cleanup_unpack_path\n cleanup_download_path\n end",
"def delete\n delete_from_server single_url\n end",
"def erase\n HDB.verbose and puts \"Erasing successfully-copied files\"\n unlinkable = @files.collect do |x|\n f = get_real_filename(x)\n File.directory?(f) or File.symlink?(f)\n end\n # TODO: unlink them now.\n # TODO: rmdir directories, starting with child nodes first\n raise \"erase unimplemented\"\n end",
"def delete_remote\n policy = get_policy(\"remove\")\n signature = get_signature(policy)\n remote = url+\"?signature=\"+signature+\"&policy=\"+policy\n try = self.class.delete(remote)\n\n # If file not found in filepicker, destroy anyway, else only if success\n if try.not_found?\n true\n else\n try.success?\n end\n end",
"def cleanup\n winrm.run_cmd( \"del #{base64_file_name} /F /Q\" )\n winrm.run_cmd( \"del #{command_file_name} /F /Q\" )\n end",
"def delete_cache_and_img_and_fingerprint\n self.delete_cache_and_img\n\n # why do we bother clearing our fingerprint if the AssetOutput itself\n # is about to get deleted? If we don't, the after_commit handler will\n # rewrite the same cache we just deleted.\n self.fingerprint = ''\n end",
"def delete_rdf_file\n public_path = public_rdf_storage_path\n private_path = private_rdf_storage_path\n FileUtils.rm(public_path) if File.exist?(public_path)\n FileUtils.rm(private_path) if File.exist?(private_path)\n end",
"def delete(files)\n # sync before we delete\n sync\n Array.wrap(files).each do |f|\n info \"removing #{f}\"\n FileUtils.rm(f)\n error \"#{f} wasn't removed\" if File.exists?(f)\n end\n end",
"def destroy_file\n start_ssh do |ssh|\n ssh.exec!(\"rm #{e full_filename}\")\n dir = File.dirname(full_filename)\n ssh.exec!(\"find #{e dir} -maxdepth 0 -empty -exec rm -r {} \\\\;\")\n dir = File.dirname(dir)\n ssh.exec!(\"find #{e dir} -maxdepth 0 -empty -exec rm -r {} \\\\;\")\n end\n end",
"def cleanup_cached_images()\n\n # swap_dir = \"../public/swap\" # use when running locally from /lib/b2_bucket.rb\n swap_dir = \"./public/swap\" # use when running via app.rb\n swap_contents = \"#{swap_dir}/*\"\n gitkeep = \"#{swap_dir}/.gitkeep\"\n\n if File.directory?(swap_dir)\n FileUtils.rm_rf(Dir.glob(swap_contents)) # delete contents of /public/swap \n file = File.new(gitkeep, 'w') # recreate .gitkeep file\n file.close if file\n else\n puts \"Directory does not exist!\"\n end\n\nend",
"def cleanup\n @agent_file_history.each { |af| FileUtils.rm_f(af) }\n @key_file_history.each { |kf| FileUtils.rm_f(kf) }\n end",
"def clear\n @uploaders.each do |uploader| \n full_preview_path = \"#{Rails.root}/public/uploads/tmp/#{uploader.preview.cache_name}\"\n cache_dir = File.expand_path('..', full_preview_path)\n uploader.remove!\n Dir.delete(cache_dir)\n end\n\n @uploaders.clear\n @downloaded_images.clear\n end",
"def delete_files\n self.bruse_files.each do |file|\n file.destroy\n end\n end",
"def clean_test_case\n if File.exists?(@local_file_download_destination)\n File.delete(@local_file_download_destination)\n end\n end",
"def delete\n File::unlink @path+\".lock\" rescue nil\n File::unlink @path+\".new\" rescue nil\n File::unlink @path rescue Errno::ENOENT\n end",
"def delete_from_disk\n thread_local_store.destroy\n end",
"def delete\n cache_delete\n super\n end",
"def delete\n cache_delete\n super\n end",
"def destroy(paths)\n\t\tlogin_filter\n\t\tpaths = [paths].flatten\n\t\tpaths = paths.collect { |path| namespace_path(path) }\n\t\[email protected](\"/cmd/delete\", {\"files\"=> paths, \"t\" => @token }).code == \"200\"\n\tend",
"def delete_expired_tempfiles\n return if !self.config.clean_up? || !self.config.enabled?\n log \"CloudTempfile.delete_expired_tempfiles is running...\"\n # Delete expired temp files\n fog_files = (self.config.local?)? local_root.files : get_remote_files\n fog_files.each do |file|\n if file.last_modified <= Time.now.utc.ago(self.config.clean_up_older_than)\n delete_file(file)\n end\n end\n log \"CloudTempfile.delete_expired_tempfiles is complete!\"\n end",
"def cleanup_cached_images()\n\n # swap_dir = \"../public/swap\" # use when running locally from /lib/s3_bucket.rb\n swap_dir = \"./public/swap\" # use when running via app.rb\n swap_contents = \"#{swap_dir}/*\"\n gitkeep = \"#{swap_dir}/.gitkeep\"\n\n if File.directory?(swap_dir)\n FileUtils.rm_rf(Dir.glob(swap_contents)) # delete contents of /public/swap \n file = File.new(gitkeep, 'w') # recreate .gitkeep file\n file.close if file\n else\n puts \"sightings directory does not exist!\"\n end\n\nend",
"def clear_shared_folders\n end",
"def delete\n File::unlink @path+\".lock\" rescue nil\n File::unlink @path+\".new\" rescue nil\n File::unlink @path rescue nil\n end",
"def clean!\n stop\n FileUtils.remove_entry(download_path) if File.exists? download_path\n FileUtils.remove_entry(tmp_save_dir, true) if File.exists? tmp_save_dir\n FileUtils.remove_entry(instance_dir, true) if File.exists? instance_dir\n FileUtils.remove_entry(md5sum_path) if File.exists? md5sum_path\n FileUtils.remove_entry(version_file) if File.exists? version_file\n end",
"def clean!\n stop\n FileUtils.remove_entry(download_path) if File.exists? download_path\n FileUtils.remove_entry(tmp_save_dir, true) if File.exists? tmp_save_dir\n FileUtils.remove_entry(instance_dir, true) if File.exists? instance_dir\n FileUtils.remove_entry(md5sum_path) if File.exists? md5sum_path\n FileUtils.remove_entry(version_file) if File.exists? version_file\n end",
"def doDeleteOperations(destinationContent, dryRun)\n #N Without this loop, we won't delete all sub-directories or files and directories within sub-directories which have been marked for deletion\n for dir in destinationContent.dirs\n #N Without this check, we would delete directories which have not been marked for deletion (which would be incorrect)\n if dir.toBeDeleted\n #N Without this, we won't know the full path of the remote directory to be deleted\n dirPath = destinationLocation.getFullPath(dir.relativePath)\n #N Without this, the remote directory marked for deletion won't get deleted\n destinationLocation.contentHost.deleteDirectory(dirPath, dryRun)\n else\n #N Without this, files and sub-directories within this sub-directory which are marked for deletion (even though the sub-directory as a whole hasn't been marked for deletion) won't get deleted.\n doDeleteOperations(dir, dryRun)\n end\n end\n #N Without this loop, we won't delete files within this directory which have been marked for deletion.\n for file in destinationContent.files\n #N Without this check, we would delete this file even though it's not marked for deletion (and therefore should not be deleted)\n if file.toBeDeleted\n #N Without this, we won't know the full path of the file to be deleted\n filePath = destinationLocation.getFullPath(file.relativePath)\n #N Without this, the file won't actually get deleted\n destinationLocation.contentHost.deleteFile(filePath, dryRun)\n end\n end\n end",
"def delete_cache_and_img\n # -- out with the old -- #\n\n finger = self.fingerprint_changed? ? self.fingerprint_was : self.fingerprint\n imgfinger = self.image_fingerprint_changed? ? self.image_fingerprint_was : self.image_fingerprint\n\n if finger && imgfinger\n # -- delete our old cache -- #\n Rails.cache.delete(\"img:\"+[self.asset.id,imgfinger,self.output.code].join(\":\"))\n\n # -- delete our AssetOutput -- #\n path = self.asset.image.path(self)\n\n if path\n # this path could have our current values in it. make sure we've\n # got old fingerprints\n path = path.gsub(self.asset.image_fingerprint,imgfinger).gsub(self.fingerprint,finger)\n\n self.asset.image.delete_path(path)\n end\n end\n\n true\n end",
"def update_remotely_deleted(file, node)\n #\n if node != ancestor.file_node(file) && !overwrite?\n if UI.ask(\"local changed #{file} which remote deleted\\n\" +\n \"use (c)hanged version or (d)elete?\") == \"d\"\n then remove file\n else add file\n end\n else\n remove file\n end\n end",
"def delete_files(files)\n not_found = []\n files.each do |file|\n file_stored = Files.where({ '_id' => file[:uuid]}).first\n if file_stored.nil?\n logger.error 'File not found ' + file.to_s\n not_found << file\n else\n if file_stored['pkg_ref'] == 1\n # Referenced only once. Delete in this case\n file_stored.destroy\n del_ent_dict(file_stored, :files)\n file_md5 = Files.where('md5' => file_stored['md5'])\n if file_md5.size.to_i.zero?\n # Remove files from grid\n grid_fs = Mongoid::GridFs\n grid_fs.delete(file_stored['grid_fs_id'])\n end\n else\n # Referenced above once. Decrease counter\n file_stored.update_attributes(pkg_ref: file_stored['pkg_ref'] - 1)\n end\n # file_stored.destroy\n # del_ent_dict(file_stored, :files)\n #\n # # Remove files from grid\n # grid_fs = Mongoid::GridFs\n # grid_fs.delete(file_stored['grid_fs_id'])\n end\n end\n not_found\n end",
"def __remove_cluster_data\n FileUtils.rm_rf arguments[:path_data]\n end",
"def destroy(_)\n paths = [\n instance.provisioner[:root_path], instance.verifier[:root_path]\n ]\n paths.each do |p|\n FileUtils.rm_rf(p)\n logger.info(\"[Localhost] Deleted temp dir '#{p}'.\")\n end\n self.class.unlock!\n end",
"def destroy\n FileUtils.rm_r(@target_path) if File.exist?(@target_path)\n\n @author_site_storage.destroy\n respond_to do |format|\n format.html { redirect_to author_site_storages_url, notice: t('success_delete') }\n format.json { head :no_content }\n end\n end",
"def cleanup!\n FileUtils.rm_rf(obsolete_files)\n FileUtils.rm_rf(metadata_file) unless @site.incremental?\n end",
"def clear_cache\n FileUtils.rm File.expand_path(\"cms-css/#{self.slug}.css\", Rails.public_path), :force => true\n FileUtils.rm File.expand_path(\"cms-js/#{self.slug}.js\", Rails.public_path), :force => true\n end",
"def delete(*args)\n args.each do |arg|\n @cache.delete(\"#{@cache_name}:#{arg}\")\n end\n end",
"def cleanup\n\n # ----------------------------------------------\n account_name = 'your account name' # <-- change this!\n project_name = 'your project name' # <-- change this!\n # ----------------------------------------------\n\n project_dir = \"/home/#{account_name}/www\"\n Dir.chdir(project_dir)\n\n Dir.entries(project_name).select do |entry1|\n\n dir1 = File.join(project_name,entry1) #dir2 = \"#{project_name}/#{entry1}\"\n if is_directory?(dir1)\n Dir.entries(dir1).select do |entry2|\n \n dir2 = File.join(dir1,entry2) #dir2 = \"#{project_name}/#{entry1}/#{entry2}\"\n if is_directory?(dir2)\n Dir.entries(dir2).select do |entry3|\n \n dir3 = File.join(dir2,entry3) #dir3 = \"#{project_name}/#{entry1}/#{entry2}/#{entry3}\"\n if is_directory?(dir3)\n Dir.entries(dir3).select do |entry4|\n delete_file(File.join(dir3,entry4))\n end\n end\n\n delete_file(dir3)\n delete_dir(dir3)\n end\n end\n\n delete_file(dir2)\n delete_dir(dir2)\n end\n end\n\n delete_file(dir1)\n delete_dir(dir1)\n end\n\n delete_dir(project_name)\nend",
"def cleanup\n\tsh 'del /F /Q .\\_site\\*'\n\t# sh 'rm -rf ./_site'\nend",
"def cleanup\n return unless @dst\n\n @dst.unlink\n @dst = nil\n end",
"def delete(path)\n with_remote do |http|\n http.delete(path)\n end\n end",
"def destroy\n remove_files(@path + \"*\")\n end",
"def clean_cache!(seconds)\n File.grid.namespace.\n where(filename: /\\d+-\\d+-\\d+(?:-\\d+)?\\/.+/).\n and(:filename.lt => (Time.now.utc - seconds).to_i.to_s).\n delete\n end",
"def unlink_site\n FileUtils.rm_rf(self.absolute_path) if File.exists?(self.absolute_path)\n end",
"def remove_archive_cache\n expire_action(:controller => '/articles', :action => 'index')\n expire_fragment(%r{/articles/page/*})\n expire_fragment(%r{/categories/*})\n articles_folder = ActionController::Base.page_cache_directory + '/articles/'\n FileUtils.rmtree articles_folder if File.exists? articles_folder \n end",
"def clean_cache(staging_path, metadata)\n actual_file_list = Dir.glob(File.join(staging_path, \"**/*\"))\n expected_file_list = []\n CookbookMetadata.new(metadata).files { |_, path, _| expected_file_list << File.join(staging_path, path) }\n\n extra_files = actual_file_list - expected_file_list\n extra_files.each do |path|\n if File.file?(path)\n FileUtils.rm(path)\n end\n end\n end",
"def delete_all_caching_without_touching_additives\n\t\t\tself.delete_category_menu_fragments\n \t\tself.delete_cache\n \t\tself.delete_shared_item_items\n\t\t\tself.delete_category_browser_fragments\nend",
"def invalidate(blob_access, delete_single=false)\n if delete_single\n FileSystemMetaData.new(cache_file_path(blob_access)).delete\n else\n cache_path(blob_access).entries.each {|cache_file|\n unless cache_file.to_s.match(/\\.meta$/) || cache_file.directory?\n base_name = cache_file.to_s\n FileSystemMetaData.new(cache_path(blob_access).join(cache_file)).delete if base_name.match(cache_file_base(blob_access))\n end\n } if Dir.exist?(cache_path(blob_access))\n end\n end",
"def destroy\n @remote_image_content = RemoteImageContent.find(params[:id])\n @remote_image_content.destroy\n\n respond_to do |format|\n format.html { redirect_to(remote_image_contents_url) }\n format.xml { head :ok }\n end\n end",
"def purge(paths)\n\t\tlogin_filter\n\t\tpaths = [paths].flatten\n\t\tpaths = paths.collect { |path| namespace_path(path) }\n\t\[email protected](\"/cmd/purge\", {\"files\"=> paths, \"t\" => @token }).code == \"200\"\n\tend",
"def destroy\n delete!(get, phase: :destroyed) if get && !cache.uploaded?(get)\n end",
"def erase_cache_symlinks #:nodoc:\n Dir.chdir(self.cache_full_path) do\n Dir.glob('*').each do |entry|\n # FIXME how to only erase symlinks that points to a CBRAIN cache or local DP?\n # Parsing the value of the symlink is tricky...\n File.unlink(entry) if File.symlink?(entry)\n end\n end\n end",
"def prune_cache!\n Dir.chdir @cache_path do\n branches = Dir.glob('*/')\n return if branches.nil? or branches.length <= @cache_num\n\n branches \\\n .sort_by {|f| File.mtime(f)}[@cache_num..-1] \\\n .each do|dir|\n FileUtils.rm_rf(dir)\n @cached_branches.delete(dir.gsub('/', ''))\n end\n end\n end",
"def clear!\n \n # Removes old files in the test directory\n ['to', 'from'].each do |folder|\n Dir.glob(File.expand_path(File.dirname(__FILE__) + \"/data/#{folder}/*\")).each do |file|\n FileUtils.rm(file)\n end\n end\n \n {'some_zip_files.zip' => 'zip_real', 'test_package.rar' => 'rar_real'}.each_pair do |first, last|\n\n # Removes old files in the test directory\n Dir.glob(File.expand_path(File.dirname(__FILE__) + \"/data/#{last}/*\")).each do |file|\n FileUtils.rm(file) if Mimer.identify(file).text?\n end\n\n src = File.expand_path(File.dirname(__FILE__) + \"/data/o_files/#{first}\")\n dest = File.expand_path(File.dirname(__FILE__) + \"/data/#{last}/#{first}\")\n FileUtils.copy_file(src, dest)\n end\n\n # Removes old files in the test directory\n Dir.glob(File.expand_path(File.dirname(__FILE__) + \"/data/movie_to/*\")).each do |file|\n FileUtils.rm(file) if Mimer.identify(file).text?\n end\n \n {'test_package.rar' => 'to', 'some_zip_files.zip' => 'to'}.each do |first,last|\n src = File.expand_path(File.dirname(__FILE__) + \"/data/o_files/#{first}\")\n dest = File.expand_path(File.dirname(__FILE__) + \"/data/from/#{first}\")\n FileUtils.copy_file(src, dest)\n end\nend",
"def remove_deleted_files\n cache_file_hash = {}\n @cookbooks_by_name.each_key do |k|\n cache_file_hash[k] = {}\n end\n\n # First populate files from cache\n cache.find(File.join(%w{cookbooks ** {*,.*}})).each do |cache_file|\n md = cache_file.match(%r{^cookbooks/([^/]+)/([^/]+)/(.*)})\n next unless md\n\n (cookbook_name, segment, file) = md[1..3]\n if have_cookbook?(cookbook_name)\n cache_file_hash[cookbook_name][segment] ||= {}\n cache_file_hash[cookbook_name][segment][\"#{segment}/#{file}\"] = cache_file\n end\n end\n # Determine which files don't match manifest\n @cookbooks_by_name.each_key do |cookbook_name|\n cache_file_hash[cookbook_name].each_key do |segment|\n manifest_segment = cookbook_segment(cookbook_name, segment)\n manifest_record_paths = manifest_segment.map { |manifest_record| manifest_record[\"path\"] }.to_set\n to_be_removed = cache_file_hash[cookbook_name][segment].keys.to_set - manifest_record_paths\n to_be_removed.each do |path|\n cache_file = cache_file_hash[cookbook_name][segment][path]\n\n Chef::Log.info(\"Removing #{cache_file} from the cache; its is no longer in the cookbook manifest.\")\n cache.delete(cache_file)\n @events.removed_cookbook_file(cache_file)\n end\n end\n end\n end",
"def rest__delete_remote\n remote_module_name = ret_non_null_request_params(:remote_module_name)\n remote_namespace = ret_request_params(:remote_module_namespace)\n force_delete = ret_request_param_boolean(:force_delete)\n\n remote_params = remote_params_dtkn(:node_module, remote_namespace, remote_module_name)\n client_rsa_pub_key = ret_request_params(:rsa_pub_key)\n project = get_default_project()\n\n NodeModule.delete_remote(project, remote_params, client_rsa_pub_key, force_delete)\n rest_ok_response\n end",
"def doSync(options = {})\n #N Without this, the content files will be cleared regardless of whether :full options is specified\n if options[:full]\n #N Without this, the content files won't be cleared when the :full options is specified\n clearCachedContentFiles()\n end\n #N Without this, the required content information won't be retrieved (be it from cached content files or from the actual locations)\n getContentTrees()\n #N Without this, the required copy and delete operations won't be marked for execution\n markSyncOperations()\n #N Without this, we won't know if only a dry run is intended\n dryRun = options[:dryRun]\n #N Without this check, the destination cached content file will be cleared, even for a dry run\n if not dryRun\n #N Without this check, the destination cached content file will remain there, even though it is stale once an actual (non-dry-run) sync operation is started.\n @destinationLocation.clearCachedContentFile()\n end\n #N Without this, the marked copy operations will not be executed (or in the case of dry-run, they won't be echoed to the user)\n doAllCopyOperations(dryRun)\n #N Without this, the marked delete operations will not be executed (or in the case of dry-run, they won't be echoed to the user)\n doAllDeleteOperations(dryRun)\n #N Without this check, the destination cached content file will be updated from the source content file, even if it was only a dry-run (so the remote location hasn't actually changed)\n if (not dryRun and @destinationLocation.cachedContentFile and @sourceLocation.cachedContentFile and\n File.exists?(@sourceLocation.cachedContentFile))\n #N Without this, the remote cached content file won't be updated from local cached content file (which is a reasonable thing to do assuming the sync operation completed successfully)\n FileUtils::Verbose.cp(@sourceLocation.cachedContentFile, @destinationLocation.cachedContentFile)\n end\n #N Without this, any cached SSH connections will remain unclosed (until the calling application has terminated, which may or may not happen soon after completing the sync).\n closeConnections()\n end",
"def destroy\n @file_version.destroy\n head :no_content\n end",
"def purge\n purge_file\n cdb_destroy\n end",
"def sync_to_cache_for_archiving\n result = sync_to_cache(false)\n self.erase_cache_symlinks rescue nil\n result\n end",
"def deleteT(dir1, dir2)\n\t\tFileUtils.rm_rf Dir.glob(\"#{dir1}*\")\n\t\tFileUtils.rm_rf Dir.glob(\"#{dir2}*\")\n\tend",
"def shared_files\n if current_user.shared_files\n @assets = list_shared_assets\n \n assets = current_user.assets.all\n\n assets.each do |asset|\n if asset.tempfile == true\n asset.destroy\n end\n end\n end\n end",
"def destroy\n File.delete(temp_path)\n end",
"def removed_unmarked_paths\n #remove dirs\n dirs_enum = @dirs.each_value\n loop do\n dir_stat = dirs_enum.next rescue break\n if dir_stat.marked\n dir_stat.marked = false # unset flag for next monitoring\\index\\remove phase\n #recursive call\n dir_stat.removed_unmarked_paths\n else\n # directory is not marked. Remove it, since it does not exist.\n write_to_log(\"NON_EXISTING dir: \" + dir_stat.path)\n # remove file with changed checksum\n $local_content_data_lock.synchronize{\n $local_content_data.remove_directory(dir_stat.path, Params['local_server_name'])\n }\n rm_dir(dir_stat)\n end\n end\n\n #remove files\n files_enum = @files.each_value\n loop do\n file_stat = files_enum.next rescue break\n if file_stat.marked\n file_stat.marked = false # unset flag for next monitoring\\index\\remove phase\n else\n # file not marked meaning it is no longer exist. Remove.\n write_to_log(\"NON_EXISTING file: \" + file_stat.path)\n # remove file with changed checksum\n $local_content_data_lock.synchronize{\n $local_content_data.remove_instance(Params['local_server_name'], file_stat.path)\n }\n # remove from tree\n @files.delete(file_stat.path)\n end\n end\n end",
"def destroy\n FileUtils.rm_rf(target)\n end",
"def after_destroy\n super\n\n # Try our best to remove the directory. If it fails there is little\n # else that we could do to resolve the situation -- we already tried to\n # delete it once...\n self.tmpdir and FileUtils.remove_entry_secure(self.tmpdir, true)\n\n # Remove repo directory.\n if self.iso_url\n # Some files in archives are write-only. Change this property so the\n # delete succeeds.\n remove_directory(iso_location)\n end\n end",
"def delete_files\n\t\t\tFileUtils.rm_rf(@clean_image)\n\t\t\tFileUtils.rm_rf(@image) if pdf?\n\t\tend",
"def cleanup_script_execution\n FileUtils.rm_rf(InstanceConfiguration::CACHE_PATH)\n end",
"def clean!\n stop\n remove_instance_dir!\n FileUtils.remove_entry(config.download_path) if File.exists?(config.download_path)\n FileUtils.remove_entry(config.tmp_save_dir, true) if File.exists? config.tmp_save_dir\n md5.clean!\n FileUtils.remove_entry(config.version_file) if File.exists? config.version_file\n end",
"def destroy\n all.each { |file| FileUtils.rm_f(file) }\n end",
"def destroy\n File.unlink(@resource[:path])\n Puppet.debug \"deleted file #{@resource[:path]}\"\n end",
"def destroy\n @related_content = RelatedContent.find(params[:id])\n @related_content.destroy\n dirname = \"#{RelatedContent::UPLOAD_DIR}/#{@related_content.id}\"\n FileUtils.rm_rf dirname\t\n redirect_to @related_content.node\t \n\nend",
"def invalidate_all!\n FileUtils.rm_r(@cache_path, force: true, secure: true)\n end",
"def delete_downloads\n FileUtils.remove_entry_secure(dir) if Dir.exist?(dir)\n end",
"def sync_down\n existing = list_files\n new_objects = []\n self.objects.each do |obj|\n filename = filename_from_key(obj.key)\n existing.delete( filename )\n file = directory + filename\n if !File.exists?(file)\n puts \"Downloading file #{file} with key #{obj.key})\"\n new_objects << s3_client.get_object({ bucket: bucket, key: obj.key }, target: directory + filename_from_key(obj.key) )\n end\n end\n\n existing.each do |file|\n puts \"Deleting file #{file}\"\n File.delete( directory + file )\n end\n\n # Return true if the directory changed\n (new_objects.count > 0) || (existing.count > 0)\n end"
] | [
"0.68381095",
"0.68269175",
"0.68269175",
"0.6720919",
"0.64047134",
"0.6160758",
"0.6075725",
"0.6033957",
"0.6015497",
"0.5943525",
"0.5941422",
"0.59313303",
"0.5930817",
"0.5922106",
"0.5873191",
"0.5863049",
"0.58577955",
"0.58343303",
"0.5814217",
"0.57643545",
"0.5763",
"0.5763",
"0.57551986",
"0.5711761",
"0.5698243",
"0.56912595",
"0.56720936",
"0.56720394",
"0.5670927",
"0.5662635",
"0.56479293",
"0.5639485",
"0.56308377",
"0.5630537",
"0.5624679",
"0.5605414",
"0.5591936",
"0.5591167",
"0.5582477",
"0.55660665",
"0.5555284",
"0.5547603",
"0.55465186",
"0.55383325",
"0.55383325",
"0.5533246",
"0.55262166",
"0.55100113",
"0.55084336",
"0.55074483",
"0.5500051",
"0.5500051",
"0.5488779",
"0.54867893",
"0.54751533",
"0.5468107",
"0.5465492",
"0.5464708",
"0.54595494",
"0.545754",
"0.54559964",
"0.5454219",
"0.54537386",
"0.5453684",
"0.5453672",
"0.5452679",
"0.54510754",
"0.54443365",
"0.5441888",
"0.5439385",
"0.54349",
"0.5430535",
"0.5428429",
"0.5426306",
"0.54248405",
"0.5422348",
"0.5420622",
"0.54197586",
"0.5415962",
"0.54125637",
"0.5405678",
"0.54034907",
"0.5396242",
"0.53960085",
"0.53868425",
"0.5380615",
"0.53778243",
"0.5376812",
"0.53745633",
"0.5374204",
"0.5373973",
"0.5368732",
"0.53664416",
"0.5365943",
"0.53643745",
"0.5335656",
"0.53335637",
"0.53335327",
"0.53248537",
"0.5321758"
] | 0.8078011 | 0 |
Do the sync. Options: :full = true means clear the cached content files first, :dryRun means don't do the actual copies and deletes, but just show what they would be. N Without this, there won't be a single method that can be called to do the sync operations (optionally doing a dry run) | def doSync(options = {})
#N Without this, the content files will be cleared regardless of whether :full options is specified
if options[:full]
#N Without this, the content files won't be cleared when the :full options is specified
clearCachedContentFiles()
end
#N Without this, the required content information won't be retrieved (be it from cached content files or from the actual locations)
getContentTrees()
#N Without this, the required copy and delete operations won't be marked for execution
markSyncOperations()
#N Without this, we won't know if only a dry run is intended
dryRun = options[:dryRun]
#N Without this check, the destination cached content file will be cleared, even for a dry run
if not dryRun
#N Without this check, the destination cached content file will remain there, even though it is stale once an actual (non-dry-run) sync operation is started.
@destinationLocation.clearCachedContentFile()
end
#N Without this, the marked copy operations will not be executed (or in the case of dry-run, they won't be echoed to the user)
doAllCopyOperations(dryRun)
#N Without this, the marked delete operations will not be executed (or in the case of dry-run, they won't be echoed to the user)
doAllDeleteOperations(dryRun)
#N Without this check, the destination cached content file will be updated from the source content file, even if it was only a dry-run (so the remote location hasn't actually changed)
if (not dryRun and @destinationLocation.cachedContentFile and @sourceLocation.cachedContentFile and
File.exists?(@sourceLocation.cachedContentFile))
#N Without this, the remote cached content file won't be updated from local cached content file (which is a reasonable thing to do assuming the sync operation completed successfully)
FileUtils::Verbose.cp(@sourceLocation.cachedContentFile, @destinationLocation.cachedContentFile)
end
#N Without this, any cached SSH connections will remain unclosed (until the calling application has terminated, which may or may not happen soon after completing the sync).
closeConnections()
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sync\n run 'sync', :quiet => true\n end",
"def sync\n local_directories.each do |local_directory|\n if settings[:dry_run]\n log.info(sync_command(local_directory))\n else\n IO.popen(sync_command(local_directory)).each { |line| handle_output(line) }\n end\n end\n end",
"def fsync() end",
"def fsync() end",
"def fsync() end",
"def sync!\n begin \n FileUtils.touch lock_file_name\n\n rsync_type = seq_complete? ? 'final' : 'partial'\n logger.info \"Starting #{rsync_type} rsync...\"\n\n source_dir = Shellwords.escape(\"#{run_dir}/\")\n dest_dir = Shellwords.escape(File.join(Conf.global_conf[:safe_location_dir], run_name))\n\n Rsync.run(source_dir, dest_dir, '-raP') do |result|\n\n if result.success?\n result.changes.each do |change|\n logger.info \"#{change.filename} (#{change.summary})\"\n end\n logger.info \"#{result.changes.count} change(s) sync'd.\"\n logger.info \"End of #{rsync_type} rsync.\"\n else\n raise Errors::RsyncProcessError.new(\n \"'rsync' exited with nonzero status (#{rsync_type} rsync), motivation: #{result.error}\")\n end\n end\n\n rescue => e\n logger.error \"#{e.class} encountered while performing the sync'ing step\"\n logger.error e.message\n logger.error \"trace:\\n#{e.backtrace.join(\"\\n\")}\"\n Mailer.notify_admins(self, 'sync', e)\n ensure\n FileUtils.rm lock_file_name if File.exists?(lock_file_name)\n end\n end",
"def fsync\n end",
"def fsync\n end",
"def fsync()\n #This is a stub, used for indexing\n end",
"def sync_cmd\n warn(\"Legacy call to #sync_cmd cannot be preserved, meaning that \" \\\n \"test files will not be uploaded. \" \\\n \"Code that calls #sync_cmd can now use the transport#upload \" \\\n \"method to transfer files.\")\n end",
"def sync(srcDir, dstDir)\n end",
"def perform_sync(source, destination, options)\n new_files, new_files_destination = get_new_files_to_sync(source, destination, options)\n sync_new_files(source, new_files, new_files_destination, options)\n cleanup_files_we_dont_want_to_keep(source, new_files, new_files_destination) unless options[:keep].nil?\n end",
"def sync() end",
"def sync() end",
"def sync() end",
"def sync\n end",
"def sync\n end",
"def sync\n TaskwarriorWeb::Command.new(:sync, nil, nil).run\n end",
"def sync()\n #This is a stub, used for indexing\n end",
"def perform!\n exclude_filter = ''\n @excludes.each { |e| exclude_filter << \" --exclude '#{e}' \" }\n \n @tasks.each do |task|\n prepared_source = prepare_path(task[:source], @source_base_path)\n prepared_target = prepare_path(task[:target], @target_base_path)\n Logger.message \"Perform One-Way-Mirror:\"\n Logger.message \" - Source: #{prepared_source}\"\n Logger.message \" - Target: #{prepared_target}\"\n\n create_dir_if_missing(prepared_target)\n \n `rsync --archive -u -v --delete #{exclude_filter} \"#{prepared_source}\" \"#{prepared_target}\"`\n end\n end",
"def sync; end",
"def sync\n if not cloned?\n clone\n else\n update\n end\n end",
"def sync\n @data_file.fsync\n end",
"def sync\n unlock if locked?\n lock\n PATH()\n end",
"def dry_run\n @dry_run = true\n end",
"def sync_to_cache(deep=true) #:nodoc:\n syncstat = self.local_sync_status(:refresh)\n return true if syncstat && syncstat.status == 'InSync'\n super()\n if deep && ! self.archived?\n self.sync_civet_outputs\n self.update_cache_symlinks\n end\n @cbfl = @civet_outs = nil # flush internal cache\n true\n end",
"def sync\n # TODO stop forcing a sync every time.\n @cache.sync\n\n if cloned?\n fetch\n else\n clone\n end\n reset\n end",
"def sync\n cached_dataset(:_sync) do\n clone(:async=>false)\n end\n end",
"def execute_sync\n @env.primary_vm.run_action(Vagrant::Mirror::Middleware::Sync)\n end",
"def sync\n contents_sync(resource.parameter(:source) || self)\n end",
"def sync\n each_difference(local_resources, true) { |name, diffs| sync_difference(name, diffs) }\n end",
"def sync\n compile_sprockets_assets\n clean_sprockets_assets\n\n if serve_assets == \"remote\" \n storage.upload_files\n storage.clean_remote\n end\n\n end",
"def action_sync\n assert_target_directory_valid!\n if ::File.exist?(::File.join(@new_resource.destination, 'CVS'))\n Chef::Log.debug \"#{@new_resource} update\"\n converge_by(\"sync #{@new_resource.destination} from #{@new_resource.repository}\") do\n run_command(run_options(:command => sync_command))\n Chef::Log.info \"#{@new_resource} updated\"\n end\n else\n action_checkout\n end\n end",
"def sync(src_object, dest_object=nil) # LOCAL_DIR s3://BUCKET[/PREFIX] or s3://BUCKET[/PREFIX] LOCAL_DIR\n send_command \"sync\", src_object, dest_object\n end",
"def run!(options)\n display \"Initialising Ssync, performing pre-sync checks ...\"\n\n e! \"Couldn't connect to AWS with the credentials specified in '#{config_path}'.\" unless Setup.aws_credentials_is_valid?\n e! \"Couldn't find the S3 bucket specified in '#{config_path}'.\" unless Setup.bucket_exists?\n e! \"The local path specified in '#{config_path}' does not exist.\" unless Setup.local_file_path_exists?\n\n if options.force?\n display \"Clearing previous sync state ...\"\n clear_sync_state\n end\n create_tmp_sync_state\n\n if last_sync_recorded?\n display \"Performing time based comparison ...\"\n files_modified_since_last_sync\n else\n display \"Performing (potentially expensive) MD5 checksum comparison ...\"\n display \"Generating local manifest ...\"\n generate_local_manifest\n display \"Traversing S3 for remote manifest ...\"\n fetch_remote_manifest\n # note that we do not remove files on s3 that no longer exist on local host.\n # this behaviour may be desirable (ala rsync --delete) but we currently don't support it.\n display \"Performing checksum comparison ...\"\n files_on_localhost_with_checksums - files_on_s3\n end.each do |file|\n encrypt_file(file) if encrypting?\n push_file(file)\n end\n\n finalize_sync_state\n\n display \"Sync complete!\"\n clean_up_encrypted(true) if encrypting?\n \n end",
"def pre_sync\n #move\n end",
"def sync_dir dir\n # TODO: think of a better name scheme\n # maybe the title should include the relative path?\n calculated_photoset_name = \"[ruphy-backup] #{dir}\"\n Dir.chdir @root + '/' + dir\n\n if photoset_exist? calculated_photoset_name\n #sync\n flickr_list = get_file_list calculated_photoset_name\n local_list = Dir[\"*\"]\n remotely_missing = []\n locally_missing = []\n \n local_list.each do |f|\n remotely_missing << f unless flickr_list.include? f\n end\n# puts \"remotely missing files: \" + remotely_missing.join(',')\n \n remotely_missing.each do |f|\n upload f, calculated_photoset_name\n end\n \n \n flickr_list.each do |f|\n locally_missing << f unless local_list.include? f\n end\n puts \"we're locally missing: \" + locally_missing.join(', ')\n \n # TODO: really perform sync\n \n else\n # set not existing: just upload\n Dir[\"*\"].each do |f|\n upload f, calculated_photoset_name\n end\n end\n end",
"def sync_code_dir\n fs_commands = { 'commit': '{\"commit-all\": true}', 'force-sync': \"\" }\n fs_commands.each do |fs_cmd, data|\n curl = %W[\n curl\n -X POST\n --cert $(puppet config print hostcert)\n --key $(puppet config print hostprivkey)\n --cacert $(puppet config print localcacert)\n -H \"Content-type: application/json\"\n https://#{master}:8140/file-sync/v1/#{fs_cmd}\n -d '#{data}'\n ].join(\" \")\n\n on(master, curl)\n end\n end",
"def markSyncOperations\n #N Without this, the sync operations won't be marked\n @sourceContent.markSyncOperationsForDestination(@destinationContent)\n #N Without these puts statements, the user won't receive feedback about what sync operations (i.e. copies and deletes) are marked for execution\n puts \" ================================================ \"\n puts \"After marking for sync --\"\n puts \"\"\n puts \"Local:\"\n #N Without this, the user won't see what local files and directories are marked for copying (i.e. upload)\n @sourceContent.showIndented()\n puts \"\"\n puts \"Remote:\"\n #N Without this, the user won't see what remote files and directories are marked for deleting\n @destinationContent.showIndented()\n end",
"def sync_files\n User.sync_files!(@context)\n end",
"def sync\n # preparation\n check_remote_path_valid\n check_git_repo\n reset_remote_repo\n\n diff_text = local_diff\n apply_diff_to_remote diff_text\n\n # output = @ssh.exec! 'hostname'\n # puts output\n end",
"def iosync\n @tc_storage.sync\n @tc_log.sync\n @tc_heads.sync\n nil\n end",
"def sync=\n end",
"def flush\n osync = @sync\n @sync = true\n do_write \"\"\n return self\n ensure\n @sync = osync\n end",
"def run_syncdb\n manage_py_execute('syncdb', '--noinput') if new_resource.syncdb\n end",
"def sync_data\n\t\tSYNC_TABLES.each do |sync|\n\t\t\tself.sync_table(sync)\n\t\tend\n\tend",
"def sync!\n\n destfiles = begin \n FsShellProxy.new.ls(@dest, true) \n rescue NoSuchFile \n {}\n end\n results = HSync::compare(LocalFs.new.ls(@source, true), destfiles)\n push_files(results.files_missing_in_b)\n # push_files(results.files_newer_in_a) # todo\n end",
"def sync\n #debug 'content sync'\n # We're safe not testing for the 'source' if there's no 'should'\n # because we wouldn't have gotten this far if there weren't at least\n # one valid value somewhere.\n @resource.write(:content)\n end",
"def rsync( srcs, target, opts )\n @commands << rsync_args( host, srcs, target, opts )\n ( rand(2) == 1 ) ? [ [ 'something', 'somefile' ] ] : []\n end",
"def sync\n @lock.synchronize do\n if @cache.in_transaction?\n @cache.abort_transaction\n @cache.flush\n PEROBS.log.fatal \"You cannot call sync() during a transaction: \\n\" +\n Kernel.caller.join(\"\\n\")\n end\n @cache.flush\n end\n end",
"def sync_to_cache_for_archiving\n result = sync_to_cache(false)\n self.erase_cache_symlinks rescue nil\n result\n end",
"def sync\n @mutex.synchronize do\n config_provider.sync\n sync_input_files\n cleanup_output_files\n end\n end",
"def sync(options = {})\n @log.clear\n @platform.analyze\n # These paths are needed because Drupal allows libraries to be installed\n # inside modules. Hence, we must ignore them when synchronizing those modules.\n @makefile.each_library do |l|\n @libraries_paths << @platform.local_path + @platform.contrib_path + l.target_path\n end\n # We always need a local copy of Drupal core (either the version specified\n # in the makefile or the latest version), even if we are not going to\n # synchronize the core, in order to extract the list of core projects.\n if get_drupal\n if options[:nocore]\n blah \"Skipping core\"\n else\n sync_drupal_core\n end\n else\n return\n end\n sync_projects(options)\n sync_libraries unless options[:nolibs]\n # Process derivative builds\n @derivative_builds.each do |updater|\n updater.sync(options.merge(:nocore => true))\n @log.merge(updater.log)\n end\n return\n end",
"def sync\n # source directory already exists? if not then create\n cat_dir = Settings.catalog_dir\n if !File.directory?(cat_dir)\n raise BakerError, \"error in catalog.rb\"\n # File.makedirs(cat_dir)\n end\n local_path = DownloadManager.regional_download(self.catalog_urls, self.local_region, cat_dir, true)\n if !local_path\n raise BakerError, \"Catalog synchronization failed when downloading.\"\n end\n success = DownloadManager.extract(local_path)\n if !success\n puts BakerError, \"Catalog synchronization failed when extracting.\"\n end\n end",
"def sync\n self.disabled_reason = nil\n if valid?\n execute_sync\n true\n else\n false\n end\n end",
"def sync_command local_directory\n config_file = settings[:s3cmd_config] ? \"--config=#{Shellwords.escape(settings[:s3cmd_config])}\" : \"\"\n \"#{s3cmd_program} sync #{Shellwords.escape(local_directory)} #{Shellwords.escape(s3_uri)} --no-delete-removed --bucket-location=#{settings[:region]} #{config_file} 2>&1\"\n end",
"def doAllCopyOperations(dryRun)\n #N Without this, the copy operations won't be executed\n doCopyOperations(@sourceContent, @destinationContent, dryRun)\n end",
"def sync\n logger.info \"Syncing EVERYTHING\"\n # Update info in background\n Thread.new do\n if Qbo.exists?\n Customer.sync\n Invoice.sync\n QboItem.sync\n Employee.sync\n Estimate.sync\n \n # Record the last sync time\n Qbo.update_time_stamp\n end\n ActiveRecord::Base.connection.close\n end\n\n redirect_to :home, :flash => { :notice => \"Successfully synced to Quickbooks\" }\n end",
"def sync\n current = @resource.stat ? @resource.stat.mode : 0644\n set(desired_mode_from_current(@should[0], current).to_s(8))\n end",
"def sync\n current = @resource.stat ? @resource.stat.mode : 0644\n set(desired_mode_from_current(@should[0], current).to_s(8))\n end",
"def run_autosync\n begin\n self.status = _(\"Synchronizing organisations.\")\n self.update_organisation_cache\n \n self.status = _(\"Synchronizing worktime.\")\n self.update_worktime_cache\n \n self.status = _(\"Automatic synchronization done.\")\n rescue => e\n self.status = sprintf(_(\"Error while auto-syncing: %s\"), e.message)\n puts Knj::Errors.error_str(e)\n ensure\n @sync_thread = nil\n end\n end",
"def run\n @attached.each { |item| process(item) }\n\n (@mode == :replace ? [ @add_file ] : [ @add_file, @remove_file ]).each do |file|\n file.puts(FOOTER)\n file.flush\n file.rewind\n end\n\n if @mode == :replace\n @database.resource.put(@add_file)\n elsif @mode == :update\n @database.resource[:update_method => :subtract].post(@remove_file)\n @database.resource[:update_method => :add].post(@add_file)\n end\n\n unless ENV['DIRECTEDEDGE_DEBUG']\n @add_file.unlink if @add_file\n @remove_file.unlink if @remove_file\n end\n end",
"def finalize_sync_operation\n puts \" - Transferred the following #{ @st_ops_cache_file.keys.count } st_ops versions to foreign repos:\"\n @st_ops_cache_file.keys.each { |from_git_commit, to_git_commit|\n puts \" - #{ from_git_commit } to #{ to_git_commit }\"\n }\n if @successful_files_with_st_ops.any?\n puts \" - The following #{ @successful_files_with_st_ops.count } files with st operations were synced successfully:\".color(:green)\n @successful_files_with_st_ops.each { |file_path| puts \" - #{ file_path }\" }\n else\n puts \" - No files with st operations were synced successfully\".color(:red)\n end\n if @successful_files_with_autosplit.any?\n puts \" - The following #{ @successful_files_with_autosplit.count } files with autosplit were synced successfully:\".color(:green)\n @successful_files_with_autosplit.each { |file_path| puts \" - #{ file_path }\" }\n else\n puts \" - No files with autosplit were synced successfully\".color(:red)\n end\n if @successful_files_without_st_ops.any?\n puts \" - The following #{ @successful_files_without_st_ops.count } files without st operations were synced successfully:\".color(:green)\n @successful_files_without_st_ops.each { |file_path| puts \" - #{ file_path }\" }\n else\n puts \" - No files without st operations were synced successfully\".color(:red)\n end\n if @unprocessable_files.any?\n puts \" - The following #{ @unprocessable_files.count } files could not be synced:\".color(:red)\n @unprocessable_files.each { |f_attrs|\n print \" - #{ f_attrs[:file].repo_relative_path(true) }: \".ljust(52).color(:red)\n puts \"#{ f_attrs[:message] }\".color(:red)\n }\n else\n puts \" - All file syncs were successful!\".color(:green)\n end\n if @files_with_autosplit_exceptions.any?\n puts \" - The following #{ @files_with_autosplit_exceptions.count } files raised an exception during autosplit:\".color(:red)\n @files_with_autosplit_exceptions.each { |f_attrs|\n print \" - #{ f_attrs[:file].repo_relative_path(true) }: \".ljust(52).color(:red)\n puts \"#{ f_attrs[:message] }\".color(:red)\n }\n else\n puts \" - No files raised exceptions during autosplit\".color(:green)\n end\n if @files_with_subtitle_count_mismatch.any?\n puts \" - The following #{ @files_with_subtitle_count_mismatch.count } files were synced, however their subtitle counts don't match:\".color(:red)\n @files_with_subtitle_count_mismatch.each { |f_attrs|\n print \" - #{ f_attrs[:file].repo_relative_path(true) }: \".ljust(52).color(:red)\n puts \"#{ f_attrs[:message] }\".color(:red)\n }\n else\n puts \" - All synced files have matching subtitle counts.\".color(:green)\n end\n true\n end",
"def sync_local\n sync_hash = {\n ['~/Library/Application\\\\ Support/Firefox', '~/Library/Application\\\\ Support/Quicksilver',\n '~/Library/Preferences' ] =>'library/',\n ['~/.boson', '~/.sake', '~/.cronrc', '~/.gemrc', '~/.gitconfig', '~/.gem/specs']=>'dotfiles/',\n }\n sync_hash.each do |src, dest|\n src.each do |e| \n cmd = \"rsync -av #{e} #{File.join('~/backup', dest)}\"\n system cmd\n end\n end\n end",
"def copy_contents\n cmd = rsync_cmd\n\n @log.debug \"Copying contents with: #{cmd}\"\n\n %x[#{cmd}]\n $?.success?\n end",
"def postSync(options = {})\n deleteLocalDataDir(options)\n end",
"def rsync_with dir\n rsync_options = \"-avP --exclude '*svn*' --exclude '*swp' --exclude '*rbc'\" +\n \" --exclude '*.rej' --exclude '*.orig' --exclude 'lib/rubygems/defaults/*'\"\n sh \"rsync #{rsync_options} bin/gem #{dir}/bin/gem\"\n sh \"rsync #{rsync_options} lib/ #{dir}/lib\"\n sh \"rsync #{rsync_options} test/ #{dir}/test/rubygems\"\n sh \"rsync #{rsync_options} util/gem_prelude.rb #{dir}/gem_prelude.rb\"\nend",
"def run\n create_lockfile!\n syncer.run\n ensure\n delete_lockfile!\n end",
"def mirror(incremental = false)\n # First, make sure the source file classes exist in the destination mogile\n mirror_class_entries\n\n begin\n # Clear out data from previous runs unless we are doing a full mirror\n ActiveRecord::Base.connection.execute(\"TRUNCATE TABLE #{MirrorFile.table_name}\") unless incremental\n\n # Scan all files greater than max_fid in the source mogile database and copy over any\n # which are missing from the dest mogile database.\n mirror_missing_destination_files unless SignalHandler.instance.should_quit\n\n # This is only run when incremental is not set because it requires the mirror_files db to express\n # exactly the same state as the remote mogile db. Otherwise this would effectively do nothing.\n remove_superfluous_destination_files unless SignalHandler.instance.should_quit\n\n ensure\n # Print the overall summary\n final_summary\n end\n end",
"def sync_rspec_only\n copy_skel_files\n end",
"def fdatasync\n fsync\n end",
"def sync_special_fat32_files\n Dir[File.join(@path_source, '**/*\\./')].sort.each do |source_dir|\n # Syncing files from source and dest\n dest_dir = get_dest_filepath(source_dir)\n\n puts \"Manually syncing files to #{File.basename(dest_dir)}\"\n rsync_dirs(source_dir, dest_dir, true)\n end\n end",
"def rput( *args )\n opts = @default_options\n opts = opts.merge( args.pop ) if args.last.is_a?( Hash )\n opts = opts.merge( coalesce: false )\n\n flush\n\n srcs, target = expand_implied_target( args )\n\n srcs = resolve_sources( srcs, Array( opts[ :sync_paths ] ) )\n\n changes = []\n\n if opts[:erb_process] != false\n sdirs, sfiles = srcs.partition { |src| File.directory?( src ) }\n serbs, sfiles = sfiles.partition { |src| src =~ /\\.erb$/ }\n plains = sdirs + sfiles #might not have/is not templates\n maybes = sdirs + serbs #might have/is templates\n\n if maybes.empty?\n changes = rsync( plains, target, opts ) unless plains.empty?\n else\n if ssh_host_name == 'localhost' && opts[ :user ]\n # tmpdir needs to be visable to alt. opts[ :user ]\n opts[ :tmpdir_mode ] = 0755\n end\n process_templates( maybes, opts ) do |processed|\n unless processed.empty? || plains.empty?\n opts = opts.dup\n opts[ :excludes ] = Array( opts[ :excludes ] ) + [ '*.erb' ]\n end\n new_srcs = plains + processed\n changes = rsync( new_srcs, target, opts ) unless new_srcs.empty?\n end\n end\n else\n changes = rsync( srcs, target, opts ) unless srcs.empty?\n end\n\n changes\n end",
"def perform\n return if @exit\n\n args, opts = @arguments, @options\n [:to, :from, :to_safe, :exclude, :schemas].each do |opt|\n opts[opt] ||= config[opt.to_s]\n end\n map_deprecations(args, opts)\n\n if opts[:init]\n setup(db_config_file(args[0]) || config_file || \".pgsync.yml\")\n else\n sync(args, opts)\n end\n\n true\n end",
"def sync\n announcing 'Syncing Portage Tree' do\n chroot 'sync'\n end\n send_to_state('build', 'sync')\n end",
"def sync\n pull && push\n end",
"def sync(only: nil, except: nil, parallel: nil, output: $stdout)\n subscribed_task_stats(output) do\n indexes_from(only: only, except: except).each_with_object([]) do |index, synced_indexes|\n output.puts \"Synchronizing #{index}\"\n output.puts \" #{index} doesn't support outdated synchronization\" unless index.supports_outdated_sync?\n time = Time.now\n sync_result = index.sync(parallel: parallel)\n if !sync_result\n output.puts \" Something went wrong with the #{index} synchronization\"\n elsif (sync_result[:count]).positive?\n output.puts \" Missing documents: #{sync_result[:missing]}\" if sync_result[:missing].present?\n output.puts \" Outdated documents: #{sync_result[:outdated]}\" if sync_result[:outdated].present?\n synced_indexes.push(index)\n else\n output.puts \" Skipping #{index}, up to date\"\n end\n output.puts \" Took #{human_duration(Time.now - time)}\"\n end\n end\n end",
"def sync(&block)\n queue SyncCommand, [], {}, &block\n end",
"def sync\n # catalog directory already exists?\n cat_dir = Settings.catalog_dir\n if !File.directory?(cat_dir)\n raise IOError, \"Catalog directory does not exist: #{cat_dir}\"\n # File.makedirs(cat_dir)\n end\n local_path = DownloadManager.regional_download(catalog_urls, local_region, cat_dir, Settings.opt_force)\n if ! local_path\n raise IOError, \"Catalog synchronization failed when downloading.\"\n end\n success = DownloadManager.extract(local_path)\n if !success\n puts IOError, \"Catalog synchronization failed when extracting '#{local_path}'.\"\n end\n end",
"def old_sync; end",
"def sync\n @cache.flush(true)\n @nodes.sync\n end",
"def sync_complete()\n LOGGER.debug(\"#{self.name} sync completed\")\n @synced = true\n end",
"def fetch\n log.info(log_key) { \"Copying from `#{source_path}'\" }\n\n create_required_directories\n FileSyncer.sync(source_path, project_dir, source_options)\n # Reset target shasum on every fetch\n @target_shasum = nil\n target_shasum\n end",
"def run\n\t\tself.rsync_to_temp\n\t\tself.convert_to_mp3\n\t\tself.rsync_to_usb\n\t\tself.delete_temp_dir\n\tend",
"def remote_sync_if_necessary(options={})\n false\n end",
"def sync_zup_dir\n if zup_dir_enabled?\n local_dir = File.basename(Dir.pwd) \n\n # Output the full unison command if debugging enabled\n puts($SYNC_COMMAND + ' . ' + @conf['protocol'] + '://' \\\n + @conf['server'] + '/' + @conf['remote_dir'] + '/' \\\n + local_dir) if $ZUP_DEBUG\n\n # Run unison\n system($SYNC_COMMAND + ' . ' + @conf['protocol'] + '://' \\\n + @conf['server'] + '/' + @conf['remote_dir'] + '/' \\\n + local_dir)\n else\n puts \" * Current directory not initialised (Run 'zup init' to add it)\"\n exit 0\n end\n end",
"def sync!(jobs, timeout = -1)\n DRMAA.synchronize(jobs, timeout, true)\n end",
"def sync!(jobs, timeout = -1)\n DRMAA.synchronize(jobs, timeout, true)\n end",
"def rsync(wait = false)\n @config ||= LockStep::Config\n @config.destinations.each do |destination|\n # See if we're to use an SSH key\n # and make sure it exists\n ssh_key = false\n if destination.identity_file and destination.hostname\n identity_file = File.expand_path(destination.identity_file)\n ssh_key = identity_file if File.exists?(identity_file)\n end\n\n # Build the rsync command\n command = \"rsync -avz \"\n command << \"-e 'ssh -i #{ssh_key}' \" if ssh_key\n command << \"--delete \" if destination.cleanup\n command << \"#{@config.source_path}/ \"\n command << \"#{destination.user}@\" if destination.user and destination.hostname\n command << \"#{destination.hostname}:\" if destination.hostname\n command << \"#{destination.path}/\"\n\n # A little latency\n sleep 1 if wait\n\n # Re-direct stdout to the log file if we're meant to\n LockStep::Logger.redirect_stdout\n # Run the command\n system command\n end\n rescue Exception => e\n LockStep::Logger.write \"Caught #{e}\"\n end",
"def sync( options = {} )\n options = { :local => \".\", :remote => \".\" , :passive => false}.merge( options )\n local, remote , passive = options[:local], options[:remote], options[:passive]\n \n tmpname = tmpfilename\n connect do |ftp|\n ftp.passive = passive\n # Read remote .syncftp\n begin\n ftp.gettextfile( remote+\"/\"+\".syncftp\", tmpname )\n @remote_md5s = YAML.load( File.open( tmpname ).read )\n rescue Net::FTPPermError => e\n raise Net::FTPPermError, e.message, caller if ftp.remote_file_exist?( remote+\"/\"+\".syncftp\" )\n end\n \n # Do the job Bob !\n send_dir( ftp, local, remote )\n \n # Write new .syncftp\n File.open( tmpname, 'w' ) do |out|\n YAML.dump( @local_md5s, out )\n end\n \n # Delete files\n @delete_dirs = []\n @delete_files = []\n @remote_md5s.keys.clone.delete_if{ |f| @local_md5s.keys.include?(f) }.each do |f|\n if @remote_md5s[f] == \"*\"\n @delete_dirs << f\n else\n @delete_files << f\n end\n end\n @delete_files.each do |f|\n @log.info \"Delete ftp://#{@host}:#{@port}/#{f}\"\n begin\n ftp.delete( f )\n rescue => e\n @log.info \"ftp://#{@host}:#{@port}/#{f} does not exist\"\n end\n end \n @delete_dirs.each do |f|\n @log.info \"Delete ftp://#{@host}:#{@port}/#{f}\"\n begin\n ftp.delete( f )\n rescue => e\n @log.info \"ftp://#{@host}:#{@port}/#{f} does not exist\"\n end\n end \n \n ftp.puttextfile( tmpname, remote+\"/\"+\".syncftp\" )\n end\n File.delete( tmpname )\n end",
"def sync_file(file)\n cache_filename = File.join(\"cookbooks\", file.cookbook.name, file.manifest_record[\"path\"])\n mark_cached_file_valid(cache_filename)\n\n # If the checksums are different between on-disk (current) and on-server\n # (remote, per manifest), do the update. This will also execute if there\n # is no current checksum.\n if !cached_copy_up_to_date?(cache_filename, file.manifest_record[\"checksum\"])\n download_file(file.manifest_record[\"url\"], cache_filename)\n @events.updated_cookbook_file(file.cookbook.name, cache_filename)\n else\n Chef::Log.trace(\"Not storing #{cache_filename}, as the cache is up to date.\")\n end\n\n # Load the file in the cache and return the full file path to the loaded file\n cache.load(cache_filename, false)\n end",
"def perform\n tmp_mongo_dir = \"mongodump-#{Time.now.strftime(\"%Y%m%d%H%M%S\")}\"\n tmp_dump_dir = File.join(tmp_path, tmp_mongo_dir)\n\n case self.backup_method.to_sym\n when :mongodump\n #this is the default options \n # PROS:\n # * non-locking\n # * much smaller archive sizes\n # * can specifically target different databases or collections to dump\n # * de-fragements the datastore\n # * don't need to run under sudo\n # * simple logic\n # CONS:\n # * a bit longer to restore as you have to do an import\n # * does not include indexes or other meta data\n log system_messages[:mongo_dump]\n exit 1 unless run \"#{mongodump} #{mongodump_options} #{collections_to_include} -o #{tmp_dump_dir} #{additional_options} > /dev/null 2>&1\"\n when :disk_copy\n #this is a bit more complicated AND potentially a lot riskier: \n # PROS:\n # * byte level copy, so it includes all the indexes, meta data, etc\n # * fast recovery; you just copy the files into place and startup mongo\n # CONS:\n # * locks the database, so ONLY use against a slave instance\n # * copies everything; cannot specify a collection or a database\n # * will probably need to run under sudo as the mongodb db_path file is probably under a different owner. \n # If you do run under sudo, you will probably need to run rake RAILS_ENV=... if you aren't already\n # * the logic is a bit brittle... \n log system_messages[:mongo_copy]\n\n cmd = \"#{mongo} #{mongo_disk_copy_options} --quiet --eval 'printjson(db.isMaster());' admin\"\n output = JSON.parse(run(cmd, :exit_on_failure => true))\n if output['ismaster']\n puts \"You cannot run in disk_copy mode against a master instance. This mode will lock the database. Please use :mongodump instead.\"\n exit 1\n end\n \n begin\n cmd = \"#{mongo} #{mongo_disk_copy_options} --quiet --eval 'db.runCommand({fsync : 1, lock : 1}); printjson(db.runCommand({getCmdLineOpts:1}));' admin\"\n output = JSON.parse(run(cmd, :exit_on_failure => true))\n\n #lets go find the dbpath. it is either going to be in the argv just returned OR we are going to have to parse through the mongo config file\n cmd = \"mongo --quiet --eval 'printjson(db.runCommand({getCmdLineOpts:1}));' admin\"\n output = JSON.parse(run(cmd, :exit_on_failure => true))\n #see if --dbpath was passed in\n db_path = output['argv'][output['argv'].index('--dbpath') + 1] if output['argv'].index('--dbpath') \n #see if --config is passed in, and if so, lets parse it\n db_path ||= $1 if output['argv'].index('--config') && File.read(output['argv'][output['argv'].index('--config') + 1]) =~ /dbpath\\s*=\\s*([^\\s]*)/ \n db_path ||= \"/data/db/\" #mongo's default path\n run \"cp -rp #{db_path} #{tmp_dump_dir}\" \n ensure\n #attempting to unlock\n cmd = \"#{mongo} #{mongo_disk_copy_options} --quiet --eval 'printjson(db.currentOp());' admin\"\n output = JSON.parse(run(cmd, :exit_on_failure => true))\n (output['fsyncLock'] || 1).to_i.times do\n run \"#{mongo} #{mongo_disk_copy_options} --quiet --eval 'db.$cmd.sys.unlock.findOne();' admin\"\n end\n end\n else\n puts \"you did not enter a valid backup_method option. Your choices are: #{BACKUP_METHOD_OPTIONS.join(', ')}\"\n exit 1\n end \n \n log system_messages[:compressing]\n run \"tar -cz -C #{tmp_path} -f #{File.join(tmp_path, compressed_file)} #{tmp_mongo_dir}\"\n end",
"def sync\n # Update info in background\n Thread.new do\n if Qbo.exists?\n Customer.sync\n QboItem.sync\n QboEmployee.sync\n QboEstimate.sync\n QboInvoice.sync\n \n # Record the last sync time\n Qbo.update_time_stamp\n end\n ActiveRecord::Base.connection.close\n end\n\n redirect_to qbo_path(:redmine_qbo), :flash => { :notice => \"Successfully synced to Quickbooks\" }\n end",
"def exec_sync\n raise \"You must override `exec_sync' in your class\"\n end",
"def sync_cookbooks\n Chef::Log.info(\"Loading cookbooks [#{cookbooks.map { |ckbk| ckbk.name + \"@\" + ckbk.version }.join(\", \")}]\")\n Chef::Log.trace(\"Cookbooks detail: #{cookbooks.inspect}\")\n\n clear_obsoleted_cookbooks\n\n queue = Chef::Util::ThreadedJobQueue.new\n\n Chef::Log.warn(\"skipping cookbook synchronization! DO NOT LEAVE THIS ENABLED IN PRODUCTION!!!\") if Chef::Config[:skip_cookbook_sync]\n files.each do |file|\n queue << lambda do |lock|\n full_file_path = sync_file(file)\n\n lock.synchronize do\n # Save the full_path of the downloaded file to be restored in the manifest later\n save_full_file_path(file, full_file_path)\n mark_file_synced(file)\n end\n end\n end\n\n @events.cookbook_sync_start(cookbook_count)\n queue.process(Chef::Config[:cookbook_sync_threads])\n # Ensure that cookbooks know where they're rooted at, for manifest purposes.\n ensure_cookbook_paths\n # Update the full file paths in the manifest\n update_cookbook_filenames\n\n rescue Exception => e\n @events.cookbook_sync_failed(cookbooks, e)\n raise\n else\n @events.cookbook_sync_complete\n true\n end",
"def rsync_to_temp\n\t\tputs \"\\n=> copying to temp dir.\\n\"\n\t\tself.rsync_str(@@opt_rsync, @@dir_src, @@dir_temp)\n\tend",
"def sync\n object.save\n end",
"def get_rsync(options)\n 'rsync ./ ' + options[:full_path]\n end",
"def sync_cmd\n \"rsync --delete -avzhe '#{@ssh_path} -p #{@port}' #{cygdrive_path @log_dir} #{user_at_host}:#{@remote_log_parent_dir}\"\n end",
"def flush\n return unless resource.should(:ensure) == :present\n unless @share_edit_args.empty?\n sharing([\"-e\", existing_share_name] + @share_edit_args)\n end\n end"
] | [
"0.7001521",
"0.6518536",
"0.6421248",
"0.64205265",
"0.64205265",
"0.63177806",
"0.6235949",
"0.6235949",
"0.6191756",
"0.61621034",
"0.6099505",
"0.60952705",
"0.6016058",
"0.6016058",
"0.6016058",
"0.5947251",
"0.5947251",
"0.5939929",
"0.5930152",
"0.5921011",
"0.58695143",
"0.5860297",
"0.5821986",
"0.58129376",
"0.5812412",
"0.57892627",
"0.5789048",
"0.577247",
"0.5767206",
"0.5727537",
"0.5690021",
"0.56683064",
"0.56369144",
"0.5635039",
"0.56349075",
"0.56287867",
"0.55854326",
"0.5582962",
"0.55711585",
"0.5526667",
"0.5520539",
"0.5499981",
"0.54845643",
"0.5471274",
"0.5459605",
"0.5454049",
"0.54368305",
"0.5421288",
"0.5420788",
"0.5398185",
"0.5379095",
"0.53677195",
"0.53632295",
"0.5357707",
"0.53510904",
"0.534689",
"0.53395176",
"0.53271586",
"0.5326768",
"0.52912563",
"0.5282167",
"0.52743006",
"0.52705914",
"0.5269005",
"0.5262757",
"0.5256487",
"0.52409506",
"0.5237967",
"0.5217462",
"0.52039915",
"0.5203074",
"0.5178456",
"0.5172886",
"0.5164573",
"0.51537114",
"0.5141755",
"0.5138481",
"0.5132447",
"0.5126383",
"0.510693",
"0.51056355",
"0.51024127",
"0.510128",
"0.50819284",
"0.50816375",
"0.5076555",
"0.5071054",
"0.5068353",
"0.50655097",
"0.5063996",
"0.50540274",
"0.50498855",
"0.5045675",
"0.5043592",
"0.5038206",
"0.50351447",
"0.503107",
"0.50306845",
"0.50267947",
"0.5025776"
] | 0.7811997 | 0 |
Do all the copy operations, copying local directories or files which are missing from the remote location N Without this, there won't be an easy way to execute (or echo if dryrun) all the marked copy operations | def doAllCopyOperations(dryRun)
#N Without this, the copy operations won't be executed
doCopyOperations(@sourceContent, @destinationContent, dryRun)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def doCopyOperations(sourceContent, destinationContent, dryRun)\n #N Without this loop, we won't copy the directories that are marked for copying\n for dir in sourceContent.dirs\n #N Without this check, we would attempt to copy those directories _not_ marked for copying (but which might still have sub-directories marked for copying)\n if dir.copyDestination != nil\n #N Without this, we won't know what is the full path of the local source directory to be copied\n sourcePath = sourceLocation.getFullPath(dir.relativePath)\n #N Without this, we won't know the full path of the remote destination directory that this source directory is to be copied into\n destinationPath = destinationLocation.getFullPath(dir.copyDestination.relativePath)\n #N Without this, the source directory won't actually get copied\n destinationLocation.contentHost.copyLocalToRemoteDirectory(sourcePath, destinationPath, dryRun)\n else\n #N Without this, we wouldn't copy sub-directories marked for copying of this sub-directory (which is not marked for copying in full)\n doCopyOperations(dir, destinationContent.getDir(dir.name), dryRun)\n end\n end\n #N Without this loop, we won't copy the files that are marked for copying\n for file in sourceContent.files\n #N Without this check, we would attempt to copy those files _not_ marked for copying\n if file.copyDestination != nil\n #N Without this, we won't know what is the full path of the local file to be copied\n sourcePath = sourceLocation.getFullPath(file.relativePath)\n #N Without this, we won't know the full path of the remote destination directory that this source directory is to be copied into\n destinationPath = destinationLocation.getFullPath(file.copyDestination.relativePath)\n #N Without this, the file won't actually get copied\n destinationLocation.contentHost.copyLocalFileToRemoteDirectory(sourcePath, destinationPath, dryRun)\n end\n end\n end",
"def execute\n\n copiedCounter = 0\n failedCounter = 0\n skippedCounter = 0\n \n # traverse all srcfiles\n FiRe::filesys.find(@source) { |srcItem|\n \n # give some feedback\n FiRe::log.info \"searching #{srcItem}...\" if FiRe::filesys.directory?(srcItem)\n \n # skip this subtree if it matches ignored-items\n FiRe::filesys.prune if ignore?(srcItem) \n \n # transform srcpath to destpath\n destItem = srcItem.gsub(@source, @destination)\n\n # do not copy if item already exists and looks OK\n if needCopy(destItem,srcItem)\n copyWentWell = copyItem(srcItem, destItem)\n copiedCounter += 1 if copyWentWell\n failedCounter += 1 if !copyWentWell\n else\n skippedCounter += 1 \n end\n \n }\n \n # give some feedback\n FiRe::log.info \"copied #{copiedCounter} items, while #{failedCounter} items failed. #{skippedCounter} items did not need to be copied today.\"\n\n end",
"def copy_files\n file_candidates.each do |remote_file|\n local_file = File.basename(remote_file)\n if File.exist?(local_file)\n if same_file?(local_file, remote_file)\n info \"\\n>> '#{local_file}' has the same contents here as in the repo. Leaving it alone.\"\n else\n if config['answer_yes']\n warn \"\\n>> '#{local_file}' is different than its counterpart in the repo.\"\n info \"Copying #{remote_file} to #{local_file}... (answer_yes is true)\"\n copy_file(remote_file, local_file)\n else\n warn \"\\n>> '#{local_file}' is different than its counterpart in the repo (see below)\"\n git_diff(local_file, remote_file)\n prompt \"\\nDo you want to overwrite #{local_file} with the version from the repo? [y/N]: \"\n\n answer = $stdin.gets.chomp\n case answer\n when ''\n error 'Moving on.' # Default behavior.\n when /y/i\n info \"Copying #{remote_file} to #{local_file}...\"\n copy_file(remote_file, local_file)\n when /n/i\n error 'Moving on.'\n else\n error 'Unknown selection. Moving on.'\n end\n end\n\n end\n else\n info \"\\n>> '#{local_file}' does not exist locally.\"\n info \"Copying #{remote_file} to #{local_file}...\"\n copy_file(remote_file, local_file)\n end\n end\n end",
"def safe_cp(from, to, owner, group, cwd = '', include_paths = [], exclude_paths = [])\n credentials = ''\n credentials += \"-o #{owner} \" if owner\n credentials += \"-g #{group} \" if group\n excludes = find_command_excludes(from, cwd, exclude_paths).join(' ')\n\n copy_files = proc do |from_, cwd_, path_ = ''|\n cwd_ = File.expand_path(File.join('/', cwd_))\n \"if [[ -d #{File.join(from_, cwd_, path_)} ]]; then \" \\\n \"#{dimg.project.find_path} #{File.join(from_, cwd_, path_)} #{excludes} -type f -exec \" \\\n \"#{dimg.project.bash_path} -ec '#{dimg.project.install_path} -D #{credentials} {} \" \\\n \"#{File.join(to, '$(echo {} | ' \\\n \"#{dimg.project.sed_path} -e \\\"s/#{File.join(from_, cwd_).gsub('/', '\\\\/')}//g\\\")\")}' \\\\; ;\" \\\n 'fi'\n end\n\n commands = []\n commands << [dimg.project.install_path, credentials, '-d', to].join(' ')\n commands.concat(include_paths.empty? ? Array(copy_files.call(from, cwd)) : include_paths.map { |path| copy_files.call(from, cwd, path) })\n commands << \"#{dimg.project.find_path} #{to} -type d -exec \" \\\n \"#{dimg.project.bash_path} -ec '#{dimg.project.install_path} -d #{credentials} {}' \\\\;\"\n commands.join(' && ')\n end",
"def batch_copy_missing_destination_files(files)\n dest_domain = DestDomain.find_by_namespace(@dest_mogile.domain)\n\n files.each do |file|\n # Quit if no results\n break if file.nil?\n\n # Quit if program exit has been requested.\n break if SignalHandler.instance.should_quit\n\n # Look up the source file's key in the destination domain\n destfile = DestFile.find_by_dkey_and_dmid(file.dkey, dest_domain.dmid)\n if destfile\n # File exists!\n # Check that the source and dest file sizes match\n if file.length != destfile.length\n # File exists but has been modified. Copy it over.\n begin\n Log.instance.debug(\"Key [ #{file.dkey} ] is out of date. Updating.\")\n stream_copy(file)\n @updated += 1\n @copied_bytes += file.length\n rescue => e\n @failed += 1\n Log.instance.error(\"Error updating [ #{file.dkey} ]: #{e.message}\\n#{e.backtrace}\")\n end\n else\n Log.instance.debug(\"key [ #{file.dkey} ] is up to date.\")\n @uptodate += 1\n end\n else\n # File does not exist. Copy it over.\n begin\n Log.instance.debug(\"key [ #{file.dkey} ] does not exist... creating.\")\n stream_copy(file)\n @added += 1\n @copied_bytes += file.length\n rescue => e\n @failed += 1\n Log.instance.error(\"Error adding [ #{file.dkey} ]: #{e.message}\\n#{e.backtrace}\")\n end\n end\n end\n end",
"def mirror_missing_destination_files\n # Find the id of the domain we are mirroring\n source_domain = SourceDomain.find_by_namespace(@source_mogile.domain)\n\n # Get the max fid from the mirror db\n # This will only be nonzero if we are doing an incremental\n max_fid = MirrorFile.max_fid\n\n # Process source files in batches.\n Log.instance.info(\"Searching for files in domain [ #{source_domain.namespace} ] whose fid is larger than [ #{max_fid} ].\")\n SourceFile.where('dmid = ? AND fid > ?', source_domain.dmid, max_fid).includes(:domain, :fileclass).find_in_batches(batch_size: 1000) do |batch|\n # Create an array of MirrorFiles which represents files we have mirrored.\n remotefiles = batch.collect { |file| MirrorFile.new(fid: file.fid, dkey: file.dkey, length: file.length, classname: file.classname) }\n\n # Insert the mirror files in a batch format.\n Log.instance.debug('Bulk inserting mirror files.')\n MirrorFile.import remotefiles\n\n # Figure out which files need copied over\n # (either because they are missing or because they have been updated)\n batch_copy_missing_destination_files(remotefiles)\n\n # Show our progress so people know we are working\n summarize\n\n # Quit if program exit has been requested.\n return true if SignalHandler.instance.should_quit\n end\n end",
"def markCopyOperations(destinationDir)\n #N Without this we can't loop over the immediate sub-directories to determine how each one needs to be marked for copying\n for dir in dirs\n #N Without this we won't have the corresponding sub-directory in the other directory with the same name as this sub-directory (if it exists)\n destinationSubDir = destinationDir.getDir(dir.name)\n #N Without this check, we won't be able to correctly process a sub-directory based on whether or not one with the same name exists in the other directory\n if destinationSubDir != nil\n #N Without this, files and directories missing or changed from the other sub-directory (which does exist) won't get copied\n dir.markCopyOperations(destinationSubDir)\n else\n #N Without this, the corresponding missing sub-directory in the other directory won't get updated from this sub-directory\n dir.markToCopy(destinationDir)\n end\n end\n #N Without this we can't loop over the files to determine how each one needs to be marked for copying\n for file in files\n #N Without this we won't have the corresponding file in the other directory with the same name as this file (if it exists)\n destinationFile = destinationDir.getFile(file.name)\n #N Without this check, this file will get copied, even if it doesn't need to be (it only needs to be if it is missing, or the hash is different)\n if destinationFile == nil or destinationFile.hash != file.hash\n #N Without this, a file that is missing or changed won't get copied (even though it needs to be)\n file.markToCopy(destinationDir)\n end\n end\n end",
"def perform!\n exclude_filter = ''\n @excludes.each { |e| exclude_filter << \" --exclude '#{e}' \" }\n \n @tasks.each do |task|\n prepared_source = prepare_path(task[:source], @source_base_path)\n prepared_target = prepare_path(task[:target], @target_base_path)\n Logger.message \"Perform One-Way-Mirror:\"\n Logger.message \" - Source: #{prepared_source}\"\n Logger.message \" - Target: #{prepared_target}\"\n\n create_dir_if_missing(prepared_target)\n \n `rsync --archive -u -v --delete #{exclude_filter} \"#{prepared_source}\" \"#{prepared_target}\"`\n end\n end",
"def doSync(options = {})\n #N Without this, the content files will be cleared regardless of whether :full options is specified\n if options[:full]\n #N Without this, the content files won't be cleared when the :full options is specified\n clearCachedContentFiles()\n end\n #N Without this, the required content information won't be retrieved (be it from cached content files or from the actual locations)\n getContentTrees()\n #N Without this, the required copy and delete operations won't be marked for execution\n markSyncOperations()\n #N Without this, we won't know if only a dry run is intended\n dryRun = options[:dryRun]\n #N Without this check, the destination cached content file will be cleared, even for a dry run\n if not dryRun\n #N Without this check, the destination cached content file will remain there, even though it is stale once an actual (non-dry-run) sync operation is started.\n @destinationLocation.clearCachedContentFile()\n end\n #N Without this, the marked copy operations will not be executed (or in the case of dry-run, they won't be echoed to the user)\n doAllCopyOperations(dryRun)\n #N Without this, the marked delete operations will not be executed (or in the case of dry-run, they won't be echoed to the user)\n doAllDeleteOperations(dryRun)\n #N Without this check, the destination cached content file will be updated from the source content file, even if it was only a dry-run (so the remote location hasn't actually changed)\n if (not dryRun and @destinationLocation.cachedContentFile and @sourceLocation.cachedContentFile and\n File.exists?(@sourceLocation.cachedContentFile))\n #N Without this, the remote cached content file won't be updated from local cached content file (which is a reasonable thing to do assuming the sync operation completed successfully)\n FileUtils::Verbose.cp(@sourceLocation.cachedContentFile, @destinationLocation.cachedContentFile)\n end\n #N Without this, any cached SSH connections will remain unclosed (until the calling application has terminated, which may or may not happen soon after completing the sync).\n closeConnections()\n end",
"def copy(files=[])\n files = ignore_stitch_sources files\n if files.size > 0\n begin\n message = 'copied file'\n message += 's' if files.size > 1\n UI.info \"#{@msg_prefix} #{message.green}\" unless @config[:silent]\n puts '| ' #spacing\n files.each do |file|\n if !check_jekyll_exclude(file)\n path = destination_path file\n FileUtils.mkdir_p File.dirname(path)\n FileUtils.cp file, path\n puts '|' + \" → \".green + path\n else\n puts '|' + \" ~ \".yellow + \"'#{file}' detected in Jekyll exclude, not copying\".red unless @config[:silent]\n end\n end\n puts '| ' #spacing\n\n rescue Exception\n UI.error \"#{@msg_prefix} copy has failed\" unless @config[:silent]\n UI.error e\n stop_server\n throw :task_has_failed\n end\n true\n end\n end",
"def copyLocalFileToRemoteDirectory(sourcePath, destinationPath, dryRun)\n #N Without this, the copy command won't be run at all\n sshAndScp.copyLocalFileToRemoteDirectory(sourcePath, destinationPath, dryRun)\n end",
"def copyLocalToRemoteDirectory(sourcePath, destinationPath, dryRun)\n #N Without this there won't be a description of the copy operation that can be displayed to the user as feedback\n description = \"SCP: copy directory #{sourcePath} to #{user}@#{host}:#{destinationPath}\"\n #N Without this the user won't see the echoed description\n puts description\n #N Without this check, the files will be copied even if it is only meant to be a dry run.\n if not dryRun\n #N Without this, the files won't actually be copied.\n scpConnection.upload!(sourcePath, destinationPath, :recursive => true)\n end\n end",
"def copy(command)\n src = clean_up(command[1])\n dest = clean_up(command[2])\n pp @client.files.copy(src, dest)\n end",
"def prepare_copy_folders\n return if config[:copy_folders].nil?\n\n info(\"Preparing to copy specified folders to #{sandbox_module_path}.\")\n kitchen_root_path = config[:kitchen_root]\n config[:copy_folders].each do |folder|\n debug(\"copying #{folder}\")\n folder_to_copy = File.join(kitchen_root_path, folder)\n copy_if_src_exists(folder_to_copy, sandbox_module_path)\n end\n end",
"def fetch\n log.info(log_key) { \"Copying from `#{source_path}'\" }\n\n create_required_directories\n FileSyncer.sync(source_path, project_dir, source_options)\n # Reset target shasum on every fetch\n @target_shasum = nil\n target_shasum\n end",
"def sync!\n\n destfiles = begin \n FsShellProxy.new.ls(@dest, true) \n rescue NoSuchFile \n {}\n end\n results = HSync::compare(LocalFs.new.ls(@source, true), destfiles)\n push_files(results.files_missing_in_b)\n # push_files(results.files_newer_in_a) # todo\n end",
"def copyLocalToRemoteDirectory(sourcePath, destinationPath, dryRun)\n #N Without this, the copy command won't be run at all\n sshAndScp.copyLocalToRemoteDirectory(sourcePath, destinationPath, dryRun)\n end",
"def preform_copy_file\n @destination_files.each do |destination|\n copy_file(@sources.pop, destination)\n end\n end",
"def deploy!\n if copy_cache\n if File.exists?(copy_cache)\n logger.debug \"refreshing local cache to revision #{revision} at #{copy_cache}\"\n system(source.sync(revision, copy_cache))\n else\n logger.debug \"preparing local cache at #{copy_cache}\"\n system(source.checkout(revision, copy_cache))\n end\n\n # Check the return code of last system command and rollback if not 0\n unless $? == 0\n raise Capistrano::Error, \"shell command failed with return code #{$?}\"\n end\n\n FileUtils.mkdir_p(destination)\n\n logger.debug \"copying cache to deployment staging area #{destination}\"\n Dir.chdir(copy_cache) do\n queue = Dir.glob(\"*\", File::FNM_DOTMATCH)\n while queue.any?\n item = queue.shift\n name = File.basename(item)\n\n next if name == \".\" || name == \"..\"\n next if copy_exclude.any? { |pattern| File.fnmatch(pattern, item) }\n\n if File.symlink?(item)\n FileUtils.ln_s(File.readlink(item), File.join(destination, item))\n elsif File.directory?(item)\n queue += Dir.glob(\"#{item}/*\", File::FNM_DOTMATCH)\n FileUtils.mkdir(File.join(destination, item))\n else\n FileUtils.ln(item, File.join(destination, item))\n end\n end\n end\n else\n logger.debug \"getting (via #{copy_strategy}) revision #{revision} to #{destination}\"\n system(command)\n\n if copy_exclude.any?\n logger.debug \"processing exclusions...\"\n if copy_exclude.any?\n copy_exclude.each do |pattern|\n delete_list = Dir.glob(File.join(destination, pattern), File::FNM_DOTMATCH)\n # avoid the /.. trap that deletes the parent directories\n delete_list.delete_if { |dir| dir =~ /\\/\\.\\.$/ }\n FileUtils.rm_rf(delete_list.compact)\n end\n end\n end\n end\n\n # merge stuffs under specific dirs\n if configuration[:merge_dirs]\n configuration[:merge_dirs].each do |dir, dest|\n from = Pathname.new(destination) + dir\n to = Pathname.new(destination) + dest\n logger.trace \"#{from} > #{to}\"\n FileUtils.mkdir_p(to)\n FileUtils.cp_r(Dir.glob(from), to)\n end\n end\n\n # for a rails application in sub directory\n # set :deploy_subdir, \"rails\"\n if configuration[:deploy_subdir]\n subdir = configuration[:deploy_subdir]\n logger.trace \"deploy subdir #{destination}/#{subdir}\"\n Dir.mktmpdir do |dir|\n FileUtils.move(\"#{destination}/#{subdir}\", dir)\n FileUtils.rm_rf destination rescue nil\n FileUtils.move(\"#{dir}/#{subdir}\", \"#{destination}\")\n end\n end\n\n File.open(File.join(destination, \"REVISION\"), \"w\") { |f| f.puts(revision) }\n\n logger.trace \"compressing #{destination} to #{filename}\"\n Dir.chdir(copy_dir) { system(compress(File.basename(destination), File.basename(filename)).join(\" \")) }\n\n distribute!\n ensure\n puts $! if $!\n FileUtils.rm filename rescue nil\n FileUtils.rm_rf destination rescue nil\n FileUtils.rm_rf copy_subdir rescue nil\n end",
"def copyLocalFileToRemoteDirectory(sourcePath, destinationPath, dryRun)\n #N Without this there won't be a description of the copy operation that can be displayed to the user as feedback\n description = \"SCP: copy file #{sourcePath} to #{user}@#{host}:#{destinationPath}\"\n #N Without this the user won't see the echoed description\n puts description\n #N Without this check, the file will be copied even if it is only meant to be a dry run.\n if not dryRun\n #N Without this, the file won't actually be copied.\n scpConnection.upload!(sourcePath, destinationPath)\n end\n end",
"def rsync(*sources)\n # Default options include --inplace because we only care about consistency\n # at the end of the job, and rsync will do more work for big files without\n # it.\n #\n # rsync can spend a long time at the far end checking over its files at\n # the far end without transfer, so we want to wait as long as possible\n # without jeopardising the timing of the next backup run.\n #\n #\n args = %w( rsync --archive --xattrs --numeric-ids --delete-excluded --delete-during --inplace --relative )\n\n #\n # Add on the I/O-timeout\n #\n args += ['--timeout', @io_timeout.to_s ] unless ( @io_timeout.nil? )\n\n\n args += ['--rsh', \"ssh -o BatchMode=yes -x -a -i #{@ssh_key} -l #{@destination_user}\"]\n args << '--verbose' if @verbose\n args += @excludes.map { |x| ['--exclude', x] }.flatten\n\n #\n # Add in the rsync excludes and sources files, if present.\n #\n if File.exist?('/etc/byteback/excludes')\n args += ['--exclude-from', '/etc/byteback/excludes']\n end\n\n #\n # Add in an rsync_filter if required.\n #\n if File.exist?('/etc/byteback/rsync_filter')\n args += ['--filter', 'merge /etc/byteback/rsync_filter']\n end\n\n #\n # To add extra rsync flags, a file can be used. This can have flags all on one line, or one per line.\n #\n if File.exist?('/etc/byteback/rsync_flags')\n args += File.readlines('/etc/byteback/rsync_flags').map(&:chomp)\n end\n\n args += ['--rsync-path', 'rsync --fake-super']\n\n args += sources\n args << @destination\n\n log_system(*args)\nend",
"def copy(src,target)\n mkdir_p target if ! File.exist?(target)\n sh 'cp ' + src + '/* ' + target\nend",
"def cp_r(src, dest, options = {})\r\n fu_check_options options, OPT_TABLE['cp_r']\r\n fu_output_message \"cp -r#{options[:preserve] ? 'p' : ''}#{options[:remove_destination] ? ' --remove-destination' : ''} #{[src,dest].flatten.join ' '}\" if options[:verbose]\r\n return if options[:noop]\r\n options[:dereference_root] = true unless options.key?(:dereference_root)\r\n fu_each_src_dest(src, dest) do |s, d|\r\n copy_entry s, d, options[:preserve], options[:dereference_root], options[:remove_destination]\r\n end\r\n end",
"def cp_r(src, dest, options = {})\r\n fu_check_options options, OPT_TABLE['cp_r']\r\n fu_output_message \"cp -r#{options[:preserve] ? 'p' : ''}#{options[:remove_destination] ? ' --remove-destination' : ''} #{[src,dest].flatten.join ' '}\" if options[:verbose]\r\n return if options[:noop]\r\n options[:dereference_root] = true unless options.key?(:dereference_root)\r\n fu_each_src_dest(src, dest) do |s, d|\r\n copy_entry s, d, options[:preserve], options[:dereference_root], options[:remove_destination]\r\n end\r\n end",
"def copy files, host, dir\n dest = \"#{dir}/#{host}\"\n File.directory?(dest) || mkdir_p(dest)\n #puts \"Connecting to #{host}\"\n begin\n Net::SFTP.start(host, \"root\", :auth_methods => [\"publickey\"], :keys => [$key], :timeout => 1) do |sftp|\n files.each do |file|\n begin\n dir = File.dirname \"#{dest}/#{file}\"\n stats = sftp.stat! file\n if stats\n File.directory?(dir) || mkdir_p(dir)\n if stats.directory?\n sftp.download! file, \"#{dest}/#{file}\", :recursive => true\n chmod stats.permissions, \"#{dest}/#{file}\"\n else\n sftp.download! file, \"#{dest}/#{file}\"\n chmod stats.permissions, \"#{dest}/#{file}\"\n end\n touch \"#{dest}/.completed\" #at least one copied file. Too intensive?\n end\n rescue\n #puts \"Next for #{file}\"\n next #file does not exist\n end\n end\n end\n rescue Net::SFTP::Exception => e\n puts \"#{host} sftp exception: #{e}\"\n return false\n #rescue Net::SCP::Error => e\n # puts \"#{host} scp error: #{e}\"\n # return false\n rescue Timeout::Error => e\n puts \"#{host} timeout: #{e}\"\n return false\n rescue Errno::ECONNREFUSED => e\n puts \"#{host} refused: #{e}\"\n return false\n rescue SocketError => e\n puts \"#{host} resolve: #{e}\"\n return false\n rescue Net::SSH::AuthenticationFailed => e\n puts \"#{host} auth failed: #{e}\"\n return false\n rescue Net::SSH::Disconnect => e\n puts \"#{host} disconnected: #{e}\"\n return false #no access to host\n end\n return true\nend",
"def preform_copy_directory\n @destination_directories.each do |destination|\n @sources.each do |source|\n write_mode = 'w'\n new_path = Pathname.new(destination.to_s).join(source.basename)\n # Check if the specified file is a directory\n if new_path.directory?\n return false if get_input(\"Destination path '\" + new_path.to_s + \"' is a directory. (S)kip the file or (C)ancel: \", ['s','c']) == 'c'\n next\n end\n # Copy the file\n return false unless copy_file(source, new_path)\n end\n end\n return true\n end",
"def copy_files\n source_dir = Item.new(Path.new(params[:source]))\n dest_dir = Item.new(Path.new(params[:dest]))\n type = params[:type]\n response = {}\n response[:source_dir] = source_dir\n response[:dest_dir] = dest_dir\n if source_dir.copy_files_to(dest_dir, type)\n response[:msg] = \"Success\"\n else\n response[:msg] = \"Fail\"\n end\n render json: response\n end",
"def go_single_transfer_in\r\n wait_for_transfer_file_come_up\r\n size = wait_for_the_data_to_all_get_here\r\n @copied_files += copy_files_from_dropbox_to_local_permanent_storage size\r\n create_done_copying_files_to_local_file\r\n wait_till_current_transfer_is_over\r\n\treturn recombinate_files_for_multiple_transfers_possibly\r\n end",
"def perform_file_copy\n\t\tretrieve_target_dir do |target_dir|\n\t\t\tFileUtils.mkdir_p target_dir\n\t\t\tcopy_depdencies_to target_dir\n\t\tend\t\n\tend",
"def copy(src, dst)\n\t\t# TODO: make cp able to handle strings, where it will create an entry based\n\t\t# on the box it's run from.\n\t\t\n\t\tif !(src.kind_of?(Rush::Entry) && dst.kind_of?(Rush::Entry))\n\t\t\traise ArgumentError, \"must operate on Rush::Dir or Rush::File objects\"\n\t\tend\n\t\t\n\t\t# 5 cases:\n\t\t# 1. local-local\n\t\t# 2. local-remote (uploading)\n\t\t# 3. remote-local (downloading)\n\t\t# 4. remote-remote, same server\n\t\t# 5. remote-remote, cross-server\n\t\tif src.box == dst.box # case 1 or 4\n\t\t\tif src.box.remote? # case 4\n\t\t\t\tsrc.box.ssh.exec!(\"cp -r #{src.full_path} #{dst.full_path}\") do |ch, stream, data|\n\t\t\t\t\tif stream == :stderr\n\t\t\t\t\t\traise Rush::DoesNotExist, stream\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\telse # case 1\n\t\t\t\tFileUtils.cp_r(src.full_path, dst.full_path)\n\t\t\tend\n\t\telse # case 2, 3, or 5\n\t\t\tif src.local? && !dst.local? # case 2\n\t\t\t\t# We use the connection on the remote machine to do the upload\n\t\t\t\tdst.box.ssh.scp.upload!(src.full_path, dst.full_path, :recursive => true)\n\t\t\telsif !src.local? && dst.local? # case 3\n\t\t\t\t# We use the connection on the remote machine to do the download\n\t\t\t\tsrc.box.ssh.scp.download!(src.full_path, dst.full_path, :recursive => true)\n\t\t\telse # src and dst not local, case 5\n\t\t\t\tremote_command = \"scp #{src.full_path} #{dst.box.user}@#{dst.box.host}:#{dst.full_path}\"\n\t\t\t\t# doesn't matter whose connection we use\n\t\t\t\tsrc.box.ssh.exec!(remote_command) do |ch, stream, data|\n\t\t\t\t\tif stream == :stderr\n\t\t\t\t\t\traise Rush::DoesNotExist, stream\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\t# TODO: use tar for cross-server transfers.\n\t\t# something like this?:\n\t\t# archive = from.box.read_archive(src)\n\t\t# dst.box.write_archive(archive, dst)\n\n\t\tnew_full_path = dst.dir? ? \"#{dst.full_path}#{src.name}\" : dst.full_path\n\t\tsrc.class.new(new_full_path, dst.box)\n\trescue Errno::ENOENT\n\t\traise Rush::DoesNotExist, File.dirname(to)\n\trescue RuntimeError\n\t\traise Rush::DoesNotExist, from\n\tend",
"def remote_copy(from, to, sudo: false, owner: nil, group: nil)\n extra_opts = {}\n extra_opts[:sudo] = sudo if sudo\n extra_opts[:owner] = owner if owner\n extra_opts[:group] = group if group\n @calls << [:remote_copy, from, to] + (extra_opts.empty? ? [] : [extra_opts])\n @remote_copy_code&.call(@stdout_io, @stderr_io, self)\n end",
"def upload\n @files.each do |fn|\n sh %{scp -q #{@local_dir}/#{fn} #{@host}:#{@remote_dir}}\n end\n end",
"def cp(*args, **kwargs)\n queue CopyCommand, args, kwargs\n end",
"def cp_lr(src, dest, noop: nil, verbose: nil,\n dereference_root: true, remove_destination: false)\n fu_output_message \"cp -lr#{remove_destination ? ' --remove-destination' : ''} #{[src,dest].flatten.join ' '}\" if verbose\n return if noop\n fu_each_src_dest(src, dest) do |s, d|\n link_entry s, d, dereference_root, remove_destination\n end\n end",
"def copy_scripts\n script_list.each do |name|\n source = File.join(__dir__, \"script/#{name}.bash\")\n dest = File.expand_path(\"~/.#{name}-goodies.bash\")\n puts \"Copy #{name}-goodies\".green\n `cp #{source} #{dest}`\n end\nend",
"def copy_files\r\n %w{_config.dev.yml about.md feed.xml gulpfile.js index.html}.each do |file|\r\n copy_file file\r\n end\r\n end",
"def gather\n if File.exist?(@location_dir) && File.directory?(@location_dir)\n if Dir.glob(File.join(@location_dir, '*')).size > 0 # avoid creating the dest directory if the source dir is empty\n unless File.exists? @destination_dir\n FileUtils.mkpath @destination_dir\n end\n @files.each do |f|\n Dir.glob(File.join(@location_dir, f)).each do |file|\n FileUtils.cp_r file, @destination_dir\n end\n end\n end\n else\n puts \"Error: #{@location_dir}, doesn't exist or not a directory\"\n end\n end",
"def cp_r(src, dest, preserve: nil, noop: nil, verbose: nil,\n dereference_root: true, remove_destination: nil)\n fu_output_message \"cp -r#{preserve ? 'p' : ''}#{remove_destination ? ' --remove-destination' : ''} #{[src,dest].flatten.join ' '}\" if verbose\n return if noop\n fu_each_src_dest(src, dest) do |s, d|\n copy_entry s, d, preserve, dereference_root, remove_destination\n end\n end",
"def perform_sync(source, destination, options)\n new_files, new_files_destination = get_new_files_to_sync(source, destination, options)\n sync_new_files(source, new_files, new_files_destination, options)\n cleanup_files_we_dont_want_to_keep(source, new_files, new_files_destination) unless options[:keep].nil?\n end",
"def do_local_checkout_and_rsync(svn_username, actor)\n configuration.logger.debug(\"++++ LOCAL CHECKOUT AND RSYNC ++++\")\n rsync_username = configuration[:rsync_username] ? \"#{configuration[:rsync_username]}@\" : \"\"\n local_rsync_cache= configuration[:local_rsync_cache]\n remote_rsync_cache= configuration[:remote_rsync_cache]\n if local_rsync_cache.nil? || remote_rsync_cache.nil?\n throw \"to use rsync local_rsync_cache and remote_rsync_cache must be set\"\n end\n\n configuration.logger.debug \"rm -rf #{local_rsync_cache} && #{svn} export #{svn_username} -q -r#{configuration[:revision]} #{rep_path} #{local_rsync_cache}\"\n\n # update the local svn cache\n run_local(\n \n \"rm -rf #{local_rsync_cache}&& #{svn} export #{svn_username} -q -r#{configuration[:revision]} #{rep_path} #{local_rsync_cache}\"\n )\n\n # rsync with the remote machine(s)\n rcmd = 'rsync '\n # add rsync options\n %w{\n archive\n compress\n copy-links\n cvs-exclude\n delete-after\n no-blocking-io\n stats\n }.each { | opt | rcmd << \"--#{opt} \" }\n\n # excluded files and directories\n excludes= configuration[:rsync_excludes] || []\n excludes.each { |e| rcmd << \" --exclude \\\"#{e}\\\" \" }\n\n # for each server in current task\n actor.current_task.servers.each do |server|\n configuration.logger.debug \"RSyncing deployment cache for #{server}\"\n configuration.logger.debug \"#{rcmd} -e ssh #{local_rsync_cache}/ #{rsync_username}#{server}:#{remote_rsync_cache}/\"\n run_local(\"#{rcmd} -e ssh #{local_rsync_cache}/ #{rsync_username}#{server}:#{remote_rsync_cache}/\")\n end\n\n # copy the remote_rsync_cache on the remote machine as if it has been checked out there\n cmd=\"cp -a #{remote_rsync_cache}/ #{actor.release_path} && \"\n run_remote(actor, cmd)\n end",
"def rsync(local_folder, remote_destination, delete)\n @log.info(\"rsyncing folder '#{local_folder}' to '#{remote_destination}'...\")\n @process_runner.execute!(\"rsync --filter='P *.css' --filter='P apidocs' --filter='P cdn' --filter='P get-started' --partial --archive --checksum --compress --omit-dir-times --quiet#{' --delete' if delete} --chmod=Dg+sx,ug+rw,Do+rx,o+r --protocol=28 --exclude='.snapshot' #{local_folder}/ #{remote_destination}\")\n end",
"def copyCommon(destPath)\n\tcopyUI(destPath)\n\tcopyEvothings(destPath)\nend",
"def rsync( srcs, target, opts )\n @commands << rsync_args( host, srcs, target, opts )\n ( rand(2) == 1 ) ? [ [ 'something', 'somefile' ] ] : []\n end",
"def calculate_copies\n # no copies if we don't have an ancestor.\n # no copies if we're going backwards.\n # no copies if we're overwriting.\n return {} unless ancestor && !(backwards? || overwrite?)\n # no copies if the user says not to follow them.\n return {} unless @repo.config[\"merge\", \"followcopies\", Boolean, true]\n\n \n dirs = @repo.config[\"merge\", \"followdirs\", Boolean, false]\n # calculate dem hoes!\n copy, diverge = Amp::Graphs::Mercurial::CopyCalculator.find_copies(self, local, remote, ancestor, dirs)\n \n # act upon each divergent rename (one branch renames to one name,\n # the other branch renames to a different name)\n diverge.each {|of, fl| divergent_rename of, fl }\n \n copy\n end",
"def copy_files\n message \"Checking for existing #{@@app_name.capitalize} install in #{install_directory}\"\n files_yml = File.join(install_directory,'installer','files.yml')\n old_files = read_yml(files_yml) rescue Hash.new\n \n message \"Reading files from #{source_directory}\"\n new_files = sha1_hash_directory_tree(source_directory)\n new_files.delete('/config/database.yml') # Never copy this.\n \n # Next, we compare the original install hash to the current hash. For each\n # entry:\n #\n # - in new_file but not in old_files: copy\n # - in old files but not in new_files: delete\n # - in both, but hash different: copy\n # - in both, hash same: don't copy\n #\n # We really should add a third hash (existing_files) and compare against that\n # so we don't overwrite changed files.\n\n added, changed, deleted, same = hash_diff(old_files, new_files)\n \n if added.size > 0\n message \"Copying #{added.size} new files into #{install_directory}\"\n added.keys.sort.each do |file|\n message \" copying #{file}\"\n copy_one_file(file)\n end\n end\n \n if changed.size > 0\n message \"Updating #{changed.size} files in #{install_directory}\"\n changed.keys.sort.each do |file|\n message \" updating #{file}\"\n copy_one_file(file)\n end\n end\n \n if deleted.size > 0\n message \"Deleting #{deleted.size} files from #{install_directory}\"\n \n deleted.keys.sort.each do |file|\n message \" deleting #{file}\"\n rm(File.join(install_directory,file)) rescue nil\n end\n end\n \n write_yml(files_yml,new_files)\n end",
"def copyLocalFileToRemoteDirectory(sourcePath, destinationPath, dryRun)\n #N Without this, the external SCP application won't actually be run to copy the file\n executeCommand(\"#{@scpCommandString} #{sourcePath} #{userAtHost}:#{destinationPath}\", dryRun)\n end",
"def copy_files\n @files.each do |file|\n basename = File.basename file\n FileUtils.cp file, @backup_folder + basename if File.file? file\n FileUtils.cp_r file, @backup_folder + basename if File.directory? file\n end\n end",
"def sync_special_fat32_files\n Dir[File.join(@path_source, '**/*\\./')].sort.each do |source_dir|\n # Syncing files from source and dest\n dest_dir = get_dest_filepath(source_dir)\n\n puts \"Manually syncing files to #{File.basename(dest_dir)}\"\n rsync_dirs(source_dir, dest_dir, true)\n end\n end",
"def sftp_copy(username, password, server, files_map)\n ssh = FileCopy.ssh_connect(username, password, server)\n ssh.sftp.connect do |sftp|\n uploads = files_map.map { |from,to|\n remote_dir = File.dirname(to)\n sftp_mkdir_recursive(sftp, File.dirname(to))\n Log.debug1(\"Copying %s to %s\",from, to)\n sftp.upload(from, to)\n }\n uploads.each { |u| u.wait }\n Log.debug1(\"Done.\")\n end # ssh.sftp.connect\n end",
"def sync_local\n sync_hash = {\n ['~/Library/Application\\\\ Support/Firefox', '~/Library/Application\\\\ Support/Quicksilver',\n '~/Library/Preferences' ] =>'library/',\n ['~/.boson', '~/.sake', '~/.cronrc', '~/.gemrc', '~/.gitconfig', '~/.gem/specs']=>'dotfiles/',\n }\n sync_hash.each do |src, dest|\n src.each do |e| \n cmd = \"rsync -av #{e} #{File.join('~/backup', dest)}\"\n system cmd\n end\n end\n end",
"def agent_setup_commands\n [\n \"cp -r #{REMOTE_SOURCE_VOLUME_PATH_RO} #{REMOTE_SOURCE_VOLUME_PATH}\",\n \"cd #{REMOTE_SOURCE_VOLUME_PATH}\",\n \"#{DO_NEXT}=\\\"0\\\"\",\n \"#{EXIT_CODE}=\\\"0\\\"\",\n \"#{BUILD_EXIT_CODE}=\\\"0\\\"\",\n ]\n end",
"def force_copy\n add option: \"-force-copy\"\n end",
"def copy_contents\n cmd = rsync_cmd\n\n @log.debug \"Copying contents with: #{cmd}\"\n\n %x[#{cmd}]\n $?.success?\n end",
"def rsync(source, target, exclude = [], options = [], verbose = false)\n excludes = exclude.map {|e| \"--exclude=#{e} \"}\n host = source.split(/\\//)[2]\n port = 873\n\n # Make the target directory if it's not there.\n FileUtils.mkdir(target) if !File.directory?(target)\n\n begin\n raise Exception, \"Unable to connect to remote host #{source}\" unless port_open?(host, port)\n\n log(\"rsync #{options} #{excludes} #{source} #{target}\")\n\n if verbose\n puts \"RUNNING: rsync #{options} #{excludes} #{source} #{target}\"\n system \"rsync #{options} #{excludes} #{source} #{target}\"\n else\n `rsync #{options} #{excludes} #{source} #{target}`\n end\n\n rescue Errno::EACCES, Errno::ENOENT, Errno::ENOTEMPTY, Exception => e\n log(e.to_s)\n end\nend",
"def copy_assets src, dest, inclusive=true, missing='exit'\n unless File.file?(src)\n unless inclusive then src = src + \"/.\" end\n end\n src_to_dest = \"#{src} to #{dest}\"\n unless (File.file?(src) || File.directory?(src))\n case missing\n when \"warn\"\n @logger.warn \"Skipping migrate action (#{src_to_dest}); source not found.\"\n return\n when \"skip\"\n @logger.debug \"Skipping migrate action (#{src_to_dest}); source not found.\"\n return\n when \"exit\"\n @logger.error \"Unexpected missing source in migrate action (#{src_to_dest}).\"\n raise \"MissingSourceExit\"\n end\n end\n @logger.debug \"Copying #{src_to_dest}\"\n begin\n FileUtils.mkdir_p(dest) unless File.directory?(dest)\n if File.directory?(src)\n FileUtils.cp_r(src, dest)\n else\n FileUtils.cp(src, dest)\n end\n @logger.info \"Copied #{src} to #{dest}.\"\n rescue Exception => ex\n @logger.error \"Problem while copying assets. #{ex.message}\"\n raise\n end\nend",
"def copyLocalToRemoteDirectory(sourcePath, destinationPath, dryRun)\n #N Without this, the external SCP application won't actually be run to copy the directory\n executeCommand(\"#{@scpCommandString} -r #{sourcePath} #{userAtHost}:#{destinationPath}\", dryRun)\n end",
"def update_copied_remote_file(file, copy)\n # the remote has a file that has been copied or moved from copy[file] to file.\n # file is also destination.\n src = copy[file]\n \n # If the user doen't even have the source, then we apparently renamed a directory.\n if !(working_changeset.include?(file2))\n directory nil, file, src, remote.flags(file)\n elsif remote.include? file2\n # If the remote also has the source, then it was copied, not moved\n merge src, file, file, flag_merge(src, file, src), false\n else\n # If the source is gone, it was moved. Hence that little \"true\" at the end there.\n merge src, file, file, flag_merge(src, file, src), true\n end\n end",
"def copy\n actionlist = actionlist(:copy, copylist)\n\n if actionlist.empty?\n report_nothing_to_generate\n return\n end\n\n #logger.report_startup(job, output)\n\n mkdir_p(output) unless File.directory?(output)\n\n backup(actionlist) if backup?\n\n Dir.chdir(output) do\n actionlist.each do |action, fname|\n atime = Time.now\n how = __send__(\"#{action}_item\", Pathname.new(fname))\n report_create(fname, how, atime)\n end\n #logger.report_complete\n #logger.report_fixes(actionlist.map{|a,f|f})\n end\n end",
"def cp_r(src, dest, options = {})\r\n fu_check_options options, :preserve, :noop, :verbose\r\n fu_output_message \"cp -r#{options[:preserve] ? 'p' : ''} #{[src,dest].flatten.join ' '}\" if options[:verbose]\r\n return if options[:noop]\r\n\r\n fu_each_src_dest(src, dest) do |s,d|\r\n if File.directory?(s)\r\n fu_copy_dir s, d, '.', options[:preserve]\r\n else\r\n fu_p_copy s, d, options[:preserve]\r\n end\r\n end\r\n end",
"def fast_copy_chain(base_dir, targets, options={})\n # Normalize the filesnames param so it is an array\n filenames = options[:files] || ['.']\n filenames = [filenames] unless filenames.respond_to?(:each)\n \n # Normalize the targets param, so that targets is an array of Hosts and\n # destinations is a hash of hosts => dirs\n destinations = {}\n targets = [targets] unless targets.respond_to?(:each)\n base_dir += '/' unless base_dir[-1] == '/'\n if targets.is_a? Hash\n destinations = targets\n destinations.each {|t, d| destinations[t] += '/' unless d[-1] == '/'}\n targets = targets.keys\n else\n destinations = targets.inject({}) {|memo, target| memo[target] = base_dir; memo}\n end\n raise \"No target hosts supplied\" if targets.count < 1\n \n file_list = filenames.join ' '\n port = (options[:port] || 7000).to_i\n \n if Jetpants.compress_with || Jetpants.decompress_with\n comp_bin = Jetpants.compress_with.split(' ')[0]\n confirm_installed comp_bin\n output \"Using #{comp_bin} for compression\"\n else\n output \"Compression disabled -- no compression method specified in Jetpants config file\"\n end\n \n # On each destination host, do any initial setup (and optional validation/erasing),\n # and then listen for new files. If there are multiple destination hosts, all of them\n # except the last will use tee to \"chain\" the copy along to the next machine.\n workers = []\n targets.reverse.each_with_index do |t, i|\n dir = destinations[t]\n raise \"Directory #{t}:#{dir} looks suspicious\" if dir.include?('..') || dir.include?('./') || dir == '/' || dir == ''\n \n if Jetpants.compress_with || Jetpants.decompress_with\n decomp_bin = Jetpants.decompress_with.split(' ')[0]\n t.confirm_installed decomp_bin\n end\n t.ssh_cmd \"mkdir -p #{dir}\"\n \n # Check if contents already exist / non-empty.\n # Note: doesn't do recursive scan of subdirectories\n unless options[:overwrite]\n all_paths = filenames.map {|f| dir + f}.join ' '\n dirlist = t.dir_list(all_paths)\n dirlist.each {|name, size| raise \"File #{name} exists on destination and has nonzero size!\" if size.to_i > 0}\n end\n \n decompression_pipe = Jetpants.decompress_with ? \"| #{Jetpants.decompress_with}\" : ''\n if i == 0\n workers << Thread.new { t.ssh_cmd \"cd #{dir} && nc -l #{port} #{decompression_pipe} | tar xv\" }\n t.confirm_listening_on_port port\n t.output \"Listening with netcat.\"\n else\n tt = targets.reverse[i-1]\n fifo = \"fifo#{port}\"\n workers << Thread.new { t.ssh_cmd \"cd #{dir} && mkfifo #{fifo} && nc #{tt.ip} #{port} <#{fifo} && rm #{fifo}\" }\n checker_th = Thread.new { t.ssh_cmd \"while [ ! -p #{dir}/#{fifo} ] ; do sleep 1; done\" }\n raise \"FIFO not found on #{t} after 10 tries\" unless checker_th.join(10)\n workers << Thread.new { t.ssh_cmd \"cd #{dir} && nc -l #{port} | tee #{fifo} #{decompression_pipe} | tar xv\" }\n t.confirm_listening_on_port port\n t.output \"Listening with netcat, and chaining to #{tt}.\"\n end\n end\n \n # Start the copy chain.\n output \"Sending files over to #{targets[0]}: #{file_list}\"\n compression_pipe = Jetpants.compress_with ? \"| #{Jetpants.compress_with}\" : ''\n ssh_cmd \"cd #{base_dir} && tar vc #{file_list} #{compression_pipe} | nc #{targets[0].ip} #{port}\"\n workers.each {|th| th.join}\n output \"File copy complete.\"\n \n # Verify\n output \"Verifying file sizes and types on all destinations.\"\n compare_dir base_dir, destinations, options\n output \"Verification successful.\"\n end",
"def cp_r(src,dst)\n src_root = Pathname.new(src)\n FileUtils.mkdir_p(dst, :verbose => VERBOSE) unless File.exists? dst\n Dir[\"#{src}/**/**\"].each do |abs_path|\n src_path = Pathname.new(abs_path)\n rel_path = src_path.relative_path_from(src_root)\n dst_path = \"#{dst}/#{rel_path.to_s}\"\n \n next if abs_path.include? '.svn'\n \n if src_path.directory?\n FileUtils.mkdir_p(dst_path, :verbose => VERBOSE)\n elsif src_path.file?\n FileUtils.cp(abs_path, dst_path, :verbose => VERBOSE)\n end\n end\nend",
"def issue_pings_with_pptasks(sources, targets)\n id = Thread.current.__id__\n @logger.debug \"id: #{id.inspect}\"\n\n # XXX: DOESN'T WORK FOR RIOT NODES!\n File.open(\"/tmp/sources#{id}\", \"w\") { |f| f.puts sources.join \"\\n\" } \n File.open(\"/tmp/targets#{id}\", \"w\") { |f| f.puts targets.join \"\\n\" } \n\n @logger.warn \"here\" if not system \"#{FailureIsolation::PPTASKS} scp #{FailureIsolation::MonitorSlice} /tmp/sources#{id} 100 100 \\\n /tmp/targets#{id} @:/tmp/targets#{id}\"\n\n # TODO: don't assume eth0!\n @logger.warn \"there\" if not system %{#{FailureIsolation::PPTASKS} ssh #{FailureIsolation::MonitorSlice} /tmp/sources#{id} 100 1000 \\\n \"cd colin/Scripts; sudo 2>/dev/null ./scamper -o /tmp/warts#{id} -O Warts -c 'ping -c 1' -f /tmp/targets#{id}\"}\n\n FileUtils.rm_rf(\"/tmp/warts#{id}\")\n FileUtils.mkdir_p(\"/tmp/warts#{id}\")\n\n results = Set.new\n\n @logger.warn \"everywhere\" if not system \"#{FailureIsolation::PPTASKS} scp #{FailureIsolation::MonitorSlice} /tmp/sources#{id} 100 100 \\\n @:/tmp/warts#{id} :warts\"\n\n Dir.glob(\"/tmp/warts#{id}/*\").each do |file|\n warts_results = `#{FailureIsolation::WartsDumpPath} #{file}`.split(\"\\n\")\n ip_addrs = warts_results.map { |str| str.split[0] } \n results |= ip_addrs\n end\n\n if results.empty?\n uuid = (0...36).map { (97 + rand(25)).chr }.join\n FileUtils.mkdir_p(\"#{FailureIsolation::EmptyPingsLogDir}/#{uuid}\")\n system %{#{FailureIsolation::PPTASKS} ssh #{FailureIsolation::MonitorSlice} /tmp/sources#{id} 100 100 \"hostname --fqdn ; ps aux\" > #{FailureIsolation::EmptyPingsLogDir}/#{uuid}/ps-aux}\n @logger.warn { \"issue_pings_with_pptasks empty results time #{Time.now.utc.strftime(\"%Y%m%d%H%M%S\")} srcs #{sources.length} #{sources.join(\",\")} targets #{targets.length} #{targets.join(\",\")} logs #{FailureIsolation::EmptyPingsLogDir}/#{uuid}\" }\n else\n @logger.info { \"pptasks issued pings successfully\" }\n end\n\n results\n end",
"def copy\n nodes = Node.accessible_by(@context).where(id: params[:item_ids])\n\n NodeCopyWorker.perform_async(\n params[:scope],\n nodes.pluck(:id),\n session_auth_params,\n )\n\n render json: nodes, root: \"nodes\", adapter: :json,\n meta: {\n messages: [{\n type: \"success\",\n message: I18n.t(\"api.files.copy.files_are_copying\"),\n }],\n }\n end",
"def copy(dest, overwrite = false)\n# if(dest.path == path)\n# Conflict\n# elsif(stat.directory?)\n# dest.make_collection\n# FileUtils.cp_r(\"#{file_path}/.\", \"#{dest.send(:file_path)}/\")\n# OK\n# else\n# exists = File.exists?(file_path)\n# if(exists && !overwrite)\n# PreconditionFailed\n# else\n# open(file_path, \"rb\") do |file|\n# dest.write(file)\n# end\n# exists ? NoContent : Created\n# end\n# end\n\n # ディレクトリなら末尾に「/」をつける。\n # (dstにもともと「/」が付いているかどうか、クライアントに依存している)\n # CarotDAV : 「/」が付いていない\n # TeamFile : 「/」が付いている\n dest.collection! if collection?\n\n src = @bson['filename']\n dst = dest.file_path\n exists = nil\n\n @collection.find({:filename => /^#{Regexp.escape(src)}/}).each do |bson|\n src_name = bson['filename']\n dst_name = dst + src_name.slice(src.length, src_name.length)\n\n exists = @collection.find_one({:filename => dst_name}) rescue nil\n\n return PreconditionFailed if (exists && !overwrite && !collection?)\n\n @filesystem.open(src_name, \"r\") do |src|\n @filesystem.open(dst_name, \"w\") do |dst|\n dst.write(src) if src.file_length > 0\n end\n end\n\n @collection.remove(exists) if exists\n end\n\n collection? ? Created : (exists ? NoContent : Created)\n end",
"def rel_copy(full_src, rel_dest, opts={})\n \n dest_path = File.dirname(rel_dest)\n \n fname = Pathname.new(full_src).basename\n \n if !File.directory?(dest_path)\n cmd = \"mkdir -p #{dest_path}\"\n \n if !opts[:mock]\n run cmd\n else\n puts \"mocking #{cmd}\"\n end \n end\n \n cmd = \"cp #{full_src} #{dest_path}/#{fname}\"\n \n if !opts[:mock]\n run cmd\n else\n puts \"mocking #{cmd}\"\n end\n\nend",
"def copy_cloud_files(ips, cloud_type)\n # Use MCollective?\n # - Without MCollective we are able to send it to both one machine or multiple\n # machines without changing anything, so not really.\n\n ips.each do |vm|\n \n if vm != MY_IP\n \n # Cloud manifest\n file = \"init-#{cloud_type}.pp\"\n path = \"/etc/puppet/modules/#{cloud_type}/manifests/#{file}\"\n out, success = CloudSSH.copy_remote(path, vm, path)\n unless success\n @err.call \"Impossible to copy #{file} to #{vm}\"\n end\n\n end\n \n end\n \n end",
"def make_copy(src, dest)\n#\tcommandz(\"cp -p #{src} #{dest}\")\n\n\t#Now with Ruby :)\n\tFileUtils.cp(\"#{src}\", \"#{dest}\", :preserve => true )\nend",
"def net_scp_transfer!(direction, recursive, *files)\n \n unless [:upload, :download].member?(direction.to_sym)\n raise \"Must be one of: upload, download\" \n end\n \n if @rye_current_working_directory\n debug \"CWD (#{@rye_current_working_directory})\"\n end\n \n files = [files].flatten.compact || []\n\n # We allow a single file to be downloaded into a StringIO object\n # but only when no target has been specified. \n if direction == :download \n if files.size == 1\n debug \"Created StringIO for download\"\n target = StringIO.new\n else\n target = files.pop # The last path is the download target.\n end\n \n elsif direction == :upload\n# p :UPLOAD, @rye_templates\n raise \"Cannot upload to a StringIO object\" if target.is_a?(StringIO)\n if files.size == 1\n target = self.getenv['HOME'] || guess_user_home\n debug \"Assuming upload to #{target}\"\n else\n target = files.pop\n end\n \n # Expand fileglobs (e.g. path/*.rb becomes [path/1.rb, path/2.rb]).\n # This should happen after checking files.size to determine the target\n unless @rye_safe\n files.collect! { |file| \n file.is_a?(StringIO) ? file : Dir.glob(File.expand_path(file)) \n }\n files.flatten! \n end\n end\n \n # Fail early. We check whether the StringIO object is available to read\n files.each do |file|\n if file.is_a?(StringIO)\n raise \"Cannot download a StringIO object\" if direction == :download\n raise \"StringIO object not opened for reading\" if file.closed_read?\n # If a StringIO object is at end of file, SCP will hang. (TODO: SCP)\n file.rewind if file.eof?\n end\n end\n \n debug \"FILES: \" << files.join(', ')\n \n # Make sure the target directory exists. We can do this only when\n # there's more than one file because \"target\" could be a file name\n if files.size > 1 && !target.is_a?(StringIO)\n debug \"CREATING TARGET DIRECTORY: #{target}\"\n self.mkdir(:p, target) unless self.file_exists?(target)\n end\n \n Net::SCP.start(@rye_host, @rye_user, @rye_opts || {}) do |scp|\n transfers = []\n prev = \"\"\n files.each do |file|\n debug file.to_s\n prev = \"\"\n line = nil\n transfers << scp.send(direction, file, target, :recursive => recursive) do |ch, n, s, t|\n line = \"%-50s %6d/%-6d bytes\" % [n, s, t]\n spaces = (prev.size > line.size) ? ' '*(prev.size - line.size) : ''\n pinfo \"[%s] %s %s %s\" % [direction, line, spaces, s == t ? \"\\n\" : \"\\r\"] # update line: \"file: sent/total\"\n @rye_info.flush if @rye_info # make sure every line is printed\n prev = line\n end\n end\n transfers.each { |t| t.wait } # Run file transfers in parallel\n end\n \n target.is_a?(StringIO) ? target : nil\n end",
"def copy_files(from, to, options={})\n exceptions = options[:except] || []\n\n puts \"Copying files #{from} => #{to}...\" if ENV['VERBOSE']\n\n Dir[\"#{from}/**/*\"].each do |f|\n next unless File.file?(f)\n next if exceptions.include?(File.basename(f))\n\n target = File.join(to, f.gsub(/^#{Regexp.escape from}/, ''))\n\n FileUtils.mkdir_p File.dirname(target)\n puts \"%20s => %-20s\" % [f, target] if ENV['VERBOSE']\n FileUtils.cp f, target\n end\nend",
"def copy_dir(src, dest)\n output = `rsync -r --exclude='.svn' --exclude='.git' --exclude='.gitignore' --filter=':- .gitignore' 2>&1 #{Shellwords.escape(src.to_s)}/ #{Shellwords.escape(dest.to_s)}`\n [output, $?]\n end",
"def selective_copy(directory, &block)\n Dir[File.join(source_paths, directory)].each do |filename|\n file = filename.to_s.gsub(\"#{Engine.root.to_s}/\", '')\n copy_file file\n end\n end",
"def action_sync\n assert_target_directory_valid!\n if ::File.exist?(::File.join(@new_resource.destination, 'CVS'))\n Chef::Log.debug \"#{@new_resource} update\"\n converge_by(\"sync #{@new_resource.destination} from #{@new_resource.repository}\") do\n run_command(run_options(:command => sync_command))\n Chef::Log.info \"#{@new_resource} updated\"\n end\n else\n action_checkout\n end\n end",
"def cp (from, to, as: user, on: hosts, quiet: false, once: nil, delete: false)\n self.once once, quiet: quiet do\n log.info \"cp: #{from} -> #{to}\", quiet: quiet do\n Dir.chdir File.dirname(file) do\n hash_map(hosts) do |host|\n host.cp from, to, as: as, quiet: quiet, delete: delete\n end\n end\n end\n end\n end",
"def remove_superfluous_destination_files\n # join mirror_file and dest_file and delete everything from dest_file which isn't in mirror_file\n # because mirror_file should represent the current state of the source mogile files\n Log.instance.info('Joining destination and mirror tables to determine files that have been deleted from source repo.')\n DestFile.where('mirror_file.dkey IS NULL').joins('LEFT OUTER JOIN mirror_file ON mirror_file.dkey = file.dkey').find_in_batches(batch_size: 1000) do |batch|\n batch.each do |file|\n # Quit if program exit has been requested.\n break if SignalHandler.instance.should_quit\n\n # Delete all files from our destination domain which no longer exist in the source domain.\n begin\n Log.instance.debug(\"key [ #{file.dkey} ] should not exist. Deleting.\")\n @dest_mogile.delete(file.dkey)\n @removed += 1\n @freed_bytes += file.length\n rescue => e\n @failed += 1\n Log.instance.error(\"Error deleting [ #{file.dkey} ]: #{e.message}\\n#{e.backtrace}\")\n end\n end\n\n # Print a summary to the user.\n summarize\n\n # Quit if program exit has been requested.\n return true if SignalHandler.instance.should_quit\n end\n end",
"def make_copy_file_tasks\n @files.each do |source, destination|\n next if source == destination\n next if Rake::FileTask.task_defined? destination\n type = File.directory?(source) ? 'folder' : 'file'\n task = Rake::FileTask.define_task destination do |t|\n folder = File.dirname(t.name)\n FileUtils.mkpath folder unless File.directory? folder\n FileUtils.copy source, t.name\n end\n task.comment = \"Create the #{destination} #{type}\"\n task.enhance ['wix']\n if Rake::FileTask.task_defined? source\n task.enhance [source]\n end\n end\n end",
"def exec(src, dest, options={})\n @failures.synchronize do\n @failures.clear\n end\n rsync_cmd = command(src, dest, options)\n if options[:chdir]\n rsync_cmd = \"cd '#{options[:chdir]}'; #{rsync_cmd}\"\n end\n @logger.debug rsync_cmd if @logger\n ok = system(rsync_cmd)\n unless ok\n @failures.synchronize do\n @failures << {:source => src, :dest => dest, :options => options.dup}\n end\n end\n end",
"def copy_importants_from(other_redmine)\n Dir.chdir(root) do\n # Copy database.yml\n FileUtils.cp(other_redmine.database_yml_path, database_yml_path)\n\n # Copy configuration.yml\n if File.exist?(other_redmine.configuration_yml_path)\n FileUtils.cp(other_redmine.configuration_yml_path, configuration_yml_path)\n end\n\n # Copy Gemfile.local\n if File.exist?(other_redmine.gemfile_local_path)\n FileUtils.cp(other_redmine.gemfile_local_path, gemfile_local_path)\n end\n\n # Copy files\n if task.options.copy_files_with_symlink\n FileUtils.rm_rf(files_path)\n FileUtils.ln_s(other_redmine.files_path, root)\n else\n FileUtils.cp_r(other_redmine.files_path, root)\n end\n\n # Copy old logs\n FileUtils.mkdir_p(log_path)\n Dir.glob(File.join(other_redmine.log_path, 'redmine_installer_*')).each do |log|\n FileUtils.cp(log, log_path)\n end\n\n # Copy bundle config\n if Dir.exist?(other_redmine.bundle_path)\n FileUtils.mkdir_p(bundle_path)\n FileUtils.cp_r(other_redmine.bundle_path, root)\n end\n end\n\n # Copy 'keep' files (base on options)\n Array(task.options.keep).each do |path|\n origin_path = File.join(other_redmine.root, path)\n next unless File.exist?(origin_path)\n\n # Ensure folder\n target_dir = File.join(root, File.dirname(path))\n FileUtils.mkdir_p(target_dir)\n\n # Copy recursive\n FileUtils.cp_r(origin_path, target_dir)\n end\n\n logger.info('Important files was copyied')\n end",
"def create_copy_file_tasks(source_files, source_root, dest_root, invoking_task)\n source_files.each do |source|\n target = source.pathmap(\"%{#{source_root},#{dest_root}}p\")\n directory File.dirname(target)\n file target => [File.dirname(target), source] do |t|\n cp source, target\n end\n task invoking_task => target\n end\nend",
"def copy_folder_ind\n create_process(process: \"COPY_FOLDER\")\n end",
"def download_all_files files,dest\n return if files.empty?\n RubyUtil::partition files do |sub|\n cmd = \"mv -t #{dest} \"\n cmd += sub.map { |f| \"\\\"#{f.full_path}\\\"\" }.join(' ')\n exec_cmd(cmd) \n end\n # update files object !\n files.map! { |f| f.path = dest; f }\n end",
"def dragged\n $dz.determinate(true)\n \n move = true\n \n if ENV['OPERATION'] == \"NSDragOperationCopy\"\n operation = \"Copying\"\n move = false\n else\n operation = \"Moving\"\n end\n \n $dz.begin(\"#{operation} files...\")\n\n Rsync.do_copy($items, ENV['EXTRA_PATH'], move)\n \n finish_op = (move ? \"Move\" : \"Copy\")\n $dz.finish(\"#{finish_op} Complete\")\n $dz.url(false)\nend",
"def FileCopy(src, dst)\n success?(parse(cmd(with_args(src, dst))))\n end",
"def cp_dir(src, dst)\n puts \"#{cmd_color('copying')} #{dir_color(src)}\"\n puts \" -> #{dir_color(dst)}\"\n Find.find(src) do |fn|\n next if fn =~ /\\/\\./\n r = fn[src.size..-1]\n if File.directory? fn\n mkdir File.join(dst,r) unless File.exist? File.join(dst,r)\n else\n cp(fn, File.join(dst,r))\n end\n end\nend",
"def copy from, to\n add \"cp #{from} #{to}\", check_file(to)\n end",
"def cp(src, dst, **_opts)\n full_src = full_path(src)\n full_dst = full_path(dst)\n\n mkdir_p File.dirname(full_dst)\n sh! %(cp -a -f #{Shellwords.escape(full_src)} #{Shellwords.escape(full_dst)})\n rescue CommandError => e\n e.status == 1 ? raise(BFS::FileNotFound, src) : raise\n end",
"def sync_dir dir\n # TODO: think of a better name scheme\n # maybe the title should include the relative path?\n calculated_photoset_name = \"[ruphy-backup] #{dir}\"\n Dir.chdir @root + '/' + dir\n\n if photoset_exist? calculated_photoset_name\n #sync\n flickr_list = get_file_list calculated_photoset_name\n local_list = Dir[\"*\"]\n remotely_missing = []\n locally_missing = []\n \n local_list.each do |f|\n remotely_missing << f unless flickr_list.include? f\n end\n# puts \"remotely missing files: \" + remotely_missing.join(',')\n \n remotely_missing.each do |f|\n upload f, calculated_photoset_name\n end\n \n \n flickr_list.each do |f|\n locally_missing << f unless local_list.include? f\n end\n puts \"we're locally missing: \" + locally_missing.join(', ')\n \n # TODO: really perform sync\n \n else\n # set not existing: just upload\n Dir[\"*\"].each do |f|\n upload f, calculated_photoset_name\n end\n end\n end",
"def cp_if_necessary(src, dst, owner = nil, mode = nil)\n if !File.exists?(dst) || different?(src, dst)\n cp(src, dst, owner, mode)\n true\n end\n end",
"def runDiffOperation(new_output, old_output, diff_folder)\n #Searching for New & updated files\n @files = Dir.glob(new_output+\"**/**\")\n for file in @files\n partName=file.split(new_output).last \n if (File.directory?(file))\n if !File.exist?(old_output+partName)\n if !File.exist?(diff_folder+partName)\n createFolder(diff_folder+partName)\n puts \"Dir Created -\" + partName\n else\n puts \"Target Dir Exists -\" + partName\n end\n end\n else\n #New file copy operation\n if !File.exist?(old_output+partName) \n folder= partName.split(partName.split(\"/\").last).first\n if folder==nil\n folder=\"\"\n end\n if !File.exist?(diff_folder+folder)\n createFolder(diff_folder+folder)\n puts \"Dir Created -\" + diff_folder+folder\n end\n File.copy(file,diff_folder+folder)\n puts \"New File Copied -\"+file +\" to \"+diff_folder+folder\n #Updated file copy operation\n elsif !(File.compare(file,old_output+partName))\n folder= partName.split(partName.split(\"/\").last).first\n if folder==nil \n folder=\"\"\n end\n if !File.exist?(diff_folder+folder)\n createFolder(diff_folder+folder)\n puts \"Dir Created -\" + diff_folder+folder\n end\n File.copy(file,diff_folder+folder)\n puts \"Updated File Copied -\"+file +\" to \"+diff_folder+folder\n end\n end\n end\n #Searching for Deleted files & creating the list\n deletedFileList=diff_folder+\"deletedFiles.list\"\n timestamp = Time.now.to_s()\n deletedFileName=\"\"\n deletedFilesCount=0;\n @files = Dir.glob(old_output+\"**/**\")\n for file in @files\n partName=file.split(old_output).last\n check=partName.include?'search/'\n if !File.exist?(new_output+partName) && !check\n if !(File.directory?(file))\n deletedFileName=partName.split(\"/\").last\n open(deletedFileList, 'a') { |f|\n f.puts deletedFileName\n }\n end\n# deletedFileName= timestamp +\"\\t\"+deletedFileName\n deletedFilesCount=deletedFilesCount+1 \n end\n end\n if Dir.glob(diff_folder+\"**/**\") .length==0\n if (File.directory?(diff_folder))\n Dir.rmdir(diff_folder)\n end\n if (File.directory?(@book_update_folder))\n Dir.rmdir(@book_update_folder)\n end \n puts \"No Changes made\"\n exit\n end\nend",
"def copyImgFiles(source, dest, logkey='')\n\tMcmlln::Tools.copyAllFiles(source,dest)\nrescue => logstring\nensure\n Mcmlln::Tools.logtoJson(@log_hash, logkey, logstring)\nend",
"def dir_upload(*paths); net_scp_transfer!(:upload, true, *paths); end",
"def remote_clone\n raise CommandNotImplemented\n end",
"def markSyncOperations\n #N Without this, the sync operations won't be marked\n @sourceContent.markSyncOperationsForDestination(@destinationContent)\n #N Without these puts statements, the user won't receive feedback about what sync operations (i.e. copies and deletes) are marked for execution\n puts \" ================================================ \"\n puts \"After marking for sync --\"\n puts \"\"\n puts \"Local:\"\n #N Without this, the user won't see what local files and directories are marked for copying (i.e. upload)\n @sourceContent.showIndented()\n puts \"\"\n puts \"Remote:\"\n #N Without this, the user won't see what remote files and directories are marked for deleting\n @destinationContent.showIndented()\n end",
"def transfer!\n create_local_directories!\n\n files_to_transfer do |local_file, remote_file|\n Logger.message \"#{storage_name} started transferring '#{ local_file }'.\"\n FileUtils.cp(\n File.join(local_path, local_file),\n File.join(remote_path, remote_file)\n )\n end\n end",
"def transfer!\n Logger.message(\"#{ self.class } started transferring \\\"#{ remote_file }\\\".\")\n create_local_directories!\n FileUtils.cp(\n File.join(local_path, local_file),\n File.join(remote_path, remote_file)\n )\n end",
"def git_clone(remote, dest)\n Dir.chdir(__dir__) do\n system \"git clone #{remote} #{dest}\"\n end\nend",
"def process_github_clones\n repos = get_github_repos_already_cloned\n repos.each do |r|\n # SMELL: does not work if the working copy directory does\n # not match the repo name\n clone_path = configatron.dir + r.name\n set_upstream(clone_path, r.parent.html_url)\n end\nend",
"def move_opt_chef(src, dest)\n converge_by(\"moving all files under #{src} to #{dest}\") do\n FileUtils.rm_rf dest\n raise \"rm_rf of #{dest} failed\" if ::File.exist?(dest) # detect mountpoints that were not deleted\n FileUtils.mv src, dest\n end\nrescue => e\n # this handles mountpoints\n converge_by(\"caught #{e}, falling back to copying and removing from #{src} to #{dest}\") do\n begin\n FileUtils.rm_rf dest\n rescue\n nil\n end # mountpoints can throw EBUSY\n begin\n FileUtils.mkdir dest\n rescue\n nil\n end # mountpoints can throw EBUSY\n FileUtils.cp_r Dir.glob(\"#{src}/*\"), dest\n FileUtils.rm_rf Dir.glob(\"#{src}/*\")\n end\nend",
"def mirror_dirs (source_dir, target_dir)\n # Skip hidden root source dir files by default.\n source_files = Dir.glob File.join(source_dir, '*')\n case RUBY_PLATFORM\n when /linux|darwin/ then\n source_files.each { | source_file | sh 'cp', '-a', source_file, target_dir }\n else\n cp_r source_files, target_dir, :preserve => true\n end\nend",
"def clone_repos(repos, shallow=true)\n repos.each do |repo|\n name = repo['name']\n subtitle \"Cloning #{name}\"\n url = repo['clone_url']\n if File.exist?(name)\n puts 'Already cloned'\n else\n if shallow\n system(\"git\", \"clone\", url, \"--depth\", \"1\", \"--recursive\")\n else\n system(\"git\", \"clone\", url)\n end\n end\n end\nend",
"def local_copy(source, target)\n FileUtils.mkpath(File.dirname(target))\n FileUtils.copy(source, \"#{target}.in_progress\")\n FileUtils.move(\"#{target}.in_progress\", target)\n end"
] | [
"0.7283741",
"0.6752468",
"0.66221154",
"0.6568697",
"0.65367734",
"0.64332926",
"0.634112",
"0.63219005",
"0.62421733",
"0.6190614",
"0.61654466",
"0.61613727",
"0.6137517",
"0.6132605",
"0.61081344",
"0.60579455",
"0.5998268",
"0.5985354",
"0.59164345",
"0.5865034",
"0.5853411",
"0.58426696",
"0.58209383",
"0.58209383",
"0.58069843",
"0.5798186",
"0.5794802",
"0.57585204",
"0.57578766",
"0.5735082",
"0.5711789",
"0.56833166",
"0.5683032",
"0.5673862",
"0.5668252",
"0.566653",
"0.5660161",
"0.56554615",
"0.56552154",
"0.5644477",
"0.5643065",
"0.56394106",
"0.56383973",
"0.5637486",
"0.56198645",
"0.5619757",
"0.5592565",
"0.55914193",
"0.5584485",
"0.55803674",
"0.5577851",
"0.5573613",
"0.5567315",
"0.55558985",
"0.5551028",
"0.55466974",
"0.5544117",
"0.55431855",
"0.55218303",
"0.5493462",
"0.5490113",
"0.5483997",
"0.5475056",
"0.5466775",
"0.54608315",
"0.5457339",
"0.54495466",
"0.5447285",
"0.5444122",
"0.54379606",
"0.5433185",
"0.54236186",
"0.54097193",
"0.53945744",
"0.5382503",
"0.53793705",
"0.5371921",
"0.53536177",
"0.5350481",
"0.5349967",
"0.53499645",
"0.5339885",
"0.5338365",
"0.5335318",
"0.5331923",
"0.53290904",
"0.5328364",
"0.5326544",
"0.5320923",
"0.5318566",
"0.5317029",
"0.5312859",
"0.53097177",
"0.5307066",
"0.52980274",
"0.5296822",
"0.52765876",
"0.5275953",
"0.5269943",
"0.52666503"
] | 0.708499 | 1 |
Do all delete operations, deleting remote directories or files which do not exist at the local location N Without this, there won't be an easy way to execute (or echo if dryrun) all the marked delete operations | def doAllDeleteOperations(dryRun)
#N Without this, the delete operations won't be executed
doDeleteOperations(@destinationContent, dryRun)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def doDeleteOperations(destinationContent, dryRun)\n #N Without this loop, we won't delete all sub-directories or files and directories within sub-directories which have been marked for deletion\n for dir in destinationContent.dirs\n #N Without this check, we would delete directories which have not been marked for deletion (which would be incorrect)\n if dir.toBeDeleted\n #N Without this, we won't know the full path of the remote directory to be deleted\n dirPath = destinationLocation.getFullPath(dir.relativePath)\n #N Without this, the remote directory marked for deletion won't get deleted\n destinationLocation.contentHost.deleteDirectory(dirPath, dryRun)\n else\n #N Without this, files and sub-directories within this sub-directory which are marked for deletion (even though the sub-directory as a whole hasn't been marked for deletion) won't get deleted.\n doDeleteOperations(dir, dryRun)\n end\n end\n #N Without this loop, we won't delete files within this directory which have been marked for deletion.\n for file in destinationContent.files\n #N Without this check, we would delete this file even though it's not marked for deletion (and therefore should not be deleted)\n if file.toBeDeleted\n #N Without this, we won't know the full path of the file to be deleted\n filePath = destinationLocation.getFullPath(file.relativePath)\n #N Without this, the file won't actually get deleted\n destinationLocation.contentHost.deleteFile(filePath, dryRun)\n end\n end\n end",
"def run_on_deletion(paths)\n end",
"def run_on_deletion(paths)\n end",
"def removed_unmarked_paths\n #remove dirs\n dirs_enum = @dirs.each_value\n loop do\n dir_stat = dirs_enum.next rescue break\n if dir_stat.marked\n dir_stat.marked = false # unset flag for next monitoring\\index\\remove phase\n #recursive call\n dir_stat.removed_unmarked_paths\n else\n # directory is not marked. Remove it, since it does not exist.\n write_to_log(\"NON_EXISTING dir: \" + dir_stat.path)\n # remove file with changed checksum\n $local_content_data_lock.synchronize{\n $local_content_data.remove_directory(dir_stat.path, Params['local_server_name'])\n }\n rm_dir(dir_stat)\n end\n end\n\n #remove files\n files_enum = @files.each_value\n loop do\n file_stat = files_enum.next rescue break\n if file_stat.marked\n file_stat.marked = false # unset flag for next monitoring\\index\\remove phase\n else\n # file not marked meaning it is no longer exist. Remove.\n write_to_log(\"NON_EXISTING file: \" + file_stat.path)\n # remove file with changed checksum\n $local_content_data_lock.synchronize{\n $local_content_data.remove_instance(Params['local_server_name'], file_stat.path)\n }\n # remove from tree\n @files.delete(file_stat.path)\n end\n end\n end",
"def delete_operations; end",
"def delete(files)\n # sync before we delete\n sync\n Array.wrap(files).each do |f|\n info \"removing #{f}\"\n FileUtils.rm(f)\n error \"#{f} wasn't removed\" if File.exists?(f)\n end\n end",
"def delete_files()\n\n puts \"Deleting cloud files on all machines...\"\n \n # Create an MCollective client so that we avoid errors that appear\n # when you create more than one client in a short time\n mcc = MCollectiveFilesClient.new(\"files\")\n \n # Delete leader, id, last_id and last_mac files on all machines\n # (leader included)\n mcc.delete_file(CloudLeader::LEADER_FILE) # Leader ID\n mcc.delete_file(CloudLeader::ID_FILE) # ID\n mcc.delete_file(CloudLeader::LAST_ID_FILE) # Last ID\n mcc.delete_file(CloudVM::LAST_MAC_FILE) # Last MAC address\n mcc.disconnect # Now it can be disconnected\n \n # Delete rest of regular files on leader machine\n files = [CloudInfrastructure::DOMAINS_FILE, # Domains file\n \"/tmp/cloud-#{@resource[:name]}\"] # Cloud file\n files.each do |file|\n if File.exists?(file)\n File.delete(file)\n else\n puts \"File #{file} does not exist\"\n end\n end\n\n end",
"def flush_deletes\n @filesystem.flush_deletes\n begin\n @alt_storage.flush_deletes\n rescue Excon::Errors::Error => e\n log(\"There was an unexpected error while deleting file from alternate storage: #{e}\")\n end\n @queued_for_delete = []\n end",
"def flush_deletes\n @queued_for_delete.each do |path|\n client.delete_object(path) if client.object_exists?(path)\n end\n @queue_for_delete = []\n end",
"def flush_deletes\n @queued_for_delete.each do |path|\n Paperclip.log(\"Delete: #{ path }\")\n file_id = search_for_title(path)\n google_api_client.delete_file(file_id) unless file_id.nil?\n end\n @queued_for_delete = []\n end",
"def clean_remote\n to_delete = remote_assets - local_compiled_assets\n to_delete.each do |f|\n delete_remote_asset(bucket.files.get(f))\n end\n end",
"def destroy(paths)\n\t\tlogin_filter\n\t\tpaths = [paths].flatten\n\t\tpaths = paths.collect { |path| namespace_path(path) }\n\t\[email protected](\"/cmd/delete\", {\"files\"=> paths, \"t\" => @token }).code == \"200\"\n\tend",
"def clean_remote!\n resp = @connection.get_bucket(\n @storage.bucket, prefix: File.dirname(@remote_path)\n )\n keys = resp.body['Contents'].map {|item| item['Key'] }\n\n @connection.delete_multiple_objects(@storage.bucket, keys) unless keys.empty?\n end",
"def flush_deletes\n @filesystem.flush_deletes\n begin\n @fog.flush_deletes\n rescue Excon::Errors::Error => e\n log(\"There was an unexpected error while deleting file from fog: #{e}\")\n end\n @queued_for_delete = []\n end",
"def define_deleted local, remote\n to_delete = remote.select do |a| \n local.all? { |s| s.path != a.path } \n end\n\n to_delete.reject{|a| a.path.to_s =~ /.html$/ }.to_a\n end",
"def call\n return log_info(\"Nothing to delete; exiting.\") if digests.none?\n\n log_info(\"Deleting batch with #{digests.size} digests\")\n return batch_delete(conn) if conn\n\n redis { |rcon| batch_delete(rcon) }\n end",
"def delete_all_files\n @import.delete_all_files\n head :no_content\n end",
"def delete_files(*files)\n files = files.flatten\n unless files.empty?\n @perforce.run(\"delete\", \"-c\", @number, *files)\n end\n end",
"def delete_files(filenames)\n filenames.each do |filename|\n shell.assert(docker_exec(\"rm #{sandbox_dir}/#{filename}\"))\n end\n end",
"def delete_files(files)\n not_found = []\n files.each do |file|\n file_stored = Files.where({ '_id' => file[:uuid]}).first\n if file_stored.nil?\n logger.error 'File not found ' + file.to_s\n not_found << file\n else\n if file_stored['pkg_ref'] == 1\n # Referenced only once. Delete in this case\n file_stored.destroy\n del_ent_dict(file_stored, :files)\n file_md5 = Files.where('md5' => file_stored['md5'])\n if file_md5.size.to_i.zero?\n # Remove files from grid\n grid_fs = Mongoid::GridFs\n grid_fs.delete(file_stored['grid_fs_id'])\n end\n else\n # Referenced above once. Decrease counter\n file_stored.update_attributes(pkg_ref: file_stored['pkg_ref'] - 1)\n end\n # file_stored.destroy\n # del_ent_dict(file_stored, :files)\n #\n # # Remove files from grid\n # grid_fs = Mongoid::GridFs\n # grid_fs.delete(file_stored['grid_fs_id'])\n end\n end\n not_found\n end",
"def delete(command)\n pp @client.files.delete(clean_up(command[1]))\n end",
"def remove_superfluous_destination_files\n # join mirror_file and dest_file and delete everything from dest_file which isn't in mirror_file\n # because mirror_file should represent the current state of the source mogile files\n Log.instance.info('Joining destination and mirror tables to determine files that have been deleted from source repo.')\n DestFile.where('mirror_file.dkey IS NULL').joins('LEFT OUTER JOIN mirror_file ON mirror_file.dkey = file.dkey').find_in_batches(batch_size: 1000) do |batch|\n batch.each do |file|\n # Quit if program exit has been requested.\n break if SignalHandler.instance.should_quit\n\n # Delete all files from our destination domain which no longer exist in the source domain.\n begin\n Log.instance.debug(\"key [ #{file.dkey} ] should not exist. Deleting.\")\n @dest_mogile.delete(file.dkey)\n @removed += 1\n @freed_bytes += file.length\n rescue => e\n @failed += 1\n Log.instance.error(\"Error deleting [ #{file.dkey} ]: #{e.message}\\n#{e.backtrace}\")\n end\n end\n\n # Print a summary to the user.\n summarize\n\n # Quit if program exit has been requested.\n return true if SignalHandler.instance.should_quit\n end\n end",
"def delete_logic( defer = false, mask_exceptions = true )\n if defer\n database.add_to_bulk_cache( { '_id' => self['_id'], '_rev' => rev, '_deleted' => true } )\n else\n begin\n delete_now\n rescue Exception => e\n if mask_exceptions || e.class == CouchDB::ResourceNotFound\n false\n else \n raise e\n end \n end \n end \n end",
"def delete\n stop\n [ @resource['instances_dir'] + \"/\" + @resource[:name],\n @resource['instances_dir'] + \"/\" + \"_\" + @resource[:name]\n ].each do |dir|\n FileUtils.rm_rf(dir) if File.directory?(dir)\n end\n end",
"def purge\n self.files.each do |f|\n f.destroy\n end\n self.commits.each do |c|\n c.destroy\n end\n end",
"def remove!\n messages = []\n transferred_files do |local_file, remote_file|\n messages << \"#{storage_name} started removing '#{ local_file }'.\"\n end\n Logger.message messages.join(\"\\n\")\n\n FileUtils.rm_r(remote_path)\n end",
"def delete_source_files source\n dir = Conf::directories\n base = File.join(dir.data)\n source.folders.each do |fold|\n url = File.join(dir.store,source.name.to_s,fold)\n delete_files_from url\n url = File.join(dir.backup,source.name.to_s,fold)\n delete_files_from url\n end\n Logger.<<(__FILE__,\"INFO\",\"Deleted files server & backup for #{source.name.to_s}\")\n end",
"def delete!(defer = false)\n delete_logic( defer, false ) \n end",
"def delete_directories account\n # Use FileUtils\n fu = FileUtils\n # If we're just running as a simulation\n if $simulate\n # Use ::DryRun, that just echoes the commands, instead of the normal FileUtils\n fu = FileUtils::DryRun # ::DryRun / ::NoWrite\n end\n \n # Tell the user\n puts \"> Tar bort kontot från filsystemet\".green\n\n # Build the paths\n mail_dir = BASE_PATH_MAIL + account['mail']\n home_dir = BASE_PATH_HOME + account['home']\n\n # Remove the directories\n fu.rm_r mail_dir\n fu.rm_r home_dir\nend",
"def delete_files(uuids)\n Uploadcare::FileList.batch_delete(uuids)\n end",
"def delete(*uris); end",
"def purge(paths)\n\t\tlogin_filter\n\t\tpaths = [paths].flatten\n\t\tpaths = paths.collect { |path| namespace_path(path) }\n\t\[email protected](\"/cmd/purge\", {\"files\"=> paths, \"t\" => @token }).code == \"200\"\n\tend",
"def delete_all_checkout\n return unless has_all_delete_link?(wait: TimeOut::WAIT_MID_CONST)\n\n num_of_link = all_delete_link.count\n num_of_link.times do\n delete_link.click\n end\n end",
"def clear_remote\n execute(:rm, '-rf', File.join(remote_cache_path, '*')) if test!(\"[ -d #{remote_cache_path} ]\")\n end",
"def delete(delete_files=true)\n if delete_files\n Bplmodels::File.find_in_batches('is_file_of_ssim'=>\"info:fedora/#{self.pid}\") do |group|\n group.each { |solr_file|\n file = Bplmodels::File.find(solr_file['id']).adapt_to_cmodel\n file.delete\n }\n end\n end\n\n #FIXME: What if this is interuppted? Need to do this better...\n #Broken so no match for now\n if self.class.name == \"Bplmodels::Volume2\"\n next_object = nil\n previous_object = nil\n #volume_object = Bplmodels::Finder.getVolumeObjects(self.pid)\n self.relationships.each_statement do |statement|\n puts statement.predicate\n if statement.predicate == \"http://projecthydra.org/ns/relations#isPrecedingVolumeOf\"\n next_object = ActiveFedora::Base.find(statement.object.to_s.split('/').last).adapt_to_cmodel\n elsif statement.predicate == \"http://projecthydra.org/ns/relations#isFollowingVolumeOf\"\n previous_object = ActiveFedora::Base.find(statement.object.to_s.split('/').last).adapt_to_cmodel\n end\n end\n\n if next_object.present? and previous_object.present?\n next_object.relationships.each_statement do |statement|\n if statement.predicate == \"http://projecthydra.org/ns/relations#isFollowingVolumeOf\"\n next_object.remove_relationship(:is_following_volume_of, statement.object)\n end\n end\n\n previous_object.relationships.each_statement do |statement|\n if statement.predicate == \"http://projecthydra.org/ns/relations#isPrecedingVolumeOf\"\n previous_object.remove_relationship(:is_preceding_volume_of, statement.object)\n end\n end\n\n next_object.add_relationship(:is_following_volume_of, \"info:fedora/#{previous_object.pid}\", true)\n previous_object.add_relationship(:is_preceding_volume_of, \"info:fedora/#{next_object.pid}\", true)\n next_object.save\n previous_object.save\n elsif next_object.present? and previous_object.blank?\n next_object.relationships.each_statement do |statement|\n if statement.predicate == \"http://projecthydra.org/ns/relations#isFollowingVolumeOf\"\n next_object.remove_relationship(:is_following_volume_of, statement.object)\n end\n end\n\n elsif next_object.blank? and previous_object.present?\n previous_object.relationships.each_statement do |statement|\n if statement.predicate == \"http://projecthydra.org/ns/relations#isPrecedingVolumeOf\"\n previous_object.remove_relationship(:is_preceding_volume_of, statement.object)\n end\n end\n end\n self.collection.first.update_index\n end\n # remove the cached IIIF manifest (may not exist, so no worry about response)\n unless self.class.name == 'Bplmodels::OAIObject'\n Typhoeus::Request.post(\"#{BPL_CONFIG_GLOBAL['commonwealth_public']}/search/#{self.pid}/manifest/cache_invalidate\")\n end\n super()\n end",
"def delete(*args)\n execute(:delete, *args)\n end",
"def file_delete(node, file)\n _out, _local, _remote, code = node.test_and_store_results_together(\"rm #{file}\", 'root', 500)\n code\nend",
"def file_delete(node, file)\n _out, _local, _remote, code = node.test_and_store_results_together(\"rm #{file}\", 'root', 500)\n code\nend",
"def clean()\n rels = releases()\n rels.pop()\n\n unless rels.empty?\n rm = ['rm', '-rf'].concat(rels.map {|r| release_dir(r)})\n rm << release_dir('skip-*')\n cmd.ssh(rm)\n end\n end",
"def nfs_prune(valid_ids)\n end",
"def delete_all\n Neo.db.execute_query(\"#{initial_match} OPTIONAL MATCH (n0)-[r]-() DELETE n0,r\")\n end",
"def clean_debris \n objdirs = File.join(\"**/\", \"obj\")\n userfiles = File.join(\"**/\", \"*.vcxproj.user\")\n\n delete_list = FileList.new(objdirs, userfiles)\n delete_list.each do |file|\n puts \"Removing #{file}\"\n FileUtils.rm_rf(\"#{file}\")\n end\nend",
"def clean_debris \n objdirs = File.join(\"**/\", \"obj\")\n userfiles = File.join(\"**/\", \"*.vcxproj.user\")\n\n delete_list = FileList.new(objdirs, userfiles)\n delete_list.each do |file|\n puts \"Removing #{file}\"\n FileUtils.rm_rf(\"#{file}\")\n end\nend",
"def delete_all_servers\n super\n end",
"def delete(*wildcards)\n wildcards.each do |wildcard|\n Dir[wildcard].each do |fn|\n if File.directory?(fn)\n log \"Deleting directory #{fn}\"\n Dir.delete(fn)\n else\n log \"Deleting file #{fn}\"\n File.delete(fn)\n end\n end\n end\n end",
"def delete(*wildcards)\n wildcards.each do |wildcard|\n Dir[wildcard].each do |fn|\n if File.directory?(fn)\n log \"Deleting directory #{fn}\"\n Dir.delete(fn)\n else\n log \"Deleting file #{fn}\"\n File.delete(fn)\n end\n end\n end\n end",
"def delete_all\n target.clear\n end",
"def delete_objects(resource, ids)\n records = resource.find(ids)\n ActiveRecord::Base.transaction do\n records.each(&:destroy)\n end\n end",
"def deleteT(dir1, dir2)\n\t\tFileUtils.rm_rf Dir.glob(\"#{dir1}*\")\n\t\tFileUtils.rm_rf Dir.glob(\"#{dir2}*\")\n\tend",
"def cleanup\n\n # ----------------------------------------------\n account_name = 'your account name' # <-- change this!\n project_name = 'your project name' # <-- change this!\n # ----------------------------------------------\n\n project_dir = \"/home/#{account_name}/www\"\n Dir.chdir(project_dir)\n\n Dir.entries(project_name).select do |entry1|\n\n dir1 = File.join(project_name,entry1) #dir2 = \"#{project_name}/#{entry1}\"\n if is_directory?(dir1)\n Dir.entries(dir1).select do |entry2|\n \n dir2 = File.join(dir1,entry2) #dir2 = \"#{project_name}/#{entry1}/#{entry2}\"\n if is_directory?(dir2)\n Dir.entries(dir2).select do |entry3|\n \n dir3 = File.join(dir2,entry3) #dir3 = \"#{project_name}/#{entry1}/#{entry2}/#{entry3}\"\n if is_directory?(dir3)\n Dir.entries(dir3).select do |entry4|\n delete_file(File.join(dir3,entry4))\n end\n end\n\n delete_file(dir3)\n delete_dir(dir3)\n end\n end\n\n delete_file(dir2)\n delete_dir(dir2)\n end\n end\n\n delete_file(dir1)\n delete_dir(dir1)\n end\n\n delete_dir(project_name)\nend",
"def delete\n Iterable.request(conf, base_path).delete\n end",
"def delete_all(name); end",
"def remove_files\n @batch.each_open_file_path do |path|\n 3.times do |i| \n begin \n File.unlink(path)\n break \n rescue Errno::EACCES # sometimes windows does not like this. let's wait and retry.\n sleep(1) # just in case it's open by something else..\n next unless i == 2 \n $stderr.puts \"Cannot remove #{path}...giving up.\"\n end \n end\n end\n end",
"def delete_from_disk; end",
"def delete_remote?\n true\n end",
"def delete_tables\n delete_characters\n delete_kiosks\n delete_traps\n delete_buttons\n end",
"def safe_destroy(name)\n # More conservative: Create a list of related resources to delete.\n # The downside is that if a root resource has already been deleted,\n # (like a DNS record) we won't find the formerly dependent records.\n\n flat_list = Lister.new(debug: @debug, availability_zone: @availability_zone)\n .list(name, true)\n\n flat_list[:groups].each do |group_name|\n delete_group_policy(group_name) rescue LOGGER.warn(\"Error deleting policy: #{$!} at #{$@}\")\n LOGGER.info(\"Deleted policy #{group_name}\")\n delete_group(group_name) rescue LOGGER.warn(\"Error deleting group: #{$!} at #{$@}\")\n LOGGER.info(\"Deleted group #{group_name}\")\n end\n flat_list.delete(:groups)\n\n flat_list[:key_names].each do |key_name|\n delete_key(key_name) rescue LOGGER.warn(\"Error deleting PK: #{$!} at #{$@}\")\n LOGGER.info(\"Deleted PK #{key_name}\")\n end\n flat_list.delete(:key_names)\n\n terminate_instances_by_id(flat_list[:instance_ids]) rescue LOGGER.warn(\"Error terminating EC2 instances: #{$!} at #{$@}\")\n LOGGER.info(\"Terminated EC2 instances #{flat_list[:instance_ids]}\")\n flat_list.delete(:instance_ids)\n flat_list.delete(:volume_ids) # Volumes are set to disappear with their instance.\n\n delete_dns_cname_records(dns_zone(name), flat_list[:cnames]) rescue LOGGER.warn(\"Error deleting CNAMEs: #{$!} at #{$@}\")\n LOGGER.info(\"Deleted CNAMEs #{flat_list[:cnames]}\")\n flat_list.delete(:cnames)\n\n flat_list.keys.tap do |forgot|\n fail(\"Still need to clean up #{forgot}\") unless forgot.empty?\n end\n end",
"def delete(*filenames); end",
"def bulk_delete(list)\n\t\tputs \"Delete entries to the local host repository from:\\n #{list}\"\n\t\thosts=list\n\t\tchanges=Array.new\n\t\tif hosts.size > 0\n\t\t\thosts.map do |x|\n\t\t\t\thost=delete(x)\n\t\t\t\tchanges.push(host) unless host.nil?\n\t\t\tend\n\t\t\tputs \"Done deleting hosts.\"\n\t\t\treturn changes\n\t\telse\n\t\t\tputs \"Error: empty list - no entry is loaded. Please check your list and try again.\"\n\t\tend\n\trescue => ee\n\t\tputs \"Exception on method #{__method__}: #{ee}\"\n\tend",
"def remove_empty_directories\n base_paths.each do |path|\n command = <<-CMD\n for directory in $(find #{path} -type d); do\n if [ ! -d $directory ]; then\n echo \"Can't find directory $directory, it was probably already deleted, skipping . . .\"\n continue\n fi\n files=$(find $directory -type f)\n if [ -z \"$files\" ]; then\n echo \"No files in directory $directory, deleting . . .\"\n sudo rm -rf $directory\n fi\n done\n CMD\n Pkg::Util::Net.remote_execute(Pkg::Config.staging_server, command)\n end\n end",
"def delete_files\n self.bruse_files.each do |file|\n file.destroy\n end\n end",
"def delete_all(*wildcards)\n wildcards.each do |wildcard|\n Dir[wildcard].each do |fn|\n next if ! File.exist?(fn)\n if File.directory?(fn)\n Dir[\"#{fn}/*\"].each do |subfn|\n next if subfn=='.' || subfn=='..'\n delete_all(subfn)\n end\n log \"Deleting directory #{fn}\"\n Dir.delete(fn)\n else\n log \"Deleting file #{fn}\"\n File.delete(fn)\n end\n end\n end\n end",
"def delete_all(*wildcards)\n wildcards.each do |wildcard|\n Dir[wildcard].each do |fn|\n next if ! File.exist?(fn)\n if File.directory?(fn)\n Dir[\"#{fn}/*\"].each do |subfn|\n next if subfn=='.' || subfn=='..'\n delete_all(subfn)\n end\n log \"Deleting directory #{fn}\"\n Dir.delete(fn)\n else\n log \"Deleting file #{fn}\"\n File.delete(fn)\n end\n end\n end\n end",
"def cleanup_nontarget_files\n\n delete_dir = File.expand_path(File.join(app.build_dir, 'Resources/', 'Base.lproj/', 'assets/', 'images/'))\n\n puts_blue \"Cleaning up excess image files from target '#{options.Target}'\"\n puts_red \"Images for the following targets are being deleted from the build directory:\"\n\n (options.Targets.keys - [options.Target]).each do |target|\n\n puts_red \"#{target.to_s}\"\n Dir.glob(\"#{delete_dir}/**/#{target}-*.{jpg,png,gif}\").each do |f|\n puts_red \" Deleting #{File.basename(f)}\"\n File.delete(f)\n end\n end\n\n puts_red \"\\nImages prefixed all- are being deleted if a corresponding #{options.Target}- exists.\"\n\n Dir.glob(\"#{delete_dir}/**/all-*.{jpg,png,gif}\").each do |f|\n if File.exist?( f.sub(\"all-\", \"#{options.Target}-\") )\n puts_red \" Deleting #{File.basename(f)}\"\n File.delete(f)\n end\n end\n\n\n end",
"def batch_delete(uuids)\n body = uuids.to_json\n request_delete(uri: '/files/storage/', content: body)\n end",
"def cleanUpWorkingFiles()\n system(\"rm -f #{@tripFile} #{routeFile} #{routeAltFile}\") ;\n end",
"def update_remotely_deleted(file, node)\n #\n if node != ancestor.file_node(file) && !overwrite?\n if UI.ask(\"local changed #{file} which remote deleted\\n\" +\n \"use (c)hanged version or (d)elete?\") == \"d\"\n then remove file\n else add file\n end\n else\n remove file\n end\n end",
"def delete(defer = false)\n delete_logic( defer )\n end",
"def run_on_removals(paths)\n paths = paths.select {|path| not options[:exclude] =~ path and File.file? path}\n\n directories = detect_nested_directories(watchers, paths, options)\n removed = []\n\n directories.each do |directory, files|\n files.each do |file|\n begin\n File.delete file\n removed << file\n rescue Error::ENOENT\n # Ignore\n end\n end\n end\n if removed.length > 0\n notify(removed, \"REMOVED\")\n end\n end",
"def host_delete_all(hosts = @hosts_delta)\n hosts.each do |host|\n host_delete(host)\n unmanage_host(host)\n end\n end",
"def delete_all\n sum(&:delete_all)\n end",
"def delete_all!\n delete(query: \"*:*\")\n end",
"def files_remote_remove(options = {})\n post('files.remote.remove', options)\n end",
"def cleanup_created_resources\n # Avoid the use of any short circuiting folds.\n cleanup_commands.reverse.inject(true) { |accum, x| accum && x.cleanup }\n end",
"def delete_all_targets\n\t\tTarget.delete_all\n\tend",
"def action_delete\n if @current_resource.exist?\n converge_by \"Delete #{r.path}\" do\n backup unless ::File.symlink?(r.path)\n ::File.delete(r.path)\n end\n r.updated_by_last_action(true)\n load_new_resource_state\n r.exist = false\n else\n Chef::Log.debug \"#{r.path} does not exists - nothing to do\"\n end\n end",
"def cleanup\n case SubutaiConfig.provider\n when :hyper_v\n SubutaiDisk.hyperv_remove_disk\n end\n\n # cleanup virtual disks\n disks = SubutaiConfig.get(:_DISK_PATHES)\n unless disks.nil?\n disks.keys.each do |key|\n if File.exist?(disks[key])\n begin\n File.delete(disks[key])\n puts \"==> default: Deleted file: #{disks[key]}\"\n rescue Errno::EACCES\n puts \"==> default: (Permission denied) Failed delete file: #{disks[key]}\"\n end\n end\n end\n end\n\n # cleanup generated files\n if File.exist?(SubutaiConfig::GENERATED_FILE)\n begin\n File.delete SubutaiConfig::GENERATED_FILE\n puts \"==> default: Deleted file: #{SubutaiConfig::GENERATED_FILE}\"\n rescue Errno::EACCES\n puts \"==> default: (Permission denied) Failed delete file: #{SubutaiConfig::GENERATED_FILE}\"\n end\n end\n end",
"def erase\n HDB.verbose and puts \"Erasing successfully-copied files\"\n unlinkable = @files.collect do |x|\n f = get_real_filename(x)\n File.directory?(f) or File.symlink?(f)\n end\n # TODO: unlink them now.\n # TODO: rmdir directories, starting with child nodes first\n raise \"erase unimplemented\"\n end",
"def perform\n ActiveRecord::Base.transaction do\n reply.update(deleted: true)\n reply.taggings.delete_all\n reply.mentionings.delete_all\n end\n end",
"def delete current_user\n raise RequestError.new(:internal_error, \"Delete: no user specified\") if current_user.nil?\n\n # remove all its files\n self.files.each { |item| item.delete current_user }\n # remove all its children, meaning all its subdirectories. (all sub-sub-directories and sub-files will me removed as well)\n self.childrens.each { |children| children.delete current_user }\n\n if current_user.id != self.user_id then # if random owner \n # remove all links between this folder and the current user only\n FileUserAssociation.all(x_file_id: self.id, user_id: current_user.id).destroy!\n # remove all associations where this folder is a children of a folder belonging to the current user only\n FolderFolderAssociation.all(children_id: self.id).each do |asso|\n asso.destroy! if current_user.x_files.get(asso.parent_id)\n end\n # No sharing for folders: no SharedToMeAssociations\n\n else # if true owner \n # remove all links between this folder and ALL users\n FileUserAssociation.all(x_file_id: self.id).destroy!\n # remove all associations where this folder is a children of a folder belonging ALL users\n FolderFolderAssociation.all(children_id: self.id).destroy!\n # No sharing for folders: no SharedByMeAssociations\n\n # No need to remove the association where this folder is a parent (of a file or folder)\n # because the children have already been removed and all theirs associations\n #\n # FolderFolderAssociation.all(parent_id: self.id).destroy!\n # FileFolderAssociation.all(parent_id: self.id).destroy!\n \n # now remove the entity\n self.destroy!\n end\n end",
"def delete_all\n @objects.each do |o|\n o.delete \n end\n\n @objects.clear\n end",
"def delete_features_from_hiptest\n puts \"\\nStart deleting...\"\n children_folders_of_root = get_children_folders $root_folder_id\n\n # Delete features from root subfolders\n children_folders_of_root.each do |folder|\n status = delete_folder_children_request folder['id']\n\n if status == 200.to_s\n puts \"Features from '#{folder['attributes']['name']}' folder deleted.\"\n end\n end\n\n # Delete folders from root subfolder\n status = delete_folder_children_request $root_folder_id\n\n if status == 200.to_s\n puts \"Folders from root folder deleted.\"\n end\nend",
"def test_iterative_delete\n @partition_manager.drop_old_partitions('comments')\n assert_equal 4, @call_count, 'The first drop call should purge 4 tables'\n @partition_manager.drop_old_partitions('comments')\n assert_equal 7, @call_count, 'The second drop call should purge the remaining 3 tables'\n end",
"def remove_folder\n space = Space.accessible_by(@context).find(params[:id])\n ids = Node.sin_comparison_inputs(unsafe_params[:ids])\n\n if space.contributor_permission(@context)\n nodes = Node.accessible_by(@context).where(id: ids)\n\n UserFile.transaction do\n nodes.update(state: UserFile::STATE_REMOVING)\n\n nodes.where(sti_type: \"Folder\").find_each do |folder|\n folder.all_children.each { |node| node.update!(state: UserFile::STATE_REMOVING) }\n end\n\n Array(nodes.pluck(:id)).in_groups_of(1000, false) do |ids|\n job_args = ids.map do |node_id|\n [node_id, session_auth_params]\n end\n\n Sidekiq::Client.push_bulk(\"class\" => RemoveNodeWorker, \"args\" => job_args)\n end\n end\n\n flash[:success] = \"Object(s) are being removed. This could take a while.\"\n else\n flash[:warning] = \"You have no permission to remove object(s).\"\n end\n\n redirect_to files_space_path(space)\n end",
"def delete_all_virtual_servers\n super\n end",
"def postSync(options = {})\n deleteLocalDataDir(options)\n end",
"def run_on_removals(paths)\n paths.each do |path|\n warn \"file #{path} removed -- it's up to you to remove it from the server if desired\"\n end\n end",
"def delete_existing\n Answer.delete_all\n Question.delete_all\n Knock.delete_all\n Door.delete_all\n Canvasser.delete_all\nend",
"def delete\n \n end",
"def cleanup\n _send_command(\"hosts -d\")\n _send_command(\"services -d\")\n _send_command(\"creds -d\")\n end",
"def delete_all\n delete_if { |b| true }\n end",
"def remove_all_vrfs\n require_relative '../lib/cisco_node_utils/vrf'\n Vrf.vrfs.each do |vrf, obj|\n next if vrf[/management/]\n # TBD: Remove vrf workaround below after CSCuz56697 is resolved\n config 'vrf context ' + vrf if\n node.product_id[/N9K.*-F/] || node.product_id[/N3K.*-F/]\n obj.destroy\n end\n end",
"def delete!\n uniq.bulk_job { |e| e.delete! }\n end",
"def delete_all repos\n unless repos\n raise \"required repository name\"\n end\n repos = @login + '/' + repos unless repos.include? '/'\n list_files(repos).each { |obj|\n delete repos, obj[:id]\n }\n end",
"def destroy_all\n proxy_target.each { |object| object.destroy }\n end",
"def delete_all_uploaded_images\n images_dir = FileUploader.file_dir('article', id)\n FileUtils.rm_rf(images_dir) if File.directory?(images_dir)\n end",
"def atomic_delete_modifier\n atomic_paths.delete_modifier\n end",
"def delete\n if options.master?\n delete_master(options)\n elsif options.slave?\n delete_slave(options)\n else\n invoke :help, [:delete]\n end\n end",
"def nuclear_option!\n query(\"MATCH (n) DETACH DELETE n\")\n end",
"def delete_packages\n return unless ask_confirmation\n\n delete_libvirt_pool\n delete_vagrant_plugins\n delete_terraform\n @dependency_manager.delete_dependencies\n end"
] | [
"0.7090771",
"0.64503205",
"0.64503205",
"0.6418074",
"0.63471127",
"0.6290854",
"0.6214927",
"0.6102063",
"0.60533196",
"0.6006432",
"0.600104",
"0.59897316",
"0.5942545",
"0.5941058",
"0.5897734",
"0.58603173",
"0.58548325",
"0.57968813",
"0.5748876",
"0.5741464",
"0.5731832",
"0.57253224",
"0.57080394",
"0.5703471",
"0.5693496",
"0.56932425",
"0.568476",
"0.56738883",
"0.56719124",
"0.56696737",
"0.5664294",
"0.5658645",
"0.5653748",
"0.56518215",
"0.564635",
"0.5637403",
"0.5635202",
"0.5635202",
"0.5632838",
"0.56318575",
"0.56038",
"0.5602915",
"0.5602915",
"0.55981785",
"0.5593568",
"0.5593568",
"0.5574885",
"0.557401",
"0.5570554",
"0.5561076",
"0.55572563",
"0.55482423",
"0.5545748",
"0.55450624",
"0.55436516",
"0.55391896",
"0.55249536",
"0.55233866",
"0.5511693",
"0.550626",
"0.5503255",
"0.54949635",
"0.54949635",
"0.5493872",
"0.5493616",
"0.5493081",
"0.54847014",
"0.5463512",
"0.5456772",
"0.5450332",
"0.5443207",
"0.54406524",
"0.54326546",
"0.5421673",
"0.5420177",
"0.5416063",
"0.54142904",
"0.541134",
"0.5406427",
"0.540146",
"0.54005754",
"0.53979075",
"0.5395055",
"0.53916955",
"0.5390553",
"0.53885233",
"0.53846663",
"0.53840256",
"0.538339",
"0.5382727",
"0.53753316",
"0.53722405",
"0.5370649",
"0.536867",
"0.53683424",
"0.5366855",
"0.5365532",
"0.5360323",
"0.5355401",
"0.5352888"
] | 0.7338213 | 0 |
Execute a (local) command, or, if dryRun, just pretend to execute it. Raise an exception if the process exit status is not 0. N Without this, there won't be an easy way to execute a local command, echoing it to the user, and optionally _not_ executing it if "dry run" is specified | def executeCommand(command, dryRun)
#N Without this, the command won't be echoed to the user
puts "EXECUTE: #{command}"
#N Without this check, the command will be executed, even though it is intended to be a dry run
if not dryRun
#N Without this, the command won't be executed (when it's not a dry run)
system(command)
#N Without this, a command that fails with error will be assumed to have completed successfully (which will result in incorrect assumptions in some cases about what has changed as a result of the command, e.g. apparently successful execution of sync commands would result in the assumption that the remote directory now matches the local directory)
checkProcessStatus(command)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def executeCommand(command, dryRun)\n #N Without this, the command won't be echoed\n puts \"EXECUTE: #{command}\"\n #N Without this check, the command will be executed even if it is meant to be a dry run\n if not dryRun\n #N Without this, the command won't actualy be execute even when it is meant to be run\n system(command)\n #N Without this check, a failed command will be treated as if it had executed successfully\n checkProcessStatus(command)\n end\n end",
"def execute!\n if Mcir::Core.instance.dryrun?\n Mcir::Core.instance.debug(\"CMD: \".purple << \"#{self.to_s.gsub(\"\\r\", \"\")}\")\n \"skipped execution due to dryrun\"\n else\n case @mode\n when :exec then exec(self.to_s)\n when :open then IO.new(self).open3\n when :capture then IO.new(self).capture3\n when :backticks then IO.new(self).backtick\n end\n end\n end",
"def run_locally(cmd)\n if dry_run\n return logger.debug \"executing locally: #{cmd.inspect}\"\n end\n logger.trace \"executing locally: #{cmd.inspect}\" if logger\n output_on_stdout = nil\n elapsed = Benchmark.realtime do\n output_on_stdout = `#{cmd}`\n end\n if $?.to_i > 0 # $? is command exit code (posix style)\n raise Capistrano::LocalArgumentError, \"Command #{cmd} returned status code #{$?}\"\n end\n logger.trace \"command finished in #{(elapsed * 1000).round}ms\" if logger\n output_on_stdout\n end",
"def exec_local(opts = {})\n sh = Mixlib::ShellOut.new(\"#{@cmd}\")\n sh.timeout = 60 * 60 * 24 # 24hours\n sh.run_command\n\n @result = ShellCommandResult.new(@cmd, sh.stdout, sh.stderr, sh.exitstatus.to_i)\n\n raise_error! if opts[:abort_on_error]\n\n return @result\n end",
"def run_command cmd, silent=false\n puts \"Running command: #{cmd}\" unless silent\n\n if silent\n `#{cmd}`\n else\n puts `#{cmd}`\n end\n\n return true if $?.exitstatus == 0\n\n puts \"Error running command '#{cmd}'\" unless silent\n false\nend",
"def run\n raise \"`#{ real_command }' failed\" unless Kernel.system( real_command )\n end",
"def execute(command, params={})\n unless params[:dry_run]\n if params[:return]\n System.execute(command, :return => true)\n else\n $stdout.puts\n System.execute(command)\n end\n end\n end",
"def run_local(cmd)\n require 'English'\n\n system cmd\n return unless $CHILD_STATUS.exitstatus != 0\n\n puts 'exit code: ' + $CHILD_STATUS.exitstatus.to_s\n abort('Shell command failed, assuming you want to abort'.foreground(:red))\nend",
"def execute_command!(*argv)\n execute_command(argv)\n raise Error.new(\"Command failed!\") unless $?.success?\n end",
"def run_or_fail(cmd, redact: nil)\n put_command(cmd, redact: redact)\n Open3.popen3(*cmd) do |i, o, e, t|\n i.close\n if not t.value.success?\n STDERR.write red_term_text(e.read)\n exit t.value.exitstatus\n end\n end\n end",
"def sh(command)\n puts command\n system command unless dry_run\nend",
"def execute_command(*argv)\n command = argv.flatten.reject(&:blank?).join(\" \\\\\\n \")\n if settings[:dry_run]\n log.info(\"Dry run:\")\n puts command\n else\n output = `#{command}`\n puts output unless output.empty?\n end\n end",
"def try_to_run(command, verbose = false)\n r = system \"#{command}\";\n return r if r;\n $stderr.puts \"Process '#{command}' exited with #{$?.exitstatus}\"\n exit ($?.exitstatus)\nend",
"def run_locally(cmd)\n logger.trace \"executing locally: #{cmd.inspect}\" if logger\n output_on_stdout = nil\n elapsed = Benchmark.realtime do\n output_on_stdout = `#{cmd}`\n end\n if $?.to_i > 0 # $? is command exit code (posix style)\n raise Capistrano::LocalArgumentError, \"Command #{cmd} returned status code #{$?}\"\n end\n logger.trace \"command finished in #{(elapsed * 1000).round}ms\" if logger\n output_on_stdout\n end",
"def execute_command(cmd, verbose = true)\n puts \"Executing: #{cmd}\" if verbose\n cmd += \" > /dev/null 2>&1\" if verbose\n %x[#{cmd}]\n success = $?.success?\n puts success if verbose\n success\n end",
"def exec!(command, input = nil)\n result = exec command, input\n return result.stdout if result.succeeded?\n \n raise \"exec! command exited with non-zero code #{result.exit_code}\"\n end",
"def run_locally(cmd)\n logger.trace \"executing locally: #{cmd.inspect}\" if logger\n output_on_stdout = nil\n elapsed = Benchmark.realtime do\n output_on_stdout = `#{cmd}`\n end\n if $?.to_i > 0 # $? is command exit code (posix style)\n raise Capistrano::LocalArgumentError, \"Command #{cmd} returned status code #{$?}\"\n end\n logger.trace \"command finished in #{(elapsed * 1000).round}ms\" if logger\n output_on_stdout\n end",
"def normaldo *args\n Kitchenplan::Log.info(*args)\n raise RuntimeError,\"'#{args}' returned non-zero\" unless system(*args)\n end",
"def run_local(cmd)\n require 'English'\n\n system cmd\n return unless $CHILD_STATUS.exitstatus != 0\n puts 'exit code: ' + $CHILD_STATUS.exitstatus.to_s\n exit\nend",
"def exec!(cmd, options={})\n exit_status, stdout, stderr, cmd = exec(cmd, options)\n error_msg = options[:error_msg] || \"The following command exited with an error\"\n raise Appd::RemoteError.new(stdout, stderr, exit_status, cmd), error_msg if exit_status != 0\n return stdout\n end",
"def run(*args, verbose: true)\n pretty_command = prettify_command(*args)\n puts(\" $ #{pretty_command}\") if verbose\n unless system(*args)\n raise Exception.new(\"Could not execute `#{pretty_command}`, status nil\") if $?.nil?\n status = $?.exitstatus\n if status == 127\n raise Exception.new(\"Command not found... `#{pretty_command}` (#{status})\")\n else\n raise Exception.new(\"Command failed... `#{pretty_command}` (#{status})\")\n end\n end\n end",
"def run(*args)\n opts = $opts.dup\n opts.merge! args.last if args.last.is_a? Hash\n status = run_with_status(*args)\n return unless opts[:errexit]\n unless status.success?\n # Print an error at the failure site\n puts \"#{c_red}Command exited with #{status.exitstatus}#{c_reset}\"\n fail \"Command exited with #{status.exitstatus}\"\n end\nend",
"def runSystemSafe(*cmdAndArgs)\n if cmdAndArgs.length < 1\n onError \"Empty runSystemSafe command\"\n end\n\n if !File.exists? cmdAndArgs[0] or !Pathname.new(cmdAndArgs[0]).absolute?\n # check that the command exists if it is not a full path to a file\n requireCMD cmdAndArgs[0]\n end\n\n system(*cmdAndArgs)\n $?.exitstatus\nend",
"def exec cmd\n puts cmd\n system cmd or die\nend",
"def execute\n unless args.skip?\n if args.chained?\n execute_command_chain\n else\n exec(*args.to_exec)\n end\n end\n end",
"def run(cmd)\n puts \"#{cmd}\"\n success = system(cmd)\n exit $?.exitstatus unless success\nend",
"def run_command!(name, *args)\n run_command(name, *args) rescue nil\n end",
"def execute command\n log command\n system(command) unless @options[:test]\n end",
"def run_cmd cmd\n info cmd\n status = system(cmd)\n if status\n info(\"Woot! Woot! - command succeeded #{cmd}\")\n else\n error(\"Gahhhh! Bad status from #{cmd}\")\n end\n status\n end",
"def runSystemSafe(*cmd_and_args)\n onError 'Empty runSystemSafe command' if cmd_and_args.empty?\n\n if !File.exist?(cmd_and_args[0]) || !Pathname.new(cmd_and_args[0]).absolute?\n # check that the command exists if it is not a full path to a file\n requireCMD cmd_and_args[0]\n end\n\n system(*cmd_and_args)\n $CHILD_STATUS.exitstatus\nend",
"def run_command(cmd, exit_on_error = false)\n Bundler.with_clean_env do\n system(cmd)\n status = $CHILD_STATUS.exitstatus\n\n return false unless status != 0\n return true unless exit_on_error\n exit status\n end\nend",
"def run_locally(cmd)\n logger.trace \"executing locally: #{cmd.inspect}\" if logger\n `#{cmd}`\n end",
"def run_command(command, *args)\n `#{command} #{args.join(' ')} 2>/dev/null`\n end",
"def run_command(command, options = {})\n status = run(command, options)\n fail \"#{command} failed\" unless status\nend",
"def run_command(command, options = {})\n status = run(command, options)\n fail \"#{command} failed\" unless status\nend",
"def run_command(command, ignore_failure = false)\n return Simp::Cli::ExecUtils::run_command(command, ignore_failure, logger)\n end",
"def run_command(cmd)\n if config[:simulate]\n puts_and_logs \" - Simulate running \\\"#{cmd}\\\"\"\n return\n end\n if config[:debug]\n if config[:verbose]\n puts_and_logs \" - Running \\\"#{cmd}\\\"\"\n else\n logger.debug \" - Running \\\"#{cmd}\\\"\"\n end\n system cmd\n return\n end\n puts_and_logs \" - Running \\\"#{cmd}\\\"\" if config[:verbose]\n system(cmd + ' > /dev/null 2>&1')\n\n end",
"def sh(command,options={},&block)\n sh_logger.debug(\"Executing '#{command}'\")\n\n stdout,stderr,status = execution_strategy.run_command(command)\n process_status = OptparsePlus::ProcessStatus.new(status,options[:expected])\n\n sh_logger.warn(\"stderr output of '#{command}': #{stderr}\") unless stderr.strip.length == 0\n\n if process_status.success?\n sh_logger.debug(\"stdout output of '#{command}': #{stdout}\") unless stdout.strip.length == 0\n call_block(block,stdout,stderr,process_status.exitstatus) unless block.nil?\n else\n sh_logger.info(\"stdout output of '#{command}': #{stdout}\") unless stdout.strip.length == 0\n sh_logger.warn(\"Error running '#{command}'\")\n end\n\n process_status.exitstatus\n rescue *exception_meaning_command_not_found => ex\n sh_logger.error(\"Error running '#{command}': #{ex.message}\")\n 127\n end",
"def run_cmd(cmd)\n puts blue(cmd)\n raise unless system cmd\n end",
"def safe_system cmd, *args\n raise ExecutionError.new($?) unless system(cmd, *args)\n end",
"def exec(_cmd, _args = {})\n false\n end",
"def run_command(*command)\n print_command command\n result = system *command\n if result.nil?\n puts \"Failed to run command.\"\n exit 255\n elsif !result\n exit $?.exitstatus\n end\nend",
"def run_shell_cmd(args)\n system(*args)\n raise \"command exited with a nonzero status code #{$?.exitstatus} (command: #{args.join(' ')})\" if !$?.success?\n end",
"def plain_command cmd, options={}\n system(cmd)\n exitstatus = $?.exitstatus == 0 || $?.exitstatus == 1\n show_output(exitstatus, options)\n exitstatus\n end",
"def run\n system(command)\n $?\n end",
"def run\n system(command)\n $?\n end",
"def try(command)\n system command\n if $? != 0 then\n raise \"Command: `#{command}` exited with code #{$?.exitstatus}\"\n end\nend",
"def try(command)\n system command\n if $? != 0 then\n raise \"Command: `#{command}` exited with code #{$?.exitstatus}\"\n end\nend",
"def try(command)\n system command\n if $? != 0 then\n raise \"Command: `#{command}` exited with code #{$?.exitstatus}\"\n end\nend",
"def run_cmd(cmd)\n print_e(\"Run: #{cmd}\")\n exit_code = system(cmd)\n fail SystemCallError, cmd unless exit_code\n exit_code\n end",
"def execute_with_exit_code(command)\n if elevated\n session = elevated_session\n command = \"$env:temp='#{unelevated_temp_dir}';#{command}\"\n else\n session = unelevated_session\n end\n\n begin\n response = session.run(command) do |stdout, _|\n logger << stdout if stdout\n end\n [response.exitcode, response.stderr]\n ensure\n close\n end\n end",
"def exec_shell(command, error_message, options = {})\n puts \"Running command: #{command}\" unless options[:silent] == true\n result = `#{command}`\n if options[:dont_fail_on_error] == true\n puts error_message unless $?.success?\n else\n fail_script_unless($?.success?, \"#{error_message}\\nShell failed: #{command}\\n#{result}\")\n end\n\n return result\n end",
"def run!\n # rubocop:disable Metrics/LineLength\n fail LaunchError, %(Command \"#{command}\" not found in PATH-variable \"#{environment['PATH']}\".) unless which(command, environment['PATH'])\n # rubocop:enable Metrics/LineLength\n\n if RUBY_VERSION < '1.9'\n begin\n old_env = ENV.to_hash\n ENV.update environment\n\n Dir.chdir @working_directory do\n @exit_status = system(@cmd) ? 0 : 1\n end\n ensure\n ENV.clear\n ENV.update old_env\n end\n elsif RUBY_VERSION < '2'\n Dir.chdir @working_directory do\n @exit_status = system(environment, @cmd) ? 0 : 1\n end\n else\n @exit_status = system(environment, @cmd, :chdir => @working_directory) ? 0 : 1\n end\n end",
"def sh(cmd)\n output = `#{cmd}`\n if !$?.success?\n puts \"Command exited with failure code: #{cmd}\"\n puts \"Aborting.\"\n exit(1)\n end\n output\nend",
"def run(cmd, opts={})\n cmd = \"sh -c '#{cmd.gsub(\"'\"){%q{'\"'\"'}}}'\"\n if opts[:env]\n sh \"touch .env.local .env.test.local\", verbose: false\n env = '.env'\n env += \".#{opts[:env]}\" unless opts[:env] == :local\n cmd = \"#{dotenv} -f #{env}.local,#{env} #{cmd}\"\n end\n puts cmd if verbose == true\n if opts[:silent]\n out = `#{cmd} 2>&1`\n abort out unless $?.success?\n elsif opts[:exec]\n exec cmd\n else\n system(cmd)\n end\nend",
"def run_inline(cmd, redact: nil)\n put_command(cmd, redact: redact)\n\n # `system`, by design (?!), hides stderr when the command fails.\n if ENV[\"PROJECTRB_USE_SYSTEM\"] == \"true\"\n if not system(*cmd)\n exit $?.exitstatus\n end\n else\n pid = spawn(*cmd)\n Process.wait pid\n if $?.exited?\n if !$?.success?\n exit $?.exitstatus\n end\n else\n error \"Command exited abnormally.\"\n exit 1\n end\n end\n end",
"def run_local_command(command)\n stdout, stderr, status = Open3.capture3(command)\n error_message = \"Attempted to run\\ncommand:'#{command}'\\nstdout:#{stdout}\\nstderr:#{stderr}\"\n raise error_message unless status.to_i.zero?\n\n stdout\n end",
"def systemOrDie(*cmd)\n puts 'executes: ' + cmd.join(' ')\n ret = system(*cmd)\n raise \"Failed to execute command: \" + cmd.join(' ') if !ret\n end",
"def run_cmd(cmd, debug=false)\n puts \"In #{Dir.pwd} executing: #{cmd}\" if debug\n `#{cmd}`\n end",
"def execute(command, ignore_failure = false)\n return Simp::Cli::ExecUtils::execute(command, ignore_failure, logger)\n end",
"def exec(command)\n ensure_mode(:privileged)\n run(command)\n end",
"def execute\n raise errors.to_sentences unless valid?\n\n # default failing command\n result = false\n\n # protect command from recursion\n mutex = Mutagem::Mutex.new('revenc.lck')\n lock_successful = mutex.execute do\n result = system_cmd(cmd)\n end\n\n raise \"action failed, lock file present\" unless lock_successful\n result\n end",
"def run( *cmd )\n\t\t\tcmd.flatten!\n\n\t\t\tif cmd.length > 1\n\t\t\t\ttrace( \"Running:\", quotelist(*cmd) )\n\t\t\telse\n\t\t\t\ttrace( \"Running:\", cmd )\n\t\t\tend\n\n\t\t\tif Rake.application.options.dryrun\n\t\t\t\tlog \"(dry run mode)\"\n\t\t\telse\n\t\t\t\tsystem( *cmd )\n\t\t\t\tunless $?.success?\n\t\t\t\t\tfail \"Command failed: [%s]\" % [cmd.join(' ')]\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def run_command(cmd)\n IO.popen(cmd) do |stdout|\n stdout.reject(&:empty?)\n end.unshift($CHILD_STATUS.exitstatus.zero?)\nend",
"def run(command)\n\traise \"non-zero exit status: `#{command}`\" if !system(\"cd #{$root} && #{command}\")\nend",
"def execute_with_exit(command) # rubocop:disable Lint/UnusedMethodArgument\n end",
"def execute_local_command(cmd)\n Bundler.clean_system(cmd)\n end",
"def exec!(cmd, *args)\n cmd = Command.new(cmd, args)\n cmd.exec!\n end",
"def execute_cmd(cmd)\n class_invariant\n pre_execute_cmd(cmd)\n begin\n env = {\"PWD\" => @pwd}\n exec(env, [cmd[0], \"\"], *cmd[1..-1], :unsetenv_others=>true, :chdir=>@pwd)\n rescue Errno::ENOENT\n puts \"Command '#{cmd[0]}' not found.\"\n end\n class_invariant\n end",
"def shell(cmd)\n puts \"Executing #{cmd}...\"\n Bundler.clean_system(cmd)\n abort \"Command '#{cmd}' failed\" unless $?.success?\n end",
"def run_local(cmd)\n system(cmd)\n end",
"def exec_command(cmd)\n exec(cmd)\n # windows? ? exec(cmd) : fake_exec(cmd)\n end",
"def safe_system(*cmd)\n exit 1 unless system(*cmd)\nend",
"def run(cmd)\n log cmd\n system(cmd) or fail \"Command Failed: [#{cmd}]\"\n end",
"def run(cmd)\n log cmd\n system(cmd) or fail \"Command Failed: [#{cmd}]\"\n end",
"def execute(command)\n system command\n code = $?.exitstatus\n if code > 0\n LOGGER.warn \"Failed to execute command `#{command}` with code #{code}.\"\n false\n else\n true\n end\n end",
"def run_command(cmd)\n IO.popen(cmd) do |stdout|\n stdout.reject(&:empty?)\n end.unshift($?.exitstatus.zero?)\nend",
"def run_command(cmd)\n IO.popen(cmd) do |stdout|\n stdout.reject(&:empty?)\n end.unshift($?.exitstatus.zero?)\nend",
"def run_in_shell(cmd, ret = false)\n\treturn `#{cmd}` if ret\n\tsystem cmd\nend",
"def run_quietly(command, *args)\n if !args.empty?\n args = args.flatten.map { |i| shell_escape(i) }.join(\" \")\n command = \"#{command} #{args}\"\n end\n run(\"#{command} > /dev/null 2> /dev/null\")\n end",
"def run_and_return(command)\n log_and_exit \"Tried to run: #{command}\" if $testing\n %x(#{command}).chomp\n end",
"def ct_exec_run(opts)\n pid = Process.fork do\n STDIN.reopen(opts[:stdin])\n STDOUT.reopen(opts[:stdout])\n STDERR.reopen(opts[:stderr])\n\n setup_exec_env\n\n cmd = [\n 'lxc-execute',\n '-P', @lxc_home,\n '-n', opts[:id],\n '-o', @log_file,\n '-s', \"lxc.environment=PATH=#{PATH.join(':')}\",\n '--',\n opts[:cmd],\n ]\n\n # opts[:cmd] can contain an arbitrary command with multiple arguments\n # and quotes, so the mapping to process arguments is not clear. We use\n # the shell to handle this.\n Process.exec(\"exec #{cmd.join(' ')}\")\n end\n\n _, status = Process.wait2(pid)\n ok(exitstatus: status.exitstatus)\n end",
"def run command, args = {}\n # check if in verbose mode\n verbose = args[:verbose] || @verbose\n output = `echo | #{command} 2>&1`\n success = $?.success?\n\n if verbose\n say \"RUNNING: #{command}\", :type => (success ? :success : :fail)\n say output\n end\n\n args[:boolean] ? success : output\n end",
"def _run_command(command)\n require \"posix-spawn\"\n\n pid, stdin, stdout, stderr = POSIX::Spawn.popen4(command)\n Process.waitpid(pid)\n\n # $?.exitstatus contains exit status do something with it if non zero raise error maybe\n end",
"def run(command, verbose = false, message = nil)\n if verbose then\n puts \"#{message}\"\n puts command\n result = `#{command}`\n puts result\n return result\n else\n `#{command}`\n end\nend",
"def run(command, verbose = false, message = nil)\n if verbose then\n puts \"#{message}\"\n puts command\n result = `#{command}`\n puts result\n return result\n else\n `#{command}`\n end\nend",
"def sh!(*cmd)\n sh?(*cmd) || raise(\"returned #{$CHILD_STATUS}\")\nend",
"def run_sh(cmd)\n begin; sh cmd; rescue; end\nend",
"def run_local_command(command)\n require 'open3'\n stdout, stderr, status = Open3.capture3(command)\n error_message = \"Attempted to run\\ncommand:'#{command}'\\nstdout:#{stdout}\\nstderr:#{stderr}\"\n\n raise error_message unless status.to_i.zero?\n\n stdout\n end",
"def run_cmd_no_exception(cmd)\n #TODO: find a better way to handle command with errors\n begin\n result = Puppet::Util::Execution.execute([cmd], {:combine => true})\n rescue\n result\n end\n end",
"def run_cmd_no_exception(cmd)\n #TODO: find a better way to handle command with errors\n begin\n result = Puppet::Util::Execution.execute([cmd], {:combine => true})\n rescue\n result\n end\n end",
"def run_sh(cmd)\n sh cmd\nrescue StandardError\n # ignored\nend",
"def system!(*args)\n log \"Executing #{args}\"\n if system(*args)\n log \"#{args} succeeded\"\n else\n log \"#{args} failed\"\n abort\n end\nend",
"def system!(*args)\n log \"Executing #{args}\"\n if system(*args)\n log \"#{args} succeeded\"\n else\n log \"#{args} failed\"\n abort\n end\nend",
"def run(cmd)\n #logger.trace \"executing locally: #{cmd.inspect}\" if logger\n run_locally cmd\n # puts `#{cmd}`\nend",
"def run(cmd)\n puts \"\\033[1;37m#{cmd}\\033[0m\"\n result = `#{cmd}`\n abort unless $?.success?\n puts result unless result.empty?\n result\nend",
"def execute(*args, env: nil, log: true, &block)\n env ||= environment\n status(\"Execute: #{args.join(\" \")}\") if log\n env.execute(*args, &block)\n end",
"def cleanup\n options = []\n options += ['-q', '--no-verbose'] unless Kontena.debug?\n command.handle_options options\n command.execute\n true\n rescue Gem::SystemExitException => e\n raise unless e.exit_code.zero?\n true\n end",
"def remote_run cmd\n ssh = ssh_command(cmd)\n _show_cmd ssh\n system(ssh) unless @opts[:norun] || $norun\n end",
"def execute_command_from_command_line\n cmd = ARGV[0]\n if not cmd\n puts CMD_LINE_HELP\n elsif OPERATION_NAMES.include?(cmd) && !options.force_command\n begin\n self.send(*ARGV)\n rescue ArgumentError => ex\n $stderr.puts \"Wrong number of arguments (#{ARGV.size-1}) for operation: #{cmd}\"\n end\n else\n send_roku_command cmd\n end\n end"
] | [
"0.7138665",
"0.68741983",
"0.6867353",
"0.66077614",
"0.65934044",
"0.6485354",
"0.64458686",
"0.64312",
"0.64247674",
"0.63332397",
"0.6329793",
"0.63161373",
"0.63060725",
"0.6296623",
"0.6239331",
"0.6091347",
"0.6079008",
"0.60544527",
"0.6041852",
"0.6034954",
"0.60132307",
"0.5990072",
"0.5983114",
"0.5981013",
"0.5975019",
"0.59675556",
"0.5958087",
"0.59474516",
"0.5925079",
"0.5919659",
"0.59086597",
"0.5886143",
"0.58794194",
"0.5870061",
"0.5870061",
"0.58527404",
"0.5840774",
"0.5816801",
"0.5810054",
"0.58069193",
"0.57837313",
"0.577575",
"0.57659423",
"0.57626396",
"0.57593703",
"0.57593703",
"0.5757873",
"0.5757873",
"0.5757873",
"0.5749267",
"0.5739616",
"0.5736116",
"0.5732518",
"0.5719861",
"0.57113785",
"0.57008237",
"0.5696939",
"0.56726056",
"0.5661802",
"0.56537",
"0.56445336",
"0.56323016",
"0.56319714",
"0.5631066",
"0.5628773",
"0.5619147",
"0.56191",
"0.56084424",
"0.5600946",
"0.55950135",
"0.55935806",
"0.55794066",
"0.5576185",
"0.5567525",
"0.5567525",
"0.55595714",
"0.5555444",
"0.5555444",
"0.55540234",
"0.5544306",
"0.5541105",
"0.55320585",
"0.55301017",
"0.5513403",
"0.55120116",
"0.55120116",
"0.55104256",
"0.55101067",
"0.5499192",
"0.5495919",
"0.5495919",
"0.5494647",
"0.54890126",
"0.54890126",
"0.54866886",
"0.5469259",
"0.5467148",
"0.54669476",
"0.54635066",
"0.54602474"
] | 0.74064827 | 0 |
Recursively perform all marked copy operations from the source content tree to the destination content tree, or if dryRun, just pretend to perform them. N Without this, there wouldn't be a way to copy files marked for copying in a source content tree to a destination content tree (or optionally do a dry run) | def doCopyOperations(sourceContent, destinationContent, dryRun)
#N Without this loop, we won't copy the directories that are marked for copying
for dir in sourceContent.dirs
#N Without this check, we would attempt to copy those directories _not_ marked for copying (but which might still have sub-directories marked for copying)
if dir.copyDestination != nil
#N Without this, we won't know what is the full path of the local source directory to be copied
sourcePath = sourceLocation.getFullPath(dir.relativePath)
#N Without this, we won't know the full path of the remote destination directory that this source directory is to be copied into
destinationPath = destinationLocation.getFullPath(dir.copyDestination.relativePath)
#N Without this, the source directory won't actually get copied
destinationLocation.contentHost.copyLocalToRemoteDirectory(sourcePath, destinationPath, dryRun)
else
#N Without this, we wouldn't copy sub-directories marked for copying of this sub-directory (which is not marked for copying in full)
doCopyOperations(dir, destinationContent.getDir(dir.name), dryRun)
end
end
#N Without this loop, we won't copy the files that are marked for copying
for file in sourceContent.files
#N Without this check, we would attempt to copy those files _not_ marked for copying
if file.copyDestination != nil
#N Without this, we won't know what is the full path of the local file to be copied
sourcePath = sourceLocation.getFullPath(file.relativePath)
#N Without this, we won't know the full path of the remote destination directory that this source directory is to be copied into
destinationPath = destinationLocation.getFullPath(file.copyDestination.relativePath)
#N Without this, the file won't actually get copied
destinationLocation.contentHost.copyLocalFileToRemoteDirectory(sourcePath, destinationPath, dryRun)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def doAllCopyOperations(dryRun)\n #N Without this, the copy operations won't be executed\n doCopyOperations(@sourceContent, @destinationContent, dryRun)\n end",
"def markCopyOperations(destinationDir)\n #N Without this we can't loop over the immediate sub-directories to determine how each one needs to be marked for copying\n for dir in dirs\n #N Without this we won't have the corresponding sub-directory in the other directory with the same name as this sub-directory (if it exists)\n destinationSubDir = destinationDir.getDir(dir.name)\n #N Without this check, we won't be able to correctly process a sub-directory based on whether or not one with the same name exists in the other directory\n if destinationSubDir != nil\n #N Without this, files and directories missing or changed from the other sub-directory (which does exist) won't get copied\n dir.markCopyOperations(destinationSubDir)\n else\n #N Without this, the corresponding missing sub-directory in the other directory won't get updated from this sub-directory\n dir.markToCopy(destinationDir)\n end\n end\n #N Without this we can't loop over the files to determine how each one needs to be marked for copying\n for file in files\n #N Without this we won't have the corresponding file in the other directory with the same name as this file (if it exists)\n destinationFile = destinationDir.getFile(file.name)\n #N Without this check, this file will get copied, even if it doesn't need to be (it only needs to be if it is missing, or the hash is different)\n if destinationFile == nil or destinationFile.hash != file.hash\n #N Without this, a file that is missing or changed won't get copied (even though it needs to be)\n file.markToCopy(destinationDir)\n end\n end\n end",
"def execute\n\n copiedCounter = 0\n failedCounter = 0\n skippedCounter = 0\n \n # traverse all srcfiles\n FiRe::filesys.find(@source) { |srcItem|\n \n # give some feedback\n FiRe::log.info \"searching #{srcItem}...\" if FiRe::filesys.directory?(srcItem)\n \n # skip this subtree if it matches ignored-items\n FiRe::filesys.prune if ignore?(srcItem) \n \n # transform srcpath to destpath\n destItem = srcItem.gsub(@source, @destination)\n\n # do not copy if item already exists and looks OK\n if needCopy(destItem,srcItem)\n copyWentWell = copyItem(srcItem, destItem)\n copiedCounter += 1 if copyWentWell\n failedCounter += 1 if !copyWentWell\n else\n skippedCounter += 1 \n end\n \n }\n \n # give some feedback\n FiRe::log.info \"copied #{copiedCounter} items, while #{failedCounter} items failed. #{skippedCounter} items did not need to be copied today.\"\n\n end",
"def cp_r(src, dest, options = {})\r\n fu_check_options options, OPT_TABLE['cp_r']\r\n fu_output_message \"cp -r#{options[:preserve] ? 'p' : ''}#{options[:remove_destination] ? ' --remove-destination' : ''} #{[src,dest].flatten.join ' '}\" if options[:verbose]\r\n return if options[:noop]\r\n options[:dereference_root] = true unless options.key?(:dereference_root)\r\n fu_each_src_dest(src, dest) do |s, d|\r\n copy_entry s, d, options[:preserve], options[:dereference_root], options[:remove_destination]\r\n end\r\n end",
"def cp_r(src, dest, options = {})\r\n fu_check_options options, OPT_TABLE['cp_r']\r\n fu_output_message \"cp -r#{options[:preserve] ? 'p' : ''}#{options[:remove_destination] ? ' --remove-destination' : ''} #{[src,dest].flatten.join ' '}\" if options[:verbose]\r\n return if options[:noop]\r\n options[:dereference_root] = true unless options.key?(:dereference_root)\r\n fu_each_src_dest(src, dest) do |s, d|\r\n copy_entry s, d, options[:preserve], options[:dereference_root], options[:remove_destination]\r\n end\r\n end",
"def preform_copy_file\n @destination_files.each do |destination|\n copy_file(@sources.pop, destination)\n end\n end",
"def copy_content\n @tocopy.each do |pair|\n src = pair[0]\n dst = File.expand_path(File.join(@temp_path, pair[1] || ''))\n dstdir = File.dirname(dst)\n FileUtils.mkpath(dstdir) unless File.exist?(dstdir)\n FileUtils.cp_r(src, dst)\n end\n\n # clear out the list of things to copy so that snippets can\n # re-load it and call copy_content again if needed\n @tocopy = []\n end",
"def copy(source_repo_id, destination_repo_id, optional = {})\n criteria = {:type_ids => [content_type], :filters => {}}\n criteria[:filters]['association'] = {'unit_id' => {'$in' => optional[:ids]}} if optional[:ids]\n criteria[:filters] = optional[:filters] if optional[:filters]\n criteria[:fields] = {:unit => optional[:fields]} if optional[:fields]\n\n payload = {:criteria => criteria}\n payload[:override_config] = optional[:override_config] if optional.key?(:override_config)\n\n if optional[:copy_children]\n payload[:override_config] ||= {}\n payload[:override_config][:recursive] = true\n end\n\n Runcible::Extensions::Repository.new(self.config).unit_copy(destination_repo_id, source_repo_id, payload)\n end",
"def safe_cp(from, to, owner, group, cwd = '', include_paths = [], exclude_paths = [])\n credentials = ''\n credentials += \"-o #{owner} \" if owner\n credentials += \"-g #{group} \" if group\n excludes = find_command_excludes(from, cwd, exclude_paths).join(' ')\n\n copy_files = proc do |from_, cwd_, path_ = ''|\n cwd_ = File.expand_path(File.join('/', cwd_))\n \"if [[ -d #{File.join(from_, cwd_, path_)} ]]; then \" \\\n \"#{dimg.project.find_path} #{File.join(from_, cwd_, path_)} #{excludes} -type f -exec \" \\\n \"#{dimg.project.bash_path} -ec '#{dimg.project.install_path} -D #{credentials} {} \" \\\n \"#{File.join(to, '$(echo {} | ' \\\n \"#{dimg.project.sed_path} -e \\\"s/#{File.join(from_, cwd_).gsub('/', '\\\\/')}//g\\\")\")}' \\\\; ;\" \\\n 'fi'\n end\n\n commands = []\n commands << [dimg.project.install_path, credentials, '-d', to].join(' ')\n commands.concat(include_paths.empty? ? Array(copy_files.call(from, cwd)) : include_paths.map { |path| copy_files.call(from, cwd, path) })\n commands << \"#{dimg.project.find_path} #{to} -type d -exec \" \\\n \"#{dimg.project.bash_path} -ec '#{dimg.project.install_path} -d #{credentials} {}' \\\\;\"\n commands.join(' && ')\n end",
"def cp_r(src, dest, preserve: nil, noop: nil, verbose: nil,\n dereference_root: true, remove_destination: nil)\n fu_output_message \"cp -r#{preserve ? 'p' : ''}#{remove_destination ? ' --remove-destination' : ''} #{[src,dest].flatten.join ' '}\" if verbose\n return if noop\n fu_each_src_dest(src, dest) do |s, d|\n copy_entry s, d, preserve, dereference_root, remove_destination\n end\n end",
"def copy\n nodes = Node.accessible_by(@context).where(id: params[:item_ids])\n\n NodeCopyWorker.perform_async(\n params[:scope],\n nodes.pluck(:id),\n session_auth_params,\n )\n\n render json: nodes, root: \"nodes\", adapter: :json,\n meta: {\n messages: [{\n type: \"success\",\n message: I18n.t(\"api.files.copy.files_are_copying\"),\n }],\n }\n end",
"def cp_r(src, dest, options = {})\r\n fu_check_options options, :preserve, :noop, :verbose\r\n fu_output_message \"cp -r#{options[:preserve] ? 'p' : ''} #{[src,dest].flatten.join ' '}\" if options[:verbose]\r\n return if options[:noop]\r\n\r\n fu_each_src_dest(src, dest) do |s,d|\r\n if File.directory?(s)\r\n fu_copy_dir s, d, '.', options[:preserve]\r\n else\r\n fu_p_copy s, d, options[:preserve]\r\n end\r\n end\r\n end",
"def copy(from_path, to_path, ctype=nil, recursive=false, replace=false)\n if to_path.end_with? '/'\n # copy into to_path, not to to_path\n to_path = File.join(to_path, File.basename(from_path))\n end\n\n count = 0\n prune = recursive ? nil : 1\n @content_tree.with_subtree(from_path, ctype, prune) do |node|\n ntype = node.node_type\n basename = node.path.split(from_path, 2)[1]\n dest = basename.empty? ? to_path : File.join(to_path, basename)\n if (! replace) and (@content_tree.exist? dest, ntype)\n raise NodeExists, \"'#{dest}' exists [#{ntype}]\"\n end\n new_node = @content_tree.clone(node, dest)\n copy_doc_resources(from_path, to_path) if ntype == :document\n copy_metadata(node.path, dest, ntype)\n notify(EVENT_CLONE, node.path, ctype, dest)\n count += 1\n end\n\n count\n end",
"def cp_lr(src, dest, noop: nil, verbose: nil,\n dereference_root: true, remove_destination: false)\n fu_output_message \"cp -lr#{remove_destination ? ' --remove-destination' : ''} #{[src,dest].flatten.join ' '}\" if verbose\n return if noop\n fu_each_src_dest(src, dest) do |s, d|\n link_entry s, d, dereference_root, remove_destination\n end\n end",
"def doSync(options = {})\n #N Without this, the content files will be cleared regardless of whether :full options is specified\n if options[:full]\n #N Without this, the content files won't be cleared when the :full options is specified\n clearCachedContentFiles()\n end\n #N Without this, the required content information won't be retrieved (be it from cached content files or from the actual locations)\n getContentTrees()\n #N Without this, the required copy and delete operations won't be marked for execution\n markSyncOperations()\n #N Without this, we won't know if only a dry run is intended\n dryRun = options[:dryRun]\n #N Without this check, the destination cached content file will be cleared, even for a dry run\n if not dryRun\n #N Without this check, the destination cached content file will remain there, even though it is stale once an actual (non-dry-run) sync operation is started.\n @destinationLocation.clearCachedContentFile()\n end\n #N Without this, the marked copy operations will not be executed (or in the case of dry-run, they won't be echoed to the user)\n doAllCopyOperations(dryRun)\n #N Without this, the marked delete operations will not be executed (or in the case of dry-run, they won't be echoed to the user)\n doAllDeleteOperations(dryRun)\n #N Without this check, the destination cached content file will be updated from the source content file, even if it was only a dry-run (so the remote location hasn't actually changed)\n if (not dryRun and @destinationLocation.cachedContentFile and @sourceLocation.cachedContentFile and\n File.exists?(@sourceLocation.cachedContentFile))\n #N Without this, the remote cached content file won't be updated from local cached content file (which is a reasonable thing to do assuming the sync operation completed successfully)\n FileUtils::Verbose.cp(@sourceLocation.cachedContentFile, @destinationLocation.cachedContentFile)\n end\n #N Without this, any cached SSH connections will remain unclosed (until the calling application has terminated, which may or may not happen soon after completing the sync).\n closeConnections()\n end",
"def copy\n FileUtils.cp_r(@src, @dest)\n end",
"def copy(dest_path, overwrite = false, depth = nil)\n NotImplemented\n end",
"def copy(source, destination, **options); end",
"def cp(*args, **kwargs)\n queue CopyCommand, args, kwargs\n end",
"def copy from, to\n add \"cp #{from} #{to}\", check_file(to)\n end",
"def preform_copy_directory\n @destination_directories.each do |destination|\n @sources.each do |source|\n write_mode = 'w'\n new_path = Pathname.new(destination.to_s).join(source.basename)\n # Check if the specified file is a directory\n if new_path.directory?\n return false if get_input(\"Destination path '\" + new_path.to_s + \"' is a directory. (S)kip the file or (C)ancel: \", ['s','c']) == 'c'\n next\n end\n # Copy the file\n return false unless copy_file(source, new_path)\n end\n end\n return true\n end",
"def copy(src,target)\n mkdir_p target if ! File.exist?(target)\n sh 'cp ' + src + '/* ' + target\nend",
"def filtered_copy(src_dir, dest_dir, filters_def = Registry[:filters_def])\n self.copy(:todir => dest_dir.to_s) do\n self.filterset do\n filters_def['filters'].each do |filter|\n token = filter.keys.first\n value = filter[token]\n self.filter(:token => token, :value => value)\n end\n end\n\n filters_def['filtered_files'].each do |includes_pattern|\n self.fileset(:dir => src_dir.to_s, :includes => includes_pattern)\n end\n end\n\n self.copy(:todir => dest_dir.to_s) do\n self.fileset(:dir => src_dir.to_s, :includes => '**/*',\n :excludes => filters_def['filtered_files'].join(','))\n end\n end",
"def doDeleteOperations(destinationContent, dryRun)\n #N Without this loop, we won't delete all sub-directories or files and directories within sub-directories which have been marked for deletion\n for dir in destinationContent.dirs\n #N Without this check, we would delete directories which have not been marked for deletion (which would be incorrect)\n if dir.toBeDeleted\n #N Without this, we won't know the full path of the remote directory to be deleted\n dirPath = destinationLocation.getFullPath(dir.relativePath)\n #N Without this, the remote directory marked for deletion won't get deleted\n destinationLocation.contentHost.deleteDirectory(dirPath, dryRun)\n else\n #N Without this, files and sub-directories within this sub-directory which are marked for deletion (even though the sub-directory as a whole hasn't been marked for deletion) won't get deleted.\n doDeleteOperations(dir, dryRun)\n end\n end\n #N Without this loop, we won't delete files within this directory which have been marked for deletion.\n for file in destinationContent.files\n #N Without this check, we would delete this file even though it's not marked for deletion (and therefore should not be deleted)\n if file.toBeDeleted\n #N Without this, we won't know the full path of the file to be deleted\n filePath = destinationLocation.getFullPath(file.relativePath)\n #N Without this, the file won't actually get deleted\n destinationLocation.contentHost.deleteFile(filePath, dryRun)\n end\n end\n end",
"def copy_contents\n cmd = rsync_cmd\n\n @log.debug \"Copying contents with: #{cmd}\"\n\n %x[#{cmd}]\n $?.success?\n end",
"def stage_copy(source_dir)\n test_dir = File.dirname(caller[0])\n stage_clear\n srcdir = File.join(test_dir, source_dir)\n Dir[File.join(srcdir, '*')].each do |path|\n FileUtils.cp_r(path, '.')\n end\n end",
"def prepare_copy_folders\n return if config[:copy_folders].nil?\n\n info(\"Preparing to copy specified folders to #{sandbox_module_path}.\")\n kitchen_root_path = config[:kitchen_root]\n config[:copy_folders].each do |folder|\n debug(\"copying #{folder}\")\n folder_to_copy = File.join(kitchen_root_path, folder)\n copy_if_src_exists(folder_to_copy, sandbox_module_path)\n end\n 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 copy(src, dst)\n\t\t# TODO: make cp able to handle strings, where it will create an entry based\n\t\t# on the box it's run from.\n\t\t\n\t\tif !(src.kind_of?(Rush::Entry) && dst.kind_of?(Rush::Entry))\n\t\t\traise ArgumentError, \"must operate on Rush::Dir or Rush::File objects\"\n\t\tend\n\t\t\n\t\t# 5 cases:\n\t\t# 1. local-local\n\t\t# 2. local-remote (uploading)\n\t\t# 3. remote-local (downloading)\n\t\t# 4. remote-remote, same server\n\t\t# 5. remote-remote, cross-server\n\t\tif src.box == dst.box # case 1 or 4\n\t\t\tif src.box.remote? # case 4\n\t\t\t\tsrc.box.ssh.exec!(\"cp -r #{src.full_path} #{dst.full_path}\") do |ch, stream, data|\n\t\t\t\t\tif stream == :stderr\n\t\t\t\t\t\traise Rush::DoesNotExist, stream\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\telse # case 1\n\t\t\t\tFileUtils.cp_r(src.full_path, dst.full_path)\n\t\t\tend\n\t\telse # case 2, 3, or 5\n\t\t\tif src.local? && !dst.local? # case 2\n\t\t\t\t# We use the connection on the remote machine to do the upload\n\t\t\t\tdst.box.ssh.scp.upload!(src.full_path, dst.full_path, :recursive => true)\n\t\t\telsif !src.local? && dst.local? # case 3\n\t\t\t\t# We use the connection on the remote machine to do the download\n\t\t\t\tsrc.box.ssh.scp.download!(src.full_path, dst.full_path, :recursive => true)\n\t\t\telse # src and dst not local, case 5\n\t\t\t\tremote_command = \"scp #{src.full_path} #{dst.box.user}@#{dst.box.host}:#{dst.full_path}\"\n\t\t\t\t# doesn't matter whose connection we use\n\t\t\t\tsrc.box.ssh.exec!(remote_command) do |ch, stream, data|\n\t\t\t\t\tif stream == :stderr\n\t\t\t\t\t\traise Rush::DoesNotExist, stream\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\t# TODO: use tar for cross-server transfers.\n\t\t# something like this?:\n\t\t# archive = from.box.read_archive(src)\n\t\t# dst.box.write_archive(archive, dst)\n\n\t\tnew_full_path = dst.dir? ? \"#{dst.full_path}#{src.name}\" : dst.full_path\n\t\tsrc.class.new(new_full_path, dst.box)\n\trescue Errno::ENOENT\n\t\traise Rush::DoesNotExist, File.dirname(to)\n\trescue RuntimeError\n\t\traise Rush::DoesNotExist, from\n\tend",
"def copyLocalFileToRemoteDirectory(sourcePath, destinationPath, dryRun)\n #N Without this, the copy command won't be run at all\n sshAndScp.copyLocalFileToRemoteDirectory(sourcePath, destinationPath, dryRun)\n end",
"def cp_r(src,dst)\n src_root = Pathname.new(src)\n FileUtils.mkdir_p(dst, :verbose => VERBOSE) unless File.exists? dst\n Dir[\"#{src}/**/**\"].each do |abs_path|\n src_path = Pathname.new(abs_path)\n rel_path = src_path.relative_path_from(src_root)\n dst_path = \"#{dst}/#{rel_path.to_s}\"\n \n next if abs_path.include? '.svn'\n \n if src_path.directory?\n FileUtils.mkdir_p(dst_path, :verbose => VERBOSE)\n elsif src_path.file?\n FileUtils.cp(abs_path, dst_path, :verbose => VERBOSE)\n end\n end\nend",
"def run\n copy_map = copy_map()\n\n mkpath target.to_s\n return false if copy_map.empty?\n\n copy_map.each do |path, source|\n dest = File.expand_path(path, target.to_s)\n if File.directory?(source)\n mkpath dest\n else\n mkpath File.dirname(dest)\n if @mapper.mapper_type\n mapped = @mapper.transform(File.open(source, 'rb') { |file| file.read }, path)\n File.open(dest, 'wb') { |file| file.write mapped }\n else # no mapping\n cp source, dest\n end\n end\n File.chmod(File.stat(source).mode | 0200, dest)\n end\n touch target.to_s\n true\n end",
"def cp(src, dest, options = {})\r\n fu_check_options options, OPT_TABLE['cp']\r\n fu_output_message \"cp#{options[:preserve] ? ' -p' : ''} #{[src,dest].flatten.join ' '}\" if options[:verbose]\r\n return if options[:noop]\r\n fu_each_src_dest(src, dest) do |s, d|\r\n copy_file s, d, options[:preserve]\r\n end\r\n end",
"def cp(src, dest, options = {})\r\n fu_check_options options, OPT_TABLE['cp']\r\n fu_output_message \"cp#{options[:preserve] ? ' -p' : ''} #{[src,dest].flatten.join ' '}\" if options[:verbose]\r\n return if options[:noop]\r\n fu_each_src_dest(src, dest) do |s, d|\r\n copy_file s, d, options[:preserve]\r\n end\r\n end",
"def perform!\n exclude_filter = ''\n @excludes.each { |e| exclude_filter << \" --exclude '#{e}' \" }\n \n @tasks.each do |task|\n prepared_source = prepare_path(task[:source], @source_base_path)\n prepared_target = prepare_path(task[:target], @target_base_path)\n Logger.message \"Perform One-Way-Mirror:\"\n Logger.message \" - Source: #{prepared_source}\"\n Logger.message \" - Target: #{prepared_target}\"\n\n create_dir_if_missing(prepared_target)\n \n `rsync --archive -u -v --delete #{exclude_filter} \"#{prepared_source}\" \"#{prepared_target}\"`\n end\n end",
"def cp(src, dest, options = {})\r\n fu_check_options options, :preserve, :noop, :verbose\r\n fu_output_message \"cp#{options[:preserve] ? ' -p' : ''} #{[src,dest].flatten.join ' '}\" if options[:verbose]\r\n return if options[:noop]\r\n\r\n fu_each_src_dest(src, dest) do |s,d|\r\n fu_preserve_attr(options[:preserve], s, d) {\r\n copy_file s, d\r\n }\r\n end\r\n end",
"def perform_file_copy\n\t\tretrieve_target_dir do |target_dir|\n\t\t\tFileUtils.mkdir_p target_dir\n\t\t\tcopy_depdencies_to target_dir\n\t\tend\t\n\tend",
"def cp srcpath, dstpath\n end",
"def copy(source, destination, **options)\n ensure_same_node(:copy, [source, destination]) do |node|\n node.copy(source, destination, **options)\n end\n end",
"def recursive_copy(path, to: nil)\n path = Pathname(path)\n to = Pathname(to) if to\n\n if path.to_s =~ %r{\\.\\./} || (to && to.to_s =~ %r{\\.\\./})\n fail StandardError, \"Recursive copy parameters cannot contain '/../'\"\n end\n\n if path.relative?\n parent = root_path\n else\n parent, path = path.split\n end\n\n target = work_path\n target /= to if to\n\n tar_cf_cmd = [\"tar\", \"cf\", \"-\", \"-h\", \"-C\", parent, path].map(&:to_s)\n tar_xf_cmd = [\"tar\", \"xf\", \"-\", \"-C\", target].map(&:to_s)\n\n IO.popen(tar_cf_cmd) do |cf|\n IO.popen(tar_xf_cmd, \"w\") do |xf|\n xf.write cf.read\n end\n\n fail StandardError, \"Error running #{tar_xf_cmd.join(\" \")}\" unless $?.success?\n end\n\n fail StandardError, \"Error running #{tar_cf_cmd.join(\" \")}\" unless $?.success?\n end",
"def copy(options)\n destination = copy_destination options\n to_path = join_paths @root_dir, destination\n to_path_exists = File.exist? to_path\n\n preserve_existing = false? options[:overwrite]\n\n copy_resource_to_path to_path, preserve_existing\n copy_pstore_to_path to_path, preserve_existing\n\n to_path_exists\n end",
"def copy(files=[])\n files = ignore_stitch_sources files\n if files.size > 0\n begin\n message = 'copied file'\n message += 's' if files.size > 1\n UI.info \"#{@msg_prefix} #{message.green}\" unless @config[:silent]\n puts '| ' #spacing\n files.each do |file|\n if !check_jekyll_exclude(file)\n path = destination_path file\n FileUtils.mkdir_p File.dirname(path)\n FileUtils.cp file, path\n puts '|' + \" → \".green + path\n else\n puts '|' + \" ~ \".yellow + \"'#{file}' detected in Jekyll exclude, not copying\".red unless @config[:silent]\n end\n end\n puts '| ' #spacing\n\n rescue Exception\n UI.error \"#{@msg_prefix} copy has failed\" unless @config[:silent]\n UI.error e\n stop_server\n throw :task_has_failed\n end\n true\n end\n end",
"def copy_data_dir_here\n copy_all from: content, to: current_dir\nend",
"def copy\n actionlist = actionlist(:copy, copylist)\n\n if actionlist.empty?\n report_nothing_to_generate\n return\n end\n\n #logger.report_startup(job, output)\n\n mkdir_p(output) unless File.directory?(output)\n\n backup(actionlist) if backup?\n\n Dir.chdir(output) do\n actionlist.each do |action, fname|\n atime = Time.now\n how = __send__(\"#{action}_item\", Pathname.new(fname))\n report_create(fname, how, atime)\n end\n #logger.report_complete\n #logger.report_fixes(actionlist.map{|a,f|f})\n end\n end",
"def force_copy\n add option: \"-force-copy\"\n end",
"def copyLocalToRemoteDirectory(sourcePath, destinationPath, dryRun)\n #N Without this, the copy command won't be run at all\n sshAndScp.copyLocalToRemoteDirectory(sourcePath, destinationPath, dryRun)\n end",
"def copyCommon(destPath)\n\tcopyUI(destPath)\n\tcopyEvothings(destPath)\nend",
"def cp(src, dest, preserve: nil, noop: nil, verbose: nil)\n fu_output_message \"cp#{preserve ? ' -p' : ''} #{[src,dest].flatten.join ' '}\" if verbose\n return if noop\n fu_each_src_dest(src, dest) do |s, d|\n copy_file s, d, preserve\n end\n end",
"def cp(source, destination)\n # possibly helpful pieces of information\n\n # if both fs's are the same class a \"cp\" will work in any case\n if @source.class.to_s == @dest.class.to_s\n @source.cp(source, destination)\n return\n end\n\n if same_node?\n case @dest.class.to_s\n when \"MoveIt::FileSystem::Hdfs\"\n @dest.hadoop_fs(\"-copyFromLocal #{source} #{destination}\")\n else\n raise \"cp from same node with different classses is not complete: #{@source.class.to_s} to #{@dest.class.to_s}\"\n end\n else\n raise \"cp from different nodes via proxy is not complete\"\n end\n\n # possible sources:\n # * s3\n # * hdfs\n # * posix\n\n # if same_node?\n # else\n # # tricky!\n # end\n end",
"def recurse\n children = (self[:recurse] == :remote) ? {} : recurse_local\n\n if self[:target]\n recurse_link(children)\n elsif self[:source]\n recurse_remote(children)\n end\n\n # If we're purging resources, then delete any resource that isn't on the\n # remote system.\n mark_children_for_purging(children) if self.purge?\n\n # REVISIT: sort_by is more efficient?\n result = children.values.sort { |a, b| a[:path] <=> b[:path] }\n remove_less_specific_files(result)\n end",
"def copy_tree_to(key, source_root, source_key)\n source_root.unprefixed_subtree_keys(source_key).each do |unprefixed_key|\n copy_content_to(File.join(key, unprefixed_key), source_root, File.join(source_key, unprefixed_key))\n end\n end",
"def perform_sync(source, destination, options)\n new_files, new_files_destination = get_new_files_to_sync(source, destination, options)\n sync_new_files(source, new_files, new_files_destination, options)\n cleanup_files_we_dont_want_to_keep(source, new_files, new_files_destination) unless options[:keep].nil?\n end",
"def FileCopy(src, dst)\n success?(parse(cmd(with_args(src, dst))))\n end",
"def copy_files(dest_dir)\n @package.documents.each do |file|\n ActiveRecord::Base.logger.debug \"copying file #{file.attach.path} in #{File.join(dest_dir, \"\")}\"\n FileUtils.cp(file.attach.path, File.join(dest_dir, \"\"))\n end\n end",
"def copy(from, to)\n @ctx.cp(@path + from, @path + to)\n end",
"def selective_copy(directory, &block)\n Dir[File.join(source_paths, directory)].each do |filename|\n file = filename.to_s.gsub(\"#{Engine.root.to_s}/\", '')\n copy_file file\n end\n end",
"def copy_actions\r\n end",
"def copy(target, copied_folder = nil)\n new_folder = self.dup\n new_folder.parent = target\n new_folder.save!\n\n copied_folder = new_folder if copied_folder.nil?\n\n self.assets.each do |assets|\n assets.copy(new_folder)\n end\n\n self.children.each do |folder|\n unless folder == copied_folder\n folder.copy(new_folder, copied_folder)\n end\n end\n new_folder\n end",
"def fetch\n log.info(log_key) { \"Copying from `#{source_path}'\" }\n\n create_required_directories\n FileSyncer.sync(source_path, project_dir, source_options)\n # Reset target shasum on every fetch\n @target_shasum = nil\n target_shasum\n end",
"def doSingleMoveCopy(action, object_domid, dest_domid, options)\n #parse source for details\n if((result = /^(([A-Z]+\\d+l\\d+)n(\\d+))([st])(\\d+)$/.match(object_domid)))\n #student_id = result[5].to_i\n person_id = result[5].to_i\n old_lesson_id = result[3].to_i\n old_slot_id = result[2]\n @domchange['object_type'] = result[4] == 's' ? 'student' : 'tutor'\n @domchange['from'] = result[1]\n elsif((result = /^([st])(\\d+)/.match(object_domid))) #index area\n #student_id = result[2].to_i\n person_id = result[2].to_i\n @domchange['object_type'] = result[1] == 's' ? 'student' : 'tutor'\n @domchange['action'] = 'copy' # ONLY a copy allowed from index area.\n else\n logger.debug \"neither index or schedule found!!! #{object_domid}\"\n return \"doSingleMoveCopy -- neither index or schedule found!!! #{object_domid}\"\n end\n object_type = @domchange['object_type']\n #parse destination for details\n if((result = /^(([A-Z]+\\d+l\\d+)n(\\d+))/.match(dest_domid)))\n new_lesson_id = result[3].to_i\n new_slot_id = result[2]\n else\n logger.debug \"doSingleMoveCopy -- invalid destination found!!!#{dest_domid.inspect}\"\n return \"doSingleMoveCopy -- invalid destination found!!! #{dest_domid.inspect}\"\n end\n #refine destination details\n if( @domchange['action'] == 'move')\n if @domchange['object_type'] == 'student'\n @role = Role\n .includes(:student)\n .where(:student_id => person_id, :lesson_id => old_lesson_id)\n .first\n else # tutor\n @role = Tutrole\n .includes(:tutor)\n .where(:tutor_id => person_id, :lesson_id => old_lesson_id)\n .first\n end\n # Can only do a single move if not a chain element\n if @role.first != nil\n return \"Cannot perform a single move on a chain element\"\n end\n @role.lesson_id = new_lesson_id\n elsif( @domchange['action'] == 'copy') # copy\n if @domchange['object_type'] == 'student'\n @role = Role.new(:student_id => person_id, :lesson_id => new_lesson_id)\n # Can only do a single copy if not a chain element\n if @role.first != nil\n return \"Cannot perform a single copy on a chain element\"\n end\n # copy relevant info from old role (status & kind)\n if old_lesson_id\n @role_from = Role.where(:student_id => person_id,\n :lesson_id => old_lesson_id).first\n @role.status = @role_from.status\n @role.kind = @role_from.kind\n end\n # handle the move student to global\n if options.has_key? 'to_global'\n @role.kind = options['to_global']\n ###@role.status = 'scheduled'\n @role.status = 'queued'\n end\n else # tutor\n @role = Tutrole.new(:tutor_id => person_id, :lesson_id => new_lesson_id)\n # Can only do a single copy if not a chain element\n if @role.first != nil\n return \"Cannot perform a single copy on a chain element\"\n end\n # copy relevant info from old role (status & kind)\n if old_lesson_id\n @role_from = Tutrole.where(:tutor_id => person_id,\n :lesson_id => old_lesson_id).first\n @role.status = @role_from.status\n @role.kind = @role_from.kind\n end\n end\n end\n render_locals = {:slot => new_slot_id, \n :lesson => new_lesson_id }\n if object_type == 'student'\n render_locals[:student] = @role.student \n render_locals[:thisrole] = @role\n else\n render_locals[:tutor] = @role.tutor \n render_locals[:thistutrole] = @role\n end\n @domchange['html_partial'] = render_to_string(\"calendar/_schedule_\" + object_type + \".html\",\n :formats => [:html], :layout => false,\n :locals => render_locals)\n # the object_id will now change (for both move and copy as the inbuild\n # lesson number will change.\n @domchange['object_id_old'] = @domchange['object_id']\n @domchange['object_id'] = new_slot_id + \"n\" + new_lesson_id.to_s +\n (@domchange['object_type'] == 'student' ? \"s\" : \"t\") +\n person_id.to_s\n # want to hold the name for sorting purposes in the DOM display\n @domchange['name'] = @domchange['object_type'] == 'student' ? @role.student.pname : @role.tutor.pname\n if @role.save\n # no issues\n else\n logger.debug \"unprocessable entity(line 813): \" + @role.errors.messages.inspect \n return @role.errors.messages\n end\n ably_rest.channels.get('calendar').publish('json', @domchange)\n\n # collect the set of stat updates and send through Ably as single message\n statschanges = Array.new\n #get_slot_stats(new_slot_id)\n statschanges.push(get_slot_stats(new_slot_id))\n if(old_slot_id && (new_slot_id != old_slot_id))\n #get_slot_stats(old_slot_id)\n statschanges.push(get_slot_stats(old_slot_id))\n end\n if @role.is_a?(Role)\n ably_rest.channels.get('stats').publish('json', statschanges)\n end\n \n # everything is completed successfully.\n #respond_to do |format|\n # format.json { render json: @domchange, status: :ok }\n #end\n return \"\"\n end",
"def calculate_copies\n # no copies if we don't have an ancestor.\n # no copies if we're going backwards.\n # no copies if we're overwriting.\n return {} unless ancestor && !(backwards? || overwrite?)\n # no copies if the user says not to follow them.\n return {} unless @repo.config[\"merge\", \"followcopies\", Boolean, true]\n\n \n dirs = @repo.config[\"merge\", \"followdirs\", Boolean, false]\n # calculate dem hoes!\n copy, diverge = Amp::Graphs::Mercurial::CopyCalculator.find_copies(self, local, remote, ancestor, dirs)\n \n # act upon each divergent rename (one branch renames to one name,\n # the other branch renames to a different name)\n diverge.each {|of, fl| divergent_rename of, fl }\n \n copy\n end",
"def copy(command)\n src = clean_up(command[1])\n dest = clean_up(command[2])\n pp @client.files.copy(src, dest)\n end",
"def copy_files\n source_dir = Item.new(Path.new(params[:source]))\n dest_dir = Item.new(Path.new(params[:dest]))\n type = params[:type]\n response = {}\n response[:source_dir] = source_dir\n response[:dest_dir] = dest_dir\n if source_dir.copy_files_to(dest_dir, type)\n response[:msg] = \"Success\"\n else\n response[:msg] = \"Fail\"\n end\n render json: response\n end",
"def copyLocalToRemoteDirectory(sourcePath, destinationPath, dryRun)\n #N Without this there won't be a description of the copy operation that can be displayed to the user as feedback\n description = \"SCP: copy directory #{sourcePath} to #{user}@#{host}:#{destinationPath}\"\n #N Without this the user won't see the echoed description\n puts description\n #N Without this check, the files will be copied even if it is only meant to be a dry run.\n if not dryRun\n #N Without this, the files won't actually be copied.\n scpConnection.upload!(sourcePath, destinationPath, :recursive => true)\n end\n end",
"def copy_files(from, to, options={})\n exceptions = options[:except] || []\n\n puts \"Copying files #{from} => #{to}...\" if ENV['VERBOSE']\n\n Dir[\"#{from}/**/*\"].each do |f|\n next unless File.file?(f)\n next if exceptions.include?(File.basename(f))\n\n target = File.join(to, f.gsub(/^#{Regexp.escape from}/, ''))\n\n FileUtils.mkdir_p File.dirname(target)\n puts \"%20s => %-20s\" % [f, target] if ENV['VERBOSE']\n FileUtils.cp f, target\n end\nend",
"def cp(options={})\n from = options[:from]\n from = '*' if from == '.'\n from_list = glob(*from).to_a\n to = options[:to]\n to_path = to\n to_path = expand_path(to_path, :from_wd=>true) unless to.nil? || to == '-'\n if from_list.size == 1\n cp_single_file_or_directory(options.merge(:from=>from_list.first, :to=>to_path))\n else\n if to && to != '-'\n to += '/' unless to =~ %r{/$/}\n end\n from_list.each do |from_item|\n cp_single_file_or_directory(options.merge(:from=>from_item, :to=>to_path))\n end\n end\n end",
"def cp(src, dst, **_opts)\n full_src = full_path(src)\n full_dst = full_path(dst)\n\n mkdir_p File.dirname(full_dst)\n sh! %(cp -a -f #{Shellwords.escape(full_src)} #{Shellwords.escape(full_dst)})\n rescue CommandError => e\n e.status == 1 ? raise(BFS::FileNotFound, src) : raise\n end",
"def post_copy(src_repo,data)\n curl_post(\"#{self.host}/api2/repos/#{src_repo}/fileops/copy/\",data).body_str\n end",
"def copy(src, dst)\n\t\tFileUtils.cp_r(src, dst)\n\t\ttrue\n\trescue Errno::ENOENT\n\t\traise Rush::DoesNotExist, File.dirname(dst)\n\trescue RuntimeError\n\t\traise Rush::DoesNotExist, src\n\tend",
"def copy_recursive(from=nil,to=nil,recursive=nil)\n if from.class == String && to.class == String && (recursive.class == TrueClass || recursive.class == FalseClass) && block_given?\n @j_del.java_method(:copyRecursive, [Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::boolean.java_class,Java::IoVertxCore::Handler.java_class]).call(from,to,recursive,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))\n return self\n end\n raise ArgumentError, \"Invalid arguments when calling copy_recursive(from,to,recursive)\"\n end",
"def copy(src, dst)\n\t\tFileUtils.cp_r(src, dst)\n\t\ttrue\n\trescue Errno::ENOENT\n\t\traise Rush::DoesNotExist, src unless File.exist?(src)\n\t\traise Rush::DoesNotExist, File.dirname(dst)\n\tend",
"def copy(*froms, to)\n froms.each do |from|\n FileUtils.cp(from, to)\n end\n end",
"def create_copy_file_tasks(source_files, source_root, dest_root, invoking_task)\n source_files.each do |source|\n target = source.pathmap(\"%{#{source_root},#{dest_root}}p\")\n directory File.dirname(target)\n file target => [File.dirname(target), source] do |t|\n cp source, target\n end\n task invoking_task => target\n end\nend",
"def copy\n move(:copy)\n end",
"def markSyncOperations\n #N Without this, the sync operations won't be marked\n @sourceContent.markSyncOperationsForDestination(@destinationContent)\n #N Without these puts statements, the user won't receive feedback about what sync operations (i.e. copies and deletes) are marked for execution\n puts \" ================================================ \"\n puts \"After marking for sync --\"\n puts \"\"\n puts \"Local:\"\n #N Without this, the user won't see what local files and directories are marked for copying (i.e. upload)\n @sourceContent.showIndented()\n puts \"\"\n puts \"Remote:\"\n #N Without this, the user won't see what remote files and directories are marked for deleting\n @destinationContent.showIndented()\n end",
"def clone_file source, target, *opts\n cmd = ['cp']\n cmd << '-R' if opts.include? :recursive\n\n if RUBY_PLATFORM.include? 'darwin'\n sh *(cmd + ['-c', source, target]) do |ok|\n break if ok\n if Jekyll.env != 'production'\n $stderr.puts \"Cannot use file cloning, falling back to regular copying\"\n end\n sh *(cmd + [source, target])\n end\n else\n # macOS requires explicit clone argument for copy (see\n # above). Behavior on other platforms is uknown, except for Linux\n # where it occur automatically. Therefore, just doing copy should\n # be fine.\n sh *(cmd + [source, target])\n end\nend",
"def copy_assets src, dest, inclusive=true, missing='exit'\n unless File.file?(src)\n unless inclusive then src = src + \"/.\" end\n end\n src_to_dest = \"#{src} to #{dest}\"\n unless (File.file?(src) || File.directory?(src))\n case missing\n when \"warn\"\n @logger.warn \"Skipping migrate action (#{src_to_dest}); source not found.\"\n return\n when \"skip\"\n @logger.debug \"Skipping migrate action (#{src_to_dest}); source not found.\"\n return\n when \"exit\"\n @logger.error \"Unexpected missing source in migrate action (#{src_to_dest}).\"\n raise \"MissingSourceExit\"\n end\n end\n @logger.debug \"Copying #{src_to_dest}\"\n begin\n FileUtils.mkdir_p(dest) unless File.directory?(dest)\n if File.directory?(src)\n FileUtils.cp_r(src, dest)\n else\n FileUtils.cp(src, dest)\n end\n @logger.info \"Copied #{src} to #{dest}.\"\n rescue Exception => ex\n @logger.error \"Problem while copying assets. #{ex.message}\"\n raise\n end\nend",
"def copy_options(options)\n copy_options = { can_copy: false, ancestor_exist: false, locked: false }\n\n destination = copy_destination options\n to_path = join_paths @root_dir, destination\n to_path_exists = File.exist? to_path\n\n copy_options[:ancestor_exist] = File.exist? parent_path destination\n copy_options[:locked] = can_copy_locked_option to_path, to_path_exists\n copy_options = can_copy_option copy_options, options, to_path_exists\n copy_options\n end",
"def cp (from, to, as: user, on: hosts, quiet: false, once: nil, delete: false)\n self.once once, quiet: quiet do\n log.info \"cp: #{from} -> #{to}\", quiet: quiet do\n Dir.chdir File.dirname(file) do\n hash_map(hosts) do |host|\n host.cp from, to, as: as, quiet: quiet, delete: delete\n end\n end\n end\n end\n end",
"def copy_files(srcGlob, targetDir, taskSymbol)\n mkdir_p targetDir\n FileList[srcGlob].each do |f|\n target = File.join targetDir, File.basename(f)\n file target => [f] do |t|\n cp f, target\n end\n task taskSymbol => target\n end\nend",
"def deploy!\n if copy_cache\n if File.exists?(copy_cache)\n logger.debug \"refreshing local cache to revision #{revision} at #{copy_cache}\"\n system(source.sync(revision, copy_cache))\n else\n logger.debug \"preparing local cache at #{copy_cache}\"\n system(source.checkout(revision, copy_cache))\n end\n\n # Check the return code of last system command and rollback if not 0\n unless $? == 0\n raise Capistrano::Error, \"shell command failed with return code #{$?}\"\n end\n\n FileUtils.mkdir_p(destination)\n\n logger.debug \"copying cache to deployment staging area #{destination}\"\n Dir.chdir(copy_cache) do\n queue = Dir.glob(\"*\", File::FNM_DOTMATCH)\n while queue.any?\n item = queue.shift\n name = File.basename(item)\n\n next if name == \".\" || name == \"..\"\n next if copy_exclude.any? { |pattern| File.fnmatch(pattern, item) }\n\n if File.symlink?(item)\n FileUtils.ln_s(File.readlink(item), File.join(destination, item))\n elsif File.directory?(item)\n queue += Dir.glob(\"#{item}/*\", File::FNM_DOTMATCH)\n FileUtils.mkdir(File.join(destination, item))\n else\n FileUtils.ln(item, File.join(destination, item))\n end\n end\n end\n else\n logger.debug \"getting (via #{copy_strategy}) revision #{revision} to #{destination}\"\n system(command)\n\n if copy_exclude.any?\n logger.debug \"processing exclusions...\"\n if copy_exclude.any?\n copy_exclude.each do |pattern|\n delete_list = Dir.glob(File.join(destination, pattern), File::FNM_DOTMATCH)\n # avoid the /.. trap that deletes the parent directories\n delete_list.delete_if { |dir| dir =~ /\\/\\.\\.$/ }\n FileUtils.rm_rf(delete_list.compact)\n end\n end\n end\n end\n\n # merge stuffs under specific dirs\n if configuration[:merge_dirs]\n configuration[:merge_dirs].each do |dir, dest|\n from = Pathname.new(destination) + dir\n to = Pathname.new(destination) + dest\n logger.trace \"#{from} > #{to}\"\n FileUtils.mkdir_p(to)\n FileUtils.cp_r(Dir.glob(from), to)\n end\n end\n\n # for a rails application in sub directory\n # set :deploy_subdir, \"rails\"\n if configuration[:deploy_subdir]\n subdir = configuration[:deploy_subdir]\n logger.trace \"deploy subdir #{destination}/#{subdir}\"\n Dir.mktmpdir do |dir|\n FileUtils.move(\"#{destination}/#{subdir}\", dir)\n FileUtils.rm_rf destination rescue nil\n FileUtils.move(\"#{dir}/#{subdir}\", \"#{destination}\")\n end\n end\n\n File.open(File.join(destination, \"REVISION\"), \"w\") { |f| f.puts(revision) }\n\n logger.trace \"compressing #{destination} to #{filename}\"\n Dir.chdir(copy_dir) { system(compress(File.basename(destination), File.basename(filename)).join(\" \")) }\n\n distribute!\n ensure\n puts $! if $!\n FileUtils.rm filename rescue nil\n FileUtils.rm_rf destination rescue nil\n FileUtils.rm_rf copy_subdir rescue nil\n end",
"def file_copy(source, dest, options={})\n\t\tFileUtils.cp source, dest, options\n\tend",
"def copy(copydirs)\n unless path(:source) == path(:destination)\n copydirs = copydirs.split(',') if copydirs.is_a? String\n abort(\"Export filter can't copy #{p option(:copydirs)}\") unless copydirs.is_a? Array\n\n copydirs.each do |src|\n dest_subdirs = src[/\\/\\/(.*)/,1] # regex returns any part of src after '//' separator\n src.gsub!('//','/') # collapse '//' separator in source path\n dest = path(:destination).dup # destination path \n dest << '/'+dest_subdirs if dest_subdirs # append any destination subdirectories\n src.insert(0,path(:source)+'/') # prepend source directory\n src << '*' if src[-1,1] == '/' # append '*' when copying directory contents\n log(\"copying '#{src}' to '#{dest}'\")\n FileUtils.mkdir_p(dest) # ensure dest intermediate dirs exist\n FileUtils.cp_r(Dir[src],dest,preserve: true) # Dir globs '*' added above\n end\n end\n end",
"def mirror_dirs (source_dir, target_dir)\n # Skip hidden root source dir files by default.\n source_files = Dir.glob File.join(source_dir, '*')\n case RUBY_PLATFORM\n when /linux|darwin/ then\n source_files.each { | source_file | sh 'cp', '-a', source_file, target_dir }\n else\n cp_r source_files, target_dir, :preserve => true\n end\nend",
"def mirror_missing_destination_files\n # Find the id of the domain we are mirroring\n source_domain = SourceDomain.find_by_namespace(@source_mogile.domain)\n\n # Get the max fid from the mirror db\n # This will only be nonzero if we are doing an incremental\n max_fid = MirrorFile.max_fid\n\n # Process source files in batches.\n Log.instance.info(\"Searching for files in domain [ #{source_domain.namespace} ] whose fid is larger than [ #{max_fid} ].\")\n SourceFile.where('dmid = ? AND fid > ?', source_domain.dmid, max_fid).includes(:domain, :fileclass).find_in_batches(batch_size: 1000) do |batch|\n # Create an array of MirrorFiles which represents files we have mirrored.\n remotefiles = batch.collect { |file| MirrorFile.new(fid: file.fid, dkey: file.dkey, length: file.length, classname: file.classname) }\n\n # Insert the mirror files in a batch format.\n Log.instance.debug('Bulk inserting mirror files.')\n MirrorFile.import remotefiles\n\n # Figure out which files need copied over\n # (either because they are missing or because they have been updated)\n batch_copy_missing_destination_files(remotefiles)\n\n # Show our progress so people know we are working\n summarize\n\n # Quit if program exit has been requested.\n return true if SignalHandler.instance.should_quit\n end\n end",
"def copy_files\n @files.each do |file|\n basename = File.basename file\n FileUtils.cp file, @backup_folder + basename if File.file? file\n FileUtils.cp_r file, @backup_folder + basename if File.directory? file\n end\n end",
"def copy_directory(source, destination)\n FileUtils.cp_r(FileSyncer.glob(\"#{source}/*\"), destination)\n end",
"def copy_directory(source, destination)\n FileUtils.cp_r(FileSyncer.glob(\"#{source}/*\"), destination)\n end",
"def copy_content_to(key, source_root, source_key, metadata = {})\n if source_root.root_type == :s3 and source_root.can_s3_copy_to?(self.name)\n do_multipart = source_root.size(source_key) > AMAZON_CUTOFF_SIZE\n source_object = source_root.s3_object(source_key)\n target_object = s3_object(key)\n source_mtime = source_root.mtime(source_key)\n if source_mtime and !(metadata[:mtime])\n metadata[:mtime] = source_mtime.to_f.to_s\n end\n unless metadata[AMAZON_HEADERS[:md5_sum]]\n metadata[AMAZON_HEADERS[:md5_sum]] = source_root.md5_sum(source_key)\n end\n # metadata? I think the commented out will just copy, but haven't checked.\n source_object.copy_to(target_object, multipart_copy: do_multipart, metadata: metadata, metadata_directive: 'REPLACE')\n #source_object.copy_to(target_object, multipart_copy: do_multipart)\n else\n super\n end\n end",
"def cp_dir(src, dst)\n puts \"#{cmd_color('copying')} #{dir_color(src)}\"\n puts \" -> #{dir_color(dst)}\"\n Find.find(src) do |fn|\n next if fn =~ /\\/\\./\n r = fn[src.size..-1]\n if File.directory? fn\n mkdir File.join(dst,r) unless File.exist? File.join(dst,r)\n else\n cp(fn, File.join(dst,r))\n end\n end\nend",
"def make_copy(src, dest)\n#\tcommandz(\"cp -p #{src} #{dest}\")\n\n\t#Now with Ruby :)\n\tFileUtils.cp(\"#{src}\", \"#{dest}\", :preserve => true )\nend",
"def copy_files\n message \"Checking for existing #{@@app_name.capitalize} install in #{install_directory}\"\n files_yml = File.join(install_directory,'installer','files.yml')\n old_files = read_yml(files_yml) rescue Hash.new\n \n message \"Reading files from #{source_directory}\"\n new_files = sha1_hash_directory_tree(source_directory)\n new_files.delete('/config/database.yml') # Never copy this.\n \n # Next, we compare the original install hash to the current hash. For each\n # entry:\n #\n # - in new_file but not in old_files: copy\n # - in old files but not in new_files: delete\n # - in both, but hash different: copy\n # - in both, hash same: don't copy\n #\n # We really should add a third hash (existing_files) and compare against that\n # so we don't overwrite changed files.\n\n added, changed, deleted, same = hash_diff(old_files, new_files)\n \n if added.size > 0\n message \"Copying #{added.size} new files into #{install_directory}\"\n added.keys.sort.each do |file|\n message \" copying #{file}\"\n copy_one_file(file)\n end\n end\n \n if changed.size > 0\n message \"Updating #{changed.size} files in #{install_directory}\"\n changed.keys.sort.each do |file|\n message \" updating #{file}\"\n copy_one_file(file)\n end\n end\n \n if deleted.size > 0\n message \"Deleting #{deleted.size} files from #{install_directory}\"\n \n deleted.keys.sort.each do |file|\n message \" deleting #{file}\"\n rm(File.join(install_directory,file)) rescue nil\n end\n end\n \n write_yml(files_yml,new_files)\n end",
"def copy(*paths)\n paths = paths.flatten\n mappings = {}\n paths.each do |path|\n if path.is_a? Hash\n mappings.merge! path\n else\n mappings[path] = path\n end\n end\n\n mappings.each do |src, dest|\n ensure_folder dest\n FileUtils.cp src_path(src), dest_path(dest)\n @to_copy.delete src\n end\n end",
"def copy(dest_path, overwrite, depth = nil)\n\n is_new = true\n\n dest = new_for_path dest_path\n unless dest.parent.exist? and dest.parent.collection?\n return Conflict\n end\n\n if dest.exist?\n if overwrite\n FileUtils.rm_r dest.file_path, secure: true\n else\n return PreconditionFailed\n end\n is_new = false\n end\n\n if collection?\n\n if request.depth == 0\n Dir.mkdir dest.file_path\n else\n FileUtils.cp_r(file_path, dest.file_path)\n end\n\n else\n\n FileUtils.cp(file_path, dest.file_path.sub(/\\/$/, ''))\n FileUtils.cp(prop_path, dest.prop_path) if ::File.exist? prop_path\n\n end\n\n is_new ? Created : NoContent\n end",
"def copy_to!(dest)\n Pow(dest).parent.create_directory\n copy_to(dest)\n end",
"def copy(source_dir)\n test_dir = File.dirname(caller[0])\n stage_clear\n srcdir = File.join(test_dir, source_dir)\n Dir[File.join(srcdir, '*')].each do |path|\n FileUtils.cp_r(path, '.')\n end\n end",
"def copy(destdir)\n # Make sure destination is a directory\n File.directory? destdir or raise ArgumentError, \"#{destdir} is not a directory\"\n # Go through files in sorted order\n num_files = self.files.length()\n # These are the files that didn't get copied to the destination dir\n uncopied = []\n self.files.each_index do |i|\n fe = self.files[i]\n # This is the destination filename\n dest = File.join(destdir, fe.archive_filename)\n # If @prune_leading_dir=true, then all files lack the leading\n # directories, so we need to prepend them.\n if @prune_leading_dir\n src = Pathname.new(@dir) + fe.archive_filename\n else\n src = fe.archive_filename\n end\n HDB.verbose and puts \"Copying (##{i+1}/#{num_files}) #{src} to #{dest}\"\n begin\n # Try and copy f to dest\n # NOTE: FileUtils.copy_entry does not work for us since it operates recursively\n # NOTE: FileUtils.copy only works on files\n self.copy_entry(src, dest)\n rescue Errno::ENOSPC\n HDB.verbose and puts \"... out of space\"\n # If the source was a file, we might have a partial copy.\n # If the source was not a file, copying it is likely atomic.\n if File.file?(dest)\n begin\n File.delete(dest)\n rescue Errno::ENOENT\n # None of the file was copied.\n end\n end\n uncopied.push(fe)\n # TODO: This may happen if destination dir doesn't exist\n rescue Errno::ENOENT\n # Src file no longer exists (was removed) - remove from\n # FileSet, as if out of space.\n HDB.verbose and puts \"... deleted before I could copy it!\"\n uncopied.push(fe)\n end\n end\n self.subtract!(uncopied)\n end",
"def make_copy_file_tasks\n @files.each do |source, destination|\n next if source == destination\n next if Rake::FileTask.task_defined? destination\n type = File.directory?(source) ? 'folder' : 'file'\n task = Rake::FileTask.define_task destination do |t|\n folder = File.dirname(t.name)\n FileUtils.mkpath folder unless File.directory? folder\n FileUtils.copy source, t.name\n end\n task.comment = \"Create the #{destination} #{type}\"\n task.enhance ['wix']\n if Rake::FileTask.task_defined? source\n task.enhance [source]\n end\n end\n end",
"def doAllDeleteOperations(dryRun)\n #N Without this, the delete operations won't be executed\n doDeleteOperations(@destinationContent, dryRun)\n end",
"def bc_cloner(item, bc, entity, source, target, replace, options={})\n options = {:debug => false}.merge! options\n debug = options[:debug] or ENV['DEBUG'] === \"true\"\n puts \"DEBUG: bc_cloner method called with debug option enabled\" if debug\n puts \"DEBUG: bc_cloner args: item=#{item}, bc=#{bc}, entity=#{entity}, source=#{source}, target=#{target}, replace=#{replace}\" if debug\n \n files = []\n new_item = (replace ? bc_replacer(item, bc, entity, :debug => debug) : item)\n puts \"DEBUG: new_item=#{new_item}\" if debug\n new_file = File.join target, new_item\n puts \"DEBUG: new_file=#{new_file}\" if debug\n new_source = File.join(source, item)\n puts \"DEBUG: new_source=#{new_source}\" if debug\n if File.directory? new_source\n puts \"DEBUG: \\tcreating directory #{new_file}.\" if debug\n FileUtils.mkdir new_file unless File.directory? new_file\n clone = Dir.entries(new_source).find_all { |e| !e.start_with? '.'}\n clone.each do |recurse|\n files += bc_cloner(recurse, bc, entity, new_source, new_file, replace, :debug => debug)\n end\n else\n #need to inject into the file\n unless replace\n puts \"DEBUG: \\t\\tcopying file #{new_file}.\" if debug\n FileUtils.cp new_source, new_file\n files << new_file\n else\n puts \"DEBUG: \\t\\tcreating file #{new_file}.\" if debug\n t = File.open(new_file, 'w')\n File.open(new_source, 'r') do |f|\n s = f.read\n t.write(bc_replacer(s, bc, entity))\n end\n t.close\n files << new_file\n end\n end\n return files\nend"
] | [
"0.7875499",
"0.6974648",
"0.68315053",
"0.6339092",
"0.6339092",
"0.62084794",
"0.61457634",
"0.6096766",
"0.60643005",
"0.60626996",
"0.5976893",
"0.5955779",
"0.5845902",
"0.5791096",
"0.5759361",
"0.57527834",
"0.5723526",
"0.56811875",
"0.5678704",
"0.5674515",
"0.5658498",
"0.5652239",
"0.5632697",
"0.5622759",
"0.56201416",
"0.5619304",
"0.55960137",
"0.5588649",
"0.5587154",
"0.5567216",
"0.5562414",
"0.55496556",
"0.55452216",
"0.55452216",
"0.5541314",
"0.5538489",
"0.55230564",
"0.55179286",
"0.5510904",
"0.55088824",
"0.54598564",
"0.54589057",
"0.5446969",
"0.5443447",
"0.5443397",
"0.54322064",
"0.54315263",
"0.54231393",
"0.5413615",
"0.5409688",
"0.53953284",
"0.5381539",
"0.53177196",
"0.5309285",
"0.5292395",
"0.52846617",
"0.5273003",
"0.52687913",
"0.5268725",
"0.5252373",
"0.5245611",
"0.52439696",
"0.5240924",
"0.52371824",
"0.5229566",
"0.5227915",
"0.5224127",
"0.5211871",
"0.52086186",
"0.5208339",
"0.5206214",
"0.51916426",
"0.51873195",
"0.5185001",
"0.5184227",
"0.5181362",
"0.517284",
"0.5168081",
"0.51674056",
"0.516411",
"0.5158833",
"0.5150955",
"0.51483274",
"0.51446956",
"0.5140526",
"0.5132326",
"0.5122642",
"0.5122642",
"0.5113334",
"0.5108513",
"0.5098014",
"0.5094448",
"0.50810444",
"0.5075618",
"0.50753534",
"0.50748736",
"0.5069138",
"0.50683707",
"0.5068233",
"0.50679505"
] | 0.78498006 | 1 |
Recursively perform all marked delete operations on the destination content tree, or if dryRun, just pretend to perform them. N Without this, we wouldn't have a way to delete files and directories in the remote destination directory which have been marked for deletion (optionally doing it dry run only) | def doDeleteOperations(destinationContent, dryRun)
#N Without this loop, we won't delete all sub-directories or files and directories within sub-directories which have been marked for deletion
for dir in destinationContent.dirs
#N Without this check, we would delete directories which have not been marked for deletion (which would be incorrect)
if dir.toBeDeleted
#N Without this, we won't know the full path of the remote directory to be deleted
dirPath = destinationLocation.getFullPath(dir.relativePath)
#N Without this, the remote directory marked for deletion won't get deleted
destinationLocation.contentHost.deleteDirectory(dirPath, dryRun)
else
#N Without this, files and sub-directories within this sub-directory which are marked for deletion (even though the sub-directory as a whole hasn't been marked for deletion) won't get deleted.
doDeleteOperations(dir, dryRun)
end
end
#N Without this loop, we won't delete files within this directory which have been marked for deletion.
for file in destinationContent.files
#N Without this check, we would delete this file even though it's not marked for deletion (and therefore should not be deleted)
if file.toBeDeleted
#N Without this, we won't know the full path of the file to be deleted
filePath = destinationLocation.getFullPath(file.relativePath)
#N Without this, the file won't actually get deleted
destinationLocation.contentHost.deleteFile(filePath, dryRun)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def doAllDeleteOperations(dryRun)\n #N Without this, the delete operations won't be executed\n doDeleteOperations(@destinationContent, dryRun)\n end",
"def recurse\n children = (self[:recurse] == :remote) ? {} : recurse_local\n\n if self[:target]\n recurse_link(children)\n elsif self[:source]\n recurse_remote(children)\n end\n\n # If we're purging resources, then delete any resource that isn't on the\n # remote system.\n mark_children_for_purging(children) if self.purge?\n\n # REVISIT: sort_by is more efficient?\n result = children.values.sort { |a, b| a[:path] <=> b[:path] }\n remove_less_specific_files(result)\n end",
"def remove_superfluous_destination_files\n # join mirror_file and dest_file and delete everything from dest_file which isn't in mirror_file\n # because mirror_file should represent the current state of the source mogile files\n Log.instance.info('Joining destination and mirror tables to determine files that have been deleted from source repo.')\n DestFile.where('mirror_file.dkey IS NULL').joins('LEFT OUTER JOIN mirror_file ON mirror_file.dkey = file.dkey').find_in_batches(batch_size: 1000) do |batch|\n batch.each do |file|\n # Quit if program exit has been requested.\n break if SignalHandler.instance.should_quit\n\n # Delete all files from our destination domain which no longer exist in the source domain.\n begin\n Log.instance.debug(\"key [ #{file.dkey} ] should not exist. Deleting.\")\n @dest_mogile.delete(file.dkey)\n @removed += 1\n @freed_bytes += file.length\n rescue => e\n @failed += 1\n Log.instance.error(\"Error deleting [ #{file.dkey} ]: #{e.message}\\n#{e.backtrace}\")\n end\n end\n\n # Print a summary to the user.\n summarize\n\n # Quit if program exit has been requested.\n return true if SignalHandler.instance.should_quit\n end\n end",
"def removed_unmarked_paths\n #remove dirs\n dirs_enum = @dirs.each_value\n loop do\n dir_stat = dirs_enum.next rescue break\n if dir_stat.marked\n dir_stat.marked = false # unset flag for next monitoring\\index\\remove phase\n #recursive call\n dir_stat.removed_unmarked_paths\n else\n # directory is not marked. Remove it, since it does not exist.\n write_to_log(\"NON_EXISTING dir: \" + dir_stat.path)\n # remove file with changed checksum\n $local_content_data_lock.synchronize{\n $local_content_data.remove_directory(dir_stat.path, Params['local_server_name'])\n }\n rm_dir(dir_stat)\n end\n end\n\n #remove files\n files_enum = @files.each_value\n loop do\n file_stat = files_enum.next rescue break\n if file_stat.marked\n file_stat.marked = false # unset flag for next monitoring\\index\\remove phase\n else\n # file not marked meaning it is no longer exist. Remove.\n write_to_log(\"NON_EXISTING file: \" + file_stat.path)\n # remove file with changed checksum\n $local_content_data_lock.synchronize{\n $local_content_data.remove_instance(Params['local_server_name'], file_stat.path)\n }\n # remove from tree\n @files.delete(file_stat.path)\n end\n end\n end",
"def delete_content_paths\n\n # Delete all the paths with the ancestor as the current id\n ContentPath.delete_all(:ancestor => self.id)\n\n # Delete all the paths with the descendant as the current id\n ContentPath.delete_all(:descendant => self.id)\n end",
"def delete_branch\n #we'll get all descendants by level descending order. That way we'll make sure deletion will come from children to parents\n children_to_be_deleted = self.class.find(:all, :conditions => \"id_path like '#{self.id_path},%'\", :order => \"level desc\")\n children_to_be_deleted.each {|d| d.destroy}\n #now delete my self :)\n self.destroy\n end",
"def safe_destroy\n if self.is_root? && self.original_post?\n Comment.transaction do\n self.descendants.each{|c| c.destroy }\n end\n self.destroy\n else\n self.update_attribute('deleted', true)\n end\n end",
"def action_delete\n if @current_resource.exist?\n converge_by \"Delete #{r.path}\" do\n backup unless ::File.symlink?(r.path)\n ::File.delete(r.path)\n end\n r.updated_by_last_action(true)\n load_new_resource_state\n r.exist = false\n else\n Chef::Log.debug \"#{r.path} does not exists - nothing to do\"\n end\n end",
"def doCopyOperations(sourceContent, destinationContent, dryRun)\n #N Without this loop, we won't copy the directories that are marked for copying\n for dir in sourceContent.dirs\n #N Without this check, we would attempt to copy those directories _not_ marked for copying (but which might still have sub-directories marked for copying)\n if dir.copyDestination != nil\n #N Without this, we won't know what is the full path of the local source directory to be copied\n sourcePath = sourceLocation.getFullPath(dir.relativePath)\n #N Without this, we won't know the full path of the remote destination directory that this source directory is to be copied into\n destinationPath = destinationLocation.getFullPath(dir.copyDestination.relativePath)\n #N Without this, the source directory won't actually get copied\n destinationLocation.contentHost.copyLocalToRemoteDirectory(sourcePath, destinationPath, dryRun)\n else\n #N Without this, we wouldn't copy sub-directories marked for copying of this sub-directory (which is not marked for copying in full)\n doCopyOperations(dir, destinationContent.getDir(dir.name), dryRun)\n end\n end\n #N Without this loop, we won't copy the files that are marked for copying\n for file in sourceContent.files\n #N Without this check, we would attempt to copy those files _not_ marked for copying\n if file.copyDestination != nil\n #N Without this, we won't know what is the full path of the local file to be copied\n sourcePath = sourceLocation.getFullPath(file.relativePath)\n #N Without this, we won't know the full path of the remote destination directory that this source directory is to be copied into\n destinationPath = destinationLocation.getFullPath(file.copyDestination.relativePath)\n #N Without this, the file won't actually get copied\n destinationLocation.contentHost.copyLocalFileToRemoteDirectory(sourcePath, destinationPath, dryRun)\n end\n end\n end",
"def markDeleteOptions(sourceDir)\n #N Without this we can't loop over the immediate sub-directories to determine how each one needs to be marked for deleting\n for dir in dirs\n #N Without this we won't have the corresponding sub-directory in the other directory with the same name as this sub-directory (if it exists)\n sourceSubDir = sourceDir.getDir(dir.name)\n #N Without this check, we won't be able to correctly process a sub-directory based on whether or not one with the same name exists in the other directory\n if sourceSubDir == nil\n #N Without this, this directory won't be deleted, even though it doesn't exist at all in the corresponding source directory\n dir.markToDelete()\n else\n #N Without this, files and directories missing from the other source sub-directory (which does exist) won't get deleted\n dir.markDeleteOptions(sourceSubDir)\n end\n end\n #N Without this we can't loop over the files to determine which ones need to be marked for deleting\n for file in files\n #N Without this we won't known if the corresponding file in the source directory with the same name as this file exists\n sourceFile = sourceDir.getFile(file.name)\n #N Without this check, we will incorrectly delete this file whether or not it exists in the source directory\n if sourceFile == nil\n #N Without this, this file which doesn't exist in the source directory won't get deleted from this directory\n file.markToDelete()\n end\n end\n end",
"def delete( object )\n\n write_targets do |target|\n rel = rel_for_object( object )\n target.reject! { |l| l['rel'] == rel }\n end\n\n if (c = @klass.correlation_for( object )) && c.recipocal?\n if self.owner && object.respond_to?( :links )\n if object.links.recipocal?( self.owner )\n object.links.delete( self.owner )\n object.save unless object.new? || @recipocating\n end\n end\n end\n\n self.owner.save if self.owner && !self.owner.new? && !@recipocating\n\n self\n end",
"def deleteDirectory(dirPath, dryRun)\n #N Without this, the required ssh command to recursive remove a directory won't be (optionally) executed. Without the '-r', the attempt to delete the directory won't be successful.\n ssh(\"rm -r #{dirPath}\", dryRun)\n end",
"def delete\n extract.children.to_a.each(&:extract)\n end",
"def deleteFile(filePath, dryRun)\n #N Without this, the deletion command won't be run at all\n sshAndScp.deleteFile(filePath, dryRun)\n end",
"def remove_folder\n space = Space.accessible_by(@context).find(params[:id])\n ids = Node.sin_comparison_inputs(unsafe_params[:ids])\n\n if space.contributor_permission(@context)\n nodes = Node.accessible_by(@context).where(id: ids)\n\n UserFile.transaction do\n nodes.update(state: UserFile::STATE_REMOVING)\n\n nodes.where(sti_type: \"Folder\").find_each do |folder|\n folder.all_children.each { |node| node.update!(state: UserFile::STATE_REMOVING) }\n end\n\n Array(nodes.pluck(:id)).in_groups_of(1000, false) do |ids|\n job_args = ids.map do |node_id|\n [node_id, session_auth_params]\n end\n\n Sidekiq::Client.push_bulk(\"class\" => RemoveNodeWorker, \"args\" => job_args)\n end\n end\n\n flash[:success] = \"Object(s) are being removed. This could take a while.\"\n else\n flash[:warning] = \"You have no permission to remove object(s).\"\n end\n\n redirect_to files_space_path(space)\n end",
"def markSyncOperationsForDestination(destination)\n markCopyOperations(destination)\n destination.markDeleteOptions(self)\n end",
"def rest__delete_remote\n remote_module_name = ret_non_null_request_params(:remote_module_name)\n remote_namespace = ret_request_params(:remote_module_namespace)\n force_delete = ret_request_param_boolean(:force_delete)\n\n remote_params = remote_params_dtkn(:node_module, remote_namespace, remote_module_name)\n client_rsa_pub_key = ret_request_params(:rsa_pub_key)\n project = get_default_project()\n\n NodeModule.delete_remote(project, remote_params, client_rsa_pub_key, force_delete)\n rest_ok_response\n end",
"def delete(delete_files=true)\n if delete_files\n Bplmodels::File.find_in_batches('is_file_of_ssim'=>\"info:fedora/#{self.pid}\") do |group|\n group.each { |solr_file|\n file = Bplmodels::File.find(solr_file['id']).adapt_to_cmodel\n file.delete\n }\n end\n end\n\n #FIXME: What if this is interuppted? Need to do this better...\n #Broken so no match for now\n if self.class.name == \"Bplmodels::Volume2\"\n next_object = nil\n previous_object = nil\n #volume_object = Bplmodels::Finder.getVolumeObjects(self.pid)\n self.relationships.each_statement do |statement|\n puts statement.predicate\n if statement.predicate == \"http://projecthydra.org/ns/relations#isPrecedingVolumeOf\"\n next_object = ActiveFedora::Base.find(statement.object.to_s.split('/').last).adapt_to_cmodel\n elsif statement.predicate == \"http://projecthydra.org/ns/relations#isFollowingVolumeOf\"\n previous_object = ActiveFedora::Base.find(statement.object.to_s.split('/').last).adapt_to_cmodel\n end\n end\n\n if next_object.present? and previous_object.present?\n next_object.relationships.each_statement do |statement|\n if statement.predicate == \"http://projecthydra.org/ns/relations#isFollowingVolumeOf\"\n next_object.remove_relationship(:is_following_volume_of, statement.object)\n end\n end\n\n previous_object.relationships.each_statement do |statement|\n if statement.predicate == \"http://projecthydra.org/ns/relations#isPrecedingVolumeOf\"\n previous_object.remove_relationship(:is_preceding_volume_of, statement.object)\n end\n end\n\n next_object.add_relationship(:is_following_volume_of, \"info:fedora/#{previous_object.pid}\", true)\n previous_object.add_relationship(:is_preceding_volume_of, \"info:fedora/#{next_object.pid}\", true)\n next_object.save\n previous_object.save\n elsif next_object.present? and previous_object.blank?\n next_object.relationships.each_statement do |statement|\n if statement.predicate == \"http://projecthydra.org/ns/relations#isFollowingVolumeOf\"\n next_object.remove_relationship(:is_following_volume_of, statement.object)\n end\n end\n\n elsif next_object.blank? and previous_object.present?\n previous_object.relationships.each_statement do |statement|\n if statement.predicate == \"http://projecthydra.org/ns/relations#isPrecedingVolumeOf\"\n previous_object.remove_relationship(:is_preceding_volume_of, statement.object)\n end\n end\n end\n self.collection.first.update_index\n end\n # remove the cached IIIF manifest (may not exist, so no worry about response)\n unless self.class.name == 'Bplmodels::OAIObject'\n Typhoeus::Request.post(\"#{BPL_CONFIG_GLOBAL['commonwealth_public']}/search/#{self.pid}/manifest/cache_invalidate\")\n end\n super()\n end",
"def clean\n if File.exist?(@destination)\n Monolith.formatter.clean(@cookbook, @destination)\n FileUtils.rm_rf(@destination)\n true\n else\n rel_dest = Monolith.formatter.rel_dir(@destination)\n Monolith.formatter.skip(@cookbook, \"#{rel_dest} doesn't exist\")\n nil\n end\n end",
"def erase\n HDB.verbose and puts \"Erasing successfully-copied files\"\n unlinkable = @files.collect do |x|\n f = get_real_filename(x)\n File.directory?(f) or File.symlink?(f)\n end\n # TODO: unlink them now.\n # TODO: rmdir directories, starting with child nodes first\n raise \"erase unimplemented\"\n end",
"def deleteDirectory(dirPath, dryRun)\n #N Without this, the deletion command won't be run at all\n sshAndScp.deleteDirectory(dirPath, dryRun)\n end",
"def doAllCopyOperations(dryRun)\n #N Without this, the copy operations won't be executed\n doCopyOperations(@sourceContent, @destinationContent, dryRun)\n end",
"def destroy\n @related_content = RelatedContent.find(params[:id])\n @related_content.destroy\n dirname = \"#{RelatedContent::UPLOAD_DIR}/#{@related_content.id}\"\n FileUtils.rm_rf dirname\t\n redirect_to @related_content.node\t \n\nend",
"def delete_dir_contents(target_dir)\n Find.find(target_dir) do |x|\n if File.file?(x)\n FileUtils.rm(x)\n elsif File.directory?(x) && x != target_dir\n FileUtils.remove_dir(x)\n end\n end\n end",
"def run_on_deletion(paths)\n end",
"def run_on_deletion(paths)\n end",
"def delete_directory_contents(options)\n Process::Delete::DirectoryContents.delete(options[:directory_path])\n end",
"def action_delete\n if (!dir_exists?(@path))\n Chef::Log::info(\"Directory #{ @path } doesn't exist; delete action not taken\")\n else\n converge_by(\"Delete #{ @new_resource }\") do\n @client.delete(@path)\n end\n new_resource.updated_by_last_action(true)\n end\n end",
"def remove(path, ctype, recursive=false, preserve_metadata=false)\n prune = recursive ? nil : 1\n count = 0\n nodes = @content_tree.subtree(path, ctype, prune)\n # NOTE: delete children first, hence the reverse()\n nodes.reverse.each do |node|\n ntype = node.node_type\n # first remove all files, then remove directories\n next if (node.kind_of? ContentRepo::DirNode)\n @content_tree.remove_node(node)\n remove_doc_resources(from_path, to_path) if ntype == :document\n remove_metadata(node.path, ntype, nil) unless preserve_metadata\n notify(EVENT_REMOVE, path, ctype)\n count += 1\n end\n\n # Remove all empty directories under path\n content_tree.remove_empty_dirs(path)\n metadata_tree.remove_empty_dirs(path)\n\n count\n end",
"def safe_delete_contents\n SafeDeletable.path_for(self).children.each {|entry| FileUtils.remove_entry_secure(entry) }\n end",
"def delete current_user\n raise RequestError.new(:internal_error, \"Delete: no user specified\") if current_user.nil?\n\n # remove all its files\n self.files.each { |item| item.delete current_user }\n # remove all its children, meaning all its subdirectories. (all sub-sub-directories and sub-files will me removed as well)\n self.childrens.each { |children| children.delete current_user }\n\n if current_user.id != self.user_id then # if random owner \n # remove all links between this folder and the current user only\n FileUserAssociation.all(x_file_id: self.id, user_id: current_user.id).destroy!\n # remove all associations where this folder is a children of a folder belonging to the current user only\n FolderFolderAssociation.all(children_id: self.id).each do |asso|\n asso.destroy! if current_user.x_files.get(asso.parent_id)\n end\n # No sharing for folders: no SharedToMeAssociations\n\n else # if true owner \n # remove all links between this folder and ALL users\n FileUserAssociation.all(x_file_id: self.id).destroy!\n # remove all associations where this folder is a children of a folder belonging ALL users\n FolderFolderAssociation.all(children_id: self.id).destroy!\n # No sharing for folders: no SharedByMeAssociations\n\n # No need to remove the association where this folder is a parent (of a file or folder)\n # because the children have already been removed and all theirs associations\n #\n # FolderFolderAssociation.all(parent_id: self.id).destroy!\n # FileFolderAssociation.all(parent_id: self.id).destroy!\n \n # now remove the entity\n self.destroy!\n end\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = DeleteFolderResultSet.new(resp)\n return results\n end",
"def deleteFile(filePath, dryRun)\n #N Without this, the required ssh command to delete a file won't be (optionally) executed.\n ssh(\"rm #{filePath}\", dryRun)\n end",
"def destroy\n \n # Add logic: if the folder is not the Trash folder, move the files \n # to the Trash folder. Otherwise, really do the delete as implemented\n # below. Complication: prevent Carrierwave from deleting the files\n # from the upload directory if we're just moving them to the trash.\n # Actually, if you don't call document.destroy, then the callback in\n # Carrierwave won't be triggered.\n \n folder_id = params[:folder_id]\n document_id = params[:id]\n document = Document.find(document_id)\n url = document.content.url\n \n # Destroy by hand so we can maintain the link count via\n # transaction. We should change this to an after_destroy\n # callback.\n \n count = Link.where(document_id: document_id).size\n link = Link.where(document_id: document_id, folder_id: folder_id).first\n ActiveRecord::Base.transaction do\n link.destroy if link\n if count == 1\n document = Document.find(document_id)\n document.destroy\n end\n end\n \n logger.info(\"Deleting file at URL: #{url}\")\n # Carrierwave does the actual delete.\n \n respond_with(nil)\n end",
"def delete(node=nil, root=nil, &block)\n return super(node, root) do | dn | \n block.call(dn) if block\n dn.update_left_size(:deleted, -1) if dn\n end\n end",
"def ftp_remove path\n return ftp_action(true, path)\n end",
"def pull_dir(localpath, remotepath, options = {}, &block)\n connect! unless @connection\n @recursion_level += 1\n\n todelete = Dir.glob(File.join(localpath, '*'))\n \n tocopy = []\n recurse = []\n\n # To trigger error if path doesnt exist since list will\n # just return and empty array\n @connection.chdir(remotepath)\n\n @connection.list(remotepath) do |e|\n entry = Net::FTP::List.parse(e)\n \n paths = [ File.join(localpath, entry.basename), \"#{remotepath}/#{entry.basename}\".gsub(/\\/+/, '/') ]\n\n if entry.dir?\n recurse << paths\n elsif entry.file?\n if options[:since] == :src\n tocopy << paths unless File.exist?(paths[0]) and entry.mtime < File.mtime(paths[0]) and entry.filesize == File.size(paths[0])\n elsif options[:since].is_a?(Time)\n tocopy << paths unless entry.mtime < options[:since] and File.exist?(paths[0]) and entry.filesize == File.size(paths[0])\n else\n tocopy << paths\n end\n end\n todelete.delete paths[0]\n end\n \n tocopy.each do |paths|\n localfile, remotefile = paths\n unless should_ignore?(localfile)\n begin\n @connection.get(remotefile, localfile)\n log \"Pulled file #{remotefile}\"\n rescue Net::FTPPermError\n log \"ERROR READING #{remotefile}\"\n raise Net::FTPPermError unless options[:skip_errors]\n end\n end\n end\n \n recurse.each do |paths|\n localdir, remotedir = paths\n Dir.mkdir(localdir) unless File.exist?(localdir)\n pull_dir(localdir, remotedir, options, &block)\n end\n \n if options[:delete]\n todelete.each do |p|\n block_given? ? yield(p) : FileUtils.rm_rf(p)\n log \"Removed path #{p}\"\n end\n end\n \n @recursion_level -= 1\n close! if @recursion_level == 0\n rescue Net::FTPPermError\n close!\n raise Net::FTPPermError\n end",
"def exec__delete(opts = {})\n task = Task.create_top_level(model_handle(:task), self, task_action: 'delete and destroy')\n ret = {\n assembly_instance_id: self.id,\n assembly_instance_name: self.display_name_print_form\n }\n opts.merge!(skip_running_check: true)\n \n if !opts[:recursive] && is_target_service_instance?\n staged_instances = get_children_instances(self)\n service_instances = []\n staged_instances.each do |v|\n service_instances << v[:display_name]\n end\n fail ErrorUsage, \"The context service cannot be deleted because there are service instances dependent on it (#{service_instances.join(', ')}). Please use flag '-r' to remove all.\" unless staged_instances.empty?\n end\n \n if opts[:recursive]\n fail ErrorUsage, \"You can use recursive delete with target service instances only!\" unless is_target_service_instance?\n delete_recursive(self, task, opts)\n end\n\n return nil unless self_subtask = delete_instance_task?(self, opts)\n\n if is_target_service_instance?\n task.add_subtask(self_subtask)\n else\n task = self_subtask\n end\n\n task = task.save_and_add_ids\n\n task.subtasks.each do |st|\n if st[:display_name].include?(\"ec2\")\n ret.merge!(has_ec2: true)\n end\n end\n \n Workflow.create(task).defer_execution\n \n ret.merge(task_id: task.id)\n end",
"def perform!\n exclude_filter = ''\n @excludes.each { |e| exclude_filter << \" --exclude '#{e}' \" }\n \n @tasks.each do |task|\n prepared_source = prepare_path(task[:source], @source_base_path)\n prepared_target = prepare_path(task[:target], @target_base_path)\n Logger.message \"Perform One-Way-Mirror:\"\n Logger.message \" - Source: #{prepared_source}\"\n Logger.message \" - Target: #{prepared_target}\"\n\n create_dir_if_missing(prepared_target)\n \n `rsync --archive -u -v --delete #{exclude_filter} \"#{prepared_source}\" \"#{prepared_target}\"`\n end\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = DeleteFileOrFolderResultSet.new(resp)\n return results\n end",
"def perform(file_set_id)\n file_set = query_service.find_by(id: Valkyrie::ID.new(file_set_id))\n Valkyrie::DerivativeService.for(FileSetChangeSet.new(file_set)).cleanup_derivatives\n rescue Valkyrie::Persistence::ObjectNotFoundError\n Rails.logger.error \"Unable to find FileSet #{file_set_id} for deletion, derivative files are probably left behind\"\n end",
"def perform\n ActiveRecord::Base.transaction do\n reply.update(deleted: true)\n reply.taggings.delete_all\n reply.mentionings.delete_all\n end\n end",
"def destroy\n delete_files_and_empty_parent_directories\n end",
"def delete\n begin \n # file_assets\n file_assets.each do |file_asset|\n file_asset.delete\n end\n # We now reload the self to update that the child assets have been removed...\n reload()\n # Call ActiveFedora Deleted via super \n super()\n rescue Exception => e\n raise \"There was an error deleting the resource: \" + e.message\n end\n end",
"def delete_logic( defer = false, mask_exceptions = true )\n if defer\n database.add_to_bulk_cache( { '_id' => self['_id'], '_rev' => rev, '_deleted' => true } )\n else\n begin\n delete_now\n rescue Exception => e\n if mask_exceptions || e.class == CouchDB::ResourceNotFound\n false\n else \n raise e\n end \n end \n end \n end",
"def delete_all\n Neo.db.execute_query(\"#{initial_match} OPTIONAL MATCH (n0)-[r]-() DELETE n0,r\")\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = DeleteRealFolderResultSet.new(resp)\n return results\n end",
"def delete_source_files source\n dir = Conf::directories\n base = File.join(dir.data)\n source.folders.each do |fold|\n url = File.join(dir.store,source.name.to_s,fold)\n delete_files_from url\n url = File.join(dir.backup,source.name.to_s,fold)\n delete_files_from url\n end\n Logger.<<(__FILE__,\"INFO\",\"Deleted files server & backup for #{source.name.to_s}\")\n end",
"def delete_root\n Dir.chdir(root) do\n Dir.entries('.').each do |entry|\n next if entry == '.' || entry == '..'\n next if entry == FILES_DIR && task.options.copy_files_with_symlink\n\n begin\n FileUtils.remove_entry_secure(entry)\n rescue\n if task.options.copy_files_with_symlink\n print_title('Cannot automatically empty ' + root + '. Please manually empty this directory (except for ' + root + '/' + FILES_DIR + ') and then hit any key to continue...')\n else\n print_title('Cannot automatically empty ' + root + '. Please manually empty this directory and then hit any key to continue...')\n end\n STDIN.getch\n break\n end\n end\n end\n\n logger.info(\"#{root} content was deleted\")\n end",
"def delete\n # no need to delete all the associations because root_folder.delete does it\n self.root_folder.delete self\n # remove all friendships where the user is the source\n Friendship.all(source_id: self.id).destroy!\n # remove all friendships where the user is the target\n Friendship.all(target_id: self.id).destroy!\n\n # remove all associations where this user receives a file >BY< another user\n SharedToMeAssociation.all(user_id: self.id).destroy!\n # remove all associations where this user shared a file >TO< another user\n SharedByMeAssociation.all(user_id: self.id).destroy!\n\n self.destroy!\n end",
"def delete(*records)\n load_target\n flatten_deeper(records).compact.each do |record|\n unless @target.delete(record).nil?\n callback(:before_remove, record)\n unlinks << record\n links.delete(record)\n record.send(:mark_as_linked, false)\n callback(:after_remove, record)\n end\n end\n self\n end",
"def delete_all\n objs = target\n source.update_attribute(source_attribute, nil)\n objs.each(&:delete)\n end",
"def delete_files_and_empty_parent_directories\n style_names = reflection.styles.map{|style| style.name} << :original\n # If the attachment was set to nil, we need the original value\n # to work out what to delete.\n if column_name = reflection.column_name_for_stored_attribute(:file_name)\n interpolation_params = {:basename => record.send(\"#{column_name}_was\")}\n else\n interpolation_params = {}\n end\n style_names.each do |style_name|\n path = interpolate_path(style_name, interpolation_params) or\n next\n FileUtils.rm_f(path)\n begin\n loop do\n path = File.dirname(path)\n FileUtils.rmdir(path)\n end\n rescue Errno::EEXIST, Errno::ENOTEMPTY, Errno::ENOENT, Errno::EINVAL, Errno::ENOTDIR\n # Can't delete any further.\n end\n end\n end",
"def rest__delete_remote\n remote_module_name = ret_non_null_request_params(:remote_module_name)\n remote_namespace = ret_request_params(:remote_module_namespace)\n force_delete = ret_request_param_boolean(:force_delete)\n\n remote_params = remote_params_dtkn(:test_module, remote_namespace, remote_module_name)\n client_rsa_pub_key = ret_request_params(:rsa_pub_key)\n\n project = get_default_project()\n TestModule.delete_remote(project, remote_params, client_rsa_pub_key, force_delete)\n rest_ok_response\n end",
"def delete\n return false unless terminated?\n\n parent = self.parent\n parent.disown(self) if parent\n\n children = self.children\n aliases = self.aliases\n\n # delete all SideJob keys and disown all children\n ports = inports.map(&:redis_key) + outports.map(&:redis_key)\n SideJob.redis.multi do |multi|\n multi.srem 'jobs', id\n multi.del redis_key\n multi.del ports + %w{worker status state aliases parent children inports outports inports:default outports:default inports:channels outports:channels created_at created_by ran_at}.map {|x| \"#{redis_key}:#{x}\" }\n children.each_value { |child| multi.hdel child.redis_key, 'parent' }\n aliases.each { |name| multi.hdel('jobs:aliases', name) }\n end\n\n # recursively delete all children\n children.each_value do |child|\n child.delete\n end\n\n publish({deleted: true})\n return true\n end",
"def rm_rf(z, path)\n z.get_children(:path => path).tap do |h|\n if h[:rc].zero?\n h[:children].each do |child|\n rm_rf(z, File.join(path, child))\n end\n elsif h[:rc] == ZNONODE\n # no-op\n else\n raise \"Oh noes! unexpected return value! #{h.inspect}\"\n end\n end\n\n rv = z.delete(:path => path)\n\n unless (rv[:rc].zero? or rv[:rc] == ZNONODE)\n raise \"oh noes! failed to delete #{path}\" \n end\n\n path\n end",
"def delete(user)\n Rails.logger.debug \"Call to article.delete\"\n photo_deletion = true #Initialize the photo deletion flag to true\n if self.picture.any? #Check if there are any photos related to the article\n for picture_obj in self.picture #Delete all photo nodes owned by the article\n photo = Photo.new(id:picture_obj[\"nodeId\"])#Create the node object to delete\n resp_photo = photo.delete(user)#Delete the photo node\n if !resp_photo[0] #An error has ocurred when deleting photos\n photo_deletion = false #Set the photo deletion flag to false\n end\n end\n Util.delete_image_folder(@@images_directory,self.id.to_s)#Delete the entire image folder related to the article\n end\n \n if !photo_deletion #Validate if there were error when deleting photos\n return false, resp[1], resp[2] #Return error\n end\n\n reqUrl = \"/api/newsArticle/#{self.id}\" #Set the request url\n rest_response = MwHttpRequest.http_delete_request(reqUrl,user['email'],user['password']) #Make the DELETE request to the server with the required parameters\n Rails.logger.debug \"Response from server: #{rest_response.code} #{rest_response.message}: #{rest_response.body}\"\n if rest_response.code == \"200\" #Validate if the response from the server is 200, which means OK\n return true, rest_response #Return success\n else\n return false, \"#{rest_response.code}\", \"#{rest_response.message}\" #Return error\n end\n end",
"def delete_recursive(path=nil,recursive=nil)\n if path.class == String && (recursive.class == TrueClass || recursive.class == FalseClass) && block_given?\n @j_del.java_method(:deleteRecursive, [Java::java.lang.String.java_class,Java::boolean.java_class,Java::IoVertxCore::Handler.java_class]).call(path,recursive,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))\n return self\n end\n raise ArgumentError, \"Invalid arguments when calling delete_recursive(path,recursive)\"\n end",
"def recursive_delete(path: nil)\n raise ArgumentError, \"path is a required argument\" if path.nil?\n\n result = zk.get_children(path: path)\n raise Kazoo::Error, \"Failed to list children of #{path} to delete them. Result code: #{result.fetch(:rc)}\" if result.fetch(:rc) != Zookeeper::Constants::ZOK\n\n threads = result.fetch(:children).map do |name|\n Thread.new do\n Thread.abort_on_exception = true\n recursive_delete(path: File.join(path, name))\n end\n end\n threads.each(&:join)\n\n result = zk.delete(path: path)\n raise Kazoo::Error, \"Failed to delete node #{path}. Result code: #{result.fetch(:rc)}\" if result.fetch(:rc) != Zookeeper::Constants::ZOK\n end",
"def clearCachedContentFiles\n #N Without this, the (local) source cached content file won't be deleted\n @sourceLocation.clearCachedContentFile()\n #N Without this, the (remote) source cached content file won't be deleted\n @destinationLocation.clearCachedContentFile()\n end",
"def deleteT(dir1, dir2)\n\t\tFileUtils.rm_rf Dir.glob(\"#{dir1}*\")\n\t\tFileUtils.rm_rf Dir.glob(\"#{dir2}*\")\n\tend",
"def file_delete(node, file)\n _out, _local, _remote, code = node.test_and_store_results_together(\"rm #{file}\", 'root', 500)\n code\nend",
"def file_delete(node, file)\n _out, _local, _remote, code = node.test_and_store_results_together(\"rm #{file}\", 'root', 500)\n code\nend",
"def recursively_destroy!\n children.each { |c| c.recursively_destroy! }\n destroy\n end",
"def delete_completely(root, resource)\n path = File.join(root, resource.path(identifying_sym))\n FileUtils.rm_rf(path)\n\n # removes the empty directories upward\n (resource.identifiers(identifying_sym).size - 1).times do |t|\n path = File.split(path).first\n begin\n FileUtils.rmdir(path)\n rescue Errno::ENOTEMPTY\n break\n end\n end\n end",
"def files_remote_remove(options = {})\n post('files.remote.remove', options)\n end",
"def delete_if\n super { |r| yield(r) && orphan_resource(r) }\n end",
"def delete\n stop\n [ @resource['instances_dir'] + \"/\" + @resource[:name],\n @resource['instances_dir'] + \"/\" + \"_\" + @resource[:name]\n ].each do |dir|\n FileUtils.rm_rf(dir) if File.directory?(dir)\n end\n end",
"def delete_files\n return if id.nil?\n return unless File.exist?(directory_path)\n\n FileUtils.rm_rf(directory_path)\n s3_delete_files\n end",
"def destroy\n self.class.where(:id => self.id).update_all(:is_mirrored => false) if self.is_mirrored?\n super\n end",
"def destroy\n @comment = Comment.find(params[:id])\n bid = @comment.blog_id\n\n @comment.deleted_parent = true\n @comment.save\n @comment = Comment.find(params[:id])\n @comment.content = '<-deleted->'\n @comment.save\n c1 = @comment\n while !c1.nil? and c1.leaf? do\n cp = c1.parent if !c1.parent.nil?\n cp = cp.nil? ? nil : cp.deleted_parent ? cp : nil\n c1.destroy\n c1 = (cp.nil?)? nil : Comment.find_by_id(cp.id)\n end\n #end while @com_par.deleted_parent == false and @com_par.leaf?\n\n respond_to do |format|\n format.html { redirect_to(Blog.find_by_id(bid)) }\n format.xml { head :ok }\n end\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = DeleteFilesResultSet.new(resp)\n return results\n end",
"def delete\n if processable? or unset?\n dir.delete\n else\n raise JobError.cannot_delete(@id, state)\n end\n end",
"def define_deleted local, remote\n to_delete = remote.select do |a| \n local.all? { |s| s.path != a.path } \n end\n\n to_delete.reject{|a| a.path.to_s =~ /.html$/ }.to_a\n end",
"def rm\n path = params[:path] || '/'\n\n if params.has_key?(:files) and params[:files].kind_of?(Array)\n files = params[:files]\n dests = []\n files.each do |file|\n dest = trash_file(File.join(path, file))\n break if dest == false\n dests << dest\n end\n render nothing: true, status: 500 and return if dests.empty?\n\n parent = File.dirname(dests[0])\n dests.map! do |dest|\n File.basename(dest)\n end\n render json: { undo: {\n name: \"Move of #{dests.length} files\",\n action: \"#{move_files_path(parent)}\",\n parameters: { _method: 'put', to: path, files: dests }\n }}\n else # if to move one file to trash\n dest = trash_file(path)\n\n render nothing: true, status: 500 and return if dest == false\n\n render json: { undo: {\n name: \"Move of #{File.basename(path)}\",\n action: \"#{move_files_path(dest)}\",\n parameters: { _method: 'put', to: path }\n }}\n end\n end",
"def clean_remote\n to_delete = remote_assets - local_compiled_assets\n to_delete.each do |f|\n delete_remote_asset(bucket.files.get(f))\n end\n end",
"def rsync(local_folder, remote_destination, delete)\n @log.info(\"rsyncing folder '#{local_folder}' to '#{remote_destination}'...\")\n @process_runner.execute!(\"rsync --filter='P *.css' --filter='P apidocs' --filter='P cdn' --filter='P get-started' --partial --archive --checksum --compress --omit-dir-times --quiet#{' --delete' if delete} --chmod=Dg+sx,ug+rw,Do+rx,o+r --protocol=28 --exclude='.snapshot' #{local_folder}/ #{remote_destination}\")\n end",
"def clean(&block)\n @target.files.each do |object|\n unless @source.files.include? object.key\n block.call(object)\n object.destroy\n end\n end\n end",
"def doSync(options = {})\n #N Without this, the content files will be cleared regardless of whether :full options is specified\n if options[:full]\n #N Without this, the content files won't be cleared when the :full options is specified\n clearCachedContentFiles()\n end\n #N Without this, the required content information won't be retrieved (be it from cached content files or from the actual locations)\n getContentTrees()\n #N Without this, the required copy and delete operations won't be marked for execution\n markSyncOperations()\n #N Without this, we won't know if only a dry run is intended\n dryRun = options[:dryRun]\n #N Without this check, the destination cached content file will be cleared, even for a dry run\n if not dryRun\n #N Without this check, the destination cached content file will remain there, even though it is stale once an actual (non-dry-run) sync operation is started.\n @destinationLocation.clearCachedContentFile()\n end\n #N Without this, the marked copy operations will not be executed (or in the case of dry-run, they won't be echoed to the user)\n doAllCopyOperations(dryRun)\n #N Without this, the marked delete operations will not be executed (or in the case of dry-run, they won't be echoed to the user)\n doAllDeleteOperations(dryRun)\n #N Without this check, the destination cached content file will be updated from the source content file, even if it was only a dry-run (so the remote location hasn't actually changed)\n if (not dryRun and @destinationLocation.cachedContentFile and @sourceLocation.cachedContentFile and\n File.exists?(@sourceLocation.cachedContentFile))\n #N Without this, the remote cached content file won't be updated from local cached content file (which is a reasonable thing to do assuming the sync operation completed successfully)\n FileUtils::Verbose.cp(@sourceLocation.cachedContentFile, @destinationLocation.cachedContentFile)\n end\n #N Without this, any cached SSH connections will remain unclosed (until the calling application has terminated, which may or may not happen soon after completing the sync).\n closeConnections()\n end",
"def remove_children_recursively\n groups.each do |g|\n g.remove_children_recursively\n g.remove_from_project\n end\n files.each { |f| f.remove_from_project }\n end",
"def remove_children_recursively\n groups.each do |g|\n g.remove_children_recursively\n g.remove_from_project\n end\n files.each { |f| f.remove_from_project }\n end",
"def destroy\n @resource = Resource.find(params[:id])\n\n # # ******************\n # # Check permissions!\n # main_tree_node = @resource.tree_nodes.select{ |e| e.is_main == true }.first\n # if not (main_tree_node && main_tree_node.can_administrate?)\n # flash[:notice] = \"Access denied. User can't delete tree node\"\n # redirect_to session[:referer]\n # end\n # # ******************\n\n @resource.destroy\n respond_to do |format|\n format.html { redirect_to session[:referer] }\n format.xml { head :ok }\n end\n end",
"def delete\n File.delete fullpath\n dirname = File.dirname(fullpath)\n while dirname != root\n Dir.rmdir(dirname)\n dirname = File.dirname(dirname)\n end\n rescue Errno::ENOTEMPTY\n end",
"def del_or_revert_folder\n @sub_shared_folders,@sub_shared_folders_collection,@sub_shared_docs,@sub_shared_docs_collection,sub_shared_docs = [],[],[],[],[]\n fn = (params[:fn] == 'false') ? false : true\n find_portfolio_and_folder\n files_and_docs_of_folder(@folder.id,true,fn)\n find_sub_shared_docs\n @folder.update_attributes(:is_deleted=>fn)\n @folder.documents.update_all(:is_deleted=>fn)\n action_type = (params[:fn] == 'false') ? \"restored\" : \"deleted\"\n send_mail_while_deleting_folder(action_type)\n send_mail_while_deleting_document(action_type)\n (params[:fn] == 'false') ? Event.create_new_event(\"restored\",current_user.id,nil,[@folder],current_user.user_role(current_user.id),@folder.name,nil) : Event.create_new_event(\"delete\",current_user.id,nil,[@folder],current_user.user_role(current_user.id),@folder.name,nil)\n assign_params(\"asset_data_and_documents\", \"show_asset_files\")\n @msg = fn == false ? \"#{@folder.name} has been reverted\" : \"#{@folder.name} successfully deleted\"\n @folder = Folder.find(@folder.parent_id) if @folder.parent_id!=0 && params[:show_past_shared] == 'true'\n find_folder_to_update_page('folder',@folder) if @folder.user_id != current_user.id\n update_page_after_deletion\n end",
"def delete\n if (exists?)\n list.each do |children|\n children.delete\n end\n factory.system.delete_dir(@path)\n end\n end",
"def action_delete\n if current_resource.exists?\n converge_by(\"Delete #{new_resource}\") do\n executor.execute!('delete-node', escape(new_resource.slave_name))\n end\n else\n Chef::Log.debug(\"#{new_resource} does not exist - skipping\")\n end\n end",
"def clean()\n rels = releases()\n rels.pop()\n\n unless rels.empty?\n rm = ['rm', '-rf'].concat(rels.map {|r| release_dir(r)})\n rm << release_dir('skip-*')\n cmd.ssh(rm)\n end\n end",
"def delete_tree(key)\n if directory_key?(key)\n Parallel.each(subtree_keys(key), in_threads: 10) do |content_key|\n delete_content(content_key)\n end\n else\n delete_content(key)\n end\n end",
"def remove\n service = FolderService.new(@context)\n nodes = Node.editable_by(@context).where(id: unsafe_params[:ids])\n result = service.remove(nodes)\n\n if result.success?\n type = :success\n text = \"Node(s) successfully removed.\"\n else\n type = :error\n text = \"Error when Node(s) removing: #{result.value[:message]}.\"\n end\n\n path = params[:scope] == Scopes::SCOPE_PUBLIC ? everybody_api_files_path : api_files_path\n\n render json: { path: path, message: { type: type, text: text } }, adapter: :json\n end",
"def delete(rmdir: false)\n # FIXME: rethink this interface... should qdel be idempotent?\n # After first call, no errors thrown after?\n\n if pbsid\n\n @torque.qdel(pbsid, host: @host)\n # FIXME: removing a directory is always a dangerous action.\n # I wonder if we can add more tests to make sure we don't delete\n # something if the script name is munged\n\n # recursively delete the directory after killing the job\n Pathname.new(path).rmtree if path && rmdir && File.exist?(path)\n end\n end",
"def update_remotely_deleted(file, node)\n #\n if node != ancestor.file_node(file) && !overwrite?\n if UI.ask(\"local changed #{file} which remote deleted\\n\" +\n \"use (c)hanged version or (d)elete?\") == \"d\"\n then remove file\n else add file\n end\n else\n remove file\n end\n end",
"def cleanup_created_resources\n # Avoid the use of any short circuiting folds.\n cleanup_commands.reverse.inject(true) { |accum, x| accum && x.cleanup }\n end",
"def delete(defer = false)\n delete_logic( defer )\n end",
"def destroy_descendants\n return if right.nil? || left.nil? || skip_before_destroy\n \n if acts_as_nested_set_options[:dependent] == :destroy\n descendants.each do |model|\n model.skip_before_destroy = true\n model.destroy\n end\n else\n base_class.delete_all scoped(left_column_name => { '$gt' => left }, right_column_name => { '$lt' => right })\n end\n \n # update lefts and rights for remaining nodes\n diff = right - left + 1\n base_class.all(scoped(left_column_name => { '$gt' => right })).each do |node|\n node.update_attributes left_column_name => node.left - diff\n end\n base_class.all(scoped(right_column_name => { '$gt' => right })).each do |node|\n node.update_attributes right_column_name => node.right - diff\n end\n \n # Don't allow multiple calls to destroy to corrupt the set\n self.skip_before_destroy = true\n end",
"def delete\n# if stat.directory?\n# FileUtils.rm_rf(file_path)\n# else\n# File.unlink(file_path)\n# end\n if collection?\n @collection.find({:filename => /^#{Regexp.escape(@bson['filename'])}/}).each do |bson|\n @collection.remove(bson)\n end\n else\n @collection.remove(@bson)\n end\n NoContent\n end",
"def delete_operations; end",
"def delete_directory_contents(directory, sftp, level)\n level_print(\"Deleting: \" + directory, level)\n sftp.dir.entries(directory).each do |file|\n begin\n sftp.remove!(directory + \"/\" + file.name)\n level_print(\"Deleted File: \" + file.name, level + 1)\n rescue Net::SFTP::StatusException => e\n delete_directory_contents(directory + \"/\" + file.name, sftp, level + 1)\n sftp.rmdir(directory + \"/\" + file.name)\n level_print(\"Deleted Directory: \" + file.name, level + 1)\n # puts \"Error: \" + e.description\n end\n end\nend",
"def clean_directory(path, types=nil, run_context=nil)\n raise 'clean_directory path must be a non-empty string!' if path.nil? or path.empty?\n types ||= [\n Chef::Resource::File,\n Chef::Resource::Link,\n Chef::Resource::CookbookFile,\n Chef::Resource::RemoteFile,\n Chef::Resource::Template,\n ]\n run_context ||= node.run_context\n\n # find the chef files generated\n chef_files_generated = run_context.resource_collection.select { |r|\n types.include?(r.class) and r.path.start_with?(path)\n }.map { |r| r.path }\n\n # find the fileststem files present\n filesystem_files_present = Dir[\"#{path}/**/*\"].select { |f|\n ::File.file?(f) or ::File.symlink?(f)\n }\n\n # calculate the difference, and remove the extraneous files\n (filesystem_files_present - chef_files_generated).each do |f|\n if ::File.symlink?(f)\n link \"clean_directory: #{f}\" do\n target_file f\n action :delete\n end\n else\n file \"clean_directory: #{f}\" do\n path f\n action :delete\n end\n end\n end\nend",
"def cleanup_nontarget_files\n\n delete_dir = File.expand_path(File.join(app.build_dir, 'Resources/', 'Base.lproj/', 'assets/', 'images/'))\n\n puts_blue \"Cleaning up excess image files from target '#{options.Target}'\"\n puts_red \"Images for the following targets are being deleted from the build directory:\"\n\n (options.Targets.keys - [options.Target]).each do |target|\n\n puts_red \"#{target.to_s}\"\n Dir.glob(\"#{delete_dir}/**/#{target}-*.{jpg,png,gif}\").each do |f|\n puts_red \" Deleting #{File.basename(f)}\"\n File.delete(f)\n end\n end\n\n puts_red \"\\nImages prefixed all- are being deleted if a corresponding #{options.Target}- exists.\"\n\n Dir.glob(\"#{delete_dir}/**/all-*.{jpg,png,gif}\").each do |f|\n if File.exist?( f.sub(\"all-\", \"#{options.Target}-\") )\n puts_red \" Deleting #{File.basename(f)}\"\n File.delete(f)\n end\n end\n\n\n end",
"def delete_tree_recursion(tree, node_group_id)\n tree[node_group_id].each do |childid|\n delete_tree_recursion(tree, childid)\n end\n #protect against trying to delete the Rootuuid\n delete_node_group(node_group_id) if node_group_id != Rootuuid\n end"
] | [
"0.73455304",
"0.62522185",
"0.5752937",
"0.5606207",
"0.5529007",
"0.5500345",
"0.5478859",
"0.54616225",
"0.5436599",
"0.5418047",
"0.5400986",
"0.5392225",
"0.531366",
"0.5309123",
"0.5289061",
"0.5288361",
"0.52647686",
"0.52619386",
"0.52544004",
"0.5232471",
"0.52304286",
"0.52267265",
"0.51970255",
"0.5173839",
"0.51518184",
"0.51518184",
"0.51501435",
"0.51499087",
"0.5149207",
"0.5147991",
"0.5141029",
"0.50948465",
"0.508243",
"0.50787956",
"0.5074392",
"0.5065136",
"0.5065108",
"0.50638515",
"0.5060489",
"0.5059679",
"0.50377226",
"0.5037145",
"0.5031745",
"0.4978789",
"0.4975481",
"0.4970202",
"0.49647713",
"0.49510914",
"0.4945517",
"0.49434796",
"0.49388024",
"0.49362406",
"0.49337322",
"0.49305832",
"0.49302956",
"0.4929327",
"0.492636",
"0.4919488",
"0.49192244",
"0.4908093",
"0.49074504",
"0.49034622",
"0.49034622",
"0.49022913",
"0.4900611",
"0.48951983",
"0.489293",
"0.4890863",
"0.48843277",
"0.4876244",
"0.48757622",
"0.48652884",
"0.4864596",
"0.48620093",
"0.4861054",
"0.485881",
"0.48432383",
"0.48421484",
"0.4841752",
"0.48407623",
"0.48407623",
"0.48389938",
"0.48299786",
"0.4826493",
"0.48261628",
"0.4815016",
"0.481061",
"0.47942433",
"0.47937682",
"0.47850928",
"0.4781714",
"0.47796214",
"0.4775536",
"0.4765284",
"0.47631407",
"0.47597972",
"0.4753877",
"0.47492942",
"0.47488904",
"0.4747755"
] | 0.8322386 | 0 |
N Without this there won't be any easy way to close cached SSH connections once the sync operations are all finished (and if we closed the connections as soon as we had finished with them, then we wouldn't be able to cache them) | def closeConnections
#N Without this, cached SSH connections to the remote system won't get closed
destinationLocation.closeConnections()
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def closeConnections()\n #N Without this, the connections won't be closed\n @sshAndScp.close()\n end",
"def closeConnections\n #N Without this the cached connections won't get closed\n @contentHost.closeConnections()\n end",
"def close\n @channel.close if @channel\n @channel = nil\n @ssh.close if @close_all and @ssh\n end",
"def close_ssh\n puts \"Close connection\"\n @ssh.close unless @ssh.closed?\n end",
"def close\n @net_ssh.close\n @net_ssh = nil\n end",
"def disconnect\n @ssh.close if @ssh\n @ssh = nil\n end",
"def close\n log 'closing connection'\n @ssh.close\n end",
"def close\n ssh.close if @_ssh\n end",
"def empty_connection_pools!; end",
"def close\n Timeout.timeout(3) { @connector.close }\n true\n rescue\n warn \"ssh connection could not be closed gracefully\"\n Metriks.meter('worker.vm.ssh.could_not_close').mark\n false\n ensure\n buffer.stop\n @buffer = nil\n end",
"def save_ssh_connection(conn)\n conn.exec! 'cd ~'\n @lock.synchronize do\n @connection_pool << conn\n end\n rescue\n output \"Discarding nonfunctional SSH connection\"\n end",
"def cleanup\n\t\tcleanup_ssh\n\n\tend",
"def sftp_close_connection(connection)\n connection.close!(connection)\nend",
"def sftp_close_connection(connection)\n connection.close!(connection)\nend",
"def disconnect!() @connections.each_value(&:disconnect) end",
"def clear_reloadable_connections!\n synchronize do\n @reserved_connections.clear\n @connections.each do |conn|\n checkin conn\n end\n\n @connections.delete_if(&:finished?)\n\n @available.clear\n @connections.each do |conn|\n @available.add conn\n end\n end\n end",
"def close_connections\n @connections.values.each(&:close)\n end",
"def close_client_connections\n @pending_data.each_key(&:close)\n @pending_data.clear\n end",
"def __close_connections\n # to be implemented by specific transports\n end",
"def ensure_connected! \n if @ssh_options[:timeout]\n total_timeout = @ssh_options[:timeout] * 2\n else\n total_timeout = 30\n end\n # puts \"Total timeout: #{total_timeout}\"\n @connections=[]\n hosts_to_connect = @hosts.inject(0) {|sum,h| sum += (h.connect_failed ? 0:1)}\n # puts \"#{hosts_to_connect} to connect\"\n @hosts.each do |host|\n if @connection_cache[host.name] || host.connected\n @connection_mutex.synchronize { @connections << {:connection=>@connection_cache[host.name], :host=>host} }\n host.connected=true\n elsif !host.connect_failed\n Thread.new {\n begin\n #puts \"Connecting #{host.name}\" \n c = Net::SSH.start(host.name, @user_name, @ssh_options)\n @connection_cache[host.name] = c\n @connection_mutex.synchronize { @connections << {:connection=>c, :host=>host} }\n host.connected=true\n #puts \"Connected #{host.name}\" \n rescue Exception => e\n host.connect_failed = true\n host.connected=false\n error \"Unable to connect to #{host.name}\\n#{e.message}\"\n @connection_mutex.synchronize {@connections << {:connection=>nil, :host=>host} }\n host.exception=e\n end \n }\n end\n end\n s = Time.now\n loop do\n l=0\n @connection_mutex.synchronize { l = @connections.length }\n break if l == hosts_to_connect\n sleep(0.1)\n if Time.now - s > total_timeout\n puts \"Warning -- total connection time expired\"\n puts \"Failed to connect:\"\n hosts.each do |h|\n unless h.connected\n puts \" #{h.name}\" \n h.connect_failed=true\n # TODO: Need to handle this situations much better. Attempt to kill thread and/or mark connection in cache as unreachable\n end\n end\n break\n end\n end \n end",
"def close_all\n @connections.close_all\n end",
"def close_connections\n @connections ||= {}\n @connections.values.each do |connection|\n begin\n connection.disconnect!\n rescue\n end\n end\n\n @connections = {}\n end",
"def disconnect!\n @reserved_connections.each do |name,conn|\n checkin conn\n end\n @reserved_connections = {}\n @connections.each do |conn|\n conn.disconnect!\n end\n @connections = []\n end",
"def reuse_connection\n logger.debug(\"[SSH] reusing existing connection #{@connection}\")\n yield @connection if block_given?\n @connection\n end",
"def remote_connections; end",
"def disconnect!\n @logger.info(\"Terminating SSH connection to server name=#{@name}\")\n @ssh.close\n @ssh = nil\n end",
"def disconnect_all\n @cache.values.map(&:clear_all_connections!)\n end",
"def clear_reloadable_connections!\n @reserved_connections.each do |name, conn|\n checkin conn\n end\n @reserved_connections = {}\n @connections.each do |conn|\n conn.disconnect! if conn.requires_reloading?\n end\n @connections = []\n end",
"def disconnect_ssh_tunnel\n @logger.debug('closing SSH tunnel..')\n\n @ssh.shutdown! unless @ssh.nil?\n @ssh = nil\n end",
"def realize_pending_connections! #:nodoc:\n return unless concurrent_connections\n\n server_list.each do |server|\n server.close if !server.busy?(true)\n server.update_session!\n end\n\n @connect_threads.delete_if { |t| !t.alive? }\n\n count = concurrent_connections ? (concurrent_connections - open_connections) : @pending_sessions.length\n count.times do\n session = @pending_sessions.pop or break\n # Increment the open_connections count here to prevent\n # creation of connection thread again before that is\n # incremented by the thread.\n @session_mutex.synchronize { @open_connections += 1 }\n @connect_threads << Thread.new do\n session.replace_with(next_session(session.server, true))\n end\n end\n end",
"def open\n connect\n rescue Object => anything\n begin\n @ssh.shutdown!\n rescue ::Exception # rubocop:disable Lint/HandleExceptions, Lint/RescueException\n # swallow exceptions that occur while trying to shutdown\n end\n\n raise anything\n end",
"def reuse_connection\n logger.debug(\"[SSH] reusing existing connection #{@connection}\")\n yield @connection if block_given?\n @connection\n end",
"def cleanup_connections\n @connections.keep_if do |thread, conns|\n thread.alive?\n end\n end",
"def all_connections\n hold do |c|\n sync do\n yield c\n @available_connections.each{|conn| yield conn}\n end\n end\n end",
"def all_connections\n hold do |c|\n sync do\n yield c\n @available_connections.each{|conn| yield conn}\n end\n end\n end",
"def clear_reloadable_connections!\n synchronize do\n @reserved_connections.clear\n @connections.each do |conn|\n checkin conn\n conn.disconnect! if conn.requires_reloading?\n end\n @connections.delete_if do |conn|\n conn.requires_reloading?\n end\n @available.clear\n @connections.each do |conn|\n @available.add conn\n end\n end\n end",
"def without_reconnect(&block); end",
"def finish\n @connections.each_value do |connection|\n begin\n connection.finish\n rescue Exception => e\n logger.error(\"Failed to close metadata http connection: #{e.backtrace.join(\"\\n\")}\")\n end\n end\n @connections = {}\n end",
"def clear_active_connections!\n self.ensure_ready\n self.connection_pool_list.each(&:release_connection)\n end",
"def logout!\n @ssh.close\n @ssh = nil\n end",
"def initialize_ssh; end",
"def reexecute_connections?\n return true\n end",
"def redis_shared_state_cleanup!\n Gitlab::Redis::SharedState.with(&:flushdb)\n end",
"def close()\n #N Without this check, we'll be trying to close the connection even if there isn't one, or it was already closed\n if @connection != nil\n #N Without this we won't get feedback about the SSH connection being closed\n puts \"Closing SSH connection to #{user}@#{host} ...\"\n #N Without this the connection won't actually get closed\n @connection.close()\n #N Without this we won't know the connection has been closed, because a nil @connection represents \"no open connection\"\n @connection = nil\n end\n end",
"def clear\n connections.synchronize do\n connections.map(&:last).each(&closer)\n connections.clear\n end\n end",
"def clear_reloadable_connections!\n self.ensure_ready\n self.connection_pool_list.each(&:clear_reloadable_connections!)\n end",
"def close\n # by default do nothing - close any cached connections\n end",
"def redis_shared_state_cleanup!\n Gitlab::Redis::SharedState.with(&:flushall)\n end",
"def stop\n @ssh.close if @ssh\n super.stop\n end",
"def disconnect; @connection.close end",
"def close\n @clients.each { |c| c.reset(); c.close() } if @clients\n end",
"def finalize()\n # below function is not yet fully functional\n unlock_all_instances()\n end",
"def close_locked\n close_clients\n unregister_pubcontrol_locked\n end",
"def clear_reloadable_connections!\n @reserved_connections.clear\n @connections.each do |conn|\n checkin conn\n conn.disconnect! if conn.requires_reloading?\n end\n @connections.delete_if do |conn|\n conn.requires_reloading?\n end\n @available.clear\n @connections.each do |conn|\n @available.add conn\n end\n end",
"def disconnect!\n synchronize do\n @reserved_connections.clear\n @connections.each do |conn|\n checkin conn\n $DEBUG && warn(\"Closing pg connection: #{conn.object_id}\")\n conn.close\n end\n @connections = []\n @available.clear\n end\n end",
"def thread_cleanup(th)\n tc = tconf(th)\n tc.connections.each { |conn| close_conn(conn) }\n tc.connections.clear\n tc.stack_size = 0\n tc.dbc = nil\n\n true\n end",
"def connection_pool_maximum_reuse\n super\n end",
"def close_expired_connections\n raise NotImplementedError\n end",
"def dispose\n return if @connection_pool.nil?\n\n until @connection_pool.empty?\n conn = @connection_pool.pop(true)\n conn&.close\n end\n\n @connection_pool = nil\n end",
"def disconnect\n return unless pool\n pool.map(&:close)\n @pool = nil\n end",
"def disconnect!\n clear_cache!(new_connection: true)\n reset_transaction\n @raw_connection_dirty = false\n end",
"def close_pipes; end",
"def close_connection; end",
"def resurrect_dead_connections!\n connections.dead.each { |c| c.resurrect! }\n end",
"def disconnect!\n synchronize do\n @reserved_connections.clear\n @connections.each do |conn|\n checkin conn\n conn.disconnect!\n end\n @connections.clear\n @available.clear\n end\n end",
"def test_double_close()\n rdht = Scalaroid::ReplicatedDHT.new()\n rdht.close_connection()\n rdht.close_connection()\n end",
"def killall\n begin\n\t @connections.each do |k,v| \n\t v[:thread].exit! unless v[:thread].nil?\n\t v.shutdown!\n\t end\n rescue Exception\n end\n initialize\n end",
"def reap\n stale_connections = synchronize do\n @connections.select do |conn|\n conn.in_use? && !conn.owner.alive?\n end\n end\n\n stale_connections.each do |conn|\n synchronize do\n if conn.active?\n conn.reset!\n checkin conn\n else\n remove conn\n end\n end\n end\n end",
"def close\n inactive!\n close_connections\n end",
"def close_conn(spec, h_conn, for_real = false)\n case @handling_mode\n when :cache\n # do nothing i think?\n when :pool\n # return the conn back to the pool\n else\n nil\n end\n end",
"def close_connection\n @connection.expunge\n @connection.logout\n @connection.disconnect\n end",
"def before_fork\n return unless (defined? ::DataObjects::Pooling)\n return if ::DataMapper.repository.adapter.to_s =~ /Sqlite3Adapter/\n ::DataMapper.logger.debug \"+-+-+-+-+ Cleaning up connection pool (#{::DataObjects::Pooling.pools.length}) +-+-+-+-+\"\n ::DataObjects::Pooling.pools.each {|p| p.dispose} \n end",
"def disconnect; end",
"def disconnect; end",
"def finalize\n @server.close if @server\n end",
"def close\n @sockets.each do |sock|\n sock.close\n end\n @host = @port = nil\n @sockets.clear\n @checked_out.clear\n end",
"def reap\n stale_connections = @connections.select do |conn|\n conn.in_use? && !conn.owner.alive?\n end\n\n stale_connections.each do |conn|\n if conn.active?\n conn.reset!\n checkin conn\n else\n remove conn\n end\n end\n end",
"def close\n @mutex.lock do\n unless @connection_pool.nil? or @connection_pool.is_closed\n @connection_pool.close\n @connection_pool = nil\n end\n end\n end",
"def clear_reloadable_connections!\n if @@allow_concurrency\n # With concurrent connections @@active_connections is\n # a hash keyed by thread id.\n @@active_connections.each do |thread_id, conns|\n conns.each do |name, conn|\n if conn.requires_reloading?\n conn.disconnect!\n @@active_connections[thread_id].delete(name)\n end\n end\n end\n else\n @@active_connections.each do |name, conn|\n if conn.requires_reloading?\n conn.disconnect!\n @@active_connections.delete(name)\n end\n end\n end\n end",
"def disconnect!; end",
"def disconnect_connection(conn)\n sync{@size[0] -= 1}\n super\n end",
"def with_two_connections\n run_without_connection do |original_connection|\n ActiveRecord::Base.establish_connection(original_connection.merge(pool_size: 2))\n begin\n ddl_connection = ActiveRecord::Base.connection_pool.checkout\n begin\n yield original_connection, ddl_connection\n ensure\n ActiveRecord::Base.connection_pool.checkin ddl_connection\n end\n ensure\n ActiveRecord::Base.connection_handler.clear_all_connections!(:all)\n end\n end\n end",
"def disconnect\n @streams.each { |_, stream| try { stream.finalize } }\n @conn.Disconnect()\n end",
"def with_force_shutdown; end",
"def clear_all_connections!\n disconnect_read_pool!\n @original_handler.clear_all_connections!\n end",
"def disconnect!(timeout: 120)\n start_time = ::Gitlab::Metrics::System.monotonic_time\n\n while (::Gitlab::Metrics::System.monotonic_time - start_time) <= timeout\n break if pool.connections.none?(&:in_use?)\n\n sleep(2)\n end\n\n pool.disconnect!\n end",
"def release_connection\n conn = @reserved_connections.delete(current_connection_id)\n checkin conn if conn\n end",
"def disconnect!\n @reserved_connections.clear\n @connections.each do |conn|\n checkin conn\n conn.disconnect!\n end\n @connections = []\n @available.clear\n end",
"def freeVNCPool\n $VNC_SCREEN_POOL.each { @connection_controller.close_connection(0) }\n @connection_controller = false\n end",
"def close\n pool.checkin self\n end",
"def close\n pool.checkin self\n end",
"def teardown_connections_to(servers)\n servers.each do |server|\n sessions[server].close\n sessions.delete(server)\n end\n end",
"def connection_closed\n end",
"def destroy_connection\n begin\n @ssock.close if @ssock\n @rsock.close if @rsock\n ensure\n @connected=false\n end\n end",
"def close_ssh_session(session)\n session.close\n session = nil\n true\n end",
"def disconnect\n @conn.close\nend",
"def test_connection\n @pool.hold {|conn|}\n true\n end",
"def reset_connection\n #close if \n @socket_server = nil\n connect\n end",
"def clear_active_connections!\n clear_cache!(@@active_connections) do |name, conn|\n conn.disconnect!\n end\n end",
"def testDoubleClose()\n rdht = Scalaris::ReplicatedDHT.new()\n rdht.close_connection()\n rdht.close_connection()\n end"
] | [
"0.7057207",
"0.6657495",
"0.650974",
"0.65025324",
"0.64481646",
"0.64007884",
"0.6340067",
"0.6334801",
"0.62424344",
"0.6228436",
"0.6215895",
"0.613557",
"0.60430294",
"0.60430294",
"0.6030879",
"0.6011565",
"0.60023946",
"0.598022",
"0.59301937",
"0.5915533",
"0.5832246",
"0.5816326",
"0.5792273",
"0.5789167",
"0.5759268",
"0.57582074",
"0.5755065",
"0.57438505",
"0.5741298",
"0.5726145",
"0.5721601",
"0.5717525",
"0.5696741",
"0.565735",
"0.565735",
"0.56329334",
"0.56303304",
"0.56255174",
"0.56069875",
"0.5601277",
"0.55775267",
"0.55772996",
"0.5562754",
"0.5560018",
"0.55587804",
"0.555806",
"0.55506474",
"0.55437785",
"0.5537091",
"0.5484261",
"0.5479197",
"0.5466552",
"0.5451298",
"0.54477304",
"0.54424775",
"0.5438735",
"0.54106516",
"0.54073566",
"0.5406133",
"0.54009664",
"0.53761744",
"0.5371024",
"0.53684705",
"0.53623176",
"0.53563607",
"0.53540957",
"0.5348052",
"0.53349924",
"0.53293127",
"0.5323593",
"0.53117675",
"0.53111637",
"0.5304683",
"0.5304683",
"0.5304067",
"0.5301905",
"0.52896005",
"0.52867734",
"0.5286024",
"0.52669376",
"0.52648735",
"0.5263145",
"0.52618295",
"0.5250242",
"0.5249409",
"0.52459574",
"0.52426064",
"0.5240544",
"0.52325314",
"0.52322775",
"0.52322775",
"0.52305454",
"0.5226033",
"0.5224553",
"0.5223591",
"0.5222204",
"0.521872",
"0.5212728",
"0.52083504",
"0.52032346"
] | 0.7086593 | 0 |
You arrived ten minutes too early to an appointment, so you decided to take the opportunity to go for a short walk. The city provides its citizens with a Walk Generating App on their phones everytime you press the button it sends you an array of oneletter strings representing directions to walk (eg. ['n', 's', 'w', 'e']). You always walk only a single block in a direction and you know it takes you one minute to traverse one city block, so create a function that will return true if the walk the app gives you will take you exactly ten minutes (you don't want to be early or late!) and will, of course, return you to your starting point. Return false otherwise. Note: you will always receive a valid array containing a random assortment of direction letters ('n', 's', 'e', or 'w' only). It will never give you an empty array (that's not a walk, that's standing still!). | def isValidWalk(walk)
x=0
y=0
valid=false
for d in walk
case d
when 'n'
y += 1
when 's'
y -= 1
when 'e'
x += 1
when 'w'
x -= 1
end
end
if walk.length === 10 && x===0 && y === 0
valid = true
end
p valid
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isValidWalk(walk)\r\n starting_point = []\r\n current_direction = 0\r\n distance_travelled = []\r\n if walk.size != 10\r\n false\r\n else\r\n walk.each do |direction|\r\n distance_travelled = move_player(distance_travelled, direction)\r\n end\r\n if distance_travelled == starting_point\r\n true\r\n else\r\n false\r\n end\r\n end\r\nend",
"def isValidWalk(walk)\n #your code here\n directions = {'n'=>0, 's'=>0, 'e'=>0, 'w'=>0}\n\n walk.each do |step|\n directions[step] += 1\n end\n\n if directions['n'] == directions['s'] && directions['e'] == directions['w']\n walk\n else\n false\n end\nend",
"def is_valid_walk(walk)\n a=''\n i=0\n verdad=true\n if walk.length==1 || walk.length==0\n i = 1\n verdad = false\n else\n for w in walk\n\n # puts walk[i-1]\n if i<walk.length\n if walk[i+1]==w\n verdad=false\n end\n else\n break\n end\n i=i+1\n end \n end\n if verdad==false || i != 10\n \n return 'should return true'\n\nelse\n return 'should return false'\nend\nend",
"def walkthrough()\r\n choose_winner =false \r\n choose_winner= walkthrough_test( @turn[2])\r\n \r\n\t if choose_winner ==true\r\n\t return true\r\n\t else\r\n\t return false\r\n\t end \r\n \tend",
"def good_walk\n\n puts \"Which direction would you like to walk?\"\n puts \"Options: ['n', 's', 'e', 'w']\"\n first_input = gets.chomp\n puts \"How many blocks do you wish walk?\"\n first_input_blocks = gets.chomp.to_i\n\n system('clear')\n \n if first_input == \"n\" \n puts \"We've predefined your return path to be South\"\n elsif first_input == \"s\"\n puts \"We've predefined your return path to be North\"\n elsif first_input == \"e\"\n puts \"We've predefined your return path to be West\"\n else first_input == \"w\"\n puts \"We've predefined your return path to be East\" \n end\n\n puts \"How many blocks do you intend on walking in this direction?\"\n second_input_blocks = gets.chomp.to_i\n \n if first_input_blocks + second_input_blocks > 10 \n puts \"Your walk is calcultated to run over the estimated 10 minute allocation by #{(first_input_blocks+second_input_blocks)-10} minutes\"\n elsif first_input_blocks + second_input_blocks < 10\n puts \"Your walk is calcultated to run under the estimated 10 minute allocation by #{10 - (first_input_blocks+second_input_blocks)} minutes\"\n else first_input_blocks + second_input_blocks == 10\n puts \"Your walk is calcultated to run precisely on schedule\"\n \n end\n\nend",
"def is_valid_walk(path)\n return false if path.size != 10\n\n hor_moves = 0\n ver_moves = 0\n path.each do |move|\n if move == 'n'\n ver_moves += 1\n elsif move == 's'\n ver_moves -= 1\n elsif move == 'w'\n hor_moves += 1\n else \n hor_moves -= 1\n end\n end\n return (hor_moves == 0 && ver_moves == 0) ? true : false\nend",
"def is_valid_walk(walk)\n p '--- Jan-06-2017 problem --- '\n count_ns = walk.count('n') == walk.count('s')\n count_ew = walk.count('e') == walk.count('w')\n if walk.count == 10 && count_ns == true && count_ew == true\n true\n else\n false\n end\nend",
"def is_valid_walk(walk)\n v = 0\n h = 0\n walk.each do |x| \n if x == 'n'\n v += 1\n elsif x == 's'\n v -= 1\n elsif x == 'w'\n h += 1\n elsif x == 'e'\n h -= 1\n end\n end\n v == 0 && h == 0 && walk.length == 10\n end",
"def isValidWalk(walk)\n return false if walk.size != 10\n return false if walk.count(\"n\") != walk.count(\"s\")\n return false if walk.count(\"e\") != walk.count(\"w\")\n true\nend",
"def walk\n return false if (@captives > 0 and captives_close and warrior.feel(get_bomb_direction).captive?) or # Captives needs to be rescued, dont walk away\n count_unit_type(:Sludge) > 5\n message = nil\n walk_to = nil\n if check_for_a_bomb and @bomb_optimal_direction != false\n message = \"Walking to captive with the bomb optimal direction to direction #{@bomb_optimal_direction}\"\n walk_to = @bomb_optimal_direction\n elsif @captives > 0 and check_for_a_bomb and !warrior.feel(:forward).enemy?\n message = \"Walking to get the captive with a bomb to direction #{get_bomb_direction}\"\n walk_to = get_bomb_direction\n elsif @captives > 0 and warrior.look(:forward)[1].to_s.to_sym == :\"Thick Sludge\" and count_unit_type(:\"Thick Sludge\") > 1\n message = \"Walking to avoid sludges to direction #{@captives_direction[0]}\"\n walk_to = :right\n elsif @enemies_binded < 3 and @captives > 0 and !enemies_close\n message = \"Walking to rescue captives to direction #{@captives_direction[0]}\"\n walk_to = @captives_direction[0]\n elsif !under_attack and warrior.listen.empty?\n message = \"Walking to the stairs to direction #{warrior.direction_of_stairs}\"\n walk_to = warrior.direction_of_stairs\n elsif !under_attack and !enemies_close\n message = \"Walking to closest unit to direction #{warrior.direction_of(warrior.listen.first)}\"\n walk_to = warrior.direction_of(warrior.listen.first)\n end\n if walk_to != nil\n if message != nil\n puts message\n end\n return warrior.walk! walk_to\n end\n return false\n end",
"def long_planeteer_calls(calls)\n calls.each do |word|\n if word.length > 4\n return true\n else\n return false\n end\n end\nend",
"def isValidWalk(walk)\n walk.count('w') == walk.count('e') and\n walk.count('n') == walk.count('s') and\n walk.count == 10\nend",
"def isValidWalk(walk)\n walk.count('w') == walk.count('e') and\n walk.count('n') == walk.count('s') and\n walk.count == 10\nend",
"def isValidWalk(walk)\n\tif walk.length == 10 && walk.count('n') == walk.count('s') && walk.count('e') == walk.count('w') \n\t\treturn true\n\telse\n\t\treturn false \n\tend\nend",
"def walk(direction)\r\n\tif direction == :north\r\n\tp \"Walking North\" \r\n\tend\r\n\tif direction == :south\r\n\tp \"Walking South\" \r\n\tend\r\n\tif direction == :east\r\n\tp \"Walking East\" \r\n\tend\r\n\tif direction == :west\r\n\tp \"Walking West\" \r\n\tend\r\nend",
"def walk\n if @awake != true\n puts \"Wake up, #{@name}. It's time for a walk.\"\n @awake = true\n end #end of conditional to wake up and go out\n\n if @food_in_intestine > 50\n @food_in_intestine = 0\n puts \"#{@name} pooped.\"\n else\n puts \"#{@name} sniffs around, but doesn't do business.\"\n end #end of conditional for pooping on walk\n time_passed\nend",
"def walking_toward?\n return Direction::Down if (@current_tile_indx >= 0 and @current_tile_indx <= 2)\n return Direction::Up if (@current_tile_indx >= 9 and @current_tile_indx <= 11)\n return Direction::Left if (@current_tile_indx >= 3 and @current_tile_indx <= 5)\n return Direction::Right if (@current_tile_indx >= 6 and @current_tile_indx <= 8)\n end",
"def isValidWalk1(walk)\n return false unless walk.size == 10\n start = [0, 0]\n walk.each do |dir|\n case dir\n when \"n\" then start[1] += 1\n when \"s\" then start[1] -= 1\n when \"e\" then start[0] += 1\n when \"w\" then start[0] -= 1\n end\n end\n start == [0, 0]\nend",
"def long_planeteer_calls(array)\n array.each do |element|\n return true unless element.to_s.length <= 4\n end\n return false\nend",
"def long_planeteer_calls(calls_long)\n calls_long.any? do |word|\n word.length > 4\n # if word.length>4\n # return true\n # end\n end\n\n \nend",
"def long_planeteer_calls(array)\n return array.any?{|item| item.length > 4}\n # code an argument here\n # Your code here\nend",
"def min_refuel array_of_gas_station, total_distance, l_km\r\n\tt1 = Time.now\r\n\ttotal_refuel = 0\r\n\trefueld_at = []\r\n\tcan_travel = l_km\r\n\tflag = \"yes\"\r\n\tarray_of_gas_station.each_with_index do |arr,index|\r\n\t\tif arr > can_travel\r\n\t\t\tcan_travel += l_km\r\n\t\t\ttotal_refuel += 1\r\n\t\t\trefueld_at << (index-1)\r\n\t\telsif arr == can_travel\r\n\t\t\tcan_travel += l_km\r\n\t\t\ttotal_refuel += 1\r\n\t\t\trefueld_at << index\r\n\t\tend\r\n\tend\r\n\trefueld_at.each_with_index do |arr, i|\r\n\t\tif refueld_at[i] == refueld_at[i+1] || refueld_at[i] < 0\r\n\t\t\tflag = \"no\"\r\n\t\tend\r\n\tend\r\n\tif flag.eql? \"yes\"\r\n\t\tt2 = Time.now\r\n\t\tp \"total refuel : #{total_refuel}\"\r\n\t\tp \"refueled at : #{refueld_at}\"\r\n\t\tp \"Time taken : #{t2 - t1}\"\r\n\telse\r\n\t\tt2 = Time.now\r\n\t\tp \"can't travel\"\r\n\t\tp \"Time taken : #{t2 - t1}\"\r\n\tend\r\nend",
"def walk(direction)\n if direction == :north\n p 'Je marche vers le nord'\n elsif direction == :east\n p 'Je marche vers l\\'est'\n elsif direction == :south\n p 'Je marche vers le sud'\n elsif direction == :west\n p 'Je marche vers l\\'ouest'\n else\n p 'je rentre chez moi'\n end\nend",
"def check_first_command(command)\n arr_1 = command.split(' ') #only one space\n return false if arr_1.length != 2\n return false if arr_1[0] != 'PLACE'\n command_arr = command.split(' ').join(',').split(',')\n directions = [\"NORTH\", \"EAST\", \"SOUTH\", \"WEST\"]\n coords = ['0', '1','2','3','4'] # using strings because to_i converts non numerics to 0\n return false if command_arr.length != 4\n return false if !directions.include?(command_arr[3])\n return false if !coords.include?(command_arr[1])\n return false if !coords.include?(command_arr[2])\n return true\nend",
"def who_starts?\n puts 'Do you want to make a first move (y/n)?'\n #puts(\"Who is going to make first move: 1-you, 2-computer?\") for test pass with puts()\n end",
"def long_planeteer_calls( array )\n array.map do |call|\n if call.size > 4\n return true\n else\n return false\n end\n end\nend",
"def run\n start = rand(20)\n puts \" Starting at: #{@locations[start].name}\"\n tripDesc = \"\" # human-readable List of moves for current trip segment\n @locations[start].visited = true\n visited = 1\n totalTime = 0\n while visited < 20\n group = group_nearest(start)\n best_time = 9999999999\n\n for i in 0..3\n result = getBestPath(start, group[i]) if group[i]\n if result[0] < best_time\n best_time = result[0]\n best_path = result[1]\n best_dest = group[i]\n end\n end\n tripDesc << best_path\n totalTime += best_time\n @locations[best_dest].visited = true\n start = best_dest\n visited += 1\n end\n\n puts \"*********** Total Trip Time = #{secondstoHMS(totalTime)} **************\"\n confirm = \"Complete.\\n\"\n for i in 0..19\n confirm = \"Error, not all locations visited!!\\n\" if !@locations[i].visited\n end\n tripDesc << confirm\n return [totalTime, tripDesc]\n\n end",
"def options_when_walking_away_from_desk\n# letting user know whats happening with the door\n puts \"\\nYou walk to the door and... \"\n sleep(2)\n if $items_collected.include?(\"key\") then\n puts \"You use the key to open the door\"\n sleep(2)\n opened_the_door_walked_outside\n else !$items_collected.include?(\"key\")\n puts \"Sorry you dont have the key, go back to the desk!\\n\\n\"\n sleep(2)\n remove_last_item_from_items_collected_at_desk\n end\nend",
"def did_anyone_win?(array)\n\t\tif (array.include?(0) and array.include?(4) and array.include?(8))\n\t\t\treturn true\n\t\telsif (array.include?(1) and array.include?(4) and array.include?(7))\n\t\t\treturn true\n\t\telsif (array.include?(2) and array.include?(4) and array.include?(6))\n\t\t\treturn true\n\t\telsif (array.include?(3) and array.include?(4) and array.include?(5))\n\t\t\treturn true\n\t\telsif (array.include?(8) and array.include?(4) and array.include?(0))\n\t\t\treturn true\n\t\telsif (array.include?(0) and array.include?(3) and array.include?(6))\n\t\t\treturn true\n\t\telsif (array.include?(1) and array.include?(4) and array.include?(7))\n\t\t\treturn true\n\t\telsif (array.include?(2) and array.include?(5) and array.include?(8))\n\t\t\treturn true\n\t\telsif (array.include?(0) and array.include?(1) and array.include?(2))\n\t\t\treturn true\n\t\telsif (array.include?(3) and array.include?(4) and array.include?(5))\n\t\t\treturn true\n\t\telsif (array.include?(6) and array.include?(7) and array.include?(8))\n\t\t\treturn true\n\t\telse\n\t\t\treturn false\n\t\tend\n\tend",
"def valid_move?(board, index)\n def position_taken?(array, ind)\n if array[ind] == \" \" || array[ind] == \"\" || array[ind] == nil #if the array is empty, we turn false\n return false\n else\n return true\n end\n end\n#is the user putting an appropriate number to play ex: 1-9\n def available_on_board?(num)\n if num.between?(0, 8) == true #if the number is between\n return true\n else\n return false\n end\nend\n\n if (position_taken?(board, index)) == false && (available_on_board?(index) == true)\n return true\n else\n return false\n end\nend",
"def computer_opens_game\n @avail_moves.length == 8 && @depth == 1 ? true : false\n end",
"def long_planeteer_calls(calls)\n calls.any? { |word| word.length > 4 }\nend",
"def long_planeteer_calls(array)\n array.any? do |word|\n word.length > 4 \n end \nend",
"def move_knight\n #there is no more than eight moves\nend",
"def travel_internationally?\n puts \"Will you be traveling internationally?\"\n puts \"1. Yes\\n2. No\"\n choice = gets.chomp.to_i\n\n if choice == 1\n return true\n elsif choice == 2\n return false\n else\n puts \"invalid input\"\n return travel_internationally?()\n end\nend",
"def check?\n king_coords = current_player_king_coordinates\n return true unless build_DANGER_moves_array.empty?\n end",
"def has_possible_moves\n \t\[email protected] do |mower|\n \t\t\treturn true if mower.can_move? && !mower.is_going_outside?(lawn_x, lawn_y)\n\t \tend\n \t\treturn false\n \tend",
"def plan_trip (mta, start_station, end_station)\n\n # Check if the user is already at the destination\n if(start_station == end_station)\n puts \"You are already at your destination\\n\\n\"\n else\n # Find the station indexes\n stations = find_stations mta, start_station, end_station\n\n # Build the trip\n trip = [start_station]\n trip.push *build_trip(mta, stations)\n\n #Display the trip\n display_trip trip, stations[0]\n end\n\nend",
"def long_planeteer_calls(array)\n array.any? do |word|\n word.size > 4\n end\nend",
"def route_go_ride(from, dest)\n from = from.map{|x|x+1}\n dest = dest.map{|x|x+1}\n\n x=from[0]\n y=from[1]\n\n route = \"The route is\\n\\tstart at (#{x},#{y})\"\n\n if from[0]!=dest[0]\n if from[0]<dest[0]\n until x == dest[0]\n x = x + 1\n end\n route += \"\\n\\tgo to (#{x},#{y})\"\n route += \"\\n\\tturn right\" if y>dest[1]\n route += \"\\n\\tturn left\" if y<dest[1]\n\n else from[0]>dest[0]\n until x == dest[0]\n x = x - 1\n end\n route += \"\\n\\tgo to (#{x},#{y})\"\n route += \"\\n\\tturn left\" if y>dest[1]\n route += \"\\n\\tturn right\" if y<dest[1]\n end\n end\n\n if from[1]!=dest[1]\n if from[1]<dest[1]\n until y == dest[1]\n y = y + 1\n end\n route += \"\\n\\tgo to (#{x},#{y})\"\n else from[1]>dest[1]\n until y == dest[1]\n y = y - 1\n end\n route += \"\\n\\tgo to (#{x},#{y})\"\n end\n end\n\n route += \"\\n\\tfinish at (#{x},#{y})\"\n route\n\n end",
"def has_possible_moves\n \t\[email protected] do |mower|\n \t\t\treturn true if mower.can_move?(lawn_mowers_positions)\n\t \tend\n \t\treturn false\n \tend",
"def long_planeteer_calls(array)\n array.any? { |word| word.length > 4}\nend",
"def trains_going_direction(array_of_trains, desired_direction)\n\n #loop through array_of_trains\n\n array_of_trains.each do |train|\n if train[:direction] == desired_direction\n puts train\n end\n end\nend",
"def long_planeteer_calls(array)\n array.any? do\n |word| word.length > 4\n end\nend",
"def full\n @moves.length >= 12\n end",
"def can_go_down?(the_maze, floor, position)\r\n (floor + 1 < the_maze.size) and (the_maze[floor + 1][position] == \"0\") \r\nend",
"def in_journey?\n !(voyage[:start] == nil)\n end",
"def long_planeteer_calls(planateer_calls)# code an argument here\n # Your code here\n planateer_calls.any? { |call| call.length >= 5 }\n \nend",
"def start()\n\tputs \"%s\\n%s\\n%s\\n\" % [\"You are in a dark room.\",\"There is a door to your right and left.\",\"Which one do you take?\"]\n\tprompt; next_move = gets.chomp\n\n\tif next_move.downcase.include? \"left\"\n\t\tbear_room()\n\telsif next_move == \"right\"\n\t\tcthulu_room()\n\telse\n\t\tdead(\"You stumble around the room until you starve\")\n\tend\n\t\nend",
"def shortest_walk(walk)\n # your code goes here\nend",
"def find_waters_next_step(location,cave)\n \n next_step = [0,0]\n \n if cave[location[:y] + 1][location[:x]] == \" \" # Attempt to flow down\n next_step[1] = 1\n elsif cave[location[:y]][location[:x] + 1] == \" \" # If unable to flow down try to flow right\n next_step[0] = 1\n else # Back carraige return to a ~ once we reach a cave wall\n next_step[1] = -1 # go up one level in the cave\n while cave[location[:y] + next_step[1]][location[:x] + next_step[0] - 1] == \" \"\n next_step[0] += -1\n end\n end\n \n next_step\nend",
"def space_travel\n puts \"\\n\"\n puts \"You engage the main thrusters and you feel the ship jerk forward.\"\n\n numb = rand(10)\n if numb.even?\n puts \"Everything functions as expected. You confirm your Lunar Trajectory and settle in for the trip.\"\n sleep 1.5\n\n moon_arival()\n else\n puts \"\\n\"\n puts \"Suddenly, you feel a sharp jolt as something hits your ship.\"\n puts \"You enable the radio, but all you hear is the hiss of static.\"\n puts \"It must have hit the communication dish. You are alone.\"\n puts \"\\n\"\n sleep 1.5\n\n spacewalk()\n puts \"\\n\"\n\n fix = rand(10)\n if numb.even?\n puts \"Your engineer suits for a space walk and fixes the dish. You're back online.\"\n puts \"You message Huston and inform them what happened. You continue to the Moon.\"\n sleep 1.5\n\n moon_arival()\n else\n puts \"Your engineer suits up and exits the air lock.\"\n puts \"As he\\'s climbing out, another part of debree hits and kills him.\"\n puts \"Part of the ship is torn open. You can hear the air gushing out the tear.\"\n puts \"\\n\"\n sleep 2\n puts \"Within moments, the oxygen is depleted. You spend the last few moments of consciousness looking into the void of space.\"\n end\n end\nend",
"def stop_elevator\n return false if stops_remaining?\n @direction = 0 and return true\n end",
"def move( mobile )\n\t\tif @closed && !mobile.affected?(\"pass door\")\n\t\t\tmobile.output \"The #{name} is closed.\"\n\t\t\treturn false\n elsif mobile.affected?(\"pass door\") && @passproof\n mobile.output \"You can't pass through the #{self.name}.\"\n return false\n\t\telse\n portal = @direction.nil?\n sneaking = mobile.affected?(\"sneak\")\n leave_string = \"\"\n if portal\n leave_string = \"0<N> steps into 1<n>.\"\n mobile.output(\"You step into 0<n>.\", [self]) unless sneaking\n else\n leave_string = \"0<N> leaves #{@direction.name}.\"\n end\n (mobile.room.occupants - [mobile]).each_output(leave_string, [mobile, self]) unless sneaking\n old_room = mobile.room\n mobile.move_to_room( @destination )\n if old_room\n old_room.occupants.select { |t| t.position != :sleeping && t.responds_to_event(:observe_mobile_use_exit) }.each do |t|\n Game.instance.fire_event( t, :observe_mobile_use_exit, {mobile: mobile, exit: self } )\n end\n end\n arrive_string = \"\"\n if portal\n arrive_string = \"0<N> has arrived through 1<n>.\"\n else\n arrive_string = \"0<N> has arrived.\"\n end\n (mobile.room.occupants - [mobile]).each_output arrive_string, [mobile, self] unless sneaking\n\t\tend\n return true\n\tend",
"def done?\n # legal_moves(state).empty?\n # Try to speed up by disregarding possibility of draw\n false\n end",
"def a_do(data)\n result = true\n 4.times { |x|\n return \"X won\" if data[x].join =~ /[X|T]{4}/\n return \"O won\" if data[x].join =~ /[O|T]{4}/\n }\n data2 = data.transpose\n 4.times { |y|\n return \"X won\" if data2[y].join =~ /[X|T]{4}/\n return \"O won\" if data2[y].join =~ /[O|T]{4}/\n }\n l = \"\"\n r = \"\"\n 4.times { |x|\n l += data[x][x]\n r += data[x][3-x]\n }\n return \"X won\" if l =~ /[X|T]{4}/ or r =~ /[X|T]{4}/\n return \"O won\" if l =~ /[O|T]{4}/ or r =~ /[O|T]{4}/\n\n return data.flatten.join =~ /\\./ ? \"Game has not completed\" : \"Draw\"\nend",
"def valid_movement?(m)\n if m.length > 0\n m.each do |i|\n if not Navigation.DIRECTION.include?(i)\n return false\n end\n end\n else\n return false\n end\n true\n end",
"def decide_direction()\n floors = @building.floors\n requests_below = 0\n #see how many people below, wanting to go up or down\n (1..@current_floor).each do |floor_num|\n f = floors[floor_num]\n if f.button_pairs[\"elevator#{@number}\"][\"up\"] == true || f.button_pairs[\"elevator#{@number}\"][\"down\"] == true\n requests_below += f.up_person_queue.size() + f.down_person_queue.size()\n end\n end\n requests_above = 0\n #see how many above wanting to go down or up\n (@[email protected]_of_floors).each do |floor_num|\n f = floors[floor_num]\n if f.button_pairs[\"elevator#{@number}\"][\"down\"] == true || f.button_pairs[\"elevator#{@number}\"][\"up\"] == true\n requests_above += f.up_person_queue.size() + f.down_person_queue.size()\n end\n end\n if requests_above == 0 && requests_below == 0\n @direction = \"stationary\"\n elsif requests_above > requests_below\n @direction = \"up\"\n move_up()\n else #requests_above <= requests_below\n @direction = \"down\"\n move_down()\n end \n end",
"def crash_choice_walk(name)\n\tputs \"After walking some distance\"\n\tputs \"you discover a divergent path.\"\n\tputs \"Select your path #{name}.\"\n\tputs \"(\\\"A\\\")Left path, or (\\\"B\\\"):Right path?.\"\n\tprint \">>\"\n\tpath_select = gets.chomp.capitalize\n\n\tif path_select.include? \"A\" \n\t\tputs \"Going Left takes you\"\n\t\tputs \"to a village of friendly folks.\"\n\t\tputs \"They will help you.\"\n\t\tputs \"Congratulations! #{name}....YOU SURVIVED!!\"\n\t\tputs \"Thanks for playing this Game :)\"\n\n\telsif path_select.include? \"B\" \n\t\tputs \"Good choice, right takes you\"\n\t\tputs \"to a big stone castle\"\n\t\tputs \"where a wealthy Baron\"\n\t\tputs \"invites you into his home,\"\n\t\tputs \"and offers you help.\"\n\t\tputs \"Congratulations! #{name}...YOU SURVIVED!!\"\n\t\tputs \"Thanks for playing this Game :)\"\n\telse\n \t\tputs \"Error\"\n\n\tend\n\nend",
"def dash?\n return false if @run_points == 0 && StandWalkRun::Use_run\n return true if Input.press?(Input::A) && StandWalkRun::Use_run\n end",
"def long_planeteer_calls(words)\n # Your code here\n words.any? do |word|\n word.length > 4\n end\nend",
"def verification_coordonnees \n\tcoordonnees = [\"a1\", \"a2\", \"a3\", \"b1\", \"b2\", \"b3\", \"c1\", \"c2\", \"c3\"]\n\ttrue if coordonnees.include? @answer_play \n end",
"def completed?\n min_moves == moves_count.value\n end",
"def long_planeteer_calls(planeteer_calls)\nplaneteer_calls.any? { |string| string.length > 4 }\nend",
"def scan\n x = position[0]\n y = position[1]\n !Robot.in_position(x, y).empty? || !Robot.in_position(x+1, y).empty? || !Robot.in_position(x-1,y).empty? || !Robot.in_position(x,y+1).empty? || !Robot.in_position(x,y-1).empty?\n end",
"def long_planeteer_calls(calls)# code an argument here\n # Your code here\n calls.any? {|x| x.chars.length>4}\nend",
"def user_interaction\n found = false\n puts \"What planet would you like to learn about?\"\n learn_about = gets.chomp.downcase.capitalize\n @array_of_planets.each do |search|\n if search.name == learn_about\n found = true\n puts \"Good news! That planet is in the solar system. Let me tell you about it.\"\n puts \"#{search.each_planet_return}\\n\"\n break\n end\n end\n unless found == true\n puts \"Unfortunately, that planet is not in the solar system, so there's nothing to learn\\n\"\n end\n end",
"def inflight(mins, movie_times)\n movie_times.each_with_index do |time, i|\n tmp = movie_times.dup\n tmp.slice!(i)\n diff = mins - time\n return true if tmp.include? diff\n end\n return false\nend",
"def valid_moves\n\n end",
"def move\n # Choose a random cell\n # JAVI: Extend this part of the method to choose cell with lower number of surveys (on average)\n cell = cells_around(@loc).rand\n \n # possibly a good location\n # first look ahead \n if !touches_path? cell, @path, @loc \n \n # do 1 more look ahead for each further possible step to avoid this:\n #\n # . . . . .\n # v < < . .\n # v . ^ . .\n # v . ^ < .\n # v . x o .\n # v x ? x .\n # > > ^ . .\n # . . . . . \n #\n # ^v<> = path\n # o = start\n # ? = possible good looking next move\n # x = shows that this is a dead end. All further steps are not allowed.\n #\n # Therefore, if any further step from cell is possible, then we're good to go\n \n # Configure future\n future_path = @path.dup\n future_path << cell\n second_steps = cells_around(cell)\n \n # If at least one of the future steps is valid, go for it\n second_steps.each do |ss|\n if !touches_path? ss, future_path, cell\n @path << cell\n @loc = cell\n @distance -= 1 \n return true\n end\n end \n end \n \n Rails.logger.debug \"*****************\"\n Rails.logger.debug \"Location: #{@loc.to_s}, New move: #{cell.to_s}.\"\n Rails.logger.debug \"Path: #{@path.to_s}\" \n \n false \n #cells = Cell.all :conditions => \"(x = #{@x-1} AND y = #{@y}) OR (x = #{@x+1} AND y = #{@y}) OR (x = #{@x} AND y = #{@y-1}) OR (x = #{@x} AND y = #{@y+1})\",\n # :order => \"positive_count + negative_count ASC\"\n \n # if all the cells have already been surveyed, weight index to those with few surveys \n #if cells.size == 4\n # i = rand(3)\n # i = (i - (i * 0.1)).floor \n # @x = cells[i].x\n # @y = cells[i].y\n # return\n #end\n \n # if there are empty cells, make a new cell where there's a gap and use that \n #[@x, @y-1] *<-- ALWAYS GOING DOWN\n #existing_cells = cells.map {|c| [c.x, c.y]}\n #survey_cell = (possible_cells - existing_cells).rand\n end",
"def cthulu_room()\n\tputs \"%s\\n%s\\n%s\\n\" % [\"Here you see the great evil Cthulu.\", \"He, it, whatever stares at you and you go insane.\", \"Do you flee for your life or eat your head?\"]\n\tprompt; next_move = gets.chomp\n\n\tif next_move.include? \"flee\"\n\t\tstart()\n\telsif next_move.include? \"head\"\n\t\tdead(\"Well that was tasty!\")\n\telse\n\t\tcthulu_room()\n\tend\n\nend",
"def new_trip(start_station, start_line, end_station, end_line)\n # Display trip\n puts Rainbow(\"\\nYou are travelling from #{ start_line } on the #{ start_line } to #{ end_station} on the #{ end_line }\").lavenderblush\n puts \"YOUR TRIP DETAILS\"\n\n # check for a single line trip\n if start_line == end_line\n get_trip(start_station, end_station, start_line)\n else\n get_trip(start_station, \"Union Square\", start_line)\n get_trip(\"Union Square\", end_station, end_line)\n end\nend",
"def check_path_open (from, to, board)\n #refine\n\n #Check if diagonal\n if (to[1]-from[1]).abs == (to[0]-from[0]).abs\n iterations_y = (to[1]-from[1])\n iterations_x = (to[0]-from[0])\n\n if (iterations_x > 0) && (iterations_y > 0)\n iterations_x.times do |x|\n if !is_spot_open([from[0]+x,from[1]+x],board)\n return false\n end\n end\n\n elsif (iterations_x > 0) && (iterations_y < 0)\n iterations_x.times do |x|\n if !is_spot_open([from[0]+x,from[1]-x],board)\n return false\n end\n end\n\n elsif (iterations_x < 0) && (iterations_y > 0)\n iterations_x.times do |x|\n if !is_spot_open([from[0]-x,from[1]+x],board)\n return false\n end\n end\n\n elsif (iterations_x < 0) && (iterations_y < 0)\n iterations_x.times do |x|\n if !is_spot_open([from[0]-x,from[1]-x],board)\n return false\n end\n end\n end\n\n return true\n\n\n\n #check if it moves vertical\n elsif ((to[0]==from[0])&&(to[1]!=from[1]))\n\n iterations = (to[1]-from[1])\n if iterations > 0\n iterations.times do |x|\n if !is_spot_open([from[0],from[1]+x],board)\n return false\n end\n end\n elsif iterations < 0\n iterations.times do |x|\n if !is_spot_open([from[0],from[1]-x],board)\n return false\n end\n end\n end\n\n return true\n\n #check if it moves horizontal\n elsif ((to[1]==from[1])&&(to[0]!=from[0]))\n iterations = (to[0]-from[0])\n if iterations > 0\n iterations.times do |x|\n if !is_spot_open([from[0]+x,from[1]],board)\n return false\n end\n end\n elsif iterations < 0\n iterations.times do |x|\n if !is_spot_open([from[0]-x,from[1]],board)\n return false\n end\n end\n end\n\n return true\n\n end\n\n end",
"def choose_attack_direction\n @enemies_direction = Array.new\n Directions.each do |dir|\n if warrior.feel(dir).enemy? != nil\n @enemies_direction.push dir\n end\n end\n return false \n end",
"def tourney_done?(matches)\n output = true\n matches.each do |match|\n output = false if !(match['match']['state'].eql?(\"complete\"))\n end\n return output\nend",
"def win?\n sleep(3)\n check_points\n end",
"def long_planeteer_calls(words)\n words.any? {|word| word.length > 4}\nend",
"def can_move(i,j)\n\t\t#posición es 0\n\t\tif @laberinto[i,j] == 0\n\t\t\t#no se a pasado antes por ahi\n\t\t\tif @travel_path.count([i,j]) == 0\n\t\t\t\treturn true\n\t\t\telse \n\t\t\t\treturn false\n\t\t\tend\n\t\telse\n\t\t\treturn false\n\t\tend\n\tend",
"def long_planeteer_calls(calls)\n # t_f = []\n # calls.each do |call|\n # t_f << call.include?(call.length > 4)\n # end\n # if t_f.include?(true)\n # true\n # else\n # false\n # end\n new_calls = calls.find do |call|\n (call.length > 4)\n end\n !!new_calls\nend",
"def long_planeteer_calls(words)\n words.any? { |word| word.length>4}\nend",
"def parrot_trouble(talking, hour)\n if talking && (hour < 7 || hour > 20)\n puts \"NG\"\n else\n puts \"OK\"\n end\nend",
"def long_planeteer_calls(calls)\n\tcalls.any? {|item| item.length > 4}\nend",
"def go_maze(direction)\n\t\tlocation = find_room_in_maze(@player.location)\n\t\tvalid = true\n\t\treply = \"You go \" + direction.to_s + \".\"\n\t\tunless location.connections.include?(direction)\n\t\t\treply = \"You can't go that way\" \n\t\t\tvalid = false\n\t\telse\n\t\t\[email protected] = @maze.rooms.sample.reference\n\t\tend\n\t\tputs reply\n\t\tswitch_player if valid\n\tend",
"def does_it_land?\n if self.robot.moves.count < 1 \n errors.add(:base, :landing_error) if !self.is_move_available?\n end\n end",
"def out_of_turns?\n result = !@data[@data.length-1][:key].nil?\n puts \"Out of turns!\" if result\n @out_of_turns = result\n result\n end",
"def check_for_leaving curr_loc, to_move\r\n\t\tif curr_loc.name == \"Cathedral\" and to_move == 2\r\n\t\t\tputs \"#{driver.name} heading from #{driver.location.name} to Monroeville via Fourth Ave.\"\r\n\t\t\t@sim_finished = true\r\n\t\t\treturn true\r\n\t\telsif curr_loc.name == \"Hillman\" and to_move == 0\r\n\t\t\tputs \"#{driver.name} heading from #{driver.location.name} to Downtown via Fifth Ave.\"\r\n\t\t\t@sim_finished = true\r\n\t\t\treturn true\r\n\t\tend\r\n\t\treturn false\r\n\tend",
"def displayWalks\n\t\ti = 0\n\t\twhile i < @@walks\n\t\t\tputs \"Woof\"\n\t\t\tputs \"On the #{@time.strftime(\"%d-%m-%Y at %H:%M\")} #{@name} walked #{@@distance[i]}kms in #{@@location[i]}, coordinates: #{@@coordinates[i]}. \"\n\t\ti += 1\n\t\tend\n\tend",
"def can_win?(array, index)\n\nend",
"def next_move_correct?(ary,attacking = false)\n movement_correct = false\n Possible_moves.each{|move|\n if (@current_position[0]+move[0]) == ary[0] && (@current_position[1]+move[1]) == ary[1]\n movement_correct = true\n break\n end\n }\n movement_correct\n end",
"def next_move_correct?(ary,attacking = false)\n movement_correct = false\n Possible_moves.each{|move|\n if (@current_position[0]+move[0]) == ary[0] && (@current_position[1]+move[1]) == ary[1]\n movement_correct = true\n break\n end\n }\n movement_correct\n end",
"def directions\n puts(\"\\tThe Rules: \\n\")\n print(\"\\tPlaying this game is very simple. The game will first display a\\n\")\n print(\"\\trandomly selected word replaced with underscores and a hint to\\n\")\n print(\"\\twhat the word is. The player (you) will then be prompted to enter\\n\")\n print(\"\\teither a vowel or a consonant. The game will then print out anoter\\n\")\n print(\"\\tscreen with any spaces filled in the hidden word if you entered\\n\")\n print(\"\\ta correct guess. The player will than have the option to enter\\n\")\n print(\"\\tthe entire word or keep guessing single letters. WARNING if you\\n\")\n print(\"\\ttry to guess the hidden word and turnout to be incorrect than\\n\")\n print(\"\\tyou lose the game. The wheel is spun for every guess. When\\n\")\n print(\"\\ta player enters a vowel 250 points is deducted, but if a \\n\")\n print(\"\\tplayer enters a correct consonant they win the point for the\\n\")\n print(\"\\tround, Good Luck!\\n\\n\")\n puts (\"Press Enter to continue.\")\n end",
"def move_available?\n total_available_moves > 0\n end",
"def find_waters_next_step(location,cave)\n # p \"I'm the function that finds the water flow next step\"\n next_step = [0,0]\n \n if cave[location[:y] + 1][location[:x]] == \" \" # Attempt to flow down\n next_step[1] = 1\n elsif cave[location[:y]][location[:x] + 1] == \" \" # If unable to flow down try to flow right\n next_step[0] = 1\n else #back carraige return to a ~ once we reach a cave wall\n p \"Water has no where to go\"\n next_step[1] = -1 # go up one level in the cave\n \n # Breaking some ruby rules right here to go backwards in the cave to find a blank space to fill\n \n while cave[location[:y] + next_step[1]][location[:x] + next_step[0] - 1] == \" \"\n next_step[0] += -1\n end\n end\n \n next_step\nend",
"def check_waypoint(in_lat, in_long, in_time, in_id)\n is_lat_float = float?(in_lat)\n is_long_float = float?(in_long)\n is_sent_date = date?(in_time)\n\n # Se podria agregar una verificacion del\n # identificador del vehiculo\n\n if !is_lat_float || !is_long_float || !is_sent_date || !in_id\n return false\n end\n\n true\n end",
"def can_go_up?(the_maze, floor, position)\r\n (floor - 1 > -1) and (the_maze[floor - 1][position] == \"0\") \r\nend",
"def isWalking _args\n \"isWalking _args;\" \n end",
"def game_tied?\n if @number_of_turns == 9\n true\n else\n false\n end\n end",
"def play_word(word, loc_let, loc_num, direction)\n letters = []\n word = word.upcase.split(\"\")\n i = 0\n loc_down = BOARD_HASH[loc_let]\n if direction == \"across\"\n word.length.times do\n letters << play_letter(word[i], loc_down, loc_num)\n loc_num += 1\n i += 1\n end\n\n elsif direction == \"down\"\n\n word.length.times do\n letters << play_letter(word[i], loc_down, loc_num)\n loc_down += 1\n i += 1\n end\n end\n\n if letters.include?(false)\n return false\n else\n letters.delete(true)\n return letters\n end\n end",
"def long_planeteer_calls(planeteer_calls)\n planeteer_calls.any? { |call| call.length > 4 }\nend",
"def long_planeteer_calls(planeteer_calls)\n planeteer_calls.any? { |call| call.length > 4 }\nend"
] | [
"0.7005325",
"0.64366823",
"0.6224846",
"0.6107727",
"0.6032032",
"0.60037327",
"0.5982154",
"0.59286284",
"0.58981097",
"0.5887284",
"0.58018595",
"0.57814914",
"0.57814914",
"0.5748638",
"0.5740135",
"0.5698428",
"0.56587684",
"0.5630898",
"0.55616754",
"0.5553746",
"0.5527343",
"0.5519072",
"0.5485474",
"0.5475402",
"0.54650867",
"0.5449038",
"0.5444014",
"0.5431436",
"0.54008085",
"0.53866875",
"0.5384684",
"0.53807545",
"0.5372256",
"0.5360258",
"0.5355649",
"0.5355323",
"0.53534836",
"0.53527254",
"0.5344876",
"0.5329944",
"0.53296494",
"0.5327532",
"0.53225225",
"0.5319636",
"0.5302517",
"0.5301885",
"0.5288502",
"0.52790934",
"0.52761185",
"0.5273998",
"0.5268015",
"0.5262615",
"0.52559537",
"0.52535987",
"0.5248134",
"0.52468836",
"0.52465296",
"0.523549",
"0.5220508",
"0.5203225",
"0.5197981",
"0.5189018",
"0.51882565",
"0.5186901",
"0.5184438",
"0.5182384",
"0.51798594",
"0.51763296",
"0.5175276",
"0.5163344",
"0.51580787",
"0.5155289",
"0.5154428",
"0.5151924",
"0.5147829",
"0.51422596",
"0.51407856",
"0.5140114",
"0.5139505",
"0.5138439",
"0.5132119",
"0.5129095",
"0.5126809",
"0.512636",
"0.5123228",
"0.5120664",
"0.5117438",
"0.5117237",
"0.51159793",
"0.51159793",
"0.51159203",
"0.51138234",
"0.5112945",
"0.51107115",
"0.51015866",
"0.50955975",
"0.5093268",
"0.5091228",
"0.5087884",
"0.5087884"
] | 0.5829618 | 10 |
initialize(resource, data) Method to initialize a record. | def initialize(service, resource, data, record = nil)
@resource = resource
@data = data
@record = record
@service = service
proxy = resource.spigot(service)
@map = proxy.map if proxy.present?
@associations = map ? map.associations : []
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(record)\n @record = record\n end",
"def initialize(resource_id, data)\n @logger = Config.logger\n @event_log = Config.event_log\n @job = nil\n end",
"def initialize(record = nil, *)\n @record = record\n end",
"def initialize(type, data=nil)\n # Verify then set the record type\n @type = type\n ensure_valid_type\n self.data = data\n end",
"def initialize(resource)\n @resource = resource\n end",
"def initialize_with_record(record)\n inst = self.new\n inst.send(:_record=, record)\n inst.send(:_id=, record.id)\n inst\n end",
"def initialize(resource)\n @resource = resource\n end",
"def initialize(resource)\n @resource = resource\n end",
"def initialize(user, record)\n @user = user\n @record = record\n end",
"def initialize\n super()\n init_data()\n end",
"def initialize(data)\n self.data = (self.respond_to? :prepare_data)? prepare_data(data): data\n self\n end",
"def initialize(record, controller)\n @record = record\n @serializer = Serializer.build(record)\n @controller = controller\n end",
"def initialize(data)\n\n end",
"def initialize(record_file)\n @record_file = record_file\n end",
"def instantiate\n resource.new(data)\n end",
"def initialize_data\n end",
"def initialize(resource)\n @attributes = OpenStruct.new(resource.attributes.to_hash)\n end",
"def initialize(data)\n\t\t@data = data\n\tend",
"def initialize(user = nil, record = nil)\n @user = user\n @record = record\n end",
"def initialize(data)\n @data = data\n end",
"def initialize(data)\n @data = data\n end",
"def initialize(data)\n @data = data\n end",
"def initialize(data)\n @data = data\n end",
"def initialize(data)\n @data = data\n end",
"def initialize(data)\n @data = data\n end",
"def initialize(data)\n @data = data\n end",
"def initialize(data)\n @data = data\n end",
"def initialize(attributes = {})\r\n attributes.each do |name, value|\r\n send(\"#{name}=\", value)\r\n end\r\n @record_id = nil\r\n end",
"def initialize(rowdata)\n @rowdata = rowdata\n end",
"def initialize id, data\n @id = id\n @data = data\n end",
"def initialize(api_key:, resource:)\n super(api_key: api_key)\n @resource = resource\n end",
"def initialize(resource:, zc_id:)\n @resource = resource\n @zc_id = zc_id\n end",
"def initialize(data) # will accept the attribute data. \r\n\r\n @data = data # store the attribute data, and allows it to be used each time. \r\n\r\n end",
"def initialize(handle, record_type)\n\t\t\t@prefix = read_string(handle)\n\t\t\t@name = read_dictstring(handle)\n\t\t\t@value = Record.MakeRecord(handle)\n\t\tend",
"def initialize(data = {})\n raise ArgumentError unless data.kind_of?(Hash)\n super(data)\n \n raise ArgumentError, \"ID is required\" if @id.nil?\n end",
"def initialize(record)\r\n self.record = record\r\n self.stash = Attributes.new\r\n end",
"def initialize(location, data)\n\t\t@location = location\n\t\t@data = data\n\tend",
"def initialize(data)\n @data = data\n end",
"def initialize(attrs = {})\n if attrs['data']\n super( attrs['data'] )\n else\n super(attrs)\n end\n end",
"def initialize(type_name, data_type, attribute_name, resource_hash, _referrable_type = nil)\n @type_name = type_name\n @data_type = data_type\n @attribute_name = attribute_name\n super(**resource_hash) # Pass resource to parent Puppet class.\n end",
"def initialize(attrs = nil)\n attrs ||= {}\n raise ArgumentError, \"Hash object is expected\" unless attrs.is_a?(Hash)\n\n @new_record = true\n @attributes ||= {}\n process_attributes(attrs)\n apply_defaults\n self.id = BSON::ObjectId.new unless self.id\n run_callbacks(:initialize) unless _initialize_callbacks.empty?\n end",
"def initialize data\n self.data = data\n end",
"def initialize data\n self.data = data\n end",
"def initialize data\n self.data = data\n end",
"def initialize data\n self.data = data\n end",
"def initialize data\n self.data = data\n end",
"def initialize data\n self.data = data\n end",
"def initialize data\n self.data = data\n end",
"def initialize data\n self.data = data\n end",
"def initialize(data)\n super\n end",
"def initialize(data)\n super\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(*args)\n # Don't allow an object to be created unless key values are provided and a list of keys has been defined at the class level\n raise ArgumentError unless args[0].has_keys?(self.class.keys) and !(self.class.keys.empty?)\n args.each do |arg|\n raise ArgumentError, 'Creating a Record expects a hash as an argument' unless arg.is_a?(Hash)\n arg.each do |k, v|\n self.send(\"#{k.to_s}=\".to_sym, v)\n end\n end\n # create the primary key for this record then\n # store the pk and the record in the records class instance variable\n # Use a non-printable character as the delimiter \\x01 to avoid code/data conflicts\n self.class.records[self.class.build_key(self)] = self\n end",
"def initialize(results_record)\n\n if results_record.key? 'Record'\n @record = results_record['Record'] # single record returned by retrieve api\n else\n @record = results_record # set of records returned by search api\n end\n\n @items = @record.fetch('Items', {})\n\n @bib_entity = @record.fetch('RecordInfo', {})\n .fetch('BibRecord', {})\n .fetch('BibEntity', {})\n\n @bib_relationships = @record.fetch('RecordInfo', {})\n .fetch('BibRecord', {})\n .fetch('BibRelationships', {})\n\n @bib_part = @record.fetch('RecordInfo', {})\n .fetch('BibRecord', {})\n .fetch('BibRelationships', {})\n .fetch('IsPartOfRelationships', {})[0]\n\n @bibtex = BibTeX::Entry.new\n end",
"def initialize(attributes)\n super(attributes)\n self.resource_name = attributes[:resource_name]\n self.method_name = attributes[:method_name]\n self.data = attributes[:data]\n self.message_id = attributes[:message_id] || rand(10**12)\n end",
"def initialize(data=nil)\n super(data)\n end",
"def initialize(user, data)\n\t\t\tsuper(user)\n\t\t\tinit(data)\n\t\tend",
"def initialize(raw_data)\n @raw_data = raw_data\n end",
"def initialize(resource)\n raise Puppet::DevError, \"Got TransObject instead of Resource or hash\" if resource.is_a?(Puppet::TransObject)\n resource = self.class.hash2resource(resource) unless resource.is_a?(Puppet::Resource)\n\n # The list of parameter/property instances.\n @parameters = {}\n\n # Set the title first, so any failures print correctly.\n if resource.type.to_s.downcase.to_sym == self.class.name\n self.title = resource.title\n else\n # This should only ever happen for components\n self.title = resource.ref\n end\n\n [:file, :line, :catalog, :exported, :virtual].each do |getter|\n setter = getter.to_s + \"=\"\n if val = resource.send(getter)\n self.send(setter, val)\n end\n end\n\n @tags = resource.tags\n\n @original_parameters = resource.to_hash\n\n set_name(@original_parameters)\n\n set_default(:provider)\n\n set_parameters(@original_parameters)\n\n self.validate if self.respond_to?(:validate)\n end",
"def initialize(resource, helper)\n @resource = resource\n @helper = helper\n end",
"def initialize(data)\n assert_kind_of 'data', data, Hash\n @data = data\n end",
"def initialize(data, org_id)\n @data = data\n @org_id = org_id\n end",
"def initialize(records)\n records = parse_json!(records) if records.is_a?(String)\n\n raise ::ArgumentError, invalid_type_message unless records.is_a?(Hash)\n\n @records = records.with_indifferent_access\n\n validate_record_key_presence!(@records)\n\n @championship = @records[:championship]\n @matches = @records[:matches]\n @rankings = @records[:rankings]\n @rounds = @records[:rounds]\n @teams = @records[:teams]\n end",
"def initialize(resource = nil)\n @resource = resource\n @logger = @resource&.create_log # This is an ImportLog.\n end",
"def new\n @record = Record.new()\n end",
"def initialize( uri, idobj )\n\t\t@data\t\t= {}\n\t\t@id\t\t\t= idobj\n\t\t@new\t\t= true\n\t\t@modified\t= false\n\n\t\tunless idobj.new?\n\t\t\tself.retrieve\n\t\tend\n\n\t\tsuper()\n\tend",
"def new(data={})\n self.spira_resource.new(data)\n end",
"def initialize\n load_data\n end",
"def initialize(object, resource_klass, context)\n @object = object\n @resource = resource_klass.new(object, context)\n\n # Need to reflect on resource's relationships for error reporting.\n @relationships = resource_klass._relationships.values\n @relationship_names = @relationships.map(&:name).map(&:to_sym)\n @foreign_keys = @relationships.map(&:foreign_key).map(&:to_sym)\n @resource_key_for = {}\n @formatted_key = {}\n end",
"def initialize(data = {})\n @data = data\n end",
"def initialize(resource_hash)\n @target = resource_hash['target']\n @type = resource_hash['type'].to_s.capitalize\n @title = resource_hash['title']\n @state = resource_hash['state'] || {}\n @desired_state = resource_hash['desired_state'] || {}\n @events = resource_hash['events'] || []\n end",
"def initialize(schema, data)\n @schema = schema\n @data = data\n @valid = false\n end",
"def initialize data\n @data = data\n end",
"def initialize(user, record)\n raise Pundit::NotAuthorizedError, \"Must be signed in.\" unless user\n @user = user\n @record = record\n end",
"def initialize args = {}\n self.resource = args[:resource] || ''\n end",
"def initialize(resource_json)\n @json = JSON.parse(resource_json)\n parse_base\n end",
"def initialize(*opts)\n initialize_options(*opts)\n initialize_data(*opts)\n end",
"def initialize(resource, embed_config={}, options={})\n raise NotImplementedError\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 initialize(title, data)\n @title = title\n @data = data\n end",
"def initialize(resource)\n super(resource)\n if resource.uri.authority.to_s == \"\"\n raise ArgumentError,\n \"Resource cannot be handled by client: '#{resource.uri}'\"\n end\n @response = nil\n @remaining_body = StringIO.new\n end",
"def initialize(data, row)\n @data = data\n @row = row\n end",
"def initialize(resource, params, options={})\n super(params)\n @resource = resource\n @options = ActiveSupport::HashWithIndifferentAccess.new(options)\n end",
"def from_record(record)\n end",
"def initialize(attrs = nil)\n @new_record = true\n @attributes ||= {}\n process_attributes(attrs) do\n yield(self) if block_given?\n end\n # run_callbacks(:initialize) unless _initialize_callbacks.empty?\n # raise ::TinyDyno::Errors::MissingHashKey.new(self.name) unless @hash_key.is_a?(Hash)\n end",
"def initialize(resource, rules)\n @resource = resource\n @rules = rules\n end",
"def initialize(input_data)\n @data = input_data\n end",
"def initialize(api_object)\n raise ArgumentError,\n \"Trying to initialize #{self.class.name} with empty object.\" unless api_object\n\n load_from_record(api_object)\n \n raise ArgumentError, \"Could not locate valid id in record\" if @id.blank?\n end",
"def initialize(resource = nil)\n if resource.is_a?(Hash)\n # We don't use a duplicate here, because some providers (ParsedFile, at least)\n # use the hash here for later events.\n @property_hash = resource\n elsif resource\n @resource = resource\n @property_hash = {}\n else\n @property_hash = {}\n end\n end",
"def initialize data,ref\n\t\t@data=data\n\t\t@ref=ref\n\tend",
"def initialize(*args)\n\t\t\t\t\tself.track_changed_attributes = true\n\t\t\t\t\tself.changed_attributes_aado = []\n\n\t\t\t\t\tsuper(*args)\n\t\t\t\t\t\n\t\t\t\t\trequire \"obdb/AR_DatabaseObject\"\t# its here because of a circular reference problem\n\t\t\t\t\tself.database_object = DatabaseObject.create_do(self.class, self.id, self)\n\t\t\t\tend",
"def initialize_template(record)\n\n end",
"def initialize(xmldata=\"\")\n setPerson(xmldata)\n end",
"def set_record(id = nil, pid = nil)\n unless id.to_i > 0 && self.record = resource_model.includes(includes).find(id.to_i)\n self.record = resource_model.where((pid && where) ? where.call(pid) : {}).new\n self.record.attributes = create_attributes\n end\n end",
"def initialize(resource, request_env)\n @object = resource\n @request_env = request_env\n end",
"def initialize(object)\n @id = object[\"id\"]\n @data = object[\"data\"]\n end",
"def initialize(headers, records)\n @headers = headers\n @records = records\n end",
"def initialize(data)\n @data = data\nend",
"def initialize parameter, data, *opts, &block\n @parameter, @data = (parameter and parameter.to_sym), data\n\n @data_type = opts.delete_at(0)\n\n description_and_example = opts.delete_at(0)\n case description_and_example\n when String\n @description = description_and_example\n when Hash\n @description = description_and_example.keys.first\n @example = description_and_example.values.first\n end\n\n @data_type ||= Hash\n raise WRONG_DATA_TYPE_PASSED_MSG unless @data_type.is_a?(Class)\n raise \"params #{@data_type} and block given\" if block_given? and not [Array,Hash].include?(@data_type)\n\n @block = block\n @nesting = 0\n end",
"def initialize(record)\n @xml = record\n @doc = {}\n @doc[:id] = self.getID\n self.getFormatFacet\n self.getTitle\n self.getDescription\n\n @doc[:collection_facet] = \"City of Pullman Collection\"\n \n self.getImages\n self.getSubjects\n # self.getGeographicSubjects\n self.getPublisherFacet\n self.getLanguageFacet\n # self.storeRecord\n @doc\n end"
] | [
"0.7118509",
"0.7033196",
"0.6960827",
"0.6943045",
"0.6808666",
"0.6808642",
"0.67895186",
"0.6647307",
"0.6548822",
"0.6522198",
"0.65044963",
"0.6475516",
"0.639454",
"0.63933253",
"0.6388948",
"0.63792115",
"0.6355791",
"0.63211405",
"0.62781566",
"0.6250165",
"0.62463236",
"0.62463236",
"0.62463236",
"0.62463236",
"0.6243333",
"0.6243333",
"0.6243333",
"0.6238083",
"0.6232179",
"0.62261355",
"0.6225529",
"0.6225505",
"0.62216187",
"0.6207398",
"0.61835337",
"0.617381",
"0.61533445",
"0.6148384",
"0.6131817",
"0.6123497",
"0.6118442",
"0.6114347",
"0.6114347",
"0.6114347",
"0.6114347",
"0.6114347",
"0.6114347",
"0.6114347",
"0.6114347",
"0.61007035",
"0.61007035",
"0.609914",
"0.6093316",
"0.60778713",
"0.60745203",
"0.6070886",
"0.606522",
"0.60619015",
"0.60575956",
"0.60107696",
"0.60088176",
"0.59741354",
"0.5971961",
"0.59702224",
"0.5963229",
"0.5936056",
"0.59339553",
"0.592566",
"0.59252894",
"0.591781",
"0.5898133",
"0.5895653",
"0.5895621",
"0.5895453",
"0.58940804",
"0.5879845",
"0.5877425",
"0.58764887",
"0.5871063",
"0.5870386",
"0.586674",
"0.5866385",
"0.5862868",
"0.58568925",
"0.5853335",
"0.5836297",
"0.5836044",
"0.5824788",
"0.58247447",
"0.58184165",
"0.5813586",
"0.5810092",
"0.58070004",
"0.5802293",
"0.5798663",
"0.5795315",
"0.5791692",
"0.579098",
"0.5789422",
"0.578673"
] | 0.6669831 | 7 |
instantiate Executes the initialize method on the implementing resource with formatted data. | def instantiate
resource.new(data)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(resource_json)\n @json = JSON.parse(resource_json)\n parse_base\n end",
"def initialize\n super()\n init_data()\n end",
"def new(*)\n load\n super\n end",
"def initialize(resource)\n raise Puppet::DevError, \"Got TransObject instead of Resource or hash\" if resource.is_a?(Puppet::TransObject)\n resource = self.class.hash2resource(resource) unless resource.is_a?(Puppet::Resource)\n\n # The list of parameter/property instances.\n @parameters = {}\n\n # Set the title first, so any failures print correctly.\n if resource.type.to_s.downcase.to_sym == self.class.name\n self.title = resource.title\n else\n # This should only ever happen for components\n self.title = resource.ref\n end\n\n [:file, :line, :catalog, :exported, :virtual].each do |getter|\n setter = getter.to_s + \"=\"\n if val = resource.send(getter)\n self.send(setter, val)\n end\n end\n\n @tags = resource.tags\n\n @original_parameters = resource.to_hash\n\n set_name(@original_parameters)\n\n set_default(:provider)\n\n set_parameters(@original_parameters)\n\n self.validate if self.respond_to?(:validate)\n end",
"def initialize( * )\n\t\tsuper\n\t\t@template = self.load_template\n\tend",
"def initialize(data)\n\n end",
"def initialize() end",
"def initialize(resource)\n @resource = resource\n end",
"def initialize(resource)\n @resource = resource\n end",
"def initialize(resource_id, data)\n @logger = Config.logger\n @event_log = Config.event_log\n @job = nil\n end",
"def initialize()\n #@source = aSourceTemplate\n #@representation = compile(aSourceTemplate)\n end",
"def initialize\n load_data\n end",
"def initialize(resource)\n @resource = resource\n end",
"def initialize(raw_data)\n @raw_data = raw_data\n end",
"def initialize(data)\n self.data = (self.respond_to? :prepare_data)? prepare_data(data): data\n self\n end",
"def initialize(resource, accept = nil)\n super()\n @resource = resource\n @accept = accept\n\n generate_output\n end",
"def initialize(data)\n super\n pre_parse!\n end",
"def initialize()\n end",
"def initialize\n \n end",
"def initialize(base, name)\n @base = base\n @name = name\n \n self.data = {}\n \n self.process(name)\n self.read_yaml(base, name)\n end",
"def initialize(base, name)\n @base = base\n @name = name\n \n self.data = {}\n \n self.process(name)\n self.read_yaml(base, name)\n end",
"def initialize( args={} )\n\n # Create from another instance. Used for transmuting class.\n if args[:resource]\n other = args[:resource]\n @project = other.project\n @type = other.type\n @id = other.id\n @content = other.content(:load => false)\n @yaml = other.yaml_content(:load => false)\n\n # Create from a project and id\n else\n @project = args[:project]\n @type = args[:type]\n @id = args[:id]\n if SUFFIX_REGEXP =~ @id\n suffix = $2\n @id = $1 + suffix\n @type = TYPE_SUFFIXES.invert[suffix]\n end\n @content = nil\n @yaml = nil\n end\n\n if @project.nil? or @id.nil?\n raise ArgumentError, \"Insufficient resource args: #{args.inspect}\"\n end\n end",
"def initialize(data)\n self.class.get(data)\n end",
"def initialize(resource, embed_config={}, options={})\n raise NotImplementedError\n end",
"def initialize(payload); end",
"def initialize(content); end",
"def initialize(content); end",
"def init\n raise NotImplementedError\n end",
"def initialize(data)\n super\n end",
"def initialize(data)\n super\n end",
"def new_from_resource(rsrc); self.class.new_from_resource(rsrc) end",
"def initialize(options={})\n @description = options.fetch(:description)\n parser = options[:parser] || JSON\n @resource_metadata_factory = options[:resource_metadata_factory] || ResourceMetadata\n @resources = create_resource_descriptions(parser.parse(@description, symbolize_names: true))\n end",
"def initialize\n end",
"def initialize data\n self.data = data\n parse_data\n end",
"def initialize(uri, factory, parent = nil, json: nil, ld: nil)\n super(uri, factory, parent, json: json, ld: ld)\n section_ld = ld[uri]\n self.description = self.get_property('http://purl.org/vocab/resourcelist/schema#description', section_ld)\n self.name = self.get_property('http://rdfs.org/sioc/spec/name', section_ld)\n end",
"def initialize\n init\n end",
"def initialize (template); @template = template; end",
"def initialize()\n @template = \"call load_file() or load_url() to load a template\"\n @loadOK = false \n end",
"def initialize()\n # override parent\n end",
"def initialize(file_format)\n @lines = []\n @attributes = {}\n register_file_format(file_format)\n end",
"def initialize(type_name, data_type, attribute_name, resource_hash, _referrable_type = nil)\n @type_name = type_name\n @data_type = data_type\n @attribute_name = attribute_name\n super(**resource_hash) # Pass resource to parent Puppet class.\n end",
"def initialize(data)\n\t\t@data = data\n\tend",
"def initialize\r\n\r\n end",
"def initialize(initial_hash = nil)\n super\n @optional_method_names = %i[dynamicRegistration contentFormat]\n end",
"def initialize\n initialize!\n end",
"def initialize\n initialize!\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 @data = data\n end",
"def initialize\n\t\t\n\tend",
"def initialize(user, data)\n\t\t\tsuper(user)\n\t\t\tinit(data)\n\t\tend",
"def initialize\n\n\n\n end",
"def initialize(data)\n @data = data\n end",
"def initialize(data)\n @data = data\n end",
"def initialize(data)\n @data = data\n end",
"def initialize(data)\n @data = data\n end",
"def initialize(data)\n @data = data\n end",
"def initialize(data)\n @data = data\n end",
"def initialize(data)\n @data = data\n end",
"def initialize(*) end",
"def initialize(*) end",
"def initialize(*) end",
"def initialize(*) end",
"def initialize(*) end",
"def initialize(resource = nil)\n @resource = resource\n @logger = @resource&.create_log # This is an ImportLog.\n end",
"def initialize(data) # will accept the attribute data. \r\n\r\n @data = data # store the attribute data, and allows it to be used each time. \r\n\r\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 build_resource(hash = {})\n self.resource = resource_class.new(hash)\n end",
"def initialize(resource = nil, version = nil, format = nil, options = {})\r\n @version, @format, @loaded, @private = version, format, {}, true\r\n @root = options.delete :root\r\n\r\n if self.class.model\r\n case resource\r\n when ActiveRecord::Base\r\n @resource = resource\r\n load! options[:include], :limit => options[:limit]\r\n when Hash, nil\r\n @resource = self.class.model.new\r\n self.attributes = resource\r\n end\r\n else\r\n @resource = resource\r\n end\r\n end",
"def initialize(attributes = {})\n\t\t\tload(attributes)\n\t\tend",
"def initialize\n # complete\n end",
"def initialize(attrs = {})\n load_attributes(attrs)\n load_properties(attrs)\n end",
"def initialize_data\n end",
"def initialize(resource)\n super(resource)\n if resource.uri.authority.to_s == \"\"\n raise ArgumentError,\n \"Resource cannot be handled by client: '#{resource.uri}'\"\n end\n @response = nil\n @remaining_body = StringIO.new\n end",
"def initialize(uri, factory, json: nil, ld: nil)\n super(uri, factory)\n if json\n self.active = get_property('active', json)\n self.end_date = get_date('endDate', json)\n self.start_date = get_date('startDate', json)\n self.title = get_property('title', json)\n else\n self.active = nil\n self.end_date = nil\n self.start_date = nil\n self.title = nil\n end\n end",
"def initialize(source); end",
"def initialize(input_data)\n @data = input_data\n end",
"def initialize(*args)\n old_initialize(*args)\n self.formatter = SimpleFormatter.new\n end",
"def construct\n end",
"def initialize(resource_hash)\n @target = resource_hash['target']\n @type = resource_hash['type'].to_s.capitalize\n @title = resource_hash['title']\n @state = resource_hash['state'] || {}\n @desired_state = resource_hash['desired_state'] || {}\n @events = resource_hash['events'] || []\n end",
"def initialize\n \n end",
"def initialize\n \n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end"
] | [
"0.65970284",
"0.64900386",
"0.6399915",
"0.63738805",
"0.6357284",
"0.6350854",
"0.6347237",
"0.6344723",
"0.63422",
"0.6325956",
"0.63258696",
"0.6325555",
"0.63118964",
"0.628525",
"0.6220928",
"0.6133075",
"0.6099715",
"0.60900176",
"0.60895646",
"0.6079195",
"0.6079195",
"0.60732764",
"0.6068961",
"0.60547686",
"0.60435545",
"0.60407335",
"0.60407335",
"0.60371476",
"0.6036181",
"0.6036181",
"0.6033404",
"0.60251933",
"0.6009532",
"0.6004233",
"0.5999633",
"0.59905475",
"0.598897",
"0.59888935",
"0.598588",
"0.5977773",
"0.59759045",
"0.5974503",
"0.5973159",
"0.5955199",
"0.59483016",
"0.59483016",
"0.5940212",
"0.5940212",
"0.5940212",
"0.5940212",
"0.5940212",
"0.5940212",
"0.5940212",
"0.5940212",
"0.5940212",
"0.5940212",
"0.5940212",
"0.59291685",
"0.5926367",
"0.58946186",
"0.58843476",
"0.5882644",
"0.5882644",
"0.5882644",
"0.5882644",
"0.5880725",
"0.5880725",
"0.5880725",
"0.5880011",
"0.5880011",
"0.5880011",
"0.5880011",
"0.5880011",
"0.5873941",
"0.5871047",
"0.5868365",
"0.5868365",
"0.5868365",
"0.5868365",
"0.5868365",
"0.5868365",
"0.5867587",
"0.5858255",
"0.58563465",
"0.5855994",
"0.58536416",
"0.58512104",
"0.5849079",
"0.5845303",
"0.58416164",
"0.5838451",
"0.5835292",
"0.583426",
"0.58301467",
"0.5829719",
"0.5829719",
"0.58278763",
"0.58278763",
"0.58278763",
"0.58278763"
] | 0.749517 | 0 |
create Executes the create method on the implementing resource with formatted data. | def create
data.is_a?(Array) ? create_by_array : create_by_hash(data)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(data)\n @create_resource_mixin.create(data)\n end",
"def create(*args)\n raise NotImplementedError, 'Implement a method to create the resource.'\n end",
"def create\n Puppet.debug( \"#{self.resource.type}: CREATE #{resource[:name]}\" ) \n end",
"def create\n # TODO: implement create\n end",
"def create\n event = Connection::Events::Create.from_jsonapi(params, self)\n result = event.handle\n render_resource_created_event result[:validation], result[:result]\n end",
"def create\n resource = model_class.new(permitted_resource_params)\n ensure_current_store(resource)\n\n if resource.save\n render_serialized_payload(201) { serialize_resource(resource) }\n else\n render_error_payload(resource.errors)\n end\n end",
"def create\n \n end",
"def create\n raise NotImplementedError\n end",
"def create\n raise NotImplementedError\n end",
"def create; end",
"def create; end",
"def create; end",
"def create; end",
"def create\r\n\r\n\r\n end",
"def create\n end",
"def create\n end",
"def create(resource, options = {}, format = nil)\n base_create(resource, options, format)\n end",
"def create(params={})\n raise '`create` method is not supported for this resource.'\n end",
"def create(params={})\n raise '`create` method is not supported for this resource.'\n end",
"def create(params={})\n raise '`create` method is not supported for this resource.'\n end",
"def create(params={})\n raise '`create` method is not supported for this resource.'\n end",
"def perform_create\n resource.save!\n end",
"def create\n \n end",
"def create\n \t\n end",
"def create(resource,identifier,json)\n raise 'Not Yet Implemented'\n end",
"def create\r\n end",
"def create_resource object\n object.save\n end",
"def create\n raise \"Not supported\"\n end",
"def create!\n raise NotImplementedError\n end",
"def create\n raise NotImplementedError\n end",
"def create\n\t\twrite('')\n\t\tself\n\tend",
"def create\n\t\twrite('')\n\t\tself\n\tend",
"def create\n add_breadcrumb I18n.t('integral.navigation.create')\n @resource = resource_klass.new(resource_params)\n\n yield if block_given?\n\n if @resource.save\n respond_successfully(notification_message('creation_success'), edit_backend_resource_url(@resource))\n else\n respond_failure(notification_message('creation_failure'), :new)\n end\n end",
"def create\n @resource = Resource.new(params[:resource])\n respond_to do |format|\n if @resource.save\n @resource.eval_description\n format.html { redirect_to @resource, notice: 'Resource was successfully created.' }\n format.json { render json: @resource, status: :created, location: @resource }\n else\n get_resource_types\n format.html { render action: :new }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n super\n end",
"def create\n super\n end",
"def create\n super\n end",
"def create\n super\n end",
"def create\n super\n end",
"def create\n super\n end",
"def create\n super\n end",
"def create\n super\n end",
"def create\n super\n end",
"def create(resources)\n raise NotImplementedError, \"#{self.class}#create not implemented\"\n end",
"def create!\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n validate_save_and_respond(change_set_class.new(resource_class.new), :new)\n end",
"def create_created\n controller.create_created(resource: resource)\n end",
"def base_create(resource, options, format = nil, additional_header = {})\n headers = {}\n headers[:accept] = \"#{format}\" if format\n format ||= @default_format\n headers = {content_type: \"#{format}\"}\n headers[:prefer] = @return_preference if @use_return_preference\n headers.merge!(additional_header)\n options = {} if options.nil?\n options[:resource] = resource.class\n options[:format] = format || @default_format\n reply = post resource_url(options), resource, fhir_headers(headers)\n if [200, 201].include? reply.code\n type = reply.response[:headers].detect{|x, _y| x.downcase=='content-type'}.try(:last)\n if !type.nil?\n reply.resource = if type.include?('xml') && !reply.body.empty?\n klass = self.versioned_resource_class(:Xml)\n klass.from_xml(reply.body)\n elsif type.include?('json') && !reply.body.empty?\n klass = self.versioned_resource_class(:Json)\n klass.from_json(reply.body)\n else\n resource # just send back the submitted resource\n end\n resource.id = FHIR::ResourceAddress.pull_out_id(resource.class.name.demodulize, reply.self_link)\n else\n resource.id = FHIR::ResourceAddress.pull_out_id(resource.class.name.demodulize, reply.self_link)\n reply.resource = resource # don't know the content type, so return the resource provided\n end\n else\n resource.id = FHIR::ResourceAddress.pull_out_id(resource.class.name.demodulize, reply.self_link)\n reply.resource = resource # just send back the submitted resource\n end\n set_client_on_resource(reply.resource)\n reply.resource_class = resource.class\n reply\n end",
"def create(context)\n context.request.body.rewind # in case someone already read it\n begin\n data = JSON.parse(context.request.body.read)\n rescue JSON::ParserError\n context.halt(406, { status: 'error', message: 'Not acceptable JSON payload' }.to_json)\n end\n\n permitted_params = resource_fields.map { |k| k[:name] }\n permitted_params = data.select { |k, _| permitted_params.include?(k) }\n\n begin\n instance_variable_set(:\"@#{resource_name}\", resource_name.classify.constantize.new(permitted_params))\n\n if instance_variable_get(:\"@#{resource_name}\").save\n instance_variable_get(:\"@#{resource_name}\").to_json\n else\n errors = instance_variable_get(:\"@#{resource_name}\").errors.map { |k, v| \"#{k}: #{v}\" }.join('; ')\n context.halt(406, { status: 'error', message: errors }.to_json)\n end\n rescue StandardError => e\n context.halt(500, { status: 'error', message: e.message }.to_json)\n end\n end",
"def create(resource_name)\n if ! advance? then return self end\n @@logger.debug \"Launching resource: #{resource_name}.\"\n resource = @resourcer.get resource_name\n deps = @resourcer.get_dep(resource_name)\n deps.each {|ref| create(ref)}\n created = @mutator.create(resource_name, resource)\n created.harp_script = @harp_script\n result = {:create => resource_name}\n args = {:action => :create}\n if created.output? (args)\n result[:output] = created.make_output_token(args)\n result[:line] = @current_line\n end\n @events.push(result)\n created.save\n return self\n end",
"def create(resource, format=@default_format)\n options = { resource: resource.class, format: format }\n reply = post resource_url(options), resource, fhir_headers(options)\n if [200,201].include? reply.code\n type = reply.response[:headers][:content_type]\n if !type.nil?\n if type.include?('xml') && !reply.body.empty?\n reply.resource = resource.class.from_xml(reply.body)\n elsif type.include?('json') && !reply.body.empty?\n reply.resource = resource.class.from_fhir_json(reply.body)\n else\n reply.resource = resource # just send back the submitted resource\n end\n else\n reply.resource = resource # don't know the content type, so return the resource provided\n end\n else\n reply.resource = resource # just send back the submitted resource\n end\n reply.resource_class = resource.class\n reply\n end",
"def create(attrs = {})\n super(attrs)\n end",
"def create\n raise NotImplemented\n end",
"def create_resource(object)\n object.save\n end",
"def create\n might_update_resource do\n provider.create\n end\n end",
"def create\n might_update_resource do\n provider.create\n end\n end",
"def create\n might_update_resource do\n provider.create\n end\n end",
"def create\n might_update_resource do\n provider.create\n end\n end",
"def create\n make_create_request\n end",
"def create(param)\n\t\traise NotImplementedError\n\tend",
"def create \n end",
"def create \n end",
"def instantiate\n resource.new(data)\n end",
"def create\n\t\tsuper\n\tend",
"def create(data={})\n object = self.new(data)\n object.save\n end",
"def create(data) # rubocop:disable Rails/Delegate\n client.create(data)\n end",
"def create(repository, resource)\n raise NotImplementedError\n end",
"def create\n add_breadcrumb I18n.t('integral.navigation.create'), \"new_backend_#{controller_name.singularize}_path\".to_sym\n @resource = resource_klass.new(resource_params)\n\n yield if block_given?\n\n if @resource.save\n respond_successfully(notification_message('creation_success'), send(\"edit_backend_#{controller_name.singularize}_path\", @resource.id))\n else\n respond_failure(notification_message('creation_failure'), :new)\n end\n end",
"def create\n create_entry\n end",
"def run\n @loader.retrieve_and_store\n resource = @loader.resource\n\n output = []\n if resource.valid?\n output << \"Created #{resource.name}\"\n else\n output << \"Couldn't create #{resource.name} for the following reasons:\"\n resource.errors.full_messages.each do |error|\n output << \" * #{error}\"\n end\n end\n output.join(\"\\n\")\n end",
"def create(attrs)\n super(attrs)\n end",
"def create(attrs)\n super(attrs)\n end",
"def create(attrs)\n super(attrs)\n end",
"def create(attrs)\n super(attrs)\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end"
] | [
"0.75633824",
"0.7417757",
"0.71390915",
"0.71153146",
"0.71123016",
"0.70413476",
"0.7010462",
"0.69727874",
"0.69727874",
"0.69426554",
"0.69426554",
"0.69426554",
"0.69426554",
"0.6935337",
"0.687718",
"0.686045",
"0.6859226",
"0.6855752",
"0.6855752",
"0.6855752",
"0.6855752",
"0.6847552",
"0.68439144",
"0.68218386",
"0.6776509",
"0.67375374",
"0.6732028",
"0.67308325",
"0.669672",
"0.6672636",
"0.6669572",
"0.6669572",
"0.66690844",
"0.66379195",
"0.66211283",
"0.66211283",
"0.66211283",
"0.66211283",
"0.66211283",
"0.66211283",
"0.66211283",
"0.66211283",
"0.66211283",
"0.6612372",
"0.66109145",
"0.6605712",
"0.6605712",
"0.6605712",
"0.6591844",
"0.65864533",
"0.65706396",
"0.65522456",
"0.6514447",
"0.651091",
"0.64703816",
"0.64591974",
"0.6453554",
"0.6432163",
"0.6432163",
"0.6432163",
"0.6432163",
"0.64211655",
"0.6417662",
"0.6401871",
"0.6401871",
"0.63704944",
"0.63633275",
"0.63631374",
"0.6346721",
"0.63373834",
"0.63312495",
"0.63307923",
"0.63185304",
"0.6317987",
"0.6317987",
"0.6317987",
"0.6317987",
"0.6314834",
"0.6314834",
"0.6314834",
"0.6314834",
"0.6314834",
"0.6314834",
"0.6314834",
"0.6314834",
"0.6314834",
"0.6314834",
"0.6314834",
"0.6314834",
"0.6314834",
"0.6314834",
"0.6314834",
"0.6314834",
"0.6314834",
"0.6314834",
"0.6314834",
"0.6314834",
"0.6314834",
"0.6314834",
"0.6314834",
"0.6314834"
] | 0.0 | -1 |
update Assigns the formatted data to the resource and saves. | def update
record.assign_attributes(data)
record.save! if record.changed?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(...)\n assign_attributes(...)\n save\n end",
"def update!(**args)\n @formatted = args[:formatted] if args.key?(:formatted)\n @unformatted = args[:unformatted] if args.key?(:unformatted)\n end",
"def update\n\t\t\n\t\tend",
"def update\r\n end",
"def update!\n self.save\n end",
"def update\n \n end",
"def update!(**args)\n @expected_format = args[:expected_format] if args.key?(:expected_format)\n @new_format = args[:new_format] if args.key?(:new_format)\n @sampled_data_locations = args[:sampled_data_locations] if args.key?(:sampled_data_locations)\n end",
"def update\r\n\r\n end",
"def update\n\n end",
"def update\n end",
"def update_resource object, attributes\n object.update attributes\n end",
"def update!(**args)\n @format = args[:format] if args.key?(:format)\n @raw_value = args[:raw_value] if args.key?(:raw_value)\n @value_format = args[:value_format] if args.key?(:value_format)\n end",
"def update\n\n end",
"def update\n \n end",
"def update\n\t\tend",
"def update\n\t\tend",
"def update\n @resources_data = ResourcesData.find(params[:id])\n\n respond_to do |format|\n if @resources_data.update_attributes(params[:resources_data])\n format.html { redirect_to(@resources_data, :notice => 'ResourcesData was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @resources_data.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @resource.update_attributes(params[:resource])\n @resource.eval_description\n format.html { redirect_to @resource, notice: 'Resource was successfully updated.' }\n format.json { head :no_content }\n else\n get_resource_types\n format.html { render action: :edit }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n upsert do\n # NOTE:\n # 1. update ++then++ valid to set new values in @record to draw form.\n # 1. user_scoped may have joins so that record could be\n # ActiveRecord::ReadOnlyRecord so that's why access again from\n # model.\n @record = model.find(user_scoped.find(params[:id]).id)\n #upsert_files\n if [email protected]_attributes(permitted_params(:update))\n raise ActiveRecord::RecordInvalid.new(@record)\n end\n end\n end",
"def update\r\n end",
"def update\r\n end",
"def update\r\n end",
"def update\r\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n # TODO: implement update\n end",
"def update!(**args)\n @error = args[:error] if args.key?(:error)\n @resource = args[:resource] if args.key?(:resource)\n end",
"def update\n\t\t# Left empty intentionally.\n\tend",
"def update(model_data)\n end",
"def update \n end",
"def update(resource, id, format = nil)\n base_update(resource, id, nil, format)\n end",
"def update_row_resource(resource, params)\n resource.attributes = params\n resource.save\n end",
"def update\n \n end",
"def update\n \n end",
"def update\n \n end",
"def update\n \n end",
"def update\n \n end",
"def update\n \n end",
"def update\n \n end",
"def update\n \n end",
"def update\n \n end",
"def update\n \n end",
"def update!(**args)\n @data_range = args[:data_range] if args.key?(:data_range)\n @format = args[:format] if args.key?(:format)\n @send_notification = args[:send_notification] if args.key?(:send_notification)\n @share_email_address = args[:share_email_address] if args.key?(:share_email_address)\n @title = args[:title] if args.key?(:title)\n end",
"def resource_update\n @new_name = @data.delete('new_name')\n @item = @resource_type.new(@client, @data)\n return false unless @item.retrieve!\n parse_new_name\n if @item.like?(@data)\n Puppet.notice \"#{@resource_type} #{@data['name']} is up to date.\"\n else\n Puppet.notice \"#{@resource_type} #{@data['name']} differs from resource in appliance.\"\n Puppet.debug \"Current attributes: #{JSON.pretty_generate(@item.data)}\"\n Puppet.debug \"Desired attributes: #{JSON.pretty_generate(@data)}\"\n @item.update(@data)\n @property_hash[:data] = @item.data\n end\n true\nend",
"def update\n respond_to do |format|\n if @resource.update(resource_params)\n @resource.saved_by(current_admin)\n format.html { redirect_to @resource, notice: 'Resource was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @format = args[:format] if args.key?(:format)\n @location = args[:location] if args.key?(:location)\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end"
] | [
"0.67310303",
"0.66759753",
"0.63827705",
"0.63112944",
"0.6310254",
"0.62747437",
"0.6273716",
"0.62702876",
"0.62598974",
"0.62514555",
"0.6243642",
"0.62237924",
"0.6221281",
"0.62209654",
"0.62141544",
"0.62141544",
"0.61882365",
"0.61814874",
"0.6170586",
"0.616605",
"0.616605",
"0.616605",
"0.616605",
"0.61608833",
"0.61608833",
"0.61608833",
"0.61608833",
"0.61608833",
"0.61608833",
"0.61608833",
"0.61608833",
"0.61608833",
"0.61608833",
"0.61608833",
"0.6157457",
"0.6157457",
"0.6157457",
"0.6157457",
"0.6157457",
"0.6157457",
"0.6157457",
"0.6157457",
"0.6157457",
"0.6157457",
"0.6157457",
"0.6157457",
"0.6157457",
"0.6157457",
"0.6157457",
"0.6157457",
"0.6157457",
"0.6157457",
"0.6157457",
"0.6157457",
"0.6157457",
"0.6157457",
"0.6157457",
"0.6157457",
"0.6157457",
"0.6157457",
"0.6157457",
"0.6157457",
"0.6157457",
"0.6157457",
"0.6157457",
"0.6157457",
"0.6157457",
"0.6157457",
"0.6155093",
"0.61503047",
"0.61462855",
"0.614091",
"0.6132764",
"0.61320055",
"0.6113086",
"0.61117184",
"0.61117184",
"0.61117184",
"0.61117184",
"0.61117184",
"0.61117184",
"0.61117184",
"0.61117184",
"0.61117184",
"0.61117184",
"0.6099223",
"0.60966635",
"0.6093125",
"0.6085462",
"0.60834444",
"0.60834444",
"0.60834444",
"0.60834444",
"0.60834444",
"0.60834444",
"0.60834444",
"0.60834444",
"0.60834444",
"0.60834444",
"0.60834444"
] | 0.7098775 | 0 |
copy text between cursor and mark to clipboard | def copyregion(killafter = false, killadd = false)
return unless @mark
sel = [@cursor, @mark].sort
JTClipboard.addclip @text[sel.first...sel.last], killadd
if killafter
@text[sel.first...sel.last] = ""
@cursor = @mark if @cursor > @mark
end
resetmark
notify; @last = :copyregion
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_clipboard_cut\n if do_clipboard_copy()\n pos = @selection.first\n self.gui_set_value(nil, '')\n self.cur_pos = pos\n end\n end",
"def copy_to_clipboard\n end",
"def paste; clipboard_paste; end",
"def do_copy\n @editor.value = @current_copycode\n @editor.focus\n end",
"def do_clipboard_paste\n dat = if Wx::PLATFORM == \"WXMAC\" \n # XXX i feel dirty\n `pbpaste`\n else\n dobj=RawDataObject.new\n Wx::Clipboard.open {|clip| clip.fetch dobj}\n dobj.raw_data\n end\n\n self.gui_set_value(self.cur_pos, dat) if dat and dat.size > 0\n end",
"def paste_before()\n clipboard = send_message(\"getClipboardContents\" => [])[\"clipboardContents\"]\n if clipboard[-1].chr == \"\\n\"\n [\"moveToBeginningOfLine:\", \"paste\"] + restore_cursor_position + [\"moveToBeginningOfLine:\"] +\n (is_whitespace?(clipboard[0].chr) ? [\"moveWordForward:\"] : [])\n else\n [\"paste\", \"moveForward:\"]\n end\n end",
"def copyFromClipboard \n \"copyFromClipboard\" \n end",
"def push_text_in_clipboard(text)\n OpenClipboard.call(0)\n EmptyClipboard.call()\n hmem = GlobalAlloc.call(0x42, text.length)\n mem = GlobalLock.call(hmem)\n Memcpy.call(mem, text, text.length)\n SetClipboardData.call(1, hmem) # Format CF_TEXT = 1\n GlobalFree.call(hmem)\n CloseClipboard.call()\n self\n end",
"def pbcopy(text)\n # work around, ' wrecks havoc on command line, but also caused some weird regexp substitution\n rtf = text.index('{\\rtf1')\n File.open(\"/tmp/script.scpt\", 'w') do |f|\n if rtf\n f << text\n else\n f << \"set the clipboard to \\\"#{text}\\\"\"\n end\n end\n if rtf\n `cat /tmp/script.scpt | pbcopy -Prefer rtf`\n else\n `osascript /tmp/script.scpt`\n end\nend",
"def pbpaste\n Clipboard.paste\nend",
"def show\n @clipboard = find_clipboard\n end",
"def do_clipboard_copy\n return nil unless sel=@selection and dat=@data[sel]\n # XXX i feel dirty\n if Wx::PLATFORM == \"WXMAC\"\n IO.popen(\"pbcopy\", \"w\") {|io| io.write dat}\n stat = $?.success?\n else\n dobj = RawDataObject.new(dat)\n stat = Wx::Clipboard.open {|clip| clip.place dobj}\n end\n return stat\n end",
"def copy\n out = ''\n\n Selection.each do |dd|\n docu = dd.cite_key.get\n docu.strip!\n out << \"[@#{docu}] \"\n end\n\n pbcopy(out.strip)\n growl(\"#{Selection.size} citation references copied to the clipboard\")\nend",
"def clipboard\n IO.popen('pbcopy', 'w') {|f| f << selected_items.map(&:path).join(' ')} if osx?\n end",
"def pbpaste\n a = IO.popen(\"osascript -e 'the clipboard as unicode text' | tr '\\r' '\\n'\", 'r+').read\n a.strip.force_encoding(\"UTF-8\")\nend",
"def textcopy(input)\n\tosascript <<-END\n\t\ttell application \"Copied\"\n\t\t\tsave \"#{input}\"\n\t\tend tell\n\tEND\nend",
"def cp(string)\n `echo \"#{string} | pbcopy`\n puts 'copied to clipboard'\nend",
"def paste(at: caret)\n editable? and @native.paste_text(at.to_i)\n end",
"def copy_bbcode\n str = EventPrinter::BBcode::head(@event.printed_name)\n str << (@list.map { |e| e.bbcode }).join(\"\\n\")\n str << EventPrinter::BBcode::foot\n Win32API.push_text_in_clipboard(str.to_ascii << \"\\0\")\n end",
"def get_clipboard_contents\n out = \"\"\n\n Open3.popen3(\"xclip -o -selection clipboard\") do |_, o, _, _|\n out = o.read.strip\n end\n\n out\n end",
"def move_caret_to_mouse\n # Test character by character\n 1.upto(self.text.length) do |i|\n if @window.mouse_x < x + FONT.text_width(text[0...i])\n self.caret_pos = self.selection_start = i - 1;\n return\n end\n end\n # Default case: user must have clicked the right edge\n self.caret_pos = self.selection_start = self.text.length\n end",
"def cmd_clip reference, description = 'TODO description'\n path = reference2path reference\n unless create_if_not_exist reference, path\n return\n end\n puts \"adding clipboard content to \" + reference\n open_vim path, :end_of_file, \n :add_line, \n :add_line, \n :append_desc, description, :add_line,\n :append_date, \n :add_line, \n :add_line, \n :inject_clipboard\n\n end",
"def copyToClipboard _args\n \"copyToClipboard _args;\" \n end",
"def copy(str = nil)\n clipboard_copy(:string => (!$stdin.tty? ? $stdin.read : str))\n end",
"def copy_word_backward()\n [\"moveWordBackwardAndModifySelection:\"] * @number_prefix + [\"copySelection\"] + restore_cursor_position() +\n [\"moveWordBackward:\"]\n end",
"def copy(content)\n cmd = case true\n when system(\"type pbcopy > /dev/null 2>&1\")\n :pbcopy\n when system(\"type xclip > /dev/null 2>&1\")\n :xclip\n when system(\"type putclip > /dev/null 2>&1\")\n :putclip\n end\n\n if cmd\n IO.popen(cmd.to_s, 'r+') { |clip| clip.print content }\n end\n\n content\n end",
"def copy(content)\n cmd = case true\n when system(\"type pbcopy > /dev/null 2>&1\")\n :pbcopy\n when system(\"type xclip > /dev/null 2>&1\")\n :xclip\n when system(\"type putclip > /dev/null 2>&1\")\n :putclip\n end\n\n if cmd\n IO.popen(cmd.to_s, 'r+') { |clip| clip.print content }\n end\n\n content\n end",
"def copy(item)\n copy_command = darwin? ? \"pbcopy\" : \"xclip -selection clipboard\"\n\n Kernel.system(\"echo '#{item.value.gsub(\"\\'\",\"\\\\'\")}' | tr -d \\\"\\n\\\" | #{copy_command}\")\n\n \"Boom! We just copied #{item.value} to your clipboard.\"\n end",
"def cop\n last_value = IRB.CurrentContext.last_value\n %x[echo '#{last_value}' | pbcopy]\n \"copied \\`#{last_value}' to your clipboard\"\nend",
"def cop\n last_value = IRB.CurrentContext.last_value\n %x[echo '#{last_value}' | pbcopy]\n \"copied \\`#{last_value}' to your clipboard\"\nend",
"def to_clipboard\n #prettified = self.pretty_inspect.strip\n prettified = self.to_s\n stringified = self.to_s\n printable = (\n if prettified.length > 80 then\n prettified.slice(0, 80) + '...'\n else\n prettified\n end\n ).inspect\n $clipboard.write(stringified)\n $stderr.puts(\"to_clipboard: wrote #{printable} to clipboard\")\n return nil\n end",
"def paste(text)\n can_refresh = false\n # Attempt to insert every character individually\n text.split(\"\").each do |ch|\n break unless @helper.insert(ch)\n can_refresh = true\n end\n # Only refresh if characters were inserted\n self.refresh if can_refresh\n end",
"def paste( text, typing = ! TYPING, do_parsed_indent = false )\n return if text.nil?\n\n if not text.kind_of? Array\n s = text.to_s\n if s.include?( \"\\n\" )\n text = s.split( \"\\n\", -1 )\n else\n text = [ s ]\n end\n end\n\n take_snapshot typing\n\n delete_selection DONT_DISPLAY\n\n row = @last_row\n col = @last_col\n new_col = nil\n line = @lines[ row ]\n if text.length == 1\n @lines[ row ] = line[ 0...col ] + text[ 0 ] + line[ col..-1 ]\n if do_parsed_indent\n parsed_indent row: row, do_display: false\n end\n cursor_to( @last_row, @last_col + text[ 0 ].length, DONT_DISPLAY, ! typing )\n elsif text.length > 1\n\n case @selection_mode\n when :normal\n @lines[ row ] = line[ 0...col ] + text[ 0 ]\n @lines[ row + 1, 0 ] = text[ -1 ] + line[ col..-1 ]\n @lines[ row + 1, 0 ] = text[ 1..-2 ]\n new_col = column_of( text[ -1 ].length )\n when :block\n @lines += [ '' ] * [ 0, ( row + text.length - @lines.length ) ].max\n @lines[ row...( row + text.length ) ] = @lines[ row...( row + text.length ) ].collect.with_index { |line,index|\n pre = line[ 0...col ].ljust( col )\n post = line[ col..-1 ]\n \"#{pre}#{text[ index ]}#{post}\"\n }\n new_col = col + text[ -1 ].length\n end\n\n new_row = @last_row + text.length - 1\n if do_parsed_indent\n ( row..new_row ).each do |r|\n parsed_indent row: r, do_display: false\n end\n end\n cursor_to( new_row, new_col )\n\n end\n\n set_modified\n end",
"def copy(segment=selection)\n\t\t\t$ruvim.buffers[:copy].data.replace segment\n\t\tend",
"def pbcopy(str)\n IO.popen('pbcopy', 'r+') {|io| io.puts str }\n output.puts \"-- Copy to clipboard --\\n#{str}\"\nend",
"def notifyClipboardContentChanged\n updateCommand(Wx::ID_PASTE) do |ioCommand|\n if (@Clipboard_CopyMode == nil)\n # The clipboard has nothing interesting for us\n # Deactivate the Paste command\n ioCommand[:Enabled] = false\n ioCommand[:Title] = 'Paste'\n # Cancel eventual Copy/Cut pending commands\n notifyCancelCopy\n # Notify everybody\n notifyRegisteredGUIs(:onClipboardContentChanged)\n elsif (@Clipboard_CopyMode == Wx::ID_DELETE)\n # Check that this message is adressed to us for real (if many instances of PBS are running, it is possible that some other instance was cutting things)\n if (@CopiedID == @Clipboard_CopyID)\n # Here we have to take some action:\n # Delete the objects marked as being 'Cut', as we got the acknowledge of pasting it somewhere.\n if (@CopiedMode == Wx::ID_CUT)\n if (!@Clipboard_AlreadyProcessingDelete)\n # Ensure that the loop will not come here again for this item.\n @Clipboard_AlreadyProcessingDelete = true\n executeCommand(Wx::ID_DELETE, {\n :parentWindow => nil,\n :selection => @CopiedSelection,\n :deleteTaggedShortcuts => false,\n :deleteOrphanShortcuts => false\n })\n # Then empty the clipboard.\n Wx::Clipboard.open do |ioClipboard|\n ioClipboard.clear\n end\n # Cancel the Cut pending commands.\n notifyCutPerformed\n notifyRegisteredGUIs(:onClipboardContentChanged)\n @Clipboard_AlreadyProcessingDelete = false\n end\n else\n log_bug 'We have been notified of a clipboard Cut acknowledgement, but no item was marked as to be Cut.'\n end\n end\n # Deactivate the Paste command\n ioCommand[:Enabled] = false\n ioCommand[:Title] = 'Paste'\n else\n lCopyName = nil\n case @Clipboard_CopyMode\n when Wx::ID_CUT\n lCopyName = 'Move'\n when Wx::ID_COPY\n lCopyName = 'Copy'\n else\n log_bug \"Unsupported copy mode from the clipboard: #{@Clipboard_CopyMode}.\"\n end\n if (@Clipboard_CopyID != @CopiedID)\n # Here, we have another application of PBS that has put data in the clipboard. It is not us anymore.\n notifyCancelCopy\n end\n if (lCopyName != nil)\n # Activate the Paste command with a cool title\n ioCommand[:Enabled] = true\n ioCommand[:Title] = \"Paste #{@Clipboard_SerializedSelection.getDescription} (#{lCopyName})\"\n else\n # Deactivate the Paste command, and explain why\n ioCommand[:Enabled] = false\n ioCommand[:Title] = \"Paste (invalid type #{@Clipboard_CopyMode}) - Bug ?\"\n end\n notifyRegisteredGUIs(:onClipboardContentChanged)\n end\n end\n end",
"def paste\n\t\t\t$ruvim.insert $ruvim.buffers[:copy].data\n\t\t\t$ruvim.editor.redraw\n\t\tend",
"def getSelectedData; @text_editor.selected_text; end",
"def move_caret(mouse_x)\n 1.upto(text.length) do |i|\n if mouse_x < x + @font.text_width(text[0...i])\n self.caret_pos = self.selection_start = i - 1\n return\n end\n end\n self.caret_pos = self.selection_start = text.length\n end",
"def get_selection\n return `xclip -o` if RUBY_PLATFORM =~ /linux/\n return `pbpaste` if RUBY_PLATFORM =~ /darwin/\nend",
"def paste link\n clipboard = %w{\n /usr/bin/pbcopy\n /usr/bin/xclip\n }.find { |path| File.exist? path }\n\n if clipboard\n IO.popen clipboard, 'w' do |io| io.write link end\n end\n end",
"def pbcopy(str)\n IO.popen('pbcopy', 'r+') {|io| io.puts str }\n puts \"-- Copy to clipboard --\\n#{str}\"\nend",
"def copy(content)\n case RUBY_PLATFORM\n when /darwin/\n return content if `which pbcopy`.strip == ''\n IO.popen('pbcopy', 'r+') { |clip| clip.print content }\n when /linux/\n return content if `which xclip 2> /dev/null`.strip == ''\n IO.popen('xclip', 'r+') { |clip| clip.print content }\n when /i386-cygwin/\n return content if `which putclip`.strip == ''\n IO.popen('putclip', 'r+') { |clip| clip.print content }\n end\n\n content\n end",
"def insert_selection\n insert(cursor, Tk::Selection.get(type: 'UTF8_STRING'))\n end",
"def move_caret(mouse_x)\n # Test character by character\n 1.upto(self.text.height) do |i|\n if mouse_x < x + @font.text_width(text[0...i]) then\n self.caret_pos = self.selection_start = i - 1;\n return\n end\n end\n # Default case: user must have clicked the right edge\n # self.caret_pos = self.selection_start = self.text.height\n end",
"def copy\n\n # FIXME: #copy, #cut and #paste really shouldn't use platform-\n # dependent keypresses like this. But until DSK-327491 is fixed,\n # this will have to do.\n if OperaWatir::Platform.os == :macosx\n keys.send [:command, 'c']\n else\n keys.send [:control, 'c']\n end\n end",
"def catch_text\n # get the actual offset\n start = @buffer.get_iter_at_offset(@@offset)\n\n # get the command\n cmd = @buffer.get_text(start, @buffer.end_iter)\n\n # Save the command to the history object\n @historic.append(cmd)\n\n # Write the command to our pipe\n send_cmd(cmd)\n\n # Add a return line to our buffer\n insert_text(\"\\n\")\n\n # Call the prompt\n prompt()\n\n # Create the mark tag if not exist\n if (not @buffer.get_mark('end_mark'))\n @buffer.create_mark('end_mark', @buffer.end_iter, false)\n end\n\n # Save our offset\n @@offset = @buffer.end_iter.offset\n end",
"def paste\n `pbpaste`\n end",
"def copy(text)\n IO.popen('pbcopy', 'w') {|f| f << text}\nend",
"def move_caret(mouse_x)\n # Test character by character\n 1.upto(self.text.length) do |i|\n if mouse_x < x + @font.text_width(text[0...i]) then\n self.caret_pos = self.selection_start = i - 1;\n return\n end\n end\n # Default case: user must have clicked the right edge\n self.caret_pos = self.selection_start = self.text.length\n end",
"def move_caret(mouse_x)\n len = text.length\n # Default case: user must have clicked the right edge\n self.caret_pos = self.selection_start = len\n\n # Test character by character\n 1.upto(len) do |index|\n next unless mouse_x < @point.x + @font.text_width(text[0...index])\n\n self.caret_pos = self.selection_start = index - 1\n break\n end\n end",
"def paste(str)\n send_command_to_control(\"EditPaste\", str)\n end",
"def copy(*args) IO.popen('pbcopy', 'r+') { |clipboard| clipboard.puts args.map(&:inspect) }; end",
"def copy(group, snippet = nil)\n content = Accio::Parser.read\n matches = content.search(group, snippet)\n matches.each do |match|\n match.snippets.each do |submatch|\n # Copy code to clipboard.\n Clipboard.copy submatch.code.text.gsub(/^$\\n/, '')\n\n # Format the output and display it.\n Accio::Formatter.template(\n match.title, submatch.title, submatch.comment, submatch.code\n )\n end\n end\n puts \"The last found code snippet has been copied to the clipboard\"\n end",
"def render_copy(code_str, display_str = nil)\n display_str = code_str if !display_str \n stack :margin_bottom => 12 do \n background rgb(210, 210, 210), :curve => 4\n para display_str, {:size => 9, :margin => 12, :font => 'monospace'}\n stack :top => 0, :right => 2, :width => 70 do\n background \"#8A7\", :margin => [0, 2, 0, 2], :curve => 4 \n para link(\"Copy this\", :stroke => \"#eee\", :underline => \"none\") { self.clipboard = code_str },\n :margin => 4, :align => 'center', :weight => 'bold', :size => 9\n end\n end\n end",
"def keyPressEvent(ev)\n if ev.matches(Qt::KeySequence::Copy)\n Qt::Application.clipboard.text = text_cursor.selected_text\n return\n end\n\n if is_read_only\n ev.ignore\n return\n end\n\n if ev.matches(Qt::KeySequence::Paste) && can_write?\n text_cursor.insert_text Qt::Application.clipboard.text\n highlight\n return\n end\n\n cursor = text_cursor\n txt = ev.text\n\n if cursor.position >= @min_position &&\n !txt.empty? &&\n !txt.between?(\"\\C-a\", \"\\C-z\")\n cursor.clear_selection\n cursor.insert_text txt\n highlight\n else\n ev.ignore\n end\n\n if completing? && @input.completion_proc\n if completion_pos == @completion_pos\n update_completion_prefix\n else\n @completer.popup.hide\n end\n end\n end",
"def copy(sender)\n filteredData[tableView.selectedRow].symbol.sendToPasteboard\n end",
"def paste\n `pbpaste`\nend",
"def insert_text_at_cursor(text) \n\t\tinsert_text(@cursor_row, @cursor_col, text)\n\t\n\t\tif text.include?(\"\\n\")\n\t\t\t#todo what about multiple \\n's\n\t\t\t@cursor_row += 1\n\t\t\t@cursor_col = 0\n\t\t\t#resize_contents(500, line_num_to_coord(@text.num_lines + 1))\n\t\t\temit_changed(@cursor_row - 1)\n\t\telse\n\t\t\t@cursor_col += text.length\n\t\t\temit_changed(@cursor_row)\n\t\tend\n\tend",
"def insert_text(text)\n # Create the mark tag if not exist\n @buffer.insert(@buffer.end_iter, text)\n if (not @buffer.get_mark('end_mark'))\n @buffer.create_mark('end_mark', @buffer.end_iter, false)\n end\n\n # Save our offset\n @@offset = @buffer.end_iter.offset\n\n # Scrolled the view until the end of the buffer\n @textview.scroll_mark_onscreen(@buffer.get_mark('end_mark'))\n end",
"def copy_backward()\n [\"moveBackwardAndModifySelection:\"] * @number_prefix + [\"copySelection\", \"moveForward:\", \"moveBackward:\"]\n end",
"def copy_text_content_from(brand)\n if !brand.nil?\n brand.text_contents.each do |text|\n tc = text.clone\n tc.brand_id = self.id\n tc.save\n end\n end\n end",
"def do_clip(pagename, titletxt, onlytext = false)\n pagepath = (\"#{Wiki_path}/data/pages/#{clean_pagename(pagename)}.txt\").gsub(\":\",\"/\")\n\n curpage = cururl.split(\"/\").last\n sel = has_selection\n\n # format properly if citation\n unless onlytext\n if curpage.index(\"ref:\")\n curpage = \"[@#{curpage.split(':').last.downcase}]\"\n elsif cururl.index(\"localhost/wiki\")\n curpage = \"[[:#{capitalize_word(curpage.gsub(\"_\", \" \"))}]]\"\n else\n title = (titletxt ? titletxt : curtitle)\n curpage =\"[[#{cururl}|#{title}]]\"\n end\n else\n curpage = ''\n end\n\n insert = (sel ? \"#{sel} \" : \" * \" ) # any text, or just a link (bullet list)\n insert.gsubs!( {:all_with=> \"\\n\\n\"}, \"\\n\", \"\\n\\n\\n\" )\n\n if File.exists?(pagepath)\n prevcont = File.read(pagepath)\n\n haslinks = prevcont.match(/\\-\\-\\-(\\n \\*[^\\n]+?)+?\\Z/m) # a \"---\"\" followed by only lines starting with \" * \"\n\n # bullet lists need an extra blank line after them before the \"----\"\n if sel\n divider = (haslinks ? \"\\n\\n----\\n\" : \"\\n----\\n\")\n else\n divider = (haslinks ? \"\\n\" : \"\\n----\\n\")\n end\n\n growltext = \"Selected text added to #{pagename}\"\n else\n prevcont = \"h1. #{capitalize_word(pagename)}\\n\\n\"\n growltext = \"Selected text added to newly created #{pagename}\"\n end\n filetext = [prevcont, divider, insert, curpage].join\n dwpage(pagename, filetext)\n\n growl(\"Text added\", growltext)\nend",
"def clip_again\n a = File.read(\"/tmp/dokuwiki-clip.tmp\")\n page, url, title, onlytext_s = a.split(\"\\n\")\n onlytext = (onlytext_s == 'true' && has_selection)\n\n title = curtitle if (title.strip == \"\") || (url != cururl)\n\n do_clip(page, title, onlytext)\nend",
"def move_caret(mouse_x)\n # Test character by character\n 1.upto(self.text.length) do |i|\n if mouse_x < x + @font.text_width(text[0...i]) then\n self.caret_pos = self.selection_start = i - 1;\n return\n end\n end\n \n # Default case: user must have clicked the right edge\n self.caret_pos = self.selection_start = self.text.length\n end",
"def selection\n [@fields.currentText, @entry.text.force_encoding('utf-8')]\n end",
"def go_caret_word(newtab=false)\n go_word('insert', newtab)\n end",
"def copy_input\n copy session_history\n \"The session input history has been copied to the clipboard.\"\n end",
"def copy_input\n copy session_history\n \"The session input history has been copied to the clipboard.\"\n end",
"def copy_input\n copy session_history\n \"The session input history has been copied to the clipboard.\"\n end",
"def select_word\n buffer_current.select_word\n end",
"def copy_raw\n Win32API.push_text_in_clipboard(((@list.map {|e| e.raw}).join(\"\\n\") + \"\\0\").to_ascii)\n end",
"def load_text(text)\n text = text.dup\n text.sub!(CTRL_V) { Yuki.get_clipboard }\n text.split(//).each do |char|\n if char == BACK\n last_char = @current_text[-1]\n @current_text.chop!\n @on_remove_char&.call(@current_text, last_char)\n elsif char.getbyte(0) >= 32 && @current_text.size < @max_size\n @current_text << char\n @on_new_char&.call(@current_text, char)\n end\n end\n self.text = (@empty_char.size > 0 ? @current_text.ljust(@max_size, @empty_char) : @current_text)\n end",
"def _cp(obj = Readline::HISTORY.entries[-2], *options)\n if obj.respond_to?(:join) && !options.include?(:a)\n if options.include?(:s)\n obj = obj.map { |element| \":#{element.to_s}\" }\n end\n out = obj.join(\", \")\n elsif obj.respond_to?(:inspect)\n out = obj.is_a?(String) ? obj : obj.inspect\n end\n \n if out\n IO.popen('pbcopy', 'w') { |io| io.write(out) } \n \"copied!\"\n end\nend",
"def pbcopy(string)\n `echo \"#{string}\" | pbcopy`\n string\nend",
"def pbcopy(string)\n `echo \"#{string}\" | pbcopy`\n string\nend",
"def pbcopy(string)\n `echo \"#{string}\" | pbcopy`\n string\nend",
"def pbcopy(string)\n `echo \"#{string}\" | pbcopy`\n string\nend",
"def paste\n\n # FIXME\n if OperaWatir::Platform.os == :macosx\n keys.send [:command, 'v']\n else\n keys.send [:control, 'v']\n end\n end",
"def mark_as_copied(file)\n cmd = cmd(\"setlabel\", [ file, COPIED ])\n system(cmd)\nend",
"def paste_from_clipboard(page_id, element, method, position)\n element_copy = copy(element, :page_id => page_id)\n element_copy.insert_at(position)\n if method == \"move\" && element_copy.valid?\n element.destroy\n end\n element_copy\n end",
"def copy(element)\n puts element.text\nend",
"def filecopy(input)\n\tosascript <<-END\n\t\tdelay #{@moreimage}\n\t\tset the clipboard to POSIX file (\"#{input}\")\n\t\ttell application \"Copied\"\n\t\t\tsave clipboard\n\t\tend tell\n\tEND\nend",
"def draw_text(destination_bitmap, x, y, text)\n start_x = x\n start_y = y\n cursor_x = start_x\n cursor_y = start_y\n \n for i in 0...text.length\n # New line character\n if text[i].chr == \"\\n\"\n cursor_x = 0\n cursor_y += @common.lineHeight\n end\n \n char = @chars[text[i]]\n \n # If there was no info about this character in the font file, skip it\n next if char == nil\n \n # Render the character\n x = cursor_x + char.xoffset\n y = cursor_y + char.yoffset\n \n src_bitmap = @page_bitmaps[char.page]\n \n src_rect = Rect.new(\n char.x,\n char.y,\n char.width,\n char.height\n )\n \n destination_bitmap.blt(x, y, src_bitmap, src_rect)\n \n cursor_x += char.xadvance\n end\n end",
"def paragraph_under_cursor\n ( first, _ ), ( last, _ ) = paragraph_under_cursor_pos\n @lines[ first..last ]\n end",
"def copy_html\n str = EventPrinter::HTML::head(@event.printed_name)\n str << (@list.map { |e| e.html }).join\n str << EventPrinter::HTML::foot\n Win32API.push_text_in_clipboard(str.to_ascii << \"\\0\")\n end",
"def cutText _obj, _args\n \"_obj cutText _args;\" \n end",
"def insert_completion(completion)\n cursor = text_cursor\n size = completion.size - @completer.completion_prefix.size\n\n cursor.move_position Qt::TextCursor::Left\n cursor.move_position Qt::TextCursor::EndOfWord\n\n return unless can_write_from? cursor.position\n\n cursor.insert_text completion[-size..-1]\n self.text_cursor = text_cursor\n\n highlight\n end",
"def insertText cursor, text\n if @fileContent.size == 1 and @fileContent[0] == \"\"\n dataStr = insertTextEmptyFile cursor, text\n else\n dataStr = insertTextFilledFile cursor, text\n end\n splitSize = insertTextSplitFlatten cursor\n insertTextCursorReplacement text, cursor, splitSize, dataStr\n end",
"def find_clipboard\n return session[:clipboard] ||= Clipboard.new\n end",
"def copy(from: 0, to: length)\n editable? and @native.copy_text(from.to_i, to.to_i)\n end",
"def ctrlSetText _obj, _args\n \"_obj ctrlSetText _args;\" \n end",
"def mousePressEvent(p_event)\n\t\t\tsetSelection(0, self.text.length) if !self.hasSelectedText && p_event.button == Qt::LeftButton\t\n\t\tend",
"def highlight\n return unless Config.live_highlight\n\n code = CodeRay.scan(line, :ruby).html\n\n cursor = text_cursor\n\n pos = cursor.position\n cursor.move_position Qt::TextCursor::End\n cursor.set_position @min_position, Qt::TextCursor::KeepAnchor\n cursor.remove_selected_text\n\n cursor.insert_html \"<code>#{code}</code>\"\n cursor.position = pos\n\n self.text_cursor = cursor\n end",
"def user_shot_selection_text\n \"Enter the coordinate for your shot:\\n> \"\n end",
"def gets\n @last = @current\n command = 'pbpaste'\n command << \" -pboard #{@board}\" if @board\n @current = %x[#{command}].chomp\n end",
"def change_cursor\n cursor = text_cursor\n yield cursor\n self.text_cursor = cursor\n end",
"def restore_cursor; puts \"\\e[u\" end",
"def entering text, options = {}\n widget = find_widget options[:into]\n widget.insert_text text, widget.position\n process_events\nend",
"def check_clipboard\n value = @clipboard.read\n return unless value\n\n links = @parser.parse(value)\n return if links.empty?\n\n @filter.filter(links) do |link|\n $log.debug(\"adding #{link}\")\n entry = LinkTable::Entry.new(link)\n @link_table.add(entry)\n @resolver_manager.add(entry, link)\n end\n end"
] | [
"0.7162748",
"0.70253325",
"0.69465905",
"0.68257546",
"0.67577547",
"0.6701359",
"0.6651931",
"0.66292113",
"0.652758",
"0.64711463",
"0.64573044",
"0.64228433",
"0.6377173",
"0.63673776",
"0.6274037",
"0.6267426",
"0.6252942",
"0.6209267",
"0.6203499",
"0.61606514",
"0.61570704",
"0.60823995",
"0.60550535",
"0.6017742",
"0.59970844",
"0.5979167",
"0.5979167",
"0.59127164",
"0.5861807",
"0.5861807",
"0.58563954",
"0.58466965",
"0.5836375",
"0.5829599",
"0.58289844",
"0.58142024",
"0.5798054",
"0.57615066",
"0.5752177",
"0.5742274",
"0.56986284",
"0.5697902",
"0.5695394",
"0.56931037",
"0.56846815",
"0.5654227",
"0.5612806",
"0.560589",
"0.55957985",
"0.55894357",
"0.55877566",
"0.5544591",
"0.55388975",
"0.5505123",
"0.5493695",
"0.5493541",
"0.5482096",
"0.5467981",
"0.54646355",
"0.5421194",
"0.5409861",
"0.5398377",
"0.53928316",
"0.53571016",
"0.53515893",
"0.53492683",
"0.5334988",
"0.5325244",
"0.5325244",
"0.5325244",
"0.52994686",
"0.5279658",
"0.5242499",
"0.52406555",
"0.5229333",
"0.5229333",
"0.5229333",
"0.5229333",
"0.5228852",
"0.5219611",
"0.5214912",
"0.5206617",
"0.51729566",
"0.5163988",
"0.51542234",
"0.51172805",
"0.5038875",
"0.50338286",
"0.5011806",
"0.50101143",
"0.49961957",
"0.4985965",
"0.49592167",
"0.49508923",
"0.49482968",
"0.494414",
"0.49317548",
"0.49122292",
"0.49092603",
"0.4892328"
] | 0.7296873 | 0 |
moves text between cursor and mark to clipboard | def killregion(killadd = false)
copyregion true, killadd
@last = :killregion
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_clipboard_cut\n if do_clipboard_copy()\n pos = @selection.first\n self.gui_set_value(nil, '')\n self.cur_pos = pos\n end\n end",
"def copyregion(killafter = false, killadd = false)\n return unless @mark\n sel = [@cursor, @mark].sort\n JTClipboard.addclip @text[sel.first...sel.last], killadd\n if killafter\n @text[sel.first...sel.last] = \"\"\n @cursor = @mark if @cursor > @mark\n end\n resetmark\n notify; @last = :copyregion\n end",
"def paste_before()\n clipboard = send_message(\"getClipboardContents\" => [])[\"clipboardContents\"]\n if clipboard[-1].chr == \"\\n\"\n [\"moveToBeginningOfLine:\", \"paste\"] + restore_cursor_position + [\"moveToBeginningOfLine:\"] +\n (is_whitespace?(clipboard[0].chr) ? [\"moveWordForward:\"] : [])\n else\n [\"paste\", \"moveForward:\"]\n end\n end",
"def paste; clipboard_paste; end",
"def push_text_in_clipboard(text)\n OpenClipboard.call(0)\n EmptyClipboard.call()\n hmem = GlobalAlloc.call(0x42, text.length)\n mem = GlobalLock.call(hmem)\n Memcpy.call(mem, text, text.length)\n SetClipboardData.call(1, hmem) # Format CF_TEXT = 1\n GlobalFree.call(hmem)\n CloseClipboard.call()\n self\n end",
"def copy_to_clipboard\n end",
"def do_clipboard_paste\n dat = if Wx::PLATFORM == \"WXMAC\" \n # XXX i feel dirty\n `pbpaste`\n else\n dobj=RawDataObject.new\n Wx::Clipboard.open {|clip| clip.fetch dobj}\n dobj.raw_data\n end\n\n self.gui_set_value(self.cur_pos, dat) if dat and dat.size > 0\n end",
"def do_copy\n @editor.value = @current_copycode\n @editor.focus\n end",
"def move_caret_to_mouse\n # Test character by character\n 1.upto(self.text.length) do |i|\n if @window.mouse_x < x + FONT.text_width(text[0...i])\n self.caret_pos = self.selection_start = i - 1;\n return\n end\n end\n # Default case: user must have clicked the right edge\n self.caret_pos = self.selection_start = self.text.length\n end",
"def copy_word_backward()\n [\"moveWordBackwardAndModifySelection:\"] * @number_prefix + [\"copySelection\"] + restore_cursor_position() +\n [\"moveWordBackward:\"]\n end",
"def copyFromClipboard \n \"copyFromClipboard\" \n end",
"def move_caret(mouse_x)\n 1.upto(text.length) do |i|\n if mouse_x < x + @font.text_width(text[0...i])\n self.caret_pos = self.selection_start = i - 1\n return\n end\n end\n self.caret_pos = self.selection_start = text.length\n end",
"def pbpaste\n Clipboard.paste\nend",
"def move_caret(mouse_x)\n # Test character by character\n 1.upto(self.text.height) do |i|\n if mouse_x < x + @font.text_width(text[0...i]) then\n self.caret_pos = self.selection_start = i - 1;\n return\n end\n end\n # Default case: user must have clicked the right edge\n # self.caret_pos = self.selection_start = self.text.height\n end",
"def paste(text)\n can_refresh = false\n # Attempt to insert every character individually\n text.split(\"\").each do |ch|\n break unless @helper.insert(ch)\n can_refresh = true\n end\n # Only refresh if characters were inserted\n self.refresh if can_refresh\n end",
"def cmd_clip reference, description = 'TODO description'\n path = reference2path reference\n unless create_if_not_exist reference, path\n return\n end\n puts \"adding clipboard content to \" + reference\n open_vim path, :end_of_file, \n :add_line, \n :add_line, \n :append_desc, description, :add_line,\n :append_date, \n :add_line, \n :add_line, \n :inject_clipboard\n\n end",
"def notifyClipboardContentChanged\n updateCommand(Wx::ID_PASTE) do |ioCommand|\n if (@Clipboard_CopyMode == nil)\n # The clipboard has nothing interesting for us\n # Deactivate the Paste command\n ioCommand[:Enabled] = false\n ioCommand[:Title] = 'Paste'\n # Cancel eventual Copy/Cut pending commands\n notifyCancelCopy\n # Notify everybody\n notifyRegisteredGUIs(:onClipboardContentChanged)\n elsif (@Clipboard_CopyMode == Wx::ID_DELETE)\n # Check that this message is adressed to us for real (if many instances of PBS are running, it is possible that some other instance was cutting things)\n if (@CopiedID == @Clipboard_CopyID)\n # Here we have to take some action:\n # Delete the objects marked as being 'Cut', as we got the acknowledge of pasting it somewhere.\n if (@CopiedMode == Wx::ID_CUT)\n if (!@Clipboard_AlreadyProcessingDelete)\n # Ensure that the loop will not come here again for this item.\n @Clipboard_AlreadyProcessingDelete = true\n executeCommand(Wx::ID_DELETE, {\n :parentWindow => nil,\n :selection => @CopiedSelection,\n :deleteTaggedShortcuts => false,\n :deleteOrphanShortcuts => false\n })\n # Then empty the clipboard.\n Wx::Clipboard.open do |ioClipboard|\n ioClipboard.clear\n end\n # Cancel the Cut pending commands.\n notifyCutPerformed\n notifyRegisteredGUIs(:onClipboardContentChanged)\n @Clipboard_AlreadyProcessingDelete = false\n end\n else\n log_bug 'We have been notified of a clipboard Cut acknowledgement, but no item was marked as to be Cut.'\n end\n end\n # Deactivate the Paste command\n ioCommand[:Enabled] = false\n ioCommand[:Title] = 'Paste'\n else\n lCopyName = nil\n case @Clipboard_CopyMode\n when Wx::ID_CUT\n lCopyName = 'Move'\n when Wx::ID_COPY\n lCopyName = 'Copy'\n else\n log_bug \"Unsupported copy mode from the clipboard: #{@Clipboard_CopyMode}.\"\n end\n if (@Clipboard_CopyID != @CopiedID)\n # Here, we have another application of PBS that has put data in the clipboard. It is not us anymore.\n notifyCancelCopy\n end\n if (lCopyName != nil)\n # Activate the Paste command with a cool title\n ioCommand[:Enabled] = true\n ioCommand[:Title] = \"Paste #{@Clipboard_SerializedSelection.getDescription} (#{lCopyName})\"\n else\n # Deactivate the Paste command, and explain why\n ioCommand[:Enabled] = false\n ioCommand[:Title] = \"Paste (invalid type #{@Clipboard_CopyMode}) - Bug ?\"\n end\n notifyRegisteredGUIs(:onClipboardContentChanged)\n end\n end\n end",
"def move_caret(mouse_x)\n # Test character by character\n 1.upto(self.text.length) do |i|\n if mouse_x < x + @font.text_width(text[0...i]) then\n self.caret_pos = self.selection_start = i - 1;\n return\n end\n end\n # Default case: user must have clicked the right edge\n self.caret_pos = self.selection_start = self.text.length\n end",
"def paste( text, typing = ! TYPING, do_parsed_indent = false )\n return if text.nil?\n\n if not text.kind_of? Array\n s = text.to_s\n if s.include?( \"\\n\" )\n text = s.split( \"\\n\", -1 )\n else\n text = [ s ]\n end\n end\n\n take_snapshot typing\n\n delete_selection DONT_DISPLAY\n\n row = @last_row\n col = @last_col\n new_col = nil\n line = @lines[ row ]\n if text.length == 1\n @lines[ row ] = line[ 0...col ] + text[ 0 ] + line[ col..-1 ]\n if do_parsed_indent\n parsed_indent row: row, do_display: false\n end\n cursor_to( @last_row, @last_col + text[ 0 ].length, DONT_DISPLAY, ! typing )\n elsif text.length > 1\n\n case @selection_mode\n when :normal\n @lines[ row ] = line[ 0...col ] + text[ 0 ]\n @lines[ row + 1, 0 ] = text[ -1 ] + line[ col..-1 ]\n @lines[ row + 1, 0 ] = text[ 1..-2 ]\n new_col = column_of( text[ -1 ].length )\n when :block\n @lines += [ '' ] * [ 0, ( row + text.length - @lines.length ) ].max\n @lines[ row...( row + text.length ) ] = @lines[ row...( row + text.length ) ].collect.with_index { |line,index|\n pre = line[ 0...col ].ljust( col )\n post = line[ col..-1 ]\n \"#{pre}#{text[ index ]}#{post}\"\n }\n new_col = col + text[ -1 ].length\n end\n\n new_row = @last_row + text.length - 1\n if do_parsed_indent\n ( row..new_row ).each do |r|\n parsed_indent row: r, do_display: false\n end\n end\n cursor_to( new_row, new_col )\n\n end\n\n set_modified\n end",
"def copy_bbcode\n str = EventPrinter::BBcode::head(@event.printed_name)\n str << (@list.map { |e| e.bbcode }).join(\"\\n\")\n str << EventPrinter::BBcode::foot\n Win32API.push_text_in_clipboard(str.to_ascii << \"\\0\")\n end",
"def move_caret(mouse_x)\n len = text.length\n # Default case: user must have clicked the right edge\n self.caret_pos = self.selection_start = len\n\n # Test character by character\n 1.upto(len) do |index|\n next unless mouse_x < @point.x + @font.text_width(text[0...index])\n\n self.caret_pos = self.selection_start = index - 1\n break\n end\n end",
"def paste(at: caret)\n editable? and @native.paste_text(at.to_i)\n end",
"def pbcopy(text)\n # work around, ' wrecks havoc on command line, but also caused some weird regexp substitution\n rtf = text.index('{\\rtf1')\n File.open(\"/tmp/script.scpt\", 'w') do |f|\n if rtf\n f << text\n else\n f << \"set the clipboard to \\\"#{text}\\\"\"\n end\n end\n if rtf\n `cat /tmp/script.scpt | pbcopy -Prefer rtf`\n else\n `osascript /tmp/script.scpt`\n end\nend",
"def paste\n\t\t\t$ruvim.insert $ruvim.buffers[:copy].data\n\t\t\t$ruvim.editor.redraw\n\t\tend",
"def show\n @clipboard = find_clipboard\n end",
"def copy_backward()\n [\"moveBackwardAndModifySelection:\"] * @number_prefix + [\"copySelection\", \"moveForward:\", \"moveBackward:\"]\n end",
"def move_caret(mouse_x)\n # Test character by character\n 1.upto(self.text.length) do |i|\n if mouse_x < x + @font.text_width(text[0...i]) then\n self.caret_pos = self.selection_start = i - 1;\n return\n end\n end\n \n # Default case: user must have clicked the right edge\n self.caret_pos = self.selection_start = self.text.length\n end",
"def paste_from_clipboard(page_id, element, method, position)\n element_copy = copy(element, :page_id => page_id)\n element_copy.insert_at(position)\n if method == \"move\" && element_copy.valid?\n element.destroy\n end\n element_copy\n end",
"def textcopy(input)\n\tosascript <<-END\n\t\ttell application \"Copied\"\n\t\t\tsave \"#{input}\"\n\t\tend tell\n\tEND\nend",
"def pbpaste\n a = IO.popen(\"osascript -e 'the clipboard as unicode text' | tr '\\r' '\\n'\", 'r+').read\n a.strip.force_encoding(\"UTF-8\")\nend",
"def clipboard\n IO.popen('pbcopy', 'w') {|f| f << selected_items.map(&:path).join(' ')} if osx?\n end",
"def move_to_end\n @cursor = @text.length # put cursor outside of text\n end",
"def move_to_end\n @cursor = @text.length # put cursor outside of text\n end",
"def insert_text_at_cursor(text) \n\t\tinsert_text(@cursor_row, @cursor_col, text)\n\t\n\t\tif text.include?(\"\\n\")\n\t\t\t#todo what about multiple \\n's\n\t\t\t@cursor_row += 1\n\t\t\t@cursor_col = 0\n\t\t\t#resize_contents(500, line_num_to_coord(@text.num_lines + 1))\n\t\t\temit_changed(@cursor_row - 1)\n\t\telse\n\t\t\t@cursor_col += text.length\n\t\t\temit_changed(@cursor_row)\n\t\tend\n\tend",
"def move\n @cursor.x = wrap(@cursor.x + @delta.x, @code.width)\n @cursor.y = wrap(@cursor.y + @delta.y, @code.height)\n end",
"def keyPressEvent(ev)\n if ev.matches(Qt::KeySequence::Copy)\n Qt::Application.clipboard.text = text_cursor.selected_text\n return\n end\n\n if is_read_only\n ev.ignore\n return\n end\n\n if ev.matches(Qt::KeySequence::Paste) && can_write?\n text_cursor.insert_text Qt::Application.clipboard.text\n highlight\n return\n end\n\n cursor = text_cursor\n txt = ev.text\n\n if cursor.position >= @min_position &&\n !txt.empty? &&\n !txt.between?(\"\\C-a\", \"\\C-z\")\n cursor.clear_selection\n cursor.insert_text txt\n highlight\n else\n ev.ignore\n end\n\n if completing? && @input.completion_proc\n if completion_pos == @completion_pos\n update_completion_prefix\n else\n @completer.popup.hide\n end\n end\n end",
"def cursor_move_to_end\n @cursor_position = @text.scan(/./m).size\n self.reset_cursor_blinking\n end",
"def copy(segment=selection)\n\t\t\t$ruvim.buffers[:copy].data.replace segment\n\t\tend",
"def load_text(text)\n text = text.dup\n text.sub!(CTRL_V) { Yuki.get_clipboard }\n text.split(//).each do |char|\n if char == BACK\n last_char = @current_text[-1]\n @current_text.chop!\n @on_remove_char&.call(@current_text, last_char)\n elsif char.getbyte(0) >= 32 && @current_text.size < @max_size\n @current_text << char\n @on_new_char&.call(@current_text, char)\n end\n end\n self.text = (@empty_char.size > 0 ? @current_text.ljust(@max_size, @empty_char) : @current_text)\n end",
"def insert_selection\n insert(cursor, Tk::Selection.get(type: 'UTF8_STRING'))\n end",
"def cp(string)\n `echo \"#{string} | pbcopy`\n puts 'copied to clipboard'\nend",
"def to_clipboard\n #prettified = self.pretty_inspect.strip\n prettified = self.to_s\n stringified = self.to_s\n printable = (\n if prettified.length > 80 then\n prettified.slice(0, 80) + '...'\n else\n prettified\n end\n ).inspect\n $clipboard.write(stringified)\n $stderr.puts(\"to_clipboard: wrote #{printable} to clipboard\")\n return nil\n end",
"def paste(str)\n send_command_to_control(\"EditPaste\", str)\n end",
"def restore_cursor_position() set_cursor_position(@event[\"line\"], @event[\"column\"]) end",
"def do_clipboard_copy\n return nil unless sel=@selection and dat=@data[sel]\n # XXX i feel dirty\n if Wx::PLATFORM == \"WXMAC\"\n IO.popen(\"pbcopy\", \"w\") {|io| io.write dat}\n stat = $?.success?\n else\n dobj = RawDataObject.new(dat)\n stat = Wx::Clipboard.open {|clip| clip.place dobj}\n end\n return stat\n end",
"def backspace() \n\t\t#todo\n\t\tif @cursor_col > 0\n\t\t\tline = line(@cursor_row)\n\t\t\tline[@cursor_col - 1.. @cursor_col - 1] = \"\"\n\t\t\tchange_line(@cursor_row, line)\n\t\t\t@cursor_col -= 1\n\t\t\temit_changed(@cursor_row)\n\t\tend\n\tend",
"def replace(text)\n @text = text\n @cursor = @text.length # put cursor outside of text\n end",
"def copy\n out = ''\n\n Selection.each do |dd|\n docu = dd.cite_key.get\n docu.strip!\n out << \"[@#{docu}] \"\n end\n\n pbcopy(out.strip)\n growl(\"#{Selection.size} citation references copied to the clipboard\")\nend",
"def restore_cursor; puts \"\\e[u\" end",
"def copyToClipboard _args\n \"copyToClipboard _args;\" \n end",
"def clip_again\n a = File.read(\"/tmp/dokuwiki-clip.tmp\")\n page, url, title, onlytext_s = a.split(\"\\n\")\n onlytext = (onlytext_s == 'true' && has_selection)\n\n title = curtitle if (title.strip == \"\") || (url != cururl)\n\n do_clip(page, title, onlytext)\nend",
"def move_text(from, to)\n \"#{from}->#{to}\"\nend",
"def undo\n if done\n @text = text.sub(DONE_REGEX, '').strip\n @done = false\n end\n end",
"def move_text(from, to)\n\"#{from}->#{to}\"\nend",
"def insert_text(text)\n # Create the mark tag if not exist\n @buffer.insert(@buffer.end_iter, text)\n if (not @buffer.get_mark('end_mark'))\n @buffer.create_mark('end_mark', @buffer.end_iter, false)\n end\n\n # Save our offset\n @@offset = @buffer.end_iter.offset\n\n # Scrolled the view until the end of the buffer\n @textview.scroll_mark_onscreen(@buffer.get_mark('end_mark'))\n end",
"def cut_word_forward()\n select_word_forward_including_whitespace(@number_prefix) + [\"copySelection\", \"deleteBackward:\"] +\n restore_cursor_position()\n end",
"def go_caret_word(newtab=false)\n go_word('insert', newtab)\n end",
"def paste link\n clipboard = %w{\n /usr/bin/pbcopy\n /usr/bin/xclip\n }.find { |path| File.exist? path }\n\n if clipboard\n IO.popen clipboard, 'w' do |io| io.write link end\n end\n end",
"def copy\n\n # FIXME: #copy, #cut and #paste really shouldn't use platform-\n # dependent keypresses like this. But until DSK-327491 is fixed,\n # this will have to do.\n if OperaWatir::Platform.os == :macosx\n keys.send [:command, 'c']\n else\n keys.send [:control, 'c']\n end\n end",
"def copy(content)\n cmd = case true\n when system(\"type pbcopy > /dev/null 2>&1\")\n :pbcopy\n when system(\"type xclip > /dev/null 2>&1\")\n :xclip\n when system(\"type putclip > /dev/null 2>&1\")\n :putclip\n end\n\n if cmd\n IO.popen(cmd.to_s, 'r+') { |clip| clip.print content }\n end\n\n content\n end",
"def copy(content)\n cmd = case true\n when system(\"type pbcopy > /dev/null 2>&1\")\n :pbcopy\n when system(\"type xclip > /dev/null 2>&1\")\n :xclip\n when system(\"type putclip > /dev/null 2>&1\")\n :putclip\n end\n\n if cmd\n IO.popen(cmd.to_s, 'r+') { |clip| clip.print content }\n end\n\n content\n end",
"def cop\n last_value = IRB.CurrentContext.last_value\n %x[echo '#{last_value}' | pbcopy]\n \"copied \\`#{last_value}' to your clipboard\"\nend",
"def cop\n last_value = IRB.CurrentContext.last_value\n %x[echo '#{last_value}' | pbcopy]\n \"copied \\`#{last_value}' to your clipboard\"\nend",
"def remove\n left\n @text.slice!(@cursor, 1)\n end",
"def paste\n `pbpaste`\n end",
"def insert_completion(completion)\n cursor = text_cursor\n size = completion.size - @completer.completion_prefix.size\n\n cursor.move_position Qt::TextCursor::Left\n cursor.move_position Qt::TextCursor::EndOfWord\n\n return unless can_write_from? cursor.position\n\n cursor.insert_text completion[-size..-1]\n self.text_cursor = text_cursor\n\n highlight\n end",
"def mousePressEvent(p_event)\n\t\t\tsetSelection(0, self.text.length) if !self.hasSelectedText && p_event.button == Qt::LeftButton\t\n\t\tend",
"def _rl_replace_text(text, start, _end)\r\n rl_begin_undo_group()\r\n rl_delete_text(start, _end + 1)\r\n @rl_point = start\r\n n = rl_insert_text(text)\r\n rl_end_undo_group()\r\n n\r\n end",
"def change_cursor\n cursor = text_cursor\n yield cursor\n self.text_cursor = cursor\n end",
"def copy(item)\n copy_command = darwin? ? \"pbcopy\" : \"xclip -selection clipboard\"\n\n Kernel.system(\"echo '#{item.value.gsub(\"\\'\",\"\\\\'\")}' | tr -d \\\"\\n\\\" | #{copy_command}\")\n\n \"Boom! We just copied #{item.value} to your clipboard.\"\n end",
"def cursor_move_to_beginning\n @cursor_position = 0\n self.reset_cursor_blinking\n end",
"def do_clip(pagename, titletxt, onlytext = false)\n pagepath = (\"#{Wiki_path}/data/pages/#{clean_pagename(pagename)}.txt\").gsub(\":\",\"/\")\n\n curpage = cururl.split(\"/\").last\n sel = has_selection\n\n # format properly if citation\n unless onlytext\n if curpage.index(\"ref:\")\n curpage = \"[@#{curpage.split(':').last.downcase}]\"\n elsif cururl.index(\"localhost/wiki\")\n curpage = \"[[:#{capitalize_word(curpage.gsub(\"_\", \" \"))}]]\"\n else\n title = (titletxt ? titletxt : curtitle)\n curpage =\"[[#{cururl}|#{title}]]\"\n end\n else\n curpage = ''\n end\n\n insert = (sel ? \"#{sel} \" : \" * \" ) # any text, or just a link (bullet list)\n insert.gsubs!( {:all_with=> \"\\n\\n\"}, \"\\n\", \"\\n\\n\\n\" )\n\n if File.exists?(pagepath)\n prevcont = File.read(pagepath)\n\n haslinks = prevcont.match(/\\-\\-\\-(\\n \\*[^\\n]+?)+?\\Z/m) # a \"---\"\" followed by only lines starting with \" * \"\n\n # bullet lists need an extra blank line after them before the \"----\"\n if sel\n divider = (haslinks ? \"\\n\\n----\\n\" : \"\\n----\\n\")\n else\n divider = (haslinks ? \"\\n\" : \"\\n----\\n\")\n end\n\n growltext = \"Selected text added to #{pagename}\"\n else\n prevcont = \"h1. #{capitalize_word(pagename)}\\n\\n\"\n growltext = \"Selected text added to newly created #{pagename}\"\n end\n filetext = [prevcont, divider, insert, curpage].join\n dwpage(pagename, filetext)\n\n growl(\"Text added\", growltext)\nend",
"def paste\n `pbpaste`\nend",
"def handle_text_insertion pos, text\n add_command InsertionCommand.new(pos, text)\n end",
"def replace(text)\n @text = text\n @cursor = @text.length # put cursor outside of text\n replace_mode\n end",
"def after_create\n self.syntax.increment!(:paste_count)\n end",
"def undo_move(move)\n self.cells[move.to_i - 1] = \" \"\n end",
"def copy(str = nil)\n clipboard_copy(:string => (!$stdin.tty? ? $stdin.read : str))\n end",
"def get_clipboard_contents\n out = \"\"\n\n Open3.popen3(\"xclip -o -selection clipboard\") do |_, o, _, _|\n out = o.read.strip\n end\n\n out\n end",
"def pbcopy(str)\n IO.popen('pbcopy', 'r+') {|io| io.puts str }\n output.puts \"-- Copy to clipboard --\\n#{str}\"\nend",
"def clear_up_to_cursor; puts \"\\e[1J\" end",
"def replace_text(text)\n @txt .set_editable(true) # .freeze\n @txt .buffer .set_text(\"\")\n# hdr, value = text .split(\"\\n\\n\", 2)\n# hdr .to_s .each_line{|line|\n# case line\n# when /^Subject:/ ;color = BLUE\n# when /^X-SC-Subject:/ ;color = BLUE\n# when /^From:/ ;color = PURPLE\n# #when /^To:|Cc:/ ;color = ORANGE\n# #when /^Date:/ ;color = GREEN\n# when /^X-SC-(Time|Day):/ ;color = RED\n# else ;color = BLACK\n# end\n# @txt .insert(nil, color, nil, line) if line != ''\n# }\n# @txt .insert(nil, RED, WHITE, hdr .to_s)\n# @txt .insert(nil, BLACK, nil, \"\\n\\n\" + value .to_s)\n\n @txt .buffer .insert(@txt.buffer.start_iter, MhcKconv::todisp(text))\n @txt .set_editable(@text_editable) #.thaw\n end",
"def overwriteText cursor, text\n if cursor.isAtEOL? or cursor.isAtEOF?\n insertText cursor, text\n else\n overwrite cursor, text\n end\n end",
"def paste\n\n # FIXME\n if OperaWatir::Platform.os == :macosx\n keys.send [:command, 'v']\n else\n keys.send [:control, 'v']\n end\n end",
"def entering text, options = {}\n widget = find_widget options[:into]\n widget.insert_text text, widget.position\n process_events\nend",
"def cursor_bol\n # copy of C-a - start of line\n @repaint_required = true if @pcol > 0\n @pcol = 0\n @curpos = 0\n end",
"def insert_text_after(text)\r\n text_run = get_run_after\r\n text_run.text = \"#{text}#{text_run.text}\"\r\n end",
"def delete\n @text.slice!(@cursor, 1)\n end",
"def catch_text\n # get the actual offset\n start = @buffer.get_iter_at_offset(@@offset)\n\n # get the command\n cmd = @buffer.get_text(start, @buffer.end_iter)\n\n # Save the command to the history object\n @historic.append(cmd)\n\n # Write the command to our pipe\n send_cmd(cmd)\n\n # Add a return line to our buffer\n insert_text(\"\\n\")\n\n # Call the prompt\n prompt()\n\n # Create the mark tag if not exist\n if (not @buffer.get_mark('end_mark'))\n @buffer.create_mark('end_mark', @buffer.end_iter, false)\n end\n\n # Save our offset\n @@offset = @buffer.end_iter.offset\n end",
"def insert(text, at: caret)\n editable? and @native.insert_text(at.to_i, text.to_s, text.to_s.length)\n end",
"def copy(sender)\n filteredData[tableView.selectedRow].symbol.sendToPasteboard\n end",
"def press(point)\n\t\tsuper(point)\n\t\t# storing original verts and original position via Rectangle edit, even though that data is also recorded in the undo proc from Text#resize!\n\tend",
"def reset_cursor\n c = get_cursor_pos\n print_area_to_buffer(@main_buffer, c[0], c[1], @last_chars)\n @last_chars = cache_area(@main_buffer,\n c[0], 1,\n c[1], 1)\n @cursor = [\"\\u2588\"]\n print_area_to_buffer(@main_buffer, c[0], c[1], @cursor)\n\n return\n end",
"def text=(new_text)\n @text = new_text\n refresh\n update_cursor\n end",
"def move_to(x, y); puts \"\\e[#{y};#{x}G\" end",
"def delete_current_character() \n\t\tif @selection_start != -1\n\t\t\tl1, i1 = index_line_and_col(@selection_start)\n\t\t\tl2, i2 = index_line_and_col(@selection_end)\n\t\t\tremove_range(l1, i1, l2, i2)\n\t\t\tclear_selection\n\t\t\temit_changed((l1...num_lines)) #todo\n\t\telse\n\t\t\tline = line(@cursor_row)\n\t\t\tline[@cursor_col.. @cursor_col] = \"\"\n\t\t\tchange_line(@cursor_row, line)\n\t\t\temit_changed(@cursor_row)\n\t\tend\n\tend",
"def move_if_necessary(x, y)\n return if textcursor.left == x && textcursor.top == y\n move_textcursor(x, y)\n end",
"def cursor_to_input_line\n setpos(input_line, 0)\n end",
"def replace_line(line)\n cursor = text_cursor\n\n cursor.position = document.character_count - 1\n cursor.set_position(@min_position, Qt::TextCursor::KeepAnchor)\n\n cursor.insert_text line\n\n change_cursor { |c| c.position = document.character_count - 1 }\n\n highlight\n end",
"def insertText cursor, text\n if @fileContent.size == 1 and @fileContent[0] == \"\"\n dataStr = insertTextEmptyFile cursor, text\n else\n dataStr = insertTextFilledFile cursor, text\n end\n splitSize = insertTextSplitFlatten cursor\n insertTextCursorReplacement text, cursor, splitSize, dataStr\n end",
"def mark_as_copied(file)\n cmd = cmd(\"setlabel\", [ file, COPIED ])\n system(cmd)\nend"
] | [
"0.74801946",
"0.73943496",
"0.73472476",
"0.68966055",
"0.67716205",
"0.6762277",
"0.6719375",
"0.6708828",
"0.6676742",
"0.6588983",
"0.64937186",
"0.64350796",
"0.63764286",
"0.6261668",
"0.6258935",
"0.6249099",
"0.62014",
"0.6192762",
"0.6164518",
"0.6120206",
"0.6093522",
"0.6002841",
"0.5981495",
"0.5970344",
"0.59679866",
"0.59630567",
"0.5941198",
"0.5900254",
"0.58686775",
"0.5858933",
"0.5858504",
"0.5840659",
"0.5840659",
"0.583877",
"0.5778316",
"0.57654285",
"0.57345814",
"0.57339513",
"0.5721597",
"0.57180536",
"0.57016736",
"0.5660342",
"0.56436193",
"0.5629921",
"0.56248164",
"0.56101793",
"0.5601357",
"0.5601016",
"0.5600007",
"0.55886567",
"0.558821",
"0.55865943",
"0.5573332",
"0.5567158",
"0.553674",
"0.54882336",
"0.5473605",
"0.54725814",
"0.5420138",
"0.54171956",
"0.54171956",
"0.5406673",
"0.5406673",
"0.5400115",
"0.53973526",
"0.5383311",
"0.53791535",
"0.53622746",
"0.53614706",
"0.5356542",
"0.5340066",
"0.5333657",
"0.52924085",
"0.5284758",
"0.5283148",
"0.52652854",
"0.52555794",
"0.52501965",
"0.523931",
"0.5235553",
"0.5234398",
"0.52316517",
"0.5224101",
"0.52226496",
"0.520607",
"0.5182608",
"0.51810086",
"0.51777655",
"0.5168612",
"0.516535",
"0.5162773",
"0.5158644",
"0.5154313",
"0.5141714",
"0.513862",
"0.512967",
"0.51222163",
"0.51201445",
"0.5119362",
"0.510475",
"0.50969714"
] | 0.0 | -1 |
moves text between cursor and eol to clipboard, delete line empty consecutive killtoeol calls cumulate to one clipboard entry | def killtoeol
char = @text[@cursor, 1]
if char == "\n"
killto :killtoeol do movetoright end
else
killto :killtoeol do movetoeol end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_clipboard_cut\n if do_clipboard_copy()\n pos = @selection.first\n self.gui_set_value(nil, '')\n self.cur_pos = pos\n end\n end",
"def paste_before()\n clipboard = send_message(\"getClipboardContents\" => [])[\"clipboardContents\"]\n if clipboard[-1].chr == \"\\n\"\n [\"moveToBeginningOfLine:\", \"paste\"] + restore_cursor_position + [\"moveToBeginningOfLine:\"] +\n (is_whitespace?(clipboard[0].chr) ? [\"moveWordForward:\"] : [])\n else\n [\"paste\", \"moveForward:\"]\n end\n end",
"def paste( text, typing = ! TYPING, do_parsed_indent = false )\n return if text.nil?\n\n if not text.kind_of? Array\n s = text.to_s\n if s.include?( \"\\n\" )\n text = s.split( \"\\n\", -1 )\n else\n text = [ s ]\n end\n end\n\n take_snapshot typing\n\n delete_selection DONT_DISPLAY\n\n row = @last_row\n col = @last_col\n new_col = nil\n line = @lines[ row ]\n if text.length == 1\n @lines[ row ] = line[ 0...col ] + text[ 0 ] + line[ col..-1 ]\n if do_parsed_indent\n parsed_indent row: row, do_display: false\n end\n cursor_to( @last_row, @last_col + text[ 0 ].length, DONT_DISPLAY, ! typing )\n elsif text.length > 1\n\n case @selection_mode\n when :normal\n @lines[ row ] = line[ 0...col ] + text[ 0 ]\n @lines[ row + 1, 0 ] = text[ -1 ] + line[ col..-1 ]\n @lines[ row + 1, 0 ] = text[ 1..-2 ]\n new_col = column_of( text[ -1 ].length )\n when :block\n @lines += [ '' ] * [ 0, ( row + text.length - @lines.length ) ].max\n @lines[ row...( row + text.length ) ] = @lines[ row...( row + text.length ) ].collect.with_index { |line,index|\n pre = line[ 0...col ].ljust( col )\n post = line[ col..-1 ]\n \"#{pre}#{text[ index ]}#{post}\"\n }\n new_col = col + text[ -1 ].length\n end\n\n new_row = @last_row + text.length - 1\n if do_parsed_indent\n ( row..new_row ).each do |r|\n parsed_indent row: r, do_display: false\n end\n end\n cursor_to( new_row, new_col )\n\n end\n\n set_modified\n end",
"def copyregion(killafter = false, killadd = false)\n return unless @mark\n sel = [@cursor, @mark].sort\n JTClipboard.addclip @text[sel.first...sel.last], killadd\n if killafter\n @text[sel.first...sel.last] = \"\"\n @cursor = @mark if @cursor > @mark\n end\n resetmark\n notify; @last = :copyregion\n end",
"def undo_delete_eol\n return if @delete_buffer.nil?\n #oldvalue = @buffer\n @buffer.insert @curpos, @delete_buffer \n fire_handler :CHANGE, InputDataEvent.new(@curpos,@curpos+@delete_buffer.length, self, :INSERT, 0, @delete_buffer) \n end",
"def undo_delete_eol\n return if @delete_buffer.nil?\n #oldvalue = @buffer\n @buffer.insert @curpos, @delete_buffer \n fire_handler :CHANGE, InputDataEvent.new(@curpos,@curpos+@delete_buffer.length, self, :INSERT, 0, @delete_buffer) # 2010-09-11 13:01 \n end",
"def deleteTextBackspace cursor, overwrite, nbToDelete = 1\n nbToDelete = deleteTextBackspaceTooBig cursor, nbToDelete\n while cursor.column < nbToDelete\n nbToDelete = deleteTextBackspaceConcatLine cursor, nbToDelete, overwrite\n end\n deleteTextBackspaceSameLine cursor, nbToDelete, overwrite\n nil\n end",
"def erase_all\n getmaxyx\n clrtoeol(0...@lines)\n end",
"def rl_kill_text(from, to)\r\n # Is there anything to kill?\r\n if (from == to)\r\n @_rl_last_command_was_kill = true if !@_rl_last_command_was_kill\r\n return 0\r\n end\r\n text = rl_copy_text(from, to)\r\n\r\n # Delete the copied text from the line.\r\n rl_delete_text(from, to)\r\n _rl_copy_to_kill_ring(text, from < to)\r\n @_rl_last_command_was_kill = true if !@_rl_last_command_was_kill\r\n 0\r\n end",
"def backspace() \n\t\t#todo\n\t\tif @cursor_col > 0\n\t\t\tline = line(@cursor_row)\n\t\t\tline[@cursor_col - 1.. @cursor_col - 1] = \"\"\n\t\t\tchange_line(@cursor_row, line)\n\t\t\t@cursor_col -= 1\n\t\t\temit_changed(@cursor_row)\n\t\tend\n\tend",
"def wclrtoeol\n Ncurses.wclrtoeol(pointer)\n end",
"def paste; clipboard_paste; end",
"def notifyClipboardContentChanged\n updateCommand(Wx::ID_PASTE) do |ioCommand|\n if (@Clipboard_CopyMode == nil)\n # The clipboard has nothing interesting for us\n # Deactivate the Paste command\n ioCommand[:Enabled] = false\n ioCommand[:Title] = 'Paste'\n # Cancel eventual Copy/Cut pending commands\n notifyCancelCopy\n # Notify everybody\n notifyRegisteredGUIs(:onClipboardContentChanged)\n elsif (@Clipboard_CopyMode == Wx::ID_DELETE)\n # Check that this message is adressed to us for real (if many instances of PBS are running, it is possible that some other instance was cutting things)\n if (@CopiedID == @Clipboard_CopyID)\n # Here we have to take some action:\n # Delete the objects marked as being 'Cut', as we got the acknowledge of pasting it somewhere.\n if (@CopiedMode == Wx::ID_CUT)\n if (!@Clipboard_AlreadyProcessingDelete)\n # Ensure that the loop will not come here again for this item.\n @Clipboard_AlreadyProcessingDelete = true\n executeCommand(Wx::ID_DELETE, {\n :parentWindow => nil,\n :selection => @CopiedSelection,\n :deleteTaggedShortcuts => false,\n :deleteOrphanShortcuts => false\n })\n # Then empty the clipboard.\n Wx::Clipboard.open do |ioClipboard|\n ioClipboard.clear\n end\n # Cancel the Cut pending commands.\n notifyCutPerformed\n notifyRegisteredGUIs(:onClipboardContentChanged)\n @Clipboard_AlreadyProcessingDelete = false\n end\n else\n log_bug 'We have been notified of a clipboard Cut acknowledgement, but no item was marked as to be Cut.'\n end\n end\n # Deactivate the Paste command\n ioCommand[:Enabled] = false\n ioCommand[:Title] = 'Paste'\n else\n lCopyName = nil\n case @Clipboard_CopyMode\n when Wx::ID_CUT\n lCopyName = 'Move'\n when Wx::ID_COPY\n lCopyName = 'Copy'\n else\n log_bug \"Unsupported copy mode from the clipboard: #{@Clipboard_CopyMode}.\"\n end\n if (@Clipboard_CopyID != @CopiedID)\n # Here, we have another application of PBS that has put data in the clipboard. It is not us anymore.\n notifyCancelCopy\n end\n if (lCopyName != nil)\n # Activate the Paste command with a cool title\n ioCommand[:Enabled] = true\n ioCommand[:Title] = \"Paste #{@Clipboard_SerializedSelection.getDescription} (#{lCopyName})\"\n else\n # Deactivate the Paste command, and explain why\n ioCommand[:Enabled] = false\n ioCommand[:Title] = \"Paste (invalid type #{@Clipboard_CopyMode}) - Bug ?\"\n end\n notifyRegisteredGUIs(:onClipboardContentChanged)\n end\n end\n end",
"def do_clipboard_paste\n dat = if Wx::PLATFORM == \"WXMAC\" \n # XXX i feel dirty\n `pbpaste`\n else\n dobj=RawDataObject.new\n Wx::Clipboard.open {|clip| clip.fetch dobj}\n dobj.raw_data\n end\n\n self.gui_set_value(self.cur_pos, dat) if dat and dat.size > 0\n end",
"def cut\n return unless @lines_used > 0\n\n feed(@options[:lines_total] - @lines_used + 1)\n stamp\n print(0x0c.chr)\n @lines_used = 0\n end",
"def delete_current_character() \n\t\tif @selection_start != -1\n\t\t\tl1, i1 = index_line_and_col(@selection_start)\n\t\t\tl2, i2 = index_line_and_col(@selection_end)\n\t\t\tremove_range(l1, i1, l2, i2)\n\t\t\tclear_selection\n\t\t\temit_changed((l1...num_lines)) #todo\n\t\telse\n\t\t\tline = line(@cursor_row)\n\t\t\tline[@cursor_col.. @cursor_col] = \"\"\n\t\t\tchange_line(@cursor_row, line)\n\t\t\temit_changed(@cursor_row)\n\t\tend\n\tend",
"def cursor_move_to_end\n @cursor_position = @text.scan(/./m).size\n self.reset_cursor_blinking\n end",
"def rl_kill_full_line(count, ignore)\r\n rl_begin_undo_group()\r\n @rl_point = 0\r\n rl_kill_text(@rl_point, @rl_end)\r\n @rl_mark = 0\r\n rl_end_undo_group()\r\n 0\r\n end",
"def undo\n if done\n @text = text.sub(DONE_REGEX, '').strip\n @done = false\n end\n end",
"def clear_to_cursor; print \"\\e[1K\" end",
"def clear_line_after\n CSI + '0K'\n end",
"def undo_move(move)\n self.cells[move.to_i - 1] = \" \"\n end",
"def _rl_copy_to_kill_ring(text, append)\r\n # First, find the slot to work with.\r\n if (!@_rl_last_command_was_kill)\r\n # Get a new slot.\r\n if @rl_kill_ring.nil?\r\n # If we don't have any defined, then make one.\r\n @rl_kill_ring_length = 1\r\n @rl_kill_ring = Array.new(@rl_kill_ring_length+1)\r\n @rl_kill_ring[slot = 0] = nil\r\n else\r\n # We have to add a new slot on the end, unless we have\r\n # exceeded the max limit for remembering kills.\r\n slot = @rl_kill_ring_length\r\n if (slot == @rl_max_kills)\r\n @rl_kill_ring[0,slot] = @rl_kill_ring[1,slot]\r\n else\r\n slot = @rl_kill_ring_length += 1\r\n end\r\n @rl_kill_ring[slot-=1] = nil\r\n end\r\n else\r\n slot = @rl_kill_ring_length - 1\r\n end\r\n\r\n # If the last command was a kill, prepend or append.\r\n if (@_rl_last_command_was_kill && @rl_editing_mode != @vi_mode)\r\n old = @rl_kill_ring[slot]\r\n\r\n if (append)\r\n new = old + text\r\n else\r\n new = text + old\r\n end\r\n old = nil\r\n text = nil\r\n @rl_kill_ring[slot] = new\r\n else\r\n @rl_kill_ring[slot] = text\r\n end\r\n\r\n @rl_kill_index = slot\r\n 0\r\n end",
"def move_to_end\n @cursor = @text.length # put cursor outside of text\n end",
"def move_to_end\n @cursor = @text.length # put cursor outside of text\n end",
"def rl_replace_line(text, clear_undo)\r\n len = text.delete(0.chr).length\r\n @rl_line_buffer = text.dup + 0.chr\r\n @rl_end = len\r\n if (clear_undo)\r\n rl_free_undo_list()\r\n end\r\n _rl_fix_point(true)\r\n end",
"def copy_to_clipboard\n end",
"def killLineConcat buffer\n c = @frames[buffer].cursor\n if c.isAtEOL?\n size = 1\n @killRing[0] << \"\\n\"\n else\n @killRing[0] << buffer.fileContent[c.line][c.column,\n buffer.fileContent[c.line].size]\n size = buffer.fileContent[c.line][c.column,\n buffer.fileContent[c.line].size].size\n end\n @frames[buffer].deleteBuffer buffer, size\n end",
"def remove_lines(text)\n text.delete(\"\\n\")\n end",
"def clear_line_before\n CSI + '1K'\n end",
"def erase_line_to_end\n ConsoleGlitter.escape('0K')\n end",
"def cursor_eol\n # pcol is based on max length not current line's length\n @pcol = @content_cols - @cols - 1\n _arr = _getarray\n @curpos = _arr[@current_index].size\n @repaint_required = true\n end",
"def rl_delete_text(from, to)\r\n\r\n # Fix it if the caller is confused.\r\n if (from > to)\r\n from,to = to,from\r\n end\r\n\r\n # fix boundaries\r\n if (to > @rl_end)\r\n to = @rl_end\r\n if (from > to)\r\n from = to\r\n end\r\n end\r\n if (from < 0)\r\n from = 0\r\n end\r\n text = rl_copy_text(from, to)\r\n diff = to - from\r\n @rl_line_buffer[from...to] = ''\r\n @rl_line_buffer << 0.chr * diff\r\n # Remember how to undo this delete.\r\n if (!@_rl_doing_an_undo)\r\n rl_add_undo(UNDO_DELETE, from, to, text)\r\n else\r\n text = nil\r\n end\r\n @rl_end -= diff\r\n @rl_line_buffer[@rl_end,1] = 0.chr\r\n return (diff)\r\n end",
"def clear_up_to_cursor; puts \"\\e[1J\" end",
"def remove\n\t\t\tback if (@buffer.at_end?)\n\t\t\tch = @buffer.char\n\t\t\[email protected]\n\t\t\tredraw_line((ch == Ruvim::API::CR) ? (@cursor.y ... @height) : @cursor.y) \n\t\t\tself\n\t\tend",
"def kill_line(*)\n if current_buffer[current_buffer.point] == \"\\n\"\n current_buffer.slice!(current_buffer.point)\n return true\n end\n\n line_end = current_buffer.index(/$/, current_buffer.point)\n current_buffer.slice!(current_buffer.point, line_end - current_buffer.point)\n true\nend",
"def clear_eol\n print \"\\e[0K\"\n end",
"def clrtoeol(y_indices = nil)\n if y_indices.nil?\n @stdscr.clrtoeol\n else\n old_y, old_x = getyx\n y_indices = [y_indices] unless y_indices.is_a?(Enumerable)\n y_indices.each do |y|\n @stdscr.move(y, 0)\n @stdscr.clrtoeol\n end\n @stdscr.move(old_y, old_x)\n end\n end",
"def remove\n left\n @text.slice!(@cursor, 1)\n end",
"def undoMove(index)\n @board[index] = \" \"\n end",
"def rstrip_buffer!(index = -1)\n last = @to_merge[index]\n if last.nil?\n push_silent(\"_hamlout.rstrip!\", false)\n @dont_tab_up_next_text = true\n return\n end\n\n case last.first\n when :text\n last[1].rstrip!\n if last[1].empty?\n @to_merge.slice! index\n rstrip_buffer! index\n end\n when :script\n last[1].gsub!(/\\(haml_temp, (.*?)\\);$/, '(haml_temp.rstrip, \\1);')\n rstrip_buffer! index - 1\n else\n raise SyntaxError.new(\"[HAML BUG] Undefined entry in Haml::Precompiler@to_merge.\")\n end\n end",
"def copy_word_backward()\n [\"moveWordBackwardAndModifySelection:\"] * @number_prefix + [\"copySelection\"] + restore_cursor_position() +\n [\"moveWordBackward:\"]\n end",
"def _rl_erase_at_end_of_line(l)\r\n _rl_backspace(l)\r\n @rl_outstream.write(' '*l)\r\n _rl_backspace(l)\r\n @_rl_last_c_pos -= l\r\n @visible_line[@_rl_last_c_pos,l] = 0.chr * l\r\n @rl_display_fixed = true if !@rl_display_fixed\r\n end",
"def chop!\n my_size = self.__size\n if my_size._not_equal?( 0 )\n if self.__at(-1).eql?( ?\\n )\n if my_size > 1 && self.__at(-2).eql?( ?\\r )\n self.__size=(my_size - 2)\n else\n self.__size=(my_size - 1)\n end\n else\n self.__size=(my_size - 1)\n end\n return self\n end\n return nil # no modification made\n end",
"def rstrip_buffer!(index = -1)\n last = @to_merge[index]\n if last.nil?\n push_silent(\"_hamlout.rstrip!\", false)\n @dont_tab_up_next_text = true\n return\n end\n\n case last.first\n when :text\n last[1].rstrip!\n if last[1].empty?\n @to_merge.slice! index\n rstrip_buffer! index\n end\n when :script\n last[1].gsub!(/\\(haml_temp, (.*?)\\);$/, '(haml_temp.rstrip, \\1);')\n rstrip_buffer! index - 1\n else\n raise SyntaxError.new(\"[HAML BUG] Undefined entry in Haml::Compiler@to_merge.\")\n end\n end",
"def clean_text(text)\n lines = text.strip.each_line\n lines = lines.reject { |line| SOURCE_LINE =~ line }\n lines.join.strip.delete(\"\\r\")\n end",
"def rl_unix_line_discard(count, key)\r\n if (@rl_point == 0)\r\n rl_ding()\r\n else\r\n rl_kill_text(@rl_point, 0)\r\n @rl_point = 0\r\n if (@rl_editing_mode == @emacs_mode)\r\n @rl_mark = @rl_point\r\n end\r\n end\r\n 0\r\n end",
"def cursor_bol\n # copy of C-a - start of line\n @repaint_required = true if @pcol > 0\n @pcol = 0\n @curpos = 0\n end",
"def _rl_overwrite_rubout(count, key)\r\n if (@rl_point == 0)\r\n rl_ding()\r\n return 1\r\n end\r\n\r\n opoint = @rl_point\r\n\r\n # L == number of spaces to insert\r\n l = 0\r\n count.times do\r\n rl_backward_char(1, key)\r\n l += rl_character_len(@rl_line_buffer[@rl_point,1], @rl_point) # not exactly right\r\n end\r\n\r\n rl_begin_undo_group()\r\n\r\n if (count > 1 || @rl_explicit_arg)\r\n rl_kill_text(opoint, @rl_point)\r\n else\r\n rl_delete_text(opoint, @rl_point)\r\n end\r\n # Emacs puts point at the beginning of the sequence of spaces.\r\n if (@rl_point < @rl_end)\r\n opoint = @rl_point\r\n _rl_insert_char(l, ' ')\r\n @rl_point = opoint\r\n end\r\n\r\n rl_end_undo_group()\r\n\r\n 0\r\n end",
"def cut_word_forward()\n select_word_forward_including_whitespace(@number_prefix) + [\"copySelection\", \"deleteBackward:\"] +\n restore_cursor_position()\n end",
"def clear_lines lines\n lines = lines.map do |line|\n line = line.gsub(/(\\n)$/, \"\")\n line = line.gsub(/(\\t)/,\"\")\n next if line == \"\\n\"\n end\nend",
"def erase_line_to_beginning\n ConsoleGlitter.escape('1K')\n end",
"def handle_interrupt\n if @buffer\n @buffer.pop; @buffer_info.pop; history.pop\n if @buffer.empty?\n @buffer = @buffer_info = nil\n print '[buffer empty]'\n return super\n else\n puts \"[previous line removed|#{@buffer.size}]\"\n throw :multiline\n end\n else\n super\n end\n end",
"def deleteTextBackspaceTooBig cursor, nbToDelete\n nb = nbToDelete - cursor.column\n line = cursor.line - 1\n while nb > 0 && line >= 0\n nb -= @fileContent[line].size + 1\n line -= 1\n end\n if nb <= 0\n return nbToDelete\n else \n return nbToDelete - nb\n end\n end",
"def win_line_endings( src, dst )\n case ::File.extname(src)\n when *%w[.png .gif .jpg .jpeg]\n FileUtils.cp src, dst\n else\n ::File.open(dst,'w') do |fd|\n ::File.foreach(src, \"\\n\") do |line|\n line.tr!(\"\\r\\n\",'')\n fd.puts line\n end\n end\n end\n end",
"def clear_line; print \"\\e[2K\" end",
"def delete_prev_char\n return -1 if !@editable \n return if @curpos <= 0\n # if we've panned, then unpan, and don't move cursor back\n # Otherwise, adjust cursor (move cursor back as we delete)\n adjust = true\n if @pcol > 0\n @pcol -= 1\n adjust = false\n end\n @curpos -= 1 if @curpos > 0\n delete_at\n addcol -1 if adjust # move visual cursor back\n @modified = true\n end",
"def erase_line_to_both\n ConsoleGlitter.escape('2K')\n end",
"def discard_b(event)\n @content << %Q|<tr><td></td><td></td><td><pre class=\"only_b\">#{event.new_element}</pre></td><td>#{new_line}. </td></tr>\\n|\n @new_line += 1\n end",
"def insert_after\r\n @lines.insert(@line_num, TextLineBuffer.new(\"\"))\r\n @line_num = @line_num + 1\r\n end",
"def _rl_clear_to_eol(count)\r\n if (@_rl_term_clreol)\r\n @rl_outstream.write(@_rl_term_clreol)\r\n elsif (count!=0)\r\n space_to_eol(count)\r\n end\r\n end",
"def delete_chars(count)\r\n return if (count > @_rl_screenwidth) # XXX\r\n\r\n if @hConsoleHandle.nil?\r\n #if (@_rl_term_DC)\r\n # buffer = tgoto(_rl_term_DC, count, count);\r\n # @_rl_out_stream.write(buffer * count)\r\n #else\r\n if (@_rl_term_dc)\r\n @_rl_out_stream.write(@_rl_term_dc * count)\r\n end\r\n #end\r\n end\r\n end",
"def backspace\n\t\tif @marked\n\t\t\tmark_row,row = ordered_mark_rows\n\t\t\tif @colmode\n\t\t\t\tcolumn_backspace(mark_row,row,@col)\n\t\t\telse\n\t\t\t\tcolumn_backspace(mark_row,row,1)\n\t\t\tend\n\t\telse\n\t\t\tif (@col+@row)==0\n\t\t\t\treturn\n\t\t\tend\n\t\t\tif @col == 0\n\t\t\t\tcursor_left\n\t\t\t\tmergerows(@row,@row+1)\n\t\t\t\treturn\n\t\t\tend\n\t\t\tcursor_left\n\t\t\tdelchar(@row,@col)\n\t\tend\n\tend",
"def copy_bbcode\n str = EventPrinter::BBcode::head(@event.printed_name)\n str << (@list.map { |e| e.bbcode }).join(\"\\n\")\n str << EventPrinter::BBcode::foot\n Win32API.push_text_in_clipboard(str.to_ascii << \"\\0\")\n end",
"def overwrite c, text\n pos = text =~ /\\n/\n unless pos\n if text.size > @fileContent[c.line][c.column, @fileContent[c.line].size].size\n @fileContent[c.line] = @fileContent[c.line][0, c.column] + text\n else\n @fileContent[c.line] = @fileContent[c.line][0, c.column] +\n text + @fileContent[c.line][c.column + text.size,\n @fileContent[c.line].size]\n end\n c.moveToColumn c.column + text.size\n else\n if @fileContent[c.line][c.column, @fileContent[c.line].size].size > pos\n nbToDelete = text[pos, text.size].count \"^\\n\"\n insertText c, text\n deleteTextDelete c, nbToDelete\n else\n @fileContent[c.line] = @fileContent[c.line][0, c.column] + text[0, pos]\n c.moveToColumn c.column + pos\n insertText c, text[pos, text.size]\n end\n end\n end",
"def delete_left(count = 1)\n if self.cursor_can_move_left?\n # limiting character count\n count = @cursor_position if count > @cursor_position\n # split text at cursor with one character removed left from the cursor\n chars = @text.scan(/./m)\n left = (@cursor_position > count ? chars[0, @cursor_position - count] : [])\n if @cursor_position < chars.size\n right = chars[@cursor_position, chars.size - @cursor_position]\n else\n right = []\n end\n # set cursor at right position\n @cursor_position -= count\n # put together the split halves\n self.text = (left + right).join\n self.reset_cursor_blinking\n end\n end",
"def paste(text)\n can_refresh = false\n # Attempt to insert every character individually\n text.split(\"\").each do |ch|\n break unless @helper.insert(ch)\n can_refresh = true\n end\n # Only refresh if characters were inserted\n self.refresh if can_refresh\n end",
"def deleteTextDelete c, nbToDelete = 1\n nbToDelete = deleteTextDeleteTooBig c, nbToDelete\n while @fileContent[c.line].size - c.column < nbToDelete\n nbToDelete = deleteTextDeleteConcatLine c, nbToDelete\n end\n deleteTextDeleteSameLine c, nbToDelete\n nil\n end",
"def reset_cursor\n c = get_cursor_pos\n print_area_to_buffer(@main_buffer, c[0], c[1], @last_chars)\n @last_chars = cache_area(@main_buffer,\n c[0], 1,\n c[1], 1)\n @cursor = [\"\\u2588\"]\n print_area_to_buffer(@main_buffer, c[0], c[1], @cursor)\n\n return\n end",
"def to_clipboard\n #prettified = self.pretty_inspect.strip\n prettified = self.to_s\n stringified = self.to_s\n printable = (\n if prettified.length > 80 then\n prettified.slice(0, 80) + '...'\n else\n prettified\n end\n ).inspect\n $clipboard.write(stringified)\n $stderr.puts(\"to_clipboard: wrote #{printable} to clipboard\")\n return nil\n end",
"def delete\n @text.slice!(@cursor, 1)\n end",
"def delete_after\r\n result = @buffer.delete_at(@cursor)\r\n @buffer.compact! #needed?\r\n result\r\n end",
"def clear_line\n CSI + '2K' + column(1)\n end",
"def flush_left text\n indent = 9999\n\n text.each_line do |line|\n line_indent = line =~ /\\S/ || 9999\n indent = line_indent if indent > line_indent\n end\n\n empty = ''\n empty = RDoc::Encoding.change_encoding empty, text.encoding\n\n text.gsub(/^ {0,#{indent}}/, empty)\n end",
"def remove_whitespace_before(index, buffer, rewriter, remove_preceeding_newline)\n end_pos = index\n begin_pos = end_pos - 1\n begin_pos -= 1 while code[begin_pos] =~ /\\s/ && code[begin_pos] != \"\\n\"\n begin_pos -= 1 if code[begin_pos] == \"\\n\"\n begin_pos -= 1 if code[begin_pos] == \"\\n\" && remove_preceeding_newline\n return if begin_pos.next == end_pos\n rewriter.remove Parser::Source::Range.new(buffer, begin_pos.next, end_pos)\n end",
"def apply_backspace\n end",
"def clear_all\n Terminal.move_up(previous_draw_amount_of_lines)\n Terminal.clear_screen_from_cursor\n end",
"def cmd_clip reference, description = 'TODO description'\n path = reference2path reference\n unless create_if_not_exist reference, path\n return\n end\n puts \"adding clipboard content to \" + reference\n open_vim path, :end_of_file, \n :add_line, \n :add_line, \n :append_desc, description, :add_line,\n :append_date, \n :add_line, \n :add_line, \n :inject_clipboard\n\n end",
"def move_caret_to_mouse\n # Test character by character\n 1.upto(self.text.length) do |i|\n if @window.mouse_x < x + FONT.text_width(text[0...i])\n self.caret_pos = self.selection_start = i - 1;\n return\n end\n end\n # Default case: user must have clicked the right edge\n self.caret_pos = self.selection_start = self.text.length\n end",
"def overwrite(lines, delete)\n if delete\n lines.times do\n system \"printf \\\"\\\\033[1A\\\"\"\n system \"printf \\\"\\\\033[K\\\"\"\n end\n else\n system \"printf \\\"\\\\033[#{lines}A\\\"\" # move cursor n lines up\n end\nend",
"def overwrite(lines, delete)\n if delete\n lines.times do\n system \"printf \\\"\\\\033[1A\\\"\"\n system \"printf \\\"\\\\033[K\\\"\"\n end\n else\n system \"printf \\\"\\\\033[#{lines}A\\\"\" # move cursor n lines up\n end\nend",
"def load_text(text)\n text = text.dup\n text.sub!(CTRL_V) { Yuki.get_clipboard }\n text.split(//).each do |char|\n if char == BACK\n last_char = @current_text[-1]\n @current_text.chop!\n @on_remove_char&.call(@current_text, last_char)\n elsif char.getbyte(0) >= 32 && @current_text.size < @max_size\n @current_text << char\n @on_new_char&.call(@current_text, char)\n end\n end\n self.text = (@empty_char.size > 0 ? @current_text.ljust(@max_size, @empty_char) : @current_text)\n end",
"def update_line(old, ostart, new, current_line, omax, nmax, inv_botlin)\r\n # If we're at the right edge of a terminal that supports xn, we're\r\n # ready to wrap around, so do so. This fixes problems with knowing\r\n # the exact cursor position and cut-and-paste with certain terminal\r\n # emulators. In this calculation, TEMP is the physical screen\r\n # position of the cursor.\r\n if @encoding == 'X'\r\n old.force_encoding('ASCII-8BIT')\r\n new.force_encoding('ASCII-8BIT')\r\n end\r\n\r\n if !@rl_byte_oriented\r\n temp = @_rl_last_c_pos\r\n else\r\n temp = @_rl_last_c_pos - w_offset(@_rl_last_v_pos, @visible_wrap_offset)\r\n end\r\n if (temp == @_rl_screenwidth && @_rl_term_autowrap && !@_rl_horizontal_scroll_mode &&\r\n @_rl_last_v_pos == current_line - 1)\r\n\r\n if (!@rl_byte_oriented)\r\n # This fixes only double-column characters, but if the wrapped\r\n # character comsumes more than three columns, spaces will be\r\n # inserted in the string buffer.\r\n if (@_rl_wrapped_line[current_line] > 0)\r\n _rl_clear_to_eol(@_rl_wrapped_line[current_line])\r\n end\r\n\r\n if new[0,1] != 0.chr\r\n case @encoding\r\n when 'E'\r\n wc = new.scan(/./me)[0]\r\n ret = wc.length\r\n tempwidth = wc.length\r\n when 'S'\r\n wc = new.scan(/./ms)[0]\r\n ret = wc.length\r\n tempwidth = wc.length\r\n when 'U'\r\n wc = new.scan(/./mu)[0]\r\n ret = wc.length\r\n tempwidth = wc.unpack('U').first >= 0x1000 ? 2 : 1\r\n when 'X'\r\n wc = new[0..-1].force_encoding(@encoding_name)[0]\r\n ret = wc.bytesize\r\n tempwidth = wc.ord >= 0x1000 ? 2 : 1\r\n else\r\n ret = 1\r\n tempwidth = 1\r\n end\r\n else\r\n tempwidth = 0\r\n end\r\n\r\n if (tempwidth > 0)\r\n bytes = ret\r\n @rl_outstream.write(new[0,bytes])\r\n @_rl_last_c_pos = tempwidth\r\n @_rl_last_v_pos+=1\r\n\r\n if old[ostart,1] != 0.chr\r\n case @encoding\r\n when 'E'\r\n wc = old[ostart..-1].scan(/./me)[0]\r\n ret = wc.length\r\n when 'S'\r\n wc = old[ostart..-1].scan(/./ms)[0]\r\n ret = wc.length\r\n when 'U'\r\n wc = old[ostart..-1].scan(/./mu)[0]\r\n ret = wc.length\r\n when 'X'\r\n wc = old[ostart..-1].force_encoding(@encoding_name)[0]\r\n ret = wc.bytesize\r\n end\r\n else\r\n ret = 0\r\n end\r\n if (ret != 0 && bytes != 0)\r\n if ret != bytes\r\n len = old[ostart..-1].index(0.chr,ret)\r\n old[ostart+bytes,len-ret] = old[ostart+ret,len-ret]\r\n end\r\n old[ostart,bytes] = new[0,bytes]\r\n end\r\n else\r\n @rl_outstream.write(' ')\r\n @_rl_last_c_pos = 1\r\n @_rl_last_v_pos+=1\r\n if (old[ostart,1] != 0.chr && new[0,1] != 0.chr)\r\n old[ostart,1] = new[0,1]\r\n end\r\n end\r\n\r\n else\r\n if (new[0,1] != 0.chr)\r\n @rl_outstream.write(new[0,1])\r\n else\r\n @rl_outstream.write(' ')\r\n end\r\n @_rl_last_c_pos = 1\r\n @_rl_last_v_pos+=1\r\n if (old[ostart,1] != 0.chr && new[0,1] != 0.chr)\r\n old[ostart,1] = new[0,1]\r\n end\r\n end\r\n end\r\n\r\n # Find first difference.\r\n if (!@rl_byte_oriented)\r\n # See if the old line is a subset of the new line, so that the\r\n # only change is adding characters.\r\n temp = (omax < nmax) ? omax : nmax\r\n if old[ostart,temp]==new[0,temp]\r\n ofd = temp\r\n nfd = temp\r\n else\r\n if (omax == nmax && new[0,omax]==old[ostart,omax])\r\n ofd = omax\r\n nfd = nmax\r\n else\r\n new_offset = 0\r\n old_offset = ostart\r\n ofd = 0\r\n nfd = 0\r\n while(ofd < omax && old[ostart+ofd,1] != 0.chr &&\r\n _rl_compare_chars(old, old_offset, new, new_offset))\r\n\r\n old_offset = _rl_find_next_mbchar(old, old_offset, 1, MB_FIND_ANY)\r\n new_offset = _rl_find_next_mbchar(new, new_offset, 1, MB_FIND_ANY)\r\n ofd = old_offset - ostart\r\n nfd = new_offset\r\n end\r\n end\r\n end\r\n else\r\n ofd = 0\r\n nfd = 0\r\n while(ofd < omax && old[ostart+ofd,1] != 0.chr && old[ostart+ofd,1] == new[nfd,1])\r\n ofd += 1\r\n nfd += 1\r\n end\r\n end\r\n\r\n\r\n # Move to the end of the screen line. ND and OD are used to keep track\r\n # of the distance between ne and new and oe and old, respectively, to\r\n # move a subtraction out of each loop.\r\n oe = old.index(0.chr,ostart+ofd) - ostart\r\n if oe.nil? || oe>omax\r\n oe = omax\r\n end\r\n\r\n ne = new.index(0.chr,nfd)\r\n if ne.nil? || ne>omax\r\n ne = nmax\r\n end\r\n\r\n # If no difference, continue to next line.\r\n if (ofd == oe && nfd == ne)\r\n return\r\n end\r\n\r\n\r\n wsatend = true # flag for trailing whitespace\r\n\r\n if (!@rl_byte_oriented)\r\n\r\n ols = _rl_find_prev_mbchar(old, ostart+oe, MB_FIND_ANY) - ostart\r\n nls = _rl_find_prev_mbchar(new, ne, MB_FIND_ANY)\r\n while ((ols > ofd) && (nls > nfd))\r\n\r\n if (!_rl_compare_chars(old, ostart+ols, new, nls))\r\n break\r\n end\r\n if (old[ostart+ols,1] == \" \")\r\n wsatend = false\r\n end\r\n\r\n ols = _rl_find_prev_mbchar(old, ols+ostart, MB_FIND_ANY) - ostart\r\n nls = _rl_find_prev_mbchar(new, nls, MB_FIND_ANY)\r\n end\r\n else\r\n ols = oe - 1 # find last same\r\n nls = ne - 1\r\n while ((ols > ofd) && (nls > nfd) && old[ostart+ols,1] == new[nls,1])\r\n if (old[ostart+ols,1] != \" \")\r\n wsatend = false\r\n end\r\n ols-=1\r\n nls-=1\r\n end\r\n end\r\n\r\n if (wsatend)\r\n ols = oe\r\n nls = ne\r\n elsif (!_rl_compare_chars(old, ostart+ols, new, nls))\r\n if (old[ostart+ols,1] != 0.chr) # don't step past the NUL\r\n if !@rl_byte_oriented\r\n ols = _rl_find_next_mbchar(old, ostart+ols, 1, MB_FIND_ANY) - ostart\r\n else\r\n ols+=1\r\n end\r\n end\r\n if (new[nls,1] != 0.chr )\r\n if !@rl_byte_oriented\r\n nls = _rl_find_next_mbchar(new, nls, 1, MB_FIND_ANY)\r\n else\r\n nls+=1\r\n end\r\n end\r\n end\r\n\r\n # count of invisible characters in the current invisible line.\r\n current_invis_chars = w_offset(current_line, @wrap_offset)\r\n if (@_rl_last_v_pos != current_line)\r\n _rl_move_vert(current_line)\r\n if (@rl_byte_oriented && current_line == 0 && @visible_wrap_offset!=0)\r\n @_rl_last_c_pos += @visible_wrap_offset\r\n end\r\n end\r\n\r\n # If this is the first line and there are invisible characters in the\r\n # prompt string, and the prompt string has not changed, and the current\r\n # cursor position is before the last invisible character in the prompt,\r\n # and the index of the character to move to is past the end of the prompt\r\n # string, then redraw the entire prompt string. We can only do this\r\n # reliably if the terminal supports a `cr' capability.\r\n\r\n # This is not an efficiency hack -- there is a problem with redrawing\r\n # portions of the prompt string if they contain terminal escape\r\n # sequences (like drawing the `unbold' sequence without a corresponding\r\n # `bold') that manifests itself on certain terminals.\r\n\r\n lendiff = @local_prompt_len\r\n\r\n if (current_line == 0 && !@_rl_horizontal_scroll_mode &&\r\n @_rl_term_cr && lendiff > @prompt_visible_length && @_rl_last_c_pos > 0 &&\r\n ofd >= lendiff && @_rl_last_c_pos < prompt_ending_index())\r\n @rl_outstream.write(@_rl_term_cr)\r\n _rl_output_some_chars(@local_prompt,0,lendiff)\r\n if !@rl_byte_oriented\r\n # We take wrap_offset into account here so we can pass correct\r\n # information to _rl_move_cursor_relative.\r\n @_rl_last_c_pos = _rl_col_width(@local_prompt, 0, lendiff) - @wrap_offset\r\n @cpos_adjusted = true\r\n else\r\n @_rl_last_c_pos = lendiff\r\n end\r\n end\r\n\r\n o_cpos = @_rl_last_c_pos\r\n\r\n # When this function returns, _rl_last_c_pos is correct, and an absolute\r\n # cursor postion in multibyte mode, but a buffer index when not in a\r\n # multibyte locale.\r\n _rl_move_cursor_relative(ofd, old, ostart)\r\n\r\n # We need to indicate that the cursor position is correct in the presence\r\n # of invisible characters in the prompt string. Let's see if setting this\r\n # when we make sure we're at the end of the drawn prompt string works.\r\n if (current_line == 0 && !@rl_byte_oriented &&\r\n (@_rl_last_c_pos > 0 || o_cpos > 0) &&\r\n @_rl_last_c_pos == @prompt_physical_chars)\r\n @cpos_adjusted = true\r\n end\r\n\r\n # if (len (new) > len (old))\r\n # lendiff == difference in buffer\r\n # col_lendiff == difference on screen\r\n # When not using multibyte characters, these are equal\r\n lendiff = (nls - nfd) - (ols - ofd)\r\n if !@rl_byte_oriented\r\n col_lendiff = _rl_col_width(new, nfd, nls) - _rl_col_width(old, ostart+ofd, ostart+ols)\r\n else\r\n col_lendiff = lendiff\r\n end\r\n\r\n # If we are changing the number of invisible characters in a line, and\r\n # the spot of first difference is before the end of the invisible chars,\r\n # lendiff needs to be adjusted.\r\n if (current_line == 0 && !@_rl_horizontal_scroll_mode &&\r\n current_invis_chars != @visible_wrap_offset)\r\n if !@rl_byte_oriented\r\n lendiff += @visible_wrap_offset - current_invis_chars\r\n col_lendiff += @visible_wrap_offset - current_invis_chars\r\n else\r\n lendiff += @visible_wrap_offset - current_invis_chars\r\n col_lendiff = lendiff\r\n end\r\n end\r\n\r\n # Insert (diff (len (old), len (new)) ch.\r\n temp = ne - nfd\r\n if !@rl_byte_oriented\r\n col_temp = _rl_col_width(new,nfd,ne)\r\n else\r\n col_temp = temp\r\n end\r\n if (col_lendiff > 0) # XXX - was lendiff\r\n\r\n # Non-zero if we're increasing the number of lines.\r\n gl = current_line >= @_rl_vis_botlin && inv_botlin > @_rl_vis_botlin\r\n\r\n # If col_lendiff is > 0, implying that the new string takes up more\r\n # screen real estate than the old, but lendiff is < 0, meaning that it\r\n # takes fewer bytes, we need to just output the characters starting from\r\n # the first difference. These will overwrite what is on the display, so\r\n # there's no reason to do a smart update. This can really only happen in\r\n # a multibyte environment.\r\n if lendiff < 0\r\n _rl_output_some_chars(new, nfd, temp)\r\n @_rl_last_c_pos += _rl_col_width(new, nfd, nfd+temp)\r\n\r\n # If nfd begins before any invisible characters in the prompt, adjust\r\n # _rl_last_c_pos to account for wrap_offset and set cpos_adjusted to\r\n # let the caller know.\r\n if current_line == 0 && @wrap_offset && nfd <= @prompt_last_invisible\r\n @_rl_last_c_pos -= @wrap_offset\r\n @cpos_adjusted = true\r\n end\r\n return\r\n # Sometimes it is cheaper to print the characters rather than\r\n # use the terminal's capabilities. If we're growing the number\r\n # of lines, make sure we actually cause the new line to wrap\r\n # around on auto-wrapping terminals.\r\n elsif (@_rl_terminal_can_insert && ((2 * col_temp) >= col_lendiff || @_rl_term_IC) && (!@_rl_term_autowrap || !gl))\r\n\r\n # If lendiff > prompt_visible_length and _rl_last_c_pos == 0 and\r\n # _rl_horizontal_scroll_mode == 1, inserting the characters with\r\n # _rl_term_IC or _rl_term_ic will screw up the screen because of the\r\n # invisible characters. We need to just draw them.\r\n if (old[ostart+ols,1] != 0.chr && (!@_rl_horizontal_scroll_mode || @_rl_last_c_pos > 0 ||\r\n lendiff <= @prompt_visible_length || current_invis_chars==0))\r\n\r\n insert_some_chars(new[nfd..-1], lendiff, col_lendiff)\r\n @_rl_last_c_pos += col_lendiff\r\n elsif ((@rl_byte_oriented) && old[ostart+ols,1] == 0.chr && lendiff > 0)\r\n # At the end of a line the characters do not have to\r\n # be \"inserted\". They can just be placed on the screen.\r\n # However, this screws up the rest of this block, which\r\n # assumes you've done the insert because you can.\r\n _rl_output_some_chars(new,nfd, lendiff)\r\n @_rl_last_c_pos += col_lendiff\r\n else\r\n _rl_output_some_chars(new,nfd, temp)\r\n @_rl_last_c_pos += col_temp\r\n # If nfd begins before any invisible characters in the prompt, adjust\r\n # _rl_last_c_pos to account for wrap_offset and set cpos_adjusted to\r\n # let the caller know.\r\n if current_line == 0 && @wrap_offset && nfd <= @prompt_last_invisible\r\n @_rl_last_c_pos -= @wrap_offset\r\n @cpos_adjusted = true\r\n end\r\n return\r\n end\r\n # Copy (new) chars to screen from first diff to last match.\r\n temp = nls - nfd\r\n if ((temp - lendiff) > 0)\r\n _rl_output_some_chars(new,(nfd + lendiff),temp - lendiff)\r\n # XXX -- this bears closer inspection. Fixes a redisplay bug\r\n # reported against bash-3.0-alpha by Andreas Schwab involving\r\n # multibyte characters and prompt strings with invisible\r\n # characters, but was previously disabled.\r\n @_rl_last_c_pos += _rl_col_width(new,nfd+lendiff, nfd+lendiff+temp-col_lendiff)\r\n end\r\n else\r\n # cannot insert chars, write to EOL\r\n _rl_output_some_chars(new,nfd, temp)\r\n @_rl_last_c_pos += col_temp\r\n # If we're in a multibyte locale and were before the last invisible\r\n # char in the current line (which implies we just output some invisible\r\n # characters) we need to adjust _rl_last_c_pos, since it represents\r\n # a physical character position.\r\n end\r\n else # Delete characters from line.\r\n # If possible and inexpensive to use terminal deletion, then do so.\r\n if (@_rl_term_dc && (2 * col_temp) >= -col_lendiff)\r\n\r\n # If all we're doing is erasing the invisible characters in the\r\n # prompt string, don't bother. It screws up the assumptions\r\n # about what's on the screen.\r\n if (@_rl_horizontal_scroll_mode && @_rl_last_c_pos == 0 &&\r\n -lendiff == @visible_wrap_offset)\r\n col_lendiff = 0\r\n end\r\n\r\n if (col_lendiff!=0)\r\n delete_chars(-col_lendiff) # delete (diff) characters\r\n end\r\n\r\n # Copy (new) chars to screen from first diff to last match\r\n temp = nls - nfd\r\n if (temp > 0)\r\n # If nfd begins at the prompt, or before the invisible characters in\r\n # the prompt, we need to adjust _rl_last_c_pos in a multibyte locale\r\n # to account for the wrap offset and set cpos_adjusted accordingly.\r\n _rl_output_some_chars(new,nfd, temp)\r\n if !@rl_byte_oriented\r\n @_rl_last_c_pos += _rl_col_width(new,nfd,nfd+temp)\r\n if current_line == 0 && @wrap_offset && nfd <= @prompt_last_invisible\r\n @_rl_last_c_pos -= @wrap_offset\r\n @cpos_adjusted = true\r\n end\r\n else\r\n @_rl_last_c_pos += temp\r\n end\r\n end\r\n\r\n # Otherwise, print over the existing material.\r\n else\r\n if (temp > 0)\r\n # If nfd begins at the prompt, or before the invisible characters in\r\n # the prompt, we need to adjust _rl_last_c_pos in a multibyte locale\r\n # to account for the wrap offset and set cpos_adjusted accordingly.\r\n _rl_output_some_chars(new,nfd, temp)\r\n @_rl_last_c_pos += col_temp # XXX\r\n if !@rl_byte_oriented\r\n if current_line == 0 && @wrap_offset && nfd <= @prompt_last_invisible\r\n @_rl_last_c_pos -= @wrap_offset\r\n @cpos_adjusted = true\r\n end\r\n end\r\n end\r\n\r\n lendiff = (oe) - (ne)\r\n if !@rl_byte_oriented\r\n col_lendiff = _rl_col_width(old, ostart, ostart+oe) - _rl_col_width(new, 0, ne)\r\n else\r\n col_lendiff = lendiff\r\n end\r\n\r\n if (col_lendiff!=0)\r\n if (@_rl_term_autowrap && current_line < inv_botlin)\r\n space_to_eol(col_lendiff)\r\n else\r\n _rl_clear_to_eol(col_lendiff)\r\n end\r\n end\r\n end\r\n end\r\n end",
"def rl_revert_line(count, key)\r\n if @rl_undo_list.nil?\r\n rl_ding()\r\n else\r\n while (@rl_undo_list)\r\n rl_do_undo()\r\n end\r\n if (@rl_editing_mode == @vi_mode)\r\n @rl_point = @rl_mark = 0 # rl_end should be set correctly\r\n end\r\n end\r\n 0\r\n end",
"def flush_left text\n indents = []\n\n text.each_line do |line|\n indents << (line =~ /[^\\s]/ || 9999)\n end\n\n indent = indents.min\n\n flush = []\n\n text.each_line do |line|\n line[/^ {0,#{indent}}/] = ''\n flush << line\n end\n\n flush.join\n end",
"def ti_delete_line\n\ttictl(\"dl\")\n end",
"def clear_line!\n print \"\\r\\e[2K\"\n end",
"def pbpaste\n Clipboard.paste\nend",
"def clear\n\n # remove the trailing newline, otherwise an upper line will get eaten\n @rendered.sub!(/\\n\\z/, '')\n\n # determine how many lines to move up\n lines = @rendered.scan(/\\n/).length\n\n if @bottomline\n print IOChar.cursor_down + IOChar.carriage_return + IOChar.clear_line + IOChar.cursor_up\n end\n\n # jump back to the first position and clear the line\n print IOChar.cursor_down + IOChar.carriage_return + IOChar.clear_line + IOChar.cursor_up + IOChar.clear_line + IOChar.carriage_return + ( IOChar.cursor_up + IOChar.clear_line ) * lines + IOChar.clear_line\n end",
"def adjust(val)\n val.gsub!(/\\n/, ' ')\n val.strip!\n end",
"def remove_lines(text)\n text.gsub(/\\n/, '')\n end",
"def paste_from_clipboard(page_id, element, method, position)\n element_copy = copy(element, :page_id => page_id)\n element_copy.insert_at(position)\n if method == \"move\" && element_copy.valid?\n element.destroy\n end\n element_copy\n end",
"def endclip\n pop\n end",
"def move_caret(mouse_x)\n 1.upto(text.length) do |i|\n if mouse_x < x + @font.text_width(text[0...i])\n self.caret_pos = self.selection_start = i - 1\n return\n end\n end\n self.caret_pos = self.selection_start = text.length\n end",
"def wclrtobot\n Ncurses.wclrtobot(pointer)\n end",
"def killLine buffer\n if @frames[buffer].lastCmd.start_with? \"Kill\"\n killLineConcat buffer\n else\n killLineNewEntry buffer\n end\n @frames[buffer].updateLastCmd \"KillLine\"\n @killRingPosition = 0\n end",
"def copyFromClipboard \n \"copyFromClipboard\" \n end",
"def rl_kill_line (direction, ignore)\r\n if (direction < 0)\r\n return (rl_backward_kill_line(1, ignore))\r\n else\r\n orig_point = @rl_point\r\n rl_end_of_line(1, ignore)\r\n if (orig_point != @rl_point)\r\n rl_kill_text(orig_point, @rl_point)\r\n end\r\n @rl_point = orig_point\r\n if (@rl_editing_mode == @emacs_mode)\r\n @rl_mark = @rl_point\r\n end\r\n end\r\n 0\r\n end",
"def restore_cursor; puts \"\\e[u\" end",
"def space_to_eol(count)\r\n if @hConsoleHandle\r\n csbi = 0.chr * 24\r\n @GetConsoleScreenBufferInfo.Call(@hConsoleHandle,csbi)\r\n cursor_pos = csbi[4,4].unpack('L').first\r\n written = 0.chr * 4\r\n @FillConsoleOutputCharacter.Call(@hConsoleHandle,0x20,count,cursor_pos,written)\r\n else\r\n @rl_outstream.write(' ' * count)\r\n end\r\n @_rl_last_c_pos += count\r\n end"
] | [
"0.67969537",
"0.6596287",
"0.6181221",
"0.6146281",
"0.6015248",
"0.5967393",
"0.59610367",
"0.5960387",
"0.5933118",
"0.59182364",
"0.5839885",
"0.57057226",
"0.5688946",
"0.56852984",
"0.5641738",
"0.561514",
"0.5598298",
"0.5547041",
"0.55289435",
"0.54814607",
"0.5476521",
"0.54724455",
"0.5463303",
"0.54461473",
"0.54461473",
"0.54300565",
"0.5406074",
"0.5393307",
"0.53929806",
"0.538209",
"0.53753597",
"0.5363992",
"0.5353788",
"0.53507495",
"0.5346524",
"0.5335927",
"0.5328448",
"0.53209627",
"0.52689314",
"0.5248093",
"0.5241526",
"0.52364767",
"0.5230382",
"0.52076703",
"0.52033985",
"0.51945984",
"0.51934946",
"0.5183096",
"0.5174905",
"0.51679415",
"0.51630646",
"0.5149049",
"0.5148826",
"0.51454085",
"0.51330394",
"0.5124755",
"0.51127195",
"0.5109217",
"0.51060504",
"0.5090441",
"0.50821245",
"0.5079187",
"0.5079091",
"0.50748515",
"0.5073075",
"0.50705963",
"0.5038351",
"0.50349194",
"0.5024289",
"0.50170845",
"0.5010439",
"0.50094765",
"0.5005186",
"0.50046945",
"0.5001736",
"0.4989012",
"0.49847382",
"0.4984649",
"0.49811718",
"0.49811652",
"0.49811652",
"0.49638805",
"0.49593136",
"0.49516028",
"0.4940947",
"0.49394062",
"0.49382237",
"0.49371472",
"0.49299893",
"0.49223936",
"0.49208587",
"0.49169326",
"0.4916783",
"0.49116623",
"0.49052456",
"0.4903372",
"0.490187",
"0.48838738",
"0.48760954",
"0.4871081"
] | 0.67587405 | 1 |
expand set to false (default) means that subnodes will not be drawn | def initialize(*params, &block)
@expand = false
super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expand\n expanding_vertices, @apical_vertices, @dist_thresh = @apical_vertices.clone, [], @dist_thresh.next\n expanding_vertices.each {|vertex| merge_with_edges(generate_subgraph(vertex))}\n self\n end",
"def expand\n @state.neighbors.map{|n|\n AStarNode.new(n, self)\n }\n end",
"def expand_children node=:current_index\n $multiplier = 999 if !$multiplier || $multiplier == 0\n node = row_to_node if node == :current_index\n return if node.children.empty? # or node.is_leaf?\n #node.children.each do |e| \n #expand_node e # this will keep expanding parents\n #expand_children e\n #end\n node.breadth_each($multiplier) do |e|\n expand_node e\n end\n $multiplier = 0\n _structure_changed true\n end",
"def TreeView_Expand(hwnd, hitem, code) send_treeview_message(hwnd, TVM_EXPAND, wparam: code, lparam: hitem) end",
"def show\n @new = false\n @single = true\n @width = @height = 150\n @vw = 80\n @vh = 40\n @vx = @tree.x - @vw/2\n @vy = @tree.y - @vh/2\n \n end",
"def expand(current_node)\r\n x = current_node.x\r\n y = current_node.y\r\n return [ Astar_Node.new(x, y-1, @closed_nodes.size-1, -1, -1, -1), # north\r\n Astar_Node.new(x, y+1, @closed_nodes.size-1, -1, -1, -1), # south\r\n Astar_Node.new(x+1, y, @closed_nodes.size-1, -1, -1, -1), # east\r\n Astar_Node.new(x-1, y, @closed_nodes.size-1, -1, -1, -1) ] # west\r\n end",
"def mark_parents_expanded node\n # i am setting parents as expanded, but NOT firing handlers - XXX separate this into expand_parents\n _path = node.tree_path\n _path.each do |e|\n # if already expanded parent then break we should break\n set_expanded_state(e, true)\n end\n end",
"def expand(current_node)\n x = current_node.x\n y = current_node.y\n\n return [ [x, (y - 1)], # north\n [x, (y + 1)], # south\n [(x + 1), y], # east\n [(x - 1), y] ] # west\n end",
"def expand\n end",
"def collapse!\n\t self.pre_order do |n|\n\t if n!=self\n\t while n.placements.length > 0\n\t\t p = Node.unlink_placement(n.placements[0])\n\t\t p.set_field_value('edge_num', self.index)\n\t\t Node.link_placement(p)\n\t end\n\t end\n\t end\n\t @collapsed = true\n end",
"def expand_node(id)\n wait_for_ajax do\n page.driver.browser.execute_script(<<-JS)\n Ext.ComponentQuery.query('treepanel')[0].getStore().getNodeById('#{id}').expand();\n JS\n end\n end",
"def expand_parents node\n _path = node.tree_path\n _path.each do |e|\n # if already expanded parent then break we should break\n #set_expanded_state(e, true) \n expand_node(e)\n end\n end",
"def show_tree\n\t\t@root_node.show\n\tend",
"def autoexpand?\n false\n end",
"def expand\n move = @untried_moves.pop\n create_child(move)\n end",
"def x_show\n @explorer = true\n tree_select\n end",
"def expand_first_row\n @tree.expand_first_row\n end",
"def draw_children\n first = true\n @children.each do |child|\n child.draw(1, first)\n first = false\n end\n puts '└──'\n end",
"def expand(dx, dy = dx)\n return clone.expand!(dx, dy)\n end",
"def fully_expanded?\n @unexpanded.empty? && (\n self.is_root? || parent.fully_expanded?\n )\n end",
"def expand_current(nodes, klass)\n nodes.each {|node| node.old_parent = node.parent }\n list = klass.new(nodes)\n list.parent = self\n @nodes[@pos] = list\n end",
"def expand_depth(node) #:nodoc:\n relations_for(node).each do |rel|\n yield_node(rel)\n\n expand_node(rel) unless @description.prune_node?(rel)\n end\n end",
"def expand(problem)\n # \"Return a list of nodes reachable from this node. [Fig. 3.8]\"\n expand = []\n #bpoint\n problem.successor(@state).each do | action_succ |\n act = action_succ[0]\n next_act = action_succ[1]\n expand << Node.new(next_act, self, act,problem.path_cost(@path_cost, @state, act, next_act))\n end\n return expand\n end",
"def expand!\n if attributes.nil?\n @attributes = {}\n if @parent\n @parent.expand!\n\n @parent.send(:\"_#{@path.last}=\", self)\n end\n end\n end",
"def setup\n size(800, 200)\n new_tree\nend",
"def is_leaf\n true\n end",
"def is_leaf\n true\n end",
"def repaint graphic, r=@row,c=@col, row_index=-1, treearraynode=nil, value=@text, leaf=nil, focussed=false, selected=false, expanded=false\n #$log.debug \"label :#{@text}, #{value}, #{r}, #{c} col= #{@color}, #{@bgcolor} acolor= #{acolor} j:#{@justify} dlL: #{@display_length} \"\n\n prepare_default_colors focussed, selected\n\n value=value.to_s # ??\n #icon = object.is_leaf? ? \"-\" : \"+\"\n #icon = leaf ? \"-\" : \"+\"\n\n #level = treearraynode.level\n #node = treearraynode.node\n level = treearraynode.level\n node = treearraynode\n if parent.node_expanded? node\n icon = PLUS_MINUS # can collapse\n else\n icon = PLUS_PLUS # can expand\n end\n if node.children.size == 0\n icon = PLUS_Q # either no children or not visited yet\n if parent.has_been_expanded node\n icon = PLUS_MINUS # definitely no children, we've visited\n end\n end\n # adding 2 to level, that's the size of icon\n # XXX FIXME if we put the icon here, then when we scroll right, the icon will show, it shoud not\n # FIXME we ignore truncation etc on previous level and take the object as is !!!\n _value = \"%*s %s\" % [ level+2, icon, node.user_object ]\n @actual_length = _value.length\n pcol = @pcol\n if pcol > 0\n _len = @display_length || @parent.width-2\n _value = _value[@pcol..@pcol+_len-1] \n end\n _value ||= \"\"\n if @height && @height > 1\n else\n # ensure we do not exceed\n if !@display_length.nil?\n if _value.length > @display_length\n @actual_length = _value.length\n _value = _value[0..@display_length-1]\n end\n end\n #lablist << value\n end\n len = @display_length || _value.length\n graphic.printstring r, c, \"%-*s\" % [len, _value], @color_pair,@attr\n #_height = @height || 1\n #0.upto(_height-1) { |i| \n #graphic.printstring r+i, c, ( \" \" * len) , @color_pair,@attr\n #}\n #lablist.each_with_index do |_value, ix|\n #break if ix >= _height\n #if @justify.to_sym == :center\n #padding = (@display_length - _value.length)/2\n #_value = \" \"*padding + _value + \" \"*padding # so its cleared if we change it midway\n #end\n #graphic.printstring r, c, str % [len, _value], @color_pair,@attr\n #r += 1\n #end\n end",
"def setVisibleIfTreeCollapsed _obj, _args\n \"_obj setVisibleIfTreeCollapsed _args;\" \n end",
"def expanded; end",
"def expand_all_panels\n @default_panel_state = :expanded\n end",
"def expand_fully\n expansion_level = 0\n while !expanded? && expansion_level < MAX_EXPANSION_LEVEL\n expansion_level += 1\n expand\n end\n end",
"def show_tree\n\tend",
"def expandable?\n options[:expandable]\n end",
"def update_nodes\n incr = 0\n self.nodes.build(:displayed => true) if not new_record? and self.nodes.count == 0 # Insure at least 1 node\n self.nodes.each do |node|\n node.title = name\n node.menu_name = name\n node.set_safe_shortcut(\"#{incr.to_s}-#{name}\")\n node.displayed = display\n incr += 1\n end\n end",
"def preserve_children?\n false\n end",
"def with_rows_and_height\n root = self\n queue = [root]\n visited = []\n\n until queue.empty?\n current = queue.shift\n adjacency_list = current.children\n\n self.height += 1\n adjacency_list.each do |node|\n root.rows << (node.nil? ? \"x\" : node.value)\n next if node.nil?\n visited << node.value\n\n if node.distance == Float::INFINITY\n node.distance = current.distance + 1\n node.parent = current\n queue.push(node)\n end\n end\n end\n\n self\n end",
"def will_expand_action node\n path = File.join(*node.user_object_path)\n dirs = _directories path\n ch = node.children\n # add only children that may not be there\n ch.each do |e| \n o = e.user_object\n if dirs.include? o\n dirs.delete o\n else\n # delete this child since its no longer present TODO\n end\n end\n node.add dirs\n path_expanded path\n end",
"def leaf?; false end",
"def nodes; end",
"def nodes; end",
"def nodes; end",
"def vis(prefix=\"\")\n puts \"#{prefix}row #{cells.inspect.to_s}\"\n children.each{|c| c.vis(prefix + \" \")}\n end",
"def expand_graph_adj(vertex, pass = nil)\n m = $game_map\n add_vertex(vertex)\n \n tp = vertex.x == 21 && vertex.y == 5\n \n t = Time.now\n vx,vy = vertex.x, vertex.y\n return if !MoveUtils.ev_passable?(vx,vy, @source)\n \n ([Vertex.new(vx-1,vy, m.terrain_tag(vx-1,vy)),Vertex.new(vx,vy-1, m.terrain_tag(vx,vy-1))]).each_with_index do |v,i|\n next if !@verticies[v]\n x,y = v.x,v.y\n dir = (i+1)*4\n ev_pass = MoveUtils.ev_passable?(x,y,@source)\n next if !ev_pass\n add_edge(vertex, v, {} , opp_dir(dir), dir)\n end\n end",
"def update_nodes\n incr = 0\n self.original_nodes.build(:displayed => true) if not new_record? and self.original_nodes.count == 0 # Insure at least 1 node\n self.original_nodes.each do |node|\n node.title = self.name\n node.menu_name = self.name\n incr = (node.new_record? ? node.set_safe_shortcut(self.name.parameterize.html_safe, 0, incr) : node.set_safe_shortcut(self.name.parameterize.html_safe, node.id, incr))\n node.displayed = self.display\n incr += 1\n end\n end",
"def pin_true_nodes\n r = []\n @start_nodes.each {|n| n.pin(r) }\n @start_nodes = r\n\n # consisitency check\n @start_nodes.each do |n|\n raise unless n.parents.empty?\n next if n.children.empty?\n raise if n.children.size == 1\n raise if n.children.any? {|cc| cc.pinned }\n end\n\n # remove unused nodes\n @start_nodes.reject! {|n| n.children.empty? }\n end",
"def leaf?\n true\n end",
"def expand!(dx, dy)\n min = Point.new(@min.x - dx, @min.y - dy)\n max = Point.new(@max.x + dx, @max.y + dy)\n initialize(min, max)\n return self\n end",
"def vis(prefix=\"\")\n puts \"#{prefix}group\"\n children.each{|c| c.vis(prefix + \" \")}\n end",
"def nodes_field\n define_nodes_field\n end",
"def apply_children\n \n end",
"def needs_redraw?; end",
"def rearrange_children!\n @rearrange_children = true\n end",
"def growing\n new_outer_nodes = []\n @outer_nodes.each do |o_n|\n new_partial_outer_nodes = set_outer_nodes(@neighbors_hash[o_n])\n new_outer_nodes << check_partial_outer_nodes(new_partial_outer_nodes, o_n)\n new_outer_nodes.flatten!\n end\n @outer_nodes = new_outer_nodes.compact\n end",
"def draw(root)\n end",
"def set_expanded_view\n session[:view] = 'expanded'\n end",
"def expand!\n @children = {}\n for child in Dir[\"#{@target}/*\"]\n name = File.basename child\n @children[name] = Symlink::Node.new name, child\n end\n @target = nil\n end",
"def draw_tree(pen, length)\n\tangle = 20\n\tmin_length = 4\n\tshrink_rate = 0.7\n\treturn if length < min_length\n\tpen.move length\n\tpen.turn_left angle\n\tdraw_tree pen, length * shrink_rate\n\tpen.turn_right angle * 2\n\tdraw_tree pen, length * shrink_rate\n\tpen.turn_left angle\n\tpen.move -length\nend",
"def refresh()\n self.contents.clear\n @cLevelUpLabel.draw()\n end",
"def expand!(expansion)\n case expansion\n when Rectangle\n self.x -= expansion.width\n self.y -= expansion.height\n self.width += 2*expansion.width\n self.height += 2*expansion.height\n when Fixnum, Float\n self.x -= expansion\n self.y -= expansion\n self.width += 2*expansion\n self.height += 2*expansion\n else raise \"Can't expand, without a valid Rectangle or constant Fixnum!\"\n end\n self # Return self expanded rectangle\n end",
"def default_layout(width=@width, height=@height)\n if @nodes.length > 0\n set_static_nodes(width,height)\n static_wheel_nodes(width,height)\n fruchterman_reingold(100,width,height) #fast, little bit of layout for now\n normalize_graph(width,height)\n #do_kamada_kawai\n else\n @notice = NO_ITEM_ERROR\n end\n end",
"def draw\n @parent.mask(:y) do \n parent_box = @parent.bounds \n @parent.bounds = self \n @parent.y = absolute_top\n @action.call \n @parent.bounds = parent_box\n end\n end",
"def draw\n\t\t#puts \"Node#draw : #{@node_x}, #{@node_y}\"\n\t\t#puts \"Node#draw: str_pos: \" + @str_pos.to_s\n\t\tpushStyle\n\t\t\tno_stroke\n\t\t\tfill 40, 50, 70\n\t\t\tellipse(@node_x, @node_y, @@node_size, @@node_size)\n\t\tpopStyle\n\tend",
"def show_node(tree, node)\n print \"ID:#{node.id} Parent:#{node.parent} Keys:\"\n node.keys.each { |key| print \"[#{key}]\"}\n print \" Sub trees:\"\n node.sub_trees.each { |sub_tree| print \"-#{sub_tree}-\"}\n print \"\\n\"\n node.sub_trees.compact.each { |sub_tree| show_node(tree, tree.nodes[sub_tree])}\nend",
"def needs_redraw?\n true \n end",
"def highlight\n\t\tpushStyle\n\t\t\tno_stroke\n\t\t\tfill 14, 70, 70\n\t\t\tellipse(@node_x, @node_y, @@node_size + @@expand, @@node_size + @@expand)\n\t\tpopStyle\n\tend",
"def full?\r\n\t\tif nodes?\r\n\t\t\tnodes.each { |node|\r\n\t\t\t\tif node == nil\r\n\t\t\t\t\treturn false\r\n\t\t\t\tend\r\n\t\t\t}\r\n\t\tend\r\n\t\t\r\n\t\treturn true\r\n\tend",
"def leafify(n)\n n.extend(Leaf)\n end",
"def should_collapse?\n true\n end",
"def has_children?\n @nodes && [email protected]?\n end",
"def redraw_tree?\n ### DISCUSS: how to set this flag from outside?\n params[:reload_tree] || false\n end",
"def redraw_tree?\n ### DISCUSS: how to set this flag from outside?\n params[:reload_tree] || false\n end",
"def empty\n delete_old_nodes 0\n end",
"def global_expand\n DrawExt::Merio.snapshot do\n snapshot do\n DrawExt::Merio.copy_settings(self)\n yield self\n end\n end\n end",
"def guidance_text_expanded?\n has_expanded_root?\n end",
"def draw(graph, options = {})\n node = graph.add_nodes(name ? name.to_s : 'nil',\n label: description(options),\n width: '1',\n height: '1',\n shape: final? ? 'doublecircle' : 'ellipse')\n\n # Add open arrow for initial state\n graph.add_edges(graph.add_nodes('starting_state', shape: 'point'), node) if initial?\n\n true\n end",
"def test_slide_1\n TaxonName.slide(2, 3)\n assert_equal 6, @child_middle.reload.l\n TaxonName.slide(-2, 3)\n assert @root_node.reload.check_subtree\n end",
"def disp_node(node, depth)\n# mon_string = ''\n# depth.times {mon_string+=' '}\n# mon_string += \"- #{node.name}\"\n# `echo \"#{mon_string}\" >> toto.txt`\n\n # depth.times {print ' '}\n # puts \"- #{node.name}\"\n self.graph.each_adjacent node do |adj_node|\n disp_node adj_node, depth+1\n end\n end",
"def child_node; end",
"def expand_into plan:\n plan PlanningDSL.new(plan: plan, action: self)\n end",
"def draw_node(dx, dy, x, y, connections, type, scale)\n draw_x = dx + x*$node_size + $node_size / 2.0\n draw_y = dy + y*$node_size + $node_size / 2.0\n Node.create({:x => draw_x, :y => draw_y, :factor_x => scale, :factor_y => scale}, type)\n n, s, e, w = connections.values\n OutConnector.create(:x => draw_x, :y => draw_y,:angle => 0, :factor_x => scale, :factor_y => scale) if n == 1\n OutConnector.create(:x => draw_x, :y => draw_y,:angle => 180, :factor_x => scale, :factor_y => scale) if s == 1\n OutConnector.create(:x => draw_x, :y => draw_y,:angle => 90, :factor_x => scale, :factor_y => scale) if e == 1\n OutConnector.create(:x => draw_x, :y => draw_y,:angle => 270, :factor_x => scale, :factor_y => scale) if w == 1\n InConnector.create(:x => draw_x, :y => draw_y,:angle => 0, :factor_x => scale, :factor_y => scale) if n == 2\n InConnector.create(:x => draw_x, :y => draw_y,:angle => 180, :factor_x => scale, :factor_y => scale) if s == 2\n InConnector.create(:x => draw_x, :y => draw_y,:angle => 90, :factor_x => scale, :factor_y => scale) if e == 2\n InConnector.create(:x => draw_x, :y => draw_y,:angle => 270, :factor_x => scale, :factor_y => scale) if w == 2\n end",
"def draw_tree\n result = ''\n max_cols = @n + 1\n calc_tree.each do |row|\n print = ' ' * ((max_cols - row.length) / 2) * max_cols\n print << row.join(' ')\n result << \"#{print}\\n\"\n end\n puts result\n end",
"def children(reload=false)\n reload = true if !@children\n reload ? child_nodes(true) : @children\n end",
"def children\n new_board = Array(3) { Array (3) }\n root = PolyTreeNode.new(new_board)\n possible_moves =\n end\nend",
"def recurse_nodes(parent_names, source_tmp_geo_area)\n if parent_names.count > 1\n parents = parent_names.dup # Tricky! \n name = parents.shift\n puts \"building internal node: #{name} : #{parents} \"\n add_item(\n name: name,\n parent_names: parents,\n source_table: source_tmp_geo_area.source_table,\n source_table_gid: source_tmp_geo_area.source_table_gid,\n is_internal_node: true\n )\n recurse_nodes(parents, source_tmp_geo_area)\n end\n end",
"def children\n # find array of empty positions on board (children candidates)\n\n # create node by duping board and putting next_mover_mark in one of the empty positions\n\n end",
"def build_nodes!\n @nodes.sort_by(&:key).each { |node| add_node(@graph, node) }\n end",
"def build_nodes!\n @nodes.sort_by(&:key).each { |node| add_node(@graph, node) }\n end",
"def leaf?; @leaf; end",
"def expand_properties\n @properties.each do |key,value|\n value.expand_to_element self\n end\n end",
"def expand(n)\n # Nothing to do.\n end",
"def on_pop(node)\n child = node.children.first\n\n node.update(:expand, [\n child,\n AST::Node.new(:nop, [], node.metadata)\n ], nil)\n end",
"def update\n @node.setTranslateX @node.getTranslateX + @vX\n @node.setTranslateY @node.getTranslateY + @vY\n end",
"def expand state\n @map.adjacent(state[:city]).map do |c|\n {\n city: c,\n path: state[:path] + [c],\n depth: state[:depth] + 1,\n cost: state[:cost] + state[:city].distance_to(c)\n }\n end\n end",
"def nodes()\n self.root.nodes()\n end",
"def facet_tree_node_row(id_base, id, parent_id, indent_level, start_shown, label, num_objects, start_open)\n\t state = \"collapsed\"\n\t state = \"expanded\" if start_shown && start_open\n\t\thtml = \"<tr data-category='#{id_base}' data-id='#{id}' data-parent-id='#{parent_id}' class='category-btn #{state} #{'hidden' if !start_shown}'>\"\n\t\thtml += \"<td class='limit_to_lvl#{indent_level}'>\"\n\t\thtml += \"<span class='exp-arrow #{\"hidden\" if start_open}'>#{image_tag('arrow.gif')}</span>\"\n\t\thtml += \"<span class='col-arrow #{\"hidden\" if !start_open}'>#{image_tag('arrow_dn.gif')}</span>\"\n\t\thtml += \"<span class='nav_link' >#{h(label)}</span></td><td class='num_objects'>#{num_objects}</td></tr>\\n\"\n\t\treturn raw(html)\n\tend",
"def test_expand_provider_suffix\r\n\r\n provider_profile_url =PropertiesReader.get_provider_profile_url\r\n @place_holder.login_goto_profile(provider_profile_url)\r\n\r\n @place_holder.add_to_or_view_on_graph('initially after adding the nodes on graph')\r\n\r\n actual_initial_node_count = @place_holder.get_actual_node_count\r\n\r\n # Verify that the initial node count on the graph matches\r\n message = \"initial node count for the profile #{@provider_node_message} before expansion\"\r\n @place_holder.assert_actual_node_count(PropertiesReader.get_expected_initial_node_count, message)\r\n\r\n suffix_node_message = PropertiesReader.get_suffix_node_message\r\n suffix_node_vertex_id = PropertiesReader.get_suffix_node_vertex_id\r\n @place_holder.expand_node(suffix_node_vertex_id, suffix_node_message)\r\n\r\n # These verifications are removed until the data dependency is reduced by adding framework support to identify the graph nodes using an attribute\r\n begin\r\n ## Make sure the expected nodes are initially added onto the graph so the assertion after the expansion for the existence of the nodes\r\n ## below would not be invalid\r\n #@place_holder.assert_nodes_on_provider_graph\r\n #\r\n #provider_node = get_provider_node\r\n #@place_holder.print_element_coordinates(provider_node, 'provider node prior to the expansion')\r\n #\r\n #\r\n #expand_recipient_95_context_item = ContextMenuItems::EXPAND_RECIPIENT_95_CONTEXT_ID\r\n #\r\n #expand_resultant_node_vertex_id = PropertiesReader.get_expand_resultant_node_vertex_id\r\n #expand_resultant_node_vertex_message = PropertiesReader.get_expand_resultant_node_vertex_message\r\n #\r\n ## Make sure the node doesn't exist prior to the expansion to make sure the assertion below (for the existence of this node to be true) would be valid\r\n #@place_holder.assert_node_existence_on_graph(expand_resultant_node_vertex_id, false, \"existence of the node as a results of expanding the node: <#{expand_resultant_node_vertex_message}> on <#{expand_recipient_95_context_item} > that is expected to be added on the graph prior to the expansion to make sure the assertion below expansion for its existence true to be valid \")\r\n #\r\n #\r\n ## Verify that the expected node is added to the graph after the expansion\r\n #@place_holder.assert_node_existence_on_graph(expand_resultant_node_vertex_id, true, \"this node is added to the graph as a results of expanding the node: <#{expand_resultant_node_vertex_message}> on<#{expand_recipient_95_context_item} >\")\r\n #@place_holder.assert_equal(provider_initial_coordinates, provider_post_expansion_coordinates, 'Location coordinates of the provider profile to stay the same after the expansion')\r\n #\r\n #provider_post_expansion_coordinates = get_element_coordinates(get_provider_node, 'provider node after the expansion')\r\n #@place_holder.print_element_coordinates(provider_node, 'provider node after the expansion')\r\n #\r\n ## Verify that the expansion didn't mess up the existing nodes\r\n #@place_holder.assert_nodes_on_provider_graph\r\n\r\n end\r\n\r\n actual_node_count_post_expansion = @place_holder.get_actual_node_count\r\n\r\n puts \"actual_initial_node_count: #{actual_initial_node_count}\"\r\n puts \"actual_node_count_post_expansion: #{actual_node_count_post_expansion}\"\r\n\r\n expected_expansion_node_count = PropertiesReader.get_expected_expansion_result_node_count\r\n exp_total_nodes_after_expansion = actual_initial_node_count + expected_expansion_node_count\r\n\r\n # Use the actual (not the expected) initial node count in determining the expected count after expansion\r\n @place_holder.assert_equal(exp_total_nodes_after_expansion, actual_node_count_post_expansion, 'Number of nodes displayed on the graph after expansion')\r\n\r\n end",
"def valid_tree?\n false\n end",
"def has_children?\n !leaf?\n end",
"def prepare_children\n if predict_matrix.is_a?(NodeMatrix) && predict_matrix.has_great_grandchildren?\n create_children\n else\n nil\n end\n end"
] | [
"0.6218303",
"0.60740393",
"0.59683406",
"0.58888197",
"0.5835355",
"0.57563967",
"0.5654657",
"0.563873",
"0.5632658",
"0.5627397",
"0.55157226",
"0.5503459",
"0.5453877",
"0.5447366",
"0.5407305",
"0.5363828",
"0.53593504",
"0.5358762",
"0.53344333",
"0.53266793",
"0.529115",
"0.52810323",
"0.5262414",
"0.52439487",
"0.52434325",
"0.5228601",
"0.5228601",
"0.51858103",
"0.51788956",
"0.5157745",
"0.51442355",
"0.5142395",
"0.5133525",
"0.51289135",
"0.5108124",
"0.50955",
"0.5085234",
"0.5033408",
"0.502588",
"0.50128925",
"0.50128925",
"0.50128925",
"0.4997083",
"0.49561253",
"0.4927713",
"0.4905066",
"0.48831058",
"0.4880395",
"0.4877145",
"0.48715657",
"0.48615047",
"0.48327994",
"0.4831226",
"0.4827398",
"0.48190653",
"0.48125276",
"0.48037034",
"0.478997",
"0.47872064",
"0.47846878",
"0.47827646",
"0.47778842",
"0.47733858",
"0.47668615",
"0.47657186",
"0.47610676",
"0.4759293",
"0.47557572",
"0.47495854",
"0.47309893",
"0.4730626",
"0.4730626",
"0.47043714",
"0.47019523",
"0.4698155",
"0.46823317",
"0.46811664",
"0.4679144",
"0.46734393",
"0.46725568",
"0.466812",
"0.46656644",
"0.46643293",
"0.46626425",
"0.46487314",
"0.46486786",
"0.4644689",
"0.4644689",
"0.46426174",
"0.46399412",
"0.46292225",
"0.46276698",
"0.46224153",
"0.46214795",
"0.4614214",
"0.46121478",
"0.4604412",
"0.45998004",
"0.45996344",
"0.45991814"
] | 0.48733154 | 49 |
Format of auth.yml: consumer_key: (from osm.org) consumer_secret: (from osm.org) token: (use oauth setup flow to get this) token_secret: (use oauth setup flow to get this) The consumer key and consumer secret are the identifiers for this particular application, and are issued when the application is registered with the site. Use your own. | def test_local
auth = YAML.load(File.open('local_auth.yaml'))
@consumer=OAuth::Consumer.new auth['consumer_key'],
auth['consumer_secret'],
{:site=>"http://localhost:3000"}
# Create the access_token for all traffic
return OAuth::AccessToken.new(@consumer, auth['token'], auth['token_secret'])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def consumer_secret; config[:consumer_secret]; end",
"def oauth\n {\n consumer_key: @consumer_key,\n consumer_secret: @consumer_secret,\n token: @token,\n token_secret: @token_secret\n }\n end",
"def token_secret; config[:token_secret]; end",
"def authenticate (oauth_token, oauth_secret)\n Twitter.configure do |config|\n config.consumer_key = TWITTER_KEY\n config.consumer_secret = TWITTER_SECRET\n config.oauth_token = \"#{oauth_token}\"\n config.oauth_token_secret = \"#{oauth_secret}\"\n end\n end",
"def initialize(oauth_token_key, oauth_token_secret, params = {})\n @http_logger = params[:logger]\n site = params[:site] || :prod\n @consumer = ::OAuth::Consumer.new(oauth_token_key,\n oauth_token_secret,\n :scheme => :query_string,\n # :scheme => :header,\n :http_method => :get,\n :site => OAUTH_SITES[site],\n :request_token_path => OAUTH_REQUEST_TOKEN_URL,\n :access_token_path => OAUTH_ACCESS_TOKEN_URL,\n :authorize_path => OAUTH_AUTHORIZATION_URL)\n\n if params[:application_type] == APPLICATION_TYPE_ONSITE\n @access_token = ::OAuth::AccessToken.new(@consumer, \"\", \"\")\n elsif params[:access_token]\n @access_token = ::OAuth::AccessToken.new(@consumer,\n params[:access_token],\n params[:access_token_secret])\n end\n if params[:request_token]\n @request_token = ::OAuth::RequestToken.new(@consumer,\n params[:request_token],\n params[:request_token_secret])\n end\n end",
"def oauth_data\n {\n consumer_key: CONSUMER_KEY,\n consumer_secret: CONSUMER_SECRET,\n token: session[:token],\n token_secret: session[:secret],\n realm_id: session[:realm_id]\n }\n end",
"def initialize(consumer_key, consumer_secret, token, token_secret)\n @consumer = OAuth::Consumer.new(consumer_key, consumer_secret, {:site => API_HOST})\n @access_token = OAuth::AccessToken.new(@consumer, token, token_secret)\n end",
"def consumer_key; config[:consumer_key]; end",
"def configure_authentication\n consumer_secret = \"18yElxR1Zf8ESVkl3k7XQZxyAPWngz5iM69nbhH7yE\"\n consumer_key = \"zQ727fZBHDIv36pKhr2Hg\"\n\n Twitter.configure do |config|\n config.consumer_key = consumer_key\n config.consumer_secret = consumer_secret\n config.oauth_token = \"157879876-iSPfgtHxw8QSAj6cJl0uYTbDTV1kfxsw8Tgi1QGK\"\n config.oauth_token_secret = \"XiI1kkuGgvqZNc4mGIGkPxjcr19p9PVxhT7m0M\"\n Twitter::Client.new\n end\n end",
"def access_token_secret\n credentials['secret']\n end",
"def authorized_twitter\n oauth = Twitter::OAuth.new($configure[:twitter][:ctoken], $configure[:twitter][:csecret])\n # Request OAuth authentication if there are no access token yet\n unless($configure[:twitter][:atoken] && $configure[:twitter][:asecret])\n rtoken = oauth.request_token\n puts \"Open next url, authorize this application: #{rtoken.authorize_url}\"\n puts \"Then, enter PIN code:\"\n pin = STDIN.gets.chomp\n # Authrize request token using PIN code (this is required for an application which type is \"Client\")\n atoken = OAuth::RequestToken.new(oauth.consumer, rtoken.token, rtoken.secret).get_access_token(:oauth_verifier => pin)\n # Save access token\n $configure[:twitter][:atoken] = atoken.token\n $configure[:twitter][:asecret] = atoken.secret\n end\n oauth.authorize_from_access($configure[:twitter][:atoken], $configure[:twitter][:asecret])\n # Create Twitter client instance with OAuth\n Twitter::Base.new(oauth)\nend",
"def twitter_consumer_config_value\n my_config = ParseConfig.new('config/application.yml')\n consumer_key = my_config.get_value('consumer_key')\n consumer_secret = my_config.get_value('consumer_secret')\n return consumer_key,consumer_secret\n end",
"def oauth_data\n {\n consumer_key: @consumer_key,\n consumer_secret: @consumer_secret,\n token: @token,\n token_secret: @token_secret\n }\n end",
"def token_secret; end",
"def token_secret; end",
"def token_secret; end",
"def oauth!(key = :consumer_key, token = :token, secret = :token_secret, consumer_secret = :consumer_secret)\n @authenticates = :oauth\n @credentials = [key, token, secret, consumer_secret]\n end",
"def auth_settings\n {\n 'auth' =>\n {\n type: 'oauth2',\n in: 'header',\n key: 'Authorization',\n value: \"Bearer #{access_token}\"\n },\n }\n end",
"def oauth\n ::OAuth::Consumer.new(Config.consumer_key, Config.consumer_secret, :site => \"https://api.twitter.com\")\n end",
"def oauth_hash\n {\n :consumer_key => consumer_key || Bountybase.config.twitter_app[\"consumer_key\"],\n :consumer_secret => consumer_secret || Bountybase.config.twitter_app[\"consumer_secret\"],\n :oauth_token => oauth_token,\n :oauth_token_secret => oauth_secret\n }\n end",
"def consumer\n @consumer = OAuth::Consumer.new session[:consumer_key], session[:consumer_secret], :site => MISO_SITE\nend",
"def initialize( user_token = nil, user_secret = nil )\n\t\t@consumer = OAuth::Consumer.new(TWOAUTH_KEY, TWOAUTH_SECRET, { :site=> TWOAUTH_SITE })\n\t\t@access_token = OAuth::AccessToken.new( @consumer, user_token, user_secret ) if user_token && user_secret\n end",
"def oauth_authentication; end",
"def config\n Simple::OAuth2.config\n end",
"def configure_twitter(access_token, access_token_secret)\n Twitter::REST::Client.new do |config|\n config.consumer_key = ENV[\"twitter_api_key\"]\n config.consumer_secret = ENV[\"twitter_api_secret\"]\n config.access_token = access_token\n config.access_token_secret = access_token_secret\n end\n end",
"def authenticate()\n\n Twitter.configure do |config|\n config.consumer_key = @consumer_key\n config.oauth_token = @oauth_token\n config.oauth_token_secret = @oauth_token_secret\n config.consumer_secret = @consumer_secret\n\n end\n\n end",
"def setupApp(pia_url, app_key, app_secret)\n token = getToken(pia_url, app_key, app_secret)\n { \"url\" => pia_url,\n \"app_key\" => app_key,\n \"app_secret\" => app_secret,\n \"token\" => token }\nend",
"def consumer\n OAuth::Consumer.new(consumer_key, consumer_secret, :site => endpoint)\n end",
"def oauth_authentication(credential_file='credentials.yml')\n begin\n @credentials = YAML.load_file(credential_file)\n rescue\n raise CouldNotLoadCredentials, \"Couldn't load your ikbis credentials. You may need to run ikbis-auth.\"\n end\n @consumer = OAuth::Consumer.new(@credentials[:consumer_key], @credentials[:consumer_secret], {:site => \"http://localhost:3000\"})\n @access_token = OAuth::AccessToken.new(@consumer, @credentials[:access_token], @credentials[:access_token_secret])\n end",
"def initialize(credentials)\n raise ArgumentError unless credentials.kind_of? Hash\n raise KeyError if credentials.empty?\n\n # Please provide this four exact parameters\n raise ArgumentError if credentials.keys.count != 4 and credentials.keys & [:app_key, :app_secret, :access_token, :access_token_secret] != [:app_key, :app_secret, :access_token, :access_token_secret]\n \n @consumer = OAuth::Consumer.new(credentials[:app_key], credentials[:app_secret], { :site => HOST})\n @access_token = OAuth::AccessToken.new(@consumer, credentials[:access_token], credentials[:access_token_secret])\n end",
"def initialize(consumer_key, consumer_secret)\n\t\t\t\t@consumer = OAuth::Consumer.new consumer_key, consumer_secret,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ :site => 'http://twitter.com/',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t:request_token_path => '/oauth/request_token',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t:access_token_path => '/oauth/access_token',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t:authorize_path => '/oauth/authorize',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t:scheme => :header\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\tend",
"def consumer_key\n oauth_merged_params[:oauth_consumer_key]\n end",
"def auth\n if configuration.api_key\n { :key => configuration.api_key, :sign => 'true' }\n elsif configuration.access_token\n { :access_token => configuration.access_token }\n end\n end",
"def consumer_secret\n ENV['DESK_CONSUMER_SECRET']\n end",
"def oauth_options\n {\n consumer_key: client_id,\n consumer_secret: client_secret,\n token: access_token,\n token_secret: access_token_secret\n }\n end",
"def config\n Grape::OAuth2.config\n end",
"def consumer_secret\n ENV[CONSUMER_SECRET_NAME]\n end",
"def auth_settings\n {\n 'JWT' =>\n {\n type: 'oauth2',\n in: 'header',\n key: 'Authorization',\n value: \"Bearer #{access_token}\"\n },\n }\n end",
"def auth_settings\n {\n 'JWT' =>\n {\n type: 'oauth2',\n in: 'header',\n key: 'Authorization',\n value: \"Bearer #{access_token}\"\n },\n }\n end",
"def from_auth_token_and_secret(token, secret)\n @token = OAuth::AccessToken.from_hash(@consumer,\n :oauth_token => token,\n :oauth_token_secret => secret)\n end",
"def get_consumer\n OAuth::Consumer.new(ENV[\"EVERNOTE_CONSUMER_KEY\"], ENV[\"EVERNOTE_SECRET\"], {\n :site => ENV[\"EVERNOTE_URL\"],\n :request_token_path => \"/oauth\",\n :access_token_path => \"/oauth\",\n :authorize_path => \"/OAuth.action\"\n })\n end",
"def consumer\n @consumer ||= OAuth::Consumer.new(\n config[:consumer_key],\n config[:consumer_secret],\n :site => base_url\n )\n end",
"def initialize(tokens_and_secrets = {})\n @oauth = KynetxAmApi::Oauth.new(tokens_and_secrets)\n end",
"def oauth_token_secret\n @json['oauthTokenSecret']\n end",
"def init\n init_oauth_access_token\n end",
"def oauth_consumer\n @oauth_consumer\n end",
"def prepare_access_token(oauth_token, oauth_token_secret)\n consumer = OAuth::Consumer.new(\n CONSUMER_KEY,\n CONSUMER_SECRET,\n {\n :site => \"https://api.twitter.com\",\n :scheme => :header\n }\n )\n\n # now create the access token object from passed values\n token_hash = { :oauth_token => oauth_token, :oauth_token_secret => oauth_token_secret }\n access_token = OAuth::AccessToken.from_hash(consumer, token_hash )\n\n return access_token\nend",
"def prepare_access_token(oauth_token, oauth_token_secret)\n consumer = OAuth::Consumer.new(CONSUMER_KEY, CONSUMER_SECRET, { :site => \"https://api.twitter.com\", :scheme => :header })\n \n # now create the access token object from passed values\n token_hash = { :oauth_token => oauth_token, :oauth_token_secret => oauth_token_secret }\n access_token = OAuth::AccessToken.from_hash(consumer, token_hash )\n \n return access_token\nend",
"def consumer\n @consumer ||= begin\n options = {\n :site => \"https://www.google.com\",\n :request_token_path => \"/accounts/OAuthGetRequestToken\",\n :access_token_path => \"/accounts/OAuthGetAccessToken\",\n :authorize_path=> \"/accounts/OAuthAuthorizeToken\"\n }\n \n OAuth::Consumer.new('lfmp.heroku.com', 'EqH7lROs9KwfSU3QnFpkd8tX', options)\n end\n end",
"def connect\n consumer = OAuth::Consumer.new(@c_key, @c_sec,\n { :site => \"https://api.twitter.com\",\n :scheme => :header\n })\n\n token_hash = { :oauth_token => @a_tok,\n :oauth_token_secret => @a_sec\n }\n\n @access_token = OAuth::AccessToken.from_hash(consumer, token_hash)\n end",
"def token_secret\n ENV['DESK_TOKEN_SECRET']\n end",
"def configure\n # Consumer details come from registering an app at https://dev.twitter.com/\n # Once you have consumer details, use \"ebooks auth\" for new access tokens\n self.consumer_key = 't9g6TgrUYsZ4R5aeArsM2C36G' # Your app consumer key\n self.consumer_secret = 'olto6fNhfZz0CZwtx4uaFFpoyW88KG4LZnuaMFtWkvhgWq3897' # Your app consumer secret\n\n # Users to block instead of interacting with\n self.blacklist = ['']\n\n # Range in seconds to randomize delay when bot.delay is called\n self.delay_range = 1..6\n\t\n\t@userinfo = {}\n end",
"def consumer\n @consumer ||= OAuth::ConsumerWithHyvesExtension.new(key, secret, oauth_options)\n end",
"def oauth\n Auth.new(params[:uid], params[:oauth_token], action_name)\n end",
"def oauth\n request_token = @oauth_consumer.get_request_token\n authorize_url = request_token.authorize_url(:oauth_consumer_key => \n Netflix::Client.consumer_key)\n Launchy.open(authorize_url)\n puts \"Go to browser, a page has been opened to establish oauth\"\n printf \"Pin from Netflix:\"\n pin = gets.chomp\n access_token = request_token.get_access_token(:oauth_verifier => pin)\n end",
"def setup_token_credentials\n config_key = credential_config_key\n\n if config(\"#{config_key}.token\")\n $stderr.puts \"Token credentials already configured for API Provider #{api_url}\"\n unless yes?('Would you like to reconfigure the token for this provider?')\n $stderr.puts 'Nothing to do.'\n exit 1\n end\n end\n\n token_request_body = {:scopes => %w(repo user gist), :note => \"General oauth\"}\n\n username, _, response = _auth_loop_request(\"#{api_url}/authorizations\") do |url|\n Net::HTTP::Get.new(url.path).tap {|request|\n request.body = JSON.generate(token_request_body)\n }\n end\n\n case response\n when Net::HTTPOK\n token = JSON.parse(response.body).first['token']\n $stdout.puts \"Storing token credentials for API Provider #{api_url} with key #{config_key}\"\n store_config_credentials(username, :token => token)\n else\n $stderr.puts \"Failed to acquire token: #{response.code}: #{response.message}\"\n end\n nil\n end",
"def access_token_secret\n ENV[ACCESS_TOKEN_SECRET_NAME]\n end",
"def get_token\n consumer = OAuth::Consumer.new('jzICjLlLF3dLrGVaVal0w', '3ydl3o44K4MaR8sFAk2gWtTTzHfFc7PzZjelP0XIoik', {\n :site => 'https://api.twitter.com',\n :scheme => :header\n })\n token_hash = {\n :oauth_token => '14615533-Qy2ck9vrfqsNdUp5cGi5PpHyrqBRmh7aXP6qcUr9w',\n :oauth_token_secret => 'tECZ96ci1nXrvs3OkxSEbZyQtngQWslhgGeuTgEFJwU'\n }\n\n OAuth::AccessToken.from_hash(consumer, token_hash)\nend",
"def get_OAuthTokenSecret()\n \t return @outputs[\"OAuthTokenSecret\"]\n \tend",
"def prepare_access_token(oauth_token, oauth_token_secret)\n consumer = OAuth::Consumer.new(configatron.consumer_key, configatron.consumer_secret, { :site => configatron.tw_api_url })\n \n token_hash = { :oauth_token => oauth_token, :oauth_token_secret => oauth_token_secret }\n OAuth::AccessToken.from_hash(consumer, token_hash)\n end",
"def consumer_secret\n ENV['WHCC_CONSUMER_SECRET']\n end",
"def prepare_access_token(oauth_token, oauth_token_secret)\n consumer = OAuth::Consumer.new( ENV[\"CONSUMER_KEY\"], ENV[\"CONSUMER_SECRET\"], { :site => \"https://api.twitter.com\", :scheme => :header })\n\n # now create the access token object from passed values\n token_hash = { :oauth_token => oauth_token, :oauth_token_secret => oauth_token_secret }\n access_token = OAuth::AccessToken.from_hash(consumer, token_hash )\n\n return access_token\n end",
"def client_secret; end",
"def prepare_access_token(oauth_token, oauth_token_secret)\n consumer = OAuth::Consumer.new(\"ZIaUkHC2dqpBAxUiUU9w\", \"eO0t8SYwZxrGuYoEC7MJdMbLakMqPMH7vpnj1uC1NM\", { :site => \"http://api.twitter.com\", :scheme => :header})\n\n # now create the access token object from passed values\n token_hash = { :oauth_token => oauth_token, :oauth_token_secret => oauth_token_secret }\n access_token = OAuth::AccessToken.from_hash(consumer, token_hash )\n\n return access_token\nend",
"def oauth?\n oauth_consumer_key && oauth_consumer_secret\n end",
"def token_secret=(_arg0); end",
"def token_secret=(_arg0); end",
"def token_secret=(_arg0); end",
"def openid_client_secret; end",
"def secret_key; end",
"def prepare_access_token(oauth_token, oauth_token_secret)\n \tconsumer = OAuth::Consumer.new(\"YNB1bhMpex4y7ERRuCe8hqCA3\", \"3QezXzBngsbxZgIdJiGXxjZomXFrXLLgULWT8MoFwSDvAJPJcr\", { :site => \"https://api.twitter.com\", :scheme => :header })\n\n # now create the access token object from passed values\n \ttoken_hash = { :oauth_token => oauth_token, :oauth_token_secret => oauth_token_secret }\n \taccess_token = OAuth::AccessToken.from_hash(consumer, token_hash )\n\n return access_token\nend",
"def configureTwitter(key, secret)\n\t\t\t@client = Twitter\n\t\t\[email protected] do |config|\n\t\t\t\tconfig.consumer_key = key\n\t\t\t\tconfig.consumer_secret = secret\n\t\t\t\tconfig.oauth_token = @token_hash[:oauth_token]\n\t\t\t\tconfig.oauth_token_secret = @token_hash[:oauth_token_secret]\n\t\t\tend\n\t\tend",
"def get_consumer\n ::OAuth::Consumer.new(@key, @secret, @configuration)\n end",
"def grantAccess()\n\t\t\tif File.zero?('lib/data.txt') #if files doesn't exist it then gets the access_tokens\n\t\t\t\t@request_token = @consumer.get_request_token\n\t\t\t\tLaunchy.open(\"#{@request_token.authorize_url}\")\n\t\t\t\tprint \"Enter pin that the page gave you:\" \n\t\t\t\t@pin = STDIN.readline.chomp\n\t\t\t\t@access_token = @request_token.get_access_token(:oauth_verifier => @pin)\n\t\t\t\tputs @access_token.token\n\t\t\t\tFile.open('lib/data.txt','w') do |f|\n\t\t\t\t\tf.puts @access_token.token\n\t\t\t\t\tf.puts @access_token.secret\n\t\t\t\tend\n\t\t\telse #if they exist it simple reads them into token_hash\n\t\t\t\tFile.open('lib/data.txt','r') do |f|\n\t\t\t\t\t@token_hash = { :oauth_token => f.readline.chomp,\n\t\t\t\t\t\t\t\t\t\t\t :oauth_token_secret => f.readline.chomp\n\t\t\t\t\t\t\t\t\t\t \t\t}\n\t\t\t\t\tend\n\t\t\tend\n\t\tend",
"def configure_twitter\n Twitter.configure do |config|\n config.consumer_key = \"VowhzjVm7OWLZmHGxosVyg\"\n config.consumer_secret = \"Pwkd1J2rxWVaejWdvg1MOW2qHmP6lAncP0EDTXWvZM\"\n config.oauth_token = \"109484472-I0kSWE9FnpxjlzUrDmL0eIFxkcDxnkLyIaZskQhf\"\n config.oauth_token_secret = \"1PmK1OlThcRsiYgHYwOdRHXVEboog5jukq35nIUNauA\"\n end\nend",
"def prepare_access_token\n consumer = OAuth::Consumer.new(@consumer_key, @consumer_secret,\n { :site => @hostname,\n :scheme => :header,\n :access_token_path=>\"/v1/oauth/token/access\",\n :authorize_path => \"/v1/oauth/authorize\",\n :request_token_path => \"/v1/oauth/token/request\"\n })\n\n access_token = OAuth::AccessToken.from_hash(consumer, :oauth_token => @access_token, :oauth_token_secret => @access_token_secret) \n return access_token\n end",
"def auth_token(opts = {})\n get_config_auth_token() || create_authorization(opts)\n end",
"def consumer\n @consumer ||= OAuth::Consumer.new(\n @consumer_key,\n @consumer_secret,\n { :site=> self.class.site }\n )\n end",
"def generate_keys\n self.client_id = OAuth::Helper.generate_key(40)[0,40]\n self.client_secret_hash = OAuth::Helper.generate_key(40)[0,40]\n end",
"def twitter_client\n yml_config = YAML::load_file(File.join(Rails.root, 'config', 'twitter.yml'))[Rails.env]\n Twitter::REST::Client.new do |config|\n config.consumer_key = yml_config['consumer_key']\n config.consumer_secret = yml_config['consumer_secret']\n config.access_token = token\n config.access_token_secret = token_secret\n end\n end",
"def configure(consumer_key, consumer_secret, oauth_version = nil, oauth_cipher = nil, twitter_api = nil)\n @consumer_key = consumer_key\n @consumer_secret = consumer_secret\n\n @oauth_version = oauth_version || OAUTH_VERSION\n @oauth_cipher = oauth_cipher || OAUTH_CIPHER\n @twitter_api = twitter_api || TWITTER_API\n\n @@configured = true\n end",
"def auth_settings\n {\n 'accessToken' =>\n {\n type: 'bearer',\n in: 'header',\n key: 'Authorization',\n value: \"Bearer #{access_token}\"\n },\n }\n end",
"def auth_settings\n {\n 'accessToken' =>\n {\n type: 'bearer',\n in: 'header',\n key: 'Authorization',\n value: \"Bearer #{access_token}\"\n },\n }\n end",
"def request_access_token\n # An `OAuth::Consumer` object can make requests to the service on\n # behalf of the client application.\n\n # Ask service for a URL to send the user to so that they may authorize\n # us.\n request_token = CONSUMER.get_request_token\n authorize_url = request_token.authorize_url\n\n # Launchy is a gem that opens a browser tab for us\n Launchy.open(authorize_url)\n\n # Because we don't use a redirect URL; user will receive a short PIN\n # (called a **verifier**) that they can input into the client\n # application. The client asks the service to give them a permanent\n # access token to use.\n puts \"Login, and type your verification code in\"\n oauth_verifier = gets.chomp\n access_token = request_token.get_access_token(\n :oauth_verifier => oauth_verifier\n )\nend",
"def consumer_key\n ENV[CONSUMER_KEY_NAME]\n end",
"def auth\n require 'oauth'\n say \"This will reset your current access tokens.\", :red if already_authed?\n\n # get the request token URL\n callback = OAuth::OUT_OF_BAND\n consumer = OAuth::Consumer.new $bot[:config][:consumer_key],\n $bot[:config][:consumer_secret],\n site: Twitter::REST::Client::BASE_URL,\n scheme: :header\n request_token = consumer.get_request_token(oauth_callback: callback)\n url = request_token.authorize_url(oauth_callback: callback)\n\n puts \"Open this URL in a browser: #{url}\"\n pin = ''\n until pin =~ /^\\d+$/\n print \"Enter PIN =>\"\n pin = $stdin.gets.strip\n end\n\n access_token = request_token.get_access_token(oauth_verifier: pin)\n $bot[:config][:access_token] = access_token.token\n $bot[:config][:access_token_secret] = access_token.secret\n\n # get the bot's user name (screen_name) and print it to the console\n $bot[:config][:screen_name] = get_screen_name access_token\n puts \"Hello, #{$bot[:config][:screen_name]}!\"\n end",
"def initialize(app_id, app_secret, api_key, email, password)\n\n merge!(\n {\n applicationCredentials: {\n applicationId: app_id,\n applicationSecret: app_secret\n },\n userCredentials: {\n apiKey: api_key,\n email: email,\n password: password \n }\n }\n )\n end",
"def consumer_secret\n config_method_not_implemented\n end",
"def auth\r\n OAuth2\r\n end",
"def initialize(ctoken, csecret, options={})\n @ctoken, @csecret, @consumer_options = ctoken, csecret, {}\n\n # if options[:sign_in]\n # @consumer_options[:authorize_path] = '/oauth/authenticate'\n # end\n end",
"def app_credentials\n {user: @config['mysql_app_user'], pass: @config['mysql_app_password']}\n end",
"def authorize(token, token_secret)\n\t\t\t@access_token = OAuth::AccessToken.new(@client, token, token_secret)\n\t\tend",
"def prepare_access_token(oauth_token, oauth_token_secret)\n consumer = OAuth::Consumer.new(\"zuDJxQuK96WA2s0k0g3tqHr6r\", \"PhiNIibo53GYGhXgoWJ1UDBoKDVGqhaeCmTiSWCwz3VKucxfTD\",\n { :site => \"https://api.twitter.com\",\n :scheme => :header\n })\n # now create the access token object from passed values\n token_hash = { :oauth_token => oauth_token,\n :oauth_token_secret => oauth_token_secret\n }\n access_token = OAuth::AccessToken.from_hash(consumer, token_hash )\n \n RestClient.add_before_execution_proc do |req, params|\n access_token.sign! req\n end\n\n return access_token\nend",
"def exchange_oauth_tokens\n end",
"def log_in_to_twitter\n @client = Twitter::REST::Client.new do |config|\n #https://apps.twitter.com/app/14450234\n config.consumer_key = Figaro.env.pusher_key\n config.consumer_secret = Figaro.env.pusher_secret\n config.access_token = Figaro.env.stripe_api_key\n config.access_token_secret = Figaro.env.stripe_publishable_key\n end\n end",
"def token_secret\n config_method_not_implemented\n end",
"def read_credentials\n {\n consumer_key: SiteSetting.lti_consumer_key,\n consumer_secret: SiteSetting.lti_consumer_secret\n }\n end",
"def openid_client_secret=(_arg0); end",
"def oauth_application(token)\n request(\n __method__,\n :get,\n \"#{api_base}/oauth2/applications/@me\",\n Authorization: token\n )\n end",
"def initialize(consumer_key, consumer_secret, token, token_secret)\n consumer = OAuth::Consumer.new(consumer_key, consumer_secret, {\n :site => \"https://www.google.com\",\n :scheme => :header\n })\n\n @connection = OAuth::AccessToken.new(consumer,token, token_secret)\n\n @calendars = Calendar.new(@connection)\n end"
] | [
"0.7173915",
"0.70331264",
"0.6911294",
"0.6880273",
"0.67467296",
"0.6710576",
"0.662208",
"0.6619271",
"0.65218675",
"0.65190595",
"0.6505039",
"0.650424",
"0.6424107",
"0.6410788",
"0.6410788",
"0.6410788",
"0.6395793",
"0.6393676",
"0.6386917",
"0.6375623",
"0.63683295",
"0.63625515",
"0.6354196",
"0.63452184",
"0.63432866",
"0.633636",
"0.6313644",
"0.62995434",
"0.6282444",
"0.6262987",
"0.62571776",
"0.624043",
"0.6239007",
"0.6235766",
"0.62332016",
"0.62281",
"0.6205308",
"0.61958504",
"0.61958504",
"0.61911196",
"0.6188716",
"0.6174764",
"0.61677355",
"0.6142414",
"0.61386514",
"0.613747",
"0.61244065",
"0.61109585",
"0.60991406",
"0.6091943",
"0.6091685",
"0.6090243",
"0.60839945",
"0.6079266",
"0.60756844",
"0.6074501",
"0.60741574",
"0.6069357",
"0.60665953",
"0.6065811",
"0.6063898",
"0.60623705",
"0.6055162",
"0.6041486",
"0.60385436",
"0.60325223",
"0.60325223",
"0.60325223",
"0.6026444",
"0.600984",
"0.6008437",
"0.60024387",
"0.5998984",
"0.5995999",
"0.5993053",
"0.59910846",
"0.59878165",
"0.59873885",
"0.59850633",
"0.5973038",
"0.597108",
"0.59660196",
"0.59660196",
"0.5947637",
"0.59460217",
"0.59386426",
"0.592527",
"0.5920179",
"0.59197533",
"0.5918865",
"0.59183735",
"0.5913851",
"0.59054667",
"0.59020907",
"0.589829",
"0.58764106",
"0.58697283",
"0.5867971",
"0.5860421",
"0.5852677"
] | 0.67301637 | 5 |
need to override the json view to return what full_calendar is expecting. | def as_json(options = {})
{
:id => self.id,
:title => self.name,
:description => self.description || "",
:start => starts_at.rfc822,
:end => ends_at.rfc822,
:url => Rails.application.routes.url_helpers.select_path(id),
#:color => "red"
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def as_json(options = {})\n {\n :id => self.id,\n :title => self.title,\n :description => self.description || \"\",\n :start => unless starts_at.blank? then starts_at.rfc822 else \"\" end,\n :end => unless ends_at.blank? then ends_at.rfc822 else \"\" end,\n :allDay => self.all_day,\n :recurring => false,\n #:url => Rails.application.routes.url_helpers.event_path(id),\n #:color => \"red\"\n }\n end",
"def as_json(options = {})\n {\n :id => self.id,\n :title => self.title,\n :description => self.description || \"\",\n :start => starts_at.rfc822,\n :end => ends_at.rfc822,\n :allDay => self.all_day,\n :recurring => false,\n :url => Rails.application.routes.url_helpers.event_path(id),\n #:color => \"red\"\n }\n\n end",
"def as_json(*)\n CalendarJSON.rent(self)\n end",
"def render_json\n end",
"def show\n render json: @evento.formatted_data.as_json()\n end",
"def as_json(options = {})\n {\n :id => self.id,\n :title => self.title,\n :description => self.description || \"\",\n :start => self.starts_at.rfc822,\n :end => self.ends_at.rfc822,\n :allDay => self.all_day,\n :recurring => false,\n :color => self.color.nil? ? \"blue\" : self.color,\n :location => self.location,\n :notes => self.notes,\n :url => self.edit_url #Rails.application.routes.url_helpers.edit_event_path(id)\n }\n end",
"def show\n render json: format_event(@event)\n end",
"def as_json(options = {})\n {\n :id => self.id,\n :title => self.title,\n :description => self.description || \"\",\n :start => starts_at.rfc822,\n :end => ends_at.rfc822,\n :allDay => self.all_day,\n :recurring => false,\n :backgroundColor => bgColor\n\n #:url => Rails.application.routes.url_helpers.team_event_path(self.team, self.id),\n #:color => \"red\"\n }\n\n end",
"def as_json(options = {})\n {\n :id => self.id,\n :title => self.title,\n :description => self.description || \"\",\n :start => starts_at.rfc822,\n :end => ends_at.rfc822,\n :allDay => self.all_day,\n :recurring => false,\n :url => Rails.application.routes.url_helpers.event_path(id)\n }\n \n end",
"def as_json(options = {})\n {\n :id => self.id,\n :title => self.titre,\n :description => self.contenu || \"\",\n :start => start_at.rfc822,\n :end => end_at.rfc822,\n :allDay => self.all_day,\n :recurring => false,\n :url => Rails.application.routes.url_helpers.event_path(id)\n }\n end",
"def as_json(options = {})\n {\n :id => self.id,\n :title => self.title,\n :description => self.description || \"\",\n :start => starts_at.rfc822,\n :end => ends_at && !ends_at.blank? ? ends_at.rfc822 : '',\n :allDay => self.all_day,\n :color => self.person ? self.person.bg_color : \"#f3f2f2\",\n :borderColor => self.person ? self.person.bg_color : \"#ddd\",\n :textColor => self.person ? self.person.txt_color : \"#666\",\n :className => \"event #{'unsinged' unless self.person}\",\n :recurring => false,\n :resource => self.person ? self.person.id : \"\",\n :resourceId => self.person ? self.person.id : \"\",\n :url => Rails.application.routes.url_helpers.event_path(id)\n }\n \n end",
"def as_json(options = {})\n {\n :id => self.id,\n :title => self.title,\n :description => self.description || \"\",\n :start => start_time.rfc822,\n :end => end_time.rfc822,\n :allDay => false,\n :recurring => false,\n :color => self.event_status,\n :textColor => 'black',\n :url => Rails.application.routes.url_helpers.event_path(id)\n }\n end",
"def as_json(options = {})\n {\n :id => self.ID,\n :title => self.listing,\n :description => self.summary,\n :start => setTimes(self.eventstartdate, self.eventstarttime),\n :end => setTimes(self.eventenddate, self.eventendtime),\n :allDay => holiday?,\n :recurring => false,\n :url => get_url,\n :color => get_color,\n :textColor => get_text_color\n }\n end",
"def fullcalendar_events_json\n events.map do |event|\n {\n id: event.id.to_s,\n title: event.name,\n start: event.starts_at.strftime('%Y-%m-%d %H:%M:%S'),\n end: event.ends_at.strftime('%Y-%m-%d %H:%M:%S'),\n allDay: event.all_day,\n url: event_path(event)\n }\n end\n end",
"def as_json(options = {})\n {\n :id => self.id,\n :title => self.title,\n :description => self.description || \"\",\n :start => (starts_at + 5.hours),\n :end => (ends_at + 5.hours),\n :allDay => self.all_day,\n :recurring => false,\n :url => Rails.application.routes.url_helpers.event_path(id)\n }\n \n end",
"def as_json(options = {})\n {\n :id => self.id,\n :title => self.title,\n :description => self.description || \"\",\n :start => (starts_at).to_datetime.iso8601,\n :end => (ends_at).to_datetime.iso8601,\n :allDay => self.all_day,\n :recurring => false,\n :url => Rails.application.routes.url_helpers.main_event_event_path(self.main_event.id, id)\n }\n end",
"def as_json(options = {})\n {\n :id => self.id,\n :title => self.title,\n :description => self.description || \"\",\n :start => starts_at.rfc822,\n :end => ends_at.rfc822,\n :url => Rails.application.routes.url_helpers.event_path(id)\n }\n end",
"def show\n \trender json: @event\n end",
"def show_json\n end",
"def index\n respond_to do |format|\n format.html\n format.json { render json: @events }\n end\n end",
"def show\n render json: @event\n end",
"def show\n render json: @event\n end",
"def show\n render json: @event\n end",
"def show\n render json: @event\n end",
"def show\n render json: @event\n end",
"def as_json(options = {})\n {\n :id => self.id,\n :title => self.title,\n :description => self.description || \"\",\n :start => self.starts_at.rfc822,\n :end => self.ends_at.rfc822,\n :allDay => self.all_day,\n :recurring => false\n }\n\n end",
"def show\n render json: @clock_event\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def format\n :json\n end",
"def index\n @events = Event.where('user_id = ?', current_user)\n formatted_events = @events.map do |event|\n format_event event\n end\n\n render json: formatted_events\n end",
"def as_json(options = {})\n {\n :id => self.id,\n :title => self.purpose,\n :start => start_time.rfc822,\n :end => end_time.rfc822,\n :allDay => self.allDay,\n :recurring => false,\n :url => Rails.application.routes.url_helpers.reservation_path(id),\n }\n end",
"def index\n @events = Event.all\n respond_to do |format|\n format.html \n format.json do\n render :json => {events: @events}\n end\n end\n end",
"def index_for_calendar\n # build_calendar_data --> AppointmentsHelper method\n render json: build_calendar_data, status: 200\n end",
"def jsonize\n {id: self.id, title: self.title, start: self.start_date.strftime('%a %b %d %Y'), end: self.end_date.strftime('%a %b %d %Y'), resource: self.resource_id}\n end",
"def show\n respond_to do |format|\n format.html \n # format.json { render json: @day_availability }\n end\n end",
"def render(*)\n respond_to do |format|\n format.jsonapi { super }\n format.json { super }\n end\n end",
"def show_events\n render json: current_user\n end",
"def json\n {\"creation_date\" => @creation_date}\n end",
"def upcoming_events\n @events = Event.upcoming\n respond_to do |format|\n format.html { render :partial=>\"home/upcoming_events\", :locals=>{:upcoming_events=>@events} }\n format.json { render :layout => false, :json => @events }\n format.js\n end\n end",
"def show\n @calendar_event = CalendarEvent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @calendar_event }\n end\n end",
"def as_json(options = {})\n {\n :id => self.id,\n :title => self.title+\" by \"+self.counselor.full_name,\n :start => start_at.rfc822,\n :end => end_at.rfc822,\n :allDay => 0,\n :recurring => false\n # :url => '/'+self.counselor.class.to_s.downcase+'/dashboards'\n }\n\n end",
"def show\n render json: @event_configuration.to_json\n end",
"def index\n @histories = History.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: json_out = {\n \"timeline\"=>\n {\n \"headline\"=>\"The Main Timeline Headline Goes here\",\n \"type\"=>\"default\",\n \"text\"=>\"<p>Intro body text goes here, some HTML is ok</p>\",\n \"asset\"=> {\n \"media\"=>\"http://www.exglam.com/wp-content/uploads/2013/02/Kajal-agarwal-in-Blue-and-white-Fade-Short-with-white-Top-and-a-Blue-bow-in-hair.jpg\",\n \"credit\"=>\"Credit Name Goes Here\",\n \"caption\"=>\"Caption text goes here\"\n },\n\n \"date\"=> @histories.map { |timeline| {\"startDate\" => timeline.startdate.strftime(\"%Y,%m,%d\"),\"endDate\" => timeline.enddate.strftime(\"%Y,%m,%d\"),\"headline\" => timeline.headline,\"text\" => timeline.content, \"asset\" => {\"media\" => timeline.media}}},\n\n\n \"era\"=> [\n {\n \"startDate\"=>\"2011,12,10\",\n \"endDate\"=>\"2011,12,11\",\n \"headline\"=>\"Headline Goes Here\",\n \"text\"=>\"<p>Body text goes here, some HTML is OK</p>\",\n \"tag\"=>\"This is Optional\"\n }\n\n ]\n }\n } }\n end\n end",
"def render\n Oj.dump(to_json)\n end",
"def as_json(options = {})\n {\n :title => self.title,\n :start => self.start_time,\n :end => self.end_time,\n :description => self.description\n }\n end",
"def fullcalendarify\n\t\t{\n\t\t\tid: id,\n\t\t\tstart: start_date.iso8601,\n\t\t\tend: end_date.iso8601,\n\t\t\ttitle: title + (showtime ? \"\\n#{start_date.strftime \"%l:%M %p\"} - #{end_date.strftime \"%l:%M %p\"}\" : \"\"),\n\t\t\turl: \"/events/#{id}\",\n\t\t\tcolor: color\n\t\t}\n\tend",
"def show\n render json: @dia_evento\n end",
"def index\n # @weekdays = Weekday.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: Oj.dump(@weekdays, mode: :compat) }\n end\n end",
"def show\n render json: EventSerializer.new(@event).as_json, status: 200\n end",
"def show\n render json: @business_event.to_json(\n :methods => [:activity_types],\n include: {\n business_addresses: {only: [:id, :name, :address, :latitude, :longitude]},\n event_activities: {except: []}\n }),\n status: 200\n end",
"def show\n @calendar_date = CalendarDate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @calendar_date }\n end\n end",
"def as_json\n # if it belongs to a department, user_id = 0\n user_id = self.user ? self.user.id : 0 \n {\n :id => self.id,\n :notify => self.notify,\n :kind => self.kind,\n :current_state => self.status,\n :title => self.overview,\n :tag => self.tag,\n :long_description => self.content,\n :editable => true,\n :start => self.started,\n :finish => self.finished,\n :end => self.finished,\n :department_id => self.department_id,\n :user_id => user_id,\n :allDay => false,\n :url => Rails.application.routes.url_helpers.activity_path(id) \n }\n end",
"def show\n render json: @formato\n end",
"def show\n render json: @event_requirement\n end",
"def index\n @events = Event.all\n respond_to do |format|\n format.html \n format.json \n end\n end",
"def index\n @events = @category.events\n render json: @events \n end",
"def show\n @event = Event.find(params[:id])\n\n # ^^^^ + show.json.jbuilder + builder.key_format camelize: :lower in environment.rb will\n # convert ruby's model_properties into json's modelProperties.\n # Verify by viewing http://localhost:3000/events/1926.json and seeing camelcase, not snakecase.\n # and it replaces the code below:\n\n # respond_to do |format|\n # format.html\n # format.json { render :json => @event }\n # end\n end",
"def as_json(options = {})\r\n\t\tsuper\r\n\t\t {type: type,\r\n\t\t \t Title: Title,\r\n\t\t \t Authors: authors,\r\n\t\t \t With: with,\r\n\t\t \t Details: details,\r\n\t\t \t Year: year\r\n\t\t \t }\r\n\tend",
"def new\n @calendar_event = CalendarEvent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @calendar_event }\n end\n end",
"def as_json(options = {})\n if self.category == 'platform' && self.status == 'unconfirmed'\n bck_color = '#d2322d'\n text_color = '#fff'\n elsif self.category == 'platform'\n bck_color = '#60A869'\n text_color = '#004203'\n elsif self.category == 'sync'\n bck_color = '#aaa'\n text_color = '#7e7e7e'\n else\n #bck_color = '#91C9DF'\n #text_color = '#2B6379'\n bck_color = '#808080'\n text_color = '#444444'\n end\n if self.category == 'sync'\n title = 'Busy Time (sync)'\n else\n title = [self.user_name, self.user ? self.user.name : nil, self.therapy_name, self.title, 'Appointment'].reject{ |c| !c.present? }\n title = title[0]\n end\n {\n id: self.id,\n title: title,\n address: self.address || \"\",\n start: self.service_starts_at,\n # fullCalendar stores end time as exclusive\n end: service_ends_at + 1.second,\n color: bck_color,\n textColor: text_color\n }\n end",
"def render\n Oj.dump(to_json)\n end",
"def as_json(options = {})\n {\n :id => self.id,\n :title => self.subject.name,\n :description => self.description || \"\",\n :start => starts_at.rfc822,\n :end => ends_at.rfc822,\n :allDay => self.all_day,\n :recurring => false,\n :url => Rails.application.routes.url_helpers.routine_path(id)\n }\n end",
"def formatJSON\n # @formattedContents = .... whatever puts it into JSON\n end",
"def show\n @venue = Venue.find(params[:id])\n\n respond_to do |format|\n #format.html # show.html.erb\n format.json { render :json => @venue.to_json(:except=>[:display, :user_id, :modified_user_id]), :callback=>params[:callback] }\n end\n end",
"def show\n render json: @day, include: [:activities]\n end",
"def index\n # @schedules = Schedule.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: Oj.dump(@schedules, mode: :compat) }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event_import_result }\n end\n end",
"def show\n render json: @service_schedule\n end",
"def to_json\n Formatter::JSON.render(self)\n end",
"def as_json(options={})\n\t\tsuper(:methods => [:display_result,:display_normal_biological_interval,:display_count_or_grade,:display_comments_or_inference,:test_is_abnormal,:test_is_ready_for_reporting,:test_is_verified, :successfully_updated_by_lis])\n\tend",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @holiday }\n end\n end",
"def dayIndex\n render json: Restaurant.restaurantsDay\n end",
"def show\n @calendar = Calendar.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @calendar }\n end\n end",
"def show\n @calendar = Calendar.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @calendar }\n end\n end",
"def new\n @calendar = Calendar.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @calendar }\n end\n end",
"def show\n render json: @event, status: :ok\n end",
"def dates\n render json: @standings\n end",
"def votecannotbecast\t\t\n\t\trespond_to do |format|\n\t\t\tformat.js {}\n\t\tend\n\tend",
"def tojson\n\t\tend",
"def new\n @calendar_date = CalendarDate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @calendar_date }\n end\n end",
"def index\n \n @events = current_user.events\n \n \n respond_to do |format|\n format.html {}\n format.json { render json: Event.events_to_json(@events) }\n end\n end",
"def json\n {}\n end",
"def as_json(options={})\n super(:except => [:created_at, :updated_at])\n end",
"def as_json(options={})\n super(:except => [:created_at, :updated_at])\n end",
"def as_json(options={})\n super(:except => [:created_at, :updated_at])\n end",
"def show\n @event = Event.find(params[:id])\n if ((@event.opening_bands == nil or @event.opening_bands == \"\") and @event.bands)\n @event.opening_bands = \"\";\n @event.bands.each do |b|\n if (@event.band and b.name != @event.band.name)\n @event.opening_bands = @event.opening_bands + \" \" + b.name\n end\n end\n end\n if (@event.event_datetime.hour == 00)\n if (@event.venue.default_time != nil)\n @event.timestr = @event.venue.default_time.strftime(\"%l %p\")\n else\n @event.timestr = \"\"\n end\n else\n @event.timestr = @event.event_datetime.strftime(\"%l %p\")\n end\n puts @event.timestr\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event.to_json(:methods => [:timestr]) }\n end\n end",
"def new\n @calendar = Calendar.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @calendar }\n end\n end",
"def new\n @calendar = Calendar.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @calendar }\n end\n end",
"def index\n @event = Event.all\n render json: @event\n end",
"def get_events\t\t\t\n @task = UserEvent.where(\"user_id\"=>current_user.id)\n events = []\n @task.each do |task|\n events << {:id => task.id, :title => task.title, :start => DateTime.parse(task.start.to_s).strftime(\"%Y-%m-%d\"), :end => DateTime.parse(task.end.to_s).strftime(\"%Y-%m-%d\") }\n end\n render :text => events.to_json \n end",
"def as_json(*)\n super(except: %i[created_at updated_at deleted_at])\n end",
"def index\n @events = Event.all\n render json: @events\n end",
"def events_jsonify(events)\n\t\t\tevents.collect do |event|\n\t\t\t\t{ id: event.id,\n\t\t\t\t\tname: event.name,\n\t\t\t\t\tsummary: event.summary,\n\t\t\t\t\tstart_era: event.start_era,\n\t\t\t\t\tstart_date: \"#{event.start_date or 0}/#{event.start_month or 0}/#{event.start_year}\",\n\t\t\t\t\tend_date: \"#{event.end_date or 0}/#{event.end_month or 0}/#{event.end_year or event.start_year}\",\n\t\t\t\t\tarcs: event.arcs,\n\t\t\t\t\tentities: event.entities }\n\t\t\tend.to_json\n\t\tend",
"def index\n respond_with(events) do |format|\n format.ics { send_data(events_as_ical, filename: \"#{current_user.username}-#{current_instance.subdomain}-calendar.ics\", type: Mime::Type.lookup_by_extension('ics')) }\n format.json { render json: fullcalendar_events_json }\n end\n end",
"def index\n @events = @calendar.events.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @events }\n end\n end",
"def index\n @events = Event.all\n\n render json: @events\n end",
"def to_json\n attributes = self.values\n attributes[:date_published] = self.date_published_iso8601\n return attributes.to_json\n end",
"def list\n @events = Event.coming_events\n respond_to do |format|\n format.html do\n render layout: 'events'\n end\n format.json do \n events = @events.map {|event| {event: event, users: event.users, applied: event.users.include?(current_user) }}\n render json: events \n end\n end\n end",
"def as_json(options=nil)\n if options && options[:presenter_action] && json_presenter_class\n json_presenter_class.new(self).as_json(options)\n else\n super(options)\n end\n end"
] | [
"0.7442322",
"0.7395148",
"0.7354672",
"0.73337483",
"0.7333633",
"0.72639316",
"0.72342384",
"0.7227933",
"0.7221674",
"0.7163745",
"0.7143839",
"0.71263796",
"0.7060929",
"0.7058184",
"0.7036862",
"0.7031318",
"0.7006431",
"0.6857564",
"0.6796224",
"0.6760483",
"0.67209804",
"0.67209804",
"0.67209804",
"0.67209804",
"0.67209804",
"0.6644791",
"0.6620242",
"0.66141665",
"0.66141665",
"0.6593894",
"0.6589958",
"0.6576554",
"0.655962",
"0.6544086",
"0.6538713",
"0.65314496",
"0.6524411",
"0.6522292",
"0.6486654",
"0.6464281",
"0.64570796",
"0.64560646",
"0.6452715",
"0.6443887",
"0.64295846",
"0.64218396",
"0.6420896",
"0.6419708",
"0.6417602",
"0.64008087",
"0.6378767",
"0.6376891",
"0.6369172",
"0.63619417",
"0.63478625",
"0.63469416",
"0.6338523",
"0.6333268",
"0.6331107",
"0.6320981",
"0.63209474",
"0.630371",
"0.6292379",
"0.6289954",
"0.6285558",
"0.6277891",
"0.62697667",
"0.626581",
"0.6264591",
"0.6262442",
"0.625941",
"0.6249627",
"0.62450296",
"0.62439317",
"0.62439317",
"0.62417835",
"0.6239954",
"0.6232452",
"0.62252784",
"0.62230337",
"0.6221635",
"0.622131",
"0.6209616",
"0.6203343",
"0.6203343",
"0.6203343",
"0.620012",
"0.61939573",
"0.61939573",
"0.619253",
"0.6192016",
"0.61898756",
"0.6184346",
"0.61836964",
"0.61815125",
"0.6180417",
"0.6172968",
"0.61727935",
"0.61645484",
"0.61630255"
] | 0.66245323 | 26 |
GET /nurses/1 GET /nurses/1.json | def show
@nurse = Nurse.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @nurse }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @nail_salon = NailSalon.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @nail_salon }\n end\n end",
"def show\n @nugget = Nugget.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @nugget }\n end\n end",
"def show\n @sundry_grn = SundryGrn.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @sundry_grn }\n end\n end",
"def index\n @nepals = Nepal.all\n\n render json: @nepals\n end",
"def show\n rsa = Rsa.find_by id: params[:id];\n respond_to do |format|\n format.json {render json: {'n' => rsa.n , 'e' => rsa.e, 'd' => rsa.d}}\n end\n end",
"def new\n @nail_salon = NailSalon.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @nail_salon }\n end\n end",
"def index\n @sirens = Siren.all\n end",
"def show\n @entrant = Entrant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @entrant }\n end\n end",
"def show\n @entrant = Entrant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @entrant }\n end\n end",
"def show\n @studnet = Studnet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @studnet }\n end\n end",
"def show\n render json: @nepal\n end",
"def show\n my_rsa = RsaFull.find_by id: params[:id]\n respond_to do |format|\n format.json {render json: {'n' => my_rsa.n, 'e' => my_rsa.e, 'd' => my_rsa.d}}\n end\n end",
"def show\n @respuesta = Respuesta.find(params[:id])\n\n render json: @respuesta\n end",
"def show\n @verse = Verse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @verse }\n end\n end",
"def show\n @verse = Verse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @verse }\n end\n end",
"def show\n @verse = Verse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @verse }\n end\n end",
"def show\n @suplente = Suplente.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @suplente }\n end\n end",
"def index\n @snps = Snp.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @snps }\n end\n end",
"def show\n @csosn = Csosn.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @csosn }\n end\n end",
"def show\n @nominee = Nominee.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @nominee }\n end\n end",
"def retrieve(id)\n @client.make_request(:get, \"insurances/#{id}\", MODEL_CLASS)\n end",
"def new\n @srsa = Srsa.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @srsa }\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 @nave = Nave.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @nave }\n end\n end",
"def new\n @studnet = Studnet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @studnet }\n end\n end",
"def new\n @snp = Snp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @snp }\n end\n end",
"def index\n @interno_unidads = InternoUnidad.all\n render json: @interno_unidads\n end",
"def show\n @issuer = Issuer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @issuer }\n end\n end",
"def new\n @nurse = Nurse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @nurse }\n end\n end",
"def index\n @pubs = Pub.all\n\n render json: @pubs\n end",
"def show\r\n @venue = Venue.fetch(params[:id])\r\n render json: @venue\r\n end",
"def show\n @seguro = Seguro.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @seguro }\n end\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 @identities = Identity.all\n\n render json: @identities\n end",
"def show\n @surname = Surname.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @surname }\n end\n end",
"def show\n render json: @susu_membership\n end",
"def index\n @ordens = Orden.all\n render json: @ordens\n end",
"def show\n @ventas_seguimiento = Ventas::Seguimiento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ventas_seguimiento }\n end\n end",
"def index\n @ownerships = ownerships\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ownerships }\n end\n end",
"def show\n @encuestum = Encuestum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @encuestum }\n end\n end",
"def show\n @repuestum = Repuestum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @repuestum }\n end\n end",
"def show\n @srsa = Srsa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @srsa }\n end\n end",
"def index\n @pinns = Pinn.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pinns }\n end\n end",
"def index\n @susu_memberships = SusuMembership.page(params[:page]).per(params[:per])\n\n render json: @susu_memberships\n end",
"def index\n @universes = Universe.all.page(params[:page]).per(25)\n respond_to do |format|\n format.html\n format.json { render json: @universes }\n end\n end",
"def show\n @userr = Userr.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @userr }\n end\n end",
"def new\n @entrant = Entrant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entrant }\n end\n end",
"def new\n @entrant = Entrant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entrant }\n end\n end",
"def show\n respond_to do |format|\n format.json { render json: @uri, status: 200 }\n end\n end",
"def new\n @skid = Skid.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @skid }\n end\n end",
"def show\n render json: Alien.find(params[\"id\"])\n end",
"def new\n @nursing_time = NursingTime.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @nursing_time }\n end\n end",
"def show\n @saiken = Saiken.find(params[:id])\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @saiken }\n end\n end",
"def show\n @nasp_rail = NaspRail.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @nasp_rail }\n end\n end",
"def get_default_profile \n get(\"/profiles.json/default\")\nend",
"def show\n @asesor = Asesor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @asesor }\n end\n end",
"def new\n @stone = Stone.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stone }\n end\n end",
"def new\n @nave = Nave.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @nave }\n end\n end",
"def show\n #@restroom = Restroom.find(params[:id])\n @venue = client.venue(:query => params[:venue_id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @restroom }\n end\n end",
"def show\n @social_network = SocialNetwork.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @social_network }\n end\n end",
"def retrieve_snack_list\n response = RestClient.get SNACKS_URL\n logger.debug \"web service response code => #{response.code}\"\n if response.code != 200\n flash[:notice] = \"Error: #{response.code} while communicating with services, please try again later.\"\n end\n parsed = JSON.parse(response) \n end",
"def show\n @sotrudniki = Sotrudniki.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sotrudniki }\n end\n end",
"def show\n @nlp = Nlp.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @nlp }\n end\n end",
"def show\n @client_sex = ClientSex.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client_sex }\n end\n end",
"def getOrden \n \t@orden = Orden.where(:rest => params[:id_res])\n \trender json: @orden\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 semesters\n uni_year = UniYear.find_by_id(params[:uni_year_id])\n @semesters = uni_year ? uni_year.semesters : []\n \n respond_to do |format|\n format.json { render json: @semesters }\n end\n end",
"def show\n @respuesta = Respuesta.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @respuesta }\n end\n end",
"def show\n @soiree = Soiree.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @soiree }\n end\n end",
"def index\n @snips = Snip.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @snips }\n end\n end",
"def show\n @clue = Clue.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clue }\n end\n end",
"def show\n @clue = Clue.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clue }\n end\n end",
"def index\n @sesions = Sesion.where(entidad_paraestatal_id: @entidad_paraestatal.id).all\n @suplente = Suplente.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sesions }\n end\n end",
"def show\n @enroll = Enroll.find(params[:id])\n render json: JSON.parse(@enroll.to_json)\n end",
"def show\n @consensu = Consensu.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @consensu }\n end\n end",
"def show\n @possess = Possess.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @possess }\n end\n end",
"def index\n\n if params[:ventas_seguimiento]\n cliente_id = params[:ventas_seguimiento][:cliente_id]\n @ventas_seguimientos = Ventas::Seguimiento.where(\"cliente_id = ?\",cliente_id).order(\"created_at DESC\").paginate(:page => params[:page], :per_page => 5)\n @seguimientos = Ventas::Seguimiento.new(:cliente_id => cliente_id)\n else\n @ventas_seguimientos = Ventas::Seguimiento.order(\"created_at DESC\").paginate(:page => params[:page], :per_page => 5)\n @seguimientos = Ventas::Seguimiento.new\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ventas_seguimientos }\n end\n end",
"def index\n @profiles = Profile.all\n @original_niche = get_subscriber_details(@profiles, \"niche\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @profiles }\n end\n end",
"def index\n @denuncia = Denuncium.all\n\n render json: @denuncia\n end",
"def show\n @repuesto = Repuesto.find(params[:id])\n respond_to do |format|\n format.html { render :show }\n format.json { render json: @repuesto.to_json }\n end\n end",
"def index\n @seihinns = Seihinn.all\n end",
"def show\n @national_rank = NationalRank.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @national_rank }\n end\n end",
"def show\n @reserved_username = ReservedUsername.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @reserved_username }\n end\n end",
"def new\n @asesor = Asesor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @asesor }\n end\n end",
"def get_skus()\n\tputs \"Getting skus\"\n\tresponse = request_get(\"/api/sku\")\n\tputs response.body\nend",
"def new\n @soiree = Soiree.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @soiree }\n end\n end",
"def new\n @verse = Verse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @verse }\n end\n end",
"def new\n @verse = Verse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @verse }\n end\n end",
"def new\n @verse = Verse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @verse }\n end\n end",
"def new\n @site = Site.new\n @profile_id = Profile.where(:username=>session[:username]).first.id\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @site }\n end\n end",
"def new\n @stundent = Stundent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stundent }\n end\n end",
"def index\n # TODO pull out api key before pushing to github & pull out binding prys\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 subId = message[:data][0][:id]\n else\n # Port is open in our router\n params = { url: SUBSCRIPTION_URL, events: ['invitee.created', 'invitee.canceled'] }\n newRes = HTTParty.post URL, body: params, headers: HEADERS\n message = JSON.parse newRes.body, symbolize_names: true\n # TODO need error handling\n subId = message[:id]\n end\n end\n end",
"def show\n render json: @pub\n end",
"def show\n @seguidore = Seguidore.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @seguidore }\n end\n end",
"def index\n @conns = current_user.conns\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @conns }\n end\n end",
"def index\n @notadedebito = Notadedebito.find(params[:notadedebito_id])\n @renglon_nddndcs = @notadedebito.renglon_nddndcs\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @renglon_nddndcs }\n end\n end",
"def room_descriptions_method\r\n my_port = 8081\r\n htttproomnumber = $roomnumber\r\n roomsNtext = \"/#{htttproomnumber}\"\r\n rooms_message = \"/rooms#{roomsNtext}\"\r\n url = URI.parse(\"http://localhost:#{my_port}#{rooms_message}\")\r\n req = Net::HTTP::Get.new(url.to_s)\r\n res = Net::HTTP.start(url.host, url.port){|http|\r\n http.request(req)\r\n }\r\n my_json = JSON.parse(res.body) \r\n return my_json[\"room\"].to_s\r\nend",
"def new\n @csosn = Csosn.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @csosn }\n end\n end",
"def index\n @regiones = Region.all\n\n render json: @regiones\n end",
"def new\n @suplente = Suplente.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @suplente }\n end\n end"
] | [
"0.60660243",
"0.5961539",
"0.5942432",
"0.5841825",
"0.57584375",
"0.57443655",
"0.5744085",
"0.5731102",
"0.5731102",
"0.5712483",
"0.5704033",
"0.56945145",
"0.56624126",
"0.5638775",
"0.5638775",
"0.5638775",
"0.5629483",
"0.5583855",
"0.557659",
"0.5575616",
"0.5567756",
"0.55668354",
"0.55585885",
"0.55570966",
"0.55479425",
"0.55467904",
"0.55365914",
"0.55283606",
"0.55186474",
"0.55181795",
"0.55131894",
"0.5499926",
"0.5490189",
"0.5482652",
"0.54778594",
"0.547028",
"0.5467651",
"0.5460661",
"0.5455894",
"0.5451869",
"0.545097",
"0.5443021",
"0.5423962",
"0.542267",
"0.5421859",
"0.54177254",
"0.541445",
"0.541445",
"0.54071236",
"0.5399883",
"0.53973264",
"0.5395609",
"0.538727",
"0.5386985",
"0.53860915",
"0.538581",
"0.53796196",
"0.5372113",
"0.5366045",
"0.5356338",
"0.5355878",
"0.5350671",
"0.53441817",
"0.53437537",
"0.5343543",
"0.53430915",
"0.5341833",
"0.5340702",
"0.53403366",
"0.53391886",
"0.5337667",
"0.5337667",
"0.5330531",
"0.5330229",
"0.5329529",
"0.53277993",
"0.5327759",
"0.53265727",
"0.5323086",
"0.5322512",
"0.5321221",
"0.53206027",
"0.53193986",
"0.53176403",
"0.53174996",
"0.5312458",
"0.53095365",
"0.53095365",
"0.53095365",
"0.53089154",
"0.53066295",
"0.5306243",
"0.53014815",
"0.53012574",
"0.53009653",
"0.5294619",
"0.5294476",
"0.52942115",
"0.52941656",
"0.52877903"
] | 0.5800752 | 4 |
GET /nurses/new GET /nurses/new.json | def new
@nurse = Nurse.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @nurse }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @nail_salon = NailSalon.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @nail_salon }\n end\n end",
"def new\n @newspage = Newspage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @newspage }\n end\n end",
"def new\n @possess = Possess.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @possess }\n end\n end",
"def new\n @snp = Snp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @snp }\n end\n end",
"def new\n @nave = Nave.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @nave }\n end\n end",
"def new\n @title = t('view.providers.new_title')\n @provider = Provider.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @provider }\n end\n end",
"def new\n @suplente = Suplente.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @suplente }\n end\n end",
"def new\n @verse = Verse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @verse }\n end\n end",
"def new\n @verse = Verse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @verse }\n end\n end",
"def new\n @verse = Verse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @verse }\n end\n end",
"def new\n @url = Url.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @url }\n end\n end",
"def new\n @lost = Lost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lost }\n end\n end",
"def new\n @nursing_time = NursingTime.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @nursing_time }\n end\n end",
"def new\n @stundent = Stundent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stundent }\n end\n end",
"def new\n @entrant = Entrant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entrant }\n end\n end",
"def new\n @entrant = Entrant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entrant }\n end\n end",
"def new\n @studnet = Studnet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @studnet }\n end\n end",
"def new\n @surname = Surname.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @surname }\n end\n end",
"def new\n @clue = Clue.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @clue }\n end\n end",
"def new\n @clue = Clue.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @clue }\n end\n end",
"def new\n @nlp = Nlp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @nlp }\n end\n end",
"def new\n @srsa = Srsa.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @srsa }\n end\n end",
"def new\n @seguidore = Seguidore.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @seguidore }\n end\n end",
"def new\n @sezione = Sezione.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sezione }\n end\n end",
"def new\n @selecao = Selecao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @selecao }\n end\n end",
"def new\n @sesion = Sesion.where(entidad_paraestatal_id: @entidad_paraestatal.id).new\n #@sesion.suplente = Suplente.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sesion }\n end\n end",
"def new\n post = Post.new\n render json: post\n end",
"def new\n @precinct = Precinct.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @precinct }\n end\n end",
"def new\n @u = U.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @u }\n end\n end",
"def new\n @torneo = Torneo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @torneo }\n end\n end",
"def new\n @nabe = Nabe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @nabe }\n end\n end",
"def new\n @sitio_entrega = SitioEntrega.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sitio_entrega }\n end\n end",
"def new\n @spdatum = Spdatum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @spdatum }\n end\n end",
"def new\n @sotrudniki = Sotrudniki.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sotrudniki }\n end\n end",
"def new\n @stone = Stone.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stone }\n end\n end",
"def new\n @unp = Unp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @unp }\n end\n end",
"def new\n @trnodo = Trnodo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trnodo }\n end\n end",
"def new\n @lore = Lore.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lore }\n end\n end",
"def new\n @ident = Ident.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ident }\n end\n end",
"def new\n @csosn = Csosn.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @csosn }\n end\n end",
"def new\n @repuestum = Repuestum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @repuestum }\n end\n end",
"def new\n @seguro = Seguro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @seguro }\n end\n end",
"def new\n @noto = Noto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @noto }\n end\n end",
"def new\n @pub = Pub.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pub }\n end\n end",
"def new\n @new_policy = NewPolicy.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @new_policy }\n end\n end",
"def new\n @spiel = Spiel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @spiel }\n end\n end",
"def new\n @provider = Provider.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @provider }\n end\n end",
"def new\n @provider = Provider.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @provider }\n end\n end",
"def new\n puts 'NEW METHOD'\n @pessoa = Pessoa.new\n @pessoa.enderecos.build\n 2.times { @pessoa.telefones.build }\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pessoa }\n end\n end",
"def new\n @spieler = Spieler.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @spieler }\n end\n end",
"def new\n authorize! :new, @mesasredonda\n @mesasredonda = Mesasredonda.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mesasredonda }\n end\n end",
"def new\n @county = County.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @county }\n end\n end",
"def new\n @pologeno = Pologeno.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pologeno }\n end\n end",
"def new\n @tenni = Tenni.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tenni }\n end\n end",
"def new\n @asesor = Asesor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @asesor }\n end\n end",
"def new\n @social_network = SocialNetwork.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @social_network }\n end\n end",
"def new\n @nasp_rail = NaspRail.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @nasp_rail }\n end\n end",
"def new\n @reserf = Reserve.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @reserf }\n end\n end",
"def new\n @stable = Stable.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stable }\n end\n end",
"def new\n @lease = Lease.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @lease }\n end\n end",
"def new\n @ninja = Ninja.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ninja }\n end\n end",
"def new\n @identifier = Identifier.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @identifier }\n end\n end",
"def new\n @ventas_seguimiento = Ventas::Seguimiento.new params[:ventas_seguimiento]\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ventas_seguimiento }\n end\n end",
"def new\n @pinn = current_user.pinns.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pinn }\n end\n end",
"def new\n @national_rank = NationalRank.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @national_rank }\n end\n end",
"def new\n @skid = Skid.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @skid }\n end\n end",
"def new\n @name = Name.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @name }\n end\n end",
"def new\n @respuesta = Respuesta.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @respuesta }\n end\n end",
"def new\n @name = Name.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @name }\n end\n end",
"def new\n @utente = Utente.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @utente }\n end\n end",
"def new\n @sell = Sell.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sell }\n end\n end",
"def new\n @niveau = Niveau.new\n authorize! :new, @niveau\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @niveau }\n end\n end",
"def new\n @uniqueid = Uniqueid.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @uniqueid }\n end\n end",
"def new\n @suc = Suc.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @suc }\n end\n end",
"def new\n @produccion = Produccion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @produccion }\n end\n end",
"def new\n @nightclub = Nightclub.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @nightclub }\n end\n end",
"def new\n @produccion = Produccion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @produccion }\n end\n end",
"def new\n @network = Network.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @network }\n end\n end",
"def new\n @po = Po.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @po }\n end\n end",
"def new\n @neighborhood = Neighborhood.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @neighborhood }\n end\n end",
"def new\n @neighborhood = Neighborhood.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @neighborhood }\n end\n end",
"def new\n @party = Party.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @party }\n end\n end",
"def new\n @vpn = Vpn.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @vpn }\n end\n end",
"def new\n @vpn = Vpn.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @vpn }\n end\n end",
"def new\n respond_with( @nurse = Nurse.new )\n end",
"def new\r\n @antenne = Antenne.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @antenne }\r\n end\r\n end",
"def new\n @ridol = Ridol.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ridol }\n end\n end",
"def new\n @entry = Entry.new\n\n render json: @entry\n end",
"def new\n @adress = Adresse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @adress }\n end\n end",
"def new\n @rsvp = Rsvp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @rsvp }\n end\n end",
"def new\n @rsvp = Rsvp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @rsvp }\n end\n end",
"def new\r\n @usertable = Usertable.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @usertable }\r\n end\r\n end",
"def new\n @community = Community.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @community }\n end\n end",
"def new\n @sitio = Sitio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sitio }\n end\n end",
"def new\n @newspost = Newspost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @newspost }\n end\n end",
"def new\n # Create new news\n @news = News.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @news }\n end\n end",
"def new\n @minicurso = Minicurso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @minicurso }\n end\n end",
"def new\n @substrate = Substrate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @substrate }\n end\n end",
"def new\n @nyan = Nyan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @nyan }\n end\n end",
"def new\n @uniprot = Uniprot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @uniprot }\n end\n end"
] | [
"0.72123146",
"0.702307",
"0.70105606",
"0.69525266",
"0.69315284",
"0.68915606",
"0.68661326",
"0.68593687",
"0.68593687",
"0.68593687",
"0.6857373",
"0.6853299",
"0.68462634",
"0.6836695",
"0.6831094",
"0.6831094",
"0.68307436",
"0.6830159",
"0.68199927",
"0.68199927",
"0.68140256",
"0.68114835",
"0.6798455",
"0.6798197",
"0.67826605",
"0.67745334",
"0.67645985",
"0.67621684",
"0.6759058",
"0.67497104",
"0.6744452",
"0.67331517",
"0.67325157",
"0.6725632",
"0.6720729",
"0.6716333",
"0.6715987",
"0.6708589",
"0.67051655",
"0.67045605",
"0.6698559",
"0.6681417",
"0.6681268",
"0.66796106",
"0.6671983",
"0.6666997",
"0.6656103",
"0.6656103",
"0.6655901",
"0.66507894",
"0.66477084",
"0.6646462",
"0.6646266",
"0.6640155",
"0.66379696",
"0.66302997",
"0.66298306",
"0.6623707",
"0.66221315",
"0.66185623",
"0.6613117",
"0.6610006",
"0.66099507",
"0.6608714",
"0.6607825",
"0.6600214",
"0.65945935",
"0.65917593",
"0.6591298",
"0.65891325",
"0.65864265",
"0.65818274",
"0.65804887",
"0.6579277",
"0.6577975",
"0.65763587",
"0.65762246",
"0.6573308",
"0.6571557",
"0.6568921",
"0.6568921",
"0.65675455",
"0.65669674",
"0.65669674",
"0.65646774",
"0.6564282",
"0.65620327",
"0.6559873",
"0.6559338",
"0.6553753",
"0.6553753",
"0.65471184",
"0.6546375",
"0.65460473",
"0.65459144",
"0.6541109",
"0.65397334",
"0.6533103",
"0.65325904",
"0.6531954"
] | 0.6925118 | 5 |
POST /nurses POST /nurses.json | def create
@nurse = Nurse.new(params[:nurse])
respond_to do |format|
if @nurse.save
format.html { redirect_to @nurse, notice: 'Nurse was successfully created.' }
format.json { render json: @nurse, status: :created, location: @nurse }
else
format.html { render action: "new" }
format.json { render json: @nurse.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @onsen = Onsen.new(onsen_params)\n\n respond_to do |format|\n if @onsen.save\n format.html { redirect_to @onsen, notice: 'Onsen was successfully created.' }\n format.json { render :show, status: :created, location: @onsen }\n else\n format.html { render :new }\n format.json { render json: @onsen.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @nepal = Nepal.new(nepal_params)\n\n if @nepal.save\n render json: @nepal, status: :created, location: @nepal\n else\n render json: @nepal.errors, status: :unprocessable_entity\n end\n end",
"def create\n @sundry_grn = SundryGrn.new(params[:sundry_grn])\n\n respond_to do |format|\n if @sundry_grn.save\n format.html { redirect_to @sundry_grn, :notice => 'Sundry grn was successfully created.' }\n format.json { render :json => @sundry_grn, :status => :created, :location => @sundry_grn }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @sundry_grn.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @nail_salon = NailSalon.new(params[:nail_salon])\n\n respond_to do |format|\n if @nail_salon.save\n format.html { redirect_to @nail_salon, notice: 'Nail salon was successfully created.' }\n format.json { render json: @nail_salon, status: :created, location: @nail_salon }\n else\n format.html { render action: \"new\" }\n format.json { render json: @nail_salon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @snail = Snail.new(name: params[:snail][:name], owner: params[:snail][:owner], description: params[:snail][:description], speed: Random.new.rand(1..10), endurance: Random.new.rand(1..10), motivation: Random.new.rand(1..10), win: 0, lose: 0)\n\n respond_to do |format|\n if @snail.save\n format.html { redirect_to @snail, notice: 'Snail was successfully created.' }\n format.json { render :show, status: :created, location: @snail }\n else\n format.html { render :new }\n format.json { render json: @snail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @nursery_table = NurseryTable.new(nursery_table_params)\n\n respond_to do |format|\n if @nursery_table.save\n format.html { redirect_to @nursery_table, notice: \"Nursery table was successfully created.\" }\n format.json { render :show, status: :created, location: @nursery_table }\n else\n format.html { render :new }\n format.json { render json: @nursery_table.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @siren = Siren.new(siren_params)\n\n respond_to do |format|\n if @siren.save\n format.html { redirect_to @siren, notice: 'Siren was successfully created.' }\n format.json { render :show, status: :created, location: @siren }\n else\n format.html { render :new }\n format.json { render json: @siren.errors, status: :unprocessable_entity }\n end\n end\n end",
"def moip_post\n @nasp_rail = NaspRail.new(params[:nasp_rail])\n\n format.html { redirect_to @nasp_rail, :notice => 'Nova entrada criada com sucesso.' }\n format.json { render :json => @nasp_rail, :status => :created, :location => @nasp_rail }\n end",
"def create\n @snail = Snail.new(snail_params)\n\n respond_to do |format|\n if @snail.save\n format.html { redirect_to @snail, notice: 'Snail was successfully created.' }\n format.json { render :show, status: :created, location: @snail }\n else\n format.html { render :new }\n format.json { render json: @snail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @nineteen = Nineteen.new(nineteen_params)\n\n respond_to do |format|\n if @nineteen.save\n format.html { redirect_to @nineteen, notice: 'Nineteen was successfully created.' }\n format.json { render action: 'show', status: :created, location: @nineteen }\n else\n format.html { render action: 'new' }\n format.json { render json: @nineteen.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @studnet = Studnet.new(params[:studnet])\n\n respond_to do |format|\n if @studnet.save\n format.html { redirect_to @studnet, notice: 'Studnet was successfully created.' }\n format.json { render json: @studnet, status: :created, location: @studnet }\n else\n format.html { render action: \"new\" }\n format.json { render json: @studnet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @nippou = Nippou.new(nippou_params)\n\n respond_to do |format|\n if @nippou.save\n format.html { redirect_to @nippou, notice: 'Nippou was successfully created.' }\n format.json { render action: 'show', status: :created, location: @nippou }\n else\n format.html { render action: 'new' }\n format.json { render json: @nippou.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @nave = Nave.new(params[:nave])\n\n respond_to do |format|\n if @nave.save\n format.html { redirect_to @nave, notice: 'Nave was successfully created.' }\n format.json { render json: @nave, status: :created, location: @nave }\n else\n format.html { render action: \"new\" }\n format.json { render json: @nave.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_and_invitation_studant(params = {})\n run(:post, \"/invitations\", [201,422], JSON.dump(params))\n end",
"def create\n @studnet = Studnet.new(studnet_params)\n\n respond_to do |format|\n if @studnet.save\n format.html { redirect_to @studnet, notice: 'Studnet was successfully created.' }\n format.json { render :show, status: :created, location: @studnet }\n else\n format.html { render :new }\n format.json { render json: @studnet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def POST; end",
"def create\n @nsgrule = Nsgrule.new(nsgrule_params)\n\n respond_to do |format|\n if @nsgrule.save\n format.html { redirect_to @nsgrule, notice: 'Nsgrule was successfully created.' }\n format.json { render :show, status: :created, location: @nsgrule }\n else\n format.html { render :new }\n format.json { render json: @nsgrule.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n authorize Entrepreneur\n @entrepreneur = Entrepreneur.new(entrepreneur_params)\n\n respond_to do |format|\n if @entrepreneur.save\n format.html { redirect_to @entrepreneur, notice: 'Entrepreneur was successfully created.' }\n format.json { render :show, status: :created, location: @entrepreneur }\n else\n format.html { render :new }\n format.json { render json: @entrepreneur.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @entrant = Entrant.new(params[:entrant])\n\n respond_to do |format|\n if @entrant.save\n format.html { redirect_to @entrant, notice: 'Entrant was successfully created.' }\n format.json { render json: @entrant, status: :created, location: @entrant }\n else\n format.html { render action: \"new\" }\n format.json { render json: @entrant.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @persosn = Persosn.new(persosn_params)\n\n respond_to do |format|\n if @persosn.save\n format.html { redirect_to @persosn, notice: 'Persosn was successfully created.' }\n format.json { render :show, status: :created, location: @persosn }\n else\n format.html { render :new }\n format.json { render json: @persosn.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @respuesta = Respuesta.new(params[:respuesta])\n\n if @respuesta.save\n render json: @respuesta, status: :created, location: @respuesta\n else\n render json: @respuesta.errors, status: :unprocessable_entity\n end\n end",
"def create\n @sinnoh = Sinnoh.new(sinnoh_params)\n\n respond_to do |format|\n if @sinnoh.save\n format.html { redirect_to @sinnoh, notice: 'Sinnoh was successfully created.' }\n format.json { render :show, status: :created, location: @sinnoh }\n else\n format.html { render :new }\n format.json { render json: @sinnoh.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @studen = Studen.new(studen_params)\n\n respond_to do |format|\n if @studen.save\n format.html { redirect_to @studen, notice: 'Studen was successfully created.' }\n format.json { render :show, status: :created, location: @studen }\n else\n format.html { render :new }\n format.json { render json: @studen.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @seihinn = Seihinn.new(seihinn_params)\n\n respond_to do |format|\n if @seihinn.save\n format.html { redirect_to @seihinn, notice: \"Seihinn was successfully created.\" }\n format.json { render :show, status: :created, location: @seihinn }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @seihinn.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @nafe = Nave.new(nafe_params)\n\n respond_to do |format|\n if @nafe.save\n format.html { redirect_to @nafe, notice: 'Nave was successfully created.' }\n format.json { render :show, status: :created, location: @nafe }\n else\n format.html { render :new }\n format.json { render json: @nafe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @naren = Naren.new(naren_params)\n\n respond_to do |format|\n if @naren.save\n format.html { redirect_to @naren, notice: 'Naren was successfully created.' }\n format.json { render :show, status: :created, location: @naren }\n else\n format.html { render :new }\n format.json { render json: @naren.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @uen = Uen.new(uen_params)\n\n respond_to do |format|\n if @uen.save\n format.html { redirect_to @uen, notice: 'Uen was successfully created.' }\n format.json { render :show, status: :created, location: @uen }\n else\n format.html { render :new }\n format.json { render json: @uen.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @renseignement = Renseignement.new(renseignement_params)\n \n\n respond_to do |format|\n if @renseignement.save\n format.html { redirect_to @renseignement, notice: \"Renseignement was successfully created.\" }\n format.json { render :show, status: :created, location: @renseignement }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @renseignement.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @possess = Possess.new(params[:possess])\n\n respond_to do |format|\n if @possess.save\n format.html { redirect_to @possess, notice: 'Possess was successfully created.' }\n format.json { render json: @possess, status: :created, location: @possess }\n else\n format.html { render action: \"new\" }\n format.json { render json: @possess.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create(params)\n http.post(\"/nfse\", { body: params }) do |response|\n respond_with_entity(response)\n end\n end",
"def post\n Rentlinx.client.post(self)\n end",
"def create\n @sponsor = Sponsor.new(sponsor_params)\n\n respond_to do |format|\n if @sponsor.save\n format.html { redirect_to sponsors_url, notice: 'El auspiciante se creó correctamente.' }\n format.json { render :show, status: :created, location: sponsors_url }\n else\n format.html { render :new }\n format.json { render json: @sponsor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create(params = {})\n wrapped_params = { insurance: params }\n @client.make_request(:post, 'insurances', MODEL_CLASS, wrapped_params)\n end",
"def create\n @nurse = Nurse.new(params[:nurse])\n flash[:notice] = 'Created Nurse.' if @nurse.save\n respond_with @nurse\n end",
"def new\n @nail_salon = NailSalon.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @nail_salon }\n end\n end",
"def create\n # Loggin data from POST\n logger.debug \"--\" * 50\n logger.debug \"Data from POST: #{params.inspect}\"\n logger.debug \"--\" * 50\n\n @nasp_rail = NaspRail.new(params.keep_if { |key, value| NaspRail.column_names.include? key })\n\n respond_to do |format|\n if @nasp_rail.save\n format.html { redirect_to @nasp_rail, :notice => 'Nova entrada criada com sucesso.' }\n format.json { render :json => @nasp_rail, :status => :created, :location => @nasp_rail }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @nasp_rail.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @niveis_ensino = NiveisEnsino.new(params[:niveis_ensino])\n\n respond_to do |format|\n if @niveis_ensino.save\n format.html { redirect_to(@niveis_ensino, :notice => 'Niveis ensino cadastrado com sucesso.') }\n format.xml { render :xml => @niveis_ensino, :status => :created, :location => @niveis_ensino }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @niveis_ensino.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @niveau = Niveau.new(params[:niveau])\n authorize! :create, @niveau\n respond_to do |format|\n if @niveau.save\n format.html { redirect_to @niveau, notice: 'Niveau werd succesvol aangemaakt.' }\n format.json { render json: @niveau, status: :created, location: @niveau }\n else\n format.html { render action: \"new\" }\n format.json { render json: @niveau.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @nebulosa = Nebulosa.new(nebulosa_params)\n\n respond_to do |format|\n if @nebulosa.save\n format.html { redirect_to @nebulosa, notice: 'Nebulosa was successfully created.' }\n format.json { render :show, status: :created, location: @nebulosa }\n else\n format.html { render :new }\n format.json { render json: @nebulosa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @surrender = @insurance.surrenders.new(surrender_params)\n\n respond_to do |format|\n if @surrender.save\n format.html { redirect_to [@surrender.insurance, @surrender], notice: 'Surrender was successfully created.' }\n format.json { render :show, status: :created, location: [@surrender.insurance, @surrender] }\n else\n format.html { render :new }\n format.json { render json: @surrender.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @snp = Snp.new(params[:snp])\n\n respond_to do |format|\n if @snp.save\n format.html { redirect_to @snp, notice: 'Snp was successfully created.' }\n format.json { render json: @snp, status: :created, location: @snp }\n else\n format.html { render action: \"new\" }\n format.json { render json: @snp.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @nursing_time = NursingTime.new(params[:nursing_time])\n\n respond_to do |format|\n if @nursing_time.save\n format.html { redirect_to @nursing_time, notice: 'Nursing time was successfully created.' }\n format.json { render json: @nursing_time, status: :created, location: @nursing_time }\n else\n format.html { render action: \"new\" }\n format.json { render json: @nursing_time.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sejour = current_user.sejours.build(sejour_params)\n\n respond_to do |format|\n if @sejour.save\n format.html { redirect_to @sejour, notice: 'Le sejour a bien ete cree.' }\n format.json { render :show, status: :created, location: @sejour }\n else\n format.html { render :new }\n format.json { render json: @sejour.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @souvenir = Souvenir.new(souvenir_params)\n\n respond_to do |format|\n if @souvenir.save\n format.html { redirect_to @souvenir, notice: 'Souvenir was successfully created.' }\n format.json { render :show, status: :created, location: @souvenir }\n else\n format.html { render :new }\n format.json { render json: @souvenir.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @manage_nourish = ManageNourish.new(manage_nourish_params)\n\n respond_to do |format|\n if @manage_nourish.save\n format.html { redirect_to @manage_nourish, notice: 'Manage nourish was successfully created.' }\n format.json { render action: 'show', status: :created, location: @manage_nourish }\n else\n format.html { render action: 'new' }\n format.json { render json: @manage_nourish.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @uzser = Uzser.new(uzser_params)\n\n respond_to do |format|\n if @uzser.save\n format.html { redirect_to @uzser, notice: 'Uzser was successfully created.' }\n format.json { render :show, status: :created, location: @uzser }\n else\n format.html { render :new }\n format.json { render json: @uzser.errors, status: :unprocessable_entity }\n end\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 create\n @otg_sess = OtgSess.new(otg_sess_params)\n\n respond_to do |format|\n if @otg_sess.save\n format.html { redirect_to @otg_sess, notice: 'Otg sess was successfully created.' }\n format.json { render :show, status: :created, location: @otg_sess }\n else\n format.html { render :new }\n format.json { render json: @otg_sess.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sumne = Sumne.new(sumne_params)\n\n respond_to do |format|\n if @sumne.save\n format.html { redirect_to @sumne, notice: 'Sumne was successfully created.' }\n format.json { render :show, status: :created, location: @sumne }\n else\n format.html { render :new }\n format.json { render json: @sumne.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @daw_encuest = DawEncuest.new(daw_encuest_params)\n\n respond_to do |format|\n if @daw_encuest.save\n format.html { redirect_to @daw_encuest, notice: 'Daw encuest was successfully created.' }\n format.json { render :show, status: :created, location: @daw_encuest }\n else\n format.html { render :new }\n format.json { render json: @daw_encuest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @rameur = Rameur.new(rameur_params)\n\n respond_to do |format|\n if @rameur.save\n sign_in @rameur\n # Tell the UserMailer to send a welcome Email after save\n UserMailer.welcome_email(@rameur).deliver\n\n format.html { redirect_to @rameur, notice: \"Vous êtes membre, félicitations!\" }\n format.json { render action: 'show', status: :created, location: @rameur }\n else\n format.html { render action: 'new' }\n format.json { render json: @rameur.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create \n num_days = (Date.parse(params['rent_info']['end_date']).mjd - Date.parse(params['rent_info']['start_date']).mjd) \n total = num_days * params['rent_info']['price_per_day']\n # byebug\n if User.find(params['rent_info']['owner_id'])\n user = User.find(params['rent_info']['owner_id'])\n user.money_made += total \n user.save\n end\n\n renter_post = RenterPost.create(\n renter_id: params['rent_info']['renter_id'],\n post_id: params['rent_info'][\"post_id\"],\n start_date: params['rent_info'][\"start_date\"],\n end_date: params['rent_info'][\"end_date\"],\n status: params['rent_info'][\"status\"]\n )\n if renter_post \n render json: renter_post\n else\n render json: {error: \"Could not create Renter Post\"}\n end\n end",
"def create\n @enqury = Enqury.new(enqury_params)\n\n respond_to do |format|\n if @enqury.save\n format.html { redirect_to @enqury, notice: 'Enqury was successfully created.' }\n format.json { render :show, status: :created, location: @enqury }\n else\n format.html { render :new }\n format.json { render json: @enqury.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\r\n @respuestum = Respuestum.new(respuestum_params)\r\n\r\n respond_to do |format|\r\n if @respuestum.save\r\n format.html { redirect_to @respuestum, notice: 'Respuestum was successfully created.' }\r\n format.json { render :show, status: :created, location: @respuestum }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @respuestum.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n # binding.pry\n @pub = Pub.new pub_params\n # binding.pry\n @pub.username = @pub.username.downcase\n if @pub.save\n render :json => @pub\n else\n render :json => {:errors => @pub.errors}\n end\n end",
"def create\n @espn_game = EspnGame.new(espn_game_params)\n\n respond_to do |format|\n if @espn_game.save\n format.html { redirect_to @espn_game, notice: 'Espn game was successfully created.' }\n format.json { render action: 'show', status: :created, location: @espn_game }\n else\n format.html { render action: 'new' }\n format.json { render json: @espn_game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @nabe = Nabe.new(params[:nabe])\n\n respond_to do |format|\n if @nabe.save\n format.html { redirect_to @nabe, notice: 'Nabe was successfully created.' }\n format.json { render json: @nabe, status: :created, location: @nabe }\n else\n format.html { render action: \"new\" }\n format.json { render json: @nabe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @respuesta = Respuesta.new(params[:respuesta])\n\n respond_to do |format|\n if @respuesta.save\n format.html { redirect_to @respuesta, notice: 'Respuesta was successfully created.' }\n format.json { render json: @respuesta, status: :created, location: @respuesta }\n else\n format.html { render action: \"new\" }\n format.json { render json: @respuesta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @encuestum = Encuestum.new(params[:encuestum])\n\n respond_to do |format|\n if @encuestum.save\n format.html { redirect_to @encuestum, notice: 'Encuestum was successfully created.' }\n format.json { render json: @encuestum, status: :created, location: @encuestum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @encuestum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @nitrou = Nitrou.new(nitrou_params)\n\n respond_to do |format|\n if @nitrou.save\n format.html { redirect_to @nitrou, notice: 'Nitrou was successfully created.' }\n format.json { render :show, status: :created, location: @nitrou }\n else\n format.html { render :new }\n format.json { render json: @nitrou.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @souvenior = Souvenior.new(souvenior_params)\n\n respond_to do |format|\n if @souvenior.save\n format.html { redirect_to root_path, notice: 'Souvenior was successfully created.' }\n format.json { render :show, status: :created, location: @souvenior }\n else\n format.html { render :new }\n format.json { render json: @souvenior.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @onske = Onske.new(params[:onske])\n\n respond_to do |format|\n if @onske.save\n format.html { redirect_to @onske, notice: 'Onske was successfully created.' }\n format.json { render json: @onske, status: :created, location: @onske }\n else\n format.html { render action: \"new\" }\n format.json { render json: @onske.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @suplente = Suplente.new(params[:suplente])\n\n respond_to do |format|\n if @suplente.save\n format.html { redirect_to @suplente, notice: 'Lista acuerdo was successfully created.' }\n format.json { render json: @suplente, status: :created, location: @suplente }\n else\n format.html { render action: \"new\" }\n format.json { render json: @suplente.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(url, params = {})\n client.post(url, params).body\n end",
"def create\n @repuestum = Repuestum.new(params[:repuestum])\n\n respond_to do |format|\n if @repuestum.save\n format.html { redirect_to @repuestum, notice: 'Repuestum was successfully created.' }\n format.json { render json: @repuestum, status: :created, location: @repuestum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @repuestum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @urij = Urij.new(urij_params)\n\n respond_to do |format|\n if @urij.save\n format.html { redirect_to @urij, notice: 'Urij was successfully created.' }\n format.json { render action: 'show', status: :created, location: @urij }\n else\n format.html { render action: 'new' }\n format.json { render json: @urij.errors, status: :unprocessable_entity }\n end\n end\n end",
"def ns_catalogue_poster()\n url = 'http://apis.t-nova.eu:4011/network-services'\n puts url\n uri = URI.parse(url)\n puts uri\n\n params = File.read('config/catalogue_nsd.json')\n puts params\n\n http = Net::HTTP.new(uri.host, uri.port)\n #http.use_ssl = true\n #http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Post.new(uri.request_uri)\n\n #request.set_form_data('code' => token, 'client_id' => @client_id, 'client_secret' => client_secret, 'redirect_uri' => googleauth_url, 'grant_type' => 'authorization_code')\n request.content_type = 'application/json'\n request.body = params\n response = http.request(request)\n response.code\n\n if response.code == 201\n puts \"#{response.code}\".color(Colors::GREEN)\n else\n puts \"#{response.code}\".color(Colors::RED)\n end\n\n return response.code\n end",
"def create\n @ess = Esse.new(ess_params)\n\n respond_to do |format|\n if @ess.save\n format.html { redirect_to esses_url, notice: 'Esse was successfully created.' }\n format.json { render :show, status: :created, location: @ess }\n else\n format.html { render :new }\n format.json { render json: @ess.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @srsa = Srsa.new(params[:srsa])\n\n respond_to do |format|\n if @srsa.save\n format.html { redirect_to :action => 'index' }\n format.json { render json: @srsa, status: :created, location: @srsa }\n else\n format.html { render action: \"new\" }\n format.json { render json: @srsa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def criar_sobrevivente\n @suvivor = Sobrevivente.create(\n name: params[:name], genero: params[:genero], idade: params[:idade],\n lat: params[:lat], lon: params[:lon],\n agua: params[:agua], comida: params[:comida], medicamento: params[:medicamento],\n municao: params[:municao]\n )\n render json: @suvivor\n end",
"def create\n @usern = Usern.new(usern_params)\n\n respond_to do |format|\n if @usern.save\n format.html { redirect_to @usern, notice: 'Usern was successfully created.' }\n format.json { render :show, status: :created, location: @usern }\n else\n format.html { render :new }\n format.json { render json: @usern.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @souvenir = Souvenir.new(souvenir_params)\n\n respond_to do |format|\n if @souvenir.save\n format.html { redirect_to @souvenir, notice: 'Souvenir was successfully created.' }\n format.json { render json: { user: @souvenir, status: 200, description: 'Souvenir was successfully created.' }, status: :ok }\n else\n format.html { render :new }\n format.json { render json: { user: @souvenir, status: 500, description: 'Internal server error : faliled to save' }, status: :internal_server_error }\n end\n end\n end",
"def create\n @pinn = current_user.pinns.new(params[:pinn])\n\n respond_to do |format|\n if @pinn.save\n format.html { redirect_to @pinn, notice: 'Pinn was successfully created.' }\n format.json { render json: @pinn, status: :created, location: @pinn }\n else\n format.html { render action: \"new\" }\n format.json { render json: @pinn.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sessao = Sessao.new(sessao_params)\n\n respond_to do |format|\n if @sessao.save\n format.html { redirect_to @sessao, notice: 'Sessao was successfully created.' }\n format.json { render :show, status: :created, location: @sessao }\n else\n format.html { render :new }\n format.json { render json: @sessao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @possess = Possess.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @possess }\n end\n end",
"def create\n @asesor = Asesor.new(params[:asesor])\n\n respond_to do |format|\n if @asesor.save\n format.html { redirect_to @asesor, notice: 'Asesor was successfully created.' }\n format.json { render json: @asesor, status: :created, location: @asesor }\n else\n format.html { render action: \"new\" }\n format.json { render json: @asesor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @studnet = Studnet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @studnet }\n end\n end",
"def create\n @seniority = Seniority.new(seniority_params)\n\n respond_to do |format|\n if @seniority.save\n format.html { redirect_to @seniority, notice: \"Seniority was successfully created.\" }\n format.json { render :show, status: :created, location: @seniority }\n else\n format.html { render :new }\n format.json { render json: @seniority.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @nino = Nino.new(nino_params)\n\n respond_to do |format|\n if @nino.save\n format.html { redirect_to ninos_path, notice: \"El niño #{@nino.nombre} ha sido creado.\" }\n format.json { render action: 'show', status: :created, location: @nino }\n else\n format.html { render action: 'new' }\n format.json { render json: @nino.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @entrant = Entrant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entrant }\n end\n end",
"def new\n @entrant = Entrant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entrant }\n end\n end",
"def create\n @verse = Verse.new(params[:verse])\n\n respond_to do |format|\n if @verse.save\n format.html { redirect_to @verse, notice: 'Verse was successfully created.' }\n format.json { render json: @verse, status: :created, location: @verse }\n else\n format.html { render action: \"new\" }\n format.json { render json: @verse.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @verse = Verse.new(params[:verse])\n\n respond_to do |format|\n if @verse.save\n format.html { redirect_to @verse, notice: 'Verse was successfully created.' }\n format.json { render json: @verse, status: :created, location: @verse }\n else\n format.html { render action: \"new\" }\n format.json { render json: @verse.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @renter = Renter.new(params[:renter])\n @locals = User.where(:city => @buyer.city)\n @users = @locals.random(5)\n respond_to do |format|\n if @renter.save\n @users.each do |user|\n RenterMailer.registration_welcome(@renter, user).deliver\n Renter.increment_counter(\"times_forwarded\", @renter.id)\n end\n format.html { redirect_to :submitted_page, :notice => 'Seller was successfully created.' }\n format.json { render :json => @renter, :status => :created, :location => @renter }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @renter.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @enroll = Enroll.new(params[:enroll])\n @enroll.view =0\n if @enroll.save\n render json: JSON.parse(@enroll.to_json)\n else\n render json: JSON.parse(@enroll.errors.to_json)\n end\n end",
"def create\n @encuestum = Encuestum.new(encuestum_params)\n\n respond_to do |format|\n if @encuestum.save\n format.html { redirect_to @encuestum, notice: 'Encuestum was successfully created.' }\n format.json { render :show, status: :created, location: @encuestum }\n else\n format.html { render :new }\n format.json { render json: @encuestum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n authorize! :create, :repost\n @fun.repost_by current_user\n Stat.recount @fun.user, :reposts\n render json: { success: true }\n end",
"def create\n @novedad = Novedad.new(novedad_params)\n @novedad.user = current_user\n respond_to do |format|\n if @novedad.save\n format.html { redirect_to @novedad}\n format.json { render :show, status: :created, location: @novedad }\n else\n format.html { render :new }\n format.json { render json: @novedad.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @national_rank = NationalRank.new(params[:national_rank])\n\n respond_to do |format|\n if @national_rank.save\n format.html { redirect_to @national_rank, notice: 'National rank was successfully created.' }\n format.json { render json: @national_rank, status: :created, location: @national_rank }\n else\n format.html { render action: \"new\" }\n format.json { render json: @national_rank.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sinistro = Sinistro.new(sinistro_params)\n\n respond_to do |format|\n if @sinistro.save\n format.html { redirect_to @sinistro, notice: 'Sinistro was successfully created.' }\n format.json { render :show, status: :created, location: @sinistro }\n else\n format.html { render :new }\n format.json { render json: @sinistro.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @nescafe = Nescafe.new(params[:nescafe])\n\n respond_to do |format|\n if @nescafe.save\n format.html { redirect_to @nescafe, notice: 'Nescafe was successfully created.' }\n format.json { render json: @nescafe, status: :created, location: @nescafe }\n else\n format.html { render action: \"new\" }\n format.json { render json: @nescafe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @surname = Surname.new(params[:surname])\n\n respond_to do |format|\n if @surname.save\n format.html { redirect_to @surname, notice: 'Surname was successfully created.' }\n format.json { render json: @surname, status: :created, location: @surname }\n else\n format.html { render action: \"new\" }\n format.json { render json: @surname.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_snack\n response = RestClient.post SNACKS_URL, {name: @suggestion.name, location: @suggestion.location}.to_json, content_type: :json\n logger.debug \"web service response code => #{response.code}\"\n if response.code != 200\n flash[:notice] = \"Error: #{response.code} while communicating with services, please try again later.\"\n end\n parsed = JSON.parse(response) \n end",
"def create\n\t\tauthorize! :create, Postulacion\n @postulacion = Postulacion.new(postulacion_params)\n @postulacion.aceptado=false\n\n respond_to do |format|\n if @postulacion.save\n sesion= Sesion.find_by(usuario_id: current_usuario.id, fechaFin: nil)\n Transaccion.create!(\n\t\t descripcion: \"Creación de la Postulación al proyecto #{@postulacion.proyecto.nombre} del usuario #{@postulacion.usuario.nombreUsuario}: aceptado = #{t @postulacion.aceptado.to_s}\",\n\t\t sesion_id: sesion.id ,\n\t\t proyecto_id: @postulacion.proyecto.id)\n\tformat.html {redirect_to :controller => 'proyectos', :action => 'index'\n\t flash[:success] = 'Se ha registrado tu participación' } \n format.json { render :show, status: :created, location: @postulacion }\n else\n format.html { render :new }\n format.json { render json: @postulacion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @solicitud = Solicitud.new(solicitud_params)\n\n respond_to do |format|\n if @solicitud.save\n format.html { redirect_to @solicitud, notice: \"Solicitud was successfully created.\" }\n format.json { render :show, status: :created, location: @solicitud }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @solicitud.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @grant_round = GrantRound.new(grant_round_params(params[:grant_round]))\n\n if @grant_round.save\n render json: @grant_round, status: :created, location: @grant_round\n else\n render json: @grant_round.errors, status: :unprocessable_entity\n end\n end",
"def new\n @snp = Snp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @snp }\n end\n end",
"def create\n @snipet = Snipet.new(snipet_params)\n @snipet.user_id = current_user.id\n @snipet.username = current_user.username\n respond_to do |format|\n if @snipet.save\n format.html { redirect_to @snipet, notice: 'Snipet was successfully created.' }\n format.json { render :show, status: :created, location: @snipet }\n else\n format.html { render :new }\n format.json { render json: @snipet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @repuesto = Repuesto.new(repuesto_params)\n\n respond_to do |format|\n if @repuesto.save\n format.html { redirect_to @repuesto, notice: 'Repuesto was successfully created.' }\n format.json { render :show, status: :created, location: @repuesto }\n else\n format.html { render :new }\n format.json { render json: @repuesto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @nnb = Nnb.new(nnb_params)\n respond_to do |format|\n if @nnb.save\n format.html { redirect_to @nnb, notice: 'Nnb was successfully created.' }\n format.json { render action: 'show', status: :created, location: @nnb }\n else\n format.html { render action: 'new' }\n format.json { render json: @nnb.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.6039991",
"0.5876144",
"0.58288634",
"0.57932293",
"0.5763098",
"0.57344013",
"0.5723912",
"0.563932",
"0.56129754",
"0.5584299",
"0.5580586",
"0.55512553",
"0.5532478",
"0.5512731",
"0.5511791",
"0.54805624",
"0.54601204",
"0.5436382",
"0.5435385",
"0.5433422",
"0.5419972",
"0.541607",
"0.5407271",
"0.54058105",
"0.53993386",
"0.5390866",
"0.5390506",
"0.5372903",
"0.53728527",
"0.53682214",
"0.5354892",
"0.5354351",
"0.5354024",
"0.53533864",
"0.53531533",
"0.53516513",
"0.5348797",
"0.53444743",
"0.53162915",
"0.53118795",
"0.52995694",
"0.5299096",
"0.5298793",
"0.5296769",
"0.52823335",
"0.5274579",
"0.52716494",
"0.52692354",
"0.52638686",
"0.52432424",
"0.52398384",
"0.52321076",
"0.52281743",
"0.52276546",
"0.5225954",
"0.5223612",
"0.5221389",
"0.52209973",
"0.52167714",
"0.5215713",
"0.5212051",
"0.5207072",
"0.52061194",
"0.51908743",
"0.5190654",
"0.5189708",
"0.51811314",
"0.5176597",
"0.5175606",
"0.51617664",
"0.5156813",
"0.5153052",
"0.5147584",
"0.51462233",
"0.5144117",
"0.51401687",
"0.51352763",
"0.51340735",
"0.51317996",
"0.5131497",
"0.5131497",
"0.5125653",
"0.5125653",
"0.5124138",
"0.5123313",
"0.51163703",
"0.5106171",
"0.51051855",
"0.5103791",
"0.50976676",
"0.5096677",
"0.50961196",
"0.50948775",
"0.50943375",
"0.5088768",
"0.50872606",
"0.508296",
"0.50770825",
"0.50760555",
"0.50714916"
] | 0.54143447 | 22 |
PUT /nurses/1 PUT /nurses/1.json | def update
@nurse = Nurse.find(params[:id])
respond_to do |format|
if @nurse.update_attributes(params[:nurse])
format.html { redirect_to @nurse, notice: 'Nurse was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @nurse.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update \n sneaker = find_sneaker\n # update! exceptions will be handled by the rescue_from ActiveRecord::RecordInvalid code\n sneaker.update(sneaker_params)\n render json: sneaker\n end",
"def update\n respond_to do |format|\n if @siren.update(siren_params)\n format.html { redirect_to @siren, notice: 'Siren was successfully updated.' }\n format.json { render :show, status: :ok, location: @siren }\n else\n format.html { render :edit }\n format.json { render json: @siren.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @nineteen.update(nineteen_params)\n format.html { redirect_to @nineteen, notice: 'Nineteen was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @nineteen.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @nyse.update(nyse_params)\n format.html { redirect_to @nyse, notice: 'nyse was successfully updated.' }\n format.json { render :show, status: :ok, location: @nyse }\n else\n format.html { render :edit }\n format.json { render json: @nyse.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @niveis_ensino = NiveisEnsino.find(params[:id])\n\n respond_to do |format|\n if @niveis_ensino.update_attributes(params[:niveis_ensino])\n format.html { redirect_to(@niveis_ensino, :notice => 'Niveis ensino atualizado com sucesso.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @niveis_ensino.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @onsen.update(onsen_params)\n format.html { redirect_to @onsen, notice: 'Onsen was successfully updated.' }\n format.json { render :show, status: :ok, location: @onsen }\n else\n format.html { render :edit }\n format.json { render json: @onsen.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @nepal = Nepal.find(params[:id])\n\n if @nepal.update(nepal_params)\n head :no_content\n else\n render json: @nepal.errors, status: :unprocessable_entity\n end\n end",
"def update(id, params)\n http.put(\"/nfse/#{id}\", { body: params }) do |response|\n respond_with_entity(response)\n end\n end",
"def update\n @nail_salon = NailSalon.find(params[:id])\n\n respond_to do |format|\n if @nail_salon.update_attributes(params[:nail_salon])\n format.html { redirect_to @nail_salon, notice: 'Nail salon was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @nail_salon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_onsen\n @onsen = Onsen.find(params[:id])\n end",
"def suscribe\n @estate = Estate.find(params[:id])\n @estate.update_attribute(:status, true)\n respond_to do |format|\n format.html { redirect_to estates_url, notice: 'Propiedad publicada exitosamente.' }\n format.json { head :no_content }\n end\n end",
"def update\n respond_to do |format|\n if @nursery_table.update(nursery_table_params)\n format.html { redirect_to @nursery_table, notice: \"Nursery table was successfully updated.\" }\n format.json { render :show, status: :ok, location: @nursery_table }\n else\n format.html { render :edit }\n format.json { render json: @nursery_table.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @snp = Snp.find(params[:id])\n\n respond_to do |format|\n if @snp.update_attributes(params[:snp])\n format.html { redirect_to @snp, notice: 'Snp was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @snp.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @seniority.update(seniority_params)\n format.html { redirect_to @seniority, notice: \"Seniority was successfully updated.\" }\n format.json { render :show, status: :ok, location: @seniority }\n else\n format.html { render :edit }\n format.json { render json: @seniority.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n render json: Alien.update(params[\"id\"], params[\"alien\"])\n end",
"def update\n respond_to do |format|\n if @nippou.update(nippou_params)\n format.html { redirect_to @nippou, notice: 'Nippou was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @nippou.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 @nasp_rail = NaspRail.find(params[:id])\n\n respond_to do |format|\n if @nasp_rail.update_attributes(params[:nasp_rail])\n format.html { redirect_to @nasp_rail, :notice => 'Entrada atualizada com sucesso.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @nasp_rail.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n #update venues trought users controller\n\n @user = User.find_by(authentication_token: request.headers['Authorization'])\n\n if @user.is_venue?\n @user.venue.update(venue_params)\n if @user.venue.update(venue_params)\n render json: {status: :ok}\n else\n render json: {msg: 'Invalid params'}\n end\n else\n render json: {msg: 'You dont own a venue'}, status: :error\n end\n \n\n end",
"def put!\n request! :put\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def update\n @sinh_vien = SinhVien.find(params[:id])\n\n respond_to do |format|\n if @sinh_vien.update_attributes(params[:sinh_vien]) \n format.json { head :no_content }\n else \n format.json { render json: @sinh_vien.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @onsen = Onsen.new(onsen_params)\n\n respond_to do |format|\n if @onsen.save\n format.html { redirect_to @onsen, notice: 'Onsen was successfully created.' }\n format.json { render :show, status: :created, location: @onsen }\n else\n format.html { render :new }\n format.json { render json: @onsen.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @nave = Nave.find(params[:id])\n\n respond_to do |format|\n if @nave.update_attributes(params[:nave])\n format.html { redirect_to @nave, notice: 'Nave was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @nave.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sponsor.update(sponsor_params)\n format.html { redirect_to sponsors_url, notice: 'El auspiciante se actualizó correctamente.' }\n format.json { render :show, status: :ok, location: sponsors_url }\n else\n format.html { render :edit }\n format.json { render json: @sponsor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @csosn = Csosn.find(params[:id])\n\n respond_to do |format|\n if @csosn.update_attributes(params[:csosn])\n format.html { redirect_to @csosn, notice: 'Csosn was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @csosn.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :update_almacen,Sigesp::Solicitud\n if @sigesp_solicitud.update(sigesp_solicitud_alamcen_params)\n return render json: { url: sigesp_solicitudsalmacen_path(@sigesp_solicitud)} \n else\n return render json:@sigesp_solicitud.errors ,status: :unprocessable_entity\n end \n end",
"def update\n respond_to do |format|\n if @seihinn.update(seihinn_params)\n format.html { redirect_to @seihinn, notice: \"Seihinn was successfully updated.\" }\n format.json { render :show, status: :ok, location: @seihinn }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @seihinn.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @soln.update(soln_params)\n format.html { redirect_to @soln, notice: 'Soln was successfully updated.' }\n format.json { render :show, status: :ok, location: @soln }\n else\n format.html { render :edit }\n format.json { render json: @soln.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @souvenior.update(souvenior_params)\n format.html { redirect_to @souvenior, notice: 'Souvenior was successfully updated.' }\n format.json { render :show, status: :ok, location: @souvenior }\n else\n format.html { render :edit }\n format.json { render json: @souvenior.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sneaker.update(sneaker_params)\n Sneaker.reindex\n format.html { redirect_to @sneaker, notice: 'Sneaker was successfully updated.' }\n format.json { render :show, status: :ok, location: @sneaker }\n else\n format.html { render :edit }\n format.json { render json: @sneaker.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @studnet = Studnet.find(params[:id])\n\n respond_to do |format|\n if @studnet.update_attributes(params[:studnet])\n format.html { redirect_to @studnet, notice: 'Studnet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @studnet.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 put(uri, params = {})\n send_request(uri, :put, params)\n end",
"def update\n respond_to do |format|\n name = Server.find(params[:id]).name\n n = Neography::Node.find('servers', 'name', name)\n n.name = server_params[:name]\n n.add_to_index('servers', 'name', server_params[:name]) #TODO: is this necessary?\n if @server.update(server_params)\n format.html { redirect_to @server, notice: 'Server was successfully updated.' }\n format.json { render :show, status: :ok, location: @server }\n else\n format.html { render :edit }\n format.json { render json: @server.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_siren\n @siren = Siren.find(params[:id])\n end",
"def update\n @sundry_grn = SundryGrn.find(params[:id])\n\n respond_to do |format|\n if @sundry_grn.update_attributes(params[:sundry_grn])\n format.html { redirect_to @sundry_grn, :notice => 'Sundry grn was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @sundry_grn.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @snail.update(snail_params)\n format.html { redirect_to @snail, notice: 'Snail was successfully updated.' }\n format.json { render :show, status: :ok, location: @snail }\n else\n format.html { render :edit }\n format.json { render json: @snail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @snail.update(snail_params)\n format.html { redirect_to @snail, notice: 'Snail was successfully updated.' }\n format.json { render :show, status: :ok, location: @snail }\n else\n format.html { render :edit }\n format.json { render json: @snail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @siren = Siren.new(siren_params)\n\n respond_to do |format|\n if @siren.save\n format.html { redirect_to @siren, notice: 'Siren was successfully created.' }\n format.json { render :show, status: :created, location: @siren }\n else\n format.html { render :new }\n format.json { render json: @siren.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @nino.update(nino_params)\n format.html { redirect_to @nino, notice: \"El niño #{@nino.nombre} ha sido actualizado.\" }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @nino.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sinnoh.update(sinnoh_params)\n format.html { redirect_to @sinnoh, notice: 'Sinnoh was successfully updated.' }\n format.json { render :show, status: :ok, location: @sinnoh }\n else\n format.html { render :edit }\n format.json { render json: @sinnoh.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @manage_nourish.update(manage_nourish_params)\n format.html { redirect_to @manage_nourish, notice: 'Manage nourish was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @manage_nourish.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @nsgrule.update(nsgrule_params)\n format.html { redirect_to @nsgrule, notice: 'Nsgrule was successfully updated.' }\n format.json { render :show, status: :ok, location: @nsgrule }\n else\n format.html { render :edit }\n format.json { render json: @nsgrule.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @orphan_sponsorship.update(orphan_sponsorship_params)\n format.html { redirect_to @orphan_sponsorship, notice: 'Orphan sponsorship was successfully updated.' }\n format.json { render :show, status: :ok, location: @orphan_sponsorship }\n else\n format.html { render :edit }\n format.json { render json: @orphan_sponsorship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @studnet.update(studnet_params)\n format.html { redirect_to @studnet, notice: 'Studnet was successfully updated.' }\n format.json { render :show, status: :ok, location: @studnet }\n else\n format.html { render :edit }\n format.json { render json: @studnet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n client=Client.find_by_id params[:id]\n if client!= nil\n client.cedula=params[:cedula] ? params[:cedula]: client.cedula\n client.sector=params[:sector] ? params[:sector]: client.sector\n client.nombre=params[:nombre] ? params[:nombre]: client.nombre\n client.telefono=params[:telefono] ? params[:telefono]: client.telefono\n client.pagina=params[:pagina] ? params[:pagina]: client.pagina\n client.direccion=params[:direccion] ? params[:direccion]: client.direccion\n if client.save\n render(json: client, status: 201)\n end \n else\n render(json: client.errors, status: 404)\n end \n end",
"def update\n @nurse = Nurse.find(params[:id])\n flash[:notice] = 'Updated Nurse.' if @nurse.update_attributes(params[:nurse])\n respond_with @nurse\n end",
"def update\n @onske = Onske.find(params[:id])\n\n respond_to do |format|\n if @onske.update_attributes(params[:onske])\n format.html { redirect_to @onske, notice: 'Onske was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @onske.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @niveau = Niveau.find(params[:id])\n authorize! :update, @niveau\n respond_to do |format|\n if @niveau.update_attributes(params[:niveau])\n format.html { redirect_to @niveau, notice: 'Niveau werd succesvol gewijzigd.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @niveau.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n url = 'https://casa-core.herokuapp.com/api/units/' + params[:id]\n query = {\n 'name' => params[:name]\n }\n response = HTTParty.put(url, :query => query, :headers => { \"Authorization\" => AUTH, \"Host\" => HOST})\n\n if response.code == 200\n redirect_to unit_path(params[:id]), notice: 'Unit was successfully updated.'\n else\n redirect_to unit_path(params[:id]), notice: 'Sheesh! Minor hiccup...run that again!'\n end\n end",
"def put(*args)\n request :put, *args\n end",
"def update\n @nominee = Nominee.find(params[:id])\n\n respond_to do |format|\n if @nominee.update_attributes(params[:nominee])\n format.html { redirect_to @nominee, notice: 'Nominee was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @nominee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_sesiune\n @sesiune = Sesiune.find(params[:id])\n end",
"def update\n neuron = Neuron.find(params[:id])\n\n neuron.update_attributes! params\n\n render :json => neuron\n # @neuron = Neuron.find(params[:id])\n # \n # respond_to do |format|\n # if @neuron.update_attributes(params[:neuron])\n # format.html { redirect_to @neuron, notice: 'Neuron was successfully updated.' }\n # format.json { head :ok }\n # else\n # format.html { render action: \"edit\" }\n # format.json { render json: @neuron.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 authorize! :update, Solicitud\n respond_to do |format|\n if @solicitud.update(solicitud_params)\n format.html { redirect_to solicitudes_path, notice: 'Solicitud actualizada exitosamente.' }\n format.json { render :show, status: :ok, location: solicitudes_path }\n else\n format.html { render :edit }\n format.json { render json: @solicitud.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @noshow.update(noshow_params)\n format.html { redirect_to @noshow, notice: 'Noshow was successfully updated.' }\n format.json { render :show, status: :ok, location: @noshow }\n else\n format.html { render :edit }\n format.json { render json: @noshow.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @nafe.update(nafe_params)\n format.html { redirect_to @nafe, notice: 'Nave was successfully updated.' }\n format.json { render :show, status: :ok, location: @nafe }\n else\n format.html { render :edit }\n format.json { render json: @nafe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @nut = Nut.find(params[:id])\n\n respond_to do |format|\n if @nut.update_attributes(params[:nut])\n format.html { redirect_to @nut, notice: 'Nut was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @nut.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @seance = Seances::UseCases::Update.new.call(id: params[:id], params: seance_params)\n\n if @seance.valid?\n render jsonapi: @seance\n else\n render jsonapi_errors: @seance.errors, status: :unprocessable_entity\n end\n end",
"def update\n @nostro = Nostro.find(params[:id])\n\n respond_to do |format|\n if @nostro.update_attributes(params[:nostro])\n flash[:notice] = 'Nostro was successfully updated.'\n format.html { redirect_to(@nostro) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @nostro.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def criar_sobrevivente\n @suvivor = Sobrevivente.create(\n name: params[:name], genero: params[:genero], idade: params[:idade],\n lat: params[:lat], lon: params[:lon],\n agua: params[:agua], comida: params[:comida], medicamento: params[:medicamento],\n municao: params[:municao]\n )\n render json: @suvivor\n end",
"def set_souvenior\n @souvenior = Souvenior.find(params[:id])\n end",
"def create!\n Recliner.put(uri)\n end",
"def update\n\n respond_to do |format|\n if @sponsor.update_attributes(params[:sponsor])\n format.html { redirect_to [:admin, @event, @sponsor], notice: 'Sponsor was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sponsor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @surname = Surname.find(params[:id])\n\n respond_to do |format|\n if @surname.update_attributes(params[:surname])\n format.html { redirect_to @surname, notice: 'Surname was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @surname.errors, status: :unprocessable_entity }\n end\n end\n end",
"def actualizacion \n fiesta.update (params[:id]) \n render json: fiesta\n end",
"def update\n respond_to do |format|\n if @nnb.update(nnb_params)\n format.html { redirect_to @nnb, notice: 'Nnb was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @nnb.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @usesr.update(usesr_params)\n format.html { redirect_to @usesr, notice: 'Usesr was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @usesr.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @verse = Verse.find(params[:id])\n\n respond_to do |format|\n if @verse.update_attributes(params[:verse])\n format.html { redirect_to @verse, notice: 'Verse was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @verse.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @verse = Verse.find(params[:id])\n\n respond_to do |format|\n if @verse.update_attributes(params[:verse])\n format.html { redirect_to @verse, notice: 'Verse was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @verse.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sponsor.update(sponsor_params)\n format.html { redirect_to @sponsor, notice: 'Sponsor was successfully updated.' }\n format.json { render :show, status: :ok, location: @sponsor }\n else\n format.html { render :edit }\n format.json { render json: @sponsor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sponsor.update(sponsor_params)\n format.html { redirect_to @sponsor, notice: 'Sponsor was successfully updated.' }\n format.json { render :show, status: :ok, location: @sponsor }\n else\n format.html { render :edit }\n format.json { render json: @sponsor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update \n retorno = {erro: \"322\" ,body: \"\"}\n if @usuario.update(valid_request?)\n retorno = {erro: \"000\", body: {evento_id: @usuario.id, usuario_nome: @usuario.nome}}\n end\n render json: retorno.to_json\n end",
"def update\n respond_to do |format|\n if @souvenir.update(souvenir_params)\n format.html { redirect_to @souvenir, notice: 'Souvenir was successfully updated.' }\n format.json { render :show, status: :ok, location: @souvenir }\n else\n format.html { render :edit }\n format.json { render json: @souvenir.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @entrepreneur = Entrepreneur.find(params[:id])\n authorize @entrepreneur\n respond_to do |format|\n if @entrepreneur.update(entrepreneur_params)\n format.html { redirect_to @entrepreneur, notice: 'Entrepreneur was successfully updated.' }\n format.json { render :show, status: :ok, location: @entrepreneur }\n else\n format.html { render :edit }\n format.json { render json: @entrepreneur.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n official = Official.find(params[:id])\n if official.update(official_params)\n render json: official, status: 200, location: [:api, official]\n else\n failed_to_update(official, \"official\")\n end\n end",
"def update\n @nossos_servico = NossosServico.find(params[:id])\n\n respond_to do |format|\n if @nossos_servico.update_attributes(params[:nossos_servico])\n format.html { redirect_to(@nossos_servico, :notice => 'Nossos servico was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @nossos_servico.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @studen.update(studen_params)\n format.html { redirect_to @studen, notice: 'Studen was successfully updated.' }\n format.json { render :show, status: :ok, location: @studen }\n else\n format.html { render :edit }\n format.json { render json: @studen.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @naren.update(naren_params)\n format.html { redirect_to @naren, notice: 'Naren was successfully updated.' }\n format.json { render :show, status: :ok, location: @naren }\n else\n format.html { render :edit }\n format.json { render json: @naren.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @synonymprotein.update(synonymprotein_params)\n format.html { redirect_to @synonymprotein, notice: 'Synonymprotein was successfully updated.' }\n format.json { render :show, status: :ok, location: @synonymprotein }\n else\n format.html { render :edit }\n format.json { render json: @synonymprotein.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @noyau.update(noyau_params)\n format.html { redirect_to @noyau, notice: 'Noyau was successfully updated.' }\n format.json { render :show, status: :ok, location: @noyau }\n else\n format.html { render :edit }\n format.json { render json: @noyau.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(uri, parameters)\n response = Unirest.put uri, parameters: parameters\n response.body\n end",
"def update\n respond_to do |format|\n if @sinistro.update(sinistro_params)\n format.html { redirect_to @sinistro, notice: 'Sinistro was successfully updated.' }\n format.json { render :show, status: :ok, location: @sinistro }\n else\n format.html { render :edit }\n format.json { render json: @sinistro.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @<%= singular_table_name %>.update(<%= singular_table_name %>_params)\n format.html { redirect_to @<%= singular_table_name %>, notice: \"#{t('activerecord.models.<%= singular_table_name %>.one')} atualizado com sucesso.\" }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @<%= singular_table_name %>.errors, status: :unprocessable_entity }\n end\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 @souvenir.update(souvenir_params)\n format.html { redirect_to @souvenir, notice: 'Souvenir was successfully updated.' }\n format.json { render json: { user: @souvenir, status: 200, description: 'Souvenir was successfully updated.' }, status: :ok }\n else\n format.html { render :edit }\n format.json { render json: { user: @souvenir, status: 500, description: 'Internal server error : faliled to save' }, status: :internal_server_error }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sejour.update(sejour_params)\n format.html { redirect_to @sejour, notice: 'Sejour mis a jour.' }\n format.json { render :show, status: :ok, location: @sejour }\n else\n format.html { render :edit }\n format.json { render json: @sejour.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @seguro = Seguro.find(params[:id])\n\n respond_to do |format|\n if @seguro.update_attributes(params[:seguro])\n format.html { redirect_to @seguro, notice: 'Seguro was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @seguro.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @name = Name.find(params[:id])\n\n\t\tif params[:index]\n\t\t\tn = @name.sei.length\n\t\t\ti = params[:index].to_i\n\t\t\tif i < n\n\t\t\t\tparams[:name][:mei] = params[:name][:sei][i .. n]\n\t\t\t\tparams[:name][:sei] = params[:name][:sei][0 .. i-1]\n\t\t\tend\n\t\tend\n\n respond_to do |format|\n if @name.update_attributes(params[:name])\n format.html { redirect_to @name, notice: 'Name was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @name.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @uen.update(uen_params)\n format.html { redirect_to @uen, notice: 'Uen was successfully updated.' }\n format.json { render :show, status: :ok, location: @uen }\n else\n format.html { render :edit }\n format.json { render json: @uen.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(url, vars={})\n send_request url, vars, 'PUT'\n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def update\n @issuer = Issuer.find(params[:id])\n\n respond_to do |format|\n if @issuer.update_attributes(params[:issuer])\n format.html { redirect_to issuers_path, notice: 'Issuer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @issuer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @socio = Socio.find(params[:id])\n\n respond_to do |format|\n if @socio.update_attributes(params[:socio])\n format.html { redirect_to @socio, :notice => 'Socio atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @socio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @nitrou.update(nitrou_params)\n format.html { redirect_to @nitrou, notice: 'Nitrou was successfully updated.' }\n format.json { render :show, status: :ok, location: @nitrou }\n else\n format.html { render :edit }\n format.json { render json: @nitrou.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @naievent.update(naievent_params)\n format.html { redirect_to @naievent, notice: 'Naievent was successfully updated.' }\n format.json { render :show, status: :ok, location: @naievent }\n else\n format.html { render :edit }\n format.json { render json: @naievent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @urij.update(urij_params)\n format.html { redirect_to @urij, notice: 'Urij was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @urij.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.5973854",
"0.58009416",
"0.5767399",
"0.57311505",
"0.5721174",
"0.571451",
"0.56857646",
"0.5647851",
"0.5642263",
"0.5586154",
"0.55436873",
"0.5542817",
"0.5541869",
"0.5535166",
"0.553049",
"0.55273074",
"0.55051553",
"0.54948145",
"0.5493343",
"0.5490147",
"0.54842496",
"0.546288",
"0.5461934",
"0.5454503",
"0.54484266",
"0.54438794",
"0.54374367",
"0.5431014",
"0.5426956",
"0.5410962",
"0.54076564",
"0.5402283",
"0.53957915",
"0.53955936",
"0.53809685",
"0.53759456",
"0.5371864",
"0.5356474",
"0.5354352",
"0.5354352",
"0.5349657",
"0.53172296",
"0.5314905",
"0.53099185",
"0.5298555",
"0.529529",
"0.52943546",
"0.5287035",
"0.5284392",
"0.5278216",
"0.527442",
"0.52735466",
"0.52725124",
"0.5266551",
"0.52628475",
"0.5234334",
"0.5232119",
"0.5230173",
"0.5229032",
"0.52156943",
"0.52121603",
"0.5207839",
"0.52032757",
"0.5201403",
"0.51891667",
"0.51855034",
"0.51840055",
"0.5176727",
"0.5172798",
"0.5170547",
"0.516982",
"0.51684546",
"0.51684546",
"0.51673454",
"0.51673454",
"0.51612115",
"0.5159547",
"0.5159431",
"0.51594126",
"0.5155484",
"0.5150678",
"0.51497704",
"0.5142639",
"0.51421773",
"0.51376766",
"0.5128893",
"0.5125435",
"0.51224613",
"0.5119913",
"0.511473",
"0.5114538",
"0.5113464",
"0.51120555",
"0.5110143",
"0.5109677",
"0.51060987",
"0.5103513",
"0.5101094",
"0.5099795",
"0.5098255"
] | 0.5508139 | 16 |
DELETE /nurses/1 DELETE /nurses/1.json | def destroy
@nurse = Nurse.find(params[:id])
@nurse.destroy
respond_to do |format|
format.html { redirect_to nurses_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @nail_salon = NailSalon.find(params[:id])\n @nail_salon.destroy\n\n respond_to do |format|\n format.html { redirect_to nail_salons_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @nineteen.destroy\n respond_to do |format|\n format.html { redirect_to nineteens_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @sundry_grn = SundryGrn.find(params[:id])\n @sundry_grn.destroy\n\n respond_to do |format|\n format.html { redirect_to sundry_grns_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @siren.destroy\n respond_to do |format|\n format.html { redirect_to root_path, notice: 'Siren was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @snail.destroy\n respond_to do |format|\n format.html { redirect_to snails_url, notice: 'Snail was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @snail.destroy\n respond_to do |format|\n format.html { redirect_to snails_url, notice: 'Snail was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def destroy\n @solicitud.destroy\n respond_to do |format|\n format.html { redirect_to solicitudes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @nippou.destroy\n respond_to do |format|\n format.html { redirect_to nippous_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @studnet = Studnet.find(params[:id])\n @studnet.destroy\n\n respond_to do |format|\n format.html { redirect_to studnets_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(url)\n @deleted = true\nend",
"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 destroy\n @client_sex = ClientSex.find(params[:id])\n @client_sex.destroy\n\n respond_to do |format|\n format.html { redirect_to client_sexes_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @annex = Annex.find(params[:id])\n @annex.destroy\n\n respond_to do |format|\n format.html { redirect_to annexes_url }\n format.json { head :no_content }\n end\n end",
"def do_delete(uri = \"\")\n @connection.delete do |req|\n req.url uri\n req.headers['Content-Type'] = 'application/json'\n end\n end",
"def destroy\n @consensu = Consensu.find(params[:id])\n @consensu.destroy\n\n respond_to do |format|\n format.html { redirect_to consensus_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @repuestum = Repuestum.find(params[:id])\n @repuestum.destroy\n\n respond_to do |format|\n format.html { redirect_to repuesta_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sinh_vien = SinhVien.find(params[:id])\n @sinh_vien.destroy\n\n respond_to do |format| \n format.json { head :no_content }\n end\n end",
"def destroy\n @stone = Stone.find(params[:id])\n @stone.destroy\n\n respond_to do |format|\n format.html { redirect_to stones_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @studnet.destroy\n respond_to do |format|\n format.html { redirect_to studnets_url, notice: 'Studnet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @seihinn.destroy\n respond_to do |format|\n format.html { redirect_to seihinns_url, notice: \"Seihinn was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @uriy.destroy\n respond_to do |format|\n format.html { redirect_to uriys_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @nominee.destroy\n respond_to do |format|\n format.html { redirect_to nominees_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @nudge.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def delete!\n Recliner.delete(uri)\n end",
"def destroy\n @suplente = Suplente.find(params[:id])\n @suplente.destroy\n\n respond_to do |format|\n format.html { redirect_to suplentes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @onsen.destroy\n respond_to do |format|\n format.html { redirect_to onsens_url, notice: 'Onsen was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @secubat_client = SecubatClient.find(params[:id])\n @secubat_client.destroy\n\n respond_to do |format|\n format.html { redirect_to secubat_clients_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @seguidore = Seguidore.find(params[:id])\n @seguidore.destroy\n\n respond_to do |format|\n format.html { redirect_to seguidores_url }\n format.json { head :ok }\n end\n end",
"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 destroy\n authorize! :destroy, Solicitud\n @solicitud.destroy\n respond_to do |format|\n format.html { redirect_to solicitudes_url, notice: 'Solicitud was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n request(:delete)\n end",
"def destroy\n @c_rodinny_stav.destroy\n respond_to do |format|\n format.html { redirect_to c_rodinny_stavs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @manage_nourish.destroy\n respond_to do |format|\n format.html { redirect_to manage_nourishes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @nino.destroy\n respond_to do |format|\n format.html { redirect_to ninos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @vpn = Vpn.find(params[:id])\n checkaccountobject(\"vpns\",@vpn)\n @vpn.send_delete\n\n respond_to do |format|\n format.html { redirect_to vpns_url }\n format.json { head :ok }\n end\n end",
"def delete!\n request! :delete\n end",
"def destroy\n @encuestum = Encuestum.find(params[:id])\n @encuestum.destroy\n\n respond_to do |format|\n format.html { redirect_to encuesta_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @surah.destroy\n respond_to do |format|\n format.html { redirect_to surahs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @onske = Onske.find(params[:id])\n @onske.destroy\n\n respond_to do |format|\n format.html { redirect_to onskes_url }\n format.json { head :ok }\n end\n end",
"def destroy\n client=Client.find_by_id(params[:id])\n if client != nil\n if client.destroy\n head 204\n end\n else\n head 404\n end\n end",
"def destroy\n @strosek.destroy\n respond_to do |format|\n format.html { redirect_to stroseks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sejour.destroy\n respond_to do |format|\n format.html { redirect_to sejours_url, notice: 'Sejour was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @solicitud.destroy\n respond_to do |format|\n format.html { redirect_to solicituds_url, notice: 'Solicitud was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @solicitud.destroy\n respond_to do |format|\n format.html { redirect_to solicituds_url, notice: \"Solicitud was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @nnb.destroy\n respond_to do |format|\n format.html { redirect_to nnbs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @studen.destroy\n respond_to do |format|\n format.html { redirect_to studens_url, notice: 'Studen was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @nepal.destroy\n\n head :no_content\n end",
"def destroy\r\n @sivic_rede.destroy\r\n respond_to do |format|\r\n format.html { redirect_to sivic_redes_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @substrate = Substrate.find(params[:id])\n @substrate.destroy\n\n respond_to do |format|\n format.html { redirect_to substrates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @verse = Verse.find(params[:id])\n @verse.destroy\n\n respond_to do |format|\n format.html { redirect_to verses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @verse = Verse.find(params[:id])\n @verse.destroy\n\n respond_to do |format|\n format.html { redirect_to verses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sin = Sin.find(params[:id])\n @sin.destroy\n\n respond_to do |format|\n format.html { redirect_to sins_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @niveau = Niveau.find(params[:id])\n authorize! :destroy, @niveau\n @niveau.destroy\n\n respond_to do |format|\n format.html { redirect_to niveaus_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @nsgrule.destroy\n respond_to do |format|\n format.html { redirect_to nsgrules_url, notice: 'Nsgrule was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(url, headers={})\n RestClient.delete url, headers\n end",
"def destroy\n @curso = Curso.find(params[:id])\n @curso.sesions.each do |sesion|\n sesion.destroy\n end\n @curso.destroy\n\n respond_to do |format|\n format.html { redirect_to cursos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @snp = Snp.find(params[:id])\n @snp.destroy\n\n respond_to do |format|\n format.html { redirect_to snps_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @respuesta = Respuesta.find(params[:id])\n @respuesta.destroy\n\n respond_to do |format|\n format.html { redirect_to respuestas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @aucrecord.destroy\n respond_to do |format|\n format.html { redirect_to aucrecords_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ninja = Ninja.find(params[:id])\n @ninja.destroy\n\n respond_to do |format|\n format.html { redirect_to ninjas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @nap.destroy\n respond_to do |format|\n format.html { redirect_to naps_url, notice: 'Nap was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sinnoh.destroy\n respond_to do |format|\n format.html { redirect_to sinnohs_url, notice: 'Sinnoh was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @csosn = Csosn.find(params[:id])\n @csosn.destroy\n\n respond_to do |format|\n format.html { redirect_to csosns_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sesh.destroy\n respond_to do |format|\n format.html { redirect_to root_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n neuron = Neuron.find(params[:id])\n\n neuron.destroy\n\n render :json => neuron\n # @neuron = Neuron.find(params[:id])\n # @neuron.destroy\n # \n # respond_to do |format|\n # format.html { redirect_to neurons_url }\n # format.json { head :ok }\n # end\n end",
"def destroy\n @uen.destroy\n respond_to do |format|\n format.html { redirect_to uens_url, notice: 'Uen was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @nightclub.destroy\n respond_to do |format|\n format.html { redirect_to nightclubs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @revise.destroy\n respond_to do |format|\n format.html { redirect_to revises_url }\n format.json { head :no_content }\n end\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def delete\n render json: Post.delete(params[\"id\"])\n end",
"def destroy\n @skid = Skid.find(params[:id])\n @skid.destroy\n\n respond_to do |format|\n format.html { redirect_to skids_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @nitrou.destroy\n respond_to do |format|\n format.html { redirect_to nitrous_url, notice: 'Nitrou was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @daw_encuest.destroy\n respond_to do |format|\n format.html { redirect_to daw_encuests_url, notice: 'Daw encuest was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @soiree = Soiree.find(params[:id])\n @soiree.destroy\n\n respond_to do |format|\n format.html { redirect_to soirees_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @consultorio_n.destroy\n respond_to do |format|\n format.html { redirect_to consultorio_ns_url, notice: 'Consultorio n was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @seniority.destroy\n respond_to do |format|\n format.html { redirect_to seniorities_url, notice: \"Seniority was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @subsidy = Subsidy.find(params[:id])\n @subsidy.destroy\n\n respond_to do |format|\n format.html { redirect_to subsidies_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 @grupocliente.destroy\n respond_to do |format|\n format.html { redirect_to grupoclientes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sumne.destroy\n respond_to do |format|\n format.html { redirect_to sumnes_url, notice: 'Sumne was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sotrudniki = Sotrudniki.find(params[:id])\n @sotrudniki.destroy\n\n respond_to do |format|\n format.html { redirect_to sotrudnikis_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stundent = Stundent.find(params[:id])\n @stundent.destroy\n\n respond_to do |format|\n format.html { redirect_to stundents_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stanza = Stanza.find_by_no(params[:id])\n @stanza.destroy\n\n respond_to do |format|\n format.html { redirect_to stanzas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cliente = Cliente.find(params[:id])\n @cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @nine.destroy\n respond_to do |format|\n format.html { redirect_to nines_url, notice: 'Nine was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @niveis_ensino = NiveisEnsino.find(params[:id])\n @niveis_ensino.destroy\n\n respond_to do |format|\n format.html { redirect_to(niveis_ensinos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @kont_klient.destroy\n respond_to do |format|\n format.html { redirect_to kont_klient_index_url, notice: 'Kont klient was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @diagnoz = Diagnoz.find(params[:id])\n @diagnoz.destroy\n\n respond_to do |format|\n format.html { redirect_to diagnozs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @naren.destroy\n respond_to do |format|\n format.html { redirect_to narens_url, notice: 'Naren was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @six.destroy\n respond_to do |format|\n format.html { redirect_to sixes_url }\n format.json { head :no_content }\n end\n end",
"def delete(url, headers = {})\n http :delete, \"#{url}.json\", headers\n end",
"def destroy(id)\n http.delete(\"/nfse/#{id}\") do |response|\n response.code == 204\n end\n end",
"def destroy\n @nut = Nut.find(params[:id])\n @nut.destroy\n\n respond_to do |format|\n format.html { redirect_to nuts_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @svote.destroy\n respond_to do |format|\n format.html { redirect_to svotes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @souvenir.destroy\n respond_to do |format|\n format.html { redirect_to souvenirs_url, notice: 'Souvenir was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dinosaur = Dinosaur.find(params[:id])\n @dinosaur.destroy\n\n respond_to do |format|\n format.html { redirect_to dinosaurs_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @life_insurance.destroy\n\n respond_to do |format|\n format.html { redirect_to life_insurances_url }\n format.json { head :no_content }\n end\n end"
] | [
"0.7050792",
"0.7045374",
"0.6952265",
"0.68477404",
"0.6820873",
"0.68013835",
"0.68013835",
"0.67699885",
"0.67519873",
"0.6750785",
"0.6740858",
"0.6732774",
"0.67094",
"0.6706535",
"0.6698785",
"0.6690022",
"0.6688474",
"0.66792953",
"0.6673355",
"0.667132",
"0.66699004",
"0.66619027",
"0.66499376",
"0.66376513",
"0.66369843",
"0.6636419",
"0.66335976",
"0.66324025",
"0.6628764",
"0.66204256",
"0.66156954",
"0.66077507",
"0.66052437",
"0.6599012",
"0.659011",
"0.65796894",
"0.65790224",
"0.6575391",
"0.65742886",
"0.6573066",
"0.6570847",
"0.6568738",
"0.65684104",
"0.6568176",
"0.65658003",
"0.6563853",
"0.65631735",
"0.65588945",
"0.65515375",
"0.6546243",
"0.65427184",
"0.65415484",
"0.65415484",
"0.6541383",
"0.6529258",
"0.65262735",
"0.65240484",
"0.6522741",
"0.6520334",
"0.65173984",
"0.6515784",
"0.6511367",
"0.65060484",
"0.65035236",
"0.65022373",
"0.6501249",
"0.64938056",
"0.6491991",
"0.6490912",
"0.6488445",
"0.6486115",
"0.64791167",
"0.64786565",
"0.64762807",
"0.6474816",
"0.6474151",
"0.6470948",
"0.6469831",
"0.64683205",
"0.6464806",
"0.6464806",
"0.6464301",
"0.64631194",
"0.6461203",
"0.64550596",
"0.6453693",
"0.645257",
"0.64498705",
"0.64471877",
"0.64464504",
"0.64459175",
"0.6445596",
"0.6445314",
"0.64448786",
"0.64445925",
"0.64423525",
"0.64397776",
"0.6438747",
"0.6438608",
"0.6436452"
] | 0.6906585 | 3 |
CS169PGM GOOGLE METHODS BEGIN | def fetch_project_data
response = fetch_data(@@SETTINGS.project_tab)
unless response.nil?
adjust_projects response
return true
end
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getgm() end",
"def detect_landmarks path_to_image_file:\n # [START get_vision_service]\n vision = Google::Cloud::Vision.new\n # [END get_vision_service]\n\n # [START construct_request]\n image = vision.image path_to_image_file\n landmark = image.landmark\n # [END construct_request]\n\n # [START print_landmark]\n puts \"Found landmark: #{landmark.description}\" unless landmark.nil?\n # [END print_landmarks]\nend",
"def gp_flags; end",
"def autodetect\n @gapi.autodetect\n end",
"def cobasysprog\n end",
"def show\n @photos = Photo.all\n @post = Post.find(params[:id])\n x = @post.image.url\n\n #private_key = Google::Auth::ServiceAccountCredentials.make_creds(\n #scope: 'https://www.googleapis.com/auth/cloud-platform',\n #json_key_io: StringIO.new(ENV['VISION_KEYFILE_JSON'])\n #)\n\n\n vision = Google::Cloud::Vision.new(\n project: \"redoproject-163021\",\n keyfile: \"config/redoproject-e87605fb29d9.json\",\n )\n @image = vision.image(x)\n @labels = @image.labels\n #logs\n @logs = @image.logos\n #web\n p @web = @image.web.entities\n\nend",
"def gp_flags=(_arg0); end",
"def guct\n end",
"def annotations; end",
"def annotations; end",
"def annotations; end",
"def annotations; end",
"def annotations; end",
"def annotations; end",
"def annotations; end",
"def annotations; end",
"def detect_labels path_to_image_file:\n# [START detect_labels]\n # [START importing_libraries]\n require \"google/cloud/vision\"\n # [END importing_libraries]\n\n # [START create_vision_client]\n vision = Google::Cloud::Vision.new\n # [END create_vision_client]\n\n # [START annotate_image]\n image = vision.image path_to_image_file\n annotation = vision.annotate image, labels: true\n labels = annotation.labels\n # [END annotate_image]\n\n # [START print_labels]\n puts \"Image labels:\"\n labels.each do |label|\n puts label.description\n end\n # [END print_labels]\n# [END detect_labels]\nend",
"def geo; end",
"def apis; end",
"def on_cmd_google(action)\n action.reply @web.google(action.message.sub(/^!google /, ''))\n end",
"def isp; end",
"def isp; end",
"def big_google_call()\n\n number_of_step = 30;\n lat_base = 48.810837;\n lat_step = (0.1 / number_of_step);\n lng_base = 2.241837;\n lng_step = (0.22 / number_of_step);\n\n for lat_index in 0..number_of_step\n for lng_index in 0..number_of_step\n this_lat = lat_base + lat_index * lat_step;\n this_lng = lng_base + lng_index * lng_step;\n\n places = google_radar_call([this_lat,this_lng], nil)\n places.each do |place|\n add_one_to_db(place, db)\n end\n end\n end\nend",
"def google\n process_oauth_callback\n end",
"def probers; end",
"def gounod; end",
"def google(name: T.unsafe(nil), email: T.unsafe(nil), uid: T.unsafe(nil)); end",
"def g; end",
"def g; end",
"def configure\n @client = Google::APIClient.new\n\n #We must tell ruby to read the keyfile in binary mode.\n content = File.read(KEYFILE, :mode => 'rb')\n\n pkcs12 = OpenSSL::PKCS12.new(content, PASSPHRASE)\n key = pkcs12.key\n\n # Authorize service account\n #key = Google::APIClient::PKCS12.load_key(KEYFILE, PASSPHRASE)\n asserter = Google::APIClient::JWTAsserter.new(\n CLIENT_EMAIL,\n 'https://www.googleapis.com/auth/prediction',\n key)\n @client.authorization = asserter.authorize()\n\n @prediction = @client.discovered_api('prediction', 'v1.5')\n\n end",
"def codepoints()\n #This is a stub, used for indexing\n end",
"def get_parameters; end",
"def get_parameters; end",
"def robots; end",
"def robots; end",
"def private; end",
"def detect_document_text_gcs image_path:\n # [START vision_fulltext_detection_gcs]\n # image_path = \"Google Cloud Storage URI, eg. 'gs://my-bucket/image.png'\"\n\n require \"google/cloud/vision\"\n\n image_annotator = Google::Cloud::Vision::ImageAnnotator.new\n\n response = image_annotator.document_text_detection image: image_path\n\n text = \"\"\n response.responses.each do |res|\n res.text_annotations.each do |annotation|\n text << annotation.description\n end\n end\n\n puts text\n # [END vision_fulltext_detection_gcs]\nend",
"def detect_web_gcs image_path:\n # [START vision_web_detection_gcs]\n # image_path = \"Google Cloud Storage URI, eg. 'gs://my-bucket/image.png'\"\n\n require \"google/cloud/vision\"\n\n image_annotator = Google::Cloud::Vision::ImageAnnotator.new\n\n response = image_annotator.web_detection(\n image: image_path,\n max_results: 15 # optional, defaults to 10\n )\n\n response.responses.each do |res|\n res.web_detection.web_entities.each do |entity|\n puts entity.description\n end\n\n res.web_detection.full_matching_images.each do |match|\n puts match.url\n end\n end\n # [END vision_web_detection_gcs]\nend",
"def transl8 (input,lang) #method to translate incoming text\n translate = Google::Cloud::Translate.new\n detection = translate.detect input.to_s\n #puts input + \"Looks like you're speak in #{detection.language}\"\n #puts \"Confidence: #{detection.confidence}\"\n #translation = translate.translate \"Hello world!\", to: \"la\"\n translation = translate.translate input.to_s, to: lang.to_s\n return \"In #{lang} that's \" + translation\nend",
"def detect_pdf_gcs gcs_source_uri:, gcs_destination_uri:\n # [START vision_text_detection_pdf_gcs]\n # [START vision_text_detection_pdf_gcs_migration]\n # gcs_source_uri = \"Google Cloud Storage URI, eg. 'gs://my-bucket/example.pdf'\"\n # gcs_destination_uri = \"Google Cloud Storage URI, eg. 'gs://my-bucket/prefix_'\"\n\n require \"google/cloud/vision\"\n require \"google/cloud/storage\"\n\n image_annotator = Google::Cloud::Vision::ImageAnnotator.new\n\n operation = image_annotator.document_text_detection(\n image: gcs_source_uri,\n mime_type: \"application/pdf\",\n batch_size: 2,\n destination: gcs_destination_uri,\n async: true\n )\n\n puts \"Waiting for the operation to finish.\"\n operation.wait_until_done!\n # [END vision_text_detection_pdf_gcs_migration]\n\n # Once the request has completed and the output has been\n # written to GCS, we can list all the output files.\n storage = Google::Cloud::Storage.new\n\n bucket_name, prefix = gcs_destination_uri.match(\"gs://([^/]+)/(.+)\").captures\n bucket = storage.bucket bucket_name\n\n # List objects with the given prefix.\n puts \"Output files:\"\n blob_list = bucket.files prefix: prefix\n blob_list.each do |file|\n puts file.name\n end\n\n # Process the first output file from GCS.\n # Since we specified a batch_size of 2, the first response contains\n # the first two pages of the input file.\n output = blob_list[0]\n json_string = output.download\n response = JSON.parse json_string.string\n\n # The actual response for the first page of the input file.\n first_page_response = response[\"responses\"][0]\n annotation = first_page_response[\"fullTextAnnotation\"]\n\n # Here we print the full text from the first page.\n # The response contains more information:\n # annotation/pages/blocks/paragraphs/words/symbols\n # including confidence scores and bounding boxes\n puts \"Full text:\\n#{annotation['text']}\"\n # [END vision_text_detection_pdf_gcs]\nend",
"def nasa_space_craft; end",
"def api; end",
"def api; end",
"def initialize\n @connection = nil\n @gapi = {}\n end",
"def initialize\n @connection = nil\n @gapi = {}\n end",
"def villian; end",
"def wagner; end",
"def build_client_algorithm_packet; end",
"def prapor_quest; end",
"def ipn_end_point; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def viewMap(address, to_lat, to_lng, callback)\n puts \"viewMap(address:#{address}, to_lat:#{to_lat}, to_lng:#{to_lng}, callback:#{callback}\"\n\n if GeoLocation.known_position?\n from_lat = GeoLocation.latitude\n from_lng = GeoLocation.longitude\n else\n from_lat = 34.3932857\n from_lng = 132.4705439\n from_lat = 34.4893270\n from_lng = 133.3614320\n from_lat = 35.005018\n from_lng = 135.889155\n end\n\n if callback\n #GeoLocation.set_notification(url_for(:action => :geo_callback), \"\")\n GeoLocation.set_notification(callback, \"\")\n end\n\n puts \"from:#{from_lat},#{from_lng} => to:#{to_lat},#{to_lng}\"\n puts \"distance: #{GeoLocation.haversine_distance(from_lat,from_lng,to_lat,to_lng)}\"\n\n #region = [@params['latitude'], @params['longitude'], 1/69.0, 1/69.0] #miles\n #region = [@params['latitude'], @params['longitude'], 1/111.0, 1/111.0] #km\n region = [(to_lat + from_lat) / 2, (to_lng + from_lng) / 2,\n (to_lat - from_lat).abs, (to_lng - from_lng).abs]\n\n url = \"http://maps.google.jp/maps/api/directions/json?\" +\n \"origin=#{from_lat},#{from_lng}&\" +\n \"destination=#{to_lat},#{to_lng}&\" +\n \"mode=walking&\" +\n \"language=ja&\" +\n \"sensor=true\"\n #puts url\n\n res2 = Rho::AsyncHttp.get(\n :url => url,\n #:headers => {\"Cookie\" => cookie},\n )\n #puts res2.inspect\n #puts res2[\"status\"]\n\n# if res2[\"status\"] == \"ok\"\n# end\n\n myannotations = []\n\n #puts res2[\"body\"].inspect\n #puts res2[\"body\"][\"status\"]\n #puts res2[\"body\"][\"routes\"].size\n #puts res2[\"body\"][\"routes\"][0][\"legs\"].size\n #puts res2[\"body\"][\"routes\"][0][\"legs\"][0][\"steps\"].size\n\n res2[\"body\"][\"routes\"][0][\"legs\"][0][\"steps\"].each do |step|\n #puts step.inspect\n\n title = step[\"html_instructions\"]\n title = title.gsub(/\\<\\/?[bB]\\>/, \"\")\n #puts title\n\n myannotations << {\n :latitude => step[\"start_location\"][\"lat\"],\n :longitude => step[\"start_location\"][\"lng\"],\n :title => title,\n :subtitle => step[\"distance\"][\"text\"],\n #:url => \"/app/GeoLocation/show?city=Original Location\",\n #:image => '/public/images/marker_blue.png', :image_x_offset => 8, :image_y_offset => 32\n }\n end\n\n myannotations << {\n :latitude => to_lat,\n :longitude => to_lng,\n :title => address,\n #:subtitle => @params['map']['address'],\n #:url => \"/app/GeoLocation/show?city=Original Location\"\n }\n\n map_params = {\n #:provider => \"Google\",\n :provider => \"ESRI\",\n :settings => {\n #:map_type => \"roadmap\",\n :map_type => \"standard\",\n :region => region,\n :zoom_enabled => true, :scroll_enabled => true, :shows_user_location => true,\n #:api_key => '0jDNua8T4Teq0RHDk6_C708_Iiv45ys9ZL6bEhw'\n },\n :annotations => myannotations\n }\n\n #puts map_params.inspect\n puts \"-------------------------\"\n MapView.create map_params\n end",
"def vision scope: nil, retries: nil, timeout: nil\n require \"gcloud/vision\"\n Gcloud.vision @project, @keyfile, scope: scope,\n retries: (retries || @retries),\n timeout: (timeout || @timeout)\n end",
"def internal; end",
"def service_setup()\n # Uncomment the following lines to enable logging.\n #log_file = File.open(\"#{$0}.log\", 'a+')\n #log_file.sync = true\n #logger = Logger.new(log_file)\n #logger.level = Logger::DEBUG\n #Google::APIClient.logger = logger # Logging is set globally\n\n authorization = nil\n # FileStorage stores auth credentials in a file, so they survive multiple runs\n # of the application. This avoids prompting the user for authorization every\n # time the access token expires, by remembering the refresh token.\n #\n # Note: FileStorage is not suitable for multi-user applications.\n file_storage = Google::APIClient::FileStorage.new(CREDENTIAL_STORE_FILE)\n if file_storage.authorization.nil?\n client_secrets = Google::APIClient::ClientSecrets.load\n # The InstalledAppFlow is a helper class to handle the OAuth 2.0 installed\n # application flow, which ties in with FileStorage to store credentials\n # between runs.\n flow = Google::APIClient::InstalledAppFlow.new(\n :client_id => client_secrets.client_id,\n :client_secret => client_secrets.client_secret,\n :scope => [API_SCOPE]\n )\n authorization = flow.authorize(file_storage)\n else\n authorization = file_storage.authorization\n end\n\n # Initialize API Service.\n #\n # Note: the client library automatically creates a cache file for discovery\n # documents, to avoid calling the discovery service on every invocation.\n # To set this to an ActiveSupport cache store, use the :cache_store parameter\n # (or, alternatively, set it to nil if you want to disable caching).\n service = Google::APIClient::Service.new(API_NAME, API_VERSION,\n {\n :application_name => \"Ruby #{API_NAME} samples: #{$0}\",\n :application_version => '1.0.0',\n :authorization => authorization\n }\n )\n\n return service\nend",
"def g1\n @g1 ||= values_to_sentence(['http://purl.obolibrary.org/obo/GAZ_00000071'])\n end",
"def preflight; end",
"def initialize(key, query, ip_number = nil, referrer_site = '', args={})\n\n @google_api_key = key\n @query = query\n \n @ip_number = ip_number || IPSocket.getaddress(Socket.gethostname)\n\n @referrer_site = referrer_site\n\n @args = args\n\n @response_details = @response_status = nil\n @cursor = nil\n end",
"def google(query)\n # API key, engine id, and uri to make API call\n key = CSE_API_KEY\n # \"AIzaSyDpp4azZVRsBYgmjAqSI-Z-PIZG8FI-hfw\"\n engine_id = CSE_ENGINE_ID\n # \"011724650152002634172:r-e9bq2ubda\"\n uri = URI(\"https://www.googleapis.com/customsearch/v1?cx=#{engine_id}&q=#{query}&key=#{key}\")\n\n # GET request\n request = Net::HTTP::Get.new(uri)\n\n # Receive response\n res = Net::HTTP.get_response(uri)\n\n # Parse JSON file and converts to hash\n json = JSON.parse(res.body)\n items = json['items']\n\n # Iterate through JSON/items array and print each index\n i = 0\n loop do\n puts (i+1).to_s + \" -- \" + items[i]['title']\n # puts items[i]['link'] # url\n # puts items[i]['snippet'] # snippet of article\n i += 1\n if i == items.length\n break\n end\n end\n end",
"def negotiate_algorithms; end",
"def camUseNVG _args\n \"camUseNVG _args;\" \n end",
"def sn\n end",
"def http; end",
"def map_onload_func_body\n return_string = \"\"\n @controls.each do |control|\n return_string << control.to_javascript\n end\n\n if [email protected]?\n types = { 1 => 'G_SATELLITE_TYPE', 2 => 'G_MAP_TYPE', 3 => 'G_HYBRID_TYPE'}\n \n return_string << \"#{self.name}.setMapType(#{types[type]});\"\n end\n \n @markers.each do | marker |\n if marker[:create_with] == 'default'\n return_string << GMarker.new(marker).to_javascript\n else\n function_key = marker[:create_with]\n funcname = self.marker_code_funcname_lookup[function_key]\n \n func_args = self.marker_code_args[function_key]\n function_call_string = \"var marker = #{funcname}(\"\n func_args.each do | arg |\n if marker[arg].class.name == 'Mappa::GLatLng'\n function_call_string << marker[arg].to_javascript << ','\n else\n function_call_string << marker[arg].to_s << ','\n end\n end\n \n function_call_string[-1] = \");\\n\"\n return_string << function_call_string\n end\n return_string << \"#{self.name}.addOverlay(marker);\\n\" if !return_string.nil?\n return_string << \"bounds.extend(marker);;\\n\" if center_on_bounds?\n end\n \n @event_listeners.each do | listener |\n return_string << listener.to_javascript\n end\n\n if center_on_bounds?\n return_string << \" #{self.name}.centerAndZoomOnBounds(bounds); \"\n end\n \n return return_string\n end",
"def nn\n end",
"def test\n client = Google::APIClient.new(:application_name => \"supress\")\n connection = Fog::Compute.new(:provider => \"Google\", :google_client => client)\n\n begin\n p connection.client.discovered_apis\n p connection.servers\n rescue StandardError => e\n p e.message\n end\nend",
"def ca; end",
"def swift_bic; end",
"def c_generate_proto(tables)\n tables.each{|k,v|\n puts \"static void decode_#{k}(#{$cargs_proto});\"\n }\nend",
"def implementation; end",
"def implementation; end",
"def methods() end",
"def network; end",
"def network; end",
"def network; end",
"def network; end",
"def network; end",
"def network; end",
"def how_it_works\r\n end",
"def methods; end",
"def methods; end",
"def methods; end",
"def methods; end",
"def calls; end",
"def calls; end",
"def description\n \"This task hits the Google API and creates an entity for all discovered subdomains.\"\nend",
"def peacekeeper_quest; end",
"def description\n \"This task hits the Google API and finds related content. Discovered domains are created.\"\nend",
"def description\n \"This task hits the Google API and finds related content. Discovered domains are created.\"\nend",
"def initialize\r\n\r\n end",
"def external; end",
"def protocol; end",
"def protocol; end",
"def protocol; end"
] | [
"0.5996517",
"0.57838815",
"0.56707555",
"0.55488425",
"0.54202586",
"0.53574556",
"0.53219384",
"0.53174603",
"0.5304487",
"0.5304487",
"0.5304487",
"0.5304487",
"0.5304487",
"0.5304487",
"0.5304487",
"0.5304487",
"0.5282467",
"0.52805656",
"0.5247497",
"0.5245725",
"0.5213926",
"0.5213926",
"0.5189846",
"0.51744586",
"0.51710796",
"0.51599383",
"0.5153724",
"0.5150231",
"0.5150231",
"0.5141237",
"0.51334125",
"0.5118088",
"0.5118088",
"0.5114591",
"0.5114591",
"0.5108994",
"0.50749004",
"0.5074515",
"0.5069228",
"0.5058125",
"0.5053305",
"0.50303423",
"0.50303423",
"0.5028869",
"0.5028869",
"0.50227106",
"0.5018247",
"0.5002018",
"0.49976406",
"0.49887964",
"0.49748698",
"0.49748698",
"0.49748698",
"0.49748698",
"0.49748698",
"0.49748698",
"0.49748698",
"0.49748698",
"0.49498287",
"0.49337608",
"0.49327826",
"0.49191397",
"0.491839",
"0.4905527",
"0.49027225",
"0.4899934",
"0.48892885",
"0.48888853",
"0.48746407",
"0.48658165",
"0.48635113",
"0.4862641",
"0.48593155",
"0.48544452",
"0.48541775",
"0.485332",
"0.485279",
"0.485279",
"0.48519078",
"0.48471236",
"0.48471236",
"0.48471236",
"0.48471236",
"0.48471236",
"0.48471236",
"0.4847079",
"0.48455995",
"0.48455995",
"0.48455995",
"0.48455995",
"0.4843841",
"0.4843841",
"0.4832422",
"0.48299068",
"0.48216727",
"0.48216727",
"0.481163",
"0.48046586",
"0.48034722",
"0.48034722",
"0.48034722"
] | 0.0 | -1 |
Fetches the data from the google sheet | def fetch_group_data
response = fetch_data(@@SETTINGS.group_tab)
unless response.nil?
adjust_groups response
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_cellfeed(spreadsheet_key)\n cellfeed_uri = \"http://spreadsheets.google.com/feeds/cells/#{spreadsheet_key}/od6/private/full\"\n cellfeed_response = get_feed(cellfeed_uri) \n create_datastructure_from_xml(cellfeed_response.body)\n \n end",
"def read_score_table service, spreadsheet_id\n response = service.get_spreadsheet_values(spreadsheet_id, 'Score!A:B')\n puts 'No data found.' if response.values.empty?\n response.values.each do |row|\n puts \"#{row[0]}, #{row[1]}\"\n end\nend",
"def loadstudents\n #service = googleauthorisation(request)\n returned_authorisation = googleauthorisation(request)\n if returned_authorisation[\"authorizationurl\"]\n redirect_to returned_authorisation[\"authorizationurl\"] and return\n end\n service = returned_authorisation[\"service\"]\n #spreadsheet_id = '1CbtBqeHyYb9jRmROCgItS2eEaYSwzOMpQZdUWLMvjng'\n spreadsheet_id = current_user[:ssurl].match(/spreadsheets\\/d\\/(.*?)\\//)[1]\n logger.debug 'about to read spreadsheet'\n startrow = 3\n # first get the 3 columns - Student's Name + Year, Focus, study percentages\n range = \"STUDENTS!A#{startrow}:C\"\n response = service.get_spreadsheet_values(spreadsheet_id, range)\n @students = Array.new(response.values.length){Array.new(11)}\n #logger.debug \"students: \" + @students.inspect\n basecolumncount = 1 #index for loading array - 0 contains spreadsheet row number\n rowcount = 0\t\t\t \n response.values.each do |r|\n #logger.debug \"============ row #{rowcount} ================\"\n #logger.debug \"row: \" + r.inspect\n colcount = 0\n @students[rowcount][0] = rowcount + startrow\n r.each do |c|\n #logger.debug \"============ cell value for column #{colcount} ================\"\n \t #logger.debug \"cell value: \" + c.inspect\n \t @students[rowcount][basecolumncount + colcount] = c\n \t\t colcount = colcount + 1\n end\n rowcount = rowcount + 1\n end\n basecolumncount += 3\n # second get the 1 column - email\n range = \"STUDENTS!E#{startrow}:E\"\n response = service.get_spreadsheet_values(spreadsheet_id, range)\n #logger.debug \"students: \" + @students.inspect\n rowcount = 0\t\t\t \n response.values.each do |r|\n #logger.debug \"============ row #{rowcount} ================\"\n #logger.debug \"row: \" + r.inspect\n colcount = 0\n r.each do |c|\n #logger.debug \"============ cell value for column #{colcount} ================\"\n \t #logger.debug \"cell value: \" + c.inspect\n \t @students[rowcount][basecolumncount + colcount] = c\n \t\t colcount = colcount + 1\n end\n rowcount = rowcount + 1\n end\n basecolumncount += 1\n #third get the perferences and invcode\n range = \"STUDENTS!L#{startrow}:M\"\n response = service.get_spreadsheet_values(spreadsheet_id, range)\n rowcount = 0\n response.values.each do |r|\n colcount = 0\n r.each do |c|\n \t @students[rowcount][basecolumncount + colcount] = c\n \t\t colcount = colcount + 1\n end\n rowcount = rowcount + 1\n end\n basecolumncount += 2\n #fourth get the 3 columns daycode, term 4, daycode\n # these will be manipulated to get the savable daycode\n range = \"STUDENTS!P#{startrow}:R\"\n response = service.get_spreadsheet_values(spreadsheet_id, range)\n rowcount = 0\n response.values.each do |r|\n colcount = 0\n r.each do |c|\n \t @students[rowcount][basecolumncount + colcount] = c\n \t\t colcount = colcount + 1\n end\n rowcount = rowcount + 1\n end\n basecolumncount += 3\n #logger.debug \"students: \" + @students.inspect\n # Now to update the database\n loopcount = 0 # limit output during testing\n @students.each do |t| # step through all ss students\n pnameyear = t[1]\n logger.debug \"pnameyear: \" + pnameyear.inspect\n if pnameyear == \"\" || pnameyear == nil\n t[10] = \"invalid pnameyear - do nothing\"\n next\n end\n #pnameyear[/^zz/] == nil ? status = \"active\" : status = \"inactive\"\n name_year_sex = getStudentNameYearSex(pnameyear)\n pname = name_year_sex[0]\n year = name_year_sex[1]\n sex = name_year_sex[2]\n status = name_year_sex[3]\n logger.debug \"pname: \" + pname + \" : \" + year + \" : \" +\n sex.inspect + \" : \" + status\n # day code\n # use term 3 code unless a term 4 code, then take term 4\n t[9] == \"\" || t[9] == nil ? usedaycode = t[7] : usedaycode = t[9]\n # check if alrady an entry in the database\n # if so, update it. else create a new record.\n db_student = Student.find_by pname: pname\n if(db_student) # already in the database\n flagupdate = 0 # detect if any fields change\n updatetext = \"\"\n # first get the 4 columns - 1. Student's Name + Year, 2. Focus,\n # 3. study percentages, 4. email\n # now get the 5. perferences and 6. invcode\n # now get the 7. daycode, 8. term 4, 9. daycode\n if db_student.year != year\n db_student.year = year\n flagupdate = 1\n updatetext = updatetext + \" - year\" \n end\n if sex\n if db_student.sex != sex\n db_student.sex = sex\n flagupdate = 1\n updatetext = updatetext + \" - sex (\" + sex + \")\"\n end\n end\n if db_student.comment != t[2]\n db_student.comment = t[2]\n flagupdate = 1\n updatetext = updatetext + \" - comment\" \n end\n if db_student.study != t[3]\n db_student.study = t[3]\n flagupdate = 1\n updatetext = updatetext + \" - study percentages\" \n end\n if db_student.email != t[4]\n db_student.email = t[4]\n flagupdate = 1\n updatetext = updatetext + \" - email\" \n end\n if db_student.preferences != t[5]\n db_student.preferences = t[5]\n flagupdate = 1\n updatetext = updatetext + \" - preferences\" \n end\n if db_student.invcode != t[6]\n db_student.invcode = t[6]\n flagupdate = 1\n updatetext = updatetext + \" - invoice code\" \n end\n if db_student.daycode != usedaycode\n db_student.daycode = usedaycode\n flagupdate = 1\n updatetext = updatetext + \" - day code\" \n end\n if db_student.status != status\n db_student.status = status\n flagupdate = 1\n updatetext = updatetext + \" - status\" \n end\n logger.debug \"flagupdate: \" + flagupdate.inspect + \" db_student: \" + db_student.inspect\n if flagupdate == 1 # something changed - need to save\n if db_student.save\n logger.debug \"db_student saved changes successfully\"\n t[10] = \"updated #{db_student.id} \" + updatetext \n else\n logger.debug \"db_student saving failed - \" + @db_student.errors\n t[10] = \"failed to update\"\n end\n else\n t[10] = \"no changes\"\n end\n else\n # This Student is not in the database - so need to add it.\n #\n # first get the 4 columns - 1. Student's Name + Year, 2. Focus,\n # 3. study percentages, 4. email\n # now get the 5. perferences and 6. invcode\n # now get the 7. daycode, 8. term 4, 9. daycode\n @db_student = Student.new(\n pname: pname,\n year: year,\n comment: t[2],\n study: t[3],\n email: t[4],\n preferences: t[5],\n invcode: t[6],\n daycode: usedaycode,\n status: status,\n sex: sex\n )\n logger.debug \"new - db_student: \" + @db_student.inspect\n if @db_student.save\n logger.debug \"db_student saved successfully\"\n t[10] = \"created #{@db_student.id}\" \n else\n logger.debug \"db_student saving failed - \" + @db_student.errors.inspect\n t[10] = \"failed to create\"\n end\n end\n #exit\n if loopcount > 2\n #break\n end\n loopcount += 1\n end\n end",
"def save_from_on_GoogleDrive\n session = GoogleDrive::Session.from_config(\"config.json\")\n# ws = session.spreadsheet_by_key(\"1PzbUao-3UscYOWh48FL061r5yYcH2TBl1oWXtmaW1cw\").worksheets[0] #cle a changer en fonction du lien url du fichier google drive\n ws = session.spreadsheet_by_key(\"1PzbUao-3UscYOWh48FL061r5yYcH2TBl1oWXtmaW1cw\").worksheets[1] #cle a changer en fonction du lien url du fichier google drive\n table_of_mails=[]\n # for i in 1..table_data.length\n # ws[i, 1] = table_data[i-1][:nom]\n # ws[i, 2] = table_data[i-1][:url]\n # ws[i, 3] = table_data[i-1][:email]\n # end\n puts ws.num_rows\n (1..(ws.num_rows + 1)).each do |row|\n puts ws[row + 1, 2]\n table_of_mails << ws[row + 1, 2]\n end\n Operation_on_gmail(table_of_mails)\n ws.save\n ws.reload\nend",
"def temporary_fetch\n url = \"https://docs.google.com/spreadsheets/d/1woXBbju2J6lYU5nKFKDU3nBySgKW9MWP_vEkG7FsnWs/pub?gid=2114410807&single=true&output=csv\"\n data1 = CSV.parse(open(url).read)\n parse_into_items(data1, 1)\n\n # Assessment 2\n url = \"https://docs.google.com/spreadsheets/d/1woXBbju2J6lYU5nKFKDU3nBySgKW9MWP_vEkG7FsnWs/pub?gid=1657164873&single=true&output=csv\"\n data1 = CSV.parse(open(url).read)\n parse_into_items(data1, 2)\n\n # Assessment 3\n url = \"https://docs.google.com/spreadsheets/d/1woXBbju2J6lYU5nKFKDU3nBySgKW9MWP_vEkG7FsnWs/pub?gid=1278939598&single=true&output=csv\"\n data1 = CSV.parse(open(url).read)\n parse_into_items(data1, 3)\n\n # Assessment 4\n url = \"https://docs.google.com/spreadsheets/d/1woXBbju2J6lYU5nKFKDU3nBySgKW9MWP_vEkG7FsnWs/pub?gid=397189839&single=true&output=csv\"\n data1 = CSV.parse(open(url).read)\n parse_into_items(data1, 4)\n\n # Assessment 5\n url = \"https://docs.google.com/spreadsheets/d/1woXBbju2J6lYU5nKFKDU3nBySgKW9MWP_vEkG7FsnWs/pub?gid=13824931&single=true&output=csv\"\n data1 = CSV.parse(open(url).read)\n parse_into_items(data1, 5)\n\n return Item.list\nend",
"def get_worksheet(spreadsheet_key)\n worksheet_feed_uri = \"http://spreadsheets.google.com/feeds/\" <<\n \"worksheets/#{spreadsheet_key}/private/full\"\n worksheet_feed_response = get_feed(worksheet_feed_uri) \n create_datastructure_from_xml(worksheet_feed_response.body)\n \n end",
"def get_spreadsheet\n begin\n return parse_spreadsheet(session.spreadsheet_by_key(\"1CR96shZ0bAyviDydUjGgGxmg6iVXSanh1dNrQ28AbY8\"))\n rescue Google::Apis::ClientError => e\n Raven.capture_exception(e.message)\n return nil\n end\n end",
"def loadstudentsUpdates\n @flagDbUpdateRun = false\n if params.has_key?('flagDbUpdate')\n if params['flagDbUpdate'] == 'run'\n @flagDbUpdateRun = true\n end\n end\n logger.debug \"@flagDbUpdateRun: \" + @flagDbUpdateRun.inspect\n #service = googleauthorisation(request)\n returned_authorisation = googleauthorisation(request)\n if returned_authorisation[\"authorizationurl\"]\n redirect_to returned_authorisation[\"authorizationurl\"] and return\n end\n service = returned_authorisation[\"service\"]\n #spreadsheet_id = '1CbtBqeHyYb9jRmROCgItS2eEaYSwzOMpQZdUWLMvjng'\n spreadsheet_id = current_user[:ssurl].match(/spreadsheets\\/d\\/(.*?)\\//)[1]\n sheet_name = current_user[:sstab]\n\n #---------------------- Read the spreadsheet --------------------\n logger.debug 'about to read spreadsheet'\n startrow = 1\n # first get the 3 columns - Student's Name + Year, Focus, study percentages\n #This is now all that we get\n range = sheet_name + \"!A#{startrow}:U\"\n response = service.get_spreadsheet_values(spreadsheet_id, range)\n @students_raw = Array.new(response.values.length){Array.new(11)}\n #logger.debug \"students: \" + @students_raw.inspect\n basecolumncount = 1 #index for loading array - 0 contains spreadsheet row number\n rowcount = 0\t\t\t \n response.values.each do |r|\n #logger.debug \"============ row #{rowcount} ================\"\n #logger.debug \"row: \" + r.inspect\n colcount = 0\n @students_raw[rowcount][0] = rowcount + startrow\n r.each do |c|\n #logger.debug \"============ cell value for column #{colcount} ================\"\n \t #logger.debug \"cell value: \" + c.inspect\n \t @students_raw[rowcount][basecolumncount + colcount] = c\n \t\t colcount = colcount + 1\n end\n rowcount = rowcount + 1\n end\n #------------------------ Verify spreadsheet --------------------\n sheetheader = @students_raw[0]\n flagHeaderOK = true\n expectedheader = [1, \"ID\", \"Given Name\", \"Family Name\", \"MERGE\",\n \"Preferred Name\", \"UPDATE NAME\", \"Initials\", \"Sex\", \"UPDATE SEX\",\n \"Comment\", \"UPDATE COMMENT\", \"Status\", \"UPDATE STATUS\",\n \"Year\", \"UPDATE YEAR\", \"Study Percentages\",\n \"UPDATE STUDY PERCENTAGES\", \"Email\", \"Phone\",\n \"Inv Code\", \"Day Code\"]\n \n headermessage = \"Failed headers: \"\n expectedheader.each_with_index do |o, i|\n if o != sheetheader[i]\n flagHeaderOK = false \n headermessage += \"#{i.to_s} => expected (#{o}) got (#{sheetheader[i]}) \"\n end\n end\n if flagHeaderOK == false\n @students = Array.new\n @students[0] = Hash.new\n @students[0]['message'] = \"spreadsheet error - header is not correct. \" +\n \"You have selected the wrong spreadsheet or \" +\n \"you have not set it up correctly.\"\n @students[1] = Hash.new\n @students[1]['message'] = \"Correct headers are: \" + expectedheader.inspect \n @students[2] = Hash.new\n @students[2]['message'] = headermessage \n return\n end\n #---------------------- Scan spreadsheet rows --------------------\n # now build a student hash of field names with field values\n @students = Array.new\n @studentsIndexById = Hash.new\n @students_raw.each_with_index do |s, j|\n #logger.debug \"j:: \" + j.inspect\n next if j == 0 # don't want the header\n #break if j > 4 # DEBUG ONLY\n i = j-1\n @students[i] = Hash.new\n @students[i]['row'] = s[0]\n if s[1] == \"\" # no record in the db according to the spreadsheet\n # Will need to be created. Need main values as opposed to\n # update primary values (ignore spreadsheet 'update' values).\n @students[i]['pname'] = s[5]\n @students[i]['sex'] = s[8]\n @students[i]['comment'] = s[10]\n @students[i]['status'] = s[12]\n @students[i]['year'] = s[14]\n @students[i]['study'] = s[16]\n else # we only want to update the database\n # this loads the update columns only and only if spreadsheet has content.\n @students[i]['id'] = s[1].to_i # already know it is there\n @students[i]['oldpname'] = s[5] if s[5] && s[5].match(/\\w+/)\n @students[i]['pname'] = s[6] if s[6] && s[6].match(/\\w+/) \n @students[i]['sex'] = s[9] if s[9] && s[9].match(/\\w+/) \n @students[i]['comment'] = s[11] if s[11] && s[11].match(/\\w+/) \n @students[i]['status'] = s[13] if s[13] && s[13].match(/\\w+/) \n @students[i]['year'] = s[15] if s[15] && s[15].match(/\\w+/)\n @students[i]['study'] = s[17] if s[17] && s[17].match(/\\w+/)\n # possibly a merge is required\n @students[i]['merge'] = s[4] if s[4].match(/\\w+/)\n end\n # need to store message for display to the user.\n @students[i]['message'] = \"\"\n # Build index to be used for finding merged entries.\n @studentsIndexById[@students[i]['id']] = @students[i] if @students[i].has_key?('id') \n end\n #logger.debug \"students: \" + @students.inspect\n # --------------- Check ids match pnames in dbvs spreadsheet -------------\n @allDbStudents = Student.all\n @allDbStudentsIndex = Hash.new\n @allDbStudents.each do |a|\n @allDbStudentsIndex[a.id] = a\n end\n idErrors = \"\"\n flagIdOK = true\n @students.each do |s|\n if s.has_key?('id') && s.has_key?('oldpname')\n unless @allDbStudentsIndex.has_key?(s['id']) # this spreadsheet id not in the database\n flagIdOK = false\n idErrors += \"Failed spreadsheet id not in database row #{s['row']} - #{s['id']} \"\n next\n end\n if s['oldpname'] != @allDbStudentsIndex[s['id']].pname # Still possibly OK\n # May have already been updated with new pname on previous run\n if s.has_key?('pname') # potentially still OK - check updated pname\n if s['pname'] != @allDbStudentsIndex[s['id']].pname # not OK unless merged \n flagIdOK = false\n idErrors += \"Failed id check row #{s['row']} db: #{@allDbStudentsIndex[s['id']].pname} - update pname #{s['pname']}\"\n end\n elsif s.has_key?('merge') # potentially still OK - check if merged\n m = s['merge'].match(/^Merge.+?(\\d+)$/)\n if m[1] # ensure relevenant info\n merge_into_id = m[1].to_i\n unless @studentsIndexById.has_key?(merge_into_id) # merge in entry not present\n flagIdOK = false\n idErrors += \"Failed id check - merged_into row not present row #{s['row']} db: #{@allDbStudentsIndex[s['id']].pname} - #{s['oldpname']} -> merged \"\n else\n mergedPname = \"zzzMERGED \" + @studentsIndexById[merge_into_id]['oldpname']\n if mergedPname != @allDbStudentsIndex[s['id']].pname # not OK unless merged \n flagIdOK = false\n idErrors += \"Failed id check - not previously merged either row #{s['row']} db: #{@allDbStudentsIndex[s['id']].pname} - #{s['oldpname']} -> merged \"\n end\n end\n else\n flagIdOK = false\n idErrors += \"Failed id check row on merged pname not present #{s['row']} db: #{@allDbStudentsIndex[s['id']].pname} - #{s['oldpname']} \"\n end\n else\n flagIdOK = false\n idErrors += \"Failed id check row #{s['row']} db: #{@allDbStudentsIndex[s['id']].pname} - #{s['oldpname']} \"\n end\n end\n end\n end\n if flagIdOK == false\n @students = Array.new\n @students[0] = Hash.new\n @students[0]['message'] = \"spreadsheet error - ids do not match with pnames. \" +\n \"You have selected the wrong spreadsheet or \" +\n \"you have downloaded the wrong database.\"\n @students[1] = Hash.new\n @students[1]['message'] = idErrors \n return\n end\n #\n # --------------- Now to work through database creation or update -------------\n #@students is a hash of all records from the spreadsheets\n @students.each_with_index do |s, i|\n #logger.debug \"i: \" + i.inspect + \" s[id]: \" + s['id'].inspect\n #break if i > 1 # DEBUGGING ONLY\n # --------------- create record -------------\n if s['id'] == nil || s['id'] == \"\" # not yet created according to the spreadsheet\n logger.debug \"creating a record\"\n # better check to see if it has been created in a previous run\n if @students[i].has_key?('pname') # pname field is mandatory\n @checkstudents = Student.where(pname: @students[i]['pname'])\n if @checkstudents.count == 0 # confirmed not in database as spreadsheet expects\n # simply do nothing and let update proceed.\n else\n @students[i]['message'] += \"ERROR - record already in the database - row #{(i+1).to_s}\" \n next # ERROR - record already in the database\n end\n else # no pname value - ABORT this record!!!\n @students[i]['message'] += \"no pname provided to allow db record creation - row #{(i+1).to_s}\" \n next # ERROR in spreadsheet - cannot do any more with this\n end\n # All OK for record creation\n @student = Student.new(pname: @students[i]['pname'])\n @student.comment = @students[i]['comment'] if @students[i].has_key?('comment')\n @student.status = @students[i]['status'] if @students[i].has_key?('status')\n @student.year = @students[i]['year'] if @students[i].has_key?('year')\n @student.study = @students[i]['study'] if @students[i].has_key?('study')\n @student.sex = @students[i]['sex'] if @students[i].has_key?('sex')\n #logger.debug \"create student #{i.to_s}: \" + @student.inspect\n if @flagDbUpdateRun\n logger.debug \"update option selected - creating record\"\n if @student.save\n @students[i]['message'] = \"OK - Record created - row #{i.to_s}\" + @students[i]['message']\n logger.debug \"saved changes to \" + @students[i]['message']\n else\n @students[i]['message'] += \"ERROR - row #{i.to_s} - problem saving changes to db for \" + @students[i]['message']\n logger.debug \"problem saving changes to db for \" + @students[i]['message']\n end\n else\n @students[i]['message'] = \"OK - Record created - row #{i.to_s}\" + @students[i]['message']\n end\n else # spreadsheet says record should be in th database\n # --------------- update record -------------\n #logger.debug \"updating the database\"\n @student = Student.find(s['id']) # get the record & update\n if @student # record exists - now to update\n if s['pname'] && @student.pname != s['pname']\n @students[i]['message'] += \"#update pname:\" + @student.pname.inspect + \"=>\" + s['pname']\n @student.pname = s['pname']\n end\n if s['comment'] && @student.comment != s['comment']\n @students[i]['message'] += \"#update comment:\" + @student.comment.inspect + \"=>\" + s['comment']\n @student.comment = s['comment']\n end\n if s['status'] && @student.status != s['status']\n @students[i]['message'] += \"#update status:\" + @student.status.inspect + \"=>\" + s['status']\n @student.status = s['status']\n end\n if s['year'] && @student.year != s['year']\n @students[i]['message'] += \"#update year:\" + @student.year.inspect + \"=>\" + s['year']\n @student.year = s['year']\n end\n if s['study'] && @student.study != s['study']\n @students[i]['message'] += \"#update study:\" + @student.study.inspect + \"=>\" + s['study']\n @student.study = s['study']\n end\n if s['sex'] && @student.sex != s['sex']\n @students[i]['message'] += \"#update sex:\" + @student.sex.inspect + \"=>\" + s['sex']\n @student.sex = s['sex']\n end\n if @students[i]['message'].length > 0\n #logger.debug \"saved changes row #{(i+1).to_s} \" + @students[i]['message']\n logger.debug \"update student #{i.to_s}: \" + @student.inspect\n if @flagDbUpdateRun\n logger.debug \"update option selected - updating record\"\n if @student.save\n #logger.debug \"OK - saved changes to \" + @students[i]['message']\n @students[i]['message'] = \"OK record updated - row #{i.to_s} \" + @students[i]['message']\n else\n logger.debug \"ERROR - row #{i.to_s} - problem saving changes to db for \" + @students[i]['message']\n end\n end\n else\n @students[i]['message'] = \"INFO no updates required as record is already correct - row #{i.to_s}\" + @students[i]['message']\n end\n else # record not in database - which was expected.\n @students[i]['message'] += \"ERROR - no record found for this entry - row #{(i+1).to_s}\" \n # ABORT this record.\n end\n end\n end\n #--------------------------------------merge------------------------------\n # Merge requires:\n # 1. check both records exist\n # 2. find all roles for the student record being merged\n # 3. Update the student numbers in these to reference the merged_into student\n # 4. Set status of merged student to \"inactive\"\n # 5. Prepend comment to this student \"MERGED into student id xxx pname yyy\"\n # 6. Set pname to \"zzzMERGED \" + pname.\n #---------------------------------------------------------------------=--\n count_merges = 0\n @students.each_with_index do |s, i|\n #logger.debug \"i: \" + i.to_s + \" => \" + s.inspect\n if s.has_key?('merge') # merge requested\n count_merges += 1 # count the number of merges encounted in the spreadsheet\n #break if count_merges > 1 # DEBUGGING ONLY\n next if s['id'] == 0 # Not a record in the database accordingto the spreadsheet. \n merge_id = s['id'] # record to be merged\n #logger.debug \"merge_id: \" + merge_id.inspect + s['merge'].inspect\n m = s['merge'].match(/^Merge.+?(\\d+)$/)\n if m[1] # ensure relevenant info\n merge_into_id = m[1]\n else\n @students[i]['message'] += \" \\nError - requesting merge but merge info invalid\"\n return\n end\n # now check both records exist\n @student_merge = Student.find(merge_id)\n @students[i]['message'] += \"Error - merge record not in db\" unless @student_merge\n @student_merge_into = Student.find(merge_into_id)\n @students[i]['message'] += \"Error - merge_into record not in db\" unless @student_merge_into\n # find all the relevant roles\n @roles = Role.where(student_id: @student_merge)\n # Now check to see if the merge has already been done\n if @student_merge.pname.match(/^zzzMERGED/)\n @students[i]['message'] = \"INFO - already merged.\" + @students[i]['message'] + \" \"\n next\n end\n logger.debug \"Number of roles found for \" + @student_merge.pname + \" :\" + @roles.count.to_s\n # update the student_id in these roles to now reference merge_into\n @roles.each{|o| o.student_id = @student_merge_into.id}\n # Set merged student with status, comment and pname\n @student_merge.status = \"inactive\"\n @student_merge.comment = \"MERGED into student (#{@student_merge_into.id.to_s})\" +\n \" #{@student_merge_into.pname} \" + \n @student_merge_into.comment \n @student_merge.pname = \"zzzMERGED \" + @student_merge_into.pname\n # ensure each student stuff is done as a set.\n if @flagDbUpdateRun\n logger.debug \"update option selected - merging record\"\n begin\n Role.transaction do\n @roles.each do |myrole|\n myrole.save!\n end\n @student_merge.save!\n end\n rescue ActiveRecord::RecordInvalid => exception\n logger.debug \"Transaction failed row #{i._to_s} rollback exception: \" + exception.inspect\n @students[i]['message'] = \"ERROR - Transaction failed!!!\" + exception.inspect + @students[i]['message'] + \" \"\n next\n end\n end\n @students[i]['message'] = \" OK Record Merged. \" + @students[i]['message'] + \" \"\n end\n end\n end",
"def list_email()\nsession = GoogleDrive::Session.from_config(\"config.json\")\nws = session.spreadsheet_by_key(\"1v7XEnpGDtgjgRom3bp7OwzaK99zlUQIfKuW3QdawXBc\").worksheets[0]\n#define a lopp with each for the spreadsheet.\n(1..w_sheet.num_rows).each do |list|\n\t\tmail = ws[list, 2]\n\t\tcity = ws[list, 1]\n list_email(\"email\",\"password\",mail, city)\n end\nend",
"def get(range:, id:)\n begin\n open(get_request_path(range,id)).read \n rescue => e\n \"error fetching spreadsheet id #{id} with range #{range}\" \n end\n end",
"def loadstudents2\n #service = googleauthorisation(request)\n returned_authorisation = googleauthorisation(request)\n if returned_authorisation[\"authorizationurl\"]\n redirect_to returned_authorisation[\"authorizationurl\"] and return\n end\n service = returned_authorisation[\"service\"]\n #spreadsheet_id = '1CbtBqeHyYb9jRmROCgItS2eEaYSwzOMpQZdUWLMvjng'\n spreadsheet_id = current_user[:ssurl].match(/spreadsheets\\/d\\/(.*?)\\//)[1]\n logger.debug 'about to read spreadsheet'\n startrow = 3\n # first get the 3 columns - Student's Name + Year, Focus, study percentages\n #This is now all that we get\n range = \"STUDENTS!A#{startrow}:C\"\n response = service.get_spreadsheet_values(spreadsheet_id, range)\n @students = Array.new(response.values.length){Array.new(11)}\n #logger.debug \"students: \" + @students.inspect\n basecolumncount = 1 #index for loading array - 0 contains spreadsheet row number\n rowcount = 0\t\t\t \n response.values.each do |r|\n #logger.debug \"============ row #{rowcount} ================\"\n #logger.debug \"row: \" + r.inspect\n colcount = 0\n @students[rowcount][0] = rowcount + startrow\n r.each do |c|\n #logger.debug \"============ cell value for column #{colcount} ================\"\n \t #logger.debug \"cell value: \" + c.inspect\n \t @students[rowcount][basecolumncount + colcount] = c\n \t\t colcount = colcount + 1\n end\n rowcount = rowcount + 1\n end\n #logger.debug \"students: \" + @students.inspect\n\n # Now to update the database\n loopcount = 0 # limit output during testing\n @students.each do |t| # step through all ss students\n pnameyear = t[1]\n logger.debug \"pnameyear: \" + pnameyear.inspect\n if pnameyear == \"\" || pnameyear == nil\n t[10] = \"invalid pnameyear - do nothing\"\n next\n end\n #pnameyear[/^zz/] == nil ? status = \"active\" : status = \"inactive\"\n name_year_sex = getStudentNameYearSex(pnameyear)\n pname = name_year_sex[0]\n year = name_year_sex[1]\n sex = name_year_sex[2]\n status = name_year_sex[3]\n logger.debug \"pname: \" + pname + \" : \" + year + \" : \" +\n sex.inspect + \" : \" + status\n\n # check if alrady an entry in the database\n # if so, update it. else create a new record.\n db_student = Student.find_by pname: pname\n if(db_student) # already in the database\n flagupdate = 0 # detect if any fields change\n updatetext = \"\"\n # first get the 4 columns - 1. Student's Name + Year, 2. Focus,\n # 3. study percentages, 4. email\n # now get the 5. perferences and 6. invcode\n # now get the 7. daycode, 8. term 4, 9. daycode\n if db_student.year != year\n db_student.year = year\n flagupdate = 1\n updatetext = updatetext + \" - year\" \n end\n if sex\n if db_student.sex != sex\n db_student.sex = sex\n flagupdate = 1\n updatetext = updatetext + \" - sex\"\n end\n end\n if db_student.comment != t[2]\n db_student.comment = t[2]\n flagupdate = 1\n updatetext = updatetext + \" - comment\" \n end\n if db_student.study != t[3]\n db_student.study = t[3]\n flagupdate = 1\n updatetext = updatetext + \" - study percentages\" \n end\n if db_student.status != status\n db_student.status = status\n flagupdate = 1\n updatetext = updatetext + \" - status\" \n end\n logger.debug \"flagupdate: \" + flagupdate.inspect + \" db_student: \" + db_student.inspect\n if flagupdate == 1 # something changed - need to save\n if db_student.save\n logger.debug \"db_student saved changes successfully\"\n t[10] = \"updated #{db_student.id} \" + updatetext \n else\n logger.debug \"db_student saving failed - \" + @db_student.errors\n t[10] = \"failed to update\"\n end\n else\n t[10] = \"no changes\"\n end\n else\n # This Student is not in the database - so need to add it.\n #\n # first get the 4 columns - 1. Student's Name + Year, 2. Focus,\n # 3. study percentages, 4. email\n # now get the 5. perferences and 6. invcode\n # now get the 7. daycode, 8. term 4, 9. daycode\n @db_student = Student.new(\n pname: pname,\n year: year,\n comment: t[2],\n study: t[3],\n status: status\n )\n logger.debug \"new - db_student: \" + @db_student.inspect\n if @db_student.save\n logger.debug \"db_student saved successfully\"\n t[10] = \"created #{@db_student.id}\" \n else\n logger.debug \"db_student saving failed - \" + @db_student.errors.inspect\n t[10] = \"failed to create\"\n end\n end\n #exit\n if loopcount > 2\n #break\n end\n loopcount += 1\n end\n end",
"def show\n session = GoogleDrive.login(@company.gmail, @company.gpassword)\n\n # Schedule Sheet\n @ss = session.spreadsheet_by_key(@company.drive_id).worksheets[0]\n @schedule = []\n\n for i in 1..@ss[1, 2].to_i do\n hash = { :id => (i+1), :name => @ss[i+1, 4], :start_time => @ss[i+1, 5][0..1].to_i, :end_time => @ss[i+1, 6][0..1].to_i, :note => @ss[i+1, 10] }\n @schedule << hash\n end\n\n #Event Sheet\n @es = session.spreadsheet_by_key(@company.drive_id).worksheets[1]\n @events = []\n for i in 1..@es[1,2].to_i do\n @events << @es[i,3]\n end\n\n\n @new_comment = SpreadsheetComment.new\n @comments = SpreadsheetComment.where(:employee_id => 1, :commented_on => nil).order('created_at DESC')\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @company }\n end\n end",
"def loadtutors\n #service = googleauthorisation(request)\n returned_authorisation = googleauthorisation(request)\n if returned_authorisation[\"authorizationurl\"]\n redirect_to returned_authorisation[\"authorizationurl\"] and return\n end\n service = returned_authorisation[\"service\"]\n spreadsheet_id = current_user[:ssurl].match(/spreadsheets\\/d\\/(.*?)\\//)[1]\n #spreadsheet_id = '1CbtBqeHyYb9jRmROCgItS2eEaYSwzOMpQZdUWLMvjng'\n logger.debug 'about to read spreadsheet - service ' + service.inspect\n # Need some new code to cater for variation in the spreadsheet columns.\n # Will build an array with 'column names' = 'column numbers'\n # This can then be used to identify columns by name rather than numbers.\n #\n #this function converts spreadsheet indices to column name\n # examples: e[0] => A; e[30] => AE \n e=->n{a=?A;n.times{a.next!};a} \n columnmap = Hash.new # {'column name' => 'column number'}\n range = \"TUTORS!A3:LU3\"\n response = service.get_spreadsheet_values(spreadsheet_id, range)\n headerrow = response.values[0]\n logger.debug \"response: \" + headerrow.inspect\n headerrow.each_with_index do |value, index| \n columnmap[value] = index\n end\n logger.debug \"columnmap: \" + columnmap.inspect\n #readcolumns = Array.new\n\n # pname: t[1],\n # subjects: t[2],\n # phone: t[3],\n # email: t[4],\n # sname: t[5],\n # comment: t[6],\n \n # Derived fields\n # status: \"active\" unless prefixed with zz..\n # firstaid: \"yes\" if name has suffix +\n # firstsesson: \"yes\" if name has suffix *\n\n readcolumns = [ 'NAME + INITIAL',\n 'SUBJECTS',\n 'MOBILE',\n 'EMAIL',\n 'SURNAME',\n 'NOTES'\n ]\n colerrors = \"\"\n readcolumns.each_with_index do |k, index|\n unless columnmap[k] \n colerrors += k + ':'\n end \n end\n # ensure we can read all the required spreadsheet column\n # if not, terminate and provide a user message\n unless colerrors.length == 0 # anything put into error string\n colerrors = \"Load Tutors - not all columns are findable: \" + colerrors\n redirect_to load_path, notice: colerrors\n return\n end\n # have everything we need, load the tutors from the spreadsheet\n # placing info into @tutors.\n startrow = 4 # row where the loaded data starts \n flagFirstPass = 1\n readcolumns.each_with_index do |k, index|\n columnid = e[columnmap[k]]\n range = \"TUTORS!#{columnid}#{startrow}:#{columnid}\"\n response = service.get_spreadsheet_values(spreadsheet_id, range)\n if flagFirstPass == 1\n @tutors = Array.new(response.values.length){Array.new(9)}\n for rowcount in 0..response.values.count-1 \n \t @tutors[rowcount][0] = rowcount + startrow\n end\n flagFirstPass = 0\n end\n #rowcount = 0\n #response.values.each do |r|\n #for rowcount in 0..response.values.count \n response.values.each_with_index do |c, rowindex|\n \t @tutors[rowindex ][index + 1] = c[0]\n \t #bc = v.effective_format.background_color\n \t #logger.debug \"background color: red=\" + bc.red.to_s +\n \t # \" green=\" + bc.green.to_s +\n \t\t # \" blue=\" + bc.blue.to_s\n end \n end\n\n #logger.debug \"tutors: \" + @tutors.inspect\n # Now to update the database\n loopcount = 0\n @tutors.each do |t| # step through all tutors from the spreadsheet\n t[7] = \"\"\n pname = t[1]\n logger.debug \"pname: \" + pname.inspect\n if pname == \"\" || pname == nil\n t[7] = t[7] + \"invalid pname - do nothing\"\n next\n end\n # determine status from name content - been marked by leading z...\n thisstatus = \"active\"\n if m = pname.match(/(^z+)(.+)$/) # removing leading z.. (inactive entries)\n pname = m[2].strip\n thisstatus = \"inactive\"\n #t[1] = pname\n end\n # look for + (firstaid:) * (firstsession) at end of pname \n # (first aid trained or first session trained)\n thisfirstaid = 'no'\n thisfirstlesson = 'no'\n if m = pname.match(/([+* ]+)$/)\n thisfirstaid = (m[1].include?('+') ? 'yes' : 'no')\n thisfirstlesson = (m[1].include?('*') ? 'yes' : 'no')\n pname = pname.gsub($1, '') unless $1.strip.length == 0\n end\n pname = pname.strip\n \n db_tutor = Tutor.find_by pname: pname\n if(db_tutor) # already in the database\n flagupdate = 0 # detect if any fields change\n updatetext = \"\"\n if db_tutor.comment != t[6]\n db_tutor.comment = t[6]\n flagupdate = 1\n updatetext = updatetext + \" - comment\" \n end\n if db_tutor.sname != t[5]\n db_tutor.sname = t[5]\n flagupdate = 1\n updatetext = updatetext + \" - sname\" \n end\n if db_tutor.email != t[4]\n db_tutor.email = t[4]\n flagupdate = 1\n updatetext = updatetext + \" - email\" \n end\n if db_tutor.phone != t[3]\n db_tutor.phone = t[3]\n flagupdate = 1\n updatetext = updatetext + \" - phone\" \n end\n if db_tutor.subjects != t[2]\n db_tutor.subjects = t[2]\n flagupdate = 1\n updatetext = updatetext + \" - subjects\" \n end\n if db_tutor.status != thisstatus \n db_tutor.status = thisstatus\n flagupdate = 1\n updatetext = updatetext + \" - status\" \n end\n if db_tutor.firstaid != thisfirstaid \n db_tutor.firstaid = thisfirstaid\n flagupdate = 1\n updatetext = updatetext + \" - firstaid\" \n end\n if db_tutor.firstlesson != thisfirstlesson\n db_tutor.firstlesson = thisfirstlesson\n flagupdate = 1\n updatetext = updatetext + \" - firstlesson\" \n end\n logger.debug \"flagupdate: \" + flagupdate.inspect + \" db_tutor: \" + db_tutor.inspect\n if flagupdate == 1 # something changed - need to save\n if db_tutor.save\n logger.debug \"db_tutor saved changes successfully\"\n t[7] = t[7] + \"updated\" + updatetext \n else\n logger.debug \"db_tutor saving failed - \" + @db_tutor.errors\n t[7] = t[7] + \"failed to create\"\n end\n else\n t[7] = t[7] + \"no changes\"\n end\n else\n # This tutor is not in the database - so need to add it.\n @db_tutor = Tutor.new(\n pname: pname,\n subjects: t[2],\n phone: t[3],\n email: t[4],\n sname: t[5],\n comment: t[6],\n status: thisstatus,\n firstlesson: thisfirstlesson,\n firstaid: thisfirstaid\n )\n #if pname =~ /^zz/ # the way they show inactive tutors\n #if t[1] =~ /^zz/ # the way they show inactive tutors\n # @db_tutor.status = \"inactive\"\n #end\n logger.debug \"new - db_tutor: \" + @db_tutor.inspect\n if @db_tutor.save\n logger.debug \"db_tutor saved successfully\"\n t[7] = t[7] + \"created\" \n else\n logger.debug \"db_tutor saving failed - \" + @db_tutor.errors.inspect\n t[7] = t[7] + \"failed to create\"\n end\n end\n #exit\n if loopcount > 5\n #break\n end\n loopcount += 1\n end\n #exit\n end",
"def get_my_spreadsheets()\n spreadsheet_feed_response = get_feed(SPREADSHEET_FEED)\n create_datastructure_from_xml(spreadsheet_feed_response.body)\n end",
"def worksheet\n @session ||= GoogleDrive::Session.from_service_account_key(\"client_secret.json\")\n @spreadsheet ||= @session.spreadsheet_by_title(\"Mentormonth\")\n @worksheet ||= @spreadsheet.worksheets.first\nend",
"def readSheet(service)\r\n print \"Retrieving FC members from spreadsheet... \"\r\n # Retrieve Current FC members data from spreadsheet\r\n spreadsheet_id = \"1i09Ey3KFzvJENkToV1o5bSh89AML85fW6cz0o0IMgI0\"\r\n range = \"Members (Condensed)!A2:I\"\r\n response = service.get_spreadsheet_values spreadsheet_id, range\r\n\r\n sheetMembers = Hash.new\r\n response.values.each do |row|\r\n data = OpenStruct.new\r\n data.Name = row[0]\r\n data.Rank = row[2]\r\n\r\n # Dates should be in format of MM/DD/YYYY. Empty entries will be flagged.\r\n data.Date = row[5]\r\n if data.Date == \"\"\r\n data.Date = row[4]\r\n end\r\n if data.Date != \"\"\r\n data.Date = data.Date.split(\"/\")\r\n data.Date = DateTime.parse(\"#{data.Date[2]}-#{data.Date[0]}-#{data.Date[1]}\")\r\n end\r\n\r\n data.ID = row[8].to_i\r\n sheetMembers[data.ID] = data\r\n end\r\n puts \"Finished.\"\r\n\r\n return sheetMembers\r\nend",
"def index\n @spreadsheets = Spreadsheet.all\n end",
"def fetch(url)\n response = RestClient.get(url)\n data = JSON.parse(response)\n @google_results = data[\"results\"].first(15).map do |result|\n {\n name: result[\"name\"],\n address: result[\"formatted_address\"],\n coordinates: {\n latitude: result[\"geometry\"][\"location\"][\"lat\"],\n longitude: result[\"geometry\"][\"location\"][\"lng\"]\n },\n opening_hours: result[\"opening_hours\"],\n type: result[\"types\"].first,\n rating: result[\"rating\"]\n }\n end\n @google_results\n end",
"def stock_in_google_spreadsheet\n\n # On appelle l'URL comprenant les informations et on y stocke les URL trouvées dans notre hash\n hash = get_all_the_urls_of_val_doise_townhalls('http://www.annuaire-des-mairies.com/val-d-oise.html')\n\n # On se sert d'each_with_index pour récupérer un index incrementé\n # et faire passer chaque clef et valeur associée dans le spreadsheet\n # en faisant démarrer les deux depuis la ligne 2\n hash.each_with_index do |(key, value), index |\n $ws[index+2, 1] = key\n $ws[index+2, 2] = value\n end\n $ws.save\nend",
"def process_data()\n \tSpreadsheet.client_encoding='UTF-8'\n\tbook=Spreadsheet::Workbook.new\n\tsheet = book.create_worksheet\n\tsheet.row(0).push 'Link Text','Link Url','Description' #For including headers to the spreadsheet.\n\n\tmain_content=Array.new\n\ts=''\n\ts1=''\n\tvalue=0\n\trow_count=1\n\[email protected]_i\n\twhile iterate <= @range2.to_i\n \t\tif iterate==1\n \t\t\turl='http://www.google.co.in/search?q='+@query_string.to_s\n \t\t\tlink_count=11\n \t\telsif iterate>1\n \t\t\tvalue=(iterate-1)*10\n \t\t\tlink_count=10\n \t\t\turl='http://www.google.co.in/search?q='+@query_string.to_s+'&start='+value.to_s\n \t\tend\n \t\tdoc = Pismo::Document.new(url)\n \t\tcontent=doc.body.to_s\n \t\tmain_content=content.split('*',11)\n \t\ttmp=1\n \t\twhile tmp <= link_count\n \t\t\ts=main_content[tmp]\n \t\t\ts1=s.lines.map(&:chomp) #s1=s.split(/[\\n]+/)\n \t\t\t#print \"Link #{j} : \" + s1[1].to_s + \"\\nUrl #{j} : \" + s1[2].to_s + \"\\nDesc #{j} : \" + s1[3].to_s + \"\\n\"\n \t\t\tsheet.row(row_count).push s1[1].to_s,s1[2].to_s,s1[3].to_s\n \t\t\tbook.write('/home/chandrasekar/training-ruby/shekar/18_September/website_link.xls')\n \t\t\trow_count+=1\n \t\t\ttmp+=1\n \t\tend\n \t\titerate+=1\n\tend\n end",
"def get_listfeed(spreadsheet_key)\n listfeed_uri = \"http://spreadsheets.google.com/feeds/list/#{spreadsheet_key}/od6/private/full\"\n listfeed_response = get_feed(listfeed_uri) \n create_datastructure_from_xml(listfeed_response.body)\n \n end",
"def site_url\n \"https://spreadsheets.google.com/feeds\"\n end",
"def site_url\n \"https://spreadsheets.google.com/feeds\"\n end",
"def loadschedule\n logger.debug \"in loadschedule\"\n # log levels are: :debug, :info, :warn, :error, :fatal, and :unknown, corresponding to the log level numbers from 0 up to 5\n #logger.fatal \"1.log level\" + Rails.logger.level.inspect\n #service = googleauthorisation(request)\n returned_authorisation = googleauthorisation(request)\n if returned_authorisation[\"authorizationurl\"]\n redirect_to returned_authorisation[\"authorizationurl\"] and return\n end\n service = returned_authorisation[\"service\"]\n #spreadsheet_id = '1CbtBqeHyYb9jRmROCgItS2eEaYSwzOMpQZdUWLMvjng'\n #sheet_name = 'WEEK 1'\n spreadsheet_id = current_user[:ssurl].match(/spreadsheets\\/d\\/(.*?)\\//)[1]\n sheet_name = current_user[:sstab]\n colsPerSite = 7\n # first get sites from the first row\n range = \"#{sheet_name}!A3:AP3\"\n holdRailsLoggerLevel = Rails.logger.level\n Rails.logger.level = 1 \n response = service.get_spreadsheet_values(spreadsheet_id, range)\n Rails.logger.level = holdRailsLoggerLevel \n # extract the key for this week e.g. T3W1\n myrow = response.values[0]\n week = myrow[0] # this key is used over and over\n # pick up the sites\n sites = Hash.new() # array holding all sites\n # index = site name\n # col_start = first column for site\n myrow.map.with_index do |v, i|\n sites[v[/\\w+/]] = {\"col_start\" => i-1} if v != \"\" && v != week\n end\n\n #this function converts spreadsheet indices to column name\n # examples: e[0] => A; e[30] => AE \n e=->n{a=?A;n.times{a.next!};a} \n \n #---------------------------------------------\n # We now need to work through the sites by day\n # and tutorial slots\n # We will load a spreadsheet site at a time\n #sites # array holding all sites\n # index = site name\n # col_start = first column for site\n #days # array of rows numbers starting the day\n #slottimes # array of row number starting each slot\n # index = row number, values = ssdate\n # and datetime = datetime of the slot\n # @schedule array holds all the info required for updating \n # the database and displaying the results\n @schedule = Array.new()\n #These arrays and hashes are used within the sites loop\n #They get cloned and cleared during iterations\n onCall = Array.new()\n onSetup = Array.new()\n requiredSlot = Hash.new()\n thisLesson = Hash.new()\n flagProcessingLessons = false # need to detect date to start\n # @allColours is used in the view\n # It is used to show all colors used in the google schedule\n # Analysis tool.\n @allColours = Hash.new()\n # work through our sites, reading spreadsheet for each\n # and extract the slots, lessons, tutors and students\n # We also get the lesson notes.\n # At the beginning of each day, we get the on call and\n # setup info\n sites.each do |si, sv| # site name, {col_start}\n mystartcol = e[sv[\"col_start\"]]\n myendcol = e[sv[\"col_start\"] + colsPerSite - 1]\n #myendcoldates = e[sv[\"col_start\"] + 1] \n # ****************** temp seeting during development\n # restrict output for testing and development\n #range = \"#{sheet_name}!#{mystartcol}3:#{myendcol}60\"\n #rangedates = \"#{sheet_name}!#{mystartcol}3:#{mystartcol}60\"\n # becomes for production\n range = \"#{sheet_name}!#{mystartcol}3:#{myendcol}\"\n rangedates = \"#{sheet_name}!#{mystartcol}3:#{mystartcol}\"\n Rails.logger.level = 1 \n response = service.get_spreadsheet(\n spreadsheet_id,\n ranges: range,\n fields: \"sheets(data.rowData.values\" + \n \"(formattedValue,effectiveFormat.backgroundColor))\"\n )\n \n responsedates = service.get_spreadsheet_values(\n spreadsheet_id,\n rangedates,\n {value_render_option: 'UNFORMATTED_VALUE',\n date_time_render_option: 'SERIAL_NUMBER'\n }\n )\n \n Rails.logger.level = holdRailsLoggerLevel\n # Now scan each row read from the spreadsheet in turn\n logger.debug \"processing data from spreadsheet by rows.\"\n response.sheets[0].data[0].row_data.map.with_index do |r, ri|\n # r = value[] - contains info for ss cell - content & colour,\n # ri = row index\n #\n # FOR ANALYSIS ONLY - not for loading database\n # To analyse all the colours used in the spreadsheet,\n # we store all background colours from relevant cells.\n # Show them at the end to see if some are not what they\n # should be - manual inspection.\n # use: cell_background_color = getformat.call(column_index)\n storecolours = lambda{|j| \n cf = nil\n if r.values[j]\n if r.values[j].effective_format\n cf = r.values[j].effective_format.background_color\n end\n end\n # store all colours and keep count of how often\n # also, keep location of first occurance\n if cf != nil\n #col = [cf.red,cf.green,cf.blue]\n col = colourToArray(cf)\n @allColours[col] ? \n @allColours[col][2] += 1 :\n @allColours[col] = [e[j + sv[\"col_start\"]],3+ri,1]\n end\n }\n # Now start processing the row content\n c0 = getvalue(r.values[0])\n if c0 == week # e.g. T3W1 - first row of the day \n storecolours.call(1)\n next\n end\n if c0 == \"ON CALL\" # we are on \"ON CALL\" row\n storecolours.call(1)\n for i in 1..7 do # keep everything on this row\n cv = getvalue(r.values[i])\n onCall.push(cv) if cv != \"\"\n end\n next\n end\n if c0 == \"SETUP\" # we are on \"ON CALL\" row e.g. T3W1\n storecolours.call(1)\n for i in 1..7 do # keep everything on row\n cv = getvalue(r.values[i])\n onSetup.push(cv) if cv != \"\"\n end\n next\n end\n # look for date row - first row for slot e.g 7/18/2016\n if c0.match(/(\\d+)\\/(\\d+)\\/(\\d+)/)\n cf1 = getformat(r.values[1])\n # If this cell with day/time content is black,\n # then this slot is not used.\n # just skip - any onCall or onSetup already found will be\n # put into the first valid slot.\n if colourToStatus(cf1)['colour'].downcase != 'white'\n flagProcessingLessons = false\n next\n else\n flagProcessingLessons = true\n end\n # we are now working with a valid slot\n unless requiredSlot.empty?\n @schedule.push(requiredSlot.clone)\n requiredSlot.clear\n end\n #now get the matching date from the responsedates array\n mydateserialnumber = responsedates.values[ri][0]\n \n begin\n mydate = Date.new(1899, 12, 30) + mydateserialnumber \n c1 = getvalue(r.values[1])\n n = c1.match(/(\\w+)\\s+(\\d+)\\:*(\\d{2})/im) # MONDAY 330 xxxxxxx\n # Note: add 12 to hours as these are afternoon sessions.\n # Check for ligimate dates\n myhour = n[2].to_i\n mymin = n[3].to_i\n #dt1 = DateTime.new(mydate.year, mydate.month, mydate.day,\n # 1, 1)\n #dt2 = DateTime.new(2000, 1, 1,\n # myhour + 12, mymin)\n dt = DateTime.new(mydate.year, mydate.month, mydate.day,\n myhour + 12, mymin)\n rescue \n\n errorSite = si\n #errorRow = ri + 3\n myerror = \"Load Schedule - data processing error: \" +\n \" found in site: \" + errorSite +\n \" c0: \" + c0.inspect +\n \" c1: \" + c1.inspect +\n \" mydateserialnumber: \" + mydateserialnumber.inspect +\n \" error message: \" + $!.inspect\n logger.debug myerror\n flash[:notice] = myerror\n render action: :load\n return\n end\n requiredSlot[\"timeslot\"] = dt # adjust from am to pm.\n requiredSlot[\"location\"] = si\n logger.debug \"working with \" + si.inspect + ' ' + dt.inspect\n # Now that we have a slot created, check if this has been\n # the first one for the day. i.e. there are on call and setup events\n # If so, we make them into a lesson and add them to the slot.\n # Delete them when done.\n if(!onCall.empty? || !onSetup.empty?)\n requiredSlot[\"onCall\"] = onCall.clone unless onCall.empty?\n requiredSlot[\"onSetup\"] = onSetup.clone unless onSetup.empty?\n onCall.clear\n onSetup.clear\n end\n next\n end\n # any other rows are now standard lesson rows\n # If no date row yet detected or\n # this is not a valid slot (black background on date row)\n # we ignore\n next if flagProcessingLessons == false\n # Now do normal lession processing.\n c1 = getvalue(r.values[1]) # tutor\n c2 = getvalue(r.values[2]) # student 1\n c4 = getvalue(r.values[4]) # student 2\n c6 = getvalue(r.values[6]) # lesson comment\n cf1 = getformat(r.values[1])\n cf2 = getformat(r.values[2])\n cf4 = getformat(r.values[4])\n # store colours for cells of interest\n [1,2,3,4,5,6].each do |j|\n storecolours.call(j)\n end\n thisLesson[\"tutor\"] = [c1,cf1] if c1 != \"\"\n if c2 != \"\" || c4 != \"\" #student/s present\n thisLesson[\"students\"] = Array.new()\n thisLesson[\"students\"].push([c2,cf2]) if c2 != \"\"\n thisLesson[\"students\"].push([c4,cf4]) if c4 != \"\"\n end\n thisLesson[\"comment\"] = c6 if c6 != \"\"\n requiredSlot[\"lessons\"] = Array.new() unless requiredSlot[\"lessons\"]\n requiredSlot[\"lessons\"].push(thisLesson.clone) unless thisLesson.empty?\n thisLesson.clear\n end\n # at end of last loop - need to keep if valid slot\n unless requiredSlot.empty?\n @schedule.push(requiredSlot.clone)\n requiredSlot.clear\n end\n #break # during dev only - only doing one site\n end\n # cache the tutors and students for laters processing by the utilities.\n @tutors = Tutor.all\n @students = Student.all\n \n # Now start the database updates using the info in @schedule\n # Note:\n # my... = the info extracted from @schedule\n # this... = the database record \n \n # slot info\n @schedule.each do |r|\n # These are initialise on a row by row basis\n r[\"slot_updates\"] = \"\"\n r[\"onCallupdates\"] = \"\"\n r[\"onSetupupdates\"] = \"\"\n r[\"commentupdates\"] = \"\"\n # Process the slot\n mylocation = r[\"location\"]\n mytimeslot = r[\"timeslot\"] \n thisslot = Slot.where(location: mylocation, timeslot: mytimeslot).first\n unless thisslot # none exist\n thisslot = Slot.new(timeslot: mytimeslot, location: mylocation)\n if thisslot.save\n r[\"slot_updates\"] = \"slot created\"\n else\n r[\"slot_updates\"] = \"slot creation failed\"\n end\n else\n r[\"slot_updates\"] = \"slot exists - no change\"\n end\n # Now load lessons (create or update)\n # first up is the \"On Call\"\n # these will have a lesson status of \"oncall\"\n # [\"DAVID O\\n| E12 M12 S10 |\"]\n if(mylesson = r[\"onCall\"])\n logger.debug \"mylesson - r onCall: \" + mylesson.inspect\n mytutornamecontent = findTutorNameComment(mylesson, @tutors)\n # check if there was a tutor found.\n # If not, then we add any comments to the lesson comments.\n lessoncomment = \"\"\n if mytutornamecontent[0] == nil\n lessoncomment = mylesson[0]\n elsif mytutornamecontent[0][\"name\"] == \"\" && \n mytutornamecontent[0][\"comment\"].strip != \"\"\n lessoncomment = mytutornamecontent[0][\"comment\"]\n end\n if lessoncomment != \"\" ||\n (\n mytutornamecontent[0] != nil &&\n mytutornamecontent[0][\"name\"] != \"\"\n )\n # something to put in lesson so ensure it exists - create if necessary\n thislesson = Lesson.where(slot_id: thisslot.id, status: \"onCall\").first\n unless thislesson\n thislesson = Lesson.new(slot_id: thisslot.id,\n status: \"onCall\",\n comments: lessoncomment)\n if thislesson.save\n r[\"onCallupdates\"] += \"|lesson created #{thislesson.id}|\"\n else\n r[\"onCallupdates\"] += \"|lesson creation failed|\"\n end\n end\n end\n # Now load in the tutors - if any\n mytutornamecontent.each do |te|\n logger.debug \"mytutornameconent - te: \" + te.inspect\n # need tutor record - know it exists if found here\n if te['name']\n # create a tutrole record if not already there\n thistutor = Tutor.where(pname: te['name']).first # know it exists\n mytutorcomment = te['comment']\n # determine if this tutrole already exists\n thistutrole = Tutrole.where(lesson_id: thislesson.id,\n tutor_id: thistutor.id\n ).first\n if thistutrole # already there\n if thistutrole.comment == mytutorcomment &&\n thistutrole.status == \"\" &&\n thistutrole.kind == \"onCall\"\n r[\"onCallupdates\"] += \"|no change|\"\n else\n if thistutrole.comment != mytutorcomment\n thistutrole.update(comment: mytutorcomment)\n end\n if thistutrole.status != \"\"\n thistutrole.update(status: \"\")\n end\n if thistutrole.kind != \"onSetup\"\n thistutrole.update(kind: \"onSetup\")\n end\n if thistutrole.save\n r[\"onCallupdates\"] += \"|updated tutrole|\"\n else\n r[\"onCallupdates\"] += \"|update failed|\"\n end\n end\n else # need to be created\n thistutrole = Tutrole.new(lesson_id: thislesson.id,\n tutor_id: thistutor.id,\n comment: mytutorcomment,\n status: \"\",\n kind: \"onCall\")\n if thistutrole.save\n r[\"onCallupdates\"] += \"|tutrole created #{thistutrole.id}|\"\n else\n r[\"onCallupdates\"] += \"|tutrole creation failed|\"\n end\n end\n end\n end\n end\n # second up is the \"Setup\"\n # these will have a lesson status of \"onsetup\"\n # [\"DAVID O\\n| E12 M12 S10 |\"]\n if(mylesson = r[\"onSetup\"])\n mytutornamecontent = findTutorNameComment(mylesson, @tutors)\n # check if there was a tutor found.\n # If not, then we add any comments to the lesson comments.\n lessoncomment = \"\"\n if mytutornamecontent[0][\"name\"] == \"\" && \n mytutornamecontent[0][\"comment\"].strip != \"\"\n lessoncomment = mytutornamecontent[0][\"comment\"]\n end\n if mytutornamecontent[0][\"name\"] != \"\" || \n lessoncomment != \"\"\n # something to put in lesson so ensure it exists - create if necessary\n thislesson = Lesson.where(slot_id: thisslot.id, status: \"onSetup\").first\n unless thislesson\n thislesson = Lesson.new(slot_id: thisslot.id,\n status: \"onSetup\",\n comments: lessoncomment)\n if thislesson.save\n r[\"onSetupupdates\"] += \"|created lession #{thislesson.id}|\"\n else\n r[\"onSetupupdates\"] += \"|create lession failed|\"\n end\n end\n end\n # Now load in the tutors - if any\n mytutornamecontent.each do |te|\n # need tutor record - know it exists if found here\n if te['name']\n # create a tutrole record if not already there\n thistutor = Tutor.where(pname: te['name']).first # know it exists\n mytutorcomment = te['comment']\n # determine if this tutrole already exists\n thistutrole = Tutrole.where(lesson_id: thislesson.id,\n tutor_id: thistutor.id\n ).first\n if thistutrole # already there\n if thistutrole.comment == mytutorcomment &&\n thistutrole.status == \"\" &&\n thistutrole.kind == \"onSetup\"\n r[\"onSetupupdates\"] += \"|no change #{thistutrole.id}|\"\n else\n if thistutrole.comment != mytutorcomment\n thistutrole.update(comment: mytutorcomment)\n end\n if thistutrole.status != \"\"\n thistutrole.update(status: \"\")\n end\n if thistutrole.kind != \"onSetup\"\n thistutrole.update(kind: \"onSetup\")\n end\n if thistutrole.save\n r[\"onSetupupdates\"] += \"|updated tutrole #{thistutrole.id}|\"\n else\n r[\"onSetupupdates\"] += \"|update failed|\"\n end\n end\n else # need to be created\n thistutrole = Tutrole.new(lesson_id: thislesson.id,\n tutor_id: thistutor.id,\n comment: mytutorcomment,\n status: \"\",\n kind: \"onSetup\")\n if thistutrole.save\n r[\"onSetupupdates\"] += \"|tutrole created #{thistutrole.id}|\"\n else\n r[\"onSetupupdates\"] += \"|tutrole creation failed|\"\n end\n end # if thistutrole\n end\n end\n end # end onSetup \n # third is standard lessons\n # these will have a lesson status of that depends on colour\n # which gets mapped into a status\n # [\"DAVID O\\n| E12 M12 S10 |\"]\n # mylessons = \n #[{tutor =>[name, colour], \n # students=>[[name, colour],[name, colour]],\n # comment => \"\"\n # }, ...{}... ]\n #\n #\n #{\"tutor\"=>[\"ALLYSON B\\n| M12 S12 E10 |\",\n # #<Google::Apis::SheetsV4::Color:0x00000003ef3c80 \n # @blue=0.95686275, @green=0.7607843, @red=0.6431373>],\n # \"students\"=>[\n # [\"Mia Askew 4\", \n # #<Google::Apis::SheetsV4::Color:0x00000003edeab0 \n # @blue=0.972549, @green=0.85490197, @red=0.7882353>],\n # [\"Emily Lomas 6\", \n # #<Google::Apis::SheetsV4::Color:0x00000003eb06d8 \n # @blue=0.827451, @green=0.91764706, @red=0.8509804>]],\n # \"comment\"=>\"Emilija away\"\n #}\n #\n\n # first we need to see if there are already lessons\n # for this tutor in this slot (except Setup & oncall)\n # Check procedure\n # 1. Get all lessons from database in this slot\n # 2. From the database for these lessons, we cache\n # a) all the tutroles (tutors) \n # b) all the roles (students)\n # Tutroles query excludes status \"onSetup\" & \"onCall\"\n # Note: tutroles hold: sessin_id, tutor_id, status, comment\n # 3. Loop through each lesson from the spreadsheet and check\n # Note: if tutor in ss, but not found in database, then add\n # as a comment; same for students\n # a) if tutor or student in the ss for this lesson has either\n # a tutor or student in the database, then that is the \n # lesson to use, ELSE we create a new lesson.\n # This is then the lesson we use for the following steps\n # b) for my tutor in ss, is there a tutrole with this tutor\n # If so, update the tutrole with tutor comments (if changed)\n # If not,\n # i) create a lesson in this slot\n # ii) create a tutrole record linking lesson and tutor\n # Note 1: This lesson is then used for the students.\n # If a student is found in a different lesson in this\n # slot, then they are moved into this lesson.\n # Note 2: there could be tutrole records in db that are not in ss.\n # ---------------------------------------------------------------------\n # Step 1: get all the lessons in this slot\n thislessons = Lesson.where(slot_id: thisslot.id)\n # Step 2: get all the tutrole records for this slot\n # and all the role records for this slot\n alltutroles = Tutrole.where(lesson_id: thislessons.ids).\n where.not(kind: ['onSetup', 'onCall'])\n allroles = Role.where(lesson_id: thislessons.ids)\n # Step 3:\n if(mylessons = r[\"lessons\"]) # this is all the standard\n # ss lessons in this slot\n mylessons.each do |mysess| # treat lesson by lesson from ss\n # process each ss lesson row\n thislesson = nil # ensure all reset\n mylessoncomment = \"\"\n mylessonstatus = \"standard\" # default unless over-ridden\n #\n # Process Tutors, then students, then comments\n # A sesson can have only comments without tutors & students\n #\n # Step 3a - check if tutors present\n # if so, this is the lesson to hang onto.\n # Will check later if the students are in the same lesson.\n flagtutorpresent = flagstudentpresent = FALSE\n #\n # Process tutor\n #\n mytutor = mysess[\"tutor\"] # only process if tutor exists\n # mytutor[0] is ss name string,\n # mytutor[1] is colour\n # mytutor[2] will record the view feedback\n mytutorcomment = \"\" # provide full version in comment\n tutroleupdates = \"\" # feedback for display in view\n if mytutor \n mytutorcomment = mytutor[0]\n mytutornamecontent = findTutorNameComment(mytutor[0], @tutors) \n mytutorstatus = colourToStatus(mytutor[1])[\"tutor-status\"]\n mytutorkind = colourToStatus(mytutor[1])[\"tutor-kind\"]\n if mytutorkind == 'BFL'\n mylessonstatus = 'on_BFL'\n end\n if mytutornamecontent.empty? || # no database names found for this tutor\n mytutornamecontent[0]['name'] == \"\"\n # put ss name cell content into lesson comment\n mylessoncomment += mytutor[0] \n else\n flagtutorpresent = TRUE\n # We have this tutor\n # Find all the tutroles this tutor - this will link\n # to all the lessons this tutor is in.\n # thisslot is the slot we are current populating\n thistutor = Tutor.where(pname: mytutornamecontent[0][\"name\"]).first\n thistutroles = alltutroles.where(tutor_id: thistutor.id)\n if thistutroles.empty? # none there, so create one\n # Step 4ai: Create a new lesson containing\n thislesson = Lesson.new(slot_id: thisslot.id,\n status: mylessonstatus)\n if thislesson.save\n tutroleupdates += \"|lesson created #{thislesson.id}|\"\n else\n tutroleupdates += \"|lesson creation failed\"\n end\n thistutrole = Tutrole.new(lesson_id: thislesson.id,\n tutor_id: thistutor.id,\n comment: mytutorcomment,\n status: mytutorstatus,\n kind: mytutorkind)\n if thistutrole.save\n tutroleupdates += \"|tutrole created #{thistutrole.id}|\"\n else\n tutroleupdates += \"|tutrole creation failed|\"\n end\n else # already exist\n thistutroles.each do |thistutrole1|\n # get the lesson they are in\n thislesson = Lesson.find(thistutrole1.lesson_id)\n if thislesson[:status] != mylessonstatus\n thislesson[:status] = mylessonstatus\n if thislesson.save\n tutroleupdates += \"|updated lesson status #{thislesson.id}|\"\n else \n tutroleupdates += \"|lesson status update failed|\"\n end\n end\n if thistutrole1.comment == mytutorcomment &&\n thistutrole1.status == mytutorstatus &&\n thistutrole1.kind == mytutorkind\n tutroleupdates += \"|no change #{thistutrole1.id}|\"\n else\n if thistutrole1.comment != mytutorcomment\n #thistutrole1.update(comment: mytutorcomment)\n thistutrole1.comment = mytutorcomment end\n if thistutrole1.status != mytutorstatus\n #thistutrole1.update(status: mytutorstatus)\n thistutrole1.status = mytutorstatus\n end\n if thistutrole1.kind != mytutorkind\n #thistutrole1.update(status: mytutorkind)\n thistutrole1.status = mytutorkind\n end\n if thistutrole1.save\n tutroleupdates += \"|updated tutrole #{thistutrole1.id}|\"\n else\n tutroleupdates += \"|update failed|\"\n end\n end\n end # thistutroles.each \n end # if thistutroles.emepty?\n mytutor[2] = tutroleupdates\n end\n end\n #\n # Process students\n #\n mystudents = mysess[\"students\"]\n unless mystudents == nil || mystudents.empty? # there are students in ss\n mystudents.each do |mystudent| # precess each student\n roleupdates = \"\" # records changes to display in view\n mystudentcomment = \"\"\n mystudentstatus = colourToStatus(mystudent[1])[\"student-status\"]\n mystudentkind = colourToStatus(mystudent[1])[\"student-kind\"]\n mystudentnamecontent = findStudentNameComment(mystudent[0], @students) \n if mystudentnamecontent.empty? || # no database names found for this student\n mystudentnamecontent[0]['name'] == \"\"\n # put ss name string into lesson comment\n mylessoncomment += mystudent[0] \n else\n flagstudentpresent = TRUE # we have students\n thisstudent = Student.where(pname: mystudentnamecontent[0][\"name\"]).first\n #logger.debug \"thisstudent: \" + thisstudent.inspect\n thisroles = allroles.where(student_id: thisstudent.id)\n # CHECK if there is already a lesson from the tutor processing \n # Step 4ai: Create a new lesson ONLY if necessary\n unless thislesson\n thislesson = Lesson.new(slot_id: thisslot.id,\n status: mylessonstatus)\n if thislesson.save\n roleupdates += \"|created lesson #{thislesson.id}|\"\n else\n roleupdates += \"|lesson creation failed|\"\n end\n end\n if thisroles.empty? # none there, so create one\n thisrole = Role.new(lesson_id: thislesson.id,\n student_id: thisstudent.id,\n comment: mystudentcomment,\n status: mystudentstatus,\n kind: mystudentkind)\n if thisrole.save\n roleupdates += \"|role created #{thisrole.id}|\"\n else\n roleupdates += \"|role creation failed|\"\n end\n else # already exist\n thisroles.each do |thisrole1|\n # An additional check for students\n # If a student is allocated to a different tutor\n # in the db, then we will move them to this tutor\n # as per the spreadsheet.\n # Note that a student cannot be in a lesson twice.\n if thislesson.id != thisrole1.lesson_id\n # move this student - update the role\n # student can only be in one lesson for a given slot.\n if thisrole1.update(lesson_id: thislesson.id)\n roleupdates += \"|role move updated #{thisrole1.id}|\"\n else\n roleupdates += \"|role move failed|\"\n end\n end\n if thisrole1.comment == mystudentcomment &&\n thisrole1.status == mystudentstatus &&\n thisrole1.kind == mystudentkind\n roleupdates += \"|no change #{thisrole1.id}|\"\n else\n if thisrole1.comment != mystudentcomment\n #thisrole1.update(comment: mystudentcomment)\n thisrole1.comment = mystudentcomment\n end\n if thisrole1.status != mystudentstatus\n #thisrole1.update(status: mystudentstatus)\n thisrole1.status = mystudentstatus\n end\n if thisrole1.kind != mystudentkind\n #thisrole1.update(status: mystudentkind)\n thisrole1.kind = mystudentkind\n end\n if thisrole1.save\n #r[\"roleupdates\"] += \"|role updated #{thisrole1.id}|\"\n roleupdates += \"|role updated #{thisrole1.id}|\"\n else\n #r[\"roleupdates\"] += \"|role update failed #{thisrole1.id}|\"\n roleupdates += \"|role update failed #{thisrole1.id}|\"\n end\n end\n end # thisroles.each \n end # if thisroles.emepty?\n end\n mystudent[2]= roleupdates\n end\n end\n #\n # Process comments\n #\n if mysess[\"comment\"]\n mycomments = mysess[\"comment\"].strip\n mylessoncomment += mycomments if mycomments != \"\"\n end\n # process comments - my have been generated elsewhere (failed tutor\n # and student finds, etc. so still need to be stored away \n if mylessoncomment != \"\" # some lesson comments exist\n # if no lesson exists to place the comments\n # then we need to build one.\n unless thislesson\n # let's see if there is a lesson with this comment\n # looking through the lessons for this slot that do\n # not have a tutor or student\n # Need the sesson that have no tutor or student - already done\n allcommentonlylessons = thislessons -\n thislessons.joins(:tutors, :students).distinct\n # now to see if this comment is in one of these\n allcommentonlylessons.each do |thiscommentlesson|\n if thiscommentlesson.comments == mylessoncomment\n thislesson = thiscommentlesson\n break\n end\n end\n end\n # see if we now have identified a lesson for this comment\n # create one if necessary\n #r[\"commentupdates\"] = \"\"\n unless thislesson\n thislesson = Lesson.new(slot_id: thisslot.id,\n status: 'standard')\n if thislesson.save\n r[\"commentupdates\"] += \"|created session for comments #{thislesson.id}|\"\n else\n r[\"commentupdates\"] += \"|created session for comments failed|\"\n end\n end\n if mylessoncomment == thislesson.comments\n r[\"commentupdates\"] += \"|no change #{thislesson.id}|\"\n else\n thislesson.update(comments: mylessoncomment)\n if thislesson.save\n r[\"commentupdates\"] += \"|updated lesson comment #{thislesson.id}|\"\n else\n r[\"commentupdates\"] += \"|lesson comment update failed #{thislesson.id}|\"\n end \n end\n end\n end\n end\n end\n end",
"def index\n @issue_exists_in_google_sheets = IssueExistsInGoogleSheet.all\n end",
"def download_printer_data\n \tSpreadsheet.client_encoding = 'UTF-8'\n\t\tbook = Spreadsheet::Workbook.new\n \t \tsheet1 = book.create_worksheet \n \t \tsheet1.name = \"Printer Data #{PrinterSelection.last.from_time} - #{PrinterSelection.last.to_time}\"\n \t \t\n \t \t#formatting\n \t \tdate_time = Spreadsheet::Format.new :number_format => 'DD/MM/YYYY hh:mm:ss'\n \t \tsheet1.column(4).default_format = date_time\n \t \tsheet1.column(5).default_format = date_time\n \t \t\n \t \tbold = Spreadsheet::Format.new :weight => :bold\n \t \tsheet1.row(0).default_format = bold\n \t \t \t \t\t\n \t \t#name\n \t \tsheet1.column(0).width = 20\n \t \t#project\n \t \tsheet1.column(1).width = 20\n \t \t#printer\n \t \tsheet1.column(2).width = 20\n \t \t#volume\n \t \tsheet1.column(3).width = 15\n \t \t#date\n \t \tsheet1.column(4).width = 20\n \t \t#time taken\n \t \tsheet1.column(5).width = 30\n \t \t#notes\n \t \tsheet1.column(6).width = 50\n \t \t\n \t \t#content\n \t \tsheet1.row(0).push 'Name', 'Project', 'Printer', 'Volume','Date', 'Time Taken (m)', 'Email', 'Notes'\n \t \tall_data = PrinterDatum.all\n sorted_all_data = all_data.sort{ |a,b| a.to_time <=> b.to_time}\n\t\tselection = PrinterSelection.last \t \t\t\n \t \trownum = 1\n sorted_all_data.each do |data| \n \t \t if data.from_time >= selection.from_time && data.to_time <= selection.to_time\t \t\t\t\t\n \t \t row = sheet1.row(rownum)\n\n \n from_time = data.from_time\n to_time = data.to_time\n distance_in_hours = (((to_time - from_time).abs) / 3600).round\n distance_in_minutes = ((((to_time - from_time).abs) % 3600) / 60).round\n\n difference_in_words = ''\n\n difference_in_words << \"#{distance_in_hours} #{distance_in_hours > 1 ? 'hours' : 'hour' } and \" if distance_in_hours > 0\n difference_in_words << \"#{distance_in_minutes} #{distance_in_minutes == 1 ? 'minute' : 'minutes' }\"\n\n email = FabricationUser.find_by(name: data.name).email\n\n \t \t\t\trow.push \"#{data.name}\"\n \t \t\t\trow.push \"#{data.project}\"\n \t \t\t\trow.push \"#{data.printer}\"\n \t \t\t\trow.push \"#{data.volume}\"\n \t \t\t\trow.push \"#{data.from_time.strftime \"%Y-%m-%d\"}\"\n row.push \"#{difference_in_words}\"\n row.push \"#{email}\"\n \t \t\t\trow.push \"#{data.notes}\"\n rownum += 1\n \t \t\tend\n \t \tend\n \t \t\n #name file\n \t\t@outfile = \"Printer_Data_#{selection.from_time.strftime \"%Y-%m-%d\"}_to_#{selection.to_time.strftime \"%Y-%m-%d\"}.xls\"\n \t\tPrinterSelection.delete_all\n \t\t\n \trequire 'stringio'\n \tdata = StringIO.new ''\n #write to book\n \tbook.write data\n #initiate download\n \tsend_data data.string, :type=>\"application/excel\", :disposition=>'attachment', :filename => @outfile\n end",
"def index\n #@spreadsheet = Spreadsheet.new()\n #@spreadsheets = Spreadsheet.all\n end",
"def fetch_user_google_calendars\n user_gcalendars = []\n if current_user.connected_to_google? && current_user.has_google_credentials?\n begin\n gcw = GoogleCalendarWrapper.new(current_user)\n gcw.import_calendars\n user_gcalendars = current_user.google_calendars\n rescue => e\n logger.error {\"#{e.message} #{e.backtrace.join(\"\\n\")}\"}\n current_user.update_attributes(connected_to_google: false)\n flash[:error] = \"We were not able to fetch data from #{current_user.name}'s Google account.\"\n end\n end\n user_gcalendars\n end",
"def get_response()\n # process excel - get the data segments - create hash with headers\n @data = {}\n\n sheet = @excel.sheet\n headers = []\n sheet.getRow(0).cellIterator.each do |h|\n headers << @excel.cell_value(h)\n @data[@excel.cell_value(h) ] = []\n end\n\n @excel.each_row do |row|\n row.cellIterator.each_with_index do |c, i|\n # N.B null row data can spill beyond the columns defined\n @data[headers[i]] << @excel.cell_value(c) if headers[i]\n end\n end\n @data\n end",
"def initialize(spreadsheet_id)\n # Initialize the API\n @service = Google::Apis::SheetsV4::SheetsService.new\n @service.client_options.application_name = APPLICATION_NAME\n @service.authorization = authorize\n\n # Prints the names and majors of students in a sample spreadsheet:\n # https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/edit\n # spreadsheet_id = \"1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms\"\n # range = \"Insert your updates here!A3:E\"\n range = \"'Published factchecks'!A:Q\"\n response = @service.get_spreadsheet_values spreadsheet_id, range\n puts \"No data found.\" if response.values.empty?\n\n @spreadsheet_id = spreadsheet_id\n @values = response.values\n end",
"def data_sheet\n attachments.for('data_sheet')\n end",
"def set_googlesheet\n @googlesheet = Googlesheet.find(params[:id])\n end",
"def google_csv_url\n \"https://docs.google.com/spreadsheets/d/#{ google_local_key }/export?format=csv#{ google_local_key }\"\n end",
"def index\n @list_spreadsheets = ListSpreadsheet.all.to_a\n end",
"def download_grades\n @course = Course.find(params[:id])\n book = Spreadsheet::Workbook.new\n sheet = book.create_worksheet :name => 'All Student Grades'\n\n fmt = Spreadsheet::Format.new :number_format => '0.0'\n sheet.column(2).default_format = fmt\n\n head = Spreadsheet::Format.new :weight => :bold, :size => 24, :horizontal_align => :center, :vertical_align => :middle\n sheet.merge_cells(0,0,2,2)\n sheet.row(0).default_format = head\n sheet.row(0).push @course.name + \" Grades\"\n\n top = Spreadsheet::Format.new :weight => :bold, :size => 18, :horizontal_align => :center\n sheet.row(3).default_format = top\n sheet.row(3).push \"First Name\", \"Last Name\"\n\n row = 4\n @course.users.each do |name|\n if not name.has_local_role? :grader, @course\n sheet.row(row).push name.first_name, name.last_name\n row += 1\n end\n end\n\n col = 2\n @course.assignments.each do |assignment|\n sheet.row(3).push assignment.name\n sheet.column(col).width = 15\n row = 4\n @course.users.each do |name|\n if not name.has_local_role? :grader, @course\n submission = assignment.submissions.select { |s| s.user == name }.first\n sheet.row(row).push submission.grade\n row += 1\n end\n end\n col += 1\n end\n\n sheet.column(0).width = 30\n sheet.column(1).width = 30\n\n blob = StringIO.new\n book.write blob\n send_data blob.string, :filename => @course.name + \"_grades.xls\", :type => \"application/xls\"\n end",
"def loadtest2\n returned_authorisation = googleauthorisation(request)\n if returned_authorisation[\"authorizationurl\"]\n redirect_to returned_authorisation[\"authorizationurl\"] and return\n end\n service = returned_authorisation[\"service\"]\n#-----------------------------------------------------------------\n# Create a new spreadsheet -works and tested\n #request_body = Google::Apis::SheetsV4::Spreadsheet.new\n #response = service.create_spreadsheet(request_body)\n #ss = response\n #spreadsheet_id = ss.spreadsheet_id\n#-----------------------------------------------------------------\n\n\n#-----------------------------------------------------------------\n# Use an existing previously created spreadsheet\n# Only need the id to make use of this.\n spreadsheet_id = '1VHNfTl0Qxok1ZgBD2Rwby-dqxihgSspA0InqS5dTXNI'\n#-----------------------------------------------------------------\n sheet_name = \"Sheet1\"\n\n# ************ update spreadsheet title ************************\n# https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/batchUpdate \n spreadsheet_title = \"Testing Updates from BIT Server\"\n request_body = Google::Apis::SheetsV4::BatchUpdateSpreadsheetRequest.new\n myussp = {\"properties\": {\"title\": spreadsheet_title}, \"fields\": \"*\" }\n request_body.requests = [{\"update_spreadsheet_properties\": myussp }]\n result = service.batch_update_spreadsheet(spreadsheet_id, request_body, {})\n\n\n\n\n# ************ delete all cells (rows) in a sheet ****************************\n# https://www.rubydoc.info/github/google/google-api-ruby-client/Google/Apis/SheetsV4/Request#delete_range-instance_method \n \tgridrange = {\n \t sheet_id: 0,\n \t start_row_index: 0,\n# \t end_row_index: 1,\n \t start_column_index: 0,\n# \t end_column_index: 2\n \t }\n requests = []\n requests.push(\n {\n delete_range:{\n range: gridrange,\n shift_dimension: \"ROWS\"\n }\n }\n )\n body = {requests: requests}\n result = service.batch_update_spreadsheet(spreadsheet_id, body, {})\n\n# ************ update values using update_spreadsheet_value ****************************\n# doco: https://www.rubydoc.info/github/google/google-api-ruby-client/Google%2FApis%2FSheetsV4%2FSheetsService%3Aupdate_spreadsheet_value \n range = \"#{sheet_name}!A1:B1\"\n request_body = Google::Apis::SheetsV4::ValueRange.new\n request_body.values = [[\"update_spreadsheet_value\",\"test data - this row will get a background colour\"]]\n request_body.major_dimension = \"ROWS\"\n result = service.update_spreadsheet_value(spreadsheet_id, range, request_body, \n {value_input_option: 'USER_ENTERED'})\n logger.debug \"update_spreadsheet_value completed\"\n\n# ************ update values using update_spreadsheet_value ****************************\n range = \"#{sheet_name}!A2:B3\"\n mydata = [\n {\n range: range,\n majorDimension: 'ROWS',\n values: [\n [\"spreadsheet_values_batchUpdate\", \"test data\"],\n [\"spreadsheet_values_batchUpdate\", \"third row\"]\n ]\n }\n ]\n request_body = Google::Apis::SheetsV4::BatchUpdateValuesRequest.new\n request_body.value_input_option = 'USER_ENTERED'\n request_body.data = mydata\n result = service.batch_update_values(spreadsheet_id, request_body, {})\n\n# ******** update background colours using batch_update_spreadsheet ********\n \tgridrange = {\n \t sheet_id: 0,\n \t start_row_index: 0,\n \t end_row_index: 1,\n \t start_column_index: 0,\n \t end_column_index: 2\n \t }\n requests = []\n requests.push(\n {\n repeat_cell: {\n \t range: gridrange,\n cell:\n {\n \t user_entered_format:\n \t {\n \t\t text_format: {bold: true},\n \t\t background_color:\n \t\t {\n \t\t\t red: 0.0,\n \t\t\t green: 1.0,\n \t\t\t blue: 0.0\n \t\t }\n \t }\n \t },\n fields: \"user_entered_format(background_color, text_format.bold)\"\n }\n }\n )\n body = {requests: requests}\n result = service.batch_update_spreadsheet(spreadsheet_id, body, {})\n\n# ******** autorezise columns using batch_update_spreadsheet ********\n# https://developers.google.com/sheets/api/samples/rowcolumn \n requests = []\n requests.push(\n {\n auto_resize_dimensions: {\n dimensions:\n {\n \t dimension: \"COLUMNS\",\n \t sheet_id: 0,\n end_index: 2,\n \t start_index: 0\n \t },\n }\n }\n )\n body = {requests: requests}\n result = service.batch_update_spreadsheet(spreadsheet_id, body, {})\n\n# ******** adjust columns width using batch_update_spreadsheet ********\n# https://developers.google.com/sheets/api/samples/rowcolumn \n requests = []\n requests.push(\n {\n update_dimension_properties: {\n range:\n {\n \t dimension: \"COLUMNS\",\n \t sheet_id: 0,\n end_index: 2,\n \t start_index: 0\n \t },\n \t properties: {\n \t pixel_size: 160\n \t },\n \t fields: \"pixelSize\"\n }\n }\n )\n body = {requests: requests}\n result = service.batch_update_spreadsheet(spreadsheet_id, body, {})\n\n end",
"def readsheet(i,j,k)\n sheetloc='C:\\Ruby23\\bin\\rubyselenium_poc\\Amazon_TestData\\TestData.xls'\ndoc = Spreadsheet.open(sheetloc)\nsheet = doc.worksheet(i) # list number, first list is 0 and so on...\nval = sheet[j,k] # read particular cell from list 0, r for row, c for column \nreturn val\nend",
"def fetch_month_sheets()\n date = Date.today\n days_in_month = date.end_of_month.day\n for day in ('1'..days_in_month.to_s).to_a\n range = day + \"!\" + ENV[\"CELL_RANGE\"]\n info_list = get_sheet_response(range)\n detect_change_send_email(info_list)\n end \nend",
"def list(params = {})\n response = get(\"spreadsheets/private/full\", params)\n p response.body\n @sheets ||= Gdocs::Objects::SpreadSheet.sheets(response.body, @access_token)\n end",
"def get_sheet_response(range)\n spreadsheet_id = get_spreadsheet_id(Time.now) #gets id of spreadsheet of current month\n $service.get_spreadsheet_values(spreadsheet_id, range).values # mock this\nend",
"def googleroster\n returned_authorisation = googleauthorisation(request)\n if returned_authorisation[\"authorizationurl\"]\n redirect_to returned_authorisation[\"authorizationurl\"] and return\n end\n service = returned_authorisation[\"service\"]\n#-----------------------------------------------------------------\n# Create a new spreadsheet -works and tested\n #request_body = Google::Apis::SheetsV4::Spreadsheet.new\n #response = service.create_spreadsheet(request_body)\n #ss = response\n #spreadsheet_id = ss.spreadsheet_id\n#-----------------------------------------------------------------\n\n#-----------------------------------------------------------------\n# Use an existing previously created spreadsheet\n# Only need the id to make use of this.\n #spreadsheet_id = '1VHNfTl0Qxok1ZgBD2Rwby-dqxihgSspA0InqS5dTXNI'\n spreadsheet_id = '1mfS0V2IRS1x18otIta1kOdfFvRMu6NltEe-edn7MZMc'\n#-----------------------------------------------------------------\n\n#-----------------------------------------------------------------\n# Use the spreadsheet configured in user profiles\n# = Roster Google Spreadsheet URL \n spreadsheet_id = current_user[:rosterssurl].match(/spreadsheets\\/d\\/(.*?)\\//)[1]\n\n # Get URL of spreadsheet\n response = service.get_spreadsheet(spreadsheet_id)\n @spreadsheet_url = response.spreadsheet_url\n\n # Sheet we are working on.\n sheet_name = \"Sheet1\"\n sheet_id = 0\n\n #this function converts spreadsheet indices to column name\n # examples: e[0] => A; e[30] => AE \n e =->n{a=?A;n.times{a.next!};a} \n\n# ************ update spreadsheet title ************************\n# https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/batchUpdate\n spreadsheet_title = \"Google Roster\" \n request_body = Google::Apis::SheetsV4::BatchUpdateSpreadsheetRequest.new\n myussp = {\"properties\": {\"title\": spreadsheet_title}, \"fields\": \"*\" }\n request_body.requests = [{\"update_spreadsheet_properties\": myussp }]\n result = service.batch_update_spreadsheet(spreadsheet_id, request_body, {})\n\n# ************ add sheet ************************\n googleAddSheet = lambda{ |mytitle, mysheetproperties|\n request_body = Google::Apis::SheetsV4::BatchUpdateSpreadsheetRequest.new\n myas = {\"properties\": {\"title\": mytitle}}\n request_body.requests = [{\"add_sheet\": myas }]\n result = service.batch_update_spreadsheet(spreadsheet_id, request_body, {})\n mysheetproperties.push({'index' => result.replies[0].add_sheet.properties.index,\n 'sheet_id' => result.replies[0].add_sheet.properties.sheet_id,\n 'title' => result.replies[0].add_sheet.properties.title})\n }\n \n# ************ delete sheets ************************\n googleSheetDelete = lambda{\n result = service.get_spreadsheet(spreadsheet_id)\n mysheets = result.sheets\n request_body = Google::Apis::SheetsV4::BatchUpdateSpreadsheetRequest.new\n mysheets.each_with_index do |o, i|\n next if i == 0\n request_body.requests == nil ?\n request_body.requests = [{\"delete_sheet\": {\"sheet_id\": o.properties.sheet_id}}] :\n request_body.requests.push({\"delete_sheet\": {\"sheet_id\": o.properties.sheet_id}})\n end\n unless request_body.requests == nil\n result = service.batch_update_spreadsheet(spreadsheet_id, request_body, {})\n end\n }\n\n# ************ get spreadsheet properties ************************\n googleSheetProperties = lambda{\n result = service.get_spreadsheet(spreadsheet_id)\n mysheets = result.sheets\n mysheetproperties = mysheets.map{|p| {'index' => p.properties.index, \n 'sheet_id' => p.properties.sheet_id,\n 'title' => p.properties.title } }\n \n }\n\n# ************ update sheet title ************************\n# https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/batchUpdate\n googleSetSheetTitle = lambda{ |mytitle|\n request_body = Google::Apis::SheetsV4::BatchUpdateSpreadsheetRequest.new\n myusp = {\"properties\": {\"title\": mytitle }, \"fields\": \"title\" }\n request_body.requests = [{\"update_sheet_properties\": myusp }]\n result = service.batch_update_spreadsheet(spreadsheet_id, request_body, {})\n }\n\n# ************ delete all cells (rows) in a sheet ****************************\n# https://www.rubydoc.info/github/google/google-api-ruby-client/Google/Apis/SheetsV4/Request#delete_range-instance_method \n googleClearSheet = lambda{|passed_sheet_id|\n requests = [{ delete_range:{\n range: {sheet_id: passed_sheet_id, start_row_index: 0, start_column_index: 0 },\n shift_dimension: \"ROWS\"}}]\n body = {requests: requests}\n result = service.batch_update_spreadsheet(spreadsheet_id, body, {})\n }\n \n\n# ******** set vertical alignment using batch_update_spreadsheet ********\n # googleVertAlignAll.call(palign \"TOP | MIDDLE | BOTTOM\")\n googleVertAlignAll = lambda{ |passed_sheet_id, palign|\n requests = [{repeat_cell: {\n \t range: {sheet_id: passed_sheet_id,\n \t start_row_index: 0,\n \t start_column_index: 0\n \t },\n cell: {user_entered_format: {vertical_alignment: palign} },\n fields: \"user_entered_format(vertical_alignment)\"\n }\n }]\n body = {requests: requests}\n result = service.batch_update_spreadsheet(spreadsheet_id, body, {})\n }\n\n# ****************** calls batch_update_spreadsheet ******************\n # googlebatchdataitem.call(passed_items [googlebackgroundcolouritem, ...])\n googleBatchUpdate = lambda{|passeditems|\n if passeditems.count > 0\n body = {requests: passeditems}\n result = service.batch_update_spreadsheet(spreadsheet_id, body, {})\n end\n }\n\n# ******** update background colours using batch_update_spreadsheet ********\n # googleBGColourItem.call(rowStart, colStart, numberOfRows, numberOfCols,\n # colour[red_value, geen_value, blue_value])\n googleBGColourItem = lambda{|passed_sheet_id, rs, cs, nr, nc, pcolour|\n {repeat_cell: {\n \t range: {sheet_id: passed_sheet_id,\n \t start_row_index: rs - 1,\n \t end_row_index: rs - 1 + nr,\n \t start_column_index: cs - 1,\n \t end_column_index: cs - 1 + nc},\n cell:{user_entered_format:\n \t {background_color: {red: pcolour[0], green: pcolour[1], blue: pcolour[2]}}},\n fields: \"user_entered_format(background_color)\"}}}\n \n# ******** set vertical alignment using batch_update_spreadsheet ********\n # googleVertAlign.call(rowStart, colStart, numberOfRows, numberOfCols,\n # palign \"TOP | MIDDLE | BOTTOM\")\n googleVertAlign = lambda{|passed_sheet_id, rs, cs, nr, nc, palign|\n pad = 5\n result = {repeat_cell: {\n \t range: {sheet_id: passed_sheet_id,\n \t start_row_index: rs - 1,\n \t start_column_index: cs - 1 },\n cell:{user_entered_format: {vertical_alignment: palign,\n padding: {\n top: pad,\n right: pad,\n bottom: pad,\n left: pad\n }\n } \n },\n fields: \"user_entered_format(vertical_alignment,padding)\"\n }\n }\n if nr != nil then\n result[:repeat_cell][:range][:end_row_index] = rs - 1 + nr \n end\n if nc != nil then\n result[:repeat_cell][:range][:end_column_index] = cs - 1 + nc \n end\n return result\n }\n\n# ******** set wrap text using batch_update_spreadsheet ********\n # googleWrapText.call(rowStart, colStart, numberOfRows, numberOfCols,\n # wrap \"OVERFLOW_CELL | LEGACY_WRAP | CLIP | WRAP\")\n googleWrapText = lambda{|passed_sheet_id, rs, cs, nr, nc, pwrap|\n result = {repeat_cell: {\n \t range: {sheet_id: passed_sheet_id,\n \t start_row_index: rs - 1,\n \t start_column_index: cs - 1 },\n cell:{user_entered_format: {wrap_strategy: pwrap} },\n fields: \"user_entered_format(wrap_strategy)\"\n }\n }\n if nr != nil then\n result[:repeat_cell][:range][:end_row_index] = rs - 1 + nr \n end\n if nc != nil then\n result[:repeat_cell][:range][:end_column_index] = cs - 1 + nc \n end\n return result\n }\n\n# ******** update borders using batch_update_spreadsheet ********\n# https://developers.google.com/sheets/api/samples/formatting\n # googleBorder.call(sheet_id, rowStart, colStart, numberOfRows, numberOfCols,\n # {left: color, right: .., top: .., bottom: ..}, width)\n googleBorder = lambda{|passed_sheet_id, rs, cs, nr, nc, pcolour, passedStyle |\n {\n update_borders: {\n \t range: { sheet_id: passed_sheet_id,\n \t start_row_index: rs - 1,\n \t end_row_index: rs - 1 + nr,\n \t start_column_index: cs - 1,\n \t end_column_index: cs - 1 + nc },\n top: { style: passedStyle,\n \t color: {red: pcolour[0], green: pcolour[1], blue: pcolour[2]}},\n left: { style: passedStyle,\n \t color: {red: pcolour[0], green: pcolour[1], blue: pcolour[2]}},\n right: { style: passedStyle,\n \t color: {red: pcolour[0], green: pcolour[1], blue: pcolour[2]}},\n bottom: { style: passedStyle,\n \t color: {red: pcolour[0], green: pcolour[1], blue: pcolour[2]}},\n }\n }\n }\n\n# ******** update borders using batch_update_spreadsheet ********\n# https://developers.google.com/sheets/api/samples/formatting\n # googleBorder.call(sheet_id, rowStart, colStart, numberOfRows, numberOfCols,\n # {left: color, right: .., top: .., bottom: ..}, width)\n googleRightBorder = lambda{|passed_sheet_id, rs, cs, nr, nc, pcolour, passedStyle |\n {\n update_borders: {\n \t range: { sheet_id: passed_sheet_id,\n \t start_row_index: rs - 1,\n \t end_row_index: rs - 1 + nr,\n \t start_column_index: cs - 1,\n \t end_column_index: cs - 1 + nc },\n right: { style: passedStyle,\n \t color: {red: pcolour[0], green: pcolour[1], blue: pcolour[2]}}\n }\n }\n }\n\n# ******** adjust columns width using batch_update_spreadsheet ********\n# https://developers.google.com/sheets/api/samples/rowcolumn \n\n # googlecolwidthitem.call(colStart, numberOfCols,\n # width_pixels)\n googleColWidthItem = lambda{|passed_sheet_id, cs, nc, passedpw|\n {\n update_dimension_properties: {\n range: { dimension: \"COLUMNS\",\n \t sheet_id: passed_sheet_id,\n \t start_index: cs - 1,\n end_index: cs - 1 + nc },\n \t properties: { pixel_size: passedpw },\n \t fields: \"pixelSize\"\n }\n }\n }\n\n# ******** autoresize columns using batch_update_spreadsheet ********\n# https://developers.google.com/sheets/api/samples/rowcolumn \n\n # googlecolautowidthitem.call(passed_sheet_id, colStart, numberOfCols)\n googleColAutowidthItem = lambda{|passed_sheet_id, cs, nc|\n {\n auto_resize_dimensions: { dimensions: { dimension: \"COLUMNS\",\n \t sheet_id: passed_sheet_id,\n \t start_index: cs - 1,\n end_index: cs - 1 + nc }\n }\n }\n }\n \n# ******** merge cells using batch_update_spreadsheet ********\n# https://developers.google.com/sheets/api/samples/formatting \n # googleMergeCells.call(passed_sheet_id, rowStart, numOfRows, colStart, numberOfCols)\n googleMergeCells = lambda{|passed_sheet_id, rs, nr, cs, nc|\n {\n merge_cells: { range: { sheet_id: passed_sheet_id,\n start_row_index: rs - 1,\n end_row_index: rs - 1 + nr,\n start_column_index: cs - 1,\n end_column_index: cs - 1 + nc },\n merge_type: \"MERGE_ALL\"\n }\n }\n }\n\n# ******** format header cells using batch_update_spreadsheet ********\n# https://developers.google.com/sheets/api/samples/formatting \n # googlefomratCells.call(passed_sheet_id, rowStart, numOfRows, colStart, numberOfCols, fontSize)\n googleFormatCells = lambda{|passed_sheet_id, rs, nr, cs, nc, fs|\n {\n repeat_cell: { range: { sheet_id: passed_sheet_id,\n start_row_index: rs - 1,\n end_row_index: rs - 1 + nr,\n start_column_index: cs - 1,\n end_column_index: cs - 1 + nc },\n cell: { user_entered_format: {\n horizontal_alignment: \"CENTER\",\n text_format: {\n font_size: fs,\n bold: true\n }\n }\n },\n fields: \"userEnteredFormat(textFormat, horizontalAlignment)\"\n }\n }\n }\n\n# ************ update values using update_spreadsheet_value ****************************\n# doco: https://www.rubydoc.info/github/google/google-api-ruby-client/Google%2FApis%2FSheetsV4%2FSheetsService%3Aupdate_spreadsheet_value \n# call using\n\n# googlevalues.call(rowStartIndex, columnStartIndex, numberOfRows, numberOfColumns, values[[]])\n# Indexes start at 1 for both rows and columns\n googleValues = lambda{|rs, cs, nr, nc, values| \n range = \"#{sheet_name}!\" + e[cs - 1] + rs.to_s + \":\" +\n e[cs + nc - 1] + (rs + nr).to_s\n request_body = Google::Apis::SheetsV4::ValueRange.new\n request_body.values = values\n request_body.major_dimension = \"ROWS\"\n service.update_spreadsheet_value(spreadsheet_id, range, request_body, \n {value_input_option: 'USER_ENTERED'})\n }\n \n# ************ update values using batch_update_values ****************************\n # googlebatchdataitem.call(rowStart, colStart, numberOfRows, numberOfCols,\n # values[[]])\n googleBatchDataItem = lambda{|passed_sheet_name, rs, cs, nr, nc, values|\n range = \"#{passed_sheet_name}!\" + e[cs - 1] + rs.to_s + \":\" +\n e[cs + nc - 1] + (rs + nr).to_s\n {\n range: range,\n majorDimension: 'ROWS',\n values: values\n }\n }\n\n# ************ execute batch update of values - [data items] ****************************\n # googlebatchdataitem.call(spreadsheet_id, \n # passed in batch data [gppg;ebatcjdataote, ...])\n googleBatchDataUpdate = lambda{|ss_id, dataitems |\n if dataitems.count > 0\n request_body = Google::Apis::SheetsV4::BatchUpdateValuesRequest.new\n request_body.value_input_option = 'USER_ENTERED'\n request_body.data = dataitems\n service.batch_update_values(ss_id, request_body, {})\n end\n }\n\n# ************ text format run using batch_update_values ****************************\n # googlebatchTextFormatRunItem.call(rowStart, colStart, \n # text, breakPointToChangeFormat[])\n googleTextFormatRun = lambda{|passed_sheet_id, rs, cs, myText, myBreaks|\n result = \n {\n update_cells: {\n \t start: {sheet_id: passed_sheet_id,\n \t row_index: rs - 1,\n \t column_index: cs - 1\n \t },\n rows: [ \n { values: [ \n {\n user_entered_value: {\n string_value: myText\n },\n user_entered_format: {\n text_format: {\n fontFamily: \"Arial\"\n }\n },\n text_format_runs: [\n {\n start_index: myBreaks[0],\n format: {\n bold: true,\n font_size: 10\n }\n }\n ]\n }\n ]\n }\n \n ],\n fields: \"userEnteredValue, userEnteredFormat.textFormat.bold, textFormatRuns.format.(bold, fontSize, fontFamily)\"\n }\n }\n if myBreaks[1] < myText.length then\n secondRun = {\n start_index: myBreaks[1],\n format: {\n bold: false,\n font_size: 10\n }\n }\n result[:update_cells][:rows][0][:values][0][:text_format_runs].push(secondRun)\n end\n return result\n }\n \n \n# ************ batch update of data items ****************************\n # googlebatchdataitem.call(spreadsheet_id, \n # passed in batch data [gppg;ebatcjdataote, ...])\n googleBatchDataUpdate = lambda{|ss_id, dataitems |\n if dataitems.count > 0\n request_body = Google::Apis::SheetsV4::BatchUpdateValuesRequest.new\n request_body.value_input_option = 'USER_ENTERED'\n request_body.data = dataitems\n service.batch_update_values(ss_id, request_body, {})\n end\n }\n\n#-------- To test or not to test ------------------------------\ntesting = false # true or false\nif testing then\n\n#--------------------- Test Data -------------------------------\n# Clear the sheet\n googleClearSheet.call(sheet_id)\n \n# Some test formatting\n batchitems = []\n\n batchitems.push(googleBGColourItem.call(sheet_id, 1,1,1,2,[0,1,0]))\n batchitems.push(googleBGColourItem.call(sheet_id, 6,1,1,2,[1,0,0]))\n batchitems.push(googleBGColourItem.call(sheet_id, 7,1,1,2,[0,0,1]))\n\n batchitems.push(googleBorder.call(sheet_id, 2,1,2,2, [0,0,0], \"SOLID_MEDIUM\"))\n \n batchitems.push(googleVertAlign.call(sheet_id,2,1,2,2, \"TOP\"))\n\n batchitems.push(googleWrapText.call(sheet_id, 2,1,2,2, \"WRAP\"))\n\n batchitems.push(googleColWidthItem.call(sheet_id, 1,3,160))\n \n googleBatchUpdate.call(batchitems) \n\n# Some test cellvalues - individual update\n myvalues = [[\"update_spreadsheet_value\",\"test data - this row will get a background colour\"]]\n googleValues.call(1, 1, 1, 2, myvalues)\n\n# Some test value data - batch update\n mydata = []\n mydata.push(googleBatchDataItem.call(sheet_name,2,1,2,2,\n [\n [\"spreadsheet_values_batchUpdate\", \"test data\"],\n [\"spreadsheet_values_batchUpdate\", \"third row\"]\n ])\n )\n mydata.push(googleBatchDataItem.call(sheet_name,6,1,2,2,\n [\n [\"spreadsheet_values_batchUpdate2\", \"test data\"],\n [\"spreadsheet_values_batchUpdate2\", \"seventh row\"]\n ])\n )\n googleBatchDataUpdate.call(spreadsheet_id, mydata)\n\n #Note: need to do values first so autoformat works.\n batchitems = [] # reset\n batchitems.push(googleColAutowidthItem.call(sheet_id, 1, 1))\n googleBatchUpdate.call(batchitems) \n \n logger.debug \"about to try out googleTextFormatRun\"\n batchitems = []\n batchitems.push(googleTextFormatRun.call(sheet_id, 10,2, \"123456789\\n1234567890123456789\", [0,10]))\n googleBatchUpdate.call(batchitems) \n logger.debug \"done googleTextFormatRun\"\n\nelse # Not to test.\n\n# let does some processing - writing rosters to google sheets.\n #@sf = 5 # number of significant figures in dom ids for lesson,tutor, etc.\n\n #mystartdate = current_user.daystart\n #myenddate = current_user.daystart + current_user.daydur.days\n @options = Hash.new\n #@options[:startdate] = current_user.daystart\n #@options[:enddate] = current_user.daystart + current_user.daydur.days\n @options[:startdate] = current_user.rosterstart\n @options[:enddate] = current_user.rosterstart + current_user.rosterdays.days\n \n #*****************************************************************\n # Set these to control what is displayed in the roster\n \n @tutorstatusforroster = [\"scheduled\", \"dealt\", \"confirmed\", \"attended\"]\n @studentstatusforroster = [\"scheduled\", \"dealt\", \"attended\"]\n \n #*****************************************************************\n \n # call the library in controllers/concerns/calendarutilities.rb\n #@cal = calendar_read_display2(@sf, mystartdate, myenddate)\n #calendar_read_display1f(sf, mystartdate, myenddate, options)\n \n # @tutors and @students are used by the cal\n @tutors = Tutor\n .where.not(status: \"inactive\")\n .order('pname')\n @students = Student\n .where.not(status: \"inactive\")\n .order('pname')\n \n #@cal = calendar_read_display1f(@sf, mystartdate, myenddate, {})\n #@cal = calendar_read_display1f(@sf, @options)\n @cal = calendar_read_display1f(@options)\n # Clear the first sheet - the rest are deleted.\n googleClearSheet.call(sheet_id)\n #googleVertAlignAll.call(\"TOP\")\n\n # kinds will govern the background colours for tutors and students.\n kindcolours = Hash.new\n=begin\n kindcolours = {\n 'tutor-kind-training' => [244, 164, 96],\n 'tutor-kind-called' => [135, 206, 250],\n 'tutor-kind-standard' => [0, 250, 154],\n 'tutor-kind-relief' => [245, 222, 179],\n 'tutor-kind-BFL' => [255, 255, 0],\n 'tutor-kind-onCall' => [0, 255, 255],\n 'tutor-kind-onSetup' => [234, 209, 220],\n 'student-kind-free' => [0, 255, 0],\n 'student-kind-first' => [182, 215, 168],\n 'student-kind-catchup' => [173, 216, 230],\n 'student-kind-fortnightly' => [70, 130, 180], \n 'student-kind-onetoone' => [250, 128, 114],\n 'student-kind-standard' => [0, 250, 154],\n 'tutor-kind-' => [255, 255, 255],\n 'tutor-student-' => [255, 255, 255]\n }\n=end\n kindcolours.default = [255, 255, 255] # result if called with missing key\n \n # clear unused sheets & get sheet properties\n googleSheetDelete.call\n # sets mysheetproperties = [{'index', 'sheet_id', 'title'}, ..]\n mysheetproperties = googleSheetProperties.call \n\n # will increment to 1 on stepping into loops => 1..n\n # Note: both rows and column indexes spreadsheets start at 1\n # Following counters used to track loactions in the spreadsheet\n timeData = ''\n baseSiteRow = 1 \n baseSlotRowInSite = 1\n baseLessonRowInSlot = 0\n currentTutorRowInLesson = 0\n currentStudentRowInLesson = 0\n currentStudentInLesson = 0\n maxPersonRowInAnySlot = 0\n maxPersonRowInAnySlot = 0\n currentCol = 1\n currentRow = 1\n baseSiteRow = 1 # first site \n baseSiteRowAll = 1 # for the 'all' tab \n locationindex = 0 # index into the sites\n \n # to compress or not - remove unused days\n @compress = false # can be true or false\n\n # have an all tab in google sheets to show all sites in that page\n # this is for tutors to seach for their name across all sites.\n # We still have a separate tab for each site\n googleSetSheetTitle.call(\"All\")\n mysheetproperties[locationindex]['title'] = \"All\"\n sheet_name_all = mysheetproperties[locationindex]['title']\n sheet_id_all = mysheetproperties[locationindex]['sheet_id']\n ###----------------------------------------------------------------------\n ###------------------- step through the sites ---------------------------\n ###----------------------------------------------------------------------\n @cal.each do |location, calLocation| # step through sites\n if @compress # remove days with no valid slot for this site\n usedColumns = calLocation[0][0][\"days\"].keys\n usedColumnsIndex = [0]\n for i in 1..(calLocation[0].length-1)\n if usedColumns.include?(calLocation[0][i][\"value\"]) then\n usedColumnsIndex.push(i)\n end\n end \n end\n\n mydata = [] # google batch data writter at end of processing a site\n myformat = []\n\n # make separate sheet entry for each site\n baseSiteRow = 1 # reset when new sheet for each site.\n # baseSiteRowAll continues across all sites.\n if locationindex == 0 # set up the all tab - contains all sites\n # googleSetSheetTitle.call(location)\n # mysheetproperties[locationindex]['title'] = location\n # General formatting for the 'all' sheet - done once\n myformat.push(googleVertAlign.call(sheet_id_all, 1, 1, nil, nil, \"TOP\"))\n myformat.push(googleWrapText.call(sheet_id_all, 1, 1, nil, nil, \"WRAP\"))\n myformat.push(googleColWidthItem.call(sheet_id_all, 1,100,200))\n myformat.push(googleColWidthItem.call(sheet_id_all, 1,1,0))\n end\n # now have a sheet for each site.\n mysheetproperties = googleAddSheet.call(location, mysheetproperties) # add a sheet\n # mysheets = result.sheets\n # mysheetproperties = mysheets.map{|o| {'index' => o.properties.index, \n # 'sheet_id' => o.properties.sheet_id,\n # 'title' => o.properties.title } }\n locationindex += 1\n sheet_name = mysheetproperties[locationindex]['title']\n sheet_id = mysheetproperties[locationindex]['sheet_id']\n\n # This function formats a lesson row\n # myformal and mydata are global to this google roster function\n # we are passing in values to ensure they are in the correct context.\n formatLesson = lambda { |baseLessonRowInSlot, baseSlotRowInSite, baseSiteRow, baseSiteRowAll, currentCol, maxPersonRowInLesson|\n borderRowStart = baseLessonRowInSlot + baseSlotRowInSite + baseSiteRow\n borderRowStartAll = baseLessonRowInSlot + baseSlotRowInSite + baseSiteRowAll\n borderColStart = currentCol\n borderRows = maxPersonRowInLesson\n borderCols = 4 # one tutor col and 2 student cols + lesson commment col.\n # merge the cells within the comment section of a single session\n # googleMergeCells.call(passed_sheet_id, rowStart, numOfRows, colStart, numberOfCols)\n myformat.push(googleMergeCells.call(sheet_id, borderRowStart, borderRows,\n borderColStart + borderCols - 1, 1))\n myformat.push(googleMergeCells.call(sheet_id_all, borderRowStartAll, borderRows,\n borderColStart + borderCols - 1, 1))\n myformat.push(googleBorder.call(sheet_id, borderRowStart, borderColStart, borderRows, borderCols, [0, 0, 0], \"SOLID_MEDIUM\"))\n myformat.push(googleBorder.call(sheet_id_all, borderRowStartAll, borderColStart, borderRows, borderCols, [0, 0, 0], \"SOLID_MEDIUM\"))\n myformat.push(googleRightBorder.call(sheet_id, borderRowStart, borderColStart, borderRows, 1, [0, 0, 0], \"SOLID\"))\n myformat.push(googleRightBorder.call(sheet_id_all, borderRowStartAll, borderColStart, borderRows, 1, [0, 0, 0], \"SOLID\"))\n myformat.push(googleRightBorder.call(sheet_id, borderRowStart, borderColStart+2, borderRows, 1, [0, 0, 0], \"SOLID\"))\n myformat.push(googleRightBorder.call(sheet_id_all, borderRowStartAll, borderColStart+2, borderRows, 1, [0, 0, 0], \"SOLID\"))\n myformat.push(googleWrapText.call(sheet_id, borderRowStart, borderColStart, borderRows, borderCols, \"WRAP\"))\n myformat.push(googleWrapText.call(sheet_id_all, borderRowStartAll, borderColStart, borderRows, borderCols, \"WRAP\"))\n # want to put timeslot time (timeData) in first column of each lesson row.\n for i in borderRowStart..borderRowStart+borderRows-1 do\n mydata.push(googleBatchDataItem.call(sheet_name, i,1,1,1,[[timeData]]))\n end\n for i in borderRowStartAll..borderRowStartAll+borderRows-1 do\n mydata.push(googleBatchDataItem.call(sheet_name_all,i,1,1,1,[[timeData]]))\n end\n }\n #------------- end of lambda function: formatLesson ---------\n\n ### correction ###render flexibledisplay\n \n # General formatting for each site sheet\n myformat.push(googleVertAlign.call(sheet_id, 1, 1, nil, nil, \"TOP\"))\n myformat.push(googleWrapText.call(sheet_id, 1, 1, nil, nil, \"WRAP\"))\n myformat.push(googleColWidthItem.call(sheet_id, 1,100,350))\n myformat.push(googleColWidthItem.call(sheet_id, 1,1,0))\n\n #<table id=site-<%= location %> >\n baseSlotRowInSite = 0 # first slot\n currentRow = baseSlotRowInSite + baseSiteRow\n currentRowAll = baseSlotRowInSite + baseSiteRowAll\n ###----------------------------------------------------------------------\n ###-- step through each time period for this site e.g. 3:30, 4:30, etc. - \n ###-- (entry 0 = title info: 1. site 2. populated days by date) \n ###----------------------------------------------------------------------\n calLocation.each do |rows| # step through slots containing multiple days (fist row is actually a header row!)\n timeData = rows[0][\"value\"] \n #<tr>\n maxPersonRowInAnySlot = 0 # initialised to 1 to step a row even if no tutor or student found.\n currentCol = 1\n ###--------------------------------------------------------------------\n ###------- step through each day for this time period -----------------\n ### (entry 0 = time of lesson)\n ###--------------------------------------------------------------------\n rows.each_with_index do |cells, cellIndex| # step through each day (first column is head column - for time slots!)\n if @compress \n unless usedColumnsIndex.include?(cellIndex) then\n next\n end \n end\n awaystudents = \"\"\n ###-------------------------------------------------------------------------------------------\n ###------------------- step through each lesson in this slot ---------------------------------\n ###-------------------------------------------------------------------------------------------\n if cells.key?(\"values\") then # lessons for this day in this slot \n if cells[\"values\"].respond_to?(:each) then # check we have lessons?\n # This is a slot with lessons, do I need to output a title.\n #byebug\n # First column for each day needs to have the width set\n # googlecolwidthitem.call(sheet_id, colStart, numberOfCols, width_pixels)\n myformat.push(googleColWidthItem.call(sheet_id, currentCol, 1, 130))\n myformat.push(googleColWidthItem.call(sheet_id_all, currentCol, 1, 130))\n myformat.push(googleColWidthItem.call(sheet_id, currentCol+3, 1, 200))\n myformat.push(googleColWidthItem.call(sheet_id_all, currentCol+3, 1, 200))\n title = calLocation[0][0]['value'] + # site name\n calLocation[0][cellIndex]['datetime'].strftime(\" %A %e/%-m/%y \") + # date\n rows[0]['value'] # sesson time \n mydata.push(googleBatchDataItem.call(sheet_name,\n baseSiteRow + baseSlotRowInSite - 1, \n currentCol,1,1,[[title]]))\n mydata.push(googleBatchDataItem.call(sheet_name_all,\n baseSiteRowAll + baseSlotRowInSite - 1,\n currentCol,1,1,[[title]]))\n # googleMergeCells.call(passed_sheet_id, rowStart, numOfRows, colStart, numberOfCols)\n myformat.push(googleMergeCells.call(sheet_id, baseSiteRow + baseSlotRowInSite - 1, 1,\n currentCol, 4))\n myformat.push(googleMergeCells.call(sheet_id_all, baseSiteRowAll + baseSlotRowInSite - 1, 1,\n currentCol, 4))\n # Format the header line (merged cells)\n # googlefomratCells.call(passed_sheet_id, rowStart, numOfRows, colStart, numberOfCols, fontSize)\n myformat.push(googleFormatCells.call(sheet_id, baseSiteRow + baseSlotRowInSite - 1, 1,\n currentCol, 4, 16))\n myformat.push(googleFormatCells.call(sheet_id_all, baseSiteRowAll + baseSlotRowInSite - 1, 1,\n currentCol, 4, 16))\n baseLessonRowInSlot = 0 # index of first lesson in this slot for this day\n cells[\"values\"].sort_by {|obj| [valueOrderStatus(obj),valueOrder(obj)] }.each do |entry| # step thru sorted lessons\n next if (entry.status != nil && [\"global\", \"park\"].include?(entry.status))\n currentTutorRowInLesson = 0\n if entry.tutors.respond_to?(:each) then\n entry.tutors.sort_by {|obj| obj.pname }.each do |tutor|\n if tutor then\n thistutrole = tutor.tutroles.where(lesson_id: entry.id).first\n if @tutorstatusforroster.include?(thistutrole.status) then # tutors of interest\n currentRow = currentTutorRowInLesson + baseLessonRowInSlot + baseSlotRowInSite + baseSiteRow\n currentRowAll = currentTutorRowInLesson + baseLessonRowInSlot + baseSlotRowInSite + baseSiteRowAll\n #<div class=\"tutorname tutorinline <%= set_class_status(tutor, entry) %>\">tutor: <%= tutor.pname %></div>\n tutorData = tutor.pname\n tutorDataAll = tutor.pname\n formatBreakPoints = []\n formatBreakPointsAll = []\n formatBreakPoints.push(0)\n formatBreakPointsAll.push(0)\n formatBreakPoints.push(tutor.pname.length)\n formatBreakPointsAll.push(tutor.pname.length)\n # tutor.subjects\n mysubjects = tutor.subjects\n mysubjects = mysubjects ? mysubjects : \"\"\n # thistutrole.comment\n # tutor.comment\n # Status: thistutrole.status Kind: thistutrole.kind\n mykind = thistutrole.kind\n mykind = mykind ? mykind : \"\"\n # don't diaplay subjects or kind for tutors on setup\n unless (entry.status == 'onSetup' && mykind == 'onSetup') ||\n (entry.status == 'onCall' && mykind == 'onCall')\n tutorData += ((mysubjects == \"\") ? \"\" : (\"\\n\" + mysubjects)) \n tutorData += ((mykind == \"\") ? \"\" : (\"\\n\" + mykind)) unless [\"standard\"].include?(mykind)\n tutorDataAll += ((mykind == \"\") ? \"\" : (\"\\n\" + mykind)) unless [\"standard\"].include?(mykind)\n end\n if thistutrole.comment != nil && thistutrole.comment != \"\"\n tutorData += \"\\n\" + thistutrole.comment\n end\n mycolour = kindcolours['tutor-kind-' + mykind]\n mycolour = mycolour.map {|p| p/255.0} \n myformat.push(googleTextFormatRun.call(sheet_id, currentRow, currentCol,\n tutorData, formatBreakPoints))\n myformat.push(googleTextFormatRun.call(sheet_id_all, currentRowAll, currentCol,\n tutorDataAll, formatBreakPointsAll))\n ###myformat.push(googleBGColourItem.call(sheet_id, currentRow, currentCol, 1, 1, mycolour))\n ###myformat.push(googleBGColourItem.call(sheet_id_all, currentRowAll, currentCol, 1, 1, mycolour))\n currentTutorRowInLesson += 1\n end # tutors of interest\n end\n #break\n end\n # keep track of the largest count of tutors or students in lesson.\n maxPersonRowInAnySlot = maxPersonRowInAnySlot > currentTutorRowInLesson + baseLessonRowInSlot ?\n maxPersonRowInAnySlot : currentTutorRowInLesson + baseLessonRowInSlot\n end\n currentStudentRowInLesson = 0\n currentStudentInLesson = 0\n studentLessonComments = \"\"\n if entry.students.respond_to?(:each) then\n entry.students.each do |student|\n if student then\n logger.debug \"student: \" + student.pname\n thisrole = student.roles.where(lesson_id: entry.id).first\n #logger.debug \"thisrole: \" + thisrole.inspect\n if ['away', 'awaycourtesy', 'bye', 'absent'].include?(thisrole.status) then \n displayname = student.pname + \" (\" + thisrole.status + \")\"\n awaystudents += awaystudents.length > 0 ? \"\\n\" + displayname : displayname\n end\n if @studentstatusforroster.include?(thisrole.status) then # students of interest\n #logger.debug \"*************processing student: \" + student.pname\n #logger.debug \"currentStudentInLesson: \" + currentStudentInLesson.inspect\n #logger.debug \"currentStudentRowInLesson + baseLessonRowInSlot + baseSlotRowInSite: \" +\n # currentStudentRowInLesson.to_s + \", \" + baseLessonRowInSlot.to_s + \", \" + baseSlotRowInSite.to_s\n currentRow = currentStudentRowInLesson + baseLessonRowInSlot + baseSlotRowInSite + baseSiteRow\n currentRowAll = currentStudentRowInLesson + baseLessonRowInSlot + baseSlotRowInSite + baseSiteRowAll\n #<div class=\"studentname studentinline <%= set_class_status(student, entry) %>\">student: <%= student.pname %></div>\n #logger.debug \"DataItem parameters: \" + currentRow.to_s + \", \" + currentCol.to_s + \", 1, 1, \" + student.pname \n formatBreakPoints = []\n formatBreakPoints.push(0)\n studentData = student.pname\n studentSex = student.sex == nil ? \"\" :\n (student.sex.downcase.include?(\"female\") ? \"(F) \" : (student.sex.downcase.include?(\"male\") ? \"(M) \" : \"\"))\n studentData += \" \" + studentSex\n #logger.debug \"student.pname: \" + student.pname \n #logger.debug \"lesson_id: \" + entry.id.to_s\n #formatBreakPoints.push(student.pname.length)\n #studentSubjects = \" Yr: \" + (student.year == nil ? \" \" : student.year.rjust(3)) +\n # \" | \" + (student.study == nil ? \"\" : student.study)\n #studentYear = \" Yr:\" + (student.year == nil ? student.year.rjust(3))\n studentYear = \" Yr:\" + (student.year == nil ? \"\" : student.year)\n studentSubjects = student.study == nil ? \"\" : student.study\n studentData += studentYear\n studentDataAll = studentData\n formatBreakPointsAll = formatBreakPoints\n studentData += \"\\n\" + studentSubjects\n formatBreakPoints.push(studentData.length)\n # thisrole.comment\n # student.comment\n # Status: thisrole.status Kind: thisrole.kind\n mykind = thisrole.kind\n mykind = mykind ? mykind : \"\"\n studentData += \" (\" + mykind + \")\" unless [\"standard\"].include?(mykind)\n if thisrole.comment != nil && thisrole.comment != \"\"\n studentLessonComments += student.pname + \":\\n\" + thisrole.comment + \"\\n\"\n #studentData += \"\\n\" + thisrole.comment\n end\n if student.comment != nil && student.comment != \"\"\n studentData += \"\\n\" + student.comment\n end\n mycolour = kindcolours['student-kind-' + mykind]\n mycolour = mycolour.map {|p| p/255.0}\n #myformat.push(googleTextFormatRun.call(sheet_id, currentRow, currentCol + 1,\n # studentData, formatBreakPoints))\n colOffset = 1 + (currentStudentInLesson % 2)\n myformat.push(googleTextFormatRun.call(sheet_id, currentRow, currentCol + colOffset,\n studentData, formatBreakPoints))\n myformat.push(googleTextFormatRun.call(sheet_id_all, currentRowAll, currentCol + colOffset,\n studentDataAll, formatBreakPointsAll))\n ###myformat.push(googleBGColourItem.call(sheet_id, currentRow, currentCol + colOffset, 1, 1, mycolour))\n ###myformat.push(googleBGColourItem.call(sheet_id_all, currentRowAll, currentCol + colOffset, 1, 1, mycolour))\n \n #byebug \n currentStudentRowInLesson += 1 if (currentStudentInLesson % 2) == 1 # odd\n currentStudentInLesson += 1\n end # students of interest\n end\n end\n # Need to get correct count of rows (rounding up is necessary)\n # derive currentStudentRowInLesson from the currentStudentInLesson\n currentStudentRowInLesson = (currentStudentInLesson % 2) == 0 ? \n currentStudentInLesson / 2 : (currentStudentInLesson / 2) + 1 \n \n # keep track of the largest count of tutors or students in lesson.\n maxPersonRowInAnySlot = maxPersonRowInAnySlot > currentStudentRowInLesson + baseLessonRowInSlot ?\n maxPersonRowInAnySlot : currentStudentRowInLesson + baseLessonRowInSlot\n end\n maxPersonRowInLesson = currentTutorRowInLesson > currentStudentRowInLesson ? \n currentTutorRowInLesson : currentStudentRowInLesson \n # put a border around this lesson if there were lessons with people\n if maxPersonRowInLesson > 0 then\n # put in lesson comments if there were tutors or students.\n #<div class=\"lessoncommenttext\"><% if entry.comments != nil && entry.comments != \"\" %><%= entry.comments %><% end %></div>\n #<div class=\"lessonstatusinfo\"><% if entry.status != nil && entry.status != \"\" %>Status: <%= entry.status %> <% end %></div>\n mylessoncomment = ''\n if entry.status != nil && entry.status != ''\n unless [\"standard\", \"routine\", \"flexible\"].include?(entry.status) # if this is a standard lesson \n mylessoncomment = entry.status + \"\\n\" # don't show the lesson status (kind)\n end\n end\n mylessoncommentAll = mylessoncomment\n if entry.comments != nil && entry.comments != \"\"\n mylessoncomment += entry.comments\n end\n mylessoncomment += studentLessonComments\n if mylessoncomment.length > 0\n mylessoncomment = mylessoncomment.sub(/\\n$/, '') # remove trailing new line\n mydata.push(googleBatchDataItem.call(sheet_name, currentRow, currentCol+3,1,1,[[mylessoncomment]]))\n mydata.push(googleBatchDataItem.call(sheet_name_all,currentRowAll,currentCol+3,1,1,[[mylessoncommentAll]]))\n end\n # ----- formatting of the lesson row within the slot ---------\n formatLesson.call(baseLessonRowInSlot, baseSlotRowInSite, baseSiteRow, baseSiteRowAll, currentCol, maxPersonRowInLesson)\n end\n ###baseLessonRowInSlot += maxPersonRowInLesson\n baseLessonRowInSlot += maxPersonRowInLesson\n #currentRow = maxPersonRowInAnySlot + baseLessonRowInSlot + baseSlotRowInSite + baseSiteRow # next empty row \n end # end looping sorted lessons within a day/slot\n end # responds to cell[\"values\"]\n elsif cells.key?(\"value\") then # just holds cell info (not lessons) to be shown\n currentRow = baseSlotRowInSite + baseSiteRow\n currentRowAll = baseSlotRowInSite + baseSiteRowAll\n #timeData = cells[\"value\"].to_s #if currentCol == 1 &&\n # cells[\"value\"] != nil # pick up the time\n #mydata.push(googleBatchDataItem.call(sheet_name, currentRow, currentCol,1,1,[[cells[\"value\"].to_s]]))\n #mydata.push(googleBatchDataItem.call(sheet_name_all,currentRowAll,currentCol,1,1,[[cells[\"value\"].to_s]]))\n end\n # Now add a dummy row at end of slot to show students who are away\n if awaystudents.length > 0\n currentRow = baseLessonRowInSlot + baseSlotRowInSite + baseSiteRow\n currentRowAll = baseLessonRowInSlot + baseSlotRowInSite + baseSiteRowAll\n mydata.push(googleBatchDataItem.call(sheet_name, currentRow, currentCol,1,1,[[\"Students Away\"]]))\n mydata.push(googleBatchDataItem.call(sheet_name_all, currentRowAll, currentCol,1,1,[[\"Students Away\"]]))\n myformat.push(googleFormatCells.call(sheet_id, currentRow, 1, currentCol, 1, 10))\n myformat.push(googleFormatCells.call(sheet_id_all, currentRowAll, 1, currentCol, 1, 10))\n mydata.push(googleBatchDataItem.call(sheet_name, currentRow, currentCol + 1,1,1,[[awaystudents]]))\n mydata.push(googleBatchDataItem.call(sheet_name_all, currentRowAll, currentCol + 1,1,1,[[awaystudents]]))\n maxPersonRowInLesson = 1\n formatLesson.call(baseLessonRowInSlot, baseSlotRowInSite, baseSiteRow,\n baseSiteRowAll, currentCol, maxPersonRowInLesson) # apply the standard formatting\n baseLessonRowInSlot += 1 # add another row for this\n # update tracking of the largest count of tutors or students in lesson.\n maxPersonRowInAnySlot = maxPersonRowInAnySlot > currentStudentRowInLesson + baseLessonRowInSlot ?\n maxPersonRowInAnySlot : currentStudentRowInLesson + baseLessonRowInSlot\n maxPersonRowInAnySlot = maxPersonRowInAnySlot > currentTutorRowInLesson + baseLessonRowInSlot ?\n maxPersonRowInAnySlot : currentTutorRowInLesson + baseLessonRowInSlot\n end\n #</td>\n currentCol += currentCol == 1 ? 1 : 4 # first column is title, rest have adjacent tutors & students.\n end # end looping days within slots\n #</tr>\n #byebug\n baseSlotRowInSite += maxPersonRowInAnySlot # set ready for next slot (row of days)\n if baseLessonRowInSlot == 0 && maxPersonRowInAnySlot == 0 then\n baseSlotRowInSite += 1 # cater for when no lessons with tutors or students of interest\n end\n # Add an extra row between slots - except the first title slot\n # Jasmine wanted no rows between slots so reduced from 2 to 1.\n baseSlotRowInSite += 1 unless baseSlotRowInSite == 1\n end # end looping slots\n holdRailsLoggerLevel = Rails.logger.level\n Rails.logger.level = 1 \n googleBatchDataUpdate.call(spreadsheet_id, mydata)\n googleBatchUpdate.call(myformat) \n Rails.logger.level = holdRailsLoggerLevel\n\n #</table>\n baseSiteRow += baseSlotRowInSite + 1 # +1 adds blank row between sites\n baseSiteRowAll += baseSlotRowInSite + 1 # +1 adds blank row between sites\n #<br>\n end # end looping sites\nend # end of testing option.\n ### correction ###return # return without rendering.\n end",
"def rows(range = 'Sheet1!A1:E')\n get_spreadsheet_data('1eu1Dk67gKnrIgQQ9Fm0Y-RCMzRfZf1UaTQzEt7hjWp0', range)\n end",
"def all\n\t\tself.google_doc.restart_session_if_necessary\n\t\treset_worksheet_obj if @worksheet_obj == nil\n\t\tif(@worksheet_obj.nil?)\n\t\t\treturn []\n\t\telse\n\t\t\t@worksheet_obj.list.to_hash_array\n\t\tend\n\tend",
"def loadtest\n returned_authorisation = googleauthorisation(request)\n if returned_authorisation[\"authorizationurl\"]\n redirect_to returned_authorisation[\"authorizationurl\"] and return\n end\n service = returned_authorisation[\"service\"]\n #service = googleauthorisation(request)\n spreadsheet_id = '10dXs-AT-UiFV1OGv2DOZIVYHEp81QSchFbIKZkrNiC8'\n sheet_name = 'New Sheet Name'\n range = \"#{sheet_name}!A7:C33\"\n holdRailsLoggerLevel = Rails.logger.level\n Rails.logger.level = 1 \n response = service.get_spreadsheet(\n spreadsheet_id,\n ranges: range,\n fields: \"sheets(data.rowData.values\" + \n \"(formattedValue,effectiveFormat.backgroundColor))\"\n )\n Rails.logger.level = holdRailsLoggerLevel\n # Now scan each row read from the spreadsheet in turn\n\n @output = Array.new()\n rowarray = Array.new()\n cellcontentarray = Array.new(3)\n response.sheets[0].data[0].row_data.map.with_index do |r, ri| # value[], row index\n # Now start processing the row content\n r.values.map.with_index do |mycell, cellindex|\n c0 = getvalue(mycell)\n cellcontentarray[0] = c0\n \n cf0 = getformat(mycell)\n cellcontentarray[1] = showcolour(cf0)\n cellcontentarray[2] = cf0\n\n logger.debug \"c0: \" + c0.inspect\n logger.debug \"cf0: \" + showcolour(cf0)\n logger.debug \"\"\n \n rowarray[cellindex] = cellcontentarray.clone\n end\n @output[ri] = rowarray.clone\n end\n logger.debug \"@output: \" + @output.inspect\n \n # Test some helpers\n logger.debug \"------testing in controller-------------\"\n [\n \"Joshua Kerr\",\n \"Alexandra (Alex) Cosgrove 12\",\n \"Aanya Daga 4 (male)\",\n \"Riley Howatson 1 (female)\",\n \"Amelia Clark (kindy)\",\n \"Amelia Clark (kindy) (female)\",\n \"Amelia Clark kindy (female)\",\n \"Amelia Clark kindy female\",\n \"Amelia Clark 1 (female)\",\n \"Bill Clark 1 (male)\",\n \"Amelia Clark 1 female\",\n \"Elisha Stojanovski K\",\n \"Bella Parsonage Phelan 8\",\n \"Billy Johnson K (female)\"\n ].each do |a|\n b = getStudentNameYearSex(a)\n logger.debug \"name: \" + a + \"\\n\" + b.inspect \n end\n end",
"def worksheet_by_url(url)\n if !(url =~\n %r{^https?://spreadsheets.google.com/feeds/cells/(.*)/(.*)/private/full((\\?.*)?)$})\n raise(GoogleDrive::Error, \"URL is not a cell-based feed URL: #{url}\")\n end\n worksheet_feed_url = \"https://spreadsheets.google.com/feeds/worksheets/#{$1}/private/full/#{$2}#{$3}\"\n worksheet_feed_entry = request(:get, worksheet_feed_url)\n return Worksheet.new(self, nil, worksheet_feed_entry)\n end",
"def get_range_data(spreadsheet_id, ranges)\n req_url = spreadsheet_path(\"#{spreadsheet_id}/values:batchGet?#{ranges}\")\n Api.get_with_google_auth(req_url, @access_token).parse\n end",
"def get_column(col_title)\n id_gmail = ENV['GMAIL_ID']\n mdp_gmail = ENV['GMAIL_MDP']\n session = GoogleDrive::Session.from_config(\"config.json\")\n ws = session.spreadsheet_by_key(\"1N7--OE8i6xGaAO2AA8cxe9Ry1xm2GSdGULdlyJL7-iE\").worksheets[0]\n gmail = Gmail.connect!(id_gmail, mdp_gmail)\n i = 0\n column = Array.new\n while i < ws.num_rows do\n column.push(ws.list[i][col_title])\n i += 1\n end\n column\nend",
"def raw_data_sheet\r\n @book.worksheet(WBF[:data_sheet])\r\n end",
"def get_google_calendar\n result = Gandalf::GoogleApiClient.get_google_calendar(self.apps_cal_id)\n result.data\n end",
"def get_sheet\n\tsheet = Array.new\n\ti = 1\n\twhile i < RC_C.num_rows\n\t\tsheet[i-1] = RC_C.rows[i]\n\t\ti += 1\n\tend\n\treturn sheet\nend",
"def load_spreadsheet(opts)\n if opts[:url]\n @session.spreadsheet_by_key parse_gdoc_url_for_key(opts[:url])\n elsif opts[:key]\n @session.spreadsheet_by_key(opts[:key])\n end\n end",
"def get_spreadsheet(session, excel)\n\t\t#on recupere le fichier de notre drive\n\t\tfile = session.spreadsheet_by_title(excel)\n\n\t\t#je me positionne dans le 1er onglet de mon fichier spreadsheet drive (excel drive)\n\t\treturn onglet1 = file.worksheets[0]\n\tend",
"def save_as_spreadsheet\n\nsession = GoogleDrive::Session.from_config(\"config.json\")\n# First worksheet of\n# https://docs.google.com/spreadsheets/d/19fXbxVaXn9knKHPAQMuuMsiKH_Q50cN5jlj6K3H8VQc/edit#gid=0\nws = session.spreadsheet_by_key(\"19fXbxVaXn9knKHPAQMuuMsiKH_Q50cN5jlj6K3H8VQc\").worksheets[0]\n\n# Gets content of A2 cell.\n#p ws[2, 1] #==> \"hoge\"\n\n# Changes content of cells.\n# Changes are not sent to the server until you call ws.save().\n\nx = 1\n$my_hash.each do |key, value|\n\tws[x, 1] = key\n\tws[x, 2] = value\n\tx +=1\nend\nws.save\n\n# Dumps all cells.\n(1..ws.num_rows).each do |row|\n (1..ws.num_cols).each do |col|\n p ws[row, col]\n end\nend\n\n# Yet another way to do so.\np ws.rows #==> [[\"fuga\", \"\"], [\"foo\", \"bar]]\n\n# Reloads the worksheet to get changes by other clients.\nws.reload\nend",
"def initialize(spreadsheetkey,user=nil,password=nil)\n @filename = spreadsheetkey\n @spreadsheetkey = spreadsheetkey\n @user = user\n @password = password\n unless user\n user = ENV['GOOGLE_MAIL']\n end\n unless password\n password = ENV['GOOGLE_PASSWORD']\n end\n @cell = Hash.new {|h,k| h[k]=Hash.new}\n @cell_type = Hash.new {|h,k| h[k]=Hash.new}\n @formula = Hash.new\n @first_row = Hash.new\n @last_row = Hash.new\n @first_column = Hash.new\n @last_column = Hash.new\n @cells_read = Hash.new\n @header_line = 1\n @date_format = '%d/%m/%Y'\n @datetime_format = '%d/%m/%Y %H:%M:%S' \n @time_format = '%H:%M:%S'\n @gs = GData::Spreadsheet.new(spreadsheetkey)\n @gs.authenticate(user, password) unless user.empty? || password.empty?\n @sheetlist = @gs.sheetlist\n @default_sheet = self.sheets.first\n end",
"def spreadsheets(options={})\n unless @spreadsheets.nil?\n return @spreadsheets\n end\n SpreadsheetExtractionAlgorithm.new.extract(self).to_a.sort # to_a converts from java.util.ArrayList to Ruby Array\n end",
"def fetch\n return if fetched?\n\n ranges = fetch_ranges\n\n # Select which byte ranges to download\n records = Forecaster.configuration.records.values\n filtered_ranges = records.map { |k| ranges[k] }\n\n fetch_grib2(filtered_ranges)\n end",
"def data_responsible_person_sheet\r\n @book.worksheet(WBF[:people_sheet])\r\n end",
"def read_cells(sheet = nil)\n sheet ||= @default_sheet\n return if @cells_read[sheet] && !@cells_read[sheet].empty?\n each_row(sheet: sheet).each { |_row| }\n\n @cells_read[sheet]\n end",
"def sheets\n @sheetlist\n end",
"def index\n @nba = Googlesheet.find_by_sport('NBA')\n @nfl = Googlesheet.find_by_sport('NFL')\n @mlb = Googlesheet.find_by_sport('MLB')\n @pga = Googlesheet.find_by_sport('PGA')\n end",
"def getSheet\n case ftype\n when FTYPE_SHEET\n return Sheet.find_by_id(type_index)\n else # \n return nil\n end\n end",
"def descargar_calificaciones\n sitio_web = SitioWeb.sitio_actual(params[:asignatura_nombre],params[:semestre])\n\n if __es_del_grupo_docente\n\n Spreadsheet.client_encoding = 'UTF-8'\n book = Spreadsheet::Workbook.new\n\n bold = Spreadsheet::Format.new :weight => :bold\n \n sheets = []\n \n hoja = 0\n fila = 0\n col = 0\n\n tipos = [\"Teoría\",\"Práctica\",\"Laboratorio\",\"Otro\"]\n\n sitio_web.seccion_sitio_web.each_with_index do |seccion_sitio_web, index|\n sheet = book.create_worksheet :name => seccion_sitio_web.seccion.nombre.to_s\n fila = 0\n col = 0\n sheet[fila,col] = \"Sección: \"+seccion_sitio_web.seccion.nombre\n\n sheet.row(fila).set_format(col, bold)\n\n fila = 1\n sheet[fila,col] = \"Cédula\"\n sheet.row(fila).set_format(col, bold)\n col = 1\n\n sheet[fila,col] = \"Estudiante\"\n sheet.row(fila).set_format(col, bold)\n col = 2\n \n\n\n tipos.each do |tipo|\n if Evaluacion.where(:sitio_web_id => sitio_web.id, :tipo => tipo).size > 0\n Evaluacion.where(:sitio_web_id => sitio_web.id, :tipo => tipo).each do |evaluacion|\n sheet[fila,col] = evaluacion.nombre\n sheet.row(fila).set_format(col, bold)\n col += 1\n end\n sheet[fila,col] = \"Total \" + tipo\n sheet.row(fila).set_format(col, bold)\n col += 1\n end\n end\n\n sheet[fila,col] = \"Total\"\n sheet.row(fila).set_format(col, bold)\n\n \n\n fila += 1\n col = 0\n\n Usuario.order(:apellido, :nombre).where(:id => EstudianteSeccionSitioWeb.where(\n :seccion_sitio_web_id => seccion_sitio_web.id).collect{|x| x.estudiante_id}).each do |usuario|\n col = 0\n sheet[fila,col] = usuario.cedula\n col = 1\n sheet[fila,col] = (usuario.apellido + \" \" + usuario.nombre)\n col = 2\n\n total = 0\n suma = 0\n\n porcentaje = Evaluacion.where(:sitio_web_id => sitio_web.id).sum(\"valor\")\n\n tipos.each_with_index do |tipo|\n if Evaluacion.where(:sitio_web_id => sitio_web.id, :tipo => tipo).size > 0\n suma = 0\n Evaluacion.where(:sitio_web_id => sitio_web.id, :tipo => tipo).each do |evaluacion|\n if calificacion = Calificacion.where(:evaluacion_id => evaluacion.id, :estudiante_id => usuario.id).first\n if calificacion.calificacion\n sheet[fila,col] = calificacion.calificacion\n suma += (evaluacion.valor.to_f*calificacion.calificacion.to_f)\n end\n end\n col += 1\n end\n sheet[fila,col] = (suma/porcentaje).round(2)\n total += suma\n col += 1\n end\n end\n\n sheet[fila,col] = (total/porcentaje).round(2)\n sheet.row(fila).set_format(col, bold)\n fila += 1\n end\n\n sheets[hoja] = sheet\n end\n\n\n\n ruta = (\"#{Rails.root}/doc/calificaciones/calificaciones.xls\").to_s\n\n book.write ruta\n\n send_file ruta, :filename => \"Calificaciones de \"+sitio_web.asignatura.nombre + \" \" + sitio_web.periodo + \".xls\"\n\n return\n end\n\n flash[:error] = \"Parece que no se puede realizar la descarga en este momento. Inténtelo nuevamente.\"\n redirect_to :back\n end",
"def csv_data\n case\n when google_key || url then Curl::Easy.perform(uri).body_str\n when file then File.open(uri).read\n end\n end",
"def spreadsheet_by_title(title)\n return spreadsheets(\"q\" => [\"title = ?\", title], \"maxResults\" => 1)[0]\n end",
"def go_through_all_the_lines(worksheet_key)\n\n\tdata = []\n\tworksheet = get_worksheet(worksheet_key)\n\n\t# create an array called data in order to store all the emails\n\nworksheet.rows.each do |row|\n\n\t# for each of line of the row we add it into the \"data array\"\n\n\t data << row[1].gsub(/[[:space:]]/, '')\n end \n \n return data\nend",
"def read_cells(sheet=nil)\n sheet = @default_sheet unless sheet\n raise RangeError, \"illegal sheet <#{sheet}>\" unless sheets.index(sheet)\n sheet_no = sheets.index(sheet)+1\n xml = @gs.fulldoc(sheet_no).to_s\n doc = XML::Parser.string(xml).parse\n doc.find(\"//*[local-name()='cell']\").each do |item|\n row = item['row']\n col = item['col']\n key = \"#{row},#{col}\"\n string_value = item['inputvalue'] || item['inputValue'] \n numeric_value = item['numericvalue'] || item['numericValue'] \n (value, value_type) = determine_datatype(string_value, numeric_value)\n @cell[sheet][key] = value unless value == \"\" or value == nil\n @cell_type[sheet][key] = value_type \n @formula[sheet] = {} unless @formula[sheet]\n @formula[sheet][key] = string_value if value_type == :formula\n end\n @cells_read[sheet] = true\n end",
"def index\n @sheet_bs = SheetB.all\n end",
"def spreadsheet_by_url(url)\n file = file_by_url(url)\n if !file.is_a?(Spreadsheet)\n raise(GoogleDrive::Error, \"The file with the URL is not a spreadsheet: %s\" % url)\n end\n return file\n end",
"def sheets?\n @gapi.source_format == \"GOOGLE_SHEETS\"\n end",
"def spreadsheets(params = {}, &block)\n params = convert_params(params)\n query = construct_and_query([\n \"mimeType = 'application/vnd.google-apps.spreadsheet'\",\n params[\"q\"],\n ])\n return files(params.merge({\"q\" => query}), &block)\n end",
"def fetch_data(connection,path,definition)\n @definition=definition\n @headers = definition.data_headers\n @headers.delete_if {|x| x=='source'}\n @raw_headers=headers # headers are the full set here\n items = []\n page = 1\n while page <= AMEE::Data::Category.get(connection, \"/data#{path}\").pager.last_page do\n category = AMEE::Data::Category.get(connection, \"/data#{path}\", { 'page' => \"#{page}\" })\n category.items.each do |item|\n items << item\n end\n page += 1\n end\n parse_api_rows items\n end",
"def spreadsheet\n @items = Item.all.order(id: :desc)\n end",
"def save_as_spreadsheet\n session = GoogleDrive::Session.from_config('./config.json')\n key = '1cAn303rPBOi1d2O0j4tQuGi5FZksD2yVAzNQd57cDns'\n ws = session.spreadsheet_by_key(key).worksheets[0]\n i = 1\n get_townhall_url.sto_a.each do |x|\n ws[i, 1] = x[0]\n ws[i, 2] = x[1]\n i += 1\n end\n ws.save\n puts \"\\nTon fichier google est prêt\\n\\n\"\n Index.new.index\n end",
"def data(options = {})\n sheetname = options[:sheetname]\n column = options[:column]\n filename = options[:filename]\n\n data = []\n\n spreadsheet = Roo::Spreadsheet.open(filename)\n\n csv = CSV.parse(spreadsheet.sheet(sheetname).to_csv, { :headers => true })\n\n csv.each do |row|\n country = Country.find_by_name(row['Region'])\n next unless country\n\n # Get all quarterly cells\n #row.select{|h,v| h.match(/Q\\d \\d{4}/)}.each do |header, value|\n quarter, year = *sheetname.split(' ')\n start_date = Date.new(year.to_i, QUARTER_MAP[quarter][0], QUARTER_MAP[quarter][1])\n\n value = row[ column ].to_f\n if options[ :multiplier ].present?\n value *= options[ :multiplier ]\n end\n\n i = Indicator.new( :start_date => start_date, :original_value => value )\n i.country = country\n data << i\n #end\n end\n data\n end",
"def save_as_spreadsheet\n session = GoogleDrive::Session.from_config(\"../config.json\")\n ws = session.spreadsheet_by_key(ENV['SPREADSHEET_KEY']).worksheets[0]\n ws.reload\n i = 0\n n = get_townhall_urls.count\n while i <= 4\n ws[i+1, 1] = @emails[i]\n ws[i+1, 2] = @names_of_town[i]\n i +=1\n end\n ws.save\n end",
"def index\n \n #@sheets = Sheet.include(:game).where(\"user_id = ?\", current_user.id)\n @sheets = current_user.sheets.includes(:game)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sheets }\n end\n end",
"def get_townhall_urls\n \tnames_arr = []\n \temails_arr = []\n \turls_arr = []\n \t\n\tpage = Nokogiri::HTML(open(\"http://annuaire-des-mairies.com/val-d-oise.html\"))\n\tnames = page.xpath('//tr/td/p/a').each do |name|#Voici la liste du nom des villes\n\tnames_arr.push(name.text)\n\tputs names_arr \n end\n\t\t\n\turls = page.xpath('//a[contains(@href, \"95\")]/@href').each do |url|\n\turls_arr.push(url.value)\n\t\t\t \n\tend\n\n\turls_arr.each do |url|\n\tcom = \"http://annuaire-des-mairies.com/\"+url\n\temails_arr.push(get_townhall_email(com))#Voici la liste des emails pour chaque ville\n\t\t\t\n\tend\n\n\tmy_hash = names_arr.zip(emails_arr).to_h\n\treturn my_hash\n\n def file_json(my_hash)\n\tFile.open('./db/emails.json', \"w\") do |json|\n\tjson << my_hash.to_json\n \tend\n end\n\n\tdata = get_townhall_urls\n\tfile_json(data)\n\t\n#-----------------------------------------------------------------------------------------------------------------------\n\t\t\n def spreadsheet\n\tindex = 1\n\tsession GoogleDrive::Session.from_config(\"config.json\")\n\tws = session.spreadsheet_by_key(\"157NepG10EpvxtEhokrNWlma16BjTeD8bQDovwKxQlwY\").worksheets[0]\n\t@@my_hash.each_key do |key|\n\tws[index, 1]\t= key\n\tws[index, 2] = @@my_hash[key]\n\tindex += 1\n\t end\n\tws.save\n\tws.reload\n end\n def csv\n\t File.open(\"./db/email.csv\", \"w\") do |f|\n f << @@my_hash.map { |c| c.join(\",\")}.join(\"\\n\")\n end \n end\nend",
"def fetch\n # NOTE: have sample data from TCP K072\n puts params\n resp = {}\n resp['sEcho'] = params[:sEcho]\n resp['iTotalRecords'] = Work.count()\n \n # generate order info based on params\n search_col_idx = params[:iSortCol_0].to_i\n cols = [nil,nil,nil,nil,'wks_work_id',\n 'wks_tcp_number','wks_title','wks_author',\n 'work_ocr_results.ocr_completed','work_ocr_results.ocr_engine_id',\n 'work_ocr_results.batch_id','work_ocr_results.juxta_accuracy',\n 'work_ocr_results.retas_accuracy']\n dir = params[:sSortDir_0]\n order_col = cols[search_col_idx]\n order_col = cols[4] if order_col.nil?\n\n # stuff filter params in session so they can be restored each view\n session[:search] = params[:sSearch]\n session[:gt] = params[:gt]\n session[:batch] = params[:batch]\n session[:set] = params[:set]\n session[:from] = params[:from]\n session[:to] = params[:to]\n session[:ocr] = params[:ocr]\n session[:font] = params[:font]\n \n # generate the select, conditional and vars parts of the query\n # the true parameter indicates that this result should include\n # all columns necessry to populate the dashboard view.\n sel, where_clause, vals = generate_query()\n\n # build the ugly query\n limits = \"limit #{params[:iDisplayLength]} OFFSET #{params[:iDisplayStart]}\"\n order = \"order by #{order_col} #{dir}\"\n if session[:ocr] == 'ocr_sched'\n # scheduled uses a different query that needs a group by to make the results work\n sql = [\"#{sel} #{where_clause} group by work_id, batch_id #{order} #{limits}\"] \n else\n sql = [\"#{sel} #{where_clause} #{order} #{limits}\"] \n end\n \n sql = sql + vals\n\n # get all of the results (paged)\n results = WorkOcrResult.find_by_sql(sql)\n \n # run a count query without the paging limits to get\n # the total number of results available\n pf_join = \"left outer join print_fonts on pf_id=wks_primary_print_font\"\n if session[:ocr] == 'ocr_sched'\n # search for scheduled uses different query to get data. Also need slightly\n # differnent query to get counts\n count_sel = \"select count(distinct batch_id) as cnt from works #{pf_join} inner join job_queue on wks_work_id=job_queue.work_id \"\n else\n count_sel = \"select count(*) as cnt from works #{pf_join} left outer join work_ocr_results on wks_work_id=work_id \"\n end\n sql = [\"#{count_sel} #{where_clause}\"]\n sql = sql + vals\n filtered_cnt = Work.find_by_sql(sql).first.cnt\n \n # jam it all into an array of objects that match teh dataTables structure\n data = []\n results.each do |result|\n rec = result_to_hash(result) \n data << rec \n end\n \n resp['data'] = data\n resp['iTotalDisplayRecords'] = filtered_cnt\n render :json => resp, :status => :ok\n end",
"def get_calendars\r\n http = Net::HTTP.new(@google_url, 80)\r\n response, data = http.get(\"http://#{@google_url}/calendar/feeds/\" + @user_id, @headers)\r\n case response\r\n when Net::HTTPSuccess, Net::HTTPRedirection\r\n redirect_response, redirect_data = http.get(response['location'], @headers)\r\n case response\r\n when Net::HTTPSuccess, Net::HTTPRedirection\r\n doc = REXML::Document.new redirect_data\r\n \t doc.elements.each('//entry')do |e|\r\n \t title = e.elements['title'].text\r\n \t url = e.elements['link'].attributes['href']\r\n \t @calendars << GCalendar.new(title, url.sub!(\"http://#{@google_url}\",''))\r\n \t end\r\n return redirect_response\r\n else\r\n response.error!\r\n end\r\n else\r\n response.error!\r\n end\r\n end",
"def reload!\n fetch_data!\n end",
"def newSheet(table, taskName, id=nil)\n # open the Google Sheet service\n service = Google::Apis::SheetsV4::SheetsService.new\n service.client_options.application_name = APPLICATION_NAME\n service.authorization = authorize\n\n # open the Google Drive service\n drive = Google::Apis::DriveV3::DriveService.new\n drive.client_options.application_name = APPLICATION_NAME\n drive.authorization = authorize\n puts \"id in export sheet\"\n puts id\n\n #create a new sheet\n if id == nil\n\n spreadsheet = {\n properties: {\n title: taskName\n }\n }\n spreadsheet = service.create_spreadsheet(spreadsheet,\n fields: 'spreadsheetId')\n puts \"Spreadsheet ID: #{spreadsheet.spreadsheet_id}\"\n #fill the sheet with the data 'table'\n data = [\n {\n range: 'A:Z',\n majorDimension: \"ROWS\",\n values: table,\n }\n ]\n value_range_object = Google::Apis::SheetsV4::ValueRange.new(range: 'A:Z',\n majorDimension: \"ROWS\",\n values: table)\n result = service.update_spreadsheet_value(spreadsheet.spreadsheet_id,\n 'A:Z',\n value_range_object,\n value_input_option: 'RAW')\n puts = \"#{result.updated_cells} cells updated.\"\n file = drive.get_file(spreadsheet.spreadsheet_id)\n puts \"Create this file name: #{file.name}\"\n id = spreadsheet.spreadsheet_id\n\n ##\n # change the permision of the created file\n # line in google-api-ruby-client/lib/google/apis/core/api_command.rb return {} and make and error.\n # self.body = request_representation.new(request_object).to_json(user_options: { skip_undefined: true })\n #\n data = \n {\n \"role\" => \"writer\",\n \"type\" => \"anyone\"\n }\n # byebug\n permision = drive.create_permission(id, data.to_json,\n options: {skip_serialization: true})\n \n link = \"https://docs.google.com/spreadsheets/d/#{file.id}\"\n puts \"use this link: #{link}\"\n \n return link\n ##\n # Updating the file with new information\n else\n id = id.split('/')[5]\n file = drive.get_file(id)\n #geting the info of the sheet\n get_celds = service.get_spreadsheet_values(id, 'A:C')\n #byebug\n puts get_celds.values.length\n n = get_celds.values.length + 1\n range = \"A#{n}:B#{n}\"\n #write!\n value_range_object = Google::Apis::SheetsV4::ValueRange.new(range: range,\n values: table)\n result = service.update_spreadsheet_value(id,\n range,\n value_range_object,\n value_input_option: 'RAW')\n puts \"Updating this: #{file.name}\"\n link = \"https://docs.google.com/spreadsheets/d/#{file.id}\"\n puts \"use this link: #{link}\"\n return link\n end\nend",
"def readCSV( file )\n\n data = []\n\n CSV.new( open( \"https://docs.google.com/spreadsheets/d/1uTnHOsDCHwvxmxX41sxCsZDnkPNj_7ImUGYQb3yEMjo/export?format=csv&gid=1137121615\" ) ).each_with_index do | row, row_index |\n # CSV.foreach( file, headers: true ) do | row |\n data << row\n end\n\n return data\n\n end",
"def get_sps_feed(sps_client)\n @sps_feed=sps_client.get(\"https://spreadsheets.google.com/feeds/spreadsheets/private/full?prettyprint=true\").to_xml\n return @sps_feed\n end",
"def excel_calculate_sheet(sheet)\n excel_calculated_cells.clear\n\n # Iterate over the used range calculating each cell.\n # The result of each cell is then saved.\n data = []\n begin\n sheet.UsedRange.Rows.each do |row|\n data << row_data = []\n row.Cells.each do |cell|\n # Calculate the cell if required.\n excel_calculate_cell(cell) if cell.HasFormula\n # Get the un-formatted value of this field.\n value = cell.Value2\n row_data << value\n end\n end\n rescue\n @logger.error(format_exception)\n data << [\"#{$!.message} (#{$!.class.name})\"]\n data << [$!.backtrace.join(\"\\n\")]\n end\n # Return the 2d array with all the data.\n data\n end",
"def fetch; @data = pager.fetcher[self.begin, pager.per_page]; end",
"def extract_data_from_worksheets\n worksheets do |name, xml_filename|\n \n extract ExtractValues, xml_filename, [name, 'Values']\n apply_rewrite RewriteValuesToAst, [name, 'Values']\n \n extract ExtractSimpleFormulae, xml_filename, [name, 'Formulae (simple)']\n apply_rewrite RewriteFormulaeToAst, [name, 'Formulae (simple)']\n\n extract ExtractSharedFormulae, xml_filename, [name, 'Formulae (shared)']\n apply_rewrite RewriteFormulaeToAst, [name, 'Formulae (shared)']\n\n extract ExtractSharedFormulaeTargets, xml_filename, [name, 'Formulae (shared targets)']\n\n extract ExtractArrayFormulae, xml_filename, [name, 'Formulae (array)']\n apply_rewrite RewriteFormulaeToAst, [name, 'Formulae (array)']\n \n extract_tables_for_worksheet(name,xml_filename)\n end\n end",
"def extract_data(args = {})\n sheet_data.rows.map { |row|\n row.cells.map { |c| c && c.value(args) } unless row.nil?\n }\n end",
"def getwebsite()\n\tpage = Nokogiri::HTML(open(\"https://annuaire-des-mairies.com/val-d-oise.html\"))\n\tsession = GoogleDrive::Session.from_config(\"config.json\")\n\tws = session.spreadsheet_by_key(\"1v7XEnpGDtgjgRom3bp7OwzaK99zlUQIfKuW3QdawXBc\").worksheets[0]\n\tcities = \"\"\n\ti = 1\n\t#define a loop for list of emails\n\tpage.css('a.lientxt').each do |town|\n\t\tsite = \"https://annuaire-des-mairies.com\" + town['href'][1..-1]\n\t\tcities = town.text\n\t\tws[(i), 1] = cities\n\t\tws[(i), 2] = getemail(site)\n\t\ti += 1\n\tend\n\tws.save\nend",
"def read_cells(sheet = default_sheet)\n validate_sheet!(sheet)\n return if @cells_read[sheet]\n\n sheet_found = false\n doc.xpath(\"//*[local-name()='table']\").each do |ws|\n next unless sheet == attribute(ws, 'name')\n\n sheet_found = true\n col = 1\n row = 1\n ws.children.each do |table_element|\n case table_element.name\n when 'table-column'\n @style_defaults[sheet] << table_element.attributes['default-cell-style-name']\n when 'table-row'\n if table_element.attributes['number-rows-repeated']\n skip_row = attribute(table_element, 'number-rows-repeated').to_s.to_i\n row = row + skip_row - 1\n end\n table_element.children.each do |cell|\n skip_col = attribute(cell, 'number-columns-repeated')\n formula = attribute(cell, 'formula')\n value_type = attribute(cell, 'value-type')\n v = attribute(cell, 'value')\n style_name = attribute(cell, 'style-name')\n case value_type\n when 'string'\n str_v = ''\n # insert \\n if there is more than one paragraph\n para_count = 0\n cell.children.each do |str|\n # begin comments\n #=begin\n #- <table:table-cell office:value-type=\"string\">\n # - <office:annotation office:display=\"true\" draw:style-name=\"gr1\" draw:text-style-name=\"P1\" svg:width=\"1.1413in\" svg:height=\"0.3902in\" svg:x=\"2.0142in\" svg:y=\"0in\" draw:caption-point-x=\"-0.2402in\" draw:caption-point-y=\"0.5661in\">\n # <dc:date>2011-09-20T00:00:00</dc:date>\n # <text:p text:style-name=\"P1\">Kommentar fuer B4</text:p>\n # </office:annotation>\n # <text:p>B4 (mit Kommentar)</text:p>\n # </table:table-cell>\n #=end\n if str.name == 'annotation'\n str.children.each do |annotation|\n next unless annotation.name == 'p'\n # @comment ist ein Hash mit Sheet als Key (wie bei @cell)\n # innerhalb eines Elements besteht ein Eintrag aus einem\n # weiteren Hash mit Key [row,col] und dem eigentlichen\n # Kommentartext als Inhalt\n @comment[sheet] = Hash.new unless @comment[sheet]\n key = [row, col]\n @comment[sheet][key] = annotation.text\n end\n end\n # end comments\n if str.name == 'p'\n v = str.content\n str_v += \"\\n\" if para_count > 0\n para_count += 1\n if str.children.size > 1\n str_v += children_to_string(str.children)\n else\n str.children.each do |child|\n str_v += child.content #.text\n end\n end\n str_v = str_v.gsub(/'/, \"'\") # special case not supported by unescapeHTML\n str_v = CGI.unescapeHTML(str_v)\n end # == 'p'\n end\n when 'time'\n cell.children.each do |str|\n v = str.content if str.name == 'p'\n end\n when '', nil, 'date', 'percentage', 'float'\n #\n when 'boolean'\n v = attribute(cell, 'boolean-value').to_s\n end\n if skip_col\n if !v.nil? || cell.attributes['date-value']\n 0.upto(skip_col.to_i - 1) do |i|\n set_cell_values(sheet, col, row, i, v, value_type, formula, cell, str_v, style_name)\n end\n end\n col += (skip_col.to_i - 1)\n end # if skip\n set_cell_values(sheet, col, row, 0, v, value_type, formula, cell, str_v, style_name)\n col += 1\n end\n row += 1\n col = 1\n end\n end\n end\n doc.xpath(\"//*[local-name()='automatic-styles']\").each do |style|\n read_styles(style)\n end\n\n fail RangeError unless sheet_found\n\n @cells_read[sheet] = true\n @comments_read[sheet] = true\n end",
"def sheet()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Sheet::SheetRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def data\n retrieve_data\n end",
"def send_email_through_data(gmail)\n gmail = gmail\n read_hash(gmail,read_json)\n end",
"def index\n @sites = Site.all.order(:created_at)\n\n # @debug = scrape_all\n # @debug = scrape 'http://workingnews.blog117.fc2.com/?xml'\n \n # @spreadsheet = GoogleSpreadsheets::Enhanced::Spreadsheet.find('0ArhV7gTgs6Z8dHlSRUF2SzFXWjlkU1V2d29KR2pkdXc')\n # @worksheet = @spreadsheet.worksheets.find_by(title: 'site_rows')\n # @rows = @worksheet.rows\n # @site_rows = Site.site_rows\n \n # 同期実行\n # Site.sync_with_site_rows\n\n # スクレイピング\n # ApplicationController.helpers.scrape_update\n # ApplicationController.helpers.scrape \"http://alfalfalfa.com/index.rdf\"\n\n respond_to do |format|\n if Rails.env.development?\n format.html { render :html => @sites }\n end\n format.json { render :json => @sites.as_json }\n end\n end",
"def get_cell(cell)\n query_cell_info '/cell/get', cell\n end",
"def update_spreadsheet\n\t\tconnection = GoogleDrive.login(ENV[\"GMAIL_USERNAME\"], ENV[\"GMAIL_PASSWORD\"])\n\t\tss = connection.spreadsheet_by_title('Learn-Rails-Example')\n\t\tif ss.nil?\n\t\t\tss = connection.create_spreadsheet('Learn-Rails-Example')\n\t\tend\n\t\tws = ss.worksheets[0]\n\t\tlast_empty_row = 1 + ws.num_rows\n\t\tws[last_empty_row, 1] = Time.new\n\t\tws[last_empty_row, 2] = self.name\n\t\tws[last_empty_row, 3] = self.email\n\t\tws[last_empty_row, 4] = self.content\n\t\tws.save\n\tend",
"def get_data\n if @url\n @page = fetch_url(@url)\n @parse_time = parse_dailydev_page\n @page = nil\n self.total_time\n end\n end",
"def batch_update(batch_data, cellfeed_uri)\n batch_uri = cellfeed_uri + '/batch'\n\n batch_request = <<FEED\n<?xml version=\"1.0\" encoding=\"utf-8\"?> \\\n <feed xmlns=\"http://www.w3.org/2005/Atom\" \\\n xmlns:batch=\"http://schemas.google.com/gdata/batch\" \\\n xmlns:gs=\"http://schemas.google.com/spreadsheets/2006\" \\\n xmlns:gd=\"http://schemas.google.com/g/2005\">\n <id>#{cellfeed_uri}</id>\nFEED\n\n batch_data.each do |batch_request_data|\n version_string = get_version_string(cellfeed_uri + '/' +\n batch_request_data[:cell_id])\n data = batch_request_data[:data]\n batch_id = batch_request_data[:batch_id]\n cell_id = batch_request_data[:cell_id]\n row = batch_request_data[:cell_id][1,1]\n column = batch_request_data[:cell_id][3,1]\n edit_link = cellfeed_uri + '/' + cell_id + '/' + version_string\n \n batch_request<< <<ENTRY\n <entry>\n <gs:cell col=\"#{column}\" inputValue=\"#{data}\" row=\"#{row}\"/>\n <batch:id>#{batch_id}</batch:id>\n <batch:operation type=\"update\" />\n <id>#{cellfeed_uri}/#{cell_id}</id>\n <link href=\"#{edit_link}\" rel=\"edit\" type=\"application/atom+xml\" />\n </entry>\nENTRY\n end\n \n batch_request << '</feed>'\n return post(batch_uri, batch_request)\n end",
"def [](row = 0)\n sheet_data[row]\n end",
"def get_all_the_urls_of_val_doise_townhalls\n \n #declare un hash vide \n @my_hash = Hash.new {}\n\n #on recupere tout le code de annuaire...\n val_doise = Nokogiri::HTML(open(\"http://annuaire-des-mairies.com/val-d-oise.html\"))\n #tout les a des communes\n a_des_communes = val_doise.css(\"a\")\n a_des_communes.each do |a_d_une_commune|\n #tout les href des communes\n url_commune = a_d_une_commune['href']\n #on recup tout les url qui contiennent 95\n if rege = url_commune =~ (/95/)\n mairie_name = a_d_une_commune.text #on recup le texte \"nom de commune\"\n # ensuite on change le . par https://...com\n url_commune[0] = \"http://annuaire-des-mairies.com\"\n # et on envoie l'adresse dans la fonction pour recup l'adresse mail \n mairie_mail = get_the_email_of_a_townhal_from_its_webpage(url_commune) \n # et ensuite on rempli notre hash avec nom et mail\n @my_hash[mairie_name] = mairie_mail\n end\n end\n \n tempHash = {}\n #et on print proprement\n session = GoogleDrive::Session.from_config(\"./config.json\")\n\n ws = session.spreadsheet_by_key(\"1gpKzo_6gH78KdlhfEqrxS6xpgKLbnoBqoEVeV0W4tZQ\").worksheets[0]\n compteur = 1\n @my_hash.each do |key, val|\n\n ws[compteur, 1] = key\n ws[compteur, 2] = val\n compteur +=1\n puts \"Adresse mail de : #{key} - #{val}\"\n end\n ws.save\n # binding.pry\n end",
"def get_multiple_sheet_values(spreadsheet_id, sheets: nil, value_render_option: :unformatted_value)\n sheets ||= self.get_sheets(spreadsheet_id)\n value_ranges = self.get_multiple_ranges(spreadsheet_id, \n sheets: sheets, \n value_render_option: value_render_option)\n result = {}\n value_ranges.each do |value_range|\n tab_name = self.get_range_parts(value_range.range)[0]\n result[tab_name] = value_range.values\n end\n result\n end",
"def read_cells(sheet = default_sheet)\n validate_sheet!(sheet)\n return if @cells_read[sheet]\n\n ws = worksheets[sheets.index(sheet)]\n for row in 1..ws.num_rows\n for col in 1..ws.num_cols\n read_cell_row(sheet, ws, row, col)\n end\n end\n @cells_read[sheet] = true\n end"
] | [
"0.6932061",
"0.66842407",
"0.66727114",
"0.6572149",
"0.6510849",
"0.6304237",
"0.63012975",
"0.6237194",
"0.62339646",
"0.62320703",
"0.619917",
"0.615057",
"0.6117842",
"0.61017716",
"0.6063502",
"0.6045861",
"0.60454655",
"0.6030018",
"0.601348",
"0.60029036",
"0.59935117",
"0.5978085",
"0.5978085",
"0.59433484",
"0.5919828",
"0.5912982",
"0.58923596",
"0.5886365",
"0.5882325",
"0.587305",
"0.5843254",
"0.582191",
"0.57919514",
"0.5713559",
"0.5701643",
"0.5696166",
"0.5662455",
"0.5658136",
"0.56358826",
"0.561026",
"0.5601683",
"0.5601154",
"0.5592245",
"0.5588805",
"0.55871534",
"0.55751044",
"0.5570574",
"0.5570276",
"0.5551872",
"0.5535261",
"0.552279",
"0.5479841",
"0.5479228",
"0.5472503",
"0.54260683",
"0.5421813",
"0.54167384",
"0.5411359",
"0.5410952",
"0.5395968",
"0.53946483",
"0.53639454",
"0.5359237",
"0.53543967",
"0.53424346",
"0.5339803",
"0.53294235",
"0.5323546",
"0.5318053",
"0.53144145",
"0.5306559",
"0.52978784",
"0.52912426",
"0.52794313",
"0.52651966",
"0.5265083",
"0.5241078",
"0.5241023",
"0.52402973",
"0.5229119",
"0.5227171",
"0.5224515",
"0.5215516",
"0.5214231",
"0.52107316",
"0.52100396",
"0.5206977",
"0.51976264",
"0.5192411",
"0.51771724",
"0.51748896",
"0.5172843",
"0.516692",
"0.51474607",
"0.5144715",
"0.5106799",
"0.50974834",
"0.5096011",
"0.5090467",
"0.50859654",
"0.5071828"
] | 0.0 | -1 |
Takes the google sheet response and generates all the groups from it | def adjust_groups(response)
Group.destroy_all
delete_matches(response)
create_groups(response)
redirect_to root_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getGroups\n groups = $gm.get(\"/groups\", @token, \"per_page=100\")\n group_ids = Array.new\n\n groups['response'].each do |group|\n group_ids.push({\n 'name' => group['name'],\n 'group_id' => group['id'],\n 'image' => group['image_url']})\n end\n\n return group_ids\n end",
"def groups\n response[\"groups\"].map!{|group| Foursquared::Response::BadgeGroup.new(client, group)}\n end",
"def generate_groups(groups, type)\r\n [].tap do |results|\r\n groups.each do |n, obj|\r\n group = {}\r\n group[\"name\"] = obj['name']\r\n group[\"code\"] = n\r\n group[\"risk_category\"] = \"AUTO\"\r\n group[type] = obj[type]\r\n results << group\r\n end\r\n end\r\nend",
"def fetch_group_data\n response = fetch_data(@@SETTINGS.group_tab)\n unless response.nil?\n adjust_groups response\n end\n end",
"def group_data_from_results(res, groupname, key)\n groups = res['groups']\n groups.each do |group|\n return group[key] if group['group_name'] == groupname\n end\n nil\n end",
"def list_groups()\n response = HTTParty.get(\"https://graph.microsoft.com/v1.0/groups\", { \n headers: {\n \"Authorization\" => \"Bearer #{bearerToken}\",\n \"Host\" => 'graph.microsoft.com' \n }\n })\n return JSON.parse response.read_body\n end",
"def get_groups_in_group_set(group_set_id)\n group_set_data = Array.new\n\n @url = \"http://#{$canvas_host}/api/v1/group_categories/#{group_set_id}/groups\"\n puts \"@url is #{@url}\"\n \n @getResponse = HTTParty.get(@url, :headers => $header)\n puts(\" GET to get groups in group set has Response.code #{@getResponse.code} and getResponse is #{@getResponse}\")\n group_set_data.append(@getResponse.parsed_response)\n\n while $link_parser.parse(@getResponse).by_rel('next')\n @url = $link_parser.parse(@getResponse).by_rel('next').target\n puts \"@url is #{@url}\"\n\n @getResponse = HTTParty.get(@url, :headers => $header)\n puts(\" GET to get groups in group set has Response.code #{@getResponse.code} and getResponse is #{@getResponse}\")\n \n group_set_data.append(@getResponse.parsed_response)\n end\n\n if @getResponse.empty?\n puts \"WARNING: No groups found in group set, program may not function correctly!\"\n end\n\n return group_set_data\nend",
"def list(response)\n requested_group = response.args[1]\n output = get_groups_list(response.args[1])\n if output.empty?\n response.reply(empty_state_for_list(requested_group))\n else\n response.reply(output.join(\"\\n\"))\n end\n end",
"def belonging_groups\n contact_groups = []\n @contact.contact_groups.each do |group|\n contact_groups << { _id: group['_id'].to_s, lbl: group['label'] }\n end\n\n respond_to do |format|\n format.js {}\n format.json { render json: contact_groups }\n end\n end",
"def group_ids_by_name\n reversed = assignment.groups.pluck(:group_name, :id).to_h\n respond_to do |format|\n format.xml do\n render xml: reversed.to_xml(root: 'groups', skip_types: 'true')\n end\n format.json do\n render json: reversed.to_json\n end\n end\n end",
"def groups\n find(:group).map { |g| g.content }\n end",
"def convert_groups(json)\n hash = JSON.parse(json)\n hash.map{|gr| FilmOn::Group.new(gr)}\n end",
"def existing_ce_group\n self.refresh_access_token!\n\n response = @oauth_access_token.get(\n 'https://www.google.com/m8/feeds/groups/default/full?max-results=100000',\n {\n headers: {\n 'Content-type' => 'application/atom+xml',\n 'GData-Version' => '3.0'\n }\n }\n ).body\n\n doc = Nokogiri::XML(response)\n\n ids = doc.xpath('//atom:entry/atom:id', {'atom' => ATOM_NAMESPACE}).map do |e|\n e.content.split('/')[-1]\n end\n\n titles = doc.xpath('//atom:entry/atom:title', {'atom' => ATOM_NAMESPACE}).map do |e|\n e.content\n end\n\n entries = Hash[titles.zip(ids)]\n entries['Contact Exchange']\n end",
"def get_gear_groups(gear_env)\n broker_addr = @config.get('BROKER_HOST')\n domain = gear_env['OPENSHIFT_NAMESPACE']\n app_name = gear_env['OPENSHIFT_APP_NAME']\n url = \"https://#{broker_addr}/broker/rest/domains/#{domain}/applications/#{app_name}/gear_groups.json\"\n\n params = broker_auth_params\n\n request = RestClient::Request.new(:method => :get,\n :url => url,\n :timeout => 30,\n :headers => { :accept => 'application/json;version=1.0', :user_agent => 'OpenShift' },\n :payload => params)\n\n response = request.execute\n\n if 300 <= response.code\n raise response\n end\n\n gear_groups = JSON.parse(response)\n\n gear_groups\n end",
"def groups\n result = []\n each_element('group') { |group|\n result.push(group.text)\n }\n result\n end",
"def groups\n result = []\n each_element('group') { |group|\n result.push(group.text)\n }\n result\n end",
"def add_ce_group\n self.refresh_access_token!\n\n haml_template = File.read(File.join(TEMPLATES_DIR, 'group.xml.haml'))\n request_body = Haml::Engine.new(haml_template, remove_whitespace: true).render(Object.new)\n\n @response = @oauth_access_token.post(\n 'https://www.google.com/m8/feeds/groups/default/full',\n {\n body: request_body,\n headers: {\n 'Content-type' => 'application/atom+xml',\n 'GData-Version' => '3.0'\n }\n }\n )\n\n group_id = GROUP_REGEX.match(@response.body)[1]\n\n @response.status == 201 ? group_id : nil\n end",
"def test_data_extraction\n\t\tYAML.load_file('test/groups.yml')[\"groups\"].each do |g_data|\n\t\t\tstub_request(:get, g_data[\"url\"]).\n\t\t\tto_return(:status => 200, :body => File.read(\"test/yahoo_pages/#{g_data['id']}.html\"), :headers => {})\n\n\t\t\tgroup = YahooGroupData.new(g_data[\"url\"])\n\t\t\tassert_equal g_data[\"age_restricted\"], group.age_restricted?\n\t\t\tassert_equal g_data[\"private\"], group.private?\n\t\t\tassert_equal g_data[\"not_found\"], group.not_found?\n\t\t\tassert_equal g_data[\"name\"], group.name\n\t\t\tassert_equal g_data[\"description\"], group.description\n\t\t\tassert_equal g_data[\"post_email\"], group.post_email\n\t\t\tassert_equal g_data[\"subscribe_email\"], group.subscribe_email\n\t\t\tassert_equal g_data[\"owner_email\"], group.owner_email\n\t\t\tassert_equal g_data[\"unsubscribe_email\"], group.unsubscribe_email\n\t\t\tassert_equal g_data[\"founded\"], group.founded\n\t\t\tassert_equal g_data[\"language\"], group.language\n\t\t\tassert_equal g_data[\"num_members\"], group.num_members\n\t\t\tassert_equal g_data[\"category\"], group.category\n\t\tend\n\tend",
"def build_grouping_body\n arr = []\n data.each do |_,group| \n arr << render_group(group, options)\n end\n output << arr.join(\",\\n\")\n end",
"def get_site_groups_from_google(site)\n require 'rubygems'\n gem 'soap4r', '= 1.5.8'\n require 'adwords4r'\n\n begin\n creds_production = {\n 'developerToken' => 'L3uOSV00fo-qDhGm1tjLOA',\n 'applicationToken' => 'GtZ2GUP_anEkBpcQIaAsQA',\n 'useragent' => 'Ruby Sample',\n 'password' => '4ax52aws',\n 'email' => '[email protected]',\n 'clientEmail' => '[email protected]',\n 'environment' => 'PRODUCTION',\n }\n\n creds_sandbox = {\n 'developerToken' => '[email protected]++USD',\n 'useragent' => 'Sample User Agent',\n 'password' => '4ax52aws',\n 'email' => '[email protected]',\n 'clientEmail' => '[email protected]',\n 'applicationToken' => 'IGNORED',\n 'environment' => 'SANDBOX',\n }\n\n adwords = AdWords::API.new(AdWords::AdWordsCredentials.new(creds_production))\n # adwords = AdWords::API.new\n\n languages = %w{en}\n countries = %w{US}\n follow_links = false\n\n keyword_service = adwords.get_service(13, 'KeywordTool')\n kws = keyword_service.getKeywordsFromSite(site,follow_links,languages,countries)\n\n kws.getKeywordsFromSiteReturn.groups\n\n rescue Errno::ECONNRESET, SOAP::HTTPStreamError, SocketError => e\n # This exception indicates a connection-level error.\n # In general, it is likely to be transitory.\n puts 'Connection Error: %s' % e\n puts 'Source: %s' % e.backtrace.first\n\n rescue AdWords::Error::UnknownAPICall => e\n # This exception is thrown when an unknown SOAP method is invoked.\n puts e\n puts 'Source: %s' % e.backtrace.first\n\n rescue AdWords::Error::ApiError => e\n # This exception maps to receiving a SOAP Fault back from the service.\n # The e.soap_faultstring_ex, e.code_ex, and potentially e.trigger_ex\n # attributes are the most useful, but other attributes may be populated\n # as well. To display all attributes, the following can be used:\n #\n # e.instance_variables.each do |var|\n # value = e.instance_variable_get(var)\n # if ! value.nil?\n # puts '%s => %s' % [var, value]\n # end\n # end\n puts 'SOAP Error: %s (code: %d)' % [e.soap_faultstring_ex, e.code_ex]\n puts 'Trigger: %s' % e.trigger_ex unless e.trigger_ex.nil?\n puts 'Source: %s' % e.backtrace.first\n\n ensure\n # Display API unit usage info. This data is stored as a class variable\n # in the AdWords::API class and accessed via static methods.\n # total_units() returns a running total of units used in the scope of the\n # current program. last_units() returns the number used in the last call.\n puts\n puts '%d API units consumed total (%d in last call).' %\n [adwords.total_units, adwords.last_units]\n end\n end",
"def group_element\n if response.is_a?(Array)\n return response[1]\n else\n return response[grouping_field]\n end\n end",
"def build_groups # rubocop:disable Metrics/AbcSize\n group_array = []\n @data['controls'].each do |control|\n group = HappyMapperTools::Benchmark::Group.new\n group.id = control['id']\n group.title = control['gtitle']\n group.description = \"<GroupDescription>#{control['gdescription']}</GroupDescription>\" if control['gdescription']\n\n group.rule = HappyMapperTools::Benchmark::Rule.new\n group.rule.id = control['rid']\n group.rule.severity = control['severity']\n group.rule.weight = control['rweight']\n group.rule.version = control['rversion']\n group.rule.title = control['title'].tr(\"\\n\", ' ') if control['title']\n group.rule.description = \"<VulnDiscussion>#{control['desc'].tr(\"\\n\", ' ')}</VulnDiscussion><FalsePositives></FalsePositives><FalseNegatives></FalseNegatives><Documentable>false</Documentable><Mitigations></Mitigations><SeverityOverrideGuidance></SeverityOverrideGuidance><PotentialImpacts></PotentialImpacts><ThirdPartyTools></ThirdPartyTools><MitigationControl></MitigationControl><Responsibility></Responsibility><IAControls></IAControls>\"\n\n if ['reference.dc.publisher', 'reference.dc.title', 'reference.dc.subject', 'reference.dc.type', 'reference.dc.identifier'].any? { |a| @attribute.key?(a) }\n group.rule.reference = build_rule_reference\n end\n\n group.rule.ident = build_rule_idents(control['cci']) if control['cci']\n\n group.rule.fixtext = HappyMapperTools::Benchmark::Fixtext.new\n group.rule.fixtext.fixref = control['fix_id']\n group.rule.fixtext.fixtext = control['fix']\n\n group.rule.fix = build_rule_fix(control['fix_id']) if control['fix_id']\n\n group.rule.check = HappyMapperTools::Benchmark::Check.new\n group.rule.check.system = control['checkref']\n\n # content_ref is optional for schema compliance\n if @attribute['content_ref.name'] || @attribute['content_ref.href']\n group.rule.check.content_ref = HappyMapperTools::Benchmark::ContentRef.new\n group.rule.check.content_ref.name = @attribute['content_ref.name']\n group.rule.check.content_ref.href = @attribute['content_ref.href']\n end\n\n group.rule.check.content = control['check']\n\n group_array << group\n end\n @benchmark.group = group_array\n end",
"def get_group_id(group_set_id, splitted_group_name)\n group_data_arr = Array.new\n\n @url = \"http://#{$canvas_host}/api/v1/group_categories/#{group_set_id}/groups\"\n puts \"@url is #{@url}\"\n \n @getResponse = HTTParty.get(@url, :headers => $header)\n puts(\" GET to get groups in a group set has Response.code #{@getResponse.code} and getResponse is #{@getResponse}\")\n \n if $link_parser.parse(@getResponse).by_rel('next')\n group_data_arr.append(@getResponse.parsed_response)\n\n while $link_parser.parse(@getResponse).by_rel('next')\n @url = $link_parser.parse(@getResponse).by_rel('next').target\n puts \"@url is #{@url}\"\n\n @getResponse = HTTParty.get(@url, :headers => $header)\n puts(\" GET to get groups in a group set has Response.code #{@getResponse.code} and getResponse is #{@getResponse}\")\n \n group_data_arr.append(@getResponse.parsed_response)\n end\n\n group_data_arr.each { |group_data|\n group_data.each do |group_data_info|\n if group_data_info[\"name\"] == splitted_group_name\n return group_id = group_data_info[\"id\"] \n end\n end\n }\n else\n group_data = @getResponse.parsed_response\n group_id = nil\n \n group_data.each do |group_data_info|\n if group_data_info[\"name\"] == splitted_group_name\n group_id = group_data_info[\"id\"] \n end\n end\n\n return group_id\n end\nend",
"def load_groups(input)\n groups = Hash.new\n while g = parse_rfc822_header(input)\n date = parse_date(g['Date-Created'])\n groups[g['Name']] = Newsgroup.new(g['Name'], date, g['Description'])\n end\n return groups\n end",
"def groups_list(trace: false, &block)\n r = dropbox_query(query: '2/team/groups/list', trace: trace)\n r['groups'].each(&block)\n while r['has_more']\n r = dropbox_query(query: '2/team/groups/list/continue', query_data: \"{\\\"cursor\\\":\\\"#{r['cursor']}\\\"}\", trace: trace)\n r['groups'].each(&block)\n end\n end",
"def qihu_get_all(campaign_se_id)\n adgroups = Array.new\n group_service = Qihu::DianJing::Client.new(get_auth).group\n response = group_service.getIdListByCampaignId(campaignId: campaign_se_id)\n id_list = JSON.parse(response.body)[\"groupIdList\"]\n id_list.each do |id|\n adgroup = AgaApiFactory::Model::Adgroup.new\n adgroup.se_id = id.to_i\n adgroup.adgroup_name = id \n adgroup.price = 0\n adgroup.negative_words = \"\"\n adgroup.exact_negative_words = \"\"\n adgroup.status = 0\n adgroup.se_status = adgroup.status\n adgroups << adgroup\n end\n adgroups\n end",
"def groups; end",
"def groups; end",
"def groups; end",
"def groups\n @groups ||= @csv.group_by { |row| row[:id] }\n end",
"def groups\n if groups_last_update.blank? || ((Time.now - groups_last_update) > 24 * 60 * 60)\n return groups!\n end\n group_list.split(\";?;\")\n end",
"def custom_groups\n\n groups_list = prep_format(PolcoGroup.where(name: /#{params[:q]}/i, type: :custom))\n\n respond_to do |format|\n format.json {render :json => groups_list}\n end\n end",
"def listed\n @listed = response[\"listed\"]\n @listed[\"groups\"].each do |group|\n @listed[\"items\"].map!{|item| Foursquared::Response::List.new(client, item)}\n end\n @listed\n end",
"def list(response)\n requested_group = response.args[1]\n output = get_groups_list(requested_group)\n if output.empty?\n if requested_group\n response.reply(\n \"There is no authorization group named #{requested_group}.\"\n )\n else\n response.reply(\"There are no authorization groups yet.\")\n end\n else\n response.reply(output.join(\"\\n\"))\n end\n end",
"def process\n result[:citation_groups] = citation_groups\n end",
"def groups(inherited = false)\n uri = build_uri('groups', inherited: inherited.to_s)\n req = Net::HTTP::Get.new(uri, DEFAULT_HEADERS)\n resp = request(req)\n obj = if resp.code == '200'\n JSON.parse(resp.body)\n else\n raise_on_non_200(resp, 200)\n end\n obj\n end",
"def create_groups(results, opts = {})\n created = 0\n skipped = 0\n failed = 0\n total = opts[:total] || results.count\n\n results.each do |result|\n g = yield(result)\n\n if g.nil? || group_id_from_imported_group_id(g[:id])\n skipped += 1\n else\n new_group = create_group(g, g[:id])\n created_group(new_group)\n\n if new_group.valid?\n add_group(g[:id].to_s, new_group)\n created += 1\n else\n failed += 1\n puts \"Failed to create group id #{g[:id]} #{new_group.name}: #{new_group.errors.full_messages}\"\n end\n end\n\n print_status(created + skipped + failed + (opts[:offset] || 0), total, get_start_time(\"groups\"))\n end\n\n [created, skipped]\n end",
"def groupings(column_ids)\n update if running?\n if succeeded?\n doc = post(link('group'), {:columns => column_ids}.update(@opts))\n return doc['groupings'].to_a.map {|g| Grouping.new(@opts, g)}\n elsif running?\n raise VeritableError.new(\"Grouping -- Analysis with id #{_id} is still running and not yet ready to calculate groupings.\")\n elsif failed?\n raise VeritableError.new(\"Grouping -- Analysis with id #{_id} has failed and cannot calculate groupings.\")\n else\n raise VeritableError.new(\"Grouping -- Shouldn't be here -- please let us know at [email protected].\")\n end\n end",
"def process_group_data( node, loop_detection = [] )\n result = []\n \n case node.type.name\n when \"group_spec\"\n node.specifications.each do |spec|\n if elements = process_group_data(spec, loop_detection) then\n result.concat elements\n else\n nyi( \"what happens here?\" )\n end\n end\n \n when \"rule_spec\"\n result << Reference.new(create_name(node.name))\n \n when \"spec_reference\"\n name = node.name.text\n if @specifications.member?(name) then\n spec = @specifications[name]\n \n case spec.type.name\n when \"group_spec\"\n if @group_defs.member?(name) then\n result.concat @group_defs[name].member_references.collect{|r| r.clone()}\n else\n \n #\n # If we have to process a :group_spec directly, we don't store the result. This is because\n # we flatten groups via transitive closure, and shortcut out if we detect a loop (ie. somebody\n # \"above us\" is already processing it). We don't want to store such partial results.\n \n unless loop_detection.member?(name)\n result.concat process_group_data(spec, loop_detection + [name])\n end\n end\n \n when \"rule_spec\"\n result << Reference.new( create_name(node.name) )\n else\n nyi( \"error handling for group reference to macro or other ineligible name [#{name}]\" )\n end\n else\n nyi( \"error handling for missing rule/word/character reference in group [#{name}]\", node )\n end\n else\n nyi( \"support for node type [#{node.type}]\", node )\n end\n \n return result\n end",
"def group_holdings(document)\n holdings = JSON.parse(document['holdings_json'])\n Rails.logger.info \"es287_debug #{__FILE__}:#{__LINE__}:#{__method__} holdings = #{holdings.inspect}\"\n circulating_items = []\n rare_items = []\n online_items = []\n # handle separate sets\n holdings.each do |k,holding|\n if holding[\"location\"].present?\n if holding[\"location\"][\"name\"].include?('Rare') \n rare_items << holding \n else \n circulating_items << holding \n end \n elsif holding[\"online\"].present? \n online_items << holding \n end \n end \n [circulating_items,online_items,rare_items]\n end",
"def get_info_group(detail_page)\n info_group_panel = detail_page.search('div#ctl00_MainBodyContent_group_16 table')[2]\n info_group_tr = info_group_panel.search('tr')\n \n info_group_info = []\n for i in 0..info_group_tr.length - 2\n tr = info_group_tr[i]\n info_group_td = tr.search('td')\n if (info_group_td.size > 0)\n info_group_obj = {}\n info_group_obj[:key] = clean_whitespace(info_group_td[0].inner_text).gsub(\" \",\"_\").downcase\n info_group_obj[:field] = clean_whitespace(info_group_td[1].inner_text).downcase\n info_group_info << info_group_obj\n end\n end\n return info_group_info\nend",
"def get_info_group(detail_page)\n info_group_panel = detail_page.search('div#ctl00_MainBodyContent_group_16 table')[2]\n info_group_tr = info_group_panel.search('tr')\n \n info_group_info = []\n for i in 0..info_group_tr.length - 2\n tr = info_group_tr[i]\n info_group_td = tr.search('td')\n if (info_group_td.size > 0)\n info_group_obj = {}\n info_group_obj[:key] = clean_whitespace(info_group_td[0].inner_text).gsub(\" \",\"_\").downcase\n info_group_obj[:field] = clean_whitespace(info_group_td[1].inner_text).downcase\n info_group_info << info_group_obj\n end\n end\n return info_group_info\nend",
"def battlegroups\r\n BnetApi::make_request('/wow/data/battlegroups/')\r\n end",
"def get_users_in_group(group_id)\n @url = \"http://#{$canvas_host}/api/v1/groups/#{group_id}/users\"\n puts \"@url is #{@url}\"\n\n @getResponse = HTTParty.get(@url, :headers => $header)\n puts(\" GET to get users in group has Response.code #{@getResponse.code} and getResponse is #{@getResponse}\")\n\n user_data = @getResponse.parsed_response\n set_of_user_ids = Set.new\n\n user_data.each do |user_data_info|\n set_of_user_ids.add user_data_info[\"id\"]\n end \n\n if @getResponse.empty?\n puts \"WARNING: No users in group from Active listener group 1 or Active listener group 2, program may not function correctly!\"\n end\n\n return set_of_user_ids\nend",
"def hc_group_list(id)\n org=Org.find(id)\n org.hc_groups.group_list\n end",
"def get_group_json( params, base )\n doc = Document.find(params[:document_id])\n includes = self.determine_child_includes(doc, params)\n\n if base\n grp = Group.includes(includes).base(doc, current_account.id, params[:de], params[:qc])\n else\n grp = Group.includes(includes).find(params[:id])\n end\n\n responseJSON = grp.as_json({\n include: includes,\n ancestry: true\n })\n\n if (doc.in_de? || doc.in_supp_de?) && grp.template_id\n responseJSON[:template_fields] = TemplateField.where({template_id: grp.template_id}).pluck(:field_name)\n end\n\n responseJSON[:annotations] = Annotation.by_doc_status(doc, params[:de]).flattened_by_group(grp.id, doc.in_supp_de?).as_json()\n responseJSON\n end",
"def create_groups(list)\n list_copy = []\n list.each {|item| list_copy.push(item)}\n all_groups = []\n list_copy.shuffle!\n while list_copy.size >= 4\n group = list_copy.pop(4)\n all_groups << group\n end\n if list_copy.size > 0\n list_copy.each_with_index do |person, index|\n person = list_copy.pop\n all_groups[index].push(person)\n end\n end\n hash = {}\n all_groups.each_with_index do |group, index|\n hash[\"Accountability Group #{index}\"] = group\n end\n p hash\nend",
"def groups\n normalize_boundaries\n groups = []\n (0..boundaries.size - 1).each do |k|\n groups << group_rows(k)\n end\n groups\n end",
"def li__my_groups(access_keys)\n access_token = OAuth::AccessToken.new(get_linkedin_consumer(3), access_keys[:access_token], access_keys[:access_secret])\n \n \n # -- X. WITH 'posts' -> to be used as part of automatically determining the location of the group (for targeted groups)\n # json_groups = _get_linkedin(access_token, \"people/~/group-memberships:(group:(id,name,num-members,short-description,small-logo-url,large-logo-url,website-url,site-group-url,posts,counts-by-category,locale,location),membership-state)?format=json&start=0&count=1000\")\n \n \n # -- X. WITHOUT 'posts'\n json_groups = _get_linkedin(access_token, \"people/~/group-memberships:(group:(id,name,num-members,short-description,small-logo-url,large-logo-url,website-url,site-group-url,counts-by-category,locale,location),membership-state)?format=json&start=0&count=1000\")\n \n \n # response = access_token.get(\"http://api.linkedin.com/v1/people/~/group-memberships:(group:(id,name,num-members,small-logo-url),membership-state,show-group-logo-in-profile,allow-messages-from-members,email-digest-frequency,email-announcements-from-managers,email-for-every-new-post)?format=json&start=0&count=1000\")\n # response = access_token.get(\"http://api.linkedin.com/v1/groups::(5049608,5112233,5161898):(id,name,site-group-url,posts)?format=json\")\n \n json_groups\n end",
"def groups\r\n @groups ||= fetch_groups\r\n end",
"def solr_groups(group_field)\n return [] if @solr_response[\"grouped\"] == nil\n @solr_response[\"grouped\"][group_field][\"groups\"].map {|x| x[\"groupValue\"]}\n end",
"def embiggen_grouped_results(values)\n embiggened_results = []\n values.each do |resultset|\n container = {} \n resultset.each do |set|\n data = {}\n set.data.each do |key, value|\n if value.kind_of? Hash\n if value.empty?\n value = []\n else \n value = [value] if value.kind_of? Hash\n end\n end\n data[key] = value\n end\n container.merge!(data) do |key, old, nue|\n if old.kind_of? Array\n old.push nue.first\n else\n nue\n end \n end\n end\n embiggened_results.push container\n end\n\n embiggened_results\n end",
"def groups(options = {})\n params = { :limit => 200 }.update(options)\n response = get(PATH['groups_full'], params)\n parse_groups response_body(response)\n end",
"def create_group_map(options={})\n\n\tleague_id = options[:league_id]\n\tfixtures_xml = options[:xml]\n\n\tgroup_hash = Hash.new\n\n\tfixtures_xml.xpath(\"//Match\").each do |node|\n if [16, 17].include? league_id\n home_team_id = node.xpath(\"HomeTeam_Id\").text\n away_team_id = node.xpath(\"AwayTeam_Id\").text\n if group_hash[home_team_id].nil?\n group_hash[home_team_id] = Array.new\n group_hash[home_team_id] << home_team_id\n group_hash[home_team_id] << away_team_id\n elsif !group_hash[home_team_id].include? away_team_id\n group_hash[home_team_id] << away_team_id\n end\n end\n\tend\n\n groups = Array.new\n team_has_group = Hash.new\n group_hash.each do |k,v|\n if team_has_group[k].nil?\n groups << v\n v.each do |t|\n team_has_group[t] = true\n end\n end\n end\n\n # Group name order hard-coded for 2013 (due to xmlsoccer fixture order)\n if league_id == 16\n group_names = [ 'A', 'D', 'B', 'C', 'H', 'F', 'E', 'G', ]\n elsif league_id == 17\n group_names = [ 'A', 'E', 'F', 'B', 'C', 'D', 'J', 'H', 'I', 'K', 'G', 'L' ]\n end\n \n unsorted_groups = Hash.new\n groups.each do |group|\n group_name = group_names.shift\n unsorted_groups[group_name] = Array.new\n group.each do |team_id|\n unsorted_groups[group_name] << team_id\n group_hash[team_id.to_s] = group_name\n end\n end\n\n # @groups = Hash.new\n # unsorted_groups.keys.sort.each do |key|\n # @groups[key] = unsorted_groups[key]\n # end\n\n group_hash\n\nend",
"def get_groups_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: GroupsApi.get_groups ...\"\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 if opts[:'sort_order'] && !['ascending', 'descending'].include?(opts[:'sort_order'])\n fail ArgumentError, 'invalid value for \"sort_order\", must be one of ascending, descending'\n end\n \n \n \n \n # resource path\n local_var_path = \"/api/v2/groups\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'pageSize'] = opts[:'page_size'] if opts[:'page_size']\n query_params[:'pageNumber'] = opts[:'page_number'] if opts[:'page_number']\n query_params[:'id'] = @api_client.build_collection_param(opts[:'id'], :multi) if opts[:'id']\n query_params[:'jabberId'] = @api_client.build_collection_param(opts[:'jabber_id'], :multi) if opts[:'jabber_id']\n query_params[:'sortOrder'] = opts[:'sort_order'] if opts[:'sort_order']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n auth_names = ['PureCloud OAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'GroupEntityListing')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: GroupsApi#get_groups\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def get_all_groups_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: GroupControllerApi.get_all_groups ...'\n end\n allowable_values = [\"ASC\", \"DESC\"]\n if @api_client.config.client_side_validation && opts[:'sort'] && !allowable_values.include?(opts[:'sort'])\n fail ArgumentError, \"invalid value for \\\"sort\\\", must be one of #{allowable_values}\"\n end\n # resource path\n local_var_path = '/groups/paginated'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?\n query_params[:'since'] = opts[:'since'] if !opts[:'since'].nil?\n query_params[:'before'] = opts[:'before'] if !opts[:'before'].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(['*/*'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'PageGroupProjection' \n\n # auth_names\n auth_names = opts[:auth_names] || ['API_KEY']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: GroupControllerApi#get_all_groups\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def create_group_array\n group_array= $products_hash[\"items\"].group_by {|name| name[\"brand\"]}\n return group_array\nend",
"def my_groups(options={})\n @my_groups = nil if options.delete(:force_download)\n @my_groups ||= objects_from_response(TheCity::Group, :get, \"/me/groups\", options)\n end",
"def getAssessmentResults(sheet, year_row, start_row)\n stats = Hash.new { |h,k| h[k] = Hash.new { |h,k| h[k] = {} } }\n (0..100).step(3) do |sg_offset| # go down the rows\n subgroup = sheet.row(start_row + sg_offset)[TEST_GROUP_COL]\n break if subgroup.nil? or subgroup.empty? or subgroup.include? 'English: Reading' or subgroup.include? 'Mathematics'\n (START_SCORE_COL..START_SCORE_COL+8).step(4) do |offset| # and across\n year = sheet.row(year_row)[offset]\n stats[subgroup][year][:adv] = sheet.row(start_row + sg_offset)[offset]\n stats[subgroup][year][:pro] = sheet.row(start_row + sg_offset)[offset+1]\n stats[subgroup][year][:fai] = sheet.row(start_row + sg_offset)[offset+3]\n end\n end\n stats\nend",
"def group_list\n execute('dscacheutil -q group') do |result|\n groups = []\n result.stdout.each_line do |line|\n groups << line.split(': ')[1].strip if /^name:/.match?(line)\n end\n\n yield result if block_given?\n\n groups\n end\n end",
"def groups\n if (groups_last_update.blank? || ((Time.now-groups_last_update) > 24*60*60 ))\n return groups!\n end\n return self.group_list.split(\";?;\")\n end",
"def groups\n if (groups_last_update.blank? || ((Time.now-groups_last_update) > 24*60*60 ))\n return groups!\n end\n return self.group_list.split(\";?;\")\n end",
"def group\n klass.collection.group(\n :key => field_list,\n :cond => selector,\n :initial => { :group => [] },\n :reduce => Javascript.group\n ).collect do |docs|\n docs[\"group\"] = docs[\"group\"].collect do |attrs|\n Mongoid::Factory.from_db(klass, attrs)\n end\n docs\n end\n end",
"def hc_group_list_all(id)\n org=Org.find(id)\n org.hc_groups.all(:order=>'group_name')\n end",
"def export_csv\n\n group_array = []\n @page = 1\n @per_page = 50\n\n groups = @context.get(:groups, :page => @page, :per_page => @per_page, :access_token => ENV[\"API_TOKEN\"])\n group_array << groups\n group_array, group_hash = check_paging(groups, group_array, \"groups\", @context, true)\n\n group_array.each_with_index do |group, index|\n is_new = index == 0 ? true : false\n membership_array = []\n @page = 1\n\n group_model = Group.find(group['id'], :params => { :access_token => ENV[\"API_TOKEN\"] })\n memberships = group_model.get(:memberships, :page => @page, :per_page => @per_page, :access_token => ENV[\"API_TOKEN\"])\n membership_array << memberships\n membership_array, @membership_hash = check_paging(memberships, membership_array, \"memberships\", group_model, is_new)\n end\n\n export_data = [group_array, @membership_hash]\n perform_export(export_data) \n\n respond_to do |format|\n format.html { render :inline => \"<a href=<%= @download_url %>>Download CSV</a>\" }\n format.json { render :json => @download_url.to_json }\n end\n end",
"def make_groups(list_of_names)\n result = []\n num_people = list_of_names.length\n cur_group = []\n list_of_names.each do |name|\n cur_group.push(name)\n if cur_group.length == 4 || (cur_group.length == 3 && num_people == 3)\n result.push(cur_group)\n cur_group=[]\n end\n end\n # Right now the solution doesn't gracefully handle 6 people.\n # I should write a find_available function to find an open group to stick someone\n # in.\n if cur_group.length == 2\n name = cur_group.pop\n result[1].push(name)\n end\n if cur_group.length == 1\n name = cur_group.pop\n result[0].push(name)\n end\n return result\nend",
"def get_response()\n # process excel - get the data segments - create hash with headers\n @data = {}\n\n sheet = @excel.sheet\n headers = []\n sheet.getRow(0).cellIterator.each do |h|\n headers << @excel.cell_value(h)\n @data[@excel.cell_value(h) ] = []\n end\n\n @excel.each_row do |row|\n row.cellIterator.each_with_index do |c, i|\n # N.B null row data can spill beyond the columns defined\n @data[headers[i]] << @excel.cell_value(c) if headers[i]\n end\n end\n @data\n end",
"def groups\n FfcrmMailchimp::Group.groups_for(id)\n end",
"def groups(array_of_names)\r\n\r\n\tnum_people = array_of_names.length \t\t#how many people do we have?\r\n\tgroups_5 = num_people % 4 \t#how many groups will have 5\r\n\tgroups_4 = (num_people - (groups_5 * 5)) / 4 # how many groups will have 4\r\n\ttotal_groups = groups_4 + groups_5 \t\t#how many total groups\r\n\r\n\tgroup_hash = Hash.new([])\t#new hash initialized to empty arrays\r\n\t\r\n\tnum_group = 0\r\n\tindex = 0\r\n\r\n\tgroups_5.times do\r\n\t\tpeople_in_group = []\r\n\t\t5.times do\r\n\t\t\tpeople_in_group << array_of_names[index]\r\n\t\t\tindex += 1\r\n\t\tend\r\n\t\tgroup_hash[\"Accountability Group #{num_group}\"] = people_in_group\r\n\t\tnum_group += 1\r\n\tend\r\n\r\n\tgroups_4.times do\r\n\t\tpeople_in_group = []\r\n\t\t4.times do\r\n\t\t\tpeople_in_group << array_of_names[index]\r\n\t\t\tindex += 1\r\n\t\tend\r\n\t\tgroup_hash[\"Accountability Group #{num_group}\"] = people_in_group\r\n\t\tnum_group += 1\r\n\tend\r\n\r\n\treturn group_hash\r\n\r\nend",
"def search(options)\n rsp = @flickr.send_request('flickr.groups.search', options)\n \n returning Flickr::FlickrResponse.new(:page => rsp.groups[:page].to_i,\n :pages => rsp.groups[:pages].to_i,\n :per_page => rsp.groups[:perpage].to_i,\n :total => rsp.groups[:total].to_i,\n :objects => [],\n :api => self,\n :method => :search,\n :options => options) do |groups|\n rsp.groups.group.each do |group|\n attributes = create_attributes(group)\n\n groups << Group.new(@flickr, attributes)\n end if rsp.groups.group\n end\n end",
"def mygroups\n @user = User.find_by(email: user_params[:email])\n\n @usergroups = @user.studygroups_users\n @mygroups = []\n\n @usergroups.each { |group|\n @studygroup = Studygroup.find_by(id: group.studygroup_id)\n @mygroups.push(@studygroup)\n\n }\n render json: @mygroups\n end",
"def create_groups(cohort)\n if cohort.length % 5 == 0\n hash = {} \t\n \tcounter = 1\n group_count = cohort.length / 5\n remainder = cohort.length % 5 \t\n # Set to groups(keys) to members(values)\n group_count.times do\n hash[counter] = cohort.slice!(0..4)\n counter += 1\n end\n else\n \thash = {}\n counter = 1 \n group_count = cohort.length / 4\n remainder = cohort.length % 4\n # Set to groups(keys) to members(values)\n group_count.times do\n hash[counter] = cohort.slice!(0..3)\n counter += 1\n end\n end\n # Add remainders\n counter = 1\n cohort.each do |string|\n hash[counter] << string\n counter += 1\n end\nreturn hash\nend",
"def groups\n\t\t\t@groups ||= begin\n\t\t\t\tFile.readlines(File.join(@svcdir, 'group')).map { |g| g.strip }\n\t\t\trescue Exception => e\n\t\t\t\t[]\n\t\t\tend\n\t\tend",
"def groups\n return [] if new_record?\n cached_groups do\n fetch_groups!\n end\n end",
"def get_group_by_id(id)\n $r.hgetall(\"group:#{id}\")\n end",
"def fetch_log_groups(client)\n logger.info('fetching log groups')\n log_groups = []\n next_token = nil\n\n begin\n options = { next_token: next_token }\n resp = client.describe_log_groups(options)\n log_groups += resp.log_groups\n next_token = resp.next_token\n end while next_token\n log_groups\n end",
"def view_group(group)\n @uri = URI.parse(\"#{@api_url}/group/#{group}\")\n body = make_get_request\n @doc = Nokogiri::HTML(body)\n {\n title: get_title,\n description: get_description,\n name: get_name,\n regid: get_regid,\n contact: get_contact\n }\n end",
"def groups\n groups = []\n relations = self.group_relations\n relations.each do |r|\n groups.push r.group\n end\n groups\n end",
"def create_groups(people)\n number_people = people.length\n if number_people < 3\n group_quantity = 1\n else\n group_quantity = number_people / 3\n end\n group_number = 1\n groups_names = Hash.new(\"\")\n people.each do |name|\n if group_number <= group_quantity\n groups_names[group_number] += (name + \", \")\n group_number += 1\n else\n groups_names[1] += (name + \", \")\n group_number = 2\n end\n end\n groups_names.each do |group, name|\n print \"\\n\", \"Group \", group, \"\\n\"\n print name, \"\\n\"\n end\nend",
"def listgroup \n @groups = Group.where(:company_id => params[:id])\n #@lst= []\n # @groups.each do |group| \n # @lst << JSON.parse(group.to_json).merge(member_nbr: group.users.count)\n # end\n # format.json { render :json => @lst } \n render 'list'\n end",
"def groups\n groups = []\n @config['groups'].each do |k, v|\n groups << OpenStruct.new(\n name: k,\n size: Size.new(v['size']),\n rss: v['rss'],\n requests: v['requests'],\n path: v['path'])\n end\n groups.freeze\n end",
"def index\n #@polco_groups = PolcoGroup.all.paginate(:page => params[:page], :per_page => 20) # where(name: /#{params[:q]}/i)\n @groups = Hash.new\n @groups[:states] = PolcoGroup.states.all.paginate(:page => params[:page], :per_page => 20)\n @groups[:districts] = PolcoGroup.districts.all.paginate(:page => params[:page], :per_page => 20)\n @groups[:customs] = PolcoGroup.customs.all.paginate(:page => params[:page], :per_page => 20)\n\n respond_to do |format|\n format.html # index.haml\n format.xml { render :xml => @polco_groups }\n format.json { render :json => @polco_groups.map{|g| {:id => g.id, :name => g.name}} }\n end\n end",
"def async_group &block\n em_get( \"/clients/#{uuid}/group\") do |response|\n group = Group.new( response[:content] )\n block.call( group )\n end\n end",
"def create_document groups\n doc = RDoc::Markup::Document.new\n doc.omit_headings_below = 2\n doc.file = @top_level\n\n doc << RDoc::Markup::Heading.new(1, File.basename(@file_name))\n doc << RDoc::Markup::BlankLine.new\n\n groups.sort_by do |day,| day end.reverse_each do |day, entries|\n doc << RDoc::Markup::Heading.new(2, day.dup)\n doc << RDoc::Markup::BlankLine.new\n\n doc.concat create_entries entries\n end\n\n doc\n end",
"def create_document groups\n doc = RDoc::Markup::Document.new\n doc.omit_headings_below = 2\n doc.file = @top_level\n\n doc << RDoc::Markup::Heading.new(1, File.basename(@file_name))\n doc << RDoc::Markup::BlankLine.new\n\n groups.sort_by do |day,| day end.reverse_each do |day, entries|\n doc << RDoc::Markup::Heading.new(2, day.dup)\n doc << RDoc::Markup::BlankLine.new\n\n doc.concat create_entries entries\n end\n\n doc\n end",
"def build_group_html_rows(group, col_count, label = nil, group_text = nil)\n in_a_widget = self.rpt_options[:in_a_widget] || false\n\n html_rows = []\n\n content =\n if group == :_total_\n _(\"All Rows\")\n else\n group_label = group_text || group\n group_label = _(\"<Empty>\") if group_label.blank?\n \"#{label}#{group_label}\"\n end\n\n if (self.group == 'c') && extras && extras[:grouping] && extras[:grouping][group]\n display_count = _(\"Count: %{number}\") % {:number => extras[:grouping][group][:count]}\n end\n content << \" | #{display_count}\" unless display_count.blank?\n html_rows << \"<tr><td class='group' colspan='#{col_count}'>#{CGI.escapeHTML(content)}</td></tr>\"\n\n if extras && extras[:grouping] && extras[:grouping][group] # See if group key exists\n MiqReport::GROUPINGS.each do |calc| # Add an output row for each group calculation\n if extras[:grouping][group].key?(calc.first) # Only add a row if there are calcs of this type for this group value\n grp_output = \"\"\n grp_output << \"<tr>\"\n grp_output << \"<td#{in_a_widget ? \"\" : \" class='group'\"} style='text-align:right'>#{_(calc.last)}:</td>\"\n col_order.each_with_index do |c, c_idx| # Go through the columns\n next if c_idx == 0 # Skip first column\n grp_output << \"<td#{in_a_widget ? \"\" : \" class='group'\"} style='text-align:right'>\"\n grp_output << CGI.escapeHTML(\n format(\n c.split(\"__\").first, extras[:grouping][group][calc.first][c],\n :format => self.col_formats[c_idx] ? self.col_formats[c_idx] : :_default_\n )\n ) if extras[:grouping][group].key?(calc.first)\n grp_output << \"</td>\"\n end\n grp_output << \"</tr>\"\n html_rows << grp_output\n end\n end\n end\n html_rows << \"<tr><td class='group_spacer' colspan='#{col_count}'> </td></tr>\" unless group == :_total_\n html_rows\n end",
"def get_item_groups_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: UniverseApi.get_item_groups ...\"\n end\n if opts[:'datasource'] && !['tranquility', 'singularity'].include?(opts[:'datasource'])\n fail ArgumentError, 'invalid value for \"datasource\", must be one of tranquility, singularity'\n end\n if !opts[:'page'].nil? && opts[:'page'] < 1\n fail ArgumentError, 'invalid value for \"opts[:\"page\"]\" when calling UniverseApi.get_item_groups, must be greater than or equal to 1.'\n end\n\n # resource path\n local_var_path = \"/universe/groups/\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'datasource'] = opts[:'datasource'] if !opts[:'datasource'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'user_agent'] = opts[:'user_agent'] if !opts[:'user_agent'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n header_params[:'X-User-Agent'] = opts[:'x_user_agent'] if !opts[:'x_user_agent'].nil?\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<Integer>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: UniverseApi#get_item_groups\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def create_groups(names)\n groups = []\n names.shuffle.each_slice(4) do |group|\n if group.count == 4\n groups << group\n else\n i = 0\n group.each do |name|\n groups[i] << name\n i += 1\n end\n end\n end\n p groups\nend",
"def groups\n @groups ||= {}\n end",
"def get_group_set_id(group_set_name)\n group_set_arr = Array.new\n\n @url = \"http://#{$canvas_host}/api/v1/courses/#{$canvas_course_id}/group_categories\"\n puts \"@url is #{@url}\"\n \n @getResponse = HTTParty.get(@url, :headers => $header)\n puts(\" GET to get group sets has Response.code #{@getResponse.code} and getResponse is #{@getResponse}\")\n \n if $link_parser.parse(@getResponse).by_rel('next')\n group_set_arr.append(@getResponse.parsed_response)\n\n while $link_parser.parse(@getResponse).by_rel('next')\n @url = $link_parser.parse(@getResponse).by_rel('next').target\n puts \"@url is #{@url}\"\n\n @getResponse = HTTParty.get(@url, :headers => $header)\n puts(\" GET to get group sets has Response.code #{@getResponse.code} and getResponse is #{@getResponse}\")\n \n group_set_arr.append(@getResponse.parsed_response)\n end\n\n group_set_arr.each { |group_set_data|\n group_set_data.each do |group_set_info|\n if group_set_info[\"name\"] == group_set_name\n return group_set_id = group_set_info[\"id\"] \n end\n end\n }\n else\n group_set_data = @getResponse.parsed_response\n group_set_id = nil \n \n group_set_data.each do |group_set_info|\n if group_set_info[\"name\"] == group_set_name\n group_set_id = group_set_info[\"id\"] \n end\n end\n \n return group_set_id\n end\nend",
"def list_groups\n groups = CanvasSpaces.GroupCategory.groups.active.order(:name)\n # filter out non-public groups for non-admins\n groups = groups.where(join_level: 'parent_context_auto_join') unless @current_user.account.site_admin?\n groups_json = Api.paginate(groups, self, api_v1_canvas_spaces_groups_url).map do |g|\n include = @current_user.account.site_admin? || @current_user.id == g.leader_id ? ['users'] : []\n group_formatter(g, { include: include })\n end\n render :json => groups_json\n end",
"def build_group_body\n render_table data, options.to_hash\n end",
"def get_all(which=:groups, options={})\n resp = self.class.get(\"/#{which}\", { :query => options })\n check_errors resp\n rebuild_xml_array!(resp.parsed_response['Response'], 'Entries', 'Entry')\n res = resp.parsed_response['Response']['Entries']\n if which == :contacts\n res.each { |c| rebuild_groups! c }\n end\n res\n end",
"def list_galleries\n\t\t\t@response = api_request 'LoadGroupHierarchy', [@username]\n\n\t\t\t@response['result']['Elements'].each do |value|\n\t\t\t\tif value['$type'] == \"PhotoSet\"\n\t\t\t\t\t@galleries << ZenfolioAPI::Model::Gallery.new(:id => value['Id'], :type => value['$type'], :caption => value['Caption'], \n\t\t\t\t\t\t:created_on => value['CreatedOn']['Value'], :modified_on => value['ModifiedOn']['Value'], :photo_count => value['PhotoCount'],\n\t\t\t\t\t\t:image_count => value['ImageCount'], :video_count => value['VideoCount'], :photo_bytes => value['PhotoBytes'], :views => value['Views'],\n\t\t\t\t\t\t:featured_index => value['FeaturedIndex'], :is_random_title_photo => value['IsRandomTitlePhoto'], :upload_url => value['UploadUrl'],\n\t\t\t\t\t\t:video_upload_url => value['VideoUploadUrl'], :page_url => value['PageUrl'], :mailbox_id => value['MailboxId'], :text_cn => value['TextCn'], \n\t\t\t\t\t\t:photo_list_cn => value['PhotoListCn'], :group_index => value['GroupIndex'], :title => value['Title'], :owner => value['Owner'])\n\t\t\t\telsif value['$type'] == \"Group\"\t\n\t\t\t\t\telements = []\n\t\t\t\t\tvalue['Elements'].each do |element|\n\t\t\t\t\t\tif element['$type'] == \"PhotoSet\"\n\t\t\t\t\t\t\telements << ZenfolioAPI::Model::Gallery.new(:id => element['Id'], :type => element['$type'], :caption => element['Caption'], \n\t\t\t\t\t\t\t\t:created_on => element['CreatedOn']['Value'], :modified_on => element['ModifiedOn']['Value'], :photo_count => element['PhotoCount'],\n\t\t\t\t\t\t\t\t:image_count => element['ImageCount'], :video_count => element['VideoCount'], :photo_bytes => element['PhotoBytes'], :views => element['Views'],\n\t\t\t\t\t\t\t\t:featured_index => element['FeaturedIndex'], :is_random_title_photo => element['IsRandomTitlePhoto'], :upload_url => element['UploadUrl'],\n\t\t\t\t\t\t\t\t:video_upload_url => element['VideoUploadUrl'], :page_url => element['PageUrl'], :mailbox_id => element['MailboxId'], :text_cn => element['TextCn'], \n\t\t\t\t\t\t\t\t:photo_list_cn => element['PhotoListCn'], :group_index => element['GroupIndex'], :title => element['Title'], :owner => element['Owner'])\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\t#group_elements = load_group element['Id']\n\t\t\t\t\t\t\telements << ZenfolioAPI::Model::Group.new(:id => element['Id'], :created_on => element['CreatedOn']['Value'], :modified_on => element['ModifiedOn']['Value'], \n\t\t\t\t\t\t\t\t:page_url => element['PageUrl'], :mailbox_id => element['MailboxId'], :immediate_children_count => value['ImmediateChildrenCount'], :text_cn => element['TextCn'], \n\t\t\t\t\t\t\t\t:caption => element['Caption'], :collection_count => value['CollectionCount'], :sub_group_count => value['SubGroupCount'], :gallery_count => value['GalleryCount'],\n\t\t\t\t\t\t\t\t:featured_index => element['FeaturedIndex'], :is_random_title_photo => element['IsRandomTitlePhoto'], :upload_url => element['UploadUrl'],\n\t\t\t\t\t\t\t\t:photo_count => value['PhotoCount'], :parent_groups => value['ParentGroups'], :title => value['Title'])\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\n\t\t\t\t\t@groups << ZenfolioAPI::Model::Group.new(:id => value['Id'], :created_on => value['CreatedOn']['Value'], :modified_on => value['ModifiedOn']['Value'], \n\t\t\t\t\t\t:page_url => value['PageUrl'], :mailbox_id => value['MailboxId'], :immediate_children_count => value['ImmediateChildrenCount'], :text_cn => value['TextCn'],\n\t\t\t\t\t\t:caption => value['Caption'], :collection_count => value['CollectionCount'], :sub_group_count => value['SubGroupCount'], :gallery_count => value['GalleryCount'],\n\t\t\t\t\t\t:photo_count => value['PhotoCount'], :parent_groups => value['ParentGroups'], :elements => elements, :title => value['Title'])\n\t\t\t\tend\n\t\t\tend\n\n\t\t\t{:galleries => @galleries, :groups => @groups}\n\t\tend",
"def lists\n @lists = response[\"lists\"]\n if @lists and @lists[\"groups\"]\n @lists[\"groups\"].each do |group|\n group[\"items\"].map!{|item| Foursquared::Response::List.new(client, item)}\n end\n end\n @lists\n end",
"def groups(params = {})\n params = params.with_indifferent_access\n # compose params into a string\n # See http://code.google.com/apis/contacts/docs/3.0/reference.html#Parameters\n # alt, q, max-results, start-index, updated-min,\n # orderby, showdeleted, requirealldeleted, sortorder\n params[\"max-results\"] = 100000 unless params.key?(\"max-results\")\n url = \"groups/default/full\"\n # TODO: So weird thing, version 3 doesn't return system groups\n # When it does, uncomment this line and use it to request instead\n # response = @api.get(url, params)\n response = @api.get(url, params, {\"GData-Version\" => \"2\"})\n\n case defined?(response.code) ? response.code : response.status\n when 401; raise\n when 403; raise\n when 404; raise\n when 400...500; raise\n when 500...600; raise\n end\n GoogleContactsApi::GroupSet.new(response.body, @api)\n end",
"def get_full_data(data)\n @client.api_request(\n :method => \"usergroup.get\", \n :params => {\n :filter => [data[:name]],\n :output => \"extend\"\n }\n )\n end",
"def to_list\n\t\t# Binder.collection.group(key: :owner, cond: {}, initial: {count: 0}, reduce: \"function(doc,prev) {prev.count += +1;}\")\n\t\t# <query>.selector inserted into conditions field\n\t\trange = Range.new(grouphash['range'].first.to_i,grouphash['range'].last.to_i)\n\t\traw = kollection.titleize.constantize.collection.group(\t:key => grouphash['groupvals']['key'],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t:cond => grouphash['groupvals']['cond'],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t:initial => grouphash['groupvals']['initial'],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t:reduce => grouphash['groupvals']['reduce'])\n\t\traw = raw.map{ |f| { f['owner'] => f['count'].to_i } }\n\t\traw = raw.reject{ |f| range.cover?(f.first[1]) }\n\t\traw.map{ |f| f.first[0] }\n\tend",
"def show_groups\n content = Accio::Parser.read\n content.groups.each do |group|\n puts \"#{group.title}\\n\"\n end\n end",
"def groups\n group_ids.split(',').inject(Array.new) do |arr,gid|\n arr << Ecore::Group.where(:id => gid).first\n end\n end"
] | [
"0.66396314",
"0.6445772",
"0.63362515",
"0.61798525",
"0.61107934",
"0.61091864",
"0.60524076",
"0.60028595",
"0.59868133",
"0.5980988",
"0.59232754",
"0.59211445",
"0.5856983",
"0.58489615",
"0.58300185",
"0.58300185",
"0.57403326",
"0.57222676",
"0.5701474",
"0.56954473",
"0.56912124",
"0.5666923",
"0.5634933",
"0.56226486",
"0.55706114",
"0.55665624",
"0.55364555",
"0.55364555",
"0.55364555",
"0.5521698",
"0.55082995",
"0.5499934",
"0.5491139",
"0.5490404",
"0.5485806",
"0.548337",
"0.5477371",
"0.547456",
"0.5471919",
"0.5453642",
"0.54466575",
"0.54466575",
"0.54366183",
"0.5428832",
"0.54277456",
"0.54271734",
"0.5421781",
"0.54171234",
"0.5409466",
"0.5393901",
"0.53899854",
"0.53862226",
"0.5385279",
"0.5383773",
"0.53792995",
"0.53778327",
"0.53604114",
"0.53539544",
"0.5352382",
"0.5342036",
"0.53307676",
"0.53307676",
"0.53148717",
"0.5309897",
"0.53019756",
"0.5290124",
"0.52896136",
"0.52807486",
"0.5274525",
"0.52472746",
"0.52405316",
"0.5239938",
"0.5234044",
"0.523253",
"0.52316016",
"0.5216232",
"0.52124715",
"0.5211575",
"0.52080554",
"0.52061087",
"0.52027005",
"0.51987237",
"0.5194852",
"0.5187805",
"0.5187805",
"0.5186868",
"0.518628",
"0.5183492",
"0.517065",
"0.51704925",
"0.5166507",
"0.51661974",
"0.51651865",
"0.516353",
"0.5157628",
"0.5155566",
"0.515231",
"0.5150378",
"0.51427156",
"0.51426256"
] | 0.5506566 | 31 |
Ensure valid credentials, either by restoring from the saved credentials files or intitiating an OAuth2 authorization. If authorization is required, the user's default browser will be launched to approve the request. | def authorize(force_reload)
FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))
client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)
token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)
authorizer = Google::Auth::UserAuthorizer.new(
client_id, SCOPE, token_store)
user_id = 'default'
credentials = authorizer.get_credentials(user_id)
if force_reload || credentials.nil?
session[:is_authorized] = false
redirect_to google_fetch_path
return
end
credentials
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authorize\r\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\r\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\r\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\r\n user_id = \"default\"\r\n credentials = authorizer.get_credentials user_id\r\n\r\n # launch default browser to approve request of initial OAuth2 authorization\r\n if credentials.nil?\r\n url = authorizer.get_authorization_url base_url: OOB_URI\r\n puts \"Open the following URL in the browser and enter the resulting code after authorization:\\n\" + url\r\n code = gets\r\n credentials = authorizer.get_and_store_credentials_from_code(user_id: user_id, code: code, base_url: OOB_URI)\r\n end\r\n\r\n credentials\r\nend",
"def authorize\n FileUtils.mkdir_p(File.dirname(@CREDENTIALS_PATH))\n\n file_store = Google::APIClient::FileStore.new(@CREDENTIALS_PATH)\n storage = Google::APIClient::Storage.new(file_store)\n auth = storage.authorize\n\n if auth.nil? || (auth.expired? && auth.refresh_token.nil?)\n app_info = Google::APIClient::ClientSecrets.load(@CLIENT_SECRETS_PATH)\n flow = Google::APIClient::InstalledAppFlow.new({\n :client_id => app_info.client_id,\n :client_secret => app_info.client_secret,\n :scope => @SCOPE})\n auth = flow.authorize(storage)\n puts \"Credentials saved to #{@CREDENTIALS_PATH}\" unless auth.nil?\n end\n auth\n end",
"def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIAL))\n file_store = Google::APIClient::FileStore.new(CREDENTIAL)\n storage = Google::APIClient::Storage.new(file_store)\n auth = storage.authorize\n if auth.nil? || (auth.expired? && auth.refresh_token.nil?)\n app_info = Google::APIClient::ClientSecrets.load(CLIENT_SECRET)\n flow = Google::APIClient::InstalledAppFlow.new({\n :client_id => app_info.client_id,\n :client_secret => app_info.client_secret,\n :scope => SCOPE})\n auth = flow.authorize(storage)\n puts \"Credentials saved to #{CREDENTIAL}\" unless auth.nil?\n end\n auth\n end",
"def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n credentials = authorizer.get_credentials('default')\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n\n server = WEBrick::HTTPServer.new(Port: 3000)\n server.mount_proc('/oauth2callback') do |req, res|\n code = req.query['code']\n credentials = authorizer.get_and_store_credentials_from_code(user_id: 'default', code: code, base_url: OOB_URI)\n res.body = 'Authorization successful. You can close this window and return to the terminal.'\n server.shutdown\n end\n\n warn('Open the following URL in your browser and authorize the app:')\n warn(url)\n server.start\n end\n credentials\nend",
"def authorize interactive\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil? and interactive\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n code = ask(\"Open the following URL in the browser and enter the resulting code after authorization\\n\" + url)\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend",
"def authorize\n FileUtils.mkdir_p(File.dirname(@CREDENTIALS_PATH))\n client_id = Google::Auth::ClientId.from_file(@CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: @CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, @SCOPE, token_store)\n\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: @OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: @OOB_URI)\n end\n credentials\n end",
"def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n \n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\n end",
"def find_or_prompt_for_credentials\n client_id = Google::Auth::ClientId.from_hash(CLIENT_SECRET_HASH)\n token_store = Google::Auth::Stores::RedisTokenStore.new(:prefix => REDIS_KEY_PREFIX)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization:\"\n puts url\n\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n\n credentials\n end",
"def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n\n # changed SCOPE to SCOPES to pass in multiple OAUTH scopes\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPES, token_store)\n\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\n end",
"def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' +\n 'resulting code after authorization'\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\n end",
"def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n file_store = Google::APIClient::FileStore.new(CREDENTIALS_PATH)\n storage = Google::APIClient::Storage.new(file_store)\n auth = storage.authorize\n\n if auth.nil? || (auth.expired? && auth.refresh_token.nil?)\n app_info = Google::APIClient::ClientSecrets.load(CLIENT_SECRETS_PATH)\n flow = Google::APIClient::InstalledAppFlow.new({\n client_id: app_info.client_id,\n client_secret: app_info.client_secret,\n scope: SCOPE})\n auth = flow.authorize(storage)\n puts \"Credentials saved to #{CREDENTIALS_PATH}\" unless auth.nil?\n end\n auth\nend",
"def authorize(interactive)\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store, '')\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil? && interactive\n url = authorizer.get_authorization_url(base_url: BASE_URI, scope: SCOPE)\n code = ask(\"Open the following URL in the browser and enter the resulting code after authorization\\n#{url}\")\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: BASE_URI\n )\n end\n credentials\nend",
"def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n file_store = Google::APIClient::FileStore.new(CREDENTIALS_PATH)\n storage = Google::APIClient::Storage.new(file_store)\n auth = storage.authorize\n\n if auth.nil? || (auth.expired? && auth.refresh_token.nil?)\n app_info = Google::APIClient::ClientSecrets.load(CLIENT_SECRETS_PATH)\n flow = Google::APIClient::InstalledAppFlow.new({\n :client_id => app_info.client_id,\n :client_secret => app_info.client_secret,\n :scope => SCOPE})\n auth = flow.authorize(storage)\n puts \"Credentials saved to #{CREDENTIALS_PATH}\" unless auth.nil?\n end\n auth\nend",
"def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n file_store = Google::APIClient::FileStore.new(CREDENTIALS_PATH)\n storage = Google::APIClient::Storage.new(file_store)\n auth = storage.authorize\n\n if auth.nil? || (auth.expired? && auth.refresh_token.nil?)\n app_info = Google::APIClient::ClientSecrets.load(CLIENT_SECRETS_PATH)\n flow = Google::APIClient::InstalledAppFlow.new({\n :client_id => app_info.client_id,\n :client_secret => app_info.client_secret,\n :scope => SCOPE})\n auth = flow.authorize(storage)\n end\n auth\nend",
"def authorize\n client_id = Google::Auth::ClientId.from_file(self.credentials_path)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: self.token_path)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPES, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\n end",
"def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = ask \"code?: \"\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\n end",
"def authorize\r\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\r\n\r\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\r\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\r\n authorizer = Google::Auth::UserAuthorizer.new(\r\n client_id, SCOPE, token_store)\r\n user_id = 'default'\r\n credentials = authorizer.get_credentials(user_id)\r\n if credentials.nil?\r\n url = authorizer.get_authorization_url(\r\n base_url: OOB_URI)\r\n puts \"Open the following URL in the browser and enter the \" +\r\n \"resulting code after authorization\"\r\n puts url\r\n code = gets\r\n credentials = authorizer.get_and_store_credentials_from_code(\r\n user_id: user_id, code: code, base_url: OOB_URI)\r\n end\r\n credentials\r\nend",
"def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend",
"def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend",
"def authorize\n\tFileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n\tclient_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n\ttoken_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n\tauthorizer = Google::Auth::UserAuthorizer.new(\n\t\tclient_id, SCOPE, token_store)\n\tuser_id = 'default'\n\tcredentials = authorizer.get_credentials(user_id)\n\tif credentials.nil?\n\t\turl = authorizer.get_authorization_url(\n\t\t\tbase_url: OOB_URI)\n\t\tputs \"Open the following URL in the browser and enter the \" +\n\t\t\"resulting code after authorization\"\n\t\tputs url\n\t\tcode = STDIN.gets\n\t\tcredentials = authorizer.get_and_store_credentials_from_code(\n\t\t\tuser_id: user_id, code: code, base_url: OOB_URI)\n\tend\n\tcredentials\nend",
"def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = $stdin.gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend",
"def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\n end",
"def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\n end",
"def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI,\n )\n end\n credentials\n end",
"def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = 'default'\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\n end",
"def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend",
"def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend",
"def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend",
"def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend",
"def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend",
"def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend",
"def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend",
"def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = $stdin.readline()\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend",
"def authorize\r\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\r\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\r\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\r\n user_id = \"default\"\r\n credentials = authorizer.get_credentials user_id\r\n if credentials.nil?\r\n url = authorizer.get_authorization_url base_url: OOB_URI\r\n puts \"Open the following URL in the browser and enter the \" \\\r\n \"resulting code after authorization:\\n\" + url\r\n code = gets\r\n credentials = authorizer.get_and_store_credentials_from_code(\r\n user_id: user_id, code: code, base_url: OOB_URI\r\n )\r\n end\r\n credentials\r\nend",
"def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n # client_id = Google::Auth::ClientId.from_hash(Rails.application.config.gdrive_secrets)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store\n )\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI\n )\n puts 'Open the following URL in the browser and enter the ' \\\n 'resulting code after authorization'\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\n end",
"def authorize\r\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\r\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\r\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\r\n user_id = 'default'\r\n credentials = authorizer.get_credentials(user_id)\r\n if credentials.nil?\r\n url = authorizer.get_authorization_url(base_url: OOB_URI)\r\n puts 'Open the following URL in the browser and enter the ' \\\r\n \"resulting code after authorization:\\n\" + url\r\n code = gets\r\n credentials = authorizer.get_and_store_credentials_from_code(\r\n user_id: user_id, code: code, base_url: OOB_URI\r\n )\r\n end\r\n credentials\r\nend",
"def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPES, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\n end",
"def authorize\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n\n credentials = authorizer.get_credentials(user_id)\n\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n\n credentials\n end",
"def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\n end",
"def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.\n new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.\n new(client_id, SCOPE, token_store)\n credentials = authorizer.\n get_credentials(CONFIGURATION[\"calendar\"][\"user_id\"])\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \"\\\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: CONFIGURATION[\"calendar\"][\"user_id\"],\n code: code,\n base_url: OOB_URI\n )\n end\n credentials\n end",
"def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\n end",
"def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI,\n )\n end\n credentials\nend",
"def authorize\n ##FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n if !File.exist?(CLIENT_SECRETS_PATH)\n puts \"Error: OAuth2認証用のsecretファイルが見つかりませんでした\"\n puts \"以下のURLからこのプロジェクト用のsecretを作成し、'client_secret.json'というファイル名でこのディレクトリに保存してください。\"\n puts\n puts \"https://console.developers.google.com/start/api?id=sheets.googleapis.com\"\n exit 1\n end\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts \"以下のURLにWebブラウザでアクセスし、認証を行った後、表示されるコードを入力してください:\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend",
"def authorize\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\n end",
"def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend",
"def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend",
"def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend",
"def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend",
"def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend",
"def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend",
"def authorize\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n 'resulting code after authorization:\\n' + url\n code = $stdin.gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend",
"def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend",
"def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend",
"def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend",
"def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend",
"def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend",
"def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend",
"def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend",
"def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend",
"def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend",
"def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend",
"def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend",
"def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend",
"def authorize\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n 'resulting code after authorization:\\n' + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend",
"def authorize\n return credentials if credentials\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = $stdin.gets\n authorizer.get_and_store_credentials_from_code(\n user_id: user_id,\n code: code,\n base_url: OOB_URI\n )\n end",
"def authorize\n client_id = Google::Auth::ClientId.from_file(@credentials_path)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: @token_path)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, @scope, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: @oob_uri)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: @oob_uri\n )\n end\n credentials\n end",
"def authorize\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code( user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend",
"def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend",
"def authorize(credentials_path, secrets_path, scope)\n\n FileUtils.mkdir_p(File.dirname(credentials_path))\n\n file_store = Google::APIClient::FileStore.new(credentials_path)\n storage = Google::APIClient::Storage.new(file_store)\n auth = storage.authorize\n\n if auth.nil? || (auth.expired? && auth.refresh_token.nil?)\n app_info = Google::APIClient::ClientSecrets.load(secrets_path)\n flow = Google::APIClient::InstalledAppFlow.new({\n :client_id => app_info.client_id,\n :client_secret => app_info.client_secret,\n :scope => scope})\n auth = flow.authorize(storage)\n puts \"Credentials saved to #{credentials_path}\" unless auth.nil?\n end\n auth\n end",
"def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the resulting code after authorization:\\n\\n\"\n puts url\n print \"\\nCode: \"\n code = gets\n puts\n credentials = authorizer.get_and_store_credentials_from_code(user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend",
"def check_credentials\n raise \"Please set load_configuration with #{RightSignature2013::Connection.api_token_keys.join(',')} or #{RightSignature2013::Connection.oauth_keys.join(',')}\" unless has_api_token? || has_oauth_credentials?\n end",
"def valid_for_http_auth?; end",
"def authorize\n credentialsFile = FILE_POSTFIX\n\n if File.exist? credentialsFile\n File.open(credentialsFile, 'r') do |file|\n credentials = JSON.load(file)\n @authorization.access_token = credentials['access_token']\n @authorization.client_id = credentials['client_id']\n @authorization.client_secret = credentials['client_secret']\n @authorization.refresh_token = credentials['refresh_token']\n @authorization.expires_in = (Time.parse(credentials['token_expiry']) - Time.now).ceil\n if @authorization.expired?\n @authorization.fetch_access_token!\n save(credentialsFile)\n end\n end\n else\n auth = @authorization\n url = @authorization.authorization_uri().to_s\n server = Thin::Server.new('0.0.0.0', 8081) do\n run lambda { |env|\n # Exchange the auth code & quit\n req = Rack::Request.new(env)\n auth.code = req['code']\n auth.fetch_access_token!\n server.stop()\n [200, {'Content-Type' => 'text/html'}, RESPONSE_HTML]\n }\n end\n\n Launchy.open(url)\n server.start()\n\n save(credentialsFile)\n end\n\n return @authorization\n end",
"def authorize\n\tclient_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n\ttoken_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n\tauthorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n\tuser_id = 'default'\n\n\tcredentials = authorizer.get_credentials(user_id)\n\treturn credentials unless credentials.nil?\n\n\turl = authorizer.get_authorization_url(base_url: OOB_URI)\n\tputs 'Open the following URL in the browser and enter the ' \\\n\t\t \"resulting code after authorization:\\n#{url}\"\n\tcode = gets\n\n\treturn authorizer.get_and_store_credentials_from_code(\n\t\tbase_url: OOB_URI,\n\t\tuser_id: user_id,\n\t\tcode: code,\n\t)\n\nend",
"def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the resulting code after authorization:\"\n puts url\n puts \"\"\n puts \"paste code here:\"\n code = gets\n\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend",
"def authorize(credentials)\n credentials_path = \"#{PATH}#{credentials}-gmail.json\"\n token_path = \"#{PATH}#{credentials}-token.yaml\"\n client_id = Google::Auth::ClientId.from_file credentials_path\n token_store = Google::Auth::Stores::FileTokenStore.new file: token_path\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = 'default'\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend",
"def authorize(token_path, scope)\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: token_path\n authorizer = Google::Auth::UserAuthorizer.new client_id, scope, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend",
"def authorize\n client_id = create_client_id\n token_store = create_token_store\n\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI\n )\n Rails.logger.debug do\n 'Open the following URL in the browser and enter the ' \\\n 'resulting code after authorization'\n end\n Rails.logger.debug url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id:, code:, base_url: OOB_URI\n )\n end\n credentials\n end",
"def verify_credentials!\n raise AuthenticationError.new(\"missing client code\") if Applitrack.client_code.nil? || Applitrack.client_code.empty?\n raise AuthenticationError.new(\"missing username\") if Applitrack.username.nil? || Applitrack.username.empty?\n raise AuthenticationError.new(\"missing password\") if Applitrack.password.nil? || Applitrack.password.empty?\n end",
"def check_auth_expiration(auth, client_secrets_path, scope)\n return false unless auth.nil? ||\n (auth.expired? && auth.refresh_token.nil?)\n app_info = Google::APIClient::ClientSecrets.load(client_secrets_path)\n flow = Google::APIClient::InstalledAppFlow.new(\n client_id: app_info.client_id,\n client_secret: app_info.client_secret,\n scope: scope)\n auth = flow.authorize(storage)\n puts \"Credentials saved to #{credentials_path}\" unless auth.nil?\n end",
"def prompt_user_authorisation\n\n require './app/routes/web'\n\n # Start local API\n Launchy.open(\"http://localhost:5000/cli/auth\")\n\n auth_thread = Thread.new do\n Linkedin2CV::Routes::Web.run!\n end\n\n auth_thread\n end",
"def auth_process\n\t\tif @auth_file.authorization.nil?\n \t\t\tmake_auth\n\t\telse\n\t\t\[email protected] = @auth_file.authorization\n\t\tend\n\tend",
"def grant_authorization\n create_verification_code if authorized?\n redirect_back\n end",
"def ensure_auth # rubocop:disable Metrics/AbcSize, Metrics/MethodLength\n if session[:prospect_params]\n # we have an application going so we've probably just refreshed the\n # screen\n redirect_to action: 'new', controller: 'prospects'\n elsif session[:cas].nil? || session[:cas][:user].nil?\n render status: :unauthorized, plain: 'Redirecting to SSO...'\n else\n user = User.find_by cas_directory_id: session[:cas][:user]\n if user.nil?\n render status: :forbidden, plain: 'Unrecognized user'\n else\n update_current_user(user)\n end\n end\n nil\n end",
"def authorize\n\t\tclient_id = Google::Auth::ClientId.new(@config[\"AuthKey\"], @config[\"AuthSecret\"])\n\t\ttoken_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n\t\tauthorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n\t\tuser_id = \"default\"\n\t\tLOGGER.debug \"[GmailDriver#authorize] Authorizing...\"\n\t\tcredentials = authorizer.get_credentials(user_id)\n\t\tif credentials.nil?\n\t\t\turl = authorizer.get_authorization_url(base_url: OOB_URI)\n\t\t\tLOGGER.warn \"Open the following URL in the browser and enter the \" \\\n\t\t\t\t\t \"resulting code after authorization:\\n\" + url\n\t\t\tcode = gets\n\t\t\tcredentials = authorizer.get_and_store_credentials_from_code(\n\t\t\t\tuser_id: user_id, code: code, base_url: OOB_URI\n\t\t\t)\n\t\tend\n\t\tcredentials\n\tend",
"def authorize!(current_user)\n @authorized = false\n oauth_drive_token = OauthDriveToken.get_provider_for(current_user, APP_CONFIG['oauth']['google']['provider_number'])\n if oauth_drive_token.present?\n # Set details\n @client.authorization.access_token = oauth_drive_token.access_token\n @client.authorization.refresh_token = oauth_drive_token.refresh_token\n @client.authorization.client_id = oauth_drive_token.client_number\n\n if oauth_drive_token.expires_at < Time.now\n # Present but expired, attempt to refresh\n @authorized = true if self.refresh_token(oauth_drive_token)\n elsif self.current_token_still_valid?\n @authorized = true\n else\n # Not valid so destroy it and prompts for re-auth\n oauth_drive_token.destroy\n end\n end\n end",
"def request_authorization\n create_ticket\n verify_resource_owner or return\n render_authorize_form\n end",
"def setup_credentials\n unless yes?('Would you like to configure and store your credentials?')\n $stderr.puts \"Unable to proceed without credentials\"\n exit 1\n end\n\n begin\n choice = choose do |menu|\n menu.prompt = 'Which type of credentials would you like to set up? (token is highly recommended) '\n menu.choices(:password, :token, :none)\n end.to_sym\n end until [:password, :token, :none].include? choice\n\n if choice == :password\n setup_password_credentials\n elsif choice == :token\n setup_token_credentials\n else\n return false\n end\n rescue StandardError => e\n options.debug ? warn(e) : raise(e)\n false\n end",
"def user_credentials_for(scope)\n FileUtils.mkdir_p(File.dirname(token_store_path))\n\n if ENV['GOOGLE_CLIENT_ID']\n client_id = Google::Auth::ClientId.new(ENV['GOOGLE_CLIENT_ID'], ENV['GOOGLE_CLIENT_SECRET'])\n else\n client_id = Google::Auth::ClientId.from_file(client_secrets_path)\n end\n token_store = Google::Auth::Stores::FileTokenStore.new(:file => token_store_path)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, scope, token_store)\n\n user_id = options[:user] || 'default'\n\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n say \"Open the following URL in your browser and authorize the application.\"\n say url\n code = ask \"Enter the authorization code:\"\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\n end",
"def credentials(authorization, request); end",
"def authorise\n # checks can go here (is the application registered for example)\n grant = generate_grant\n valid_grants << grant\n grant\n end",
"def oauth\n\t\tdropbox = DropboxConnection.new\n\t\n\t\tif params[:not_approved] == 'true'\n\t\t\tredirect_to dropbox_path, flash: { error: 'You just cancelled, didn\\'t you?' }\n\t\telse\n\t\t\t# the user has returned from Dropbox so save the session and go away\n\t\t\tdropbox.authorized\n\t\t\tredirect_to :root\n\t\tend\n\tend",
"def login_required\n return if authorized?\n unauthorized! unless auth.provided?\n bad_request! unless auth.basic?\n unauthorized! unless authorize(*auth.credentials)\n @req.env['REMOTE_USER'] = auth.username\n end",
"def authorize\n @credentials = authorizer.get_credentials(user_id)\n if @credentials.nil? || @credentials.expired?\n raise CalendarBot::AuthorizationError\n end\n\n @credentials\n end",
"def login_required\n authorized? || throw(:halt, :access_denied)\n end",
"def oauth_token_required\n unless oauth_token\n headers['WWW-Authenticate'] = 'Bearer'\n halt 403, 'OAuth token required'\n end\n end",
"def authorize\n client_id = Google::Auth::ClientId.from_file(ENV['CREDENTIALS_PATH'])\n token_store = Google::Auth::Stores::FileTokenStore.new(file: ENV['TOKEN_PATH'])\n authorizer = Google::Auth::UserAuthorizer.new(client_id, ENV['SCOPE'], token_store)\n user_id = 'default'\n authorizer.get_credentials(user_id)\n end",
"def login_required\n authorized? || throw(:halt, :access_denied)\n end",
"def check_authorization\n # Decode Basic Auth, future jwt?\n require 'base64'\n\n credentials = request.headers['Authorization']\n\n if credentials.nil?\n render json: { error: 'Missing credentials, Authorization: Basic Auth ([email protected]:usertwo)'}, status: :forbidden\n else\n # Split > decode > split\n credentials = Base64.decode64(credentials.split[1]).split(':')\n\n # Get the creator by email\n @current_creator = Creator.find_by(email: credentials[0].downcase)\n\n # If nil and not able to authenticate with the password, return forbidden 403\n unless @current_creator && @current_creator.authenticate(credentials[1])\n render json: { error: 'Not authorized! Wrong credentials!'}, status: :forbidden\n end\n end\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"
] | [
"0.6933457",
"0.6722908",
"0.6659495",
"0.6651997",
"0.65571547",
"0.6526237",
"0.6499632",
"0.6494427",
"0.64732134",
"0.6464933",
"0.6456424",
"0.6455739",
"0.6452815",
"0.64510006",
"0.64500266",
"0.6441912",
"0.64387083",
"0.6409544",
"0.6401161",
"0.6396016",
"0.6394851",
"0.6386449",
"0.6386449",
"0.63822603",
"0.6380869",
"0.63802975",
"0.63802975",
"0.63802975",
"0.63802975",
"0.63802975",
"0.63802975",
"0.63698065",
"0.6350384",
"0.63406366",
"0.63345104",
"0.6333077",
"0.6332146",
"0.63321346",
"0.6328852",
"0.6327916",
"0.6326404",
"0.63251656",
"0.63239074",
"0.63225955",
"0.63218546",
"0.63218546",
"0.63218546",
"0.63218546",
"0.6318447",
"0.6318447",
"0.6304917",
"0.6300875",
"0.62991303",
"0.62991303",
"0.62991303",
"0.62991303",
"0.62991303",
"0.62991303",
"0.62991303",
"0.62991303",
"0.62991303",
"0.62991303",
"0.62991303",
"0.6288518",
"0.6279551",
"0.62685984",
"0.62504655",
"0.6248431",
"0.62474567",
"0.6232993",
"0.62255824",
"0.6191186",
"0.6186282",
"0.6129205",
"0.6103629",
"0.60287446",
"0.59759015",
"0.5947787",
"0.59412086",
"0.58529264",
"0.5842849",
"0.583877",
"0.58361536",
"0.5830364",
"0.580739",
"0.5804176",
"0.58001465",
"0.579972",
"0.57854116",
"0.5767598",
"0.57584345",
"0.5725881",
"0.57136655",
"0.570766",
"0.56811196",
"0.56528664",
"0.5639045",
"0.5627202",
"0.56163895",
"0.56143564"
] | 0.6271662 | 65 |
Gets all the bookmark reports from the database Should return true if the length is 4 | def test_get_all_bookmark_reports
reports = BookmarkReport.getAll()
assert_equal 4, reports.length
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_all_bookmark_reports_details\n \n reports = BookmarkReport.getAll()\n\n report = reports[0]\n \n assert_equal 1, report.bookmarkId\n assert_equal 1, report.userId\n assert_equal 'something', report.issue\n assert_equal 'report', report.description\n\n end",
"def get_all_bookmarks\n begin\n \n if @filename == ''\n raise 'filename not specified'\n end\n \n \n total_bookmarks = self.get_bookmarks_count\n \n all_bookmarks = Array.new\n \n index = 1\n while index <= total_bookmarks\n \n all_annotations.push(self.get_bookmark(index))\n \n index+=1\n end\n \n return all_bookmarks\n \n \n rescue Exception=>e\n print e\n end\n end",
"def index\n @bookmarks = Bookmark.all\n \n @test = Bookmark.where(\"url = ?\", :url =>\"http://google.com\")\n \n @duplicates = Bookmark.find(:all,\n :select => \"url, COUNT(url) AS duplicate_count\",\n :conditions => \"url IS NOT NULL AND url != ''\",\n :group => \"url HAVING duplicate_count > 1\")\n \n @urlcount = Bookmark.count(:group => :url,\n :conditions => \"url IS NOT NULL AND url != ''\")\n \n @getuid = Bookmark.find(:all,\n :select => \"user_id, name\",\n :conditions => \"user_id =='4'\")\n \n @getallpeople = Bookmark.find(:all,\n :select => \"url, user_id\",\n :conditions => \"url = 'http://google.com'\")\n \n @getname = User.find(:all,\n :select => \"username\", :conditions => \"id = '4'\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @bookmarks }\n end\n end",
"def index\n\t\t@bookmarks = Bookmark.all\n\tend",
"def index\n @bookmarks = Bookmark.all\n end",
"def index\n @bookmarks = Bookmark.all\n end",
"def index\n @public_bookmarks = PublicBookmark.all\n end",
"def index\n @nagayoshi_bookmark_logs = NagayoshiBookmarkLog.all\n end",
"def index\n @solicitation_bookmarks = SolicitationBookmark.all\n end",
"def index\n @bookmarks = Bookmark.user_bookmarks(current_user)\n end",
"def index\n @reporte_links = ReporteLink.all\n end",
"def bookmarks\n\t\toptions = { list: true }\n\t\tresponse = self.server.run_with_json_template( :bookmarks, **options )\n\t\treturn response.map {|bk| Hglib::Repo::Bookmark.new(self, **bk) }\n\tend",
"def index\n\t\trespond_with current_user.bookmarks\n\tend",
"def bookmarks\n xpath './bookmark'\n end",
"def index\n @results = []\n \n Bookmark.all.each do |b|\n user_url = \"/\" + b.user.name\n entry = {id: b.id, url: b.url, title: b.title, user: b.user, name: b.user.name, user_url: user_url }\n @results.push(entry)\n end\n end",
"def index\n @bookmarks = Bookmark.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @bookmarks }\n end\n end",
"def index\n @bookmarks = BookmarkLister.new(@tag || current_user)\n .(query: params[:q], by: params[:by])\n .to_a\n end",
"def index\n @bookmarks = Bookmark.order(\"updated_at DESC\").page(params[:page]).per_page(10)\n\n respond_with @bookmarks\n end",
"def get_bookmarks\n @logger.debug \"Fetching bookmarks from Delicious\"\n bookmarks = []\n doc = REXML::Document.new(open(\"http://feeds.delicious.com/v2/rss/#{@username}?count=5\"))\n doc.each_element('//channel/item') do |item|\n bookmarks << {\n :title => item.get_text('title'),\n :url => item.get_text('link'),\n :date => Date.parse(item.get_text('pubDate').to_s)\n }\n end\n return bookmarks\n end",
"def index\n if params[:dress_id]\n @bookmarks = @bookmarks.where(\"bookmarkable_id = ?\", params[:dress_id])\n elsif params[:vendor_id]\n @bookmarks = @bookmarks.where(\"bookmarkable_id = ?\", params[:vendor_id])\n end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookmarks }\n end\n end",
"def index\n\t\t\t\tbookmarks = Bookmark.where(\"user_id == ?\", doorkeeper_token.resource_owner_id)\n\t\t\t\tformatted_bookmarks = []\n\t\t\t\tbookmarks.each do |bookmark|\n\t\t\t\t formatted_tags = []\n\t\t\t\t bookmark.tags.each do |tag|\n\t\t\t\t formatted_tags << tag.tagname\n\t\t\t\t end\t\t\t \n\t\t\t\t formatted_bookmarks << {:id => bookmark.id, :url => bookmark.url.url, :title => bookmark.title, :description => bookmark.description, :tags => formatted_tags}\n\t\t\t\tend\n\t\t\t\trespond_with formatted_bookmarks\n\t\t\tend",
"def index\n @bookmarklets = Bookmarklet.find(:all)\n if logged_in?\n @user_bookmarkltes = current_user.bookmarklets\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @bookmarklets }\n end\n end",
"def is_child_bookmark bookmark_index\n begin\n \n if @filename == ''\n raise 'filename not specified'\n end\n \n if bookmark_index == ''\n raise 'bookmark index not specified'\n end\n \n \n str_uri = $product_uri + '/pdf/' + @filename + '/bookmarks/' + bookmark_index.to_s\n str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) \n response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})\n \n stream_hash = JSON.parse(response_stream)\n \n return stream_hash['Bookmark']\n \n \n rescue Exception=>e\n print e\n end\n end",
"def index\n @bookmarks = Bookmark.where(owner: current_user)\n end",
"def show_bookmarks(conditions, title, feed_uri, user=nil, tag=nil)\n errors = []\n\n # Make sure the specified limit is valid. If no limit is specified,\n # use the default.\n if params[:limit] && params[:limit].to_i < 0\n errors << \"limit must be >=0\"\n end\n params[:limit] ||= @@default_limit\n params.delete(:limit) if params[:limit] == 0 # 0 means \"no limit\"\n\n # If a date filter was specified, make sure it's a valid date.\n if params[:date]\n begin \n params[:date] = Date.parse(params[:date])\n rescue ArgumentError\n errors << \"incorrect date format\"\n end\n end\n\n if errors.empty?\n conditions ||= [\"\"]\n \n # Add a restriction by date if neccessary.\n if params[:date]\n conditions[0] << \" AND \" unless conditions[0].empty?\n conditions[0] << \"timestamp >= ? AND timestamp < ?\"\n conditions << params[:date]\n conditions << params[:date] + 1\n end\n\n # Restrict the list to bookmarks visible to the authenticated user.\n Bookmark.only_visible_to!(conditions, @authenticated_user)\n\n # Find a set of bookmarks that matches the given conditions.\n bookmarks = Bookmark.custom_find(conditions, tag, params[:limit])\n \n # Render the bookmarks however the client requested.\n render_bookmarks(bookmarks, title, feed_uri, user)\n else\n render :text => errors.join(\"\\n\"), :status => \"400 Bad Request\"\n end\n end",
"def fetch_reports\n # fetch all the reports using this method and then create a Report for each of them\n end",
"def index\n @bookmarks = Bookmark.all\n @bookmark = Bookmark.new\n end",
"def index\n @bookmarks = Bookmark.all\n @bookmark = Bookmark.new\n end",
"def index\n # testing some params\n user = nil\n if params[:username]\n user = User.find_by_name(params[:username])\n if user == nil\n redirect_to :controller => :application, :action => :index, :notice => \"User not found\"\n return\n end\n end\n # building conditions\n conditions = Array.new\n conditions[0] = \"\"\n if params[:fromdt]\n conditions[0] = \"bookmarked_at >= ?\"\n conditions << DateTime.parse(params[:fromdt])\n end\n if params[:todt]\n conditions[0] += \" AND \" if params[:fromdt]\n conditions[0] += \"bookmarked_at <= ?\"\n conditions << DateTime.parse(params[:todt])\n end\n if params[:username]\n # filter private ones\n conditions[0] += \" AND \" if (params[:fromdt] || params[:todt])\n conditions[0] += \"private = ?\"\n conditions << 0\n elsif params[:all_users]\n user = nil\n elsif current_user\n user = current_user\n elsif (!current_user && !params[:username] && !params[:all_users])\n redirect_to :controller => :application, :action => :index\n end\n if params[:tag]\n limit = \"ALL\"\n if ActiveRecord::Base.connection.class.to_s.split('::')[-1].gsub(\"Adapter\",'') == \"SQLite3\"\n limit = -1\n end\n tags = params[:tag].split(/[ +]/)\n if user\n posts = user.bookmarks.tagged_with(params[:tag], :match_all => true).find(:all, :offset => (params[:start] || 0), :limit => (params[:results] || limit), :conditions => conditions, :order => \"bookmarked_at DESC\")\n else\n posts = Bookmark.tagged_with(params[:tag], :match_all => true).find(:all, :offset => (params[:start] || 0), :limit => (params[:results] || limit), :conditions => conditions, :order => \"bookmarked_at DESC\")\n end\n else\n if user\n posts = user.bookmarks.find(:all, :offset => (params[:start] || 0), :limit => (params[:results] || limit), :conditions => conditions, :order => \"bookmarked_at DESC\")\n else\n posts = Bookmark.find(:all, :offset => (params[:start] || 0), :limit => (params[:results] || limit), :conditions => conditions, :order => \"bookmarked_at DESC\")\n end\n end\n # filter private ones\n the_posts = Array.new\n posts.each do |post|\n if post.private?\n if current_user\n the_posts << post if (post.user == current_user)\n end\n else\n the_posts << post\n end\n end\n respond_to do |format|\n format.xml do\n if current_user\n xml_posts = Array.new\n the_posts.each do |post|\n tags = Array.new\n post.tags.each { |t| tags << t.name } if post.tags.count > 0\n xml_posts << {\"href\" => post.link.url, \"description\" => post.title, \"tag\" => tags.join(' ')}\n end\n meta = Digest::MD5.hexdigest(current_user.name + current_user.updated_at.utc.strftime(\"%Y-%m-%dT%H:%M:%SZ\"))\n posts = {:user => current_user.name, :update => current_user.updated_at.utc.strftime(\"%Y-%m-%dT%H:%M:%SZ\"), :hash => meta, :tag => \"\", :total => current_user.bookmarks.size, :post => xml_posts}\n xml_output = \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n\" + XmlSimple.xml_out(posts).gsub(\"opt\",\"posts\")\n render :xml => xml_output\n else\n render :xml => \"<?xml version='1.0' standalone='yes'?>\\n<result code=\\\"something went wrong\\\" />\"\n end\n end\n end\n end",
"def index\n @categorybookmarks = CategoryBookmark.all\n end",
"def index\n# Bookmark.destroy_all\n# @bookmarks = Bookmark.all\n\n# Get all bookmarks related to user where the primary key of User record is in session[:user_id]\n @bookmarks =User.find(session[:user_id]).bookmarks.scoped\n @[email protected](:name)\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookmarks }\n end\n end",
"def get_bookmarks_count\n begin\n \n if @filename == ''\n raise 'filename not specified'\n end\n \n \n str_uri = $product_uri + '/pdf/' + @filename + '/bookmarks'\n str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) \n response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})\n \n stream_hash = JSON.parse(response_stream)\n \n return stream_hash['Bookmarks']['List'].length\n \n \n rescue Exception=>e\n print e\n end\n end",
"def bookmarks\n full = options[:full]\n docs = options[:doc] && documents.map { |doc| [doc.id, doc] }.to_h\n item_list.map { |item|\n next unless item.is_a?(Bookmark)\n entry = {\n document_id: item.document_id,\n document_type: item.document_type.to_s,\n lens: item.lens,\n updated_at: item.updated_at,\n created_at: item.created_at,\n }\n full && entry.merge!(\n title: item.user_type, # TODO: not persisted; should it be?\n id: item.id,\n user_id: item.user_id,\n user_type: item.user_type,\n )\n docs && entry.merge!(doc: docs[item.document_id])\n entry\n }.compact.as_json\n end",
"def get_bookmark bookmark_index\n begin\n \n if @filename == ''\n raise 'filename not specified'\n end\n \n if bookmark_index == ''\n raise 'bookmark index not specified'\n end\n \n \n str_uri = $product_uri + '/pdf/' + @filename + '/bookmarks/' + bookmark_index.to_s\n str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) \n response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})\n \n stream_hash = JSON.parse(response_stream)\n \n return stream_hash['Bookmark']\n \n \n rescue Exception=>e\n print e\n end\n end",
"def get_da_urls (doc,comment_url)\n doc.search('table tbody tr').each do |tr|\n # Columns in table\n # Show Number Submitted Details\n tds = tr.search('td')\n\n break if tds[0].inner_text =~ /no records/\n\n h = tds.map{|td| td.inner_html}\n\n puts h\n info_url = 'https://pdonline.toowoombarc.qld.gov.au/Masterview/Modules/ApplicationMaster/' + tds[0].at('a')['href'].strip\n puts info_url\n descParts = h[3].split('<br>')\n record = {\n 'info_url' => info_url,\n 'comment_url' => comment_url,\n 'council_reference' => clean_whitespace(h[1]),\n 'date_received' => Date.strptime(clean_whitespace(h[2]), '%d/%m/%Y').to_s,\n # TODO: Some DAs have multiple addresses, we're just getting the first :(\n 'address' => clean_whitespace(descParts[0]),\n 'description' => clean_whitespace(descParts[1]),\n 'date_scraped' => Date.today.to_s\n }\n\n if (ScraperWiki.select(\"* from data where `council_reference`='#{record['council_reference']}'\").empty? rescue true)\n ScraperWiki.save_sqlite(['council_reference'], record)\n else\n puts \"Skipping already saved record \" + record['council_reference']\n end\n end\nend",
"def bookmark_query(q,&blk)\n response = query(q)\n bookmark = response[\"bookmark\"]\n docs = response[\"docs\"]\n\n until !docs || docs.empty?\n yield docs\n q[\"bookmark\"] = bookmark\n response = query(q)\n bookmark = response[\"bookmark\"]\n docs = response[\"docs\"]\n end\n\n docs\n end",
"def index\n if logged_in?\n @bookmarks = @current_user.bookmarks.pluck(:story_id)\n respond_to do |format|\n format.json { render json: {ids: @bookmarks} }\n format.html { redirect_to bookmarks_url }\n end\n else\n redirect_to bookmarks_url\n end\n end",
"def index\n @journal_doc_reports = JournalDocReport.all\n end",
"def index\n search = Bookmark.search(:include => [:manifestation])\n query = params[:query].to_s.strip\n unless query.blank?\n @query = query.dup\n end\n user = @user\n unless current_user.has_role?('Librarian')\n if user and user != current_user and !user.try(:share_bookmarks)\n access_denied; return\n end\n if current_user == @user\n redirect_to bookmarks_url\n return\n end\n end\n\n search.build do\n fulltext query\n order_by(:created_at, :desc)\n if user\n with(:user_id).equal_to user.id\n else\n with(:user_id).equal_to current_user.id\n end\n end\n page = params[:page] || \"1\"\n flash[:page] = page if page.to_i >= 1\n search.query.paginate(page.to_i, Bookmark.default_per_page)\n @bookmarks = search.execute!.results\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @bookmarks }\n end\n end",
"def list_bookmarks(user_id)\n url = \"#{@@request_url}/User.listBookmarks?appid=#{@@appid}&ID=#{user_id}\"\n end",
"def index\n @bookmarks = token_or_current_or_guest_user.bookmarks\n bookmark_ids = @bookmarks.collect { |b| b.document_id.to_s }\n\n if bookmark_ids.empty?\n @response = Blacklight::Solr::Response.new({}, {})\n @document_list = []\n else\n query_params = {\n q: bookmarks_query(bookmark_ids),\n defType: 'lucene',\n rows: bookmark_ids.count\n }\n # search_service.fetch does this internally (7.25)\n @response = search_service.repository.search(query_params)\n @document_list = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(@response.documents, 'The @document_list instance variable is now deprecated and will be removed in Blacklight 8.0')\n end\n\n respond_to do |format|\n format.html {}\n format.rss { render layout: false }\n format.atom { render layout: false }\n\n additional_response_formats(format)\n document_export_formats(format)\n end\n end",
"def home\r\n@recommanded_download = Download.find(:all, :limit => 8, :order=>\"download_count desc\")\r\nend",
"def extract_reports\n #puts \" Document.extract_reports\"\n # consider changing this to use split on a raw array to split by \\f then by \\n\n @raw_reports = []\n pending_report = true\n lines # read all the lines in the document file\n \n @pages = []\n collect_pages\n #puts \" collect_pages returned #{@pages}\"\n # We now have all the lines of the file and an array of the sets of pages in the file\n # Now determine where a report ends and collect those pages.\n r = Report.new()\n @pages.each_with_index do |page, i|\n r.add_page(@lines[page.first_line..page.last_line])\n pending_report = true\n current_line = page.first_line\n while current_line <= page.last_line\n if @lines[current_line].end_of_report?\n @raw_reports << r\n r = Report.new()\n pending_report = false\n break #report was added to array of reports \n end \n current_line += 1 \n end\n \n end\n if pending_report\n @raw_reports << r\n end \n @raw_reports\n end",
"def bookmarks(user)\n user = Access::Validate.user(user, false)\n Bookmark\n .where('(bookmarks.creator_id = ? OR bookmarks.updater_id = ?)', user.id, user.id)\n .order('bookmarks.updated_at DESC')\n end",
"def action_documents\n @bookmarks = token_or_current_or_guest_user.bookmarks\n bookmark_ids = @bookmarks.collect { |b| b.document_id.to_s }\n query_params = {\n q: bookmarks_query(bookmark_ids),\n defType: 'lucene',\n rows: bookmark_ids.count\n }\n solr_response = search_service.repository.search(query_params)\n [solr_response, solr_response.documents]\n end",
"def index\n @token = form_authenticity_token\n @posts = Post.where(category: 1).reverse\n \n # @latest_post = []\n \n # (0..4).each do |i|\n # @latest_post[i] = @posts[i]\n # end\n \n @rs = Post.all\n @bm = Bookmark.where(user_id: current_user.id)\n @bookmarks = []\n @rs.each do |r|\n @bm.each do |b|\n if r.id == b.post_id\n @bookmarks.push(r)\n end\n end\n end\n end",
"def index\n @bookmark_categories = BookmarkCategory.all\n end",
"def addressbook_query_report(report)\n depth = @server.http_depth(0)\n\n if depth == 0\n candidate_nodes = [@server.tree.node_for_path(@server.request_uri)]\n\n fail Dav::Exception::ReportNotSupported, 'The addressbook-query report is not supported on this url with Depth: 0' unless candidate_nodes[0].is_a?(ICard)\n else\n candidate_nodes = @server.tree.children(@server.request_uri)\n end\n\n content_type = report.content_type\n content_type << \"; version=#{report.version}\" if report.version\n\n vcard_type = negotiate_v_card(content_type)\n\n valid_nodes = []\n candidate_nodes.each do |node|\n next unless node.is_a?(ICard)\n\n blob = node.get\n blob = blob.read unless blob.is_a?(String)\n\n next unless validate_filters(blob, report.filters, report.test)\n\n valid_nodes << node\n\n if report.limit && report.limit <= valid_nodes.size\n # We hit the maximum number of items, we can stop now.\n break\n end\n end\n\n result = []\n valid_nodes.each do |valid_node|\n if depth == 0\n href = @server.request_uri\n else\n href = \"#{@server.request_uri}/#{valid_node.name}\"\n end\n\n props = @server.properties_for_path(href, report.properties, 0).first\n\n if props[200].key?(\"{#{NS_CARDDAV}}address-data\")\n props[200][\"{#{NS_CARDDAV}}address-data\"] = convert_v_card(\n props[200][\"{#{NS_CARDDAV}}address-data\"],\n vcard_type\n )\n end\n\n result << props\n end\n\n prefer = @server.http_prefer\n\n @server.http_response.status = 207\n @server.http_response.update_header('Content-Type', 'application/xml; charset=utf-8')\n @server.http_response.update_header('Vary', 'Brief,Prefer')\n @server.http_response.body = @server.generate_multi_status(result, prefer['return'] == 'minimal')\n end",
"def get_all_links page_number\n begin\n \n if @filename == ''\n raise 'filename not specified'\n end\n \n if page_number == ''\n raise 'page number not specified'\n end\n \n total_links = self.get_links_count(page_number)\n \n all_links = Array.new\n \n index = 1\n while index <= total_links\n \n all_annotations.push(self.get_link(page_number, index))\n \n index+=1\n end\n \n return all_links\n \n \n rescue Exception=>e\n print e\n end\n end",
"def get_reports\n if is_administrator?\n return Reports.all( :order => [:id.desc])\n else\n reports = Reports.all( :order => [:id.desc])\n reports_array = []\n reports.each do |report|\n next unless report and get_username\n authors = report.authors\n reports_array.push(report) if report.owner == get_username\n if authors\n reports_array.push(report) if authors.include?(get_username)\n end\n end\n return nil unless reports_array\n return reports_array\n end\nend",
"def attachment_links()\n @attachment_links ||= AttachmentLink.where(\"master_id = ? AND master_type = ?\", id, class_name).limit(attachments_count)\n end",
"def get_reports\n if is_administrator?\n return Reports.all\n else\n reports = Reports.all\n reports_array = []\n reports.each do |report|\n next unless report and get_username\n authors = report.authors\n reports_array.push(report) if report.owner == get_username \n if authors\n reports_array.push(report) if authors.include?(get_username)\n end\n end\n return nil unless reports_array\n return reports_array \n end\nend",
"def index\n if session[:user_id]\n @bookmarks = Bookmark.all(:conditions => \"user_id = \"+session[:user_id].to_s)\n user = User.find(session[:user_id])\n \n @background = Rails.root + '/data/' + user.background\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @bookmarks }\n end\n else\n redirect_to \"/login\"\n end\n end",
"def reports_list\r\n post= { \"token\" => @token }\r\n file=nessus_http_request('report/list', post)\r\n return file \r\n end",
"def reports_list\r\n post= { \"token\" => @token }\r\n file=nessus_http_request('report/list', post)\r\n return file \r\n end",
"def get_10q_reports(ticker, save_folder) # FIXME: get rid of 'save_folder' and just use /tmp'\n reports = []\n\n @log.info(\"Getting 10q reports for #{ticker}\") if @log\n files = download_10q_reports(ticker, save_folder)\n return nil if files.nil?\n files.each do |cur_file|\n cur_ten_q = QuarterlyReport.new { |q| q.log = @log }\n cur_ten_q.parse(cur_file)\n\n reports.push cur_ten_q\n end\n return reports\n end",
"def download_10q_reports(ticker, save_folder) # FIXME: should be private?\n @log.info(\"Downloading 10q reports for #{ticker}\") if @log\n return nil if not good_ticker?(ticker)\n\n reports = lookup_reports(ticker)\n return nil if reports.nil?\n reports.keep_if { |r| r[:type]=='10-Q' }\n\n report_files = get_reports(reports, save_folder)\n return report_files\n end",
"def test_delete_reports\n \n reports = BookmarkReport.getAll()\n \n for report in reports \n \n test = BookmarkReport.deleteReport(report.reportId)\n \n assert_equal true, test\n \n end\n \n end",
"def export_all\n headers['Content-Type'] = \"application/vnd.ms-excel\"\n headers['Content-Disposition'] = 'attachment; filename=\"report.xls\"'\n headers['Cache-Control'] = ''\n #SQL QUERY INTO XLS FORMAT\n @bands = PledgedBand.find_by_sql \"SELECT pledged_bands.name, pledged_bands.pledges_count, fans.first_name, fans.last_name, fans.email, pledges.created_at FROM pledged_bands LEFT JOIN pledges ON pledged_bands.id = pledges.pledged_band_id LEFT JOIN fans on pledges.fan_id = fans.id\"\n end",
"def index\n @bookmarks = Bookmark.all\n render json: { bookmarks: @bookmarks }, status: :ok\n end",
"def show(bookmarks, size)\n total = bookmarks.count\n bookmarks[-(size)..-1].each_with_index do |bookmark, i|\n print_bookmark(bookmark, total - size + i)\n end\nend",
"def select_bookmarks\n # added changes in both select_current and select_hint\n # However, the age mark that is show is still for the earlier shown forum based on outdated full_data\n # So we need to show age mark based on file datw which means a change in display program !!! At least\n # clear the array full_data\n $mode = \"forum\"\n $title = \"Bookmarks\"\n $files = $bookmarks.values\n\nend",
"def all_reports\n reports = []\n bookings.each do |booking|\n reports << booking.report unless booking.report.nil?\n end\n reports.reverse\n end",
"def fetch_recent\n @bookmarkable = @bookmark.bookmarkable\n respond_to do |format|\n format.js {\n @bookmarks = @bookmarkable.bookmarks.visible(:order => \"created_at DESC\").offset(1).limit(4)\n }\n format.html do\n id_symbol = (@bookmarkable.class.to_s.underscore + '_id').to_sym\n redirect_to url_for({:action => :index, id_symbol => @bookmarkable})\n end\n end\n end",
"def test_bookmarks\n [{ url: 'https://www.google.com', title: 'Google' },\n { url: 'https://github.com/', title: 'Github' },\n { url: 'https://www.garybusey.com/', title: 'Gary Busey' }]\nend",
"def index\n @bookmarks = Bookmark.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @bookmarks }\n format.js { render :partial => 'bookmarks/list' }\n end\n end",
"def reports?\n !reports.empty?\n end",
"def user_index\n @user = params[:user]\n @results = []\n \n u = User.where(name: params[:user]).first\n \n if u == nil\n redirect_to :root\n else \n u.bookmarks.each do |b|\n user_url = \"/\" + u.name\n entry = {id: b.id, url: b.url, title: b.title, user: b.user, name: u.name, user_url: user_url}\n @results.push(entry)\n end\n end\n end",
"def index\n @doppelte_objects = RootTable.find_by_sql(\"SELECT MAX(r.guid) as guid, r.name, COUNT(r.name) as vorkommen\n FROM root_tables r, object_tables o\n WHERE r.guid=o.guid\n GROUP BY r.name\n HAVING COUNT(r.name)>1\")\n #respond_to do |format|\n # format.xlsx {\n # response.headers[\n # 'Content-Disposition'\n # ] = \"attachment; filename='items.xlsx'\"\n # }\n # format.html { render :index }\n #end\n end",
"def list\n\t\tdocs = proxy_database.view(\"#{shared_data_context.name}/all\")[\"rows\"]\n\t\treturn docs\n \tend",
"def show\n @other_reports = Report.where(yelp_business_id: @report.spot.yelp_business_id)\n end",
"def bookmarked_songs\n doc = request(@user, \"favorites\")\n songs = []\n doc.xpath('//rss/channel/item').each do |node|\n songs << { :title => node.xpath('title').text.strip,\n :link => node.xpath('link').text.strip,\n :description => node.xpath('description').text.strip,\n :date => node.xpath('pubDate').text.strip,\n :track => node.xpath('mm:Track/dc:title').text.strip,\n :artist => node.xpath('mm:Artist/dc:title').text.strip,\n :album => node.xpath('mm:Album/dc:title').text.strip,\n :artwork => node.xpath('pandora:albumArtUrl').text.strip,\n :station => node.xpath('pandora:stationLink').text.strip }\n end\n songs\n end",
"def display_download_all?\n @purl_object.size < 10_737_418_240 &&\n @purl_object.downloadable_files.length > 1 &&\n @purl_object.downloadable_files.length < 3000\n end",
"def index\n @no_groups = RootTable.find_by_sql(\"SELECT DISTINCT r.guid, r.name, r.versiondate, r.versionid, r.description, r.collection, r.document\n FROM root_tables r, object_tables o\n WHERE r.guid=o.guid AND o.guid NOT IN (SELECT rac.guid_relobject FROM relassigncollections rac)\")\n #respond_to do |format|\n # format.xlsx {\n # response.headers[\n # 'Content-Disposition'\n # ] = \"attachment; filename='items.xlsx'\"\n # }\n # format.html { render :index }\n #end\n end",
"def index\n bookmarks_loader(Time.now, current_user.id) \n bookmark = @bookmarks.first\n if bookmark\n session[:first_link_time] = bookmark.updated_at \n end \n bookmark = @bookmarks.last\n if bookmark\n session[:last_link_time] = bookmark.updated_at\n end \n end",
"def get_all_pages()\n a_links = self.xpath('//tr[1]/td/table/tr/td/a/@href')\n a_links.map {|a_link| a_link.value}\n end",
"def show\n set_group\n\n # For groups timeline\n @bookmark_plugins = PLUGIN_CONFIG['bookmark'] \n @bookmarks = Bookmark.eager_load(:tags, :user, :url)\n .eager_load(group: :memberships)\n .where(\"bookmarks.group_id IS NOT NULL\")\n .where(\"bookmarks.group_id = ?\", params[:id])\n .order('bookmarks.updated_at DESC')\n end",
"def index\n start_date = params[:index][:start_date].to_date.beginning_of_day\n end_date = params[:index][:end_date].to_date.end_of_day\n \n if start_date > end_date\n flash[:date_discover] = \"La fecha inicial debe ser menor a la final\"\n redirect_to report_index_url\n else \n @discovers = Discover.where(:created_at => start_date..end_date)\n \n respond_to do |format|\n format.html\n format.xlsx\n format.json\n end\n end\n end",
"def test_get_bookmarks\n exp_num_bms = count_bookmarks(1)\n act_num_bms = @bs.get_bookmarks.count\n assert_equal(exp_num_bms, act_num_bms) \n end",
"def index\n @reference_lists = ReferenceList.all.page(params[:page]).per(15)\n end",
"def get_report_list\n res=api_call('GetReportList')[:data]\n end",
"def test_get_by_bookmark_id\n\n validId = BookmarkReport.getById(1)\n\n assert_equal 1, validId.userId\n assert_equal 'something', validId.issue\n assert_equal 'report', validId.description\n\n invalidId = BookmarkReport.getById(0)\n\n assert_nil invalidId\n\n end",
"def index\n @quicklinks = Quicklink.all\n end",
"def get_all_reports(type)\n \n LOGGER.info \"get all reports of type '\"+type.to_s+\"'\"\n check_report_type(type)\n @persistance.list_reports(type).collect{ |id| get_uri(type,id) }.join(\"\\n\")\n end",
"def index\n @reports = Report.all\n # @reports = Array.new\n end",
"def index\n @list_of_uploads = FedexBillCheck.select(\"verif_name as reference, count(verif_name) as records\").group(\"verif_name\").limit(10)\n @show_csv = \"false\"\n @fedex_bill_checks = FedexBillCheck.paginate(:page => params[:page])\n if params.has_key?(:ref_name)\n @fedex_bill_checks = FedexBillCheck.where(verif_name: params[:ref_name]).paginate(:page => params[:page])\n @show_csv = params[:ref_name]\n end\n end",
"def favorite_links\n favorite_ids = self.favorites\n original_length = favorite_ids.size\n favorite_links = []\n\n favorite_ids.each do |id|\n link = Link.find_by(id: id)\n\n if link.nil?\n favorite_ids.delete(id)\n else\n favorite_links << link\n end\n end\n\n if favorite_ids.size != original_length\n self.save\n end\n\n return favorite_links\n end",
"def show\n @notes = @bookmark.notes\n end",
"def download_all\n if platinum_user_and_above?\n @domains=Domain.where(\"name is not null\")\n template = Rails.root.join(\"app\",\"views\",\"reports\", \"DomainPortfolio-template.xlsx\")\n workbook = RubyXL::Parser.parse(template)\n worksheet = workbook.worksheets[0]\n worksheet.sheet_name = 'All'\n index = 0\n @domains.each do |domain|\n next if domain.name.nil?\n next if domain.name.empty?\n index += 1\n if domain.transferable\n my_row = [domain.name, \"yes\"]\n else\n my_row = [domain.name, \"no\"]\n end\n worksheet_write_row(worksheet,index, my_row)\n end\n file = \"DomainPortfolio-All-\" + Time.now.strftime('%m%d%Y') + \".xlsx\"\n send_data workbook.stream.string, filename: file, disposition: 'attachment'\n else\n redirect_back :fallback_location => root_path, :alert => \"Access denied.\"\n end\n end",
"def fulltext_links\n\n links = []\n\n ebscolinks = @record.fetch('FullText',{}).fetch('Links',{})\n if ebscolinks.count > 0\n ebscolinks.each do |ebscolink|\n if ebscolink['Type'] == 'pdflink'\n link_label = 'PDF Full Text'\n link_icon = 'PDF Full Text Icon'\n link_url = ebscolink['Url'] || 'detail'\n links.push({url: link_url, label: link_label, icon: link_icon, type: 'pdf'})\n end\n end\n end\n\n htmlfulltextcheck = @record.fetch('FullText',{}).fetch('Text',{}).fetch('Availability',{})\n if htmlfulltextcheck == '1'\n link_url = 'detail'\n link_label = 'Full Text in Browser'\n link_icon = 'Full Text in Browser Icon'\n links.push({url: link_url, label: link_label, icon: link_icon, type: 'html'})\n end\n\n if ebscolinks.count > 0\n ebscolinks.each do |ebscolink|\n if ebscolink['Type'] == 'ebook-pdf'\n link_label = 'PDF eBook Full Text'\n link_icon = 'PDF eBook Full Text Icon'\n link_url = ebscolink['Url'] || 'detail'\n links.push({url: link_url, label: link_label, icon: link_icon, type: 'ebook-pdf'})\n end\n end\n end\n\n if ebscolinks.count > 0\n ebscolinks.each do |ebscolink|\n if ebscolink['Type'] == 'ebook-epub'\n link_label = 'ePub eBook Full Text'\n link_icon = 'ePub eBook Full Text Icon'\n link_url = ebscolink['Url'] || 'detail'\n links.push({url: link_url, label: link_label, icon: link_icon, type: 'ebook-epub'})\n end\n end\n end\n\n items = @record.fetch('Items',{})\n if items.count > 0\n items.each do |item|\n if item['Group'] == 'Url'\n if item['Data'].include? 'linkTerm="'\n link_start = item['Data'].index('linkTerm="')+15\n link_url = item['Data'][link_start..-1]\n link_end = link_url.index('"')-1\n link_url = link_url[0..link_end]\n link_label_start = item['Data'].index('link>')+8\n link_label = item['Data'][link_label_start..-1]\n link_label = link_label.strip\n else\n link_url = item['Data']\n link_label = item['Label']\n end\n link_icon = 'Catalog Link Icon'\n links.push({url: link_url, label: link_label, icon: link_icon, type: 'cataloglink'})\n end\n end\n end\n\n if ebscolinks.count > 0\n ebscolinks.each do |ebscolink|\n if ebscolink['Type'] == 'other'\n link_label = 'Linked Full Text'\n link_icon = 'Linked Full Text Icon'\n link_url = ebscolink['Url'] || 'detail'\n links.push({url: link_url, label: link_label, icon: link_icon, type: 'smartlinks+'})\n end\n end\n end\n\n ft_customlinks = @record.fetch('FullText',{}).fetch('CustomLinks',{})\n if ft_customlinks.count > 0\n ft_customlinks.each do |ft_customlink|\n link_url = ft_customlink['Url']\n link_label = ft_customlink['Text']\n link_icon = ft_customlink['Icon']\n links.push({url: link_url, label: link_label, icon: link_icon, type: 'customlink-fulltext'})\n end\n end\n\n links\n end",
"def index\n # @bookmarks = current_or_guest_user.bookmarks\n logger.info \"es287_debug #{__FILE__}:#{__LINE__}:#{__method__} params = #{params.inspect}\"\n extra_head_content << view_context.auto_discovery_link_tag(:rss, url_for(params.to_unsafe_h.merge(:format => 'rss')), :title => t('blacklight.search.rss_feed') )\n extra_head_content << view_context.auto_discovery_link_tag(:atom, url_for(params.to_unsafe_h.merge(:format => 'atom')), :title => t('blacklight.search.atom_feed') )\n set_bag_name \n # make sure we are not going directly to home page\n if !params[:qdisplay].nil?\n params[:qdisplay] = ''\n end\n search_session[:per_page] = params[:per_page]\n temp_search_field = ''\n journal_titleHold = ''\n if (!params[:range].nil?)\n check_dates(params)\n end\n temp_search_field = ''\n if !params[:q].blank? and !params[:search_field].blank? # and !params[:search_field].include? '_cts'\n if params[:q].include?('%2520')\n params[:q].gsub!('%2520',' ')\n end\n if params[:q].include?('%2F') or params[:q].include?('/')\n params[:q].gsub!('%2F','')\n params[:q].gsub!('/','')\n end\n if params[:search_field] == 'isbn%2Fissn' or params[:search_field] == 'isbn/issn'\n params[:search_field] = 'isbnissn'\n end\n if params[\"search_field\"] == \"journal title\"\n journal_titleHold = \"journal title\"\n# params[:f] = {'format' => ['Journal/Periodical']}\n end\n params[:q] = sanitize(params)\n if params[:search_field] == 'call number' and !params[:q].include?('\"')\n tempQ = params[:q]\n end\n # check_params(params)\n if !tempQ.nil?\n params[:qdisplay] = tempQ\n end\n else\n if params[:q].blank?\n temp_search_field = params[:search_field]\n else\n if params[:search_field].nil?\n params[:search_field] = 'quoted'\n end\n check_params(params)\n end\n if params[:q_row] == [\"\",\"\"]\n params.delete(:q_row)\n end\n end\n if !params[:search_field].nil?\n if !params[:q].nil? and !params[:q].include?(':') and params[:search_field].include?('cts')\n params[:q] = params[:search_field] + ':' + params[:q]\n end\n end\n if !params[:q].nil? \n if params[:q].include?('_cts')\n display = params[:q].split(':')\n params[:q] = display[1]\n end\n end\n \n # params[:q] = '\"journal of parasitology\"'\n # params[:search_field] = 'quoted'\n #params[:sort]= ''\n #params = {\"utf8\"=>\"✓\", \"controller\"=>\"catalog\", \"action\"=>\"index\", \"q\"=>\"(+title:100%) OR title_phrase:\\\"100%\\\"\", \"search_field\"=>\"title\", \"qdisplay\"=>\"100%\"}\n logger.info \"es287_debug #{__FILE__}:#{__LINE__}:#{__method__} params = #{params.inspect}\"\n #params[:q] = '(+title_quoted:\"A news\" +title:Reporter)'\n# params[:search_field] = 'advanced'\n #params[:q] = '(water)'\n (@response, deprecated_document_list) = search_service.search_results #search_results(params)\n @document_list = deprecated_document_list\n logger.info \"es287_debug #{__FILE__}:#{__LINE__}:#{__method__} response = #{@response[:responseHeader].inspect}\"\n #logger.info \"es287_debug #{__FILE__}:#{__LINE__}:#{__method__} document_list = #{@document_list.inspect}\"\n if temp_search_field != ''\n params[:search_field] = temp_search_field\n end\n if journal_titleHold != ''\n params[:search_field] = journal_titleHold\n end\n if params[:search_field] == 'author_quoted'\n params[:search_field] = 'author/creator'\n end\n if @response[:responseHeader][:q_row].nil?\n# params.delete(:q_row)\n# params[:q] = @response[:responseHeader][:q]\n# params[:search_field] = ''\n# params[:advanced_query] = ''\n# params[:commit] = \"Search\"\n# params[:controller] = \"catalog\"\n# params[:action] = \"index\"\n end\n if params.nil? || params[:f].nil?\n @filters = []\n else\n @filters = params[:f] || []\n end\n\n # clean up search_field and q params. May be able to remove this\n # cleanup_params(params)\n\n @expanded_results = {}\n ['worldcat', 'summon'].each do |key|\n @expanded_results [key] = { :count => 0 , :url => '' }\n end\n # Expand search only under certain conditions\n tmp = BentoSearch::Results.new\n if !(params[:search_field] == 'call number')\n if expandable_search?\n searcher = BentoSearch::ConcurrentSearcher.new(:summon, :worldcat)\n logger.info \"es287_debug #{__FILE__}:#{__LINE__}:#{__method__} params = #{params.inspect}\"\n logger.info \"es287_debug #{__FILE__}:#{__LINE__}:#{__method__} params[:q] = #{params[:q].inspect}\"\n query = ( params[:qdisplay]?params[:qdisplay] : params[:q]).gsub(/&/, '%26')\n logger.info \"es287_debug #{__FILE__}:#{__LINE__}:#{__method__} query = #{query.inspect}\"\n searcher.search(query, :per_page => 1)\n\n @expanded_results = {}\n\n\n searcher.results.each_pair do |key, result|\n source_results = {\n :count => number_with_delimiter(result.total_items),\n :url => BentoSearch.get_engine(key).configuration.link + query,\n }\n @expanded_results[key] = source_results\n end\n end\n end\n @controller = self\n respond_to do |format|\n format.html { save_current_search_params }\n format.rss { render :layout => false }\n format.atom { render :layout => false }\n format.json { render json: { response: { document: deprecated_document_list } } }\n end\n \n if !params[:q_row].nil? \n params[:show_query] = make_show_query(params)\n search_session[:q] = params[:show_query]\n end\n\n if !params[:qdisplay].blank?\n params[:q] = params[:qdisplay]\n search_session[:q] = params[:show_query]\n# params[:q] = qparam_display\n search_session[:q] = params[:q] \n # params[:sort] = \"score desc, pub_date_sort desc, title_sort asc\"\n end\n\n end",
"def bookmark_details\n results = {\n manuscript: manuscript ? manuscript.id : nil,\n source_date: SDBMSS::Util.format_fuzzy_date(source.date),\n source_title: source.title,\n source_agent: source.source_agents.map(&:agent).join(\"; \"),\n titles: entry_titles.order(:order).map(&:display_value).join(\"; \"),\n authors: entry_authors.order(:order).map(&:display_value).join(\"; \"),\n dates: entry_dates.order(:order).map(&:display_value).join(\"; \"),\n artists: entry_artists.order(:order).map(&:display_value).join(\"; \"),\n scribes: entry_scribes.order(:order).map(&:display_value).join(\"; \"),\n languages: entry_languages.order(:order).map(&:display_value).join(\"; \"),\n materials: entry_materials.order(:order).map(&:display_value).join(\"; \"),\n places: entry_places.order(:order).map(&:display_value).join(\"; \"),\n uses: entry_uses.order(:order).map(&:use).join(\"; \"),\n other_info: other_info,\n provenance: unique_provenance_agents.map { |unique_agent| unique_agent[:name] }.join(\"; \"),\n }\n (results.select { |k, v| !v.blank? }).transform_keys{ |key| key.to_s.humanize }\n end",
"def mailbookmarks\n @email_string=\"#{params[:email_string]}\"\n# Mail all bookmarks\n @bookmarks =User.find(session[:user_id]).bookmarks.scoped\n @[email protected](:name)\n\n BookmarkMailer.bookmark_created(@bookmarks,@email_string).deliver\n\n\n\n\n respond_to do |format|\n format.html { render :index }\n format.json { render json: @bookmarks }\n end\n end",
"def bookmarks(bookmarks)\n bookmarks.each_with_object({}) do |b, bs|\n first_image = b.entry.entry_images.min_by(&:pocket_image_id)\n bs[b.id] = {\n id: b.id.to_s,\n title: b.entry.resolved_title,\n url: b.entry.url,\n status: b.status,\n addedAt: b.added_to_pocket_at.to_i,\n archivedAt: b.archived_at&.to_i,\n favorite: b.favorite,\n thumbnailUrl: determine_image_url(first_image),\n }\n end\n end",
"def show\n @bookmark = Bookmark.find(params[:id])\n end",
"def show\n @bookmark = Bookmark.find(params[:id])\n end",
"def index\n unless read_fragment({})\n @pastes = Paste.find(:all, :order => \"created_at DESC\").paginate :page => params[:page], :per_page => 4\n end\n end",
"def entire_history_aaaa\n\t\t@workflows = WorkFlow.where(is_active: true, is_in_use: false)\n\t if session[:report_wildcard].present?\n\t @wildcard = session[:report_wildcard]\n\t end\n\t if session[:report_exact].present?\n\t @exact = session[:report_exact]\n\t end\n\n\t\tif request.post? or session[:report_q_string].present?\n\t\t\t@task_confirmation = false\n\t\t\tif request.post?\n\t\t\t\tserach_result = search\n\t\t\telse\n\t\t\t \tq_string = session[:report_q_string]\n\t\t\t\tserach_result = WorkFlow.search(q_string)\n\t\t\tend\t\n\n\t\t\tif serach_result.present?\n\t\t\t\tl2_name = ''\n\t\t\t\tl1_name = ''\n\t\t\t\tl1_list = ''\n\t\t\t\t@l2_list = ''\n\t\t\t\t@l3_list = ''\n\t\t\t\tserach_result.each do |result|\n\t\t\t\t \tif l1_name != result['l1_name']\n\t\t\t\t \t\tl1_name = result['l1_name']\n\t\t\t\t \t\tl1_list += result['l1_id'].to_s+'_' \n\t\t\t\t \tend\n\n\t\t\t\t \tif l2_name != result['l2_name'] && result['l2_id'].presence\n\t\t\t\t \t\tl2_name = result['l2_name']\n\t\t\t\t \t\t@l2_list += result['l2_id'].to_s+'_' \n\t\t\t\t \tend\t\n\n\t\t\t\t \tif result['l3_id'].presence\n\t\t\t\t \t\t@l3_list += result['l3_id'].to_s+'_' \n\t\t\t\t \tend\t\n\t\t\t \tend\n\n\t\t\t \tl1_list = l1_list.split('_')\n\t\t\t\t@l2_list = @l2_list.split('_')\n\t\t\t @l3_list = @l3_list.split('_')\n\t\t\t\t@report_l1s = L1.where(id: [l1_list])\n\n\t\t\t\t@report_l1s.each do |l1|\n\t\t\t\t\tif l1.timestamp_logs.present?\n\t\t\t\t\t\t@task_confirmation = true\n\t\t\t\t\tend\n\t\t\t\t\t@l2_list_objects = l1.l2s.where(id: [@l2_list])\n\t\t\t\t\t@l2_list_objects.each do |l2|\n\t\t\t\t\t\tif l2.timestamp_logs\n\t\t\t\t\t\t\t@task_confirmation = true\n\t\t\t\t\t\tend\n\t\t\t\t\t\t\t@l3_list_objects = l2.l3s.where(id: [@l3_list])\n\t\t\t\t\t\t\t@l3_list_objects.each do |l3|\n\t\t\t\t\t\t\t\tif l3.timestamp_logs\n\t\t\t\t\t\t\t\t\t@task_confirmation = true\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\t\n\t\t\t\t\tend\n\t\t\t\tend\t\n\t\t\tend\n\t\tend\n\tend",
"def index\n @document_histories = DocumentHistory.all\n end",
"def index\n @q = @elist_reports.search params[:q]\n @elist_reports = @q.result.page(params[:page])\n end"
] | [
"0.68343604",
"0.635041",
"0.6318052",
"0.6210739",
"0.6161618",
"0.6140696",
"0.5994113",
"0.5956108",
"0.59277654",
"0.5842043",
"0.58030504",
"0.5801819",
"0.57237595",
"0.5700349",
"0.56992793",
"0.5670509",
"0.56472856",
"0.56195724",
"0.55992025",
"0.5591075",
"0.55416745",
"0.5530266",
"0.55223256",
"0.55205977",
"0.5520467",
"0.54963285",
"0.5474174",
"0.5474174",
"0.5465149",
"0.5464284",
"0.54567754",
"0.5418186",
"0.54116875",
"0.5406442",
"0.54052514",
"0.5392576",
"0.53792053",
"0.53511095",
"0.53288573",
"0.5313789",
"0.53026456",
"0.52867997",
"0.5282206",
"0.5257088",
"0.5253474",
"0.52465886",
"0.5244957",
"0.5213008",
"0.51794803",
"0.5165415",
"0.5153591",
"0.51516694",
"0.5129198",
"0.5111188",
"0.5111188",
"0.5103848",
"0.5087738",
"0.5076275",
"0.5075607",
"0.50659513",
"0.5055833",
"0.5049008",
"0.50430405",
"0.50392467",
"0.50376135",
"0.50217474",
"0.5017084",
"0.5011599",
"0.5009979",
"0.5009753",
"0.49860647",
"0.49798623",
"0.4975358",
"0.49646175",
"0.49608526",
"0.4953004",
"0.49525043",
"0.49515107",
"0.49467415",
"0.4946628",
"0.49384597",
"0.49358875",
"0.49310312",
"0.49237278",
"0.49123895",
"0.49056044",
"0.48988318",
"0.4897529",
"0.48932722",
"0.4887481",
"0.4884562",
"0.4879141",
"0.48756093",
"0.4874861",
"0.48736334",
"0.48736334",
"0.48709664",
"0.4869114",
"0.4866557",
"0.48656708"
] | 0.749952 | 0 |
Gets the first bookmark report from the database: bookmark ID = 1, user ID = 1, issue = something, description = report Should return for all the tests | def test_get_all_bookmark_reports_details
reports = BookmarkReport.getAll()
report = reports[0]
assert_equal 1, report.bookmarkId
assert_equal 1, report.userId
assert_equal 'something', report.issue
assert_equal 'report', report.description
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def external_report\n return external_reports.first\n end",
"def test_get_by_bookmark_id\n\n validId = BookmarkReport.getById(1)\n\n assert_equal 1, validId.userId\n assert_equal 'something', validId.issue\n assert_equal 'report', validId.description\n\n invalidId = BookmarkReport.getById(0)\n\n assert_nil invalidId\n\n end",
"def get_report(id)\n if is_administrator?\n return Reports.first(:id => id)\n else\n report = Reports.first(:id => id)\n if report\n authors = report.authors\n return report if report.owner == get_username\n if authors\n return report if authors.include?(get_username)\n end\n end\n end\nend",
"def get_report(id)\n if is_administrator?\n return Reports.first(:id => id)\n else\n report = Reports.first(:id => id)\n if report\n authors = report.authors\n return report if report.owner == get_username\n if authors\n return report if authors.include?(get_username)\n end\n end\n end\nend",
"def get_bookmark bookmark_index\n begin\n \n if @filename == ''\n raise 'filename not specified'\n end\n \n if bookmark_index == ''\n raise 'bookmark index not specified'\n end\n \n \n str_uri = $product_uri + '/pdf/' + @filename + '/bookmarks/' + bookmark_index.to_s\n str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) \n response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})\n \n stream_hash = JSON.parse(response_stream)\n \n return stream_hash['Bookmark']\n \n \n rescue Exception=>e\n print e\n end\n end",
"def first_report\n @user = @receiver\n @notification = @user.notifications.find_by(path: \"/reports/#{@report.id}\")\n mail to: @user.email,\n subject: \"[bootcamp] #{@report.user.login_name}さんがはじめての日報を書きました!\"\n end",
"def first(start, fin)\n start ||= Time.at(0)\n fin ||= Time.now\n self.reports.start(start,fin).first\n end",
"def test_new_report\n\n testOne = BookmarkReport.newReport(2, 1, \"issue\", \"description\");\n\n assert_equal true, testOne\n\n testTwo = BookmarkReport.newReport(nil, 1, \" \", \"test\");\n\n assert_equal false, testTwo\n\n end",
"def test_get_by_bookmark_id\n\n comments = Comment.getByBookmarkId(1)\n \n comment = comments[0]\n\n assert_equal 1, comment.commentId\n assert_equal \"This is a comment\", comment.content\n assert_equal 1, comment.bookmarkId\n assert_equal 1, comment.userId\n\n end",
"def latest_report\n @report_history.last\n end",
"def show\n @title = @note.title\n @[email protected]\n @[email protected]\n @tags = @note.tag\n @pages = Page.joins(:notes).where(\"notes.id = #{params[:id]}\").paginate(:page => params[:page], per_page: APP_CONFIG[\"pagenate_count\"][\"notes\"]).order(\"pages.id\").all\n\n if current_user\n @bookmarked = Bookmark.where(:user_id => current_user.id)\n @bookmark = Bookmark.new\n @bookmark.note_id = @note.id\n @bookmark.user_id = current_user.id\n end\n end",
"def latest_report\n @latest_report || fetch_api_data\n end",
"def get_bookmark_for_user(user_id, bookmark_id)\n query = <<-EOS\n SELECT b.id, b.name, b.notes, b.added_on, w.url \n FROM bookmarks b, users u, web_pages w\n WHERE b.user_id = u.id\n AND b.web_page_id = w.id\n AND b.user_id = $1\n AND b.id = $2\n EOS\n bm = @conn.exec(query, [user_id, bookmark_id]).first\n unless bm == nil\n bm = Bookmark.new(bm)\n end\n bm \n end",
"def test_get_all_bookmark_reports\n\n reports = BookmarkReport.getAll()\n\n assert_equal 4, reports.length\n \n end",
"def last_progress_report(user=nil)\n\t IdeaProgress.where(:idea_id => self.id).with_private(user).order(\"progress_date desc\").limit(1).first\n\tend",
"def first_commit\n\tcommit = nil\n\tresp = github_api(\"commits\")\n\tsha = resp[-1][\"commit\"][\"sha\"]\n\twhile true\n\t\tr = github_api(\"commits?sha=#{sha}&per_page=100\")\n\t\tif r.count != 1 \n\t\t\tsha = r[-1][\"sha\"]\n\t\t\tnext\n\t\tend\n\t\tcommit = r[0]\n\t\tbreak\n\tend\n\tcommit\nend",
"def next\r\n\r\n SavedReport.first(:order => 'saved_reports.id', :conditions => [\"saved_reports.id > ?\", self.id])\r\n end",
"def test_get_by_bookmark_id\n\n resultCreated = Tag.newTag(\"Payroll\", 1);\n\n assert_equal true, resultCreated\n\n results = Tag.getByBookmarkId(1);\n\n result = results[0]\n\n assert_equal \"Payroll\", result.tag\n\n assert_equal 1, results.length\n\n end",
"def pdf_item\n pdf = self.items.collect { |i| i if i.url.include?('docs.google.com') }\n pdf.first\n end",
"def report_first_page(rr)\n rr.build_html_rows_for_legacy # Create the report result details for legacy reports\n @report = rr.report # Grab the report, not including table\n\n @sb[:pages] ||= {}\n @sb[:pages][:rr_id] = rr.id\n @sb[:pages][:items] = @report.extras[:total_html_rows]\n @sb[:pages][:perpage] = settings(:perpage, :reports)\n @sb[:pages][:current] = 1\n total = @sb[:pages][:items] / @sb[:pages][:perpage]\n total += 1 if @sb[:pages][:items] % @sb[:pages][:perpage] != 0\n @sb[:pages][:total] = total\n @title = @report.title\n if @report.extras[:total_html_rows].zero?\n add_flash(_(\"No records found for this report\"), :warning)\n html = nil\n else\n html = report_build_html_table(@report,\n rr.html_rows(:page => @sb[:pages][:current],\n :per_page => @sb[:pages][:perpage]).join)\n end\n html\n end",
"def latest_report\n @latest_report ||= AedUtils.latest_published_analysis\n end",
"def show\n @bookmark = Bookmark.find(params[:id])\n end",
"def show\n @bookmark = Bookmark.find(params[:id])\n end",
"def first\n response = query(:per_page => 1, :page => 1).get!\n response[:results].first\n end",
"def first\n results.first\n end",
"def find_reports(user)\n @reports = Report.all(:conditions => { :user_id => user })\n end",
"def first_issue?\n issue_number == 1 \n end",
"def bookmark_by(u)\r\n Bookmark.bookmark_by(u, self)\r\n end",
"def show\n @report = Rails.cache.fetch(\"reports/#{params[:id]}\", :expires_in => 1.week) do\n Report.without(:email).find(params[:id])\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @report }\n end\n end",
"def fetch_reports\n # fetch all the reports using this method and then create a Report for each of them\n end",
"def get_reports\n if is_administrator?\n return Reports.all( :order => [:id.desc])\n else\n reports = Reports.all( :order => [:id.desc])\n reports_array = []\n reports.each do |report|\n next unless report and get_username\n authors = report.authors\n reports_array.push(report) if report.owner == get_username\n if authors\n reports_array.push(report) if authors.include?(get_username)\n end\n end\n return nil unless reports_array\n return reports_array\n end\nend",
"def get_bug(id)\n get_bugs(id).first\n end",
"def retrieve_first_defect(api_connection)\n defect_query = RallyAPI::RallyQuery.new(\n type: \"defect\",\n fetch: \"FormattedID, Name,CreationDate\",\n limit: 10,\n page_size: 10,\n project_scope_up: false,\n project_scope_down: true,\n order: \"CreationDate Desc\" )\n results = api_connection.find(defect_query)\n\n first_defect = { name: results[0].name,\n type: results[0].type,\n formatted_id: results[0].rally_object['FormattedID'] }\nend",
"def find_first(*args)\n id = get_range(:count => 1, *args).first\n id && find_one(id, *args)\n end",
"def fetch_issue(page, filename)\n link = page.link_with(:href => /downloads/)\n if link == nil\n puts \"No link found for #{filename}\"\n return\n else\n puts \"fetching #{filename}\"\n pdf = link.click\n pdf.save_as(filename)\n end\nend",
"def first_page\n @links['first']\n end",
"def test_get_existing_bookmark\n test_url = 'http://www.ml-class.com/'\n num0 = count_bookmarks(@bs.user_id)\n tot0 = count_bookmarks\n assert(get_bookmark(@bs.user_id, test_url) === @bs.add_or_get_bookmark(test_url))\n assert_equal(num0, count_bookmarks(@bs.user_id))\n assert_equal(tot0, count_bookmarks)\n end",
"def first!\n first or raise RecordNotFound\n end",
"def click_reports_link\n wait_for_page_and_click reports_link\n end",
"def report_get id\n call! report_get, id\n end",
"def report(report_id)\n return unless (r = get(\"reports/#{report_id}\")['Reports'])\n Report.new(r.first['Url'], party: self, details: r.first)\n end",
"def report(id)\n get(\"reports/#{id}\")\n end",
"def get_reports\n if is_administrator?\n return Reports.all\n else\n reports = Reports.all\n reports_array = []\n reports.each do |report|\n next unless report and get_username\n authors = report.authors\n reports_array.push(report) if report.owner == get_username \n if authors\n reports_array.push(report) if authors.include?(get_username)\n end\n end\n return nil unless reports_array\n return reports_array \n end\nend",
"def first\n find.limit(1).next_document\n end",
"def first_book\n Book.find(:first)\n end",
"def open_bookmark(bm)\n id = bm.shift\n url = Bookmarks.new.bookmark_url(id)\n pexit \"Failure:\".red + \" bookmark #{id} not found\", 1 if url.nil?\n puts 'opening bookmark ' + url + '...'\n openweb(wrap(url))\n open_bookmark bm unless bm.empty?\n end",
"def getIssueId(project_id, issue_name)\n\tissue_id = \"\"\n\tproject = $client.Project.find(project_id)\n\tproject.issues.each do |issue|\n\t\tif \"#{issue.summary}\" == \"#{issue_name}\"\n\t\t\tissue_id = \"#{issue.id}\"\n\t\t\twrite_to_file(\"Story id #{issue_id} was successfully found for #{issue_name}\", \"info\")\n\t\tend\n\tend\n\treturn issue_id\nend",
"def get_da_urls (doc,comment_url)\n doc.search('table tbody tr').each do |tr|\n # Columns in table\n # Show Number Submitted Details\n tds = tr.search('td')\n\n break if tds[0].inner_text =~ /no records/\n\n h = tds.map{|td| td.inner_html}\n\n puts h\n info_url = 'https://pdonline.toowoombarc.qld.gov.au/Masterview/Modules/ApplicationMaster/' + tds[0].at('a')['href'].strip\n puts info_url\n descParts = h[3].split('<br>')\n record = {\n 'info_url' => info_url,\n 'comment_url' => comment_url,\n 'council_reference' => clean_whitespace(h[1]),\n 'date_received' => Date.strptime(clean_whitespace(h[2]), '%d/%m/%Y').to_s,\n # TODO: Some DAs have multiple addresses, we're just getting the first :(\n 'address' => clean_whitespace(descParts[0]),\n 'description' => clean_whitespace(descParts[1]),\n 'date_scraped' => Date.today.to_s\n }\n\n if (ScraperWiki.select(\"* from data where `council_reference`='#{record['council_reference']}'\").empty? rescue true)\n ScraperWiki.save_sqlite(['council_reference'], record)\n else\n puts \"Skipping already saved record \" + record['council_reference']\n end\n end\nend",
"def report_file1_download(report)\n\t\t\tpost= { \"token\" => @token, \"report\" => report, \"v1\" => \"true\" }\n\n\t\t\tfile=nessus_http_request('file/report/download', post)\n\n\t\t\treturn file\n\t\tend",
"def get_first_row(*args)\n @db.get_first_row(*args)\n end",
"def first_response(pr)\n q = <<-QUERY\n select min(created) as first_resp from (\n select min(prc.created_at) as created\n from pull_request_comments prc, users u\n where prc.pull_request_id = ?\n and u.id = prc.user_id\n and u.login not in ('travis-ci', 'cloudbees')\n and prc.created_at < (\n select max(created_at)\n from pull_request_history\n where action = 'closed' and pull_request_id = ?)\n union\n select min(ic.created_at) as created\n from issues i, issue_comments ic, users u\n where i.pull_request_id = ?\n and i.id = ic.issue_id\n and u.id = ic.user_id\n and u.login not in ('travis-ci', 'cloudbees')\n and ic.created_at < (\n select max(created_at)\n from pull_request_history\n where action = 'closed' and pull_request_id = ?)\n ) as a;\n QUERY\n resp = db.fetch(q, pr[:id], pr[:id], pr[:id], pr[:id]).first[:first_resp]\n unless resp.nil?\n (resp - pr[:created_at]).to_i / 60\n else\n -1\n end\n end",
"def fetch_report_page \n @report_page = client.get(REPORT_URL)\n dump(client, @report_page)\n \n @ajax_id = get_ajax_id(@report_page)\n @report_page\n end",
"def getReport(filename)\n result = @driver.GetGeneratedReports(:ApiKey => @apikey)\n if result.getGeneratedReportsResult.errorCode == \"0\" then\n response = result.getGeneratedReportsResult.items.apiResponseItem\n @reportlist = Hash.new\n response.each do |res|\n @reportlist.update(res.filename => res.fullPath)\n end\n output = @reportlist[filename]\n else\n output = result.getGeneratedReportsResult.errorMessage\n end\n return output\n end",
"def show\n @other_reports = Report.where(yelp_business_id: @report.spot.yelp_business_id)\n end",
"def get_report(report_id, &blk)\n operation('GetReport')\n .add('ReportId' => report_id)\n\n run(&blk)\n end",
"def first\n\n wi(fetch_all({}).first)\n end",
"def report(committee)\n reports.find { |r| r.committee.name == committee }\n end",
"def getFirst\n first = \"\" \n if (@currentPage.to_i > 2)\n first = \"<a href=\\\"/pubmed/searchPubmed?method=get&term=#{@keywords}&page=1&resultsPerPage=#{@resultsPerPage}\\\" class=\\\"prev_page\\\">| « First</a>\"\n end \n first\n end",
"def show\n @report = current_user.reports.find(params[:id])\n end",
"def most_resent_report\n @channel_report = ChannelReport.order(scan_date: :desc).first\n respond_with(@channel_report)\n end",
"def test_get_bookmark\n exp_bm = get_bookmark(@bs.user_id, 'http://www.ml-class.com/')\n act_bm = @bs.get_bookmark(4)\n assert(exp_bm === act_bm)\n end",
"def first\n return nil unless first_page_uri\n perform_request(first_page_uri)\n end",
"def set_bugreport\n @bugreport = Bugreport.find(params[:id])\n end",
"def get_rally_testcase(tc_oid)\n q = RallyAPI::RallyQuery.new()\n q.type = 'TestCase'\n q.fetch = 'Name'\n q.page_size = 1\n q.limit = 1\n q.project_scope_up = false\n q.project_scope_down = true\n q.query_string = \"(ObjectID = \\\"#{tc_oid}\\\")\"\n\n begin\n results = @rally_con.find(q)\n rescue Exception => ex\n print \"ERROR: During rally.find; arg1='#{q}'\\n\"\n print \" Message returned: #{ex.message}\\n\"\n exit ERR_EXIT_RALLYFIND\n end\n\n return results.first\nend",
"def first\n graph.first_object(subject: first_subject, predicate: RDF.first)\n end",
"def first_page\n Page.find(self.first_page_id)\n end",
"def bookmarks(user)\n user = Access::Validate.user(user, false)\n Bookmark\n .where('(bookmarks.creator_id = ? OR bookmarks.updater_id = ?)', user.id, user.id)\n .order('bookmarks.updated_at DESC')\n end",
"def show\n @saved_report = SavedReport.find_by_id( params[ :id ] )\n\n # Legacy report link, or missing / unauthorized report?\n\n if ( @saved_report.nil? && params.has_key?( :report ) )\n\n # This is pretty weird as active tasks at the time the link to the\n # legacy report was generated may have become inactive or vice versa.\n # Indeed even with a conventionally generated report, another user of\n # the system may have changed an included task's active flag.\n #\n # This means that the report's active_tasks and inactive_tasks lists\n # may contain a mixture of active and inactive items. Fortunately,\n # this is all resolved by the TrackRecordReport code when the IDs are\n # given to the Report instance. It re-finds and re-builds the list of\n # tasks, assigning them to the correct active/inactive lists as it\n # does so.\n #\n # Really the active-vs-inactive list stuff inside a SavedReport is a\n # legacy throwback to the old directly generated non-model report\n # code in TrackRecord v1.x - nothing more.\n\n params[ :report ][ :reportable_user_ids ] = params[ :report ].delete( :user_ids )\n\n @saved_report = SavedReport.new( params[ :report ] )\n @saved_report.user = @current_user\n @saved_report.title = ''\n\n begin\n @saved_report.save!()\n redirect_to( report_path( @saved_report ) )\n\n rescue\n flash[ :error ] = \"The legacy report could not be generated. An unknown error occurred.\"\n redirect_to( home_path() )\n end\n\n # NOTE EARLY EXIT!\n\n return\n\n elsif ( @saved_report.nil? || ( @saved_report.user_id != @current_user.id && ! @saved_report.shared && ! @current_user.admin? ) )\n\n flash[ :error ] = \"The requested report was not found; the owner may have deleted it.\"\n redirect_to( home_path() ) and return\n\n end\n\n # Read parameters related to the 'show' action, which itself contains a\n # form that submits back to here fincluding details about CSV export\n # parameters. For plain old \"show report <id>\" uses, there are no such\n # additional parameters.\n\n read_options()\n\n @report = @saved_report.generate_report()\n @report.compile()\n\n if ( @saved_report.title.empty? )\n flash[ :warning ] = \"This report is unnamed. It will be deleted automatically. To save it permanently, use the 'Change report parameters' link underneath the report and give it a name.\"\n end\n\n respond_to do | format |\n format.html { render( { :template => 'reports/show' } ) }\n format.csv { csv_stream_report() }\n end\n\n flash.delete( :warning ) # Else it shows on the *next* fetched page too\n end",
"def get_first_meeting_dao\r\n @summary.first_meeting_dao\r\n end",
"def getJiraLinkByDefect(defect)\n return @db.execute(\"select jiralink from v1link where defect=\\\"#{defect}\\\"\")\n end",
"def set_report\n @report = Report.friendly.find(params[:id])\n end",
"def get_current_issue\r\n cover_page = @agent.get \"http://www.economist.com/printedition\"\r\n get_issue_from_cover_page(cover_page)\r\n end",
"def first\r\n\t\[email protected]\r\n\tend",
"def report_parent(id) \n\t\tReport.find(id)\t\t\t\n\tend",
"def access_report(db)\n\tputs \"Please enter your reference id to access your report:\"\n\tid = gets.to_i\n\tputs db.execute(\"SELECT * FROM incidents WHERE id = #{id}\")\nend",
"def first!\n fail_not_found_if_nil(first)\n end",
"def get_issue(date)\r\n cover_page = @agent.get \"http://www.economist.com/printedition/\"+date\r\n get_issue_from_cover_page(cover_page)\r\n end",
"def one\n if size == 0\n raise \"Could not find any records\"\n elsif size > 1\n raise \"Search returned multiple records when only one was expected\"\n else\n first\n end\n end",
"def show\n if session[:user_id]\n @bookmark = Bookmark.first(:conditions => \"id = \" + params[:id].to_s + \" AND user_id = \" + session[:user_id].to_s)\n if @bookmark\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @bookmark }\n end\n else\n redirect_to \"/bookmarks/\"\n end\n else\n redirect_to \"/login\"\n end\n end",
"def next\n Issue.find(:first, :conditions => ['date > ?', date], :order => 'date')\n end",
"def report_file_download(report)\n\t\t\tpost= { \"token\" => @token, \"report\" => report }\n\t\t\tfile = nil\n\t\t\tfile=nessus_http_request('file/report/download', post)\n\t\t\tif file.nil?\n\t\t\t\treturn\n\t\t\tend\n\t\t\treturn file\n\t\tend",
"def first_used_on\n w = workouts.order(\"date ASC\").first\n if w.present?\n w.date\n else\n nil\n end\n end",
"def first!\n first || raise_record_not_found_exception!\n end",
"def last_submission\n Submission.find_by_sql(\" select * from submissions\n where exercise_id = #{exercise_id} AND\n user_id = #{user_id}\n order by created_at desc\n limit 1\").first\n end",
"def first(&block)\n args = limit(1).include_docs.query\n\n end",
"def show\n final_params = []\n unless @repo.scans.last == nil\n last_scan_id = @repo.scans.last.id\n final_query_array = [\"SELECT * FROM issues WHERE scan_id = ?\", \"ORDER BY issues.severity DESC\"]\n final_params.push(last_scan_id)\n final_query = final_query_array.join(\" \")\n @issues = Issue.find_by_sql [final_query, *final_params]\n end\n end",
"def first_comment\n get_or_make_reference('Comment', @data, 'first_comment_id')\n end",
"def first_comment\n get_or_make_reference('Comment', @data, 'first_comment_id')\n end",
"def test_get_nonexisting_bookmark\n bm = @bs.get_bookmark(15000)\n assert(bm.errors.count > 0)\n end",
"def show\n @report = Report.find(params[:id])\n end",
"def show\n @report = Report.find(params[:id])\n end",
"def index\n @bookmarks = Bookmark.all\n \n @test = Bookmark.where(\"url = ?\", :url =>\"http://google.com\")\n \n @duplicates = Bookmark.find(:all,\n :select => \"url, COUNT(url) AS duplicate_count\",\n :conditions => \"url IS NOT NULL AND url != ''\",\n :group => \"url HAVING duplicate_count > 1\")\n \n @urlcount = Bookmark.count(:group => :url,\n :conditions => \"url IS NOT NULL AND url != ''\")\n \n @getuid = Bookmark.find(:all,\n :select => \"user_id, name\",\n :conditions => \"user_id =='4'\")\n \n @getallpeople = Bookmark.find(:all,\n :select => \"url, user_id\",\n :conditions => \"url = 'http://google.com'\")\n \n @getname = User.find(:all,\n :select => \"username\", :conditions => \"id = '4'\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @bookmarks }\n end\n end",
"def is_child_bookmark bookmark_index\n begin\n \n if @filename == ''\n raise 'filename not specified'\n end\n \n if bookmark_index == ''\n raise 'bookmark index not specified'\n end\n \n \n str_uri = $product_uri + '/pdf/' + @filename + '/bookmarks/' + bookmark_index.to_s\n str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) \n response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})\n \n stream_hash = JSON.parse(response_stream)\n \n return stream_hash['Bookmark']\n \n \n rescue Exception=>e\n print e\n end\n end",
"def find\n assert_not_nil @rdigg.stories.find(\"7987660\")\n end",
"def first(*args)\n find(:first, *args)\n end",
"def bookmark_details\n results = {\n manuscript: manuscript ? manuscript.id : nil,\n source_date: SDBMSS::Util.format_fuzzy_date(source.date),\n source_title: source.title,\n source_agent: source.source_agents.map(&:agent).join(\"; \"),\n titles: entry_titles.order(:order).map(&:display_value).join(\"; \"),\n authors: entry_authors.order(:order).map(&:display_value).join(\"; \"),\n dates: entry_dates.order(:order).map(&:display_value).join(\"; \"),\n artists: entry_artists.order(:order).map(&:display_value).join(\"; \"),\n scribes: entry_scribes.order(:order).map(&:display_value).join(\"; \"),\n languages: entry_languages.order(:order).map(&:display_value).join(\"; \"),\n materials: entry_materials.order(:order).map(&:display_value).join(\"; \"),\n places: entry_places.order(:order).map(&:display_value).join(\"; \"),\n uses: entry_uses.order(:order).map(&:use).join(\"; \"),\n other_info: other_info,\n provenance: unique_provenance_agents.map { |unique_agent| unique_agent[:name] }.join(\"; \"),\n }\n (results.select { |k, v| !v.blank? }).transform_keys{ |key| key.to_s.humanize }\n end",
"def find_first_comment\n\t\tcomments.first(created_at DESC)\n\tend",
"def report\r\n if Post.exists?(params[:id])\r\n if params[:reports]\r\n @new_report = Report.create_new(params, @usr)\r\n if @new_report.errors.empty?\r\n unless Configs.get_config('mailing_list').blank?\r\n Configs.get_config('mailing_list').split(',').each do |email|\r\n ReportMailer.deliver_email(@new_report.user.name, email.strip, @new_report, request.env['HTTP_HOST'])\r\n end\r\n end\r\n redirecting t(:redir), session[:last_page]\r\n return\r\n end\r\n end\r\n else\r\n redirect_to_info_page\r\n end\r\n end",
"def first\n result ? all.first : limit(1).all.first\n end",
"def find(ticket)\n\t\t\tself.result.select{ |p| p['Ticket_Number'] == ticket }.first\n\t\tend"
] | [
"0.64918804",
"0.6290008",
"0.59689224",
"0.59628683",
"0.5729023",
"0.572567",
"0.56150216",
"0.55334824",
"0.54678637",
"0.5370985",
"0.5329327",
"0.5287675",
"0.5277566",
"0.5253635",
"0.5223554",
"0.52191067",
"0.52067536",
"0.51553077",
"0.51386863",
"0.5133258",
"0.5118345",
"0.5111647",
"0.5111647",
"0.50828004",
"0.50707215",
"0.5069303",
"0.50501156",
"0.50479895",
"0.5035039",
"0.5015526",
"0.50060207",
"0.5003624",
"0.50003725",
"0.49825078",
"0.49824095",
"0.4981836",
"0.4981047",
"0.4965185",
"0.49481764",
"0.49238577",
"0.4921631",
"0.49166256",
"0.49122882",
"0.49118048",
"0.49029008",
"0.4899679",
"0.4888531",
"0.48875144",
"0.48807397",
"0.4880132",
"0.48762405",
"0.48691797",
"0.4865604",
"0.48616117",
"0.48609123",
"0.48562372",
"0.48424652",
"0.4841255",
"0.4830463",
"0.4830367",
"0.4827882",
"0.48221147",
"0.48110637",
"0.48104876",
"0.4787635",
"0.47847292",
"0.47792557",
"0.4777934",
"0.47775856",
"0.4757101",
"0.47561336",
"0.47557393",
"0.4755112",
"0.47550583",
"0.47538415",
"0.47528005",
"0.47521687",
"0.47487012",
"0.4746285",
"0.47411603",
"0.47334462",
"0.47277987",
"0.47238314",
"0.47225037",
"0.47218296",
"0.4709908",
"0.4697072",
"0.4697072",
"0.46958655",
"0.4692669",
"0.4692669",
"0.46881253",
"0.46858737",
"0.46778226",
"0.46725053",
"0.46704975",
"0.46667913",
"0.4666163",
"0.46645808",
"0.46622714"
] | 0.68113977 | 0 |
Adds a report into the database, one that respects the field requiremenets and one that does not Should return true for the first report because it respects the requiremenets and false for the second one | def test_new_report
testOne = BookmarkReport.newReport(2, 1, "issue", "description");
assert_equal true, testOne
testTwo = BookmarkReport.newReport(nil, 1, " ", "test");
assert_equal false, testTwo
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_report\n # TODO: should traverse listener queue for conditions and callbacks\n if @rain == :warning or @rain == :imminent\n @site.reports.create\n end\n end",
"def can_ba_create_report?\n (status == Service.status_confirmed || status == Service.status_conducted) && report.nil? \n end",
"def add_report_values\n\t\tunless self.patient.blank?\n\t\t\tself.reports.map{|report|\n\t\t\t\tif report.consider_for_processing?(self.history_tags)\n\t\t\t\t\treport.tests.map{|test|\n\t\t\t\t\t\ttest.add_result(self.patient,self.history_tags) \n\t\t\t\t\t}\n\t\t\t\tend\n\t\t\t}\n\t\tend\n\tend",
"def create\n @report = Report.new(report_params)\n @report.excercise = (report_params['excercise'] == \"Yes\" ? 1 : 0)\n if @report.save\n redirect_to reports_path\n else\n flash[:error] = \"Something went wrong.\"\n render 'new'\n end\n end",
"def create_new_report!; end",
"def create_new_report!; end",
"def report?\n [email protected]? && !Report.where(reportable_id: @proposal.id,\n reportable_type: 'Proposal',\n user_id: @user.id).exists?\n end",
"def create_report_if_valid!\n messages = conversation.messages.valid.where.not(step: nil).group(:step)\n\n if messages.size.size == STEPS.size + 1\n messages = conversation.messages.valid.where.not(step: nil).group_by(&:step)\n\n params = {\n user_email: remove_short_code(messages[1].first.body),\n reportee_name: remove_short_code(messages[2].first.body),\n reportee_mother_name: remove_short_code(messages[3].first.body),\n address: remove_short_code(messages[4].first.body),\n district: remove_short_code(messages[5].first.body),\n probable_cause: CATEGORIES_MAPPING[remove_short_code(messages[6].first.body).to_i]\n }\n\n # Creates the report and notifies the user\n CreateReport.new(params.with_indifferent_access).create!\n conversation.finished!\n send_sms('Recebemos seu alerta com sucesso, obrigado.')\n end\n end",
"def create\n # if report is valid, save it and set flag (no need to run it b/c it will be redirected)\n @report.just_created = true if @report.errors.empty?\n \n # return data in json format\n render(:json => {:report => @report}.to_json)\n end",
"def create\n @account = current_account\n @expense_report = ExpenseReport.new(expense_report_params)\n @expense_report.account_id = @account.id\n @expense_report.estimate2 =(@expense_report.Flight + @expense_report.Hotel + @expense_report.Transportation + @expense_report.Other)\n \n @travel_forms = TravelForm.all\n @expense_reports = ExpenseReport.all\n @expense_reports.each do |expense_report|\n @travel_forms.each do |travel_form|\n @travel_form = @travel_forms.find(@expense_report.travel_forms_id)\n if @expense_report.estimate2 > @travel_form.estimate\n @expense_report.update_attributes(:status => \"Denied\")\n end\n end\n end\n respond_to do |format|\n if @expense_report.save\n format.html { redirect_to employee_path(current_account.accountable_id), notice: 'Expense report was successfully created.' }\n format.json { render :show, status: :created, location: @expense_report }\n else\n format.html { render :new }\n format.json { render json: @expense_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @review=Review.find(params[:reported_id])\n @report = Report.new(report_params)\n @user=User.find(params[:reporter_id])\n \n \n if @report.save\n @review.passive_reports<<@report\n @user.active_reports<<@report\n flash[:success] = \"report created!\"\n redirect_to \"/items/\"[email protected]_s\n else\n redirect_to :root\n end\n \n end",
"def add_report_item(employee, record)\n if record.hours_worked != 0 \n amount_paid = 0\n case employee.job_group\n when \"A\"\n amount_paid += record.hours_worked * 30\n when \"B\"\n amount_paid += record.hours_worked * 20\n end\n current_date = record.date\n case current_date.day\n when 1..15\n pay_start_date = current_date.beginning_of_month\n pay_end_date = Date.new(current_date.year, current_date.month, 15)\n when 16..31\n pay_start_date = Date.new(current_date.year, current_date.month, 16)\n pay_end_date = current_date.end_of_month \n end\n report = Report.where(employee_id: employee.id, pay_start_date: pay_start_date, pay_end_date: pay_end_date).first_or_create\n report.amount_paid ||= 0\n report.amount_paid += amount_paid\n report.save!\n end\n end",
"def create\n @report = Report.new(report_params)\n @report.owner_id = current_user.id\n @report.creation_date = Date.today\n @report.diference = (@report.consumedCalories - @report.burnedCalories) \n if @report.diference > 0\n @report.diference_value = 'Caloric Surplus'\n elsif @report.diference <0\n @report.diference_value = 'Caloric Deficit'\n else\n @report.diference_value = 'Balance'\n end\n \n progress = Progress.where('user_id = ?', current_user.id).where('expires_at = ?', @report.creation_date)\n if progress != nil\n \n progress.each do |goal|\n puts \"Informacion de mi goal #{goal.consumedCalories} #{goal.burnedCalories} #{goal.consumedObjetive} #{goal.burnedObjetive} \"\n goal.burnedObjetive = goal.burnedObjetive + @report.burnedCalories\n goal.consumedObjetive = goal.consumedObjetive + @report.consumedCalories\n goal.porcent = (((goal.burnedObjetive+goal.consumedObjetive) * 100)/(goal.consumedCalories+goal.burnedCalories)).to_i\n if goal.porcent > 100\n goal.porcent = 100\n end\n puts \"Informacion de mi goal2 #{goal.consumedCalories} #{goal.burnedCalories} #{goal.consumedObjetive} #{goal.burnedObjetive} \"\n if goal.save\n puts \"guarda\"\n else\n puts \"algo paso\"\n end\n end\n end\n \n \n\n respond_to do |format|\n if @report.save\n format.html { redirect_to @report, notice: \"Report was successfully created.\" }\n format.json { render :show, status: :created, location: @report }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @report = current_user.reports.build(params[:report])#The method salary and apf is private and at the end of file\n\n correct_fuel(params[:report][:tractor_code], [email protected]_fuel_cost)\n \n respond_to do |format|\n if @report.save\n format.html { redirect_to @report, notice: 'Report was successfully created.' }\n # format.json { render json: @report, status: :created, location: @report }\n else\n format.html { render action: \"new\" }\n #format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n raise \"Disabled\"\n @report = Report.new(report_params)\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to @report, notice: 'Report was successfully created.' }\n format.json { render :show, status: :created, location: @report }\n else\n format.html { render :new }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def reports?\n !reports.empty?\n end",
"def generate_report\n @notices << \"#{ActionController::Base.helpers.pluralize(@batch_ids.count, 'Item')} clearanced into batch #{batch.id}\" if batch.id\n @errors << \"#{ActionController::Base.helpers.pluralize(@errors.count, 'id')} raised errors and were not clearanced\" if errors.any?\n @errors << \"No new clearance batch was added\" unless batch.id\n @errors << \"No Item or CSV passed\" if !@item_id && !@file\n end",
"def validate_report\n report_command ={}\n report_command[:request_report] = true\n puts \"Report command has been added\".colorize(:green)\n return report_command\nend",
"def at_least_one_indicator_target_exist \n #when not even 1 set exist(indicator_desc+target+achievement+progress )\n if half==2 && (indicator_desc_quality.blank? && target_quality.blank? && achievement_quality.blank? && progress_quality.blank?) && (indicator_desc_time.blank? && target_time.blank? && achievement_time.blank? && progress_time.blank?) && (indicator_desc_quantity.blank? && target_quantity.blank? && achievement_quantity.blank? && progress_quantity.blank?) && (indicator_desc_cost.blank? && target_cost.blank? && achievement_cost.blank? && progress_cost.blank?)\n return false \n errors.add(\"aa\",\"error la\")\n# elsif id.nil? && half==2 \n# \n# #when user selected 'Sent to PPP for Report' - with INCOMPLETE NEWly inserted xtvt(not yet saved) - (render fields although record not yet saved due to errors)\n# #RESTRICTIONS : requires 'Target fields' to be completed for repeating fields to be rendered when error occurs\n# if ( !indicator_desc_quality.blank? && !target_quality.blank? && !achievement_quality.blank? && !progress_quality.blank?)\n# return true\n# else\n# return false\n# end\n# if ( !indicator_desc_time.blank? && !target_time.blank? && !achievement_time.blank? && !progress_time.blank?)\n# return true\n# else\n# return false\n# end\n# if ( !indicator_desc_quantity.blank? && !target_quantity.blank? && !achievement_quantity.blank? && progress_quantity.blank?)\n# return true\n# else\n# return false\n# end\n# if ( !indicator_desc_cost.blank? && !target_cost.blank? && !achievement_cost.blank? && !progress_cost.blank?)\n# return true\n# else\n# return false\n# end\n\n elsif half==1 && (indicator_desc_quality.blank? && target_quality.blank?) && (indicator_desc_time.blank? && target_time.blank?) && (indicator_desc_quantity.blank? && target_quantity.blank?) && (indicator_desc_cost.blank? && target_cost.blank?)\n return false\n end\n end",
"def create\n if current_user.company.reports.any?\n if [\"Queued\", \"Running\"].include? current_user.company.reports.last.status\n redirect_to dashboard_path, notice: \"Looks like you already have a report queued. We'll get to it asap, promise!\"\n return\n end\n end\n \n @report = Report.new(report_params) \n\n respond_to do |format|\n if @report.save\n \n @report.test_suite.test_cases.order('id ASC').each do |test_case|\n @report.results.create({ status: 'Queued', report_id: @report, test_case_id: test_case.id})\n end\n \n ReportMailer.admin_requested_report_triggered_email(@report).deliver\n #ReportMailer.requested_report_triggered_email(@report).deliver\n \n format.html { redirect_to dashboard_path }\n format.json { render action: 'show', status: :created, location: @report }\n else\n format.html { render action: 'new' }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.find(params[:user_id])\n @report = @user.reports.create(report_params)\n @report.date = prepare_date(params[:date])\n prepare_report()\n @report.balance = @report_summary.working_hours_balance\n @report.workingHours = @report_summary.working_hours\n\n success = false\n begin\n if @report.save\n success = true\n end\n rescue ActiveRecord::RecordNotUnique\n flash[:alert] = I18n.t('controllers.reports.already_exists_for_date')\n end\n\n respond_to do |format|\n if success\n format.html { redirect_to [@report.user, @report], notice: I18n.t('controllers.reports.successfully_created') }\n format.json { render :show, status: :created, location: @report }\n else\n format.html { render :new }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_fields\n @screen = session.active_screen\n @report = Report.find(params[:id])\n\n params[:report] ||= {}\n params[:report][:fields] ||= []\n\n org_field_report = @report.fields_reports\n new_field_reports = params[:report][:fields]\n\n #remove not exist in new\n rem_field_report_ids = org_field_report.collect{|fr| fr.id}.compact - new_field_reports.collect{|f_r| f_r[:field_report_id].to_i unless f_r[:field_report_id].empty?}.compact\n org_field_report.each do |fr|\n fr.destroy if rem_field_report_ids.include?(fr.id)\n end unless rem_field_report_ids.empty?\n\n # merge field_report\n new_field_reports.each_with_index do |f_r, idx|\n f_r[:seq_no] = idx\n f_r['formula'] = YAML::load(f_r['formula'].gsub('^n',\"\\n\")) unless f_r['formula'].empty?\n field_report_id = f_r.delete(:field_report_id).to_i\n if field_report_id == 0\n f_r['percentage_weight'] = {'-1' => 'false'}\n \n @report.fields_reports << FieldsReport.new(f_r)\n else\n field_report = FieldsReport.find(field_report_id)\n field_report.update_attributes(f_r)\n end\n end\n\n ht_report = {}\n ht_report[:cell_location] = params[:report][:cell_location]\n \n @report.update_attributes(ht_report)\n end",
"def create\n authorize :report, :create?\n @report = Report.new(report_params)\n @report.user_id = current_user.id\n @report.resquest_criminal = @resquest_criminal\n @report.resquest_criminal.status = 1\n @report.resquest_criminal.save\n respond_to do |format|\n if @report.save\n format.html { redirect_to [@resquest_criminal,@report], notice: 'Report was successfully created.' }\n else\n format.html { render :new }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_attendence\n Attendence.create!([{\n report_id: 1,\n student_id: 1,\n present: true\n },\n {\n report_id: 1,\n student_id: 3,\n present: false\n },\n {\n report_id: 1,\n student_id: 4,\n present: true\n },\n {\n report_id: 1,\n student_id: 5,\n present: false\n }])\nend",
"def create\n retval = @survey.create_report_mockup(params[:report_mockup])\n render_json_auto retval and return\n end",
"def report_accessible?\n report || is_admin\n end",
"def init_report\n raise if @report.new_record?\n \n # if not a new record, run it and record viewing\n @report.record_viewing\n \n return run_and_handle_errors\n end",
"def cant_report_myself\n # This line will check if the id that you want report is equal of yours id\n if self.reporter.id == self.reported.id\n # This is a message that show if you want report yourself\n errors.add(:expiration_date, \"can't report myself\")\n # Will render nothing if you dont fit on this\n else\n # do nothing\n end\n end",
"def create\n @report = Report.new(report_params)\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to admin_reports_path, notice: t('shared.msgs.success_created',\n obj: t('activerecord.models.report', count: 1)) }\n format.json { render :show, status: :created, location: @report }\n else\n set_date\n format.html { render :new }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @annual_summary_report = AnnualSummaryReport.new(annual_summary_report_params)\n\n #create default questions\n questions = Question.all\n @annual_summary_report.user_id = current_user.id\n @annual_summary_report.status = 1\n\n respond_to do |format|\n if @annual_summary_report.save\n for question in questions\n answer = Answer.new\n answer.question = question.question\n answer.question_id = question.id\n answer.answer = '';\n answer.section_id = question.section_id\n answer.annual_summary_report_id = @annual_summary_report.id\n answer.save\n end\n\n format.html { redirect_to @annual_summary_report }\n format.json { render :show, status: :created, location: @annual_summary_report }\n else\n format.html { render :new }\n format.json { render json: @annual_summary_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if report_params[:client_id] # This seems to work for both new and existing clients, correctly creates and associates new client. Check again after adding validations.\n @report = Report.create(report_params)\n redirect_to user_report_path(current_user, @report)\n #elsif report_params[:client_attributes][:name]\n # @report = Report.new.build_client(name: report_params[:client_attributes][:name]).update(report_params)\n else\n render \"/reports/new\"\n end\n end",
"def create\n @report = Report.new(report_params)\n @report.user = current_user\n\n # the report period is based on the created_at date\n # need to have current period be an enum or boolean for period - current, findby\n current_period = Period.first\n @report.period = current_period\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to @report, notice: \"Report was successfully created.\" }\n format.json { render :show, status: :created, location: @report }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def compare_report\n @accounts_enabled = (Configuration.get_config_value 'MultiFeeAccountEnabled').to_i == 1\n @accounts = FeeAccount.all if @accounts_enabled\n end",
"def create_report\n\tcreate_rep_heading\n \tcreate_product_data\n \tcreate_brand_data\nend",
"def create\n\t\t\n @reporte = Reporte.new(reporte_params)\n\t\t@asignacion_actividad = @reporte.asignacion_actividad\n @actividad = @asignacion_actividad.actividad\n @proyecto = @actividad.proyecto\n\n\t\t\tif current_usuario.asignacion_roles.where(esActual: true, id: Rol.where(nombre: \"Voluntario\"), proyecto: @proyecto) && current_usuario.asignacion_roles.where(esActual: true, proyecto: @proyecto).count == 1\n\t\t\traise CanCan::AccessDenied if !Reporte.accessible_by(current_ability, :create).include?(@actividad.reportes.first)\n\t\telse\n\t\t\tauthorize! :create, Reporte\n\t\tend\n\n \n respond_to do |format|\n if @reporte.save\n\t format.html { redirect_to :action => 'index', :actividad_id => @reporte.asignacion_actividad.actividad.id \n\t\t flash[:success] = 'Reporte fue creado satisfactoriamente.' }\n format.json { render :show, status: :created, location: @reporte }\n else\n format.html { render :new }\n format.json { render json: @reporte.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_report_type\n\n\treport_type = ReportType.find_by_report_type_code(self.report_type_code)\n\t if report_type != nil \n\t\t self.report_type = report_type\n\t\t return true\n\t else\n\t\terrors.add_to_base(\"value of field: 'report_type_code' is invalid- it must be unique\")\n\t\t return false\n\tend\nend",
"def create\n @report = Mg::Report.new(params[:report])\n\n respond_to do |format|\n if @report.save\n format.html { flash[:notice] = 'Your report was successfully created, now add some report items.'; redirect_to(edit_mg_report_url @report) }\n format.xml { render :xml => @report, :status => :created, :location => @report }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @report.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @report = Report.new(report_params)\n\n respond_to do |format|\n if @report.save\n \n @report.test_suite.test_cases.each do |test_case|\n @report.results.create({ status: 'Queued', report_id: @report, test_case_id: test_case.id})\n end\n \n format.html { redirect_to [:admin, @report], notice: 'Report was successfully created.' }\n format.json { render action: 'show', status: :created, location: @report }\n else\n format.html { render action: 'new' }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @test_plan = TestPlan.new(params[:test_plan])\n @test_plan.report_definitions << ReportDefinition.find(params[:report_definition_id]) if params[:report_definition_id]\n\n respond_to do |format|\n if @test_plan.save\n format.html { redirect_to @test_plan, notice: 'Test plan was successfully created.' }\n format.json { render json: @test_plan, status: :created, location: @test_plan }\n else\n format.html { render action: \"new\" }\n format.json { render json: @test_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_report\n Report.create_for_team(id)\n end",
"def create_report\n Report.create_for_team(id)\n end",
"def agreement_report\n\t\treport = ActiveReporting::Report.new( { :title => \"Review Stage Agreement\", :description => \"Comparison of document dispositions across reviewers\" } )\n\t\tfor sr in self.stage_reviewers do\n\t\t\treport.columns << ActiveReporting::Report::Column.new( :title => \"Reviewer #{sr.user.nickname}\", :formatter => Proc.new { |v| DocumentReview.action_verb(v) } )\n\t\tend\n\t\treport.columns << ActiveReporting::Report::Column.new( :title => \"Count\" )\n\t\tsql_select1 = self.stage_reviewers.collect{ |sr| \"dr#{sr.id}.disposition disposition#{sr.id}\" }.join(\", \")\n\t\tsql_join1 = self.stage_reviewers.collect{ |sr| \"LEFT JOIN stage_reviewers sr#{sr.id} ON sr#{sr.id}.review_stage_id = rs.id AND sr#{sr.id}.id = #{sr.id}\" }.join(\"\\n\")\n\t\tsql_join2 = self.stage_reviewers.collect{ |sr| \"LEFT JOIN document_reviews dr#{sr.id} ON dr#{sr.id}.stage_reviewer_id = sr#{sr.id}.id AND dr#{sr.id}.document_id = d.id\" }.join(\"\\n\")\n\t\tsql_where1 = self.stage_reviewers.collect{ |sr| \"dr#{sr.id}.id IS NOT NULL\" }.join(\" OR \")\n\t\tsql_group1 = self.stage_reviewers.collect{ |sr| \"dr#{sr.id}.disposition\" }.join(\", \")\n\t\t# SELECT dr101.disposition disp202, dr202.disposition disp202, count(d.id)\n\t\t# FROM review_stages rs, documents d\n\t\t# LEFT JOIN stage_reviewers sr101 ON sr101.review_stage_id = rs.id AND sr101.id = 101\n\t\t# LEFT JOIN stage_reviewers sr202 ON sr202.review_stage_id = rs.id AND sr202.id = 202\n\t\t# LEFT JOIN document_reviews dr101 ON dr101.stage_reviewer_id = sr101.id AND dr101.document_id = d.id\n\t\t# LEFT JOIN document_reviews dr202 ON dr202.stage_reviewer_id = sr202.id AND dr202.document_id = d.id\n\t\t# GROUP BY dr101.disposition, dr202.disposition\n\t\t# WHERE rs.id = #{self.id} AND (dr101.id NOT NULL OR dr202.id NOT NULL)\n\t\tsql = <<-EOT\n\t\t\tSELECT\n\t\t\t\t#{sql_select1},\n\t\t\t\tCOUNT(d.id) document_count\n\t\t\t\tFROM review_stages rs JOIN documents d\n\t\t\t\tLEFT JOIN document_sources ds ON d.document_source_id = ds.id\n\t\t\t\t#{sql_join1}\n\t\t\t\t#{sql_join2}\n\t\t\t\tWHERE rs.id = #{self.id} AND ds.project_id = rs.project_id AND (#{sql_where1})\n\t\t\t\tGROUP BY\n\t\t\t\t\t#{sql_group1}\n\t\t\t\t;\n\t\tEOT\n\t\trows = self.connection.select_rows( sql )\n\t\tfor row in self.connection.select_rows( sql )\n\t\t\tvalues = {}\n\t\t\treport.columns.each_index do |i|\n\t\t\t\tcol = report.columns[i]\n\t\t\t\tvalue = col.format(row[i])\n\t\t\t\tvalues[col] = value\n\t\t\tend\n\t\t\trow = ActiveReporting::Report::Row.new( values )\n\t\t\treport.rows << row\n\t\tend\n\t\treport\n\tend",
"def create\n @report = current_user.reports.new(params[:report])\n @wizard = Wizard.new(params[:report], view_context)\n\n if @report.save\n if @wizard.active?\n @wizard.append_report @report.id\n redirect_to wizard_step4_path(@wizard.parameters), notice: 'Report was successfully saved.'\n else\n redirect_to report_path(@report), notice: 'Report was successfully created.' \n end\n else\n render action: \"new\" \n end\n end",
"def create\n @compliance_record = ComplianceRecord.new(compliance_record_params)\n if @compliance_record.save\n @compliance_record = ComplianceRecord.new\n @compliance_records = ComplianceRecord.all\n @flag = true\n else\n @flag = false\n end\n end",
"def create\n @report = Report.new(report_params.merge(user_id: current_user.id))\n\n if @report.save\n redirect_to @report, notice: t(\"activerecord.attributes.report.created\")\n else\n ender :new\n end\n end",
"def report_test\n report_data = params.require(:api).permit(:code,:stdout,:project,:suite,:section)\n report = api_user.test_reports.create(report_data)\n if report.valid?\n render text: \"ok\"\n else\n raise \"Invalid report\"\n end\n end",
"def update_requirements\n\t\treset_category_quantities_and_reports\n\t\tself.reports.map{|report|\n\t\t\treport.requirements.each do |req|\n\t\t\t\toptions = req.categories.size\n\t\t\t\t## now we need something to expand.\n\t\t\t\t## \n\t\t\t\treq.categories.each_with_index {|category,key|\n\t\t\t\t\t#puts \"looking for category: #{category.name}\"\n\t\t\t\t\tif !has_category?(category.name)\n\t\t\t\t\t\tcategory_to_add = Inventory::Category.new(quantity: category.quantity, required_for_reports: [], optional_for_reports: [], name: category.name)\n\t\t\t\t\t\tif options > 1\n\t\t\t\t\t\t\tcategory_to_add.optional_for_reports << report.id.to_s\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tcategory_to_add.required_for_reports << report.id.to_s\n\t\t\t\t\t\tend\n\t\t\t\t\t\t\n\t\t\t\t\t\t## so now what next,\n\t\t\t\t\t\t## dim that\n\t\t\t\t\t\t## don't show set_changed_for_lis\n\t\t\t\t\t\t## if its the first category in any requirement, then it is absolutely essential.\n\t\t\t\t\t\tcategory_to_add.show_by_default = Inventory::Category::YES if key == 0\n\n\t\t\t\t\t\t## however if we can ignore missing items in this category, then we don't need to show it by default.\n\t\t\t\t\t\tcategory_to_add.show_by_default = Inventory::Category::NO if category.ignore_missing_items == Inventory::Category::YES\n\t\t\t\t\t\t\n\t\t\t\t\t\tself.categories << category_to_add\n\t\t\t\t\telse\n\t\t\t\t\t\tself.categories.each do |existing_category|\n\t\t\t\t\t\t\tif existing_category.name == category.name\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\texisting_category.quantity += category.quantity\n\n\t\t\t\t\t\t\t\tif options > 1\n\t\t\t\t\t\t\t\t\texisting_category.optional_for_reports << report.id.to_s\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\texisting_category.required_for_reports << report.id.to_s\n\t\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\t\texisting_category.optional_for_reports.flatten!\n\n\t\t\t\t\t\t\t\texisting_category.required_for_reports.flatten!\n\n\t\t\t\t\t\t\t\texisting_category.show_by_default = Inventory::Category::YES if key == 0\n\n\t\t\t\t\t\t\t\texisting_category.show_by_default = Inventory::Category::NO if category.ignore_missing_items == Inventory::Category::YES\n\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t}\n\t\t\tend\n\t\t}\t\t\n\tend",
"def redirect_new_report!(options, params:, **)\n params['new_report'] == 'true' ? options['new_report'] = true : options['new_report'] = false\n true\n end",
"def report_learner\n # I'm using the ! here so we can track down errors faster if there is an issue making\n # the report_learner\n super || create_report_learner!\n end",
"def create_report(type, uri_list)\n \n LOGGER.info \"create report of type '\"+type.to_s+\"'\"\n check_report_type(type)\n \n #step 0.5: replace cv-uris with list of validation-uris\n LOGGER.debug \"validation uri list '\"+uri_list.inspect+\"'\"\n uri_list = Reports.ot_access.resolve_cv_uris(uri_list) \n \n # step1: load validations\n validation_set = Reports::ValidationSet.new(uri_list)\n raise Reports::BadRequest.new(\"no validations found\") unless validation_set and validation_set.size > 0\n LOGGER.debug \"loaded \"+validation_set.size.to_s+\" validation/s\"\n \n #step 2: create report of type\n report_content = Reports::ReportFactory.create_report(type, validation_set)\n LOGGER.debug \"report created\"\n \n #step 3: persist report if creation not failed\n id = @persistance.new_report(report_content, type)\n LOGGER.debug \"report persisted with id: '\"+id.to_s+\"'\"\n \n return get_uri(type, id)\n end",
"def report_definition\n\t\treport_def = {\n\t\t\tname: {difficulty: 40, approximator: \"none\", field_name:\"name\", max_datum:nil},\n\t\t\tdescription: {difficulty: 40, approximator:\"none\", field_name:\"description\", max_datum:nil},\n\t\t\tis_church: {difficulty: 40, approximiator:\"none\", field_name:\"is_church\", max_datum:nil},\n\t\t\tis_kingdom: {difficulty: 40, approximiator:\"none\", field_name:\"is_kingdom\", max_datum:nil},\n\t\t\tleader: {difficulty: 60, approximator:\"none\", field_name:\"leader_name\", max_datum:nil},\n\t\t\tsuzerain: {difficulty: 60, approximator:\"none\", field_name:\"suzerain_name\", max_datum:nil}\n\t\t}\t\t\t\n\tend",
"def populate_reports\n\t\tauthor_id \t\t= [*1..40].sample\n\t\tsummary \t\t= Faker::Lorem.sentences(3).join(' ')\n\t\treason \t\t\t= [*0..4].sample # enum\n\t\t\n\t\t# Report on other users\n\t\tusers = User.limit(5)\n\t\tusers.each do |u|\n\t\t\tu.reports_received.create!(author_id: author_id, reason: reason, summary: summary)\n\t\tend\n\n\t\t# Report on other services\n\t\tservices = Service.limit(5)\n\t\tservices.each do|s|\n\t\t\ts.reports_received.create!(author_id: author_id, reason: reason, summary: summary)\n\t\tend\n\tend",
"def add(date, country, install_count, update_count)\n ret = @db.execute(\"INSERT INTO reports (report_date, country, \" +\n \"install_count, update_count) VALUES (?, ?, ?, ?)\",\n [format_date(date), country, install_count, update_count])\n true\n rescue SQLite3::ConstraintException => e\n if e.message =~ /columns .* are not unique/\n $stdout.puts \"Skipping existing row for #{country} on #{date}\" if verbose?\n false\n else\n raise e\n end\n end",
"def create\n @report = Report.new(report_params)\n \n if report_params[:begin_dt] == nil and report_params[:end_dt] == nil then\n @begin_datetime = Time.new(report_params[\"begin_dt(1i)\"].to_i, report_params[\"begin_dt(2i)\"].to_i, report_params[\"begin_dt(3i)\"].to_i, report_params[\"begin_dt(4i)\"].to_i, report_params[\"begin_dt(5i)\"].to_i)\n @end_datetime = Time.new(report_params[\"end_dt(1i)\"].to_i, report_params[\"end_dt(2i)\"].to_i, report_params[\"end_dt(3i)\"].to_i, report_params[\"end_dt(4i)\"].to_i, report_params[\"end_dt(5i)\"].to_i)\n else \n @begin_datetime = report_params[:begin_dt].to_date\n @end_datetime = report_params[:end_dt].to_date\n end\n \n respond_to do |format|\n error_inconsistent_data_time = false\n if report_params[:generate_by].to_i != 0 and @begin_datetime >= @end_datetime then\n error_inconsistent_data_time = true\n end\n \n error_residuos_not_find = true\n case report_params[:generate_by].to_i\n when 0\n error_residuos_not_find = false\n when 1 #teste por departamento\n report_params[:list].each do |dep_name|\n if dep_name == \"\" then\n next\n end\n dep = Department.find_by(name: dep_name)\n if dep != nil then\n labs = dep.laboratories\n if labs != nil then\n labs.each do |lab|\n if !lab.residues.empty? then\n error_residuos_not_find = false\n end\n end\n end\n end\n end\n when 2 #teste por laboratórios\n report_params[:list].each do |lab_name|\n if lab_name == \"\" then\n next\n end\n if !Laboratory.find_by(name: lab_name).residues.empty? then\n error_residuos_not_find = false\n end\n end\n when 3\n error_residuos_not_find = false\n end\n \n if error_inconsistent_data_time\n @report.errors.add(:begin_dt, :blank, message: \"intervalo de data invalido: a data e hora de inicio esta posterior ou iqual a data e hora de final do intervalo requerido.\")\n format.html { render :new }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n elsif error_residuos_not_find\n @report.errors.add(:list, :blank, message: \"Não há residuos associados a esse(s) departamento(s)/laboratório(s)!\")\n format.html { render :new }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n elsif @report.save\n format.html { redirect_to @report, notice: 'O Relatório foi criado com sucesso!' }\n format.json { render :show, status: :created, location: @report }\n case report_params[:generate_by].to_i\n when 0 #relatório por coleção\n generate_by_collection\n when 1 #relatório por departamento\n generate_by_department\n when 2 #relatório por laboratórios\n generate_by_laboratory\n when 3 #relatório por residuos\n generate_by_residue\n end\n else\n format.html { render :new }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def report\n\t\tend",
"def set_report\n end",
"def set_can_be_finalized\n\t\tself.reports.each do |report|\n\t\t\tif report.worth_processing.blank?\n\t\t\t\tself.can_be_finalized ||= \"The order cannot be finalized for the following reasons:\"\n\t\t\t\tself.can_be_finalized += (\"<br>\" + report.name.to_s + \" -- \" + \" You need to add tube barcode details, or answer history questions to proceed.\")\n\t\t\tend\n\t\tend\n\t\tif self.can_be_finalized.blank?\n\t\t\tself.can_be_finalized = \"true\"\n\t\tend\n\tend",
"def create\n\t\t@report = Report.create(params[:report])\n\t\t\n\t\t@existing = Report.where( :cell_id => params[:report][:cell_id] ).first\n\t\tif @existing\n\t\t\trespond_to do |format|\n\t\t\t\tformat.html { redirect_to @existing, notice: 'Report already existed.' }\n\t\t\t\tformat.json { render json: @existing, status: :ok }\n\t\t\tend\n\t\telse\n\t\t\trespond_to do |format|\n\t\t\t\tif @report.save\n\t\t\t\t\tformat.html { redirect_to @report, notice: 'Report was successfully created.' }\n\t\t\t\t\tformat.json { render json: @report, status: :created, location: @report }\n\t\t\t\telse\n\t\t\t\t\tformat.html { render action: \"new\" }\n\t\t\t\t\tformat.json { render json: { :errors => @report.errors, :data => @report }, status: :unprocessable_entity }\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def create\n if current_user.admin?\n @report = Report.new(report_params)\n respond_to do |format|\n if @report.save\n format.html { redirect_to @report, notice: 'Report was successfully created.' }\n format.json { render :show, status: :created, location: @report }\n else\n format.html { render :new }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n else\n redirect_back :fallback_location => root_path, :alert => \"Access denied.\"\n end\n end",
"def create\n if OpinionReport.where(opinion_report_params).count > 0\n render json: {\n status: \"Error\",\n message: \"Ya se ha enviado un reporte sobre esta opinión\"\n }.to_json\n else \n @opinion_report = OpinionReport.new(opinion_report_params)\n if @opinion_report.save\n render json: {\n status: \"Exito\",\n message: \"Se ha enviado la denuncia satisfactoriamente\"\n }.to_json\n else\n format.json { render json: @opinion_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category_report = CategoryReport.new(category_report_params)\n set_exam_and_category\n @category_report.category = @category \n @value_max = @category.find_value_max\n\n if @category_report.save\n if @category.find_remaining_value_min == @value_max\n # Go back to the list of categories if all reports have been created for this category\n @category.reports_complete = true\n @category.save!\n redirect_to category_reports_exam_path(@exam), notice: \"All reports for category #{@category.name} have been created successfully\"\n else\n # Go back to another new report form for this category if not all values have been covered\n redirect_to new_exam_category_category_report_path(@exam, @category, value_min: @category_report.value_max + 1, value_max: @value_max), notice: \"Category report created successfully\"\n end\n else\n @value_min = @category.find_remaining_value_min\n render :new\n end\n end",
"def should_report?\n [email protected]_currency or !@external or (@original_currency||currency) == @reporter.report_currency\n end",
"def report(report_name, report, _path)\n case report_name\n when \"{#{NS_CALDAV}}calendar-multiget\"\n @server.transaction_type = 'report-calendar-multiget'\n calendar_multi_get_report(report)\n return false\n when \"{#{NS_CALDAV}}calendar-query\"\n @server.transaction_type = 'report-calendar-query'\n calendar_query_report(report)\n return false\n when \"{#{NS_CALDAV}}free-busy-query\"\n @server.transaction_type = 'report-free-busy-query'\n free_busy_query_report(report)\n return false\n end\n end",
"def find_or_create_report(opts)\n\t\treport_report(opts.merge({:wait => true}))\n\tend",
"def create\n # debugger\n # reportable = params[:report][:reportable].split(',').collect {|s| s.strip}\n #\n # at this point params might be:\n #\n # {\"commit\"=>\"Create\", \"action\"=>\"create\", \"controller\"=>\"reports\", \n # \"report\"=>{\"name\"=>\"third report\", \"public\"=>\"0\", \"reportable_id\"=>\"1\", \"description\"=>\"another description\", \"otrunk_report_template_id\"=>\"1\"}}\n #\n # we can just create a new @report instance like this:\n #\n # \n # This way all the parameters are set that are present in the\n # hash value for \"report\" in params.\n #\n # but do need to handle hard-coding the reportable_type because\n # it isn't handled more generally yet by the view or the DIY\n #\n #\n # eot_id = params[:report][:reportable_id]\n # ort_id = params[:report][:otrunk_report_template_id]\n # @report = Report.new(:reportable_type => \"ExternalOtrunkActivity\", :reportable_id => eot_id, :otrunk_report_template_id => ort_id)\n #\n @report.user = current_user\n respond_to do |format|\n if @report.save\n flash[:notice] = 'Report was successfully created.' \n format.html { redirect_to reports_url }\n format.xml { render :xml => @report, :status => :created, :location => @report }\n else\n flash[:notice] = 'Errors creating Report.'\n format.html { render :action => \"new\" }\n format.xml { render :xml => @report.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def allotment_is_not_100\n if not allot_for_item.blank? and not allot_for_const.blank? and not allot_for_research.blank?\n errors.add(:base, I18n.t('activerecord.errors.models.houdd_user.attributes.allotment_is_not_100')) if (allot_for_item + allot_for_const + allot_for_research) != 100\n end\n end",
"def create\n @weekly_report = WeeklyReport.new(weekly_report_params)\n @weekly_report.user = current_user\n @weekly_report.group = current_user.group\n @weekly_report.published = true if @weekly_report.reported_time < Time.now\n\n respond_to do |format|\n if @weekly_report.save\n format.html { redirect_to @weekly_report, notice: 'Weekly report was successfully created.' }\n format.json { render :show, status: :created, location: @weekly_report }\n else\n format.html { render :new }\n format.json { render json: @weekly_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def enriched_report(final_report)\n return unless final_report.is_a?(Hash)\n\n # Remove nil profiles if any\n final_report[:profiles].select! { |p| p }\n\n # Label this content as an inspec_report\n final_report[:type] = 'inspec_report'\n\n # Ensure controls are never stored or shipped, since this was an accidential\n # addition in InSpec and will be remove in the next inspec major release\n final_report.delete(:controls)\n final_report[:node_name] = @node_name\n final_report[:end_time] = Time.now.utc.strftime('%FT%TZ')\n final_report[:node_uuid] = @entity_uuid\n final_report[:environment] = @environment\n final_report[:roles] = @roles\n final_report[:recipes] = @recipes\n final_report[:report_uuid] = @run_id\n final_report[:source_fqdn] = @source_fqdn\n final_report[:organization_name] = @organization_name\n final_report[:policy_group] = @policy_group\n final_report[:policy_name] = @policy_name\n final_report[:chef_tags] = @chef_tags\n final_report[:ipaddress] = @ipaddress\n final_report[:fqdn] = @fqdn\n\n final_report\n end",
"def report(report_name, dom, _path)\n case report_name\n when \"{#{NS_CARDDAV}}addressbook-multiget\"\n @server.transaction_type = 'report-addressbook-multiget'\n addressbook_multi_get_report(dom)\n return false\n when \"{#{NS_CARDDAV}}addressbook-query\"\n @server.transaction_type = 'report-addressbook-query'\n addressbook_query_report(dom)\n return false\n else\n return true\n end\n end",
"def create\n if !params[:reporter_name].nil? && !params[:pet_id].nil? && !params[:lat].nil? && !params[:lon].nil? && (!params[:reporter_cel].nil? || !params[:reporter_phone].nil? || !params[:reporter_email].nil? || !params[:reporter_observations].nil?)\n pet = Pet.find_by_id(params[:pet_id])\n if pet\n report = pet.reports.create(reporterName: params[:reporter_name],\n reporterCel: params[:reporter_cel],\n reporterPhone: params[:reporter_phone],\n reporterEmail: params[:reporter_email],\n reporterObservations: params[:reporter_observations],\n lat: params[:lat],\n lon: params[:lon],\n user_email: pet.user.email)\n if report\n render json: report, include: :pet, status: :created #with user render json: report, :include => {:pet => {:include => :user}}, status: :created\n else\n render json: {message: 'There was an error saving report, please try it again'}, status: :bad_request\n end\n else\n render json: {message: 'There was an error saving report, please try it again'}, status: :bad_request\n end\n else\n render json: {message: 'There are some parameters missing'}, status: :bad_request\n end\n end",
"def proceed_for_pdf_generation?\n\t\t((any_report_just_verified? && (self.organization.generate_partial_order_reports == YES)) || (all_reports_verified? && any_report_just_verified?) || (!self.force_pdf_generation.blank?))\n\tend",
"def create\n @individual_report = @medical_record.individual_reports.new(params[:individual_report])\n\n respond_to do |format|\n if @individual_report.save\n flash[:notice] = _('El nuevo informe individual se ha almacenado con éxito')\n format.html { \n redirect_to(medical_record_individual_report_path(\n :medical_record_id => @medical_record.id, \n :id => @individual_report.id))\n }\n format.xml { render :xml => @individual_report, :status => :created, :location => @individual_report }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @individual_report.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:report_type_code => self.report_type_code}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_report_type\n\t end\nend",
"def for_report?\r\n @name =~ /Report$/\r\n end",
"def default_report_settings!\n\n #set up default values\n self.network_perf = true\n self.network_perf = true\n self.route_perf_t = true\n self.route_tt_t = true\n self.route_perf_c = true\n self.route_tt_c = true\n self.duration = 86400\n\n #These are used for ScaterPlots and ScatterGroups in \n #report generator. Will add when we get there.\n #@simulation_batches = Array.new\n #@scenarios = Array.new\n # begin\n # params[:sim_ids].each do |s|\n # sb = SimulationBatch.find_by_id(s)\n # @simulation_batches.push(sb)\n # @scenarios.push(Scenario.find_by_id(sb.scenario_id))\n # end\n # rescue NoMethodError\n # \n # end\n\n end",
"def create\n @maintreport = Maintreport.new(params[:maintreport])\n @maintenance = Maintenance.find(params[:maintreport][:maintenance_id])\n \n respond_to do |format|\n if @maintreport.save\n if params[:plan]\n update_next_date_hour\n update_partqty\n format.html { render :action => \"show\" }\n format.xml { render :xml => @maintreport, :status => :created, :location => @maintreport }\n elsif params[:unplan]\n update_work_status\n update_partqty\n format.html { render :action => \"show_up\" }\n format.xml { render :xml => @maintreport, :status => :created, :location => @maintreport }\n end\n else\n if params[:plan]\n format.html { render :action => \"new\" }\n format.xml { render :xml => @maintreport.errors, :status => :unprocessable_entity }\n elsif params[:unplan]\n format.html { render :action => \"new_up\" }\n format.xml { render :xml => @maintreport.errors, :status => :unprocessable_entity }\n end\n end\n end\n end",
"def create\n @event = Event.find(params[:event_id])\n @report = @event.reports.new(params[:report])\n @report.attributes = params[:report]\n @report.member_id = current_member.id\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to(event_path(@event)) }\n format.json { render json: @report, status: :created, location: @report }\n else\n format.html { render action: \"new\" }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @org_reports= current_user.organization.statusreports(:order=>'created_at ASC')\n @org_last_report=@org_reports.find(:last)\n if !@org_reports.blank? && !@org_last_report.blank?\n y= @org_last_report.report_number.gsub!(\"SR-\",\"\")\n puts \"###\"\n m=y.to_i\n m = m +1\n x = (\"SR-%0.4d\" %m.to_i).to_s\n puts x\n params[:statusreport][:report_number] = x\n @statusreport = Statusreport.new(params[:statusreport])\n @statusreport.organization = current_user.organization\n else\n m = 1\n x = (\"SR-%0.4d\" %m.to_i).to_s\n puts x\n params[:statusreport][:report_number] = x\n @statusreport = Statusreport.new(params[:statusreport])\n @statusreport.organization = current_user.organization\n end\n #for changing the default date format\n @statusreport.report_date = change_date_format(params[:statusreport][:report_date]) if !(params[:statusreport][:report_date]).blank?\n respond_to do |format|\n if @statusreport.save\n format.html { redirect_to @statusreport, notice: 'Statusreport was successfully created.' }\n format.json { render json: @statusreport, status: :created, location: @statusreport }\n else\n format.html { render action: \"new\" }\n format.json { render json: @statusreport.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n\t\tuser_email = params[:user_email].presence\n\t\tuser = user_email && User.find_by_email(user_email)\n\n\t\treport = Report.new(report_params)\n\t\treport.user_id = user.id\n\n\t\tif report.save\n\t\t\trender :json => {:success => true, :report_id => report.id }\n\t\telse\n\t\t\trender :json => '{\"success\" : \"false\", \"error\" : \"problem saving report\"}'\n\t\tend\n\tend",
"def submit_department_report(to_submit_report,name,title)\n select_report_option to_submit_report\n switch_to_man_frame\n department_tab_click\n click_title\n input_department_report name\n flag = find_title_exist? title \n switch_out_frame\n flag\n end",
"def create_additional_records\n case params[:mx_type]\n when 'gmail'\n create_gmail_records\n when 'godaddy'\n create_godaddy_records\n when 'networksolutions'\n create_networksolutions_records\n else\n return\n end\n end",
"def create\n @screen = session.active_screen\n @report = Report.new(params[:report])\n @report.reference_screen_alias = []\n @report.reference_screen_outer_joins = []\n @report.reference_screens.each do |s|\n a = s.label_descr.gsub(/[^A-Z]/,'').downcase\n a << \"_#{@report.reference_screen_alias.select{|x| x =~ Regexp.new(\"(^#{a}$|^#{a}_[0-9]+$)\") }.length}\" if @report.reference_screen_alias.include?(a)\n @report.reference_screen_alias << a\n @report.reference_screen_outer_joins << {'-1' => false}\n end\n\n @report.cell_location = 'col'\n\n @report.save\n end",
"def report_line(person, report_date)\n\t\trules.each do |rule|\n\t\t\treturn rule.report_line( person, report_date ) if rule.matches?( person.weeks_since_injury( report_date ) ) \n\t\tend # each rule\n\t\t# this should not be possible - but putting this here defensively...\n\t\traise \"APPLICATION BUG - A RuleSet EXISTS THAT DOES NOT COVER ALL POSSIBLE DATES!! (Date was #{report_date.strftime('%Y/%m/%d')}, person was #{person.inspect})\"\n\tend",
"def create\n @show_sales_overlay = false\n\n\n if current_user and params[:first_name]\n\t current_user.first_name = params[:first_name]\n \n ### having periods in the first name kills the attempts to email that person, so remove periods\n current_user.first_name = current_user.first_name.gsub(\".\", \"\")\n current_user.save\n end \n\n @goal = Goal.new(params[:goal])\n\n if @goal.template_owner_is_a_template\n @goal.status = \"hold\"\n end\n\n\n\n ### remove question marks because:\n ### people keep incorrectly adding their own question marks to the end of their question\n ### which messes up phrasings in the rest of the program and never is needed\n @goal.response_question = @goal.response_question.gsub(\"?\", \"\")\n\n @goal.title = @goal.response_question\n\n if [email protected]_allowed_per_day\n @goal.pushes_allowed_per_day = 1\n end \n\n\n\n\n ################################\n #Status Creation Business Rules\n ################################\n #start (create the goal starting today stopping after goal.days_to_form_a_habit days)\n #monitor (create the goal starting today stopping after goal.days_to_form_a_habit days)\n #hold (just create the goal and a default dummy date of 1/1/1900 for start and stop)\n \n respond_to do |format|\n\n tracker_data_missing_error = false\n if @goal.tracker\n\n\n\n missing = false\n if [email protected]_question or @goal.tracker_question == \"\"\n missing = true\n logger.debug(\"sgj:goals_controller:1\")\n end\n if [email protected]_units or @goal.tracker_units == \"\"\n missing = true\n logger.debug(\"sgj:goals_controller:2\")\n end\n\n\n ### these will never be null b/c they're in forced pulldowns\n ### plus these checks were not working right\n # if [email protected]_type_starts_at_zero_daily\n # missing = true\n # logger.debug(\"sgj:goals_controller:3\")\n # end\n # if [email protected]_target_higher_value_is_better\n # missing = true\n # logger.debug(\"sgj:goals_controller:4\")\n # end\n\n # if [email protected]_standard_deviation_from_last_measurement\n # missing = true\n # logger.debug(\"sgj:goals_controller:5\")\n # end\n # if [email protected]_target_threshold_bad1\n # missing = true\n # logger.debug(\"sgj:goals_controller:6\")\n # end\n # if [email protected]_target_threshold_bad2\n # missing = true\n # logger.debug(\"sgj:goals_controller:7\")\n # end\n # if [email protected]_target_threshold_bad3\n # missing = true\n # logger.debug(\"sgj:goals_controller:8\")\n # end\n # if [email protected]_target_threshold_good1\n # missing = true\n # logger.debug(\"sgj:goals_controller:9\")\n # end\n # if [email protected]_target_threshold_good2\n # missing = true\n # logger.debug(\"sgj:goals_controller:10\")\n # end\n # if [email protected]_target_threshold_good3\n # missing = true\n # logger.debug(\"sgj:goals_controller:11\")\n # end\n\n if missing\n tracker_data_missing_error = true\n @goal.errors.add(:base, \"All 'Tracker' fields are required if the 'Tracker' is enabled.\")\n end ### end if missing\n\n end ### end if @goal.tracker\n\n\n\n if !tracker_data_missing_error and @goal.save\n\n\n pmo = false\n\n if @goal.title.include? \"fapping\"\n pmo = true\n end\n\n if @goal.title.include? \"porn\"\n pmo = true\n end\n\n if @goal.title.include? \"masturb\"\n pmo = true\n end\n if @goal.title.include? \"pmo\"\n pmo = true\n end\n if @goal.title.include? \"jerking off\"\n pmo = true\n end\n if @goal.title.include? \"jerk off\"\n pmo = true\n end\n if @goal.title.include? \"touching myself\"\n pmo = true\n end\n if @goal.title.include? \"touching yourself\"\n pmo = true\n end\n if @goal.title.include? \"XXX\"\n pmo = true\n end\n if @goal.title.include? \"xxx\"\n pmo = true\n end\n\n\n if pmo\n @goal.category = \"PMO\"\n end\n\n if @goal.template_owner_is_a_template\n flash[:notice] = 'Template was successfully created.'\n\n ### if this new template was created to be part of an existing program\n if params[:program_id]\n program = Program.find(params[:program_id])\n\n program_template = ProgramTemplate.new()\n program_template.program_id = program.id\n program_template.template_goal_id = @goal.id\n\n ### you can't do this anymore now that 'next_listing_position' depends on the track\n ### because right now we don't know which track this will be in\n #program_template.listing_position = program.get_next_listing_position\n\n program_template.save\n end\n\n else\n flash[:notice] = 'Goal was successfully created.'\n\n ### show my PMO homies\n if @goal.category == \"PMO\"\n @goal.user.feed_filter_hide_pmo = false\n end\n\n ### if this is my first ever goal, record it in user for marketing\n if [email protected]_first\n @goal.user.category_first = @goal.category\n @goal.user.goal_first = @goal.title\n end\n if [email protected]_goals\n @goal.user.categories_goals = \"\"\n end\n\n if [email protected]\n @goal.category = \"Other\"\n end\n\n if [email protected]\n @goal.title = \"none\"\n end\n @goal.user.categories_goals += @goal.category + \"_:_\" + @goal.title + \"::\"\n\n\n if params[:sign_up_for_lyphted] and params[:sign_up_for_lyphted] == \"1\"\n @goal.user.lyphted_subscribe = @goal.user.dtoday\n\n\n # ####https://labs.aweber.com/snippets/subscribers\n # oauth = AWeber::OAuth.new('Ak1WLosRSScHQL6Z3X3WfV3F', 'utsxWW2PuCrWWGdUpGy1nLlFkXr1Hr2pRL7TomdR')\n\n # auth_url = oauth.request_token.authorize_url\n # logger.info(\"sgj:aweber: \" + auth_url)\n\n ### got all of the accesstoken info by following the account verifications instructions\n ### while using irb (require 'rubygems' and require 'aweber')\n ### based on: https://github.com/aweber/AWeber-API-Ruby-Library\n\n #<OAuth::AccessToken:0xb76fea70 @params={}, @consumer=#<OAuth::Consumer:0xb72e00d8 @http_method=:post, @secret=\"utsxWW2PuCrWWGdUpGy1nLlFkXr1Hr2pRL7TomdR\", @options={:access_token_path=>\"/1.0/oauth/access_token\", :oauth_version=>\"1.0\", :scheme=>:query_string, :signature_method=>\"HMAC-SHA1\", :proxy=>nil, :http_method=>:post, :request_token_path=>\"/1.0/oauth/request_token\", :authorize_path=>\"/1.0/oauth/authorize\", :site=>\"https://auth.aweber.com\"}, @key=\"Ak1WLosRSScHQL6Z3X3WfV3F\", @http=#<Net::HTTP auth.aweber.com:443 open=false>>, @secret=\"DmCMwlQWL4a2NHCrCTGaAu5u5EwaH06P5e4MLcYp\", @token=\"AgeEEz2LxKSd8zNpr602Bfyd\"> \n \n # App Name; HabitForge\n # App ID: 8765b416 \n # Consumer Key: Ak1WLosRSScHQL6Z3X3WfV3F\n # Consumer Secret: utsxWW2PuCrWWGdUpGy1nLlFkXr1Hr2pRL7TomdR\n\n ####https://labs.aweber.com/snippets/subscribers\n oauth = AWeber::OAuth.new('Ak1WLosRSScHQL6Z3X3WfV3F', 'utsxWW2PuCrWWGdUpGy1nLlFkXr1Hr2pRL7TomdR')\n oauth.authorize_with_access('AgeEEz2LxKSd8zNpr602Bfyd', 'DmCMwlQWL4a2NHCrCTGaAu5u5EwaH06P5e4MLcYp')\n aweber = AWeber::Base.new(oauth)\n new_subscriber = {}\n new_subscriber[\"email\"] = @goal.user.email\n new_subscriber[\"name\"] = @goal.user.name\n\n #### again, this one is custom and was not able to figure out how to update it\n # new_subscriber[\"YOB\"] = \"1976\"\n\n\n ##### was not able to get the updating of these custom fields to work after several different method tries\n ##### but that's OK we're now just using the built-in \"misc_notes\" \n # new_subscriber[\"custom_fields\"][\"first_category\"] = \"exercise\"\n # new_subscriber[\"custom_fields\"][\"first_goal\"] = \"run for 20 minutes\"\n # new_subscriber[\"custom_fields\"][\"categories_goals\"] = \"exercise:.:run for 20 minutes;\"\n\n begin\n new_subscriber[\"misc_notes\"] = \"first_category=\" + @goal.user.category_first\n rescue\n logger.error(\"sgj:could not add subscriber misc_note to aweber\")\n end\n\n # new_subscriber[\"misc_notes\"] = \"first_category=\" + @goal.user.category_first + \";first_goal='\" + @goal.user.goal_first + \"'\"\n\n ## The Lyphted list_id is = 3702705\n ## The Lyphted list_name is = awlist3702705\n list = aweber.account.lists.find_by_id(3702705)\n\n begin\n list.subscribers.create(new_subscriber)\n rescue\n logger.error(\"sgj:could not add subscriber to aweber (perhaps they have a role-based email address like admin@something\")\n ###https://help.aweber.com/entries/97662366\n end\n\n # aweber.account.lists.each do |list|\n # logger.info(\"sgj:aweber:\" + list.name)\n # end\n # logger.info(\"sgj:aweber:\" + aweber.account.lists.to_s)\n # logger.info(\"sgj:aweber:\" + aweber.account.lists[0].name.to_s)\n #aweber.account.lists.find_by_id(3702705).subscribers.create(new_subscriber)\n\n\n end\n\n\n\n ### update last activity date\n @goal.user.last_activity_date = @goal.user.dtoday\n @goal.user.deletion_warning = nil\n @goal.user.save\n \n ###############################################\n ###### START IF SFM_VIRGIN\n if session[:sfm_virgin] and session[:sfm_virgin] == true\n session[:sfm_virgin] = false\n @show_sales_overlay = true\n\n @user = current_user\n\n ### existing_user will be true if coming from an infusionsoft email invite\n ### in that case, do not send them another welcome email\n if !session[:existing_user]\n #### now that we have their first name, we can send the email \n the_subject = \"Confirm your HabitForge Subscription\"\n begin\n #if Rails.env.production?\n logger.error(\"sgj:goals_controller:about to send user confirmation to user \" + @user.email)\n Notifier.deliver_user_confirm(@user, the_subject) # sends the email\n #end\n rescue\n logger.error(\"sgj:email confirmation for user creation did not send\")\n end\n end\n\n\n # begin\n # #####################################################\n # #####################################################\n # #### UPDATE THE CONTACT FOR THEM IN INFUSIONSOFT ######\n # ### SANDBOX GROUP/TAG IDS\n # #112: hf new signup funnel v2 free no goal yet\n # #120: hf new signup funnel v2 free created goal\n # #\n # ### PRODUCTION GROUP/TAG IDS\n # #400: hf new signup funnel v2 free no goal yet\n # #398: hf new signup funnel v2 free created goal\n # if Rails.env.production?\n # Infusionsoft.contact_update(session[:infusionsoft_contact_id].to_i, {:FirstName => current_user.first_name, :LastName => current_user.last_name})\n # Infusionsoft.contact_add_to_group(session[:infusionsoft_contact_id].to_i, 398)\n # Infusionsoft.contact_remove_from_group(session[:infusionsoft_contact_id].to_i, 400)\n # end\n # #### END INFUSIONSOFT CONTACT ####\n # #####################################################\n # #####################################################\n # rescue\n # logger.error(\"sgj:error updating contact in infusionsoft\")\n # end\n end ### END IF SFM_VIRGIN\n ###### END IF SFM_VIRGIN\n ###############################################\n\n\n current_user.goal_temp = \"\"\n current_user.save\n end ### end if goal != a template\n\n \n if @goal.usersendhour == nil\n\t @goal.usersendhour = 20 ### 8pm\n end\n\n Time.zone = @goal.user.time_zone\n utcoffset = Time.zone.formatted_offset(false)\n offset_seconds = Time.zone.now.gmt_offset \n send_time = Time.utc(2000, \"jan\", 1, @goal.usersendhour, 0, 0) #2000-01-01 01:00:00 UTC\n central_time_offset = 21600 #add this in since we're doing UTC\n server_time = send_time - offset_seconds - central_time_offset\n puts \"User lives in #{@goal.user.time_zone} timezone, UTC offset of #{utcoffset} (#{offset_seconds} seconds).\" #Save this value in each goal, and use that to do checkpoint searches w/ cronjob\n puts \"For them to get an email at #{send_time.strftime('%k')} their time, the server would have to send it at #{server_time.strftime('%k')} Central time\"\n @goal.serversendhour = server_time.strftime('%k')\n @goal.gmtoffset = utcoffset \n #############\n \n \n\n if @goal.daym == nil \n @goal.daym = true\n end\n if @goal.dayt == nil \n @goal.dayt = true\n end\n if @goal.dayw == nil \n @goal.dayw = true\n end\n if @goal.dayr == nil \n @goal.dayr = true\n end\n if @goal.dayf == nil \n @goal.dayf = true\n end\n if @goal.days == nil \n @goal.days = true\n end\n if @goal.dayn == nil \n @goal.dayn = true\n end\n\n if [email protected]_owner_is_a_template\n if @goal.status != \"hold\" and @goal.daym and @goal.dayt and @goal.dayw and @goal.dayr and @goal.dayf and @goal.days and @goal.dayn and (@goal.goal_days_per_week == nil or @goal.goal_days_per_week == 7)\n @goal.status = \"start\"\n else\n @goal.status = \"monitor\"\n end\n end\n\n\n #########\n ### Once the goal is saved, set the start and stop dates\n\n \n dnow = get_dnow\n\n if @goal.status == \"hold\"\n @goal.start = Date.new(1900, 1, 1)\n @goal.stop = @goal.start \n end\n @goal.established_on = Date.new(1900, 1, 1)\n if (@goal.status == \"start\" or @goal.status == \"monitor\")\n start_day_offset = 1\n if params[:delay_start_for_this_many_days] \n start_day_offset = params[:delay_start_for_this_many_days].to_i\n end\n ### Set the standard dates\n @goal.start = dnow + start_day_offset\n @goal.stop = @goal.start + @goal.days_to_form_a_habit\n \t @goal.first_start_date = @goal.start \n @goal.save\n end\n\n ### save date changes\n @goal.save\n\n\n ####################################################################\n ####################################################################\n ##### ACCEPT AN INVITE\n ####################################################################\n ### if we are responding to an invitation to join a team\n if params[:invitation_id]\n begin\n attempt_to_join_team = false\n\n invite = Invite.find(params[:invitation_id].to_i)\n if invite and invite.purpose_join_team_id\n\n team = Team.find(invite.purpose_join_team_id)\n if team\n\n ### what kind of team?\n if team.goal_template_parent_id\n\n ### template based team\n if @goal.template_user_parent_goal_id and (@goal.template_user_parent_goal_id == team.goal_template_parent_id)\n attempt_to_join_team = true\n end\n\n else\n\n ### category-based team\n if team.category_name and @goal.category and (team.category_name == @goal.category)\n attempt_to_join_team = true\n end\n\n end\n\n if attempt_to_join_team\n if @goal.join_goal_to_a_team(team.id)\n logger.info(\"sgj:goals_controller.rb:success adding goal to team when responding to invitation\")\n\n\n ### we actually want to delete the invite, not save it\n ### that way if the new team member removes their goal and then\n ### changes their mind later, we can send them another invite\n #invite.accepted_on = current_user.dtoday\n #invite.save\n invite.destroy\n\n\n #### SEND INVITE ACCEPTANCE TO OWNER\n begin\n if Notifier.deliver_to_team_owner_invite_accepted(@goal, team.owner) # sends the email \n logger.info(\"sgj:goals_controller.rb:create:SUCCESS SENDING INVITE ACCEPTANCE EMAIL\") \n else\n logger.error(\"sgj:goals_controller.rb:create:FAILURE SENDING INVITE ACCEPTANCE EMAIL:goal_id = \" + @goal.id.to_s)\n end\n rescue\n logger.error(\"sgj:goals_controller.rb:create:(rescue)FAILURE SENDING INVITE ACCEPTANCE EMAIL:goal_id = \" + @goal.id.to_s)\n end\n #### END SEND INVITE ACCEPTANCE TO OWNER\n\n\n else\n logger.error(\"sgj:goals_controller.rb:failed to add goal to team when responding to invitation\")\n end\n else\n logger.error(\"sgj:goals_controller.rb:the team invite was a mis-match for either this goal category or this goal parent template .. not trying to join team\") \n end\n\n end ### if team\n\n end ### if invite and invite.purpose_join_team_id\n\n rescue\n logger.error(\"sgj:goals_controller.rb:error trying to add goal to team when responding to invitation\")\n end\n\n end ### if session[:accepting_invitation_id]\n ####################################################################\n ##### END ACCEPT AN INVITE\n ####################################################################\n ####################################################################\n\n\n\n ####################################################################\n ####################################################################\n ##### PROGRAM ENROLLMENT\n ####################################################################\n\n ### create a program enrollment record if a program is involved\n ### goal and program are linked via goal.goal_added_through_template_from_program_id\n if @goal.program\n\n ### check to see if an enrollment exists... if not, create one\n enrollment = ProgramEnrollment.find(:first, :conditions => \"program_id = '#{@goal.program.id}' and user_id = '#{@goal.user.id}'\")\n if !enrollment\n enrollment = ProgramEnrollment.new()\n # t.integer \"program_id\"\n # t.integer \"user_id\"\n # t.boolean \"active\"\n # t.boolean \"ongoing\"\n # t.integer \"program_session_id\"\n # t.date \"personal_start_date\"\n # t.date \"personal_end_date\"\n enrollment.program_id = @goal.program.id\n enrollment.user_id = @goal.user.id\n enrollment.active = true\n enrollment.ongoing = true\n\n enrollment.save\n\n end ### end if !enrollment\n end ### end if @goal.program\n\n ####################################################################\n ##### END PROGRAM ENROLLMENT\n ####################################################################\n ####################################################################\n\n\n\n ### we don't need/want these anymore\n ### destroy them so that they don't mess up a future new goal\n session[:goal_added_through_template_from_program_id] = nil\n session[:template_user_parent_goal_id] = nil\n session[:goal_template_text] = nil\n session[:category] = nil\n session[:accepting_invitation_id] = nil\n\n \n if @goal.status == \"hold\"\n ### don't send an email if it's on hold\n else\n begin \n if session[:sponsor] == \"clearworth\"\n #Notifier.deliver_goal_creation_notification_clearworth(@goal) # sends the email\n elsif session[:sponsor] == \"forittobe\"\n #Notifier.deliver_goal_creation_notification_forittobe(@goal) # sends the email\n elsif session[:sponsor] == \"marriagereminders\"\n #Notifier.deliver_goal_creation_notification_marriagereminders(@goal) # sends the email\n else\n #Notifier.deliver_goal_creation_notification(@goal) # sends the email\n end\n rescue\n puts \"Error while sending goal notification email from Goal.create action.\"\n end\n end\n\n\n\n ### if this new template was created to be part of an existing program\n if params[:program_id] or params[:return_to_program_view]\n if params[:return_to_program_view]\n format.html {redirect_to(\"/programs/#{params[:return_to_program_view]}/view\")}\n else\n\n ### if the program is a \"structured program\" you're going to want to go directly to edit mode\n p = Program.find(params[:program_id].to_i)\n if p and p.structured\n\n pt = ProgramTemplate.find(:first, :conditions => \"program_id = '#{p.id}' and template_goal_id = '#{@goal.id}'\")\n format.html {redirect_to(\"/program_templates/#{pt.id.to_s}/edit\")}\n\n else\n format.html {redirect_to(\"/programs/#{params[:program_id]}#action_items\")}\n end\n\n\n end\n\n else\n\n begin \n ### attempt to add to encourage_items\n\n\n # when a goal is created,\n # if username != unknown,\n # if the goal is public,\n # then enter it into encourage_items\n\n # --- encourage_item ---\n # encourage_type_new_checkpoint_bool (index)\n # encourage_type_new_goal_bool (index)\n # checkpoint_id\n # checkpoint_status\n # checkpoint_date (index)\n # checkpoint_updated_at_datetime\n # goal_id (index)\n # goal_name\n # goal_category\n # goal_created_at_datetime\n # goal_publish\n # goal_first_start_date (index)\n # goal_daysstraight\n # goal_days_into_it\n # goal_success_rate_percentage\n # user_id (index)\n # user_name\n # user_email\n\n logger.debug \"sgj:goals_controller.rb:consider adding to encourage_items\"\n if @goal.user.first_name != \"unknown\"\n if @goal.is_public\n logger.debug \"sgj:goals_controller.rb:candidate for encourage_items\"\n\n encourage_item = EncourageItem.new\n logger.debug \"sgj:goals_controller.rb:new encourage_items instantiated\"\n\n encourage_item.encourage_type_new_checkpoint_bool = false\n encourage_item.encourage_type_new_goal_bool = true\n\n #encourage_item.checkpoint_id = nil\n encourage_item.checkpoint_id = @goal.id ### a workaround to the validation that checkpoint_id is unique\n\n encourage_item.checkpoint_status = nil\n encourage_item.checkpoint_date = nil\n encourage_item.checkpoint_updated_at_datetime = nil\n encourage_item.goal_id = @goal.id\n encourage_item.goal_name = @goal.title\n encourage_item.goal_category = @goal.category\n encourage_item.goal_created_at_datetime = @goal.created_at\n encourage_item.goal_publish = @goal.publish\n encourage_item.goal_first_start_date = @goal.first_start_date\n encourage_item.goal_daysstraight = @goal.daysstraight\n encourage_item.goal_days_into_it = @goal.days_into_it\n encourage_item.goal_success_rate_percentage = @goal.success_rate_percentage\n encourage_item.user_id = @goal.user.id\n encourage_item.user_name = @goal.user.first_name\n encourage_item.user_email = @goal.user.email\n\n logger.debug \"sgj:goals_controller.rb:about to save encourage_items\"\n\n if encourage_item.save\n logger.info(\"sgj:goals_controller.rb:success saving encourage_item\")\n else\n logger.error(\"sgj:goals_controller.rb:error saving encourage_item\")\n end\n logger.debug \"sgj:goals_controller.rb:new encourage_item.id = \" + encourage_item.id.to_s\n\n end\n end\n\n rescue\n logger.error \"sgj:error adding to encourage_items\"\n end\n\n\n if @show_sales_overlay\n ### format.html { render :action => \"edit\" }\n\n if Rails.env.production?\n\n ### show the sales page and eventually kick back to optimize when they cancel\n #format.html {redirect_to(\"https://www.securepublications.com/habit-gse3.php?ref=#{current_user.id.to_s}&email=#{current_user.email}\")}\n\n ### do not show the sales page first, just kick to optimize\n format.html {redirect_to(\"/goals?optimize_my_first_goal=1&email=#{current_user.email}&single_login=1\")}\n\n else\n session[:dev_mode_just_returned_from_sales_page] = true\n format.html {redirect_to(\"/goals?optimize_my_first_goal=1&email=#{current_user.email}&single_login=1\")}\n end\n\n format.xml { render :xml => @goals }\n else\n\n\n ##### SUCCESSFULLY SAVED A NEW GOAL ... REDIRECT TO ???\n\n # if session[:sfm_virgin]\n # format.html { redirect_to(\"/goals/#{@goal.id}/edit?just_created_new_habit=1&just_created_first_habit=1\")}\n # else \n # format.html { redirect_to(\"/goals/#{@goal.id}/edit?just_created_new_habit=1\")}\n # end\n\n\n # if !current_user.is_habitforge_supporting_member\n # format.html {redirect_to(\"/goals?too_many_active_habits=1&just_created_new_habit=1\")} \n # else\n # format.html { render :action => \"index\" } # index.html.erb\n # end\n \n # if !current_user.is_habitforge_supporting_member\n # format.html { redirect_to(\"https://habitforge.com/widget/upgrade\")}\n # else\n format.html { redirect_to(\"/goals/#{@goal.id}/edit?just_created_new_habit=1\")}\n # end\n\n\n\n format.xml { render :xml => @goals }\n end\n\n end \n\n\n\n \n\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @goal.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_quiz_report(course_id,quiz_id,quiz_report__report_type__,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n :quiz_report__report_type__,\n :quiz_report__includes_all_versions__,\n :include,\n \n ]\n\n # verify existence of params\n raise \"course_id is required\" if course_id.nil?\n raise \"quiz_id is required\" if quiz_id.nil?\n raise \"quiz_report__report_type__ is required\" if quiz_report__report_type__.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :course_id => course_id,\n :quiz_id => quiz_id,\n :quiz_report__report_type__ => quiz_report__report_type__\n )\n\n # resource path\n path = path_replace(\"/v1/courses/{course_id}/quizzes/{quiz_id}/reports\",\n :course_id => course_id,\n :quiz_id => quiz_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:post, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:post, path, query_params, form_params, headers)\n page_params_store(:post, path)\n QuizReport.new(response)\n end",
"def add_has_violation_field\n logger.info \"Adding #{name}._has_violation audit field...\"\n db.query(\"ALTER TABLE #{audit} ADD `_has_violation` TINYINT NOT NULL DEFAULT 0\") \n end",
"def create\n @report = Report.new(report_params)\n @report.user = current_user\n @report.reportable = @reportable\n respond_to do |format|\n if @report.save\n format.html {redirect_to @reportable, notice: 'Report was successfully created.'}\n else\n format.html {redirect_to root_path, error: 'Fail to create report'}\n end\n end\n end",
"def write_report\n\n end",
"def report_only\n assert_privileges(\"report_only\")\n\n # Render error message if report doesn't exist\n if params[:rr_id].nil? && @sb.fetch_path(:pages, :rr_id).nil?\n add_flash(_(\"This report isn't generated yet. It cannot be rendered.\"), :error)\n render :partial => \"layouts/flash_msg\"\n return\n end\n # Dashboard widget will send in report result id else, find report result in the sandbox\n search_id = params[:rr_id] ? params[:rr_id].to_i : @sb[:pages][:rr_id]\n rr = MiqReportResult.for_user(current_user).find(search_id)\n\n session[:report_result_id] = rr.id # Save report result id for chart rendering\n session[:rpt_task_id] = nil # Clear out report task id, using a saved report\n\n @report = rr.report\n @report_result_id = rr.id # Passed in app/views/layouts/_report_html to the ReportDataTable\n @report_title = rr.friendly_title\n @html = report_build_html_table(rr.report_results, rr.html_rows.join)\n @ght_type = params[:type] || (@report.graph.blank? ? 'tabular' : 'hybrid')\n @render_chart = (@ght_type == 'hybrid')\n # Indicate stand alone report for views\n render 'shared/show_report', :layout => 'report_only'\n end",
"def index\n \n unless params[:promotionize]\n @report_fields = @report_setup.report_fields.sort{|x, y| x.display_name <=> y.display_name}\n else\n fields = @report_setup.fields\n\n fields = @report_setup.add_one_to_many_fields(fields, @promotion)\n fields = @report_setup.add_eval_questions(fields, @promotion)\n fields = @report_setup.add_other_promotion_specific_fields(fields, @promotion)\n # see lib/behaviors_for_reports.rb\n fields = BehaviorsForReports.add_behavior_fields(fields,@promotion)\n\n # @report_fields = @report_fields.values\n @report_fields = []\n fields.each do |id, field|\n if field[:visible]\n field[:id] = id\n @report_fields << field\n end\n end\n\n end\n\n return HESResponder({:data => @report_fields.as_json, :meta => nil})\n end",
"def company_must_have_one_hr\n if self.designation ==\"hr\"\n \tif Employee.where(:company_id=>self.company_id,:designation=>\"hr\").count ==1\n \t\tthrow :abort\n \telse\n \t\treturn true\n \tend\n end\n end",
"def report_params\n params.require(:report).permit(:consumedCalories, :burnedCalories, :diference, :diference_value, :creation_date)\n end",
"def create_new_report!\n File.write(report_filename, report_title + report_body)\n end",
"def create\n @pass_set = PassSet.new(params[:pass_set])\n @time_period = TimePeriod.new(params[:time_period])\n @pass_set.reservation_time_periods = false\n @pass_set.selling_passes = true\n if @pass_set.reservation_time_periods == true && @pass_set.selling_passes == false\n @pass_set.total_released_passes = 0\n @available_times = @pass_set.time_periods.first\n time_columns = @available_times.attributes.values\n # Remove fields that aren't times\n 3.times do\n time_columns.delete_at(time_columns.length-1)\n end\n time_columns.delete_at(0)\n logger.error \"#{time_columns}\"\n\t for x in 0..time_columns.length-1\n\t if x%2 == 1\n\t if time_columns[x] != nil\n\t @pass_set.total_released_passes += time_columns[x]\n\t end\n\t end\n\t end\n\t @pass_set.sold_passes = 0\n \t @pass_set.unsold_passes = @pass_set.total_released_passes\n\t else\n\t @pass_set.sold_passes = 0\n \t @pass_set.unsold_passes = @pass_set.total_released_passes\n\t end\n @bar = Bar.find(params[:bar_id])\n @pass_set.bar = @bar\n @time_period.pass_set = @pass_set\n\t @existing_set = @bar.pass_sets.where(\"date = ?\", @pass_set.date).first\n respond_to do |format|\n\t\tif @pass_set.date < Date.today\n\t\tflash[:notice] = 'Error: You are trying to create a pass for a date that has already passed!'\n format.html { render action: \"new\" }\n format.json { render json: @pass_set.errors, status: :unprocessable_entity }\n\telsif @existing_set\n\t\t\t\tflash[:notice] = 'Error: Please use edit to change existing passes'\n\t\t\t\tformat.html { redirect_to edit_user_bar_pass_set_path(@bar.user, @bar, @existing_set) }\n\t\t\t\tformat.json { render json: @pass_set.errors, status: :unprocessable_entity }\n elsif @pass_set.save\n format.html { redirect_to [@bar.user, @bar], notice: 'Pass set was successfully created.' }\n format.json { render json: @pass_set, status: :created, location: @pass_set }\n else\n format.html { render action: \"new\" }\n format.json { render json: @pass_set.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @report = current_user.reports.new(report_params)\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to @report, notice: 'Report was successfully created.' }\n format.json { render json: { message: 'Report was successfully created.'}, status: :created }\n else\n format.html { render :new }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def build_report(report)\n current_date = 'today'\n report_settings_tab.click unless report_settings_tab[:class]== 'selected'\n wait_until{report_name_tb.visible?}\n case report\n when Bus::DataObj::BillingSummaryReport\n report_name_tb.type_text(report.name)\n frequency_select.select(report.frequency)\n set_report_start_date(report.start_date)\n is_active_cb.uncheck unless report.is_active\n when Bus::DataObj::BillingDetailReport\n report_name_tb.type_text(report.name)\n frequency_select.select(report.frequency)\n set_report_start_date(report.start_date)\n is_active_cb.uncheck unless report.is_active\n else\n report_name_tb.type_text(report.name)\n if report.type == 'Resources Added'\n # get current date from range end checkbox for the Date Applied in the report\n str_arr = range_end_checkbox[:onclick].scan(/'\\d+'/)\n current_date = 'yesterday' unless str_arr[2].match(/\\d+/)[0] == Time.now.day.to_s\n range_start_checkbox.check\n range_end_checkbox.check\n else\n frequency_select.select(report.frequency)\n set_report_start_date(report.start_date) unless report.start_date.nil?\n is_active_cb.uncheck unless report.is_active\n end\n\n if report.type == \"Machine Over Quota\"\n quota_percentage_input.type_text(report.threshold) unless report.threshold.nil?\n end\n end\n set_email_recipients(report.recipients) unless report.recipients.nil?\n save_btn.click\n current_date\n end",
"def report(report_class, cron_def = nil)\n @reports << report_class.new(cron_def)\n end",
"def report\n @report || @schedule\n end",
"def generate_new_hire_report\n lines = []\n\n column_titles = [\n 'Social Security Number',\n 'Name - Last',\n 'Name - First',\n 'Gender',\n 'Date of Birth',\n 'Date of Hire - Original',\n 'Date of Rehire',\n 'Termination Date',\n 'Address - Street 1',\n 'Address - Street 2',\n 'Address - City',\n 'Address - State',\n 'Address - Postal Code',\n 'Division ID',\n 'Pre-tax Deferral',\n 'Roth Amount',\n 'Matching Amount',\n 'Matching Safe Harbor',\n 'Profit Sharing',\n 'Non Elective Safe Harbor',\n 'Plan Compensation',\n 'Current Hours',\n 'Marital Status',\n 'Loan Payments',\n 'Internet Address - Other',\n 'PARTICIPANTID'\n ]\n lines.push(column_titles.join(','))\n\n plan_symlink = @config.plan.symlink\n plan = Plan.where('symlink = ?', plan_symlink).first\n @new_employees.each do |employee|\n date_of_birth = employee[RecordField::DATE_BIRTH]\n if date_of_birth.present? && date_of_birth.is_a?(Date)\n date_of_birth = DateUtils.to_string(date_of_birth)\n else\n date_of_birth = ''.to_date\n end\n participant = participant_mapping(plan.id, employee, date_of_birth)\n next if participant.nil?\n\n calculate_assumed_hour = Plan.calculate_assumed_hour(employee, plan.id)\n hours = plan.assumed_hours_setting ? calculate_assumed_hour : employee[RecordField::HOURS_REGULAR]\n cells = [\n (employee[RecordField::SSN] || '').gsub(/[^\\d]/, ''),\n employee[RecordField::NAME_LAST],\n employee[RecordField::NAME_FIRST],\n employee[RecordField::GENDER] || '',\n employee[RecordField::DATE_BIRTH] || ' ',\n employee[RecordField::DATE_HIRE] || ' ',\n employee[RecordField::DATE_REHIRE] || ' ',\n employee[RecordField::DATE_TERMINATION] || ' ',\n employee[RecordField::ADDRESS_STREET_1],\n employee[RecordField::ADDRESS_STREET_2],\n employee[RecordField::ADDRESS_CITY],\n employee[RecordField::ADDRESS_STATE],\n employee[RecordField::ADDRESS_POSTAL_CODE],\n employee[RecordField::DIVISION_ID],\n employee[RecordField::AMOUNT_CONTRIBUTION_TRADITIONAL],\n employee[RecordField::AMOUNT_CONTRIBUTION_ROTH],\n employee[RecordField::AMOUNT_MATCH],\n employee[RecordField::AMOUNT_MATCH_SAFE_HARBOR],\n employee[RecordField::AMOUNT_PROFIT_SHARING],\n employee[RecordField::AMOUNT_NON_ELECTIVE_SAFE_HARBOR],\n employee[RecordField::AMOUNT_PAY_GROSS],\n hours,\n employee[RecordField::MARITAL_STATUS],\n employee[RecordField::AMOUNT_LOAN_PAYMENTS],\n employee[RecordField::EMAIL] || ' ',\n participant.try(:id)\n ]\n lines.push(cells.join(','))\n end\n\n return lines.join(\"\\n\")\n end",
"def has_abnormal_reports?\n\t\tself.reports.select{|c|\n\t\t\tc.has_abnormal_tests?\n\t\t}.size > 0\n\tend"
] | [
"0.6323783",
"0.5899068",
"0.58449686",
"0.5810592",
"0.57838315",
"0.57838315",
"0.57222235",
"0.5713861",
"0.5705615",
"0.56574976",
"0.5628815",
"0.5622186",
"0.55423266",
"0.5486699",
"0.5476326",
"0.54718643",
"0.54245496",
"0.54056215",
"0.5400118",
"0.5382249",
"0.5373681",
"0.5325543",
"0.52968836",
"0.52821565",
"0.52645427",
"0.5253761",
"0.5236584",
"0.5234757",
"0.5225191",
"0.5224629",
"0.5220532",
"0.52159303",
"0.5214081",
"0.52079827",
"0.5198699",
"0.5194455",
"0.5193272",
"0.5185808",
"0.5179088",
"0.51661974",
"0.51661974",
"0.5163733",
"0.5155727",
"0.5152837",
"0.5149711",
"0.51490843",
"0.51452184",
"0.5134238",
"0.51300454",
"0.51287806",
"0.51272726",
"0.51264334",
"0.5125542",
"0.5123636",
"0.5117173",
"0.5117108",
"0.51162785",
"0.50732523",
"0.5072262",
"0.5072191",
"0.50561917",
"0.5040709",
"0.5029621",
"0.5028681",
"0.5015088",
"0.5000794",
"0.49823633",
"0.49818105",
"0.49701345",
"0.49691415",
"0.49634865",
"0.49567568",
"0.4951933",
"0.4950906",
"0.49472296",
"0.4942293",
"0.4936633",
"0.49333122",
"0.49280632",
"0.492341",
"0.49217725",
"0.49213785",
"0.4920911",
"0.4920476",
"0.49096456",
"0.49089602",
"0.4901226",
"0.48983768",
"0.487958",
"0.48791704",
"0.4878016",
"0.48778498",
"0.48764914",
"0.48758587",
"0.4875667",
"0.48736495",
"0.48730698",
"0.48730686",
"0.48711193",
"0.48685268"
] | 0.5089973 | 57 |
Gets a report of a bookmark that has ID = 1 and a bookmark that has ID = 0 Should return true for all the tests made for ID = 1 and ID = 0, because there does not exist a bookmark with ID = 0 | def test_get_by_bookmark_id
validId = BookmarkReport.getById(1)
assert_equal 1, validId.userId
assert_equal 'something', validId.issue
assert_equal 'report', validId.description
invalidId = BookmarkReport.getById(0)
assert_nil invalidId
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_all_bookmark_reports_details\n \n reports = BookmarkReport.getAll()\n\n report = reports[0]\n \n assert_equal 1, report.bookmarkId\n assert_equal 1, report.userId\n assert_equal 'something', report.issue\n assert_equal 'report', report.description\n\n end",
"def test_get_existing_bookmark\n test_url = 'http://www.ml-class.com/'\n num0 = count_bookmarks(@bs.user_id)\n tot0 = count_bookmarks\n assert(get_bookmark(@bs.user_id, test_url) === @bs.add_or_get_bookmark(test_url))\n assert_equal(num0, count_bookmarks(@bs.user_id))\n assert_equal(tot0, count_bookmarks)\n end",
"def test_get_all_bookmark_reports\n\n reports = BookmarkReport.getAll()\n\n assert_equal 4, reports.length\n \n end",
"def test_get_by_bookmark_id\n\n resultCreated = Tag.newTag(\"Payroll\", 1);\n\n assert_equal true, resultCreated\n\n results = Tag.getByBookmarkId(1);\n\n result = results[0]\n\n assert_equal \"Payroll\", result.tag\n\n assert_equal 1, results.length\n\n end",
"def test_get_by_bookmark_id\n\n comments = Comment.getByBookmarkId(1)\n \n comment = comments[0]\n\n assert_equal 1, comment.commentId\n assert_equal \"This is a comment\", comment.content\n assert_equal 1, comment.bookmarkId\n assert_equal 1, comment.userId\n\n end",
"def test_get_bookmark\n exp_bm = get_bookmark(@bs.user_id, 'http://www.ml-class.com/')\n act_bm = @bs.get_bookmark(4)\n assert(exp_bm === act_bm)\n end",
"def has_bookmarked?(type, id)\n id.in? self.bookmarks.where({ :bookmarkable_type => type }).pluck(:bookmarkable_id)\n end",
"def is_child_bookmark bookmark_index\n begin\n \n if @filename == ''\n raise 'filename not specified'\n end\n \n if bookmark_index == ''\n raise 'bookmark index not specified'\n end\n \n \n str_uri = $product_uri + '/pdf/' + @filename + '/bookmarks/' + bookmark_index.to_s\n str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) \n response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})\n \n stream_hash = JSON.parse(response_stream)\n \n return stream_hash['Bookmark']\n \n \n rescue Exception=>e\n print e\n end\n end",
"def bookmarked?(user_id)\n !Bookmark.where(story_id: self.id, user_id: user_id).empty?\n end",
"def test_add_pvt_bookmark\n test_url = 'http://www.avilayparekh.com/'\n num_lns0 = count_links\n num_bms0 = count_bookmarks\n act_bm = @bs.add_or_get_bookmark(test_url)\n exp_bm = get_bookmark(@bs.user_id, test_url)\n assert(exp_bm === act_bm)\n assert_equal(num_lns0 + 1, count_links)\n assert_equal(num_bms0 + 1, count_bookmarks)\n assert_empty(get_link_title(test_url))\n assert_empty(exp_bm.name)\n delete_link(test_url)\n end",
"def is_bookmarked user\n Bookmark.find_by(user_id: user_id, post_id: id)\n end",
"def bookmarks\n xpath './bookmark'\n end",
"def document_is_bookmarked?(document_id)\n bookmarked_document_ids.include? document_id\n end",
"def test_add_bookmark\n test_url = 'http://www.gridgain.com/'\n num_lns0 = count_links\n num_bms0 = count_bookmarks\n act_bm = @bs.add_or_get_bookmark(test_url)\n exp_bm = get_bookmark(@bs.user_id, test_url)\n assert(exp_bm === act_bm)\n assert_equal(num_bms0 + 1, count_bookmarks)\n assert_equal(num_lns0, count_links)\n assert(get_link_title(test_url), exp_bm.name)\n delete_bookmark(@bs.user_id, test_url)\n end",
"def test_new_report\n\n testOne = BookmarkReport.newReport(2, 1, \"issue\", \"description\");\n\n assert_equal true, testOne\n\n testTwo = BookmarkReport.newReport(nil, 1, \" \", \"test\");\n\n assert_equal false, testTwo\n\n end",
"def test_get_bookmarks\n exp_num_bms = count_bookmarks(1)\n act_num_bms = @bs.get_bookmarks.count\n assert_equal(exp_num_bms, act_num_bms) \n end",
"def bookmark?(key)\n\t\t\t@bookmarks[key.to_sym]\n\t\tend",
"def test_add_new_bookmark\n test_url = 'http://gigaom.com'\n title = 'GigaOM'\n num_lns0 = count_links\n tot_bms0 = count_bookmarks\n num_bms0 = count_bookmarks(@bs.user_id)\n act_bm = @bs.add_or_get_bookmark(test_url)\n exp_bm = get_bookmark(@bs.user_id, test_url)\n assert(exp_bm === act_bm)\n assert_equal(num_lns0 + 1, count_links)\n assert_equal(tot_bms0 + 1, count_bookmarks)\n assert_equal(num_bms0 + 1, count_bookmarks(@bs.user_id))\n assert_equal(get_link_title(test_url), exp_bm.name)\n delete_link(test_url)\n end",
"def test_get_nonexisting_bookmark\n bm = @bs.get_bookmark(15000)\n assert(bm.errors.count > 0)\n end",
"def bookmarked?(an_user_id, select=nil)\n return false if self.new_record?\n return (self.send(select).to_i != 0) if !select.nil?\n Bookmark.where(:user_id => an_user_id, :bookmarkable_type => 'MediaElement', :bookmarkable_id => self.id).any?\n end",
"def index\n @bookmarks = Bookmark.all\n \n @test = Bookmark.where(\"url = ?\", :url =>\"http://google.com\")\n \n @duplicates = Bookmark.find(:all,\n :select => \"url, COUNT(url) AS duplicate_count\",\n :conditions => \"url IS NOT NULL AND url != ''\",\n :group => \"url HAVING duplicate_count > 1\")\n \n @urlcount = Bookmark.count(:group => :url,\n :conditions => \"url IS NOT NULL AND url != ''\")\n \n @getuid = Bookmark.find(:all,\n :select => \"user_id, name\",\n :conditions => \"user_id =='4'\")\n \n @getallpeople = Bookmark.find(:all,\n :select => \"url, user_id\",\n :conditions => \"url = 'http://google.com'\")\n \n @getname = User.find(:all,\n :select => \"username\", :conditions => \"id = '4'\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @bookmarks }\n end\n end",
"def existing_bookmark_for(document_id)\n # to_a, we don't want to go to the database, we want to use cached\n # copy. \n self.bookmarks.to_a.find {|b| b.document_id == document_id}\n end",
"def bookmarked_by_user?(user)\n bookmark_object(user).present?\n end",
"def bookmark_exists?(bm_name)\n raise_if_no_document\n @doc.Bookmarks.Exists(bm_name)\n end",
"def test_delete_reports\n \n reports = BookmarkReport.getAll()\n \n for report in reports \n \n test = BookmarkReport.deleteReport(report.reportId)\n \n assert_equal true, test\n \n end\n \n end",
"def open_bookmark(bm)\n id = bm.shift\n url = Bookmarks.new.bookmark_url(id)\n pexit \"Failure:\".red + \" bookmark #{id} not found\", 1 if url.nil?\n puts 'opening bookmark ' + url + '...'\n openweb(wrap(url))\n open_bookmark bm unless bm.empty?\n end",
"def test_bookmarks\n [{ url: 'https://www.google.com', title: 'Google' },\n { url: 'https://github.com/', title: 'Github' },\n { url: 'https://www.garybusey.com/', title: 'Gary Busey' }]\nend",
"def get_bookmark bookmark_index\n begin\n \n if @filename == ''\n raise 'filename not specified'\n end\n \n if bookmark_index == ''\n raise 'bookmark index not specified'\n end\n \n \n str_uri = $product_uri + '/pdf/' + @filename + '/bookmarks/' + bookmark_index.to_s\n str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) \n response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})\n \n stream_hash = JSON.parse(response_stream)\n \n return stream_hash['Bookmark']\n \n \n rescue Exception=>e\n print e\n end\n end",
"def test_update_bookmark \n bm0 = get_bookmark(@bs.user_id, 'http://www.ml-class.com/')\n new_name = SecureRandom.uuid.to_s\n bm0.name = new_name\n bm0.is_pinned = true\n new_notes = SecureRandom.uuid.to_s\n bm0.notes = new_notes\n new_bm = @bs.update_bookmark(bm0)\n assert(bm0 === new_bm, 'Updated bookmark does not match prototype')\n bm1 = get_bookmark(@bs.user_id, 'http://www.ml-class.com/')\n assert(bm1 === bm0, 'Before and after db dookmarks do not match')\n end",
"def bookmark_or_not(document)\n unless document.blank?\n if params[:controller] == 'bookmarks'\n context = {\n :url => bookmark_path(document)\n }\n else\n context = {\n :url => facet_catalog_path(document),\n :data_counter => session[:search][:counter].to_i\n }\n end\n end\n end",
"def test_get_unauth_bookmark\n bm = @bs.get_bookmark(15)\n assert(bm.errors.count > 0)\n end",
"def test_add_invalid_bookmark\n num_lns0 = count_links\n act_bm = @bs.add_or_get_bookmark('ha ha ha')\n assert(act_bm.errors.count > 0)\n assert_equal(num_lns0, count_links)\n end",
"def folder_link_should_be_highlighted(folder)\n if folder == 'none'\n id = 'none'\n else\n id = folder.id\n end\n within \"#sidebar #folders-list #folder-#{id}\" do\n expect(page).to have_css \"a[data-feed-id='all'].highlighted-link\"\n end\nend",
"def test_predicates\n assert_equal \"12\", XPath::first(@@doc, \"a/e/f[3]\").attributes[\"id\"]\n assert_equal \"13\", XPath::first(@@doc, \"a/e/f[3]/g\").attributes[\"id\"]\n assert_equal \"14\", XPath::first(@@doc, \"a/e/f[@a='d'][2]\").attributes[\"id\"]\n assert_equal \"14\", XPath::first(@@doc, \"a/e/f[@a='d'][@id='14']\").attributes[\"id\"]\n assert_equal \"a\", XPath::first( @@doc, \"*[name()='a' and @id='1']\" ).name\n c=each_test( @@doc, \"//*[name()='f' and @a='d']\") { |i|\n assert_equal \"f\", i.name\n }\n assert_equal 2, c\n c=each_test( @@doc, \"//*[name()='m' or @a='d']\") { |i|\n assert [\"m\",\"f\"].include?(i.name)\n }\n assert_equal 3, c\n\n assert_equal \"b\", XPath::first( @@doc, \"//b[@x]\" ).name\n end",
"def feed_link_should_be_highlighted(feed)\n within \"#sidebar #folders-list\" do\n expect(page).to have_css \"a[data-feed-id='#{feed.id}'].highlighted-link\"\n end\nend",
"def bookmarks(user)\n user = Access::Validate.user(user, false)\n Bookmark\n .where('(bookmarks.creator_id = ? OR bookmarks.updater_id = ?)', user.id, user.id)\n .order('bookmarks.updated_at DESC')\n end",
"def bookmarked?(article)\n bookmarked_article_ids.include?(article.id)\n end",
"def entry_should_be_marked_read(entry)\n expect(page).to have_css \"a[data-entry-id='#{entry.id}'].entry-read\"\nend",
"def bookmark_details\n results = {\n manuscript: manuscript ? manuscript.id : nil,\n source_date: SDBMSS::Util.format_fuzzy_date(source.date),\n source_title: source.title,\n source_agent: source.source_agents.map(&:agent).join(\"; \"),\n titles: entry_titles.order(:order).map(&:display_value).join(\"; \"),\n authors: entry_authors.order(:order).map(&:display_value).join(\"; \"),\n dates: entry_dates.order(:order).map(&:display_value).join(\"; \"),\n artists: entry_artists.order(:order).map(&:display_value).join(\"; \"),\n scribes: entry_scribes.order(:order).map(&:display_value).join(\"; \"),\n languages: entry_languages.order(:order).map(&:display_value).join(\"; \"),\n materials: entry_materials.order(:order).map(&:display_value).join(\"; \"),\n places: entry_places.order(:order).map(&:display_value).join(\"; \"),\n uses: entry_uses.order(:order).map(&:use).join(\"; \"),\n other_info: other_info,\n provenance: unique_provenance_agents.map { |unique_agent| unique_agent[:name] }.join(\"; \"),\n }\n (results.select { |k, v| !v.blank? }).transform_keys{ |key| key.to_s.humanize }\n end",
"def dashboard_emptied?(an_user_id)\n Bookmark.joins(\"INNER JOIN media_elements ON media_elements.id = bookmarks.bookmarkable_id AND bookmarks.bookmarkable_type = 'MediaElement'\").where('media_elements.is_public = ? AND media_elements.user_id != ? AND bookmarks.user_id = ?', true, an_user_id, an_user_id).any?\n end",
"def bookmarks(bookmarks)\n bookmarks.each_with_object({}) do |b, bs|\n first_image = b.entry.entry_images.min_by(&:pocket_image_id)\n bs[b.id] = {\n id: b.id.to_s,\n title: b.entry.resolved_title,\n url: b.entry.url,\n status: b.status,\n addedAt: b.added_to_pocket_at.to_i,\n archivedAt: b.archived_at&.to_i,\n favorite: b.favorite,\n thumbnailUrl: determine_image_url(first_image),\n }\n end\n end",
"def test_document\n add_test_judgement\n assert(@gold_standard.contains_document? :id => \"doc1\")\n end",
"def marking_started?\n Result.joins(:marks, submission: :grouping)\n .where(groupings: { assessment_id: id },\n submissions: { submission_version_used: true })\n .where.not(marks: { mark: nil })\n .any?\n end",
"def entry_should_be_marked_unread(entry)\n expect(page).to have_css \"a[data-entry-id='#{entry.id}'].entry-unread\"\nend",
"def show\n @bookmark = Bookmark.find(params[:id])\n end",
"def show\n @bookmark = Bookmark.find(params[:id])\n end",
"def feed_link_should_not_be_highlighted(feed)\n within '#sidebar #folders-list' do\n expect(page).not_to have_css \"a[data-feed-id='#{feed.id}'].highlighted-link\"\n end\nend",
"def reverse_of_bookmarks?(other_map)\n self.reverse_of_bookmarks.include?(other_map)\n end",
"def folder_link_should_not_be_highlighted(folder)\n if folder == 'none'\n id = 'none'\n else\n id = folder.id\n end\n within \"#sidebar #folders-list #folder-#{id}\" do\n expect(page).not_to have_css \"a[data-feed-id='all'].highlighted-link\"\n end\nend",
"def get_bookmark_for_user(user_id, bookmark_id)\n query = <<-EOS\n SELECT b.id, b.name, b.notes, b.added_on, w.url \n FROM bookmarks b, users u, web_pages w\n WHERE b.user_id = u.id\n AND b.web_page_id = w.id\n AND b.user_id = $1\n AND b.id = $2\n EOS\n bm = @conn.exec(query, [user_id, bookmark_id]).first\n unless bm == nil\n bm = Bookmark.new(bm)\n end\n bm \n end",
"def unread_folder_entries_should_eq(folder, count)\n if folder=='all'\n within '#sidebar #folders-list #folder-none #feeds-all span.badge' do\n expect(page).to have_content \"#{count}\"\n end\n else\n within \"#sidebar #folders-list #folder-#{folder.id} #open-folder-#{folder.id} span.folder-unread-badge\" do\n expect(page).to have_content \"#{count}\"\n end\n end\nend",
"def bookmark_query(q,&blk)\n response = query(q)\n bookmark = response[\"bookmark\"]\n docs = response[\"docs\"]\n\n until !docs || docs.empty?\n yield docs\n q[\"bookmark\"] = bookmark\n response = query(q)\n bookmark = response[\"bookmark\"]\n docs = response[\"docs\"]\n end\n\n docs\n end",
"def bookmarked_by_count\n Recommendable.redis.scard(Recommendable::Helpers::RedisKeyMapper.bookmarked_by_set_for(self.class, id))\n end",
"def entire_history_aaaa\n\t\t@workflows = WorkFlow.where(is_active: true, is_in_use: false)\n\t if session[:report_wildcard].present?\n\t @wildcard = session[:report_wildcard]\n\t end\n\t if session[:report_exact].present?\n\t @exact = session[:report_exact]\n\t end\n\n\t\tif request.post? or session[:report_q_string].present?\n\t\t\t@task_confirmation = false\n\t\t\tif request.post?\n\t\t\t\tserach_result = search\n\t\t\telse\n\t\t\t \tq_string = session[:report_q_string]\n\t\t\t\tserach_result = WorkFlow.search(q_string)\n\t\t\tend\t\n\n\t\t\tif serach_result.present?\n\t\t\t\tl2_name = ''\n\t\t\t\tl1_name = ''\n\t\t\t\tl1_list = ''\n\t\t\t\t@l2_list = ''\n\t\t\t\t@l3_list = ''\n\t\t\t\tserach_result.each do |result|\n\t\t\t\t \tif l1_name != result['l1_name']\n\t\t\t\t \t\tl1_name = result['l1_name']\n\t\t\t\t \t\tl1_list += result['l1_id'].to_s+'_' \n\t\t\t\t \tend\n\n\t\t\t\t \tif l2_name != result['l2_name'] && result['l2_id'].presence\n\t\t\t\t \t\tl2_name = result['l2_name']\n\t\t\t\t \t\t@l2_list += result['l2_id'].to_s+'_' \n\t\t\t\t \tend\t\n\n\t\t\t\t \tif result['l3_id'].presence\n\t\t\t\t \t\t@l3_list += result['l3_id'].to_s+'_' \n\t\t\t\t \tend\t\n\t\t\t \tend\n\n\t\t\t \tl1_list = l1_list.split('_')\n\t\t\t\t@l2_list = @l2_list.split('_')\n\t\t\t @l3_list = @l3_list.split('_')\n\t\t\t\t@report_l1s = L1.where(id: [l1_list])\n\n\t\t\t\t@report_l1s.each do |l1|\n\t\t\t\t\tif l1.timestamp_logs.present?\n\t\t\t\t\t\t@task_confirmation = true\n\t\t\t\t\tend\n\t\t\t\t\t@l2_list_objects = l1.l2s.where(id: [@l2_list])\n\t\t\t\t\t@l2_list_objects.each do |l2|\n\t\t\t\t\t\tif l2.timestamp_logs\n\t\t\t\t\t\t\t@task_confirmation = true\n\t\t\t\t\t\tend\n\t\t\t\t\t\t\t@l3_list_objects = l2.l3s.where(id: [@l3_list])\n\t\t\t\t\t\t\t@l3_list_objects.each do |l3|\n\t\t\t\t\t\t\t\tif l3.timestamp_logs\n\t\t\t\t\t\t\t\t\t@task_confirmation = true\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\t\n\t\t\t\t\tend\n\t\t\t\tend\t\n\t\t\tend\n\t\tend\n\tend",
"def report(report_name, dom, _path)\n case report_name\n when \"{#{NS_CARDDAV}}addressbook-multiget\"\n @server.transaction_type = 'report-addressbook-multiget'\n addressbook_multi_get_report(dom)\n return false\n when \"{#{NS_CARDDAV}}addressbook-query\"\n @server.transaction_type = 'report-addressbook-query'\n addressbook_query_report(dom)\n return false\n else\n return true\n end\n end",
"def unread_feed_entries_should_eq(feed, count, user)\n folder = feed.user_folder user\n folder_id = folder&.id || 'none'\n open_folder folder if folder.present?\n expect(page).to have_css \"#sidebar #folders-list #folder-#{folder_id} a[data-sidebar-feed][data-feed-id='#{feed.id}']\"\n within \"#sidebar #folders-list #folder-#{folder_id} a[data-sidebar-feed][data-feed-id='#{feed.id}'] span.badge\" do\n expect(page).to have_content \"#{count}\"\n end\nend",
"def get_all_bookmarks\n begin\n \n if @filename == ''\n raise 'filename not specified'\n end\n \n \n total_bookmarks = self.get_bookmarks_count\n \n all_bookmarks = Array.new\n \n index = 1\n while index <= total_bookmarks\n \n all_annotations.push(self.get_bookmark(index))\n \n index+=1\n end\n \n return all_bookmarks\n \n \n rescue Exception=>e\n print e\n end\n end",
"def show\n if session[:user_id]\n @bookmark = Bookmark.first(:conditions => \"id = \" + params[:id].to_s + \" AND user_id = \" + session[:user_id].to_s)\n if @bookmark\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @bookmark }\n end\n else\n redirect_to \"/bookmarks/\"\n end\n else\n redirect_to \"/login\"\n end\n end",
"def check_marks\n stream = Stream.find(stream_id)\n sub_maps = stream.sub_str_maps.all\n xuser = self.user\n cat = xuser.personal.category\n academic = xuser.academic\n sub_mark = sub_maps.pluck(cat)\n\n user_subs = academic.subject_entries.all\n ok = false\n i = 0\n sub_maps.each do |su|\n ok = false\n user_subs.each do |as|\n if su.subject_id === as.subject_id\n if sub_mark[i] <= as.marks\n ok = true\n end\n end\n end\n unless ok\n errors.add(:stream_id, \"This stream cannot be choosen since you dont have required marks/subject\")\n break\n end\n i += 1\n end\n ok\n end",
"def is_reported?\n (report_count > 0)\n end",
"def test_update_nonexisting_bookmark\n bm0 = Bookmark.new('id' => 1000, \n 'url' => '/some/url', \n 'title' => 'some title')\n new_bm = @bs.update_bookmark(bm0)\n assert(new_bm.errors.count > 0)\n end",
"def test_results(id)\n return [] unless @rule_results\n\n @rule_results.select { |r| r.idref == id }\n end",
"def create\n session_user = session[:usr]\n receipe = Receipe.find(params[:receipe_id])\n \n if Bookmark.create(user_id: session_user, receipe_id: receipe.id)\n redirect_to receipe\n else\n \n end\n\n end",
"def bookmark\n\t\tanswer = $screen.ask(\"bookmark:\",@bookmarks_hist)\n\t\tif answer == nil\n\t\t\t$screen.write_message(\"Cancelled\");\n\t\telse\n\t\t\t$screen.write_message(\"Bookmarked\");\n\t\t\t@bookmarks[answer] = [@row,@col]\n\t\tend\n\tend",
"def history_on?()\n (DocbookStatus::History.exists? || @end_date != NOVAL || @total_words != NOVAL || @daily_words != NOVAL)\nend",
"def is_marked?(id, ignore_errors = false)\n @entries.each do |entry|\n return entry[MARKED] != 0 if entry[ID] == id\n end\n\n return false if ignore_errors\n PEROBS.log.fatal \"Cannot find an entry for ID #{'%016X' % id} to check\"\n end",
"def bookmark_object(the_user)\n the_user.bookmarked_posts.find_by_post_id(id)\n end",
"def reports?\n !reports.empty?\n end",
"def create\n @bookmarks = if params[:bookmarks]\n permit_bookmarks[:bookmarks]\n else\n [{ document_id: params[:id], document_type: blacklight_config.document_model.to_s }]\n end\n\n current_or_guest_user.save! unless current_or_guest_user.persisted?\n\n bookmarks_to_add = @bookmarks.reject { |bookmark| current_or_guest_user.bookmarks.where(bookmark).exists? }\n success = ActiveRecord::Base.transaction do\n current_or_guest_user.bookmarks.create!(bookmarks_to_add)\n rescue ActiveRecord::RecordInvalid\n false\n end\n\n if request.xhr?\n success ? render(json: { bookmarks: { count: current_or_guest_user.bookmarks.count } }) : render(json: current_or_guest_user.errors.full_messages, status: \"500\")\n else\n if @bookmarks.any? && success\n flash[:notice] = I18n.t('blacklight.bookmarks.add.success', count: @bookmarks.length)\n elsif @bookmarks.any?\n flash[:error] = I18n.t('blacklight.bookmarks.add.failure', count: @bookmarks.length)\n end\n\n redirect_back fallback_location: bookmarks_path\n end\n end",
"def index\n if params[:dress_id]\n @bookmarks = @bookmarks.where(\"bookmarkable_id = ?\", params[:dress_id])\n elsif params[:vendor_id]\n @bookmarks = @bookmarks.where(\"bookmarkable_id = ?\", params[:vendor_id])\n end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookmarks }\n end\n end",
"def bookmark( *names, **options )\n\t\traise \"expected at least one bookmark name\" if names.empty?\n\n\t\tself.server.run( :bookmark, *names, **options )\n\t\treturn true\n\tend",
"def doesJiraLinkExist\n return @persist.findDefect(@story)[1]\n end",
"def create\n incomplete = true\n error = false\n if ((params[:url] != nil) &&( (params[:description] != nil ) || (params[:bookmark][\"title\"] != nil )))\n incomplete = false\n url = nil\n if params[:url][:url]\n url = params[:url][:url]\n else\n url = params[:url]\n end\n if not ((url =~ /^http:\\/\\//) || (url =~ /^https:\\/\\//))\n url = \"http://\" + url\n end\n link = Link.find_by_url(url) || Link.new(:url => url)\n link.save\n if link.users.include?(current_user)\n flash[:message] = \"Already in\"\n else\n datetime = nil\n datetime = params[:dt] if params[:dt]\n description = params['description'] || params[:bookmark]['title']\n\n new_bookmark = Bookmark.new(:title => description, :link_id => link.id, :user_id => current_user.id, :bookmarked_at => (datetime || Time.now))\n new_bookmark.private = 1 if ((params[:shared] && (params[:shared] == \"no\")))\n new_bookmark.private = params[:bookmark][\"private\"] if params[:bookmark][\"private\"]\n new_bookmark.tag_list = params['tags'] || params[:bookmark]['tags']\n current_user.bookmarks_update_at = Time.now\n if new_bookmark.save\n current_user.save\n logger.info(\"bookmark for #{url} added\")\n else\n error = true\n logger.warn(\"Error : could not save the new bookmark\")\n end\n end\n end\n respond_to do |format|\n format.xml do\n if incomplete || error\n render :xml => \"<?xml version='1.0' standalone='yes'?>\\n<result code=\\\"something went wrong\\\" />\"\n else\n render :xml => \"<?xml version='1.0' standalone='yes'?>\\n<result code=\\\"done\\\" />\"\n end\n end\n end\n end",
"def create_bookmarks(results, opts = {})\n created = 0\n skipped = 0\n total = opts[:total] || results.count\n\n user = User.new\n post = Post.new\n\n results.each do |result|\n params = yield(result)\n\n # only the IDs are needed, so this should be enough\n if params.nil?\n skipped += 1\n else\n user.id = user_id_from_imported_user_id(params[:user_id])\n post.id = post_id_from_imported_post_id(params[:post_id])\n\n if user.id.nil? || post.id.nil?\n skipped += 1\n puts \"Skipping bookmark for user id #{params[:user_id]} and post id #{params[:post_id]}\"\n else\n result = PostActionCreator.create(user, post, :bookmark)\n created += 1 if result.success?\n skipped += 1 if result.failed?\n end\n end\n\n print_status(created + skipped + (opts[:offset] || 0), total, get_start_time(\"bookmarks\"))\n end\n\n [created, skipped]\n end",
"def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end",
"def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end",
"def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end",
"def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end",
"def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end",
"def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end",
"def test_relevant\n add_test_judgement\n assert(@gold_standard.relevant? :document => \"doc1\", :query => \"query1\")\n end",
"def all_marks_given?(period)\n return Mark.where(:student_from_id => self, :period_id => period)\n end",
"def show\n @title = @note.title\n @[email protected]\n @[email protected]\n @tags = @note.tag\n @pages = Page.joins(:notes).where(\"notes.id = #{params[:id]}\").paginate(:page => params[:page], per_page: APP_CONFIG[\"pagenate_count\"][\"notes\"]).order(\"pages.id\").all\n\n if current_user\n @bookmarked = Bookmark.where(:user_id => current_user.id)\n @bookmark = Bookmark.new\n @bookmark.note_id = @note.id\n @bookmark.user_id = current_user.id\n end\n end",
"def json_show_user_bookmark_by_user_id_and_bookmark_id\n\n respond_to do |format|\n\n if Bookmark.\n joins(:users_bookmarks).\n joins(:bookmarks_category).\n where('user_id = ? and bookmarks.id = ?',params[:user_id],params[:bookmark_id]).exists?\n\n @user_bookmark = Bookmark.\n select('bookmarks.id, bookmark_url, bookmarks_category_id, description, i_frame, image_name, image_name_desc, bookmarks_categories.item_id, title,position,\"like\"').\n joins(:users_bookmarks).\n joins(:bookmarks_category).\n where('user_id = ? and bookmarks.id = ?',params[:user_id],params[:bookmark_id]).first\n\n format.json { render json: @user_bookmark }\n else\n format.json { render json: 'not found user_id and bookmark id' , status: :not_found }\n end\n end\n\n end",
"def test_a\n fdl_test( %{\n feature test\n (not all(x,x:[word=nil]))\n <x.id>},\n false)\n end",
"def has_assignments?\n ## TO DO add validation on link with categories and receipts\n return (self.finance_category_accounts.present? or self.finance_transaction_receipt_records.first.present?)\n end",
"def all_marks_received?(period)\n return Mark.where(:student_to_id => self, :period_id => period)\n end",
"def bookmarked_by_ids\n Recommendable.redis.smembers(Recommendable::Helpers::RedisKeyMapper.bookmarked_by_set_for(self.class, id))\n end",
"def get_marks_list(submission)\n criteria.map do |criterion|\n mark = submission.get_latest_result.marks.find_by(criterion: criterion)\n [(mark.nil? || mark.mark.nil?) ? '' : mark.mark,\n criterion.max_mark]\n end\n end",
"def ids_to_accept\n git_log_delivered_story_ids & pivotal_tracker_delivered_story_ids\n end",
"def has_abnormal_reports?\n\t\tself.reports.select{|c|\n\t\t\tc.has_abnormal_tests?\n\t\t}.size > 0\n\tend",
"def remember_bookmark\n @ole.RememberBookmark\n end",
"def test_create_assignment_report\n \n first_report = oi_assignment_reports(:first)\n \n # Try accessing from an account that is not a PCB Designer and\n # verify that the user is redirected.\n get(:create_assignment_report, { :id => oi_assignment_reports(:first) }, lee_hweng_session)\n assert_redirected_to(:controller => 'tracker', :action => 'index')\n assert_equal(\"You are not authorized to access this page\", flash['notice'])\n \n get(:create_assignment_report, {:id => first_report}, scott_designer_session)\n assert_equal(first_report.id, assigns(:assignment).id)\n assert_equal(1, assigns(:complexity_id))\n assert_equal(OiAssignmentReport::NOT_SCORED, assigns(:report).score)\n assert_equal([], assigns(:comments))\n assert_equal(OiAssignmentReport.report_card_scoring,\n assigns(:scoring_table))\n \n # Verify the redirect to create_assignment_report by create report when the \n # report has not been scored.\n \n \n end",
"def show\n render json: { bookmark: @bookmark }, status: :ok\n end",
"def end_of_report?(document)\n document\n end",
"def get_da_urls (doc,comment_url)\n doc.search('table tbody tr').each do |tr|\n # Columns in table\n # Show Number Submitted Details\n tds = tr.search('td')\n\n break if tds[0].inner_text =~ /no records/\n\n h = tds.map{|td| td.inner_html}\n\n puts h\n info_url = 'https://pdonline.toowoombarc.qld.gov.au/Masterview/Modules/ApplicationMaster/' + tds[0].at('a')['href'].strip\n puts info_url\n descParts = h[3].split('<br>')\n record = {\n 'info_url' => info_url,\n 'comment_url' => comment_url,\n 'council_reference' => clean_whitespace(h[1]),\n 'date_received' => Date.strptime(clean_whitespace(h[2]), '%d/%m/%Y').to_s,\n # TODO: Some DAs have multiple addresses, we're just getting the first :(\n 'address' => clean_whitespace(descParts[0]),\n 'description' => clean_whitespace(descParts[1]),\n 'date_scraped' => Date.today.to_s\n }\n\n if (ScraperWiki.select(\"* from data where `council_reference`='#{record['council_reference']}'\").empty? rescue true)\n ScraperWiki.save_sqlite(['council_reference'], record)\n else\n puts \"Skipping already saved record \" + record['council_reference']\n end\n end\nend",
"def general_bookmarks\n @general_bookmarks ||=\n Bookmark.with_missing_bookmarkable.or(\n Bookmark.with_bookmarkable_visible_to_registered_user\n ).is_public\n end",
"def bookmarks\n full = options[:full]\n docs = options[:doc] && documents.map { |doc| [doc.id, doc] }.to_h\n item_list.map { |item|\n next unless item.is_a?(Bookmark)\n entry = {\n document_id: item.document_id,\n document_type: item.document_type.to_s,\n lens: item.lens,\n updated_at: item.updated_at,\n created_at: item.created_at,\n }\n full && entry.merge!(\n title: item.user_type, # TODO: not persisted; should it be?\n id: item.id,\n user_id: item.user_id,\n user_type: item.user_type,\n )\n docs && entry.merge!(doc: docs[item.document_id])\n entry\n }.compact.as_json\n end",
"def add(bookmark)\n\t\t\tkparams = {}\n\t\t\tclient.add_param(kparams, 'bookmark', bookmark)\n\t\t\tclient.queue_service_action_call('bookmark', 'add', 'bool', kparams)\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil\n\t\t\tend\n\t\t\treturn client.do_queue()\n\t\tend",
"def set_my_bookmark\n @my_bookmark = MyBookmark.find(params[:id])\n end"
] | [
"0.6570599",
"0.62345517",
"0.5988543",
"0.5978591",
"0.58733493",
"0.5760648",
"0.57567286",
"0.56794226",
"0.5605636",
"0.5583483",
"0.55218905",
"0.54790664",
"0.5436384",
"0.5394215",
"0.5359893",
"0.5332839",
"0.53305566",
"0.53033876",
"0.5248693",
"0.52171856",
"0.5145901",
"0.51281714",
"0.5092325",
"0.5038964",
"0.5018444",
"0.5002784",
"0.49859658",
"0.4960276",
"0.49074477",
"0.48884395",
"0.48803222",
"0.4879735",
"0.48416263",
"0.48357",
"0.48101693",
"0.47683838",
"0.4756988",
"0.47552693",
"0.47518516",
"0.47393784",
"0.47129917",
"0.470224",
"0.46843794",
"0.46692812",
"0.4642689",
"0.4642689",
"0.46278003",
"0.46086028",
"0.45968795",
"0.45944247",
"0.45879024",
"0.4581486",
"0.45723698",
"0.45686212",
"0.45662734",
"0.4545598",
"0.45300606",
"0.4517702",
"0.45120177",
"0.44952035",
"0.44904834",
"0.44895267",
"0.44873896",
"0.44647616",
"0.44643956",
"0.44624436",
"0.44512418",
"0.4450244",
"0.44487327",
"0.44470093",
"0.44441393",
"0.44432214",
"0.44343758",
"0.44342336",
"0.4429669",
"0.4429669",
"0.4429669",
"0.4429669",
"0.4429669",
"0.4429669",
"0.4403051",
"0.439838",
"0.43969774",
"0.43966988",
"0.4396113",
"0.4394957",
"0.43903837",
"0.43874642",
"0.4377431",
"0.43766457",
"0.43757543",
"0.43747714",
"0.43619633",
"0.43605092",
"0.43570858",
"0.4356868",
"0.43552902",
"0.43535477",
"0.4348915",
"0.4347582"
] | 0.6691889 | 0 |
Gets all the reports from the database and deletes them Should return true as they do not exist anymore | def test_delete_reports
reports = BookmarkReport.getAll()
for report in reports
test = BookmarkReport.deleteReport(report.reportId)
assert_equal true, test
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_all_reports!\n reports=get_report_list\n reports.each do |rep|\n rep[:ReportID]\n delete_report(rep[:ReportID])\n end\n end",
"def delete_data\n Report.plugin_matrix.each do |resource_name, measurements|\n model = Object.const_get((resource_name + 'Resource').camelcase(:upper))\n model.dataset.all.each(&:delete)\n\n measurements.each do |measurement_name|\n table = Plugin.where(name: measurement_name).first.storage_table\n Iam.settings.DB[table.to_sym].delete\n end\n end\n Iam.settings.DB[:projects].delete\n Iam.settings.DB[:clients].delete\n end",
"def destroy\n @all_report.destroy\n respond_to do |format|\n format.html { redirect_to all_reports_url, notice: 'All report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def reports\n (@reports ||= Conversocial::Resources::QueryEngines::Report.new self).clear\n end",
"def destroy\n @report = Report.find(params[:id].to_i)\n ActiveRecord::Base.transaction do\n @report.destroy\n end\n end",
"def destroy\n @report.destroy!\n render json: {status: :ok}\n end",
"def fetch_reports\n # fetch all the reports using this method and then create a Report for each of them\n end",
"def clean_reports(node)\n Puppet::Transaction::Report.indirection.destroy(node)\n Puppet.info \"#{node}'s reports removed\"\n end",
"def clear_db\n users = User.all\n users.delete_all\n companies = Company.all\n companies.delete_all\n feedbacks = Feedback.all\n feedbacks.delete_all\n co_emp = CompanyEmployee.all\n co_emp.delete_all\n projects = Project.all\n projects.delete_all\n proj_fb = ProjectFeedback.all\n proj_fb.delete_all\nend",
"def clear_database\n User.destroy_all\n Animal.destroy_all\n Report.destroy_all\nend",
"def delete_all\n records.clear\n end",
"def db_clear\n [Project, Milestone, Category, Version, LoaderRelease].each {|x| x.delete_all}\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to admin_reports_url, notice: t('shared.msgs.success_destroyed',\n obj: t('activerecord.models.report', count: 1)) }\n format.json { head :no_content }\n end\n end",
"def update\n ActiveRecord::Base.transaction do\n @report.update!(name: params[:report][:name], unpublished: params[:report][:unpublished])\n @report.report_saved_queries.where('saved_query_id NOT IN (?)', params[:report][:saved_query_ids].map{|sqi| sqi.to_i}).destroy_all\n \n [email protected]_queries.map{|sq| sq.id}\n to_add=params[:report][:saved_query_ids].map{|sqi| sqi.to_i} - saved_query_ids\n to_add.each do |ta|\n ReportSavedQuery.create!(saved_query_id: ta, report_id: @report.id)\n end\n end\n \n render json: {status: :ok}\n end",
"def destroy\n appctrl_destroy( SavedReport, user_saved_reports_path( @user ) )\n end",
"def delete_report(report_id)\n if api_call('DeleteReport',report_id)[:data]==1\n res=true\n else\n res=false\n end\n #api_call('DeleteReport')\n end",
"def db_clear\n [Project, Milestone, Category, Version, LoaderRelease].each(&:delete_all)\n end",
"def delete_existing\n Answer.delete_all\n Question.delete_all\n Knock.delete_all\n Door.delete_all\n Canvasser.delete_all\nend",
"def cleanup()\n Track.where(scanned: false).delete_all()\n Disc.delete_all(\"id NOT IN (SELECT DISTINCT(disc_id) FROM tracks)\")\n Album.delete_all(\"id NOT IN (SELECT DISTINCT(album_id) FROM tracks)\")\n Artist.delete_all(\"id NOT IN (SELECT DISTINCT(artist_id) FROM tracks)\")\n end",
"def unignore_reports\n client.post('/api/unignore_reports', id: read_attribute(:name))\n end",
"def destroy\n @user_reports = UserReport.find(params[:id])\n @user_reports.destroy\n\n respond_to do |format|\n format.html { redirect_to(user_reports_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @report.destroy\n\n respond_to do |format|\n format.html { redirect_to(reports_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @report.destroy\n\n respond_to do |format|\n format.html { redirect_to(reports_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @report.destroy\n redirect_to reports_url, notice: t(\"activerecord.attributes.report.destroyed\")\n end",
"def destroy\n\t\t@report = Report.find(params[:id])\n\t\[email protected]\n\t\t\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to reports_url }\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend",
"def destroy\n\t\t@report = Report.find(params[:id])\n\t\[email protected]\n\t\t\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to reports_url }\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend",
"def delete_resources\n ResourceEvent.where(resource_status_id: resource_statuses.map(&:id)).delete_all\n ResourceStatus.where(report_id: id).delete_all\n end",
"def collect_garbage!\n find_including_new_records(:all, :conditions => ['as_new = ? AND created_at < ?', true, Time.now - 1.week]).each(&:destroy)\n end",
"def destroy\n @stores_report = Stores::Report.find(params[:id])\n @stores_report.destroy\n\n respond_to do |format|\n format.html { redirect_to stores_reports_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t\[email protected]\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to reports_url, notice: 'Report was successfully destroyed.' }\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report = Mg::Report.find(params[:id])\n @report.destroy\n\n respond_to do |format|\n format.html { redirect_to(mg_reports_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @report.destroy\n flash[:success] = \"report deleted\"\n redirect_to reports_url\n \n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to admin_reports_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report = Report.find(params[:id])\n @report.destroy\n\n respond_to do |format|\n format.html { redirect_to(reports_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @report = Report.find(params[:id])\n @report.destroy\n\n respond_to do |format|\n format.html { redirect_to(reports_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @report = Report.find(params[:id])\n @report.destroy\n\n respond_to do |format|\n format.html { redirect_to(reports_url) }\n format.xml { head :ok }\n end\n end",
"def delete_report( type, id )\n \n LOGGER.info \"delete report '\"+id.to_s+\"' of type '\"+type.to_s+\"'\"\n @persistance.delete_report(type, id)\n end",
"def destroy\n @report_type = ReportType.find(params[:id])\n BusinessesReportType.where(\"report_type_id = ?\", @report_type.id).each {|brt| brt.destroy}\n ComponentsReportType.where(\"report_type_id = ?\", @report_type.id).each {|crt| crt.destroy}\n EmployeesReportType.where(\"report_type_id = ?\", @report_type.id).each {|ert| ert.destroy}\n ProjectsReportType.where(\"report_type_id = ?\", @report_type.id).each {|prt| prt.destroy}\n StatusesReportType.where(\"report_type_id = ?\", @report_type.id).each {|srt| srt.destroy}\n @report_type.destroy\n respond_to do |format|\n format.html { redirect_to report_types_url, notice: 'Report type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_find_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_dashboards\n Dashboard.all.map { |data| Dashboard[data['link']] }.each { |d| d.delete }\n end",
"def destroy\n @custom_report = CustomReport.find(params[:id])\n @custom_report.destroy\n\n head :no_content\n end",
"def destroy\n @report = Report.find(params[:id])\n @report.destroy\n\n respond_to do |format|\n format.html { redirect_to reports_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report = Report.find(params[:id])\n @report.destroy\n\n respond_to do |format|\n format.html { redirect_to reports_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report = Report.find(params[:id])\n @report.destroy\n\n respond_to do |format|\n format.html { redirect_to reports_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report = Report.find(params[:id])\n @report.destroy\n\n respond_to do |format|\n format.html { redirect_to reports_url }\n format.json { head :no_content }\n end\n end",
"def unimported_records\n imported_records.where(success: false)\n end",
"def deleteAll\n Record.destroy_all()\n redirect_to(records_path)\n end",
"def clear_db\n DB.from(\"mentees\").delete\n DB.from(\"mentors\").delete\n DB.from(\"admins\").delete\n DB.from(\"users\").delete\n DB.from(\"codes\").delete\n DB.from(\"requests\").delete\n DB.from(\"questions_answers\").delete\nend",
"def destroy\n @report = current_user.reports.find(params[:id])\n @report.destroy\n\n respond_to do |format|\n format.html { redirect_to reports_url }\n format.json { head :no_content }\n end\n end",
"def index\n @reports = Report.all\n # @reports = Array.new\n end",
"def update_reports\n\n\t\tremove_reports\n\n\t\texisting_report_ids = self.reports.map{|c|\n\t\t\tc.id.to_s\n\t\t}\n\n\t\t## after this the quantity issue\n\t\t## and then the test verification toggles, textual inference, and report generation ->\n\t\t## so only if the order is finalized, then \n\t\t## now the worth processing.\n\t\t## local item group\n\t\t## organization from \n\n\t\tself.template_report_ids.each do |r_id|\n\t\t\t#puts \"doing template report id: #{r_id}\"\n\t\t\tunless existing_report_ids.include? r_id\n\t\t\t\ttx = Time.now\n\t\t\t\tself.finalize_order = NO\n\t\t\t\t## unfinalize the order\n\t\t\t\t## \n\t\t\t\t## get teh report raw hash.\n\t\t\t\t## get rid of the non-applicable ranges\n\t\t\t\t## and only then initialize the object.\n\t\t\t\t## that will make it much faster.\n\t\t\t\treport = Diagnostics::Report.find(r_id)\n\t\t\t\t\n\t\t\t\tty = Time.now\n\t\t\t\tputs \"time to get report: #{(ty - tx).in_milliseconds}\"\n\t\t\t\treport.created_by_user = User.find(report.created_by_user_id)\n\t\t\t\treport.current_user = self.current_user\n\t\t\t\ttz = Time.now\n\t\t\t\tputs \"time to get created by user: #{(tz - ty).in_milliseconds}\"\n\t\t\t\treport.run_callbacks(:find)\n\t\t\t\tt1 = Time.now\n\t\t\t\tputs \"time to run callbacks: #{(t1 - tz).in_milliseconds}\"\n\t\t\t\treport.prune_test_ranges(self.patient)\n\t\t\t\tt2 = Time.now\n\t\t\t\tputs \"prune ranges took: #{(t2-t1).in_milliseconds}\"\n\t\t\t\tself.reports << report\n\t\t\t\tself.order_completed = NO\n\t\t\tend\n\t\tend\n\tend",
"def clean_database\n\t\t\t\tbegin\n\t\t\t\t\tupdate_all(XSSF_VICTIM_DB, XSSF_VICTIM_HASH, {\"CURRENT_ATTACK_URL\" => nil, \"TUNNELED\" => false})\n\t\t\t\t\tdelete_all(XSSF_WAITING_ATTACKS_DB) \n\t\t\t\trescue\n\t\t\t\t\tprint_error(\"Error 10: #{$!}\") if (XSSF_MODE[0] =~ /^Debug$/i)\n\t\t\t\tend\n\t\t\tend",
"def destroy\n @comparative_report = ComparativeReport.find(params[:id])\n @comparative_report.destroy\n\n respond_to do |format|\n format.html { redirect_to(comparative_reports_url) }\n format.xml { head :ok }\n end\n end",
"def report_delete(id)\n\t\t\tpost= { \"token\" => @token, \"report\" => id }\n\t\t\tdocxml = nil\n\t\t\tdocxml=nessus_request('report/delete', post)\n\t\t\tif docxml.nil?\n\t\t\t\treturn\n\t\t\tend\n\t\t\treturn docxml\n\t\tend",
"def destroy\n @dailyreport = Dailyreport.find(params[:id])\n @dailyreport.destroy\n\n respond_to do |format|\n format.html { redirect_to(dailyreports_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: 'El Reporte fue Eliminado Exitosamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report = Report.find(params[:id])\n @report.destroy\n\n respond_to do |format|\n format.html { redirect_to reports_url }\n #format.json { head :ok }\n end\n end",
"def report_delete(id)\r\n\t\tpost= { \"token\" => @token, \"report\" => id } \r\n\t\tdocxml=nessus_request('report/delete', post)\r\n\t\treturn docxml\r\n\tend",
"def destroy\n @report_content.destroy\n respond_to do |format|\n format.html { redirect_to report_contents_url }\n format.json { head :no_content }\n end\n end",
"def delete_all\n\t\t\t@@driver.delete_all\n\t\tend",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to user_reports_url, notice: I18n.t('controllers.reports.successfully_updated') }\n format.json { head :no_content }\n end\n end",
"def teardown\n @report.close\n end",
"def destroy\n @report = current_user.reports.find(params[:id])\n @report.destroy\n\n respond_to do |format|\n format.html { redirect_to user_path(current_user), notice: \"Report was deleted!\" }\n format.json { head :no_content }\n end\n end",
"def clear_all\n Test.all.each do |test|\n test.clear_all\n test.save\n end\n \n redirect_to admin_root_path\n end",
"def destroy\n @individual_report = @medical_record.individual_reports.find(params[:id])\n @individual_report.destroy\n\n respond_to do |format|\n format.html { \n flash[:notice] = _('Se ha eliminado el informe correctamente')\n redirect_to(medical_record_individual_reports_url) \n }\n format.xml { head :ok }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def clear_db\n clear_urls + clear_docs\n end",
"def destroy\n @admin_report.destroy\n respond_to do |format|\n format.html { redirect_to admin_reports_url, notice: 'Report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @et_report.destroy\n respond_to do |format|\n format.html { redirect_to et_reports_url, notice: '削除が完了しました。' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: \"Report was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url, notice: \"Report was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def remove_old_results\n CustomReportsResult.where(custom_report_id: custom_report_id)\n .order('created_at DESC')\n .offset(5)\n .destroy_all\n end",
"def clean_database\n @title = \"Clean database\"\n fix = params[:fix]=='true' # This boolean determines whether we actually make changes to the database\n cum_report = \"\"\n cum_report << clean_members(fix)\n cum_report << clean_families(fix)\n cum_report << clean_locations(fix)\n cum_report << clean_field_terms(fix)\n cum_report << clean_contacts(fix)\n flash[:notice] = fix ? 'Database cleaned' : 'Report only; database not yet cleaned'\n @report = cum_report\n AppLog.create(:severity=>'info', :code=>'CleanDatabase', :description => \"Fixed = #{fix}\")\n end",
"def orphaned_design_checks\n \n log = []\n \n total_design_checks = self.design_checks.size\n self.trim_checklist_for_design_type\n self.get_design_checks\n \n completed_check_counts = self.completed_check_count\n \n attached_design_checks = []\n self.checklist.each_check { |ch| attached_design_checks << ch.design_check }\n\n directory_name = self.design.directory_name\n \n orphaned_design_checks = self.design_checks - attached_design_checks\n \n if orphaned_design_checks.size > 0\n \n self.designer_completed_checks = completed_check_counts[:self]\n self.auditor_completed_checks = completed_check_counts[:peer]\n self.save\n \n log << \" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\"\n log << \" REMOVING INAPPROPRIATE DESIGN CHECKS\"\n log << \" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\"\n\n orphaned_design_checks.each do |dc|\n check = Check.find(dc.check_id)\n \n log << \"\"\n log << \" DESIGN CHECK ID: \" + dc.id.to_s\n log << \" CHECK ID: \" + dc.check_id.to_s\n log << \" SELF CHECKED: \" + dc.self_auditor_checked?.to_s\n log << \" PEER CHECKED: \" + dc.peer_auditor_checked?.to_s\n log << \" NEW REVIEW: \" + check.full_review?.to_s\n log << \" BB REVIEW: \" + check.dot_rev_check?.to_s\n \n dc.destroy \n \n design_check_list = DesignCheck.find(:all, :conditions => \"audit_id=#{self.id} AND check_id=#{dc.check_id}\")\n if design_check_list.size > 1\n log << \"\"\n log << \" **********************************************\"\n log << \" **********************************************\"\n log << \" ***** WARNING: FOUND MULTIPLE DESIGN CHECKS!!!\"\n log << \" **********************************************\"\n log << \" **********************************************\"\n log << \"\"\n end\n end\n end\n \n log\n \n end",
"def reports?\n !reports.empty?\n end",
"def destroy\n @report = Report.find_by(id: params[:id])\n if current_user == @report.user\n @report.destroy\n redirect_to user_reports_path(current_user), notice: \"Report deleted\"\n else\n redirect_to user_reports_path(current_user), alert: \"That's not your report\"\n end\n end",
"def delete_all\n self.store.delete_keys(find_keys)\n end",
"def destroy\n @survey_report = SurveyReport.find(params[:id])\n @survey_report.destroy\n\n respond_to do |format|\n format.html { redirect_to survey_reports_url }\n format.json { head :no_content }\n end\n end",
"def purge_db\n\tUser.delete_all\n\tSubscription.delete_all\n\tDorkus.delete_all\nend",
"def destroy\n @quarterly_report = QuarterlyReport.find(params[:id])\n @quarterly_report.destroy\n\n respond_to do |format|\n format.html { redirect_to(quarterly_reports_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @user_report = UserReport.find(params[:id])\n @user_report.destroy\n\n respond_to do |format|\n format.html { redirect_to(user_reports_url) }\n format.xml { head :ok }\n end\n end"
] | [
"0.7976635",
"0.6659144",
"0.6492318",
"0.64480263",
"0.6422423",
"0.64003795",
"0.6328358",
"0.63014066",
"0.62634295",
"0.62156916",
"0.6170256",
"0.6162276",
"0.6153949",
"0.6148952",
"0.61148447",
"0.6107269",
"0.61024606",
"0.607564",
"0.60746294",
"0.60601956",
"0.6038667",
"0.6037244",
"0.6037244",
"0.60274035",
"0.6016893",
"0.6016893",
"0.60161126",
"0.59971416",
"0.5991471",
"0.59894454",
"0.5971429",
"0.5971429",
"0.5971429",
"0.59709847",
"0.5959527",
"0.59580564",
"0.5950946",
"0.5941745",
"0.5941745",
"0.5922938",
"0.5921015",
"0.59166807",
"0.5862386",
"0.58605087",
"0.58587384",
"0.5838017",
"0.5838017",
"0.5838017",
"0.5838017",
"0.5835211",
"0.58074516",
"0.5803409",
"0.5798341",
"0.579001",
"0.57769513",
"0.57753515",
"0.5765183",
"0.5764053",
"0.5759056",
"0.57552487",
"0.57549447",
"0.5749568",
"0.57433957",
"0.573546",
"0.5731012",
"0.5713641",
"0.57128316",
"0.5707674",
"0.5705237",
"0.56982005",
"0.56982005",
"0.56982005",
"0.56982005",
"0.56982005",
"0.56982005",
"0.56982005",
"0.56982005",
"0.56982005",
"0.56982005",
"0.56982005",
"0.56982005",
"0.56982005",
"0.56982005",
"0.56982005",
"0.56982005",
"0.5688421",
"0.5688168",
"0.56818724",
"0.5677855",
"0.5677855",
"0.5677483",
"0.56686205",
"0.5656663",
"0.5651618",
"0.5644358",
"0.5640978",
"0.5637248",
"0.5633051",
"0.5628996",
"0.5622983"
] | 0.7615873 | 1 |
GET /leilaos/1 GET /leilaos/1.xml | def show
@leilao = Leilao.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @leilao }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @lieus = Lieu.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lieus }\n end\n end",
"def xml(id)\n http.get(\"/nfse/#{id}/xml\") do |response|\n response.headers.fetch(\"Location\") { \"\" }\n end\n end",
"def get_xml\n response = @api.request(:get, @location, type: 'xml')\n response.body if response.status == 200\n end",
"def show\n @lote = Lote.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lote }\n end\n end",
"def rest_get(uri)\n \n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n response = http.request request\n response.value\n\n doc = REXML::Document.new response.body\n \n return doc\n \n end\n \nend",
"def show\n @lieu = Lieu.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lieu }\n end\n end",
"def api_xml(path,method=:get,options={})\n xml_message(amee,\"/data\"+path,method,options)\n end",
"def read(id=nil)\r\n request = Net::HTTP.new(@uri.host, @uri.port)\r\n if id.nil?\r\n response = request.get(\"#{@uri.path}.xml\") \r\n else\r\n response = request.get(\"#{@uri.path}/#{id}.xml\") \r\n end\r\n response.body\r\n end",
"def index\n @aisles = Aisle.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @aisles }\n end\n end",
"def download_xml\n\t\turi = URI.parse(\"http://www.esmadrid.com/opendata/tiendas_v1_es.xml\")\n\t\tresponse = Net::HTTP.get_response(uri)\n\t\tcontent = response.body\n\n\t\txml = REXML::Document.new(content)\n\n\t\treturn xml\n\tend",
"def show\n @lore = Lore.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lore }\n end\n end",
"def index\n @leks = Lek.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @leks }\n end\n end",
"def index\n @cuentas = Cuenta.all\n\n @cadena = getcuentasxml\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @cadena }\n end\n end",
"def read(id=nil)\n request = Net::HTTP.new(@uri.host, @uri.port)\n if id.nil?\n response = request.get(\"#{@uri.path}.xml\")\n else\n response = request.get(\"#{@uri.path}/#{id}.xml\")\n end\n\n response.body\n end",
"def index\n @lancamentos = Lancamento.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lancamentos }\n end\n end",
"def show\n @lien = Lien.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lien }\n end\n end",
"def index\n @clienteles = @paramun.clienteles\n\n respond_to do |format|\n if @clienteles.empty?\n format.xml { render request.format.to_sym => \"ccliErreurA\" } ## Aucune Clientele\n else \n format.xml { render xml: @clienteles }\n end\n end\n end",
"def new\n @leilao = Leilao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @leilao }\n end\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @alimentos }\n end\n end",
"def path\n \"/onca/xml\"\n end",
"def show\n @silo = Silo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @silo }\n end\n end",
"def show\n @aisle = Aisle.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @aisle }\n end\n end",
"def list\n @oyoyos = Oyoyo.find (:all)\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @oyoyo }\n end\n \nend",
"def index\n @uitgelichts = Uitgelicht.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @uitgelichts }\n end\n end",
"def index\n @estatus = Estatu.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @estatus }\n end\n end",
"def index\n @tipo_lancamentos = TipoLancamento.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tipo_lancamentos }\n end\n end",
"def show\n @legislacion = Legislacion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @legislacion }\n end\n end",
"def show\n @analisis = Analisis.find(params[:id])\n\n respond_to do |format|\n format.xml { render :xml => @analisis }\n end\n end",
"def show\n @estatu = Estatu.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @estatu }\n end\n end",
"def index\n @feria2010observaciones = Feria2010observacion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @feria2010observaciones }\n end\n end",
"def show\n @nossos_servico = NossosServico.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @nossos_servico }\n end\n end",
"def index\n @aluminis = Alumini.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @aluminis }\n end\n end",
"def index\n @annees = Annee.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @annees }\n end\n end",
"def show\n @estudiante = Estudiante.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @estudiante }\n end\n end",
"def show\n @estudiante = Estudiante.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @estudiante }\n end\n end",
"def index\n @solicitudes = Solicitud.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @solicitudes }\n end\n end",
"def show\n @livro = Livro.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @livro }\n end\n end",
"def index\n @personals = Personal.all\n\n cadena = getpersonals(@personals)\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => cadena }\n end\n end",
"def show\n @relatestagiario = Relatestagiario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @relatestagiario }\n end\n end",
"def show\n @lancamento = Lancamento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lancamento }\n end\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @documentos }\n end\n end",
"def index\n @datos = Dato.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @datos }\n end\n end",
"def show\n @estagio = Estagio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @estagio }\n end\n end",
"def show\n @lek = Lek.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lek }\n end\n end",
"def index\n @unidades = Unidad.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @unidades }\n end\n end",
"def index\n @oils = Oil.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @oils }\n end\n end",
"def show\n @ordendetalle = Ordendetalle.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ordendetalle }\n end\n end",
"def show\n @offlearn = Offlearn.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @offlearn }\n end\n end",
"def show\n @logotype = Logotype.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @logotype }\n end\n end",
"def show\n @estagiarios = Estagiario.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @estagiarios }\n end\n end",
"def index\n @eventos = Evento.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @eventos }\n end\n end",
"def show\n @lance_unico = LanceUnico.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lance_unico }\n end\n end",
"def show\n @log_pelea_guilty = LogPeleaGuilty.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @log_pelea_guilty }\n end\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @ciclos }\n end\n end",
"def get_xml(url, options = {})\n\t\t\t\n\t\t\t# better way of doing this?\n\t\t\t# Map custom keys to the HTTP request values\n\t\t\treqs = {\n\t\t\t\t:character_name => 'n',\n\t\t\t\t:realm => 'r',\n\t\t\t\t:search => 'searchQuery',\n\t\t\t\t:type => 'searchType',\n\t\t\t\t:guild_name => 'n',\n\t\t\t\t:item_id => 'i',\n\t\t\t\t:team_size => 'ts',\n\t\t\t\t:team_name => 't',\n\t\t\t\t:group => 'group'\n\t\t\t}\n\t\t\t\n\t\t\t\n\t\t\tparams = []\n\t\t\toptions.each do |key, value|\n\t\t\t\tparams << \"#{reqs[key]}=#{u(value)}\" if reqs[key]\n\t\t\tend\n\t\t\t\n\t\t\tquery = '?' + params.join('&') if params.size > 0\n\t\t\t\n\t\t\tbase = self.base_url(options[:locale], options)\n\t\t\tfull_query = base + url + query\n\t\t\t\n\t\t\tputs full_query if options[:debug]\n\t\t\t\n\t\t\tif options[:caching]\n\t\t\t\tresponse = get_cache(full_query, options)\n\t\t\telse\n\t\t\t\tresponse = http_request(full_query, options)\n\t\t\tend\n\t\t\t\t\t\t\n\t\t\tdoc = Hpricot.XML(response)\n\t\t\terrors = doc.search(\"*[@errCode]\")\n\t\t\tif errors.size > 0\nbegin\n\t\t\t\terrors.each do |error|\n\t\t\t\t\traise Wowr::Exceptions::raise_me(error[:errCode], options)\n\t\t\t\tend\nrescue\nend\n\t\t\telsif (doc%'page').nil?\n\t\t\t\traise Wowr::Exceptions::EmptyPage\n\t\t\telse\n\t\t\t\treturn (doc%'page')\n\t\t\tend\n\t\tend",
"def index\n @legislacions = Legislacion.busqueda(params[:page], params[:generico], params[:buscar], 20)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @legislacions }\n end\n end",
"def index\n @documentos = @externo.documentos.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @documentos }\n end\n end",
"def show\n @tso = Tso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tso.to_xml(:except => [ :created_at, :updated_at ]) }\n end\n end",
"def show\n @platillo = Platillo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @platillo }\n end\n end",
"def show\n @lyric = Lyric.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lyric }\n end\n end",
"def show\n @lyric = Lyric.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lyric }\n end\n end",
"def index\n @aautos = Aauto.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @aautos }\n end\n end",
"def index\n debugger\n @receitas = Receita.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @receitas }\n end\n end",
"def index\n @loans = Loan.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @loans }\n end\n end",
"def show\n @imovel = Imovel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @imovel }\n end\n end",
"def new\n @lieu = Lieu.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lieu }\n end\n end",
"def show\n @tipo_lancamento = TipoLancamento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tipo_lancamento }\n end\n end",
"def index\n @clientes = Cliente.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @clientes }\n end\n end",
"def show\n @lsrs_soildata = LsrsSoil.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lsrs_soildata }\n end\n end",
"def index\n @tipo_restaurantes = TipoRestaurante.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tipo_restaurantes }\n end\n end",
"def index\n @avisos = Aviso.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @avisos }\n end\n end",
"def show\n @situacoes_juridica = SituacoesJuridica.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @situacoes_juridica }\n end\n end",
"def show\n @uslugi = Uslugi.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @uslugi }\n end\n end",
"def new\n @omatsuri = Omatsuri.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @omatsuri }\n end\n end",
"def index\n @omatsuris = Omatsuri.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @omatsuris }\n format.json { render :json => @omatsuris }\n end\n end",
"def show\n @uitgelicht = Uitgelicht.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @uitgelicht }\n end\n end",
"def show\n @estacion = Estacion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @estacion }\n end\n end",
"def show\n @olark = Olark.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @olark }\n end\n end",
"def index\n @asistencias = Asistencia.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @asistencias }\n end\n end",
"def show\n @relatorios = Relatorio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @relatorios }\n end\n end",
"def index\n name = @xml.elements['/name'].text\n @sentence = \"Hello #{name} !\"\n render_xml\n end",
"def index\n @users = User.all\n render :xml => @users\n end",
"def index\n # @ideias = Ideia.all\n @ideias = Ideia.where(:status => '3')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @ideias }\n end\n end",
"def new\n @lote = Lote.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lote }\n end\n end",
"def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tipo_recibo }\n end\n end",
"def index\n @nodes = Node.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @nodes }\n end\n end",
"def index\n @nodes = Node.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @nodes }\n end\n end",
"def index\n @modeles = Modele.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @modeles }\n end\n end",
"def index\n @tipo_notas = TipoNota.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tipo_notas }\n end\n end",
"def show\n @elemento = Elemento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @elemento }\n end\n end",
"def show\n @nostro = Nostro.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @nostro }\n end\n end",
"def show\n @oyoyo = Oyoyo.find(params[:id])\n\n respond_to do |s|\n s.html # show.html.erb\n s.xml { render :xml => @oyoyo }\n end\n end",
"def show\n @tipo_de_documento = TipoDeDocumento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tipo_de_documento }\n end\n end",
"def index\n @boms = Bom.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @boms }\n end\n end",
"def show\n @pessoa = Pessoa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @pessoa }\n end\n end",
"def show\n @lotto_type = LottoType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lotto_type }\n end\n end",
"def show\n @glosario = Glosario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @glosario }\n end\n end",
"def show\n @reclamo = Reclamo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @reclamo }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @instituto }\n end\n end",
"def index\n @requests = Request.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @requests }\n end\n end"
] | [
"0.6636714",
"0.64375603",
"0.64191407",
"0.63023424",
"0.63012815",
"0.62957734",
"0.626545",
"0.62618005",
"0.6166575",
"0.6150047",
"0.60904324",
"0.60896915",
"0.60833794",
"0.6079378",
"0.60776573",
"0.6071869",
"0.6053767",
"0.6053576",
"0.60315585",
"0.601692",
"0.601537",
"0.5996373",
"0.5986228",
"0.5964157",
"0.59450716",
"0.5941409",
"0.59218484",
"0.5914466",
"0.5906871",
"0.5895231",
"0.5889905",
"0.5865569",
"0.5863393",
"0.58608073",
"0.5859642",
"0.5859184",
"0.5854389",
"0.5853159",
"0.58499813",
"0.5845368",
"0.58365667",
"0.58287907",
"0.5811246",
"0.5809302",
"0.5806854",
"0.58036786",
"0.57865393",
"0.5785096",
"0.57719004",
"0.5769615",
"0.5754961",
"0.57526314",
"0.57486475",
"0.57451886",
"0.5743007",
"0.5738972",
"0.5735675",
"0.57338625",
"0.57285637",
"0.57207185",
"0.57207185",
"0.57144517",
"0.5712993",
"0.57033813",
"0.5702874",
"0.57026017",
"0.5697142",
"0.56957",
"0.5690999",
"0.56906456",
"0.5688925",
"0.5687891",
"0.5686575",
"0.567643",
"0.56761646",
"0.5674483",
"0.5673143",
"0.56730175",
"0.5672507",
"0.56665665",
"0.56616664",
"0.5660902",
"0.56593704",
"0.5658714",
"0.56570864",
"0.56529784",
"0.56529784",
"0.5644676",
"0.5643849",
"0.56418306",
"0.5641071",
"0.5640961",
"0.56406426",
"0.5638861",
"0.5634314",
"0.5631356",
"0.5624548",
"0.56224823",
"0.5620808",
"0.5618073"
] | 0.6682231 | 0 |
GET /leilaos/new GET /leilaos/new.xml | def new
@leilao = Leilao.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @leilao }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @lien = Lien.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lien }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end",
"def new\n @lote = Lote.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lote }\n end\n end",
"def new\n @node = Node.scopied.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end",
"def new\n @omatsuri = Omatsuri.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @omatsuri }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nomina }\n end\n end",
"def new\n @nostro = Nostro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nostro }\n end\n end",
"def new\n @lieu = Lieu.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lieu }\n end\n end",
"def new\n @lore = Lore.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lore }\n end\n end",
"def new\n @silo = Silo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @silo }\n end\n end",
"def new\n @po = Po.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @po }\n end\n end",
"def new\n @nossos_servico = NossosServico.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nossos_servico }\n end\n end",
"def new\n @estatu = Estatu.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @estatu }\n end\n end",
"def new\n @pessoa = Pessoa.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pessoa }\n end\n end",
"def new\n @pessoa = Pessoa.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pessoa }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @instituto }\n end\n end",
"def new\n @tso = Tso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tso }\n end\n end",
"def new\n @plantilla = Plantilla.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @plantilla }\n end\n end",
"def new\n @recurso = Recurso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @recurso }\n end\n end",
"def new\n @lancamento = Lancamento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lancamento }\n end\n end",
"def new\n @solicitud = Solicitud.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @solicitud }\n end\n end",
"def new\n @aisle = Aisle.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @aisle }\n end\n end",
"def new\n @nota = Nota.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nota }\n end\n end",
"def new\n @nota = Nota.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nota }\n end\n end",
"def new\n @domino = Domino.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @domino }\n end\n end",
"def new\n @tpago = Tpago.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tpago }\n end\n end",
"def new\n @estacion = Estacion.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @estacion }\n end\n end",
"def new\n @proceso = Proceso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @proceso }\n end\n end",
"def new\n @elemento = Elemento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @elemento }\n end\n end",
"def new\n @estagio = Estagio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @estagio }\n end\n end",
"def new\n @estudiante = Estudiante.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @estudiante }\n end\n end",
"def new\n @nom = Nom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nom }\n end\n end",
"def new\n @documento = Documento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @documento }\n end\n end",
"def new\n @relatestagiario = Relatestagiario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @relatestagiario }\n end\n end",
"def new\n @newz = Newz.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @newz }\n end\n end",
"def new\n @novel = Novel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @novel }\n end\n end",
"def new\n @platillo = Platillo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @platillo }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ontology }\n end\n end",
"def new\n @puesto = Puesto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @puesto }\n end\n end",
"def new\n @olark = Olark.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @olark }\n end\n end",
"def new\n @tipo_nota = TipoNota.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tipo_nota }\n end\n end",
"def new\n @peca = Peca.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @peca }\n end\n end",
"def new\n @lotto_type = LottoType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lotto_type }\n end\n end",
"def new\n @spiel = Spiel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @spiel }\n end\n end",
"def new\n @todo = Todo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @todo }\n end\n end",
"def new\n @todo = Todo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @todo }\n end\n end",
"def new\n @tipo_lancamento = TipoLancamento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tipo_lancamento }\n end\n end",
"def new\n @request = Request.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @request }\n end\n end",
"def new\n @request = Request.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @request }\n end\n end",
"def new\n @request = Request.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @request }\n end\n end",
"def new\n @request = Request.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @request }\n end\n end",
"def new\n @node = Node.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end",
"def new\n @node = Node.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end",
"def new\n @vestimenta = Vestimenta.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @vestimenta }\n end\n end",
"def new\n @tipo_lista = TipoLista.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tipo_lista }\n end\n end",
"def new\n @noami = Noami.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @noami }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml \n end\n end",
"def new\n @tiposproceso = Tiposproceso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tiposproceso }\n end\n end",
"def new\n @remocao = Remocao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @remocao }\n end\n end",
"def new\n @aplicacion = Aplicacion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @aplicacion }\n end\n end",
"def new\n @todos = Todos.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @todos }\n end\n end",
"def new\n @colo = Colo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @colo }\n end\n end",
"def new\n @lek = Lek.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lek }\n end\n end",
"def new\n @ponto = Ponto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ponto }\n end\n end",
"def new\n @geoname = Geoname.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @geoname }\n end\n end",
"def new\n @want = Want.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @want }\n end\n end",
"def new\n @evento = Evento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @evento }\n end\n end",
"def new\n @dato = Dato.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @dato }\n end\n end",
"def new\n @dato = Dato.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @dato }\n end\n end",
"def new\n @annee = Annee.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @annee }\n end\n end",
"def new\n @dossier = Dossier.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @dossier }\n end\n end",
"def new\n @aviso = Aviso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @aviso }\n end\n end",
"def new\n @uitgelicht = Uitgelicht.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @uitgelicht }\n end\n end",
"def new\n @regiaos = Regiao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @regiaos }\n end\n end",
"def new\n @tipo_de_documento = TipoDeDocumento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tipo_de_documento }\n end\n end",
"def create\n @lien = Lien.new(params[:lien])\n\n respond_to do |format|\n if @lien.save\n flash[:notice] = 'Lien was successfully created.'\n format.html { redirect_to(@lien) }\n format.xml { render :xml => @lien, :status => :created, :location => @lien }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lien.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @precio = Precio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @precio }\n end\n end",
"def new\n @url_migration = UrlMigration.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @url_migration }\n end\n end",
"def new\n @receita = Receita.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @receita }\n end\n end",
"def new\n @legislacion = Legislacion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @legislacion }\n end\n end",
"def new\n @tipo_proy = TipoProy.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tipo_proy }\n end\n end",
"def new\n @relatorios = Relatorio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @relatorios }\n end\n end",
"def new\n @reclamo = Reclamo.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @reclamo }\n end\n \n end",
"def new\n respond_to do |format|\n format.html\n format.xml\n end\n end",
"def new\n @echo = Echo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @echo }\n end\n end",
"def new\n @tservicio = Tservicio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tservicio }\n end\n end",
"def new\n @contrato = Contrato.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @contrato }\n end\n end",
"def new\n @protocolo = Protocolo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @protocolo }\n end\n end",
"def new\n @serie = Serie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @serie }\n end\n end",
"def new\n @tcliente = Tcliente.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tcliente }\n end\n end",
"def new \n @how_to = HowTo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render xml: @how_to }\n end\n end",
"def new\n @imovel = Imovel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @imovel }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ciclo }\n end\n end",
"def new\n @periodista = Periodista.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @periodista }\n end\n end",
"def new\n @senhas = Senha.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @senhas }\n end\n end",
"def new\n @produto = ProdutoSimples.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @produto }\n end\n end",
"def new\n @wro = Wro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @wro }\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @system }\n end\n end",
"def new\n @adjunto = Adjunto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @adjunto }\n end\n end",
"def new\n @norma = Norma.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @norma }\n end\n end"
] | [
"0.73974955",
"0.7360316",
"0.726974",
"0.7250252",
"0.7227784",
"0.72236747",
"0.71942735",
"0.71741647",
"0.71721184",
"0.7165546",
"0.71629995",
"0.7161596",
"0.7156797",
"0.71560305",
"0.71560305",
"0.7120607",
"0.7087882",
"0.7071855",
"0.7070232",
"0.70670885",
"0.70603514",
"0.7043647",
"0.7019",
"0.7019",
"0.70135504",
"0.70039916",
"0.6997134",
"0.6996998",
"0.69933456",
"0.69926006",
"0.69754326",
"0.69708276",
"0.69679374",
"0.6967639",
"0.69583505",
"0.6954623",
"0.6953439",
"0.69441074",
"0.69422424",
"0.6937895",
"0.6934823",
"0.6932059",
"0.6930369",
"0.6926271",
"0.6924278",
"0.6924278",
"0.69209504",
"0.6914143",
"0.6914143",
"0.6914143",
"0.69107527",
"0.6908597",
"0.6908597",
"0.69049656",
"0.689765",
"0.6896239",
"0.6895364",
"0.6894784",
"0.6892679",
"0.6892507",
"0.68909365",
"0.6889433",
"0.6889213",
"0.68851066",
"0.68835735",
"0.6881187",
"0.6873031",
"0.68724835",
"0.68724835",
"0.68692833",
"0.68689626",
"0.6868933",
"0.68668723",
"0.6863737",
"0.6861334",
"0.68598545",
"0.68573797",
"0.68560505",
"0.68542594",
"0.6852289",
"0.6850733",
"0.6848161",
"0.684769",
"0.68441975",
"0.6843227",
"0.684256",
"0.6841489",
"0.6841146",
"0.68383723",
"0.68318963",
"0.68316156",
"0.6830738",
"0.6827812",
"0.6820359",
"0.6818409",
"0.6816522",
"0.68142223",
"0.68123966",
"0.6809167",
"0.6808526"
] | 0.7479105 | 0 |
POST /leilaos POST /leilaos.xml | def create
@leilao = Leilao.new(params[:leilao])
respond_to do |format|
if @leilao.save
flash[:notice] = 'Leilao was successfully created.'
format.html { redirect_to(@leilao) }
format.xml { render :xml => @leilao, :status => :created, :location => @leilao }
else
format.html { render :action => "new" }
format.xml { render :xml => @leilao.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(name=\"Default Name\", age=\"50\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <name>#{name}</name>\r\n <age>#{age}</age>\r\n </person>\"\r\n \r\n request = Net::HTTP::Post.new(@url)\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n \r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n response.body \r\n end",
"def create\n doc = Nokogiri::XML(request.body.read)\n cvNode = doc.xpath('elwak/checklisten_vorlage')\n cv = ChecklistenVorlage.new({\n objekt_id: cvNode.xpath('objekt_id').text.to_s, \n bezeichner: cvNode.xpath('bezeichner').text.to_s, \n version: cvNode.xpath('version').text.to_s.to_i, \n inaktiv: cvNode.xpath('inaktiv').text.to_s.to_bool \n })\n cv.save\n\n cvNode.xpath('checklisten_eintrags/checklisten_eintrag').each do |ceNode|\n ce = ChecklistenEintrag.new({\n checklisten_vorlage_id: cv.id,\n bezeichner: ceNode.xpath('bezeichner').text.to_s,\n was: ceNode.xpath('was').text.to_s,\n wann: ceNode.xpath('wann').text.to_s,\n typ: ceNode.xpath('typ').text.to_s.to_i,\n position: ceNode.xpath('position').text.to_s.to_i\n })\n ce.save\n end\n\n respond_to do |format|\n format.xml {render :xml => '<?xml version=\"1.0\" encoding=\"UTF-8\"?><success />'}\n end\n end",
"def post(xmldoc)\n headers = {'Content-Type' => 'text/xml'}\n check_response( @httpcli.post(@endpoint, xmldoc, headers) )\n end",
"def post(body)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true if uri.scheme == 'https'\n\n request = Net::HTTP::Post.new(uri)\n request['Content-Type'] = 'text/xml'\n request['Accept-Language'] = locale if locale\n request.body = body\n\n response = http.request(request)\n\n Response.new(response, uri)\n end",
"def create(name=\"Default name\")\n xml_req =\n \"<?xml version='1.0' encoding='UTF-8'?>\n <customer>\n <name>#{name}</name>\n </customer>\"\n\n request = Net::HTTP::Post.new(@url)\n request.add_field \"Content-Type\", \"application/xml\"\n request.body = xml_req\n\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n response.body\n end",
"def post_xml(url, ls_data)\n uri = URI.parse(url)\n request = Net::HTTP::Post.new(uri.request_uri, HEADER_XML)\n request.body = ls_data\n request.basic_auth(@nsx_user, @nsx_password)\n response = Net::HTTP.start(uri.host, uri.port, :use_ssl => true,\n :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |https|\n https.request(request)\n end\n return response.body if check_response(response, 201)\n end",
"def post(uri, xml)\r\n req = Net::HTTP::Post.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def create\n @lote = Lote.new(params[:lote])\n\n respond_to do |format|\n if @lote.save\n flash[:notice] = 'Lote was successfully created.'\n format.html { redirect_to(@lote) }\n format.xml { render :xml => @lote, :status => :created, :location => @lote }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lote.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n doc = Nokogiri::XML(request.body.read)\n bNode = doc.xpath('elwak/benutzer')\n\n @benutzer = Benutzer.new(benutzer_params(bNode))\n if @benutzer.save\n if bNode.xpath('objekt_zuordnungs').length > 0\n objekt_ids = bNode.xpath('objekt_zuordnungs/objekt_id').map{|oz| oz.text.to_s.to_i}\n @benutzer.setze_objekt_zuordnungen(objekt_ids)\n end\n success(@benutzer.id)\n else\n error(@benutzer.errors)\n end\n end",
"def create\n @leito = Leito.new(params[:leito])\n\n respond_to do |format|\n if @leito.save\n format.html { redirect_to @leito, notice: 'Leito was successfully created.' }\n format.json { render json: @leito, status: :created, location: @leito }\n else\n format.html { render action: \"new\" }\n format.json { render json: @leito.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @aisle = Aisle.new(params[:aisle])\n\n respond_to do |format|\n if @aisle.save\n format.html { redirect_to(@aisle, :notice => 'Aisle was successfully created.') }\n format.xml { render :xml => @aisle, :status => :created, :location => @aisle }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @aisle.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @resultadoconsultum = Resultadoconsultum.new(resultadoconsultum_params)\n\t\n\n\trequire 'nokogiri'\n\t\n\t@doc = Nokogiri::XML(File.open(\"exemplos/emplo.xml\"))\n\n\tcar_tires = @doc.xpath(\"//firstname\")\n\t\n\tdoc = Nokogiri::XML(File.open(\"emplo.xml\"))\n\tdoc.xpath('firstname').each do\n\t\tcar_tires\n\tend\n\n\t \n respond_to do |format|\n if @resultadoconsultum.save\n format.html { redirect_to @resultadoconsultum, notice: car_tires }\n format.json { render :show, status: :created, location: @resultadoconsultum }\n else\n format.html { render :new }\n format.json { render json: @resultadoconsultum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @estagio = Estagio.new(params[:estagio])\n\n respond_to do |format|\n if @estagio.save\n flash[:notice] = 'Estagio was successfully created.'\n format.html { redirect_to(@estagio) }\n format.xml { render :xml => @estagio, :status => :created, :location => @estagio }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @estagio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @lieu = Lieu.new(params[:lieu])\n\n respond_to do |format|\n if @lieu.save\n format.html { redirect_to(@lieu, :notice => 'Lieu was successfully created.') }\n format.xml { render :xml => @lieu, :status => :created, :location => @lieu }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lieu.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @domino = Domino.new(params[:domino])\n\n respond_to do |format|\n if @domino.save\n flash[:notice] = 'Domino was successfully created.'\n format.html { redirect_to(@domino) }\n format.xml { render :xml => @domino, :status => :created, :location => @domino }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @domino.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post_request(params, useSSL=false)\n # get a server handle\n port = (useSSL == true) ? 443 : 80\n http_server = Net::HTTP.new(API_HOST, port)\n http_server.use_ssl = useSSL\n \n # build a request\n http_request = Net::HTTP::Post.new(API_PATH_REST)\n http_request.form_data = params\n \n # get the response XML\n return http_server.start{|http| http.request(http_request)}.body\n end",
"def create\n @ordendetalle = Ordendetalle.new(params[:ordendetalle])\n\n respond_to do |format|\n if @ordendetalle.save\n format.html { redirect_to(@ordendetalle, :notice => 'Ordendetalle was successfully created.') }\n format.xml { render :xml => @ordendetalle, :status => :created, :location => @ordendetalle }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ordendetalle.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @lek = Lek.new(params[:lek])\n\n respond_to do |format|\n if @lek.save\n format.html { redirect_to(@lek, :notice => 'Lek was successfully created.') }\n format.xml { render :xml => @lek, :status => :created, :location => @lek }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lek.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post(url_variables:, body:)\n ensure_service_document\n\n end",
"def create\n @elemento = Elemento.new(params[:elemento])\n\n respond_to do |format|\n if @elemento.save\n flash[:notice] = 'Elemento was successfully created.'\n format.html { redirect_to(@elemento) }\n format.xml { render :xml => @elemento, :status => :created, :location => @elemento }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @elemento.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @platillo = Platillo.new(params[:platillo])\n\n respond_to do |format|\n if @platillo.save\n format.html { redirect_to(@platillo, :notice => 'Platillo was successfully created.') }\n format.xml { render :xml => @platillo, :status => :created, :location => @platillo }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @platillo.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @estudiante = Estudiante.new(params[:estudiante])\n\n respond_to do |format|\n if @estudiante.save\n flash[:notice] = 'Creado.'\n format.html { redirect_to(@estudiante) }\n format.xml { render :xml => @estudiante, :status => :created, :location => @estudiante }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @estudiante.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @estatu = Estatu.new(params[:estatu])\n\n respond_to do |format|\n if @estatu.save\n format.html { redirect_to(@estatu, :notice => 'Registro creado correctamente.') }\n format.xml { render :xml => @estatu, :status => :created, :location => @estatu }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @estatu.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post(method, params = {})\n url = make_url method, params\n query = url.query\n url.query = nil\n\n req = Net::HTTP::Post.new url.path\n req.body = query\n req.content_type = 'application/x-www-form-urlencoded'\n\n res = Net::HTTP.start url.host, url.port do |http|\n http.request req\n end\n\n xml = Nokogiri::XML(res.body, nil, nil, 0)\n\n check_error xml\n\n parse_response xml\n rescue SystemCallError, SocketError, Timeout::Error, IOError,\n Nokogiri::XML::SyntaxError => e\n raise CommunicationError.new(e)\n rescue Net::HTTPError => e\n xml = Nokogiri::XML(e.res.body) { |cfg| cfg.strict }\n check_error xml\n raise CommunicationError.new(e)\n end",
"def create\n @estudiante = Estudiante.new(params[:estudiante])\n\n respond_to do |format|\n if @estudiante.save\n format.html { redirect_to(@estudiante, :notice => 'Estudiante was successfully created.') }\n format.xml { render :xml => @estudiante, :status => :created, :location => @estudiante }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @estudiante.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @selecciones = Seleccion.where(\"cliente_id = ?\",usuario_actual.id)\n @peso_total = Seleccion.peso_total(usuario_actual.id)\n @precio_total = Seleccion.precio_total(usuario_actual.id)\n @tarjetas = usuario_actual.tdc\n \n #Cobro en el banco\n client = Savon::Client.new(\"http://localhost:3001/servicios/wsdl\")\n tdc = Tarjeta.where(\"id = ? AND cliente_id = ?\",params[:orden][:tarjeta_id],usuario_actual.id)\n total_pagar = params[:orden][:total]\n pago = '<Message>\n <Request>\n <numero_tdc>'+tdc.numero+'</numero_tdc>\n <nombre_tarjetahabiente>'+tdc.tarjetahabiente+'</nombre_tarjetahabiente>\n <fecha_vencimiento>'+tdc.mes_vencimiento+'/'+tdc.ano_vencimiento+'</fecha_vencimiento>\n <codigo_seguridad>'+tdc.codigo+'</codigo_seguridad>\n <tipo_tarjeta>'+tdc.tipo+'</tipo_tarjeta>\n <direccion_cobro>'+tdc.direccion+'</direccion_cobro>\n <total_pagar>'+total_pagar+'</total_pagar>\n <cuenta_receptora>'+cuenta_receptora+'</cuenta_receptora>\n </Request>\n </Message>'\n #response = client.request :verificar_pago, body: { \"value\" => pago } \n #if response.success?\n # data = response.to_hash[:verificar_pago_response][:value][:response].first\n # @respuesta = XmlSimple.xml_in(data)\n #end\n\n #NAMESPACE = 'pagotdc'\n #URL = 'http://localhost:8080/'\n #banco = SOAP::RPC::Driver.new(URL, NAMESPACE)\n #banco.add_method('verificar_pago', 'numero_tdc', 'nombre_tarjetahabiente', 'fecha_vencimiento', 'codigo_seguridad', 'tipo_tarjeta', 'direccion_cobro', 'total_pagar', 'cuenta_receptora')\n #\n \n #respuesta = banco.verificar_pago(tdc.numero, tdc.tarjetahabiente, tdc.mes_vencimiento.to_s+'/'+tdc.ano_vencimiento.to_s, tdc.codigo, tdc.tipo, params[:orden][:total], tdc.direccion)\n \n if true #respuesta.ack.eql?(0)\n params[:orden][:cliente_id] = usuario_actual.id\n params[:orden][:total] = Seleccion.precio_total(usuario_actual.id)\n params[:orden][:fecha_entrega] = \"0000-00-00\"\n @orden = Orden.new(params[:orden])\n \n if @orden.save\n @selecciones = Seleccion.where(\"cliente_id = ?\",usuario_actual.id)\n @selecciones.each do |seleccion|\n p = Producto.find(seleccion.producto_id)\n @venta = Venta.new(:producto_id=>p.id, \n :orden_id=>@orden.id,\n :categoria_id=>p.categoria_id, \n :cantidad=>seleccion.cantidad,\n :costo=>p.precio)\n @venta.save\n end\n \n Seleccion.vaciar_carro(usuario_actual.id)\n respond_to do |format|\n format.html { redirect_to ver_ordenes_path, notice: 'Orden generada correctamente.' }\n end\n else\n respond_to do |format|\n format.html { render action: \"new\" }\n end\n end\n else\n respond_to do |format|\n format.html { render action: \"new\", notice: respuesta.mensaje }\n end\n end\n end",
"def create\n @legislacion = Legislacion.new(params[:legislacion])\n\n respond_to do |format|\n if @legislacion.save\n flash[:notice] = 'Legislacion se ha creado con exito.'\n format.html { redirect_to(admin_legislacions_url) }\n format.xml { render :xml => @legislacion, :status => :created, :location => @legislacion }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @legislacion.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @lien = Lien.new(params[:lien])\n\n respond_to do |format|\n if @lien.save\n flash[:notice] = 'Lien was successfully created.'\n format.html { redirect_to(@lien) }\n format.xml { render :xml => @lien, :status => :created, :location => @lien }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lien.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post_save xml, options={:mapping=>:_default}\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/loan/v1\")\n end",
"def post\n response = HTTParty.post(servlet_url,\n :body => to_xml,\n :headers => { 'Content-Type' => 'application/xml' }\n ).response\n\n return Dhl::Shipment::Response.new(response.body)\n rescue Exception => e\n request_xml = if @to_xml.to_s.size>0\n @to_xml\n else\n '<not generated at time of error>'\n end\n\n response_body = if (response && response.body && response.body.to_s.size > 0)\n response.body\n else\n '<not received at time of error>'\n end\n\n log_level = if e.respond_to?(:log_level)\n e.log_level\n else\n :critical\n end\n\n log_request_and_response_xml(log_level, e, request_xml, response_body )\n raise e\n end",
"def new\n @leilao = Leilao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @leilao }\n end\n end",
"def create\n @adjunto = Adjunto.new(params[:adjunto])\n\n respond_to do |format|\n if @adjunto.save\n format.html { redirect_to(@adjunto, :notice => 'Adjunto was successfully created.') }\n format.xml { render :xml => @adjunto, :status => :created, :location => @adjunto }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @adjunto.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n megam_rest.post_node(to_hash)\n end",
"def create\n @oligo_order = OligoOrder.new(params[:oligo_order])\n\n respond_to do |format|\n if @oligo_order.save\n flash[:notice] = 'OligoOrder was successfully created.'\n format.html { redirect_to(@oligo_order) }\n format.xml { render :xml => @oligo_order, :status => :created, :location => @oligo_order }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @oligo_order.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @orc_empenho_iten = OrcEmpenhoIten.new(params[:orc_empenho_iten])\n\n respond_to do |format|\n if @orc_empenho_iten.save\n flash[:notice] = 'SALVO COM SUCESSO.'\n format.html { redirect_to(@orc_empenho_iten) }\n format.xml { render :xml => @orc_empenho_iten, :status => :created, :location => @orc_empenho_iten }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @orc_empenho_iten.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @lei = Lei.new(params[:lei])\n\n respond_to do |format|\n if @lei.save\n format.html { redirect_to @lei, notice: 'Lei was successfully created.' }\n format.json { render json: @lei, status: :created, location: @lei }\n else\n format.html { render action: \"new\" }\n format.json { render json: @lei.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @oyoyo = Oyoyo.new(params[:oyoyo])\n\n respond_to do |format|\n if @oyoyo.save\n flash[:notice] = 'Oyoyo was successfully created.'\n format.html { redirect_to(@oyoyo) }\n format.xml { render :xml => @oyoyo, :status => :created, :location => @oyoyo }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @oyoyo.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @estagiarios = Estagiario.new(params[:estagiario])\n\n respond_to do |format|\n if @estagiarios.save\n flash[:notice] = 'ESTAGIÁRIO CADASTRADO COM SUCESSO.'\n format.html { redirect_to(@estagiarios) }\n format.xml { render :xml => @estagiarios, :status => :created, :location => @estagiarios }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @estagiarios.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post(resource, params)\n case resource\n when \"pedidos\", \"place_order\", \"new_order\" then url = \"/pedidos\"\n when \"envios\", \"shipping\" then url = \"/envios\"\n else url = \"/#{resource}\"\n end\n\n post_request(url, params)\n end",
"def create\n @lore = Lore.new(params[:lore])\n\n respond_to do |format|\n if @lore.save\n format.html { redirect_to(@lore, :notice => 'Lore was successfully created.') }\n format.xml { render :xml => @lore, :status => :created, :location => @lore }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lore.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @puesto = Puesto.new(params[:puesto])\n\n respond_to do |format|\n if @puesto.save\n flash[:notice] = 'Puesto was successfully created.'\n format.html { redirect_to(@puesto) }\n format.xml { render :xml => @puesto, :status => :created, :location => @puesto }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @puesto.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @tipo_lancamento = TipoLancamento.new(params[:tipo_lancamento])\n\n respond_to do |format|\n if @tipo_lancamento.save\n flash[:notice] = 'TipoLancamento was successfully created.'\n format.html { redirect_to(tipo_lancamentos_path) }\n format.xml { render :xml => @tipo_lancamento, :status => :created, :location => @tipo_lancamento }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @tipo_lancamento.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @relatorios = Relatorio.new(params[:relatorio])\n\n respond_to do |format|\n if @relatorios.save\n flash[:notice] = 'RELATÓRIO CADASTRADO COM SUCESSO.'\n format.html { redirect_to(@relatorios) }\n format.xml { render :xml => @relatorios, :status => :created, :location => @relatorios }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @relatorios.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post_config(url_prefix, xml)\n post_data(url_prefix, xml, 'application/xml;charset=UTF-8')\n end",
"def create\n @orc_uni_despesa = OrcUniDespesa.new(params[:orc_uni_despesa])\n\n respond_to do |format|\n if @orc_uni_despesa.save\n flash[:notice] = 'SALVO COM SUCESSO.'\n format.html { redirect_to(@orc_uni_despesa) }\n format.xml { render :xml => @orc_uni_despesa, :status => :created, :location => @orc_uni_despesa }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @orc_uni_despesa.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @tipo_telefone = TipoTelefone.new(params[:tipo_telefone])\n\n respond_to do |format|\n if @tipo_telefone.save\n flash[:notice] = 'TipoTelefone was successfully created.'\n format.html { redirect_to(@tipo_telefone) }\n format.xml { render :xml => @tipo_telefone, :status => :created, :location => @tipo_telefone }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @tipo_telefone.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @neela = Neela.new(neela_params)\n\n respond_to do |format|\n if @neela.save\n format.html { redirect_to @neela, notice: 'Neela was successfully created.' }\n format.json { render :show, status: :created, location: @neela }\n else\n format.html { render :new }\n format.json { render json: @neela.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @offlearn = Offlearn.new(params[:offlearn])\n\n respond_to do |format|\n if @offlearn.save\n flash[:notice] = 'Offlearn was successfully created.'\n format.html { redirect_to(@offlearn) }\n format.xml { render :xml => @offlearn, :status => :created, :location => @offlearn }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @offlearn.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @relatestagiario = Relatestagiario.new(params[:relatestagiario])\n\n respond_to do |format|\n if @relatestagiario.save\n flash[:notice] = 'RELATÓRIO SALVO COM SUCESSO.'\n format.html { redirect_to(@relatestagiario) }\n format.xml { render :xml => @relatestagiario, :status => :created, :location => @relatestagiario }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @relatestagiario.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @tipo_de_documento = TipoDeDocumento.new(params[:tipo_de_documento])\n\n respond_to do |format|\n if @tipo_de_documento.save\n format.html { redirect_to(@tipo_de_documento, :notice => 'Tipo de documento cadastrado com sucesso.') }\n format.xml { render :xml => @tipo_de_documento, :status => :created, :location => @tipo_de_documento }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @tipo_de_documento.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @omatsuri = Omatsuri.new(params[:omatsuri])\n\n respond_to do |format|\n if @omatsuri.save\n flash[:notice] = 'Omatsuri was successfully created.'\n format.html { redirect_to(@omatsuri) }\n format.xml { render :xml => @omatsuri, :status => :created, :location => @omatsuri }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @omatsuri.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @lancamento = Lancamento.new(params[:lancamento])\n\n respond_to do |format|\n if @lancamento.save\n flash[:notice] = 'Lancamento foi criado com sucesso!'\n format.html { redirect_to(lancamentos_path) }\n format.xml { render :xml => @lancamento, :status => :created, :location => @lancamento }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lancamento.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create(params)\n\nxml =<<XML\n<entry xmlns=\"http://purl.org/atom/ns#\">\n <title>#{params[:title]}</title>\n <link rel=\"related\" type=\"text/html\" href=\"#{params[:url]}\" />\n <summary type=\"text/plain\">#{params[:comment]}</summary>\n</entry>\nXML\n\n post('/post', xml)\n end",
"def create\n @regiaos = Regiao.new(params[:regiao])\n\n respond_to do |format|\n if @regiaos.save\n flash[:notice] = 'REGIÃO SALVA COM SUCESSO'\n format.html { redirect_to(new_regiao_path)}\n format.xml { render :xml => @regiaos, :status => :created, :location => @regiaos }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @regiaos.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def POST; end",
"def create\n @tipomensaje = Tipomensaje.new(params[:tipomensaje])\n\n respond_to do |format|\n if @tipomensaje.save\n flash[:notice] = 'Tipomensaje was successfully created.'\n format.html { redirect_to(@tipomensaje) }\n format.xml { render :xml => @tipomensaje, :status => :created, :location => @tipomensaje }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @tipomensaje.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post(path, params={})\n signature_params = params.values.any?{|value| value.respond_to?(:to_io)} ? {} : params\n request(:post, path, params.to_xml, signature_params)\n end",
"def create\n @topes_legale = TopesLegale.new(topes_legale_params)\n\n respond_to do |format|\n if @topes_legale.save\n format.html { redirect_to @topes_legale, notice: 'Tope legal creado exitosamente.' }\n format.json { render :show, status: :created, location: @topes_legale }\n else\n format.html { render :new }\n format.json { render json: @topes_legale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n \n @selecciones = Seleccion.where(\"cliente_id = ?\",usuario_actual.id)\n respond_to do |format|\n unless @selecciones.empty?\n @peso_total = Seleccion.peso_total(usuario_actual.id)\n @precio_total = Seleccion.precio_total(usuario_actual.id)\n @tarjetas = usuario_actual.tdc\n @orden = Orden.new(:direccion_entrega=>usuario_actual.direccion)\n t = Time.now\n fecha = t.strftime(\"%Y-%m-%d\")\n client = Savon::Client.new(\"http://192.168.1.121/DistribuidorFIF/webservices/servicio.php?wsdl\")\n preorden = \"<solicitud_pedido>\n <num_orden>001</num_orden>\n <nombre_comercio>Tukiosquito</nombre_comercio>\n <fecha_solicitud>\"+fecha.to_s+\"</fecha_solicitud>\n <nombre_cliente>\"+usuario_actual.nombre+\" \"+usuario_actual.apellido+\"</nombre_cliente>\n <direccion_comercio>\n <avenida>Sucre</avenida>\n <calle>-</calle>\n <edificio_casa>CC Millenium</edificio_casa>\n <local_apt>C1-15</local_apt>\n <parroquia>Leoncio Martinez</parroquia>\n <municipio>Sucre</municipio>\n <ciudad>Caracas</ciudad>\n <estado>Miranda</estado>\n <pais>Venezuela</pais>\n </direccion_comercio>\n <direccion_destino>\n <avenida>Santa Rosa</avenida>\n <calle>Tierras Rojas</calle>\n <edificio_casa>Villa Magica</edificio_casa>\n <local_apt>69</local_apt>\n <parroquia> </parroquia>\n <municipio>Zamora</municipio>\n <ciudad>Cua</ciudad>\n <estado>Miranda</estado>\n <pais>Venezuela</pais>\n </direccion_destino>\"\n @selecciones.each do |seleccion|\n p = Producto.find(seleccion.producto_id)\n preorden = preorden+\"\n <articulo>\n <id>\"+p.id.to_s+\"</id>\n <descripcion>\"+p.descripcion+\"</descripcion>\n <peso>\"+p.peso.to_s+\"</peso>\n <cantidad>\"+seleccion.cantidad.to_s+\"</cantidad>\n <precio>\"+p.precio.to_s+\"</precio>\n </articulo>\"\n end\n preorden = preorden+\"</solicitud_pedido>\"\n response = client.request :ejemplo, body: { \"value\" => preorden } \n if response.success? \n respuesta = response.to_hash[:ejemplo_response][:return]\n datos = XmlSimple.xml_in(respuesta)\n end\n\n @precio_envio = datos[\"num_orden\"][0]\n #@arreglo = XmlSimple.xml_in('')\n #@xml = XmlSimple.xml_out(@arreglo, { 'RootName' => 'solicitud_pedido' })\n #url = 'http://192.168.1.101/Antonio/tukyosquito/proyecto/servicio/servicio.php'\n #cotizacion = SOAP::RPC::Driver.new(url)\n #cotizacion.add_method('obtener','asd')\n #tdc = Tarjeta.where(\"id = ? AND cliente_id = ?\",params[:orden][:tarjeta_id],usuario_actual.id)\n #@respuesta = cotizacion.obtener('123')\n format.html # new.html.erb\n else\n format.html { redirect_to carrito_path, notice: 'No tiene productos agregados al carro de compras para generar una orden.' }\n end\n end\n end",
"def create\n @rendezvouz = Rendezvouz.new(params[:rendezvouz])\n\n respond_to do |format|\n if @rendezvouz.save\n flash[:notice] = 'Rendezvouz was successfully created.'\n format.html { redirect_to(@rendezvouz) }\n format.xml { render :xml => @rendezvouz, :status => :created, :location => @rendezvouz }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @rendezvouz.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @nostro = Nostro.new(params[:nostro])\n\n respond_to do |format|\n if @nostro.save\n flash[:notice] = 'Nostro was successfully created.'\n format.html { redirect_to(@nostro) }\n format.xml { render :xml => @nostro, :status => :created, :location => @nostro }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @nostro.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @loo = Loo.new(loo_params)\n\n respond_to do |format|\n if @loo.save\n format.html { redirect_to @loo, notice: 'Loo was successfully created.' }\n format.json { render :show, status: :created, location: @loo }\n else\n format.html { render :new }\n format.json { render json: @loo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pessoa = Pessoa.new(params[:pessoa])\n\n respond_to do |format|\n if @pessoa.save\n flash[:notice] = 'Pessoa was successfully created.'\n format.html { redirect_to(@pessoa) }\n format.xml { render :xml => @pessoa, :status => :created, :location => @pessoa }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @pessoa.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def moip_post\n @nasp_rail = NaspRail.new(params[:nasp_rail])\n\n format.html { redirect_to @nasp_rail, :notice => 'Nova entrada criada com sucesso.' }\n format.json { render :json => @nasp_rail, :status => :created, :location => @nasp_rail }\n end",
"def create\n @cargo_eleicao = CargoEleicao.new(params[:cargo_eleicao])\n\n respond_to do |format|\n if @cargo_eleicao.save\n format.html { redirect_to @cargo_eleicao, notice: 'Cargo eleicao was successfully created.' }\n format.json { render json: @cargo_eleicao, status: :created, location: @cargo_eleicao }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cargo_eleicao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_nodes_with_root\n serialize_service.post_nodes_serialized\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 to_xml\n http.body\n end",
"def create\r\n @doctipo = Doctipo.new(params[:doctipo])\r\n \r\n\r\n respond_to do |format|\r\n if @doctipo.save\r\n \r\n flash[:notice] = 'EL tipo d edocumento fue creado exitosamente.'\r\n format.html { redirect_to(flash[:back] || @doctipo) }\r\n format.xml { render :xml => @doctipo, :status => :created, :location => @doctipo }\r\n\r\n else\r\n format.html { render :action => \"new\" }\r\n format.xml { render :xml => @doctipo.errors, :status => :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @entradas = Entrada.new(params[:entrada])\n\n respond_to do |format|\n if @entradas.save\n flash[:notice] = 'LANÇAMENTO ENTRADA EFETUADO'\n format.html { redirect_to(homes_path) }\n format.xml { render :xml => @entradas, :status => :created, :location => @entradas }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @entradas.errors, :status => :unprocessable_entity }\n end\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 create\n @note = Note.new(params[:note])\n\n respond_to do |format|\n if @note.save\n format.xml { render :xml => @note.to_xml(:methods => [:tag_list]), :status => 200}\n else\n format.xml { render :xml => @note.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @nebulosa = Nebulosa.new(nebulosa_params)\n\n respond_to do |format|\n if @nebulosa.save\n format.html { redirect_to @nebulosa, notice: 'Nebulosa was successfully created.' }\n format.json { render :show, status: :created, location: @nebulosa }\n else\n format.html { render :new }\n format.json { render json: @nebulosa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def process(xml)\n timeout(TIMEOUT) do\n url = URI.parse(webservices_url)\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n http.start {\n request = Net::HTTP::Post.new(url.to_s)\n request.body = xml\n response = http.request(request)\n response.body\n }\n end\n end",
"def send_request( xml )\n write( xml )\n read\n end",
"def new\n @lote = Lote.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lote }\n end\n end",
"def create\n @eleitore = Eleitore.new(eleitore_params)\n\n respond_to do |format|\n if @eleitore.save\n format.html { redirect_to @eleitore, notice: 'Eleitore was successfully created.' }\n format.json { render :show, status: :created, location: @eleitore }\n else\n format.html { render :new }\n format.json { render json: @eleitore.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @lancamento = Lancamento.new(params[:lancamento])\n\n respond_to do |format|\n if @lancamento.save\n flash[:notice] = 'Lançamento cadastrado com sucesso.'\n #format.html { redirect_to(@lancamento) }\n format.html { redirect_to(lancamentos_path) }\n format.xml { render :xml => @lancamento, :status => :created, :location => @lancamento }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lancamento.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @nossos_servico = NossosServico.new(params[:nossos_servico])\n\n respond_to do |format|\n if @nossos_servico.save\n format.html { redirect_to(@nossos_servico, :notice => 'Nossos servico was successfully created.') }\n format.xml { render :xml => @nossos_servico, :status => :created, :location => @nossos_servico }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @nossos_servico.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post_save xml, options={:mapping=>:_default}\n # using REXML's element namespace method doesn't seem to set the namespace correctly...?\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/institutionlogin/v1\")\n xml.root.add_namespace \"xsi\", \"http://www.w3.org/2001/XMLSchema-instance\"\n xml.root.add_namespace \"xsd\", \"http://www.w3.org/2001/XMLSchema\"\n # for challengeResponses/response\n xml.each_element(\"//response\") do |x|\n x.add_namespace \"v11\", \"http://schema.intuit.com/platform/fdatafeed/challenge/v1\"\n x.name = \"v11:response\"\n end\n # for challengeResponses root\n xml.each_element(\"//challengeResponses\") do |x|\n x.add_namespace \"v1\", \"http://schema.intuit.com/platform/fdatafeed/institutionlogin/v1\"\n x.name = \"challengeResponses\"\n end\n end",
"def create\n @dokuei = Dokuei.new(params[:dokuei])\n\n respond_to do |format|\n if @dokuei.save\n format.html { redirect_to(@dokuei, :notice => 'Dokuei was successfully created.') }\n format.xml { render :xml => @dokuei, :status => :created, :location => @dokuei }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @dokuei.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n params.permit!\n @silo = Silo.new(params[:silo])\n\n respond_to do |format|\n if @silo.save\n format.html { redirect_to(@silo, :notice => 'Silo was successfully created.') }\n format.xml { render :xml => @silo, :status => :created, :location => @silo }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @silo.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def http_post(request, response)\n path = request.path\n\n # Only handling xml\n content_type = request.header('Content-Type')\n return nil unless content_type.index('application/xml') || content_type.index('text/xml')\n\n # Making sure the node exists\n begin\n node = @server.tree.node_for_path(path)\n rescue Dav::Exception::NotFound\n return nil\n end\n\n request_body = request.body_as_string\n\n # If this request handler could not deal with this POST request, it\n # will return 'null' and other plugins get a chance to handle the\n # request.\n #\n # However, we already requested the full body. This is a problem,\n # because a body can only be read once. This is why we preemptively\n # re-populated the request body with the existing data.\n request.body = request_body\n\n document_type_box = Box.new('')\n message = @server.xml.parse(request_body, request.url, document_type_box)\n document_type = document_type_box.value\n\n case document_type\n # Dealing with the 'share' document, which modified invitees on a\n # calendar.\n when \"{#{Plugin::NS_CALENDARSERVER}}share\"\n # We can only deal with IShareableCalendar objects\n return true unless node.is_a?(IShareableCalendar)\n\n @server.transaction_type = 'post-calendar-share'\n\n # Getting ACL info\n acl = @server.plugin('acl')\n\n # If there's no ACL support, we allow everything\n acl.check_privileges(path, '{DAV:}write') if acl\n\n node.update_shares(message.set, message.remove)\n\n response.status = 200\n # Adding this because sending a response body may cause issues,\n # and I wanted some type of indicator the response was handled.\n response.update_header('X-Sabre-Status', 'everything-went-well')\n\n # Breaking the event chain\n return false\n # The invite-reply document is sent when the user replies to an\n # invitation of a calendar share.\n when \"{#{Plugin::NS_CALENDARSERVER}}invite-reply\"\n\n # This only works on the calendar-home-root node.\n return true unless node.is_a?(CalendarHome)\n\n @server.transaction_type = 'post-invite-reply'\n\n # Getting ACL info\n acl = @server.plugin('acl')\n\n # If there's no ACL support, we allow everything\n acl.check_privileges(path, '{DAV:}write') if acl\n\n url = node.share_reply(\n message.href,\n message.status,\n message.calendar_uri,\n message.in_reply_to,\n message.summary\n )\n\n response.status = 200\n # Adding this because sending a response body may cause issues,\n # and I wanted some type of indicator the response was handled.\n response.update_header('X-Sabre-Status', 'everything-went-well')\n\n if url\n writer = @server.xml.writer\n writer.open_memory\n writer.start_document\n writer.start_element(\"{#{Plugin::NS_CALENDARSERVER}}shared-as\")\n writer.write(Dav::Xml::Property::Href.new(url))\n writer.end_element\n response.update_header('Content-Type', 'application/xml')\n response.body = writer.output_memory\n end\n\n # Breaking the event chain\n return false\n when \"{#{Plugin::NS_CALENDARSERVER}}publish-calendar\"\n # We can only deal with IShareableCalendar objects\n return true unless node.is_a?(IShareableCalendar)\n\n @server.transaction_type = 'post-publish-calendar'\n\n # Getting ACL info\n acl = @server.plugin('acl')\n\n # If there's no ACL support, we allow everything\n acl.check_privileges(path, '{DAV:}write') if acl\n\n node.publish_status = true\n\n # iCloud sends back the 202, so we will too.\n response.status = 202\n\n # Adding this because sending a response body may cause issues,\n # and I wanted some type of indicator the response was handled.\n response.update_header('X-Sabre-Status', 'everything-went-well')\n\n # Breaking the event chain\n return false\n when \"{#{Plugin::NS_CALENDARSERVER}}unpublish-calendar\"\n # We can only deal with IShareableCalendar objects\n return true unless node.is_a?(IShareableCalendar)\n\n @server.transaction_type = 'post-unpublish-calendar'\n\n # Getting ACL info\n acl = @server.plugin('acl')\n\n # If there's no ACL support, we allow everything\n acl.check_privileges(path, '{DAV:}write') if acl\n\n node.publish_status = false\n\n response.status = 200\n\n # Adding this because sending a response body may cause issues,\n # and I wanted some type of indicator the response was handled.\n response.update_header('X-Sabre-Status', 'everything-went-well')\n\n # Breaking the event chain\n return false\n end\n end",
"def create\n @suministro = Suministro.new(params[:suministro])\n\n respond_to do |format|\n if @suministro.save\n format.html { redirect_to(@suministro, :notice => 'Suministro was successfully created.') }\n format.xml { render :xml => @suministro, :status => :created, :location => @suministro }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @suministro.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def setorden\n @xml = params[:solicitud]\n @arreglo = Orden.validarRemota(@xml)\n if !(@arreglo.nil?)\n # @cliente = Persona.new(@xml[:cliente])\n # @cliente.save\n\n # @tarjeta = @xml[:tarjeta]\n # @tarjeta = TipoPago.new(@tarjeta)\n # @tarjeta.personas_id = @cliente.id\n # @tarjeta.save\n\n # @recoleccion = Direccion.new(@xml[:direccionrecoleccion])\n @entrega = Direccion.new(@xml[:direccionentrega])\n # @recoleccion.save\n @entrega.save\n\n @orden = Orden.new(@xml[:orden])\n @orden.estado = 'Pendiente por recolectar'\n @orden.personas_id= @arreglo[0]\n @orden.save\n\n @paquete = Paquete.new(@xml[:paquete])\n @paquete.ordens_id = @orden.id\n @paquete.personas_id = @arreglo[0]\n @paquete.save\n\n @historico1= Historico.new(:ordens_id => @orden.id, :direccions_id => @arreglo[2], :tipo => 'Recolectada')\n @historico= Historico.new(:ordens_id => @orden.id, :direccions_id => @entrega.id, :tipo => 'Entregada')\n @historico1.save\n @historico.save\n \n @monto = Enviar.montoTotal(@orden.id)\n @iva = (@monto * 0.12).round(2)\n @montototal = @monto + @iva\n Enviar.compania\n @factura = Factura.new(:companias_id => 1, :ordens_id =>@orden.id , :tipo_pagos_id => @arreglo[1] , :costoTotal => @monto ,:iva => @iva)\n @factura.save\n else\n render \"errorxml\"\n end\n end",
"def create\n @director = Director.find(params[:director_id])\n @soaps = @director.soaps.create(soap_params)\n redirect_to director_path(@director)\n\n\n end",
"def download_xml\n\t\turi = URI.parse(\"http://www.esmadrid.com/opendata/tiendas_v1_es.xml\")\n\t\tresponse = Net::HTTP.get_response(uri)\n\t\tcontent = response.body\n\n\t\txml = REXML::Document.new(content)\n\n\t\treturn xml\n\tend",
"def create\n @elemento = Elemento.new(elemento_params)\n\n respond_to do |format|\n if @elemento.save\n format.html { redirect_to @elemento, notice: 'Elemento fue creado con exito.' }\n format.json { render :show, status: :created, location: @elemento }\n else\n format.html { render :new }\n format.json { render json: @elemento.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_xml_64(xml=:example_response)\n post \"/auth/saml/callback\", {'SAMLResponse' => load_xml_64(xml)}\nend",
"def create\n @alejandro = Alejandro.new(alejandro_params)\n\n respond_to do |format|\n if @alejandro.save\n format.html { redirect_to @alejandro, notice: 'Alejandro was successfully created.' }\n format.json { render :show, status: :created, location: @alejandro }\n else\n format.html { render :new }\n format.json { render json: @alejandro.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @orden = Orden.new(params[:orden])\n @usuario = Usuario.find(@orden.usuario_id)\n respond_to do |format|\n if @orden.save\n flash[:notice] = 'La Orden de Trabajo fue exitosamente generada.'\n Notificador.deliver_nueva_tarea(@usuario)\n format.html { redirect_to(:action => \"show\", :id => @orden) }\n format.xml { render :xml => @orden, :status => :created, :location => @orden }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @orden.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post_save xml, options={:mapping=>:_default}\n # using REXML's element namespace method doesn't seem to set the namespace correctly...?\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/institutionlogin/v1\")\n xml.root.add_namespace \"xsi\", \"http://www.w3.org/2001/XMLSchema-instance\"\n xml.root.add_namespace \"xsd\", \"http://www.w3.org/2001/XMLSchema\"\n # for challengeResponses/response\n xml.each_element(\"//response\") do |x| \n x.add_namespace \"v11\", \"http://schema.intuit.com/platform/fdatafeed/challenge/v1\"\n x.name = \"v11:response\"\n end\n # for challengeResponses root\n xml.each_element(\"//challengeResponses\") do |x| \n x.add_namespace \"v1\", \"http://schema.intuit.com/platform/fdatafeed/institutionlogin/v1\"\n x.name = \"challengeResponses\"\n end\n end",
"def create\n @lede = Lede.new(params[:lede])\n\n respond_to do |format|\n if @lede.save\n format.html { redirect_to @lede, notice: 'Lede was successfully created.' }\n format.json { render json: @lede, status: :created, location: @lede }\n else\n format.html { render action: \"new\" }\n format.json { render json: @lede.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @eou = Eou.new(params[:eou])\n\n respond_to do |format|\n if @eou.save\n format.html { redirect_to @eou, :notice => 'Eou was successfully created.' }\n format.json { render :json => @eou, :status => :created, :location => @eou }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @eou.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @unidad = Unidad.new(params[:unidad])\n p params[:unidad]\n \n respond_to do |format|\n if @unidad.save\n flash[:notice] = 'Unidad was successfully created.'\n format.html { redirect_to(@unidad) }\n format.xml { render :xml => @unidad, :status => :created, :location => @unidad }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @unidad.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @depositocaucion = Depositocaucion.new(@depositocaucionnuevo)\n respond_to do |format|\n if @depositocaucion.save\n flash[:notice] = 'Depositocaucion was successfully created.'\n format.html { redirect_to(@depositocaucion) }\n format.xml { render :xml => @depositocaucion, :status => :created, :location => @depositocaucion }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @depositocaucion.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @unidades = Unidade.new(params[:unidade])\n respond_to do |format|\n if @unidades.save\n flash[:notice] = 'UNIDADE CADASTRADA COM SUCESSO.'\n format.html { redirect_to(@unidades) }\n format.xml { render :xml => @unidades, :status => :created, :location => @unidades }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @unidades.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @pessoa = Pessoa.new(params[:pessoa])\n respond_to do |format|\n if @pessoa.save\n format.html { redirect_to(@pessoa, :notice => 'Pessoa cadastrada com sucesso.') }\n format.xml { render :xml => @pessoa, :status => :created, :location => @pessoa }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @pessoa.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n\n @pedidodetalle = Pedidodetalle.new(params[:pedidodetalle])\n\n @pedidodetalles = Pedidodetalle.all\n\n respond_to do |format|\n if @pedidodetalle.save\n format.html { redirect_to pedidodetalles_url, notice: 'Guardado!' }\n else\n render :action => 'index'\n end\n end\n end",
"def post(body)\n request = Net::HTTP::Post.new(bind_uri)\n request.body = body\n request.content_length = request.body.size\n request[\"Content-Type\"] = \"text/xml; charset=utf-8\"\n\n Jabber.debug(\"Sending POST request - #{body.strip}\")\n\n response = Net::HTTP.new(domain, port).start { |http| http.request(request) }\n\n Jabber.debug(\"Receiving POST response - #{response.code}: #{response.body.inspect}\")\n\n unless response.is_a?(Net::HTTPSuccess)\n raise Net::HTTPBadResponse, \"Net::HTTPSuccess expected, but #{response.class} was received\"\n end\n\n response\n end"
] | [
"0.6363825",
"0.6350087",
"0.6256222",
"0.6171393",
"0.6064402",
"0.6039733",
"0.59295046",
"0.57941824",
"0.5787358",
"0.57157487",
"0.5626261",
"0.56200886",
"0.56197876",
"0.5602025",
"0.55950296",
"0.55920094",
"0.55840456",
"0.5570361",
"0.55560124",
"0.5547443",
"0.554257",
"0.55354136",
"0.5529677",
"0.55236197",
"0.55211616",
"0.55165046",
"0.54920447",
"0.5477453",
"0.5472774",
"0.5467564",
"0.5456468",
"0.5452473",
"0.54372364",
"0.54308474",
"0.54079974",
"0.5383911",
"0.5380918",
"0.5368904",
"0.53554606",
"0.53467005",
"0.5343872",
"0.5336911",
"0.53365964",
"0.5332617",
"0.53289044",
"0.5322582",
"0.5320384",
"0.5308884",
"0.5305732",
"0.5304146",
"0.52980924",
"0.5296288",
"0.5292907",
"0.5282141",
"0.52795947",
"0.52786535",
"0.5275158",
"0.5263996",
"0.52633995",
"0.5262667",
"0.5255499",
"0.52529204",
"0.5249677",
"0.5249647",
"0.52485293",
"0.5247803",
"0.5242662",
"0.52404094",
"0.5239941",
"0.52386695",
"0.52329445",
"0.5231087",
"0.5230591",
"0.52304447",
"0.522581",
"0.52196336",
"0.52165353",
"0.52160645",
"0.52116734",
"0.52101856",
"0.5207464",
"0.5202758",
"0.51995885",
"0.51980466",
"0.51958907",
"0.5189774",
"0.5187104",
"0.5184992",
"0.51804775",
"0.5173921",
"0.51730275",
"0.51728773",
"0.516718",
"0.51656556",
"0.5164219",
"0.5161985",
"0.51532525",
"0.5152969",
"0.5144206",
"0.51423347"
] | 0.64394903 | 0 |
PUT /leilaos/1 PUT /leilaos/1.xml | def update
@leilao = Leilao.find(params[:id])
respond_to do |format|
if @leilao.update_attributes(params[:leilao])
flash[:notice] = 'Leilao was successfully updated.'
format.html { redirect_to(@leilao) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @leilao.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def rest_update(uri, method: Net::HTTP::Put)\n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n response = http.request request\n response.value\n\n doc = REXML::Document.new response.body\n \n doc = strip_class_attributes(yield doc)\n \n request2 = method.new uri\n request2.content_type = 'application/xml'\n auth_admin(request2)\n\n request2.body=doc.to_s\n \n response2 = http.request request2\n response.value\n\n end\n \nend",
"def update(id, name=\"Updated Name\", age=\"55\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <id type='integer'>#{id}</id>\r\n <name>#{name}</name>\r\n <age>#{age}</age> \r\n </person>\"\r\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n # no response body will be returned\r\n case response\r\n when Net::HTTPSuccess\r\n return \"#{response.code} OK\"\r\n else\r\n return \"#{response.code} ERROR\"\r\n end\r\n end",
"def update(id, name= \"Updated Name\")\n xml_req =\n \"<?xml version='1.0' encoding='UTF-8'?>\n <customer>\n <id type='integer'>#{id}</id>\n <name>#{name}</name>\n </customer>\"\n\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\n request.add_field \"Content-Type\", \"application/xml\"\n request.body = xml_req\n\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n # no response body will be returned\n case response\n when Net::HTTPSuccess\n return \"#{response.code} OK\"\n else\n return \"#{response.code} ERROR\"\n end\n end",
"def test_put_invoices_1_xml\n @parameters = {:invoice => {:number => 'NewNumber'}}\n \n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/invoices/1.xml',\n {:invoice => {:number => 'NewNumber'}},\n {:success_code => :ok})\n \n assert_no_difference('Invoice.count') do\n put '/invoices/1.xml', @parameters, credentials('admin')\n end\n \n invoice = Invoice.find(1)\n assert_equal \"NewNumber\", invoice.number\n \n end",
"def update\n @estagio = Estagio.find(params[:id])\n\n respond_to do |format|\n if @estagio.update_attributes(params[:estagio])\n flash[:notice] = 'Estagio was successfully updated.'\n format.html { redirect_to(@estagio) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @estagio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def test_put_expenses_1_xml\n @parameters = {:expense => {:description => 'NewDescription'}}\n if ActiveRecord::VERSION::MAJOR < 4\n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/expenses/1.xml',\n {:expense => {:description => 'NewDescription'}},\n {:success_code => :ok})\n end\n\n assert_no_difference('Expense.count') do\n put '/expenses/1.xml', @parameters, credentials('admin')\n end\n\n expense = Expense.find(1)\n assert_equal \"NewDescription\", expense.description\n end",
"def update\n @lote = Lote.find(params[:id])\n\n respond_to do |format|\n if @lote.update_attributes(params[:lote])\n flash[:notice] = 'Lote was successfully updated.'\n format.html { redirect_to(@lote) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lote.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n doc = Nokogiri::XML(request.body.read)\n cvNode = doc.xpath('elwak/checklisten_vorlage')\n\n update_params = {inaktiv: cvNode.xpath('inaktiv').text.to_s.to_bool}\n respond_to do |format|\n if @checklisten_vorlage.update(update_params)\n format.xml {render :xml => '<?xml version=\"1.0\" encoding=\"UTF-8\"?><success />'}\n else\n format.xml {render :xml => '<?xml version=\"1.0\" encoding=\"UTF-8\"?><error />'}\n end\n end\n end",
"def update\n @lieu = Lieu.find(params[:id])\n\n respond_to do |format|\n if @lieu.update_attributes(params[:lieu])\n format.html { redirect_to(@lieu, :notice => 'Lieu was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lieu.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_xml\n self.xml= dumpRouteAsXml\n self.save\n end",
"def update\n params.permit!\n @silo = Silo.find(params[:id])\n\n respond_to do |format|\n if @silo.update_attributes(params[:silo])\n format.html { redirect_to(@silo, :notice => 'Silo was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @silo.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @oligo = Oligo.find(params[:id])\n\n respond_to do |format|\n if @oligo.update_attributes(params[:oligo])\n flash[:notice] = 'Oligo was successfully updated.'\n format.html { redirect_to :action => :index }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @oligo.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put!\n request! :put\n end",
"def update\n @aisle = Aisle.find(params[:id])\n\n respond_to do |format|\n if @aisle.update_attributes(params[:aisle])\n format.html { redirect_to(@aisle, :notice => 'Aisle was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @aisle.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n doc = Nokogiri::XML(request.body.read)\n bNode = doc.xpath('elwak/benutzer')\n\n @benutzer = Benutzer.find(params[:id])\n \n #Sicherstellen, dass Benutzer synchronisiert wird auch wenn nur Objekt-Zuordnungen anders sind!\n @benutzer.updated_at = DateTime.now \n\n if bNode.xpath('objekt_zuordnungs').length > 0\n @benutzer.setze_objekt_zuordnungen(bNode.xpath('objekt_zuordnungs/objekt_id').map{|oz| oz.text.to_s.to_i})\n end\n if @benutzer.update(benutzer_params(bNode))\n success(nil)\n else\n error(@benutzer.errors)\n end\n end",
"def update\n @oyoyo = Oyoyo.find(params[:id])\n\n respond_to do |format|\n if @oyoyo.update_attributes(params[:oyoyo])\n flash[:notice] = 'Oyoyo was successfully updated.'\n format.html { redirect_to(@oyoyo) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @oyoyo.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @leito = Leito.find(params[:id])\n\n respond_to do |format|\n if @leito.update_attributes(params[:leito])\n format.html { redirect_to @leito, notice: 'Leito was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @leito.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_putpoi_update_valid\n nd = create(:node)\n cs_id = nd.changeset.id\n user = nd.changeset.user\n amf_content \"putpoi\", \"/1\", [\"#{user.email}:test\", cs_id, nd.version, nd.id, nd.lon, nd.lat, nd.tags, nd.visible]\n post :amf_write\n assert_response :success\n amf_parse_response\n result = amf_result(\"/1\")\n\n assert_equal 5, result.size\n assert_equal 0, result[0]\n assert_equal \"\", result[1]\n assert_equal nd.id, result[2]\n assert_equal nd.id, result[3]\n assert_equal nd.version + 1, result[4]\n\n # Now try to update again, with a different lat/lon, using the updated version number\n lat = nd.lat + 0.1\n lon = nd.lon - 0.1\n amf_content \"putpoi\", \"/2\", [\"#{user.email}:test\", cs_id, nd.version + 1, nd.id, lon, lat, nd.tags, nd.visible]\n post :amf_write\n assert_response :success\n amf_parse_response\n result = amf_result(\"/2\")\n\n assert_equal 5, result.size\n assert_equal 0, result[0]\n assert_equal \"\", result[1]\n assert_equal nd.id, result[2]\n assert_equal nd.id, result[3]\n assert_equal nd.version + 2, result[4]\n end",
"def update\n @lien = Lien.find(params[:id])\n\n respond_to do |format|\n if @lien.update_attributes(params[:lien])\n flash[:notice] = 'Lien was successfully updated.'\n format.html { redirect_to(@lien) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lien.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @nossos_servico = NossosServico.find(params[:id])\n\n respond_to do |format|\n if @nossos_servico.update_attributes(params[:nossos_servico])\n format.html { redirect_to(@nossos_servico, :notice => 'Nossos servico was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @nossos_servico.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @solexame.update(solexame_params)\n flash[:notice] = 'Solicitação foi alterada com sucesso.'\n format.html { redirect_to(@solexame) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @solexame.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @ontology = SYMPH::Ontology.find(params[:id])\n\n respond_to do |format|\n if @ontology.update_attributes(params[:ontology])\n flash[:notice] = 'Ontology was successfully updated.'\n format.html { redirect_to(ontologies_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ontology.errors, :status => :unprocessable_entity }\n end\n end\n\t\n end",
"def update\r\n @uom = Uom.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @uom.update_attributes(params[:uom])\r\n format.html { redirect_to(@uom, :notice => 'Uom was successfully updated.') }\r\n format.xml { head :ok }\r\n else\r\n format.html { render :action => \"edit\" }\r\n \r\n end\r\n end\r\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def update\n @logotype = Logotype.find(params[:id])\n\n respond_to do |format|\n if @logotype.update_attributes(params[:logotype])\n flash[:notice] = 'Logotype was successfully updated.'\n format.html { redirect_to(@logotype) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @logotype.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def test_should_update_link_via_API_XML\r\n get \"/logout\"\r\n put \"/links/1.xml\", :link => {:user_id => 1,\r\n :title => 'API Link 1',\r\n :url => 'http://www.api.com'}\r\n assert_response 401\r\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 @estatu = Estatu.find(params[:id])\n\n respond_to do |format|\n if @estatu.update_attributes(params[:estatu])\n format.html { redirect_to(@estatu, :notice => 'Registro actualizado correctamente.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @estatu.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @logotype = Logotype.find(params[:id])\n\n respond_to do |format|\n if @logotype.update_attributes(params[:logotype])\n format.html { redirect_to(@logotype, :notice => 'Logotype was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @logotype.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @omatsuri = Omatsuri.find(params[:id])\n\n respond_to do |format|\n if @omatsuri.update_attributes(params[:omatsuri])\n flash[:notice] = 'Omatsuri was successfully updated.'\n format.html { redirect_to(@omatsuri) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @omatsuri.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @estudiante = Estudiante.find(params[:id])\n\n respond_to do |format|\n if @estudiante.update_attributes(params[:estudiante])\n format.html { redirect_to(@estudiante, :notice => 'Estudiante was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @estudiante.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @livro = Livro.find(params[:id])\n respond_to do |format|\n if @livro.update_attributes(params[:livro])\n flash[:notice] = 'Livro was successfully updated.'\n format.html { redirect_to(@livro) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @livro.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @oase = Oasis.find(params[:id])\n\n respond_to do |format|\n if @oase.update_attributes(params[:oase])\n format.html { redirect_to @oase, notice: 'Oasis was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @oase.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @inventario = Inventario.find(params[:id])\n @foto = @inventario.foto\n \n @service = InventarioService.new(@inventario, @foto)\n respond_to do |format|\n\n if @inventario.update_attributes(params[:inventario],params[:foto_file])\n format.html { redirect_to(@inventario, :notice => 'Inventario was successfully updated.') }\n format.xml { head :ok }\n else\n\t @foto = @service.foto\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @inventario.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @estudiante = Estudiante.find(params[:id])\n\n respond_to do |format|\n if @estudiante.update_attributes(params[:estudiante])\n flash[:notice] = 'Actualizado.'\n format.html { redirect_to(@estudiante) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @estudiante.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @tipo_de_documento = TipoDeDocumento.find(params[:id])\n\n respond_to do |format|\n if @tipo_de_documento.update_attributes(params[:tipo_de_documento])\n format.html { redirect_to(@tipo_de_documento, :notice => 'Tipo de documento atualizado com sucesso.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tipo_de_documento.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @elemento = Elemento.find(params[:id])\n\n respond_to do |format|\n if @elemento.update_attributes(params[:elemento])\n flash[:notice] = 'Elemento was successfully updated.'\n format.html { redirect_to(@elemento) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @elemento.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @supervisor_estagio = SupervisorEstagio.find(params[:id])\n\n respond_to do |format|\n if @supervisor_estagio.update_attributes(params[:supervisor_estagio])\n flash[:notice] = 'Supervisor de Estagio atualizado com sucesso.'\n format.html { redirect_to(@supervisor_estagio) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @supervisor_estagio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_object_xml(object_type, id, xml)\n @client.update_business_object_by_public_id({\n :busObNameOrId => object_type,\n :busObPublicId => id,\n :updateXml => xml\n })\n return last_error\n end",
"def update\n @tso = Tso.find(params[:id])\n\n respond_to do |format|\n if @tso.update_attributes(params[:tso])\n flash[:notice] = 'Tso was successfully updated.'\n format.html { redirect_to(@tso) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tso.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\r\n @salle = Salle.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @salle.update_attributes(params[:salle])\r\n format.html { redirect_to @salle, notice: 'Salle was successfully updated.' }\r\n format.json { head :ok }\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @salle.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n @relatorios = Relatorio.find(params[:id])\n\n respond_to do |format|\n if @relatorios.update_attributes(params[:relatorio])\n flash[:notice] = 'RELATORIO SALVO COM SUCESSO.'\n format.html { redirect_to(@relatorios) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @relatorios.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @estagiarios = Estagiario.find(params[:id])\n\n respond_to do |format|\n if @estagiarios.update_attributes(params[:estagiario])\n flash[:notice] = 'ESTAGIÁRIO SALVO COM SUCESSO.'\n format.html { redirect_to(@estagiarios) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @estagiarios.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @lore = Lore.find(params[:id])\n\n respond_to do |format|\n if @lore.update_attributes(params[:lore])\n format.html { redirect_to(@lore, :notice => 'Lore was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lore.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @apoio.update(apoio_params)\n format.html { redirect_to @apoio, notice: 'Apoio was successfully updated.' }\n format.json { render :show, status: :ok, location: @apoio }\n else\n format.html { render :edit }\n format.json { render json: @apoio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_should_update_project_via_API_XML\r\n get \"/logout\"\r\n put \"/projects/1.xml\", :project => {:user_id => 1,\r\n :url => 'http://www.apiproject.com',\r\n :name => 'API Project',\r\n :description => 'API Project Desc' }\r\n assert_response 401\r\n end",
"def test_should_update_invite_via_API_XML\r\n get \"/logout\"\r\n put \"/invites/1.xml\", :invite => {:message => 'API Invite 1',\r\n :accepted => false,\r\n :email => '[email protected]',\r\n :user_id => 1 }\r\n assert_response 401\r\n end",
"def update\n connection.put(element_path, to_xml)\n end",
"def update\n @cargo_eleicao = CargoEleicao.find(params[:id])\n\n respond_to do |format|\n if @cargo_eleicao.update_attributes(params[:cargo_eleicao])\n format.html { redirect_to @cargo_eleicao, notice: 'Cargo eleicao was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cargo_eleicao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @orc_ata = OrcAta.find(params[:id])\n\n respond_to do |format|\n if @orc_ata.update_attributes(params[:orc_ata])\n flash[:notice] = 'SALVO COM SUCESSO'\n format.html { redirect_to(@orc_ata) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @orc_ata.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @serie = Serie.find(params[:id])\n\n respond_to do |format|\n if @serie.update_attributes(params[:serie])\n format.html { redirect_to(niveis_ensino_serie_url(@nivel,@serie), :notice => 'Serie atualizado com sucesso.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @serie.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @lotto_type = LottoType.find(params[:id])\n\n respond_to do |format|\n if @lotto_type.update_attributes(params[:lotto_type])\n format.html { redirect_to(@lotto_type, :notice => 'Lotto type was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lotto_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @osoba = Osoba.find(params[:id])\n\n if @osoba.update(params[:osoba])\n head :no_content\n else\n render json: @osoba.errors, status: :unprocessable_entity\n end\n end",
"def update\n @documentotipo = Documentotipo.find(params[:id])\n\n respond_to do |format|\n if @documentotipo.update_attributes(params[:documentotipo])\n format.html { redirect_to @documentotipo, notice: 'Documentotipo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @documentotipo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(*args)\n request :put, *args\n end",
"def update\n @eou = Eou.find(params[:id])\n\n respond_to do |format|\n if @eou.update_attributes(params[:eou])\n format.html { redirect_to @eou, :notice => 'Eou was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @eou.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @tipo_vinculo = TipoVinculo.find(params[:id])\n\n respond_to do |format|\n if @tipo_vinculo.update_attributes(params[:tipo_vinculo])\n flash[:notice] = 'TipoVinculo was successfully updated.'\n format.html { redirect_to(@tipo_vinculo) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tipo_vinculo.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def edit_axis2XML(carbon_home,http_port,https_port) \n\n\tFile.open(File.join(carbon_home , 'conf','axis2.xml')) do |config_file|\n\t\t# Open the document and edit the port (axis2.xml)\n\t\tconfig = Document.new(config_file)\n\t\t\n\t\tconfig.root.elements[25].elements[1].text=http_port\n\t\tconfig.root.elements[26].elements[1].text=https_port\n\t\n\t\t\n\t\t# Write the result to a new file.\n\t\tformatter = REXML::Formatters::Default.new\n\t\tFile.open(File.join(carbon_home , 'conf','result_axis2.xml'), 'w') do |result|\n\t\tformatter.write(config, result)\n\t\tend\n\tend \n\tFile.delete(File.join(carbon_home , 'conf','axis2.xml'))\n\tFile.rename( File.join(carbon_home , 'conf','result_axis2.xml'),File.join(carbon_home , 'conf','axis2.xml') )\n\nend",
"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 @domino = Domino.find(params[:id])\n\n respond_to do |format|\n if @domino.update_attributes(params[:domino])\n flash[:notice] = 'Domino was successfully updated.'\n format.html { redirect_to(@domino) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @domino.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @aauto = Aauto.find(params[:id])\n\n respond_to do |format|\n if @aauto.update_attributes(params[:aauto])\n format.html { redirect_to(@aauto, :notice => 'Aauto was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @aauto.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @office = Office.find(params[:id])\n\n respond_to do |format|\n if @office.update_attributes(params[:office])\n flash[:notice] = 'Office was successfully updated.'\n format.html { redirect_to(@office) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @office.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def api_xml(path,method=:get,options={})\n xml_message(amee,\"/data\"+path,method,options)\n end",
"def update\n @ovode = Ovode.find_by_url(params[:id])\n\n respond_to do |format|\n if @ovode.update_attributes(params[:ovode])\n format.html { redirect_to @ovode, notice: 'ovode was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ovode.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_update_volumes(username, token, workset_name, volume_ids)\n\n #<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n #<volumes xmlns=\"http://registry.htrc.i3.illinois.edu/entities/workset\">\n # <volume>\n # <id>9999999</id>\n # </volume>\n # <volume>\n # <id>3333333</id>\n # </volume>\n # </volumes>\n volumes_xml =\n \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\" +\n \"<volumes xmlns=\\\"http://registry.htrc.i3.illinois.edu/entities/workset\\\">\";\n\n for id in volume_ids\n volumes_xml += \"<volume><id>#{id}</id></volume>\"\n end\n volumes_xml += \"</volumes>\"\n\n\n # curl -v --data @new_volumes.xml -X PUT \\\n # -H \"Content-Type: application/vnd.htrc-volume+xml\" \\\n # -H \"Accept: application/vnd.htrc-volume+xml\" \\\n # http://localhost:9763/ExtensionAPI-0.1.0/services/worksets/workset1/volumes?user=fred\n\n url = URI.parse(\"#{APP_CONFIG['registry_url']}/worksets/#{workset_name}\")\n http = Net::HTTP.new(url.host, url.port)\n if Rails.env.development?\n http.set_debug_output($stdout)\n end\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Put.new(url.path)\n request[\"Content-Type\"] = \"application/vnd.htrc-volume+xml\"\n request.add_field(\"Authorization\", \"Bearer #{token}\")\n\n request.body = volumes_xml\n response = http.request(request)\n\n #xml = response.body\n\n case response\n when Net::HTTPUnauthorized then\n raise Exceptions::SessionExpiredError.new(\"Session expired. Please login again\")\n when Net::HTTPSuccess then\n # Do nothing\n else\n raise Exceptions::SystemError.new(\"Error retrieving worksets (HTTP #{response.code})\")\n end\n end",
"def update_volumes(username, token, workset_name, volume_ids)\n\n #<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n #<volumes xmlns=\"http://registry.htrc.i3.illinois.edu/entities/workset\">\n # <volume>\n # <id>9999999</id>\n # </volume>\n # <volume>\n # <id>3333333</id>\n # </volume>\n # </volumes>\n volumes_xml =\n \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\" +\n \"<volumes xmlns=\\\"http://registry.htrc.i3.illinois.edu/entities/workset\\\">\";\n\n for id in volume_ids\n volumes_xml += \"<volume><id>#{id}</id></volume>\"\n end\n volumes_xml += \"</volumes>\"\n\n\n # curl -v --data @new_volumes.xml -X PUT \\\n # -H \"Content-Type: application/vnd.htrc-volume+xml\" \\\n # -H \"Accept: application/vnd.htrc-volume+xml\" \\\n # http://localhost:9763/ExtensionAPI-0.1.0/services/worksets/workset1/volumes?user=fred\n\n url = URI.parse(\"#{APP_CONFIG['registry_url']}/worksets/#{workset_name}/volumes\")\n http = Net::HTTP.new(url.host, url.port)\n if Rails.env.development?\n http.set_debug_output($stdout)\n end\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Put.new(url.request_uri)\n request[\"Content-Type\"] = \"application/vnd.htrc-volume+xml\"\n request.add_field(\"Authorization\", \"Bearer #{token}\")\n\n request.body = volumes_xml\n response = http.request(request)\n\n #xml = response.body\n\n case response\n when Net::HTTPUnauthorized then\n raise Exceptions::SessionExpiredError.new(\"Session expired. Please login again\")\n when Net::HTTPSuccess then\n # Do nothing\n else\n raise Exceptions::SystemError.new(\"Error retrieving worksets (HTTP #{response.code})\")\n end\n\n end",
"def put payload, path = \"\"\n make_request(path, \"put\", payload)\n end",
"def update\n @pessoa = Pessoa.find(params[:id])\n\n respond_to do |format|\n if @pessoa.update_attributes(params[:pessoa])\n flash[:notice] = 'Pessoa was successfully updated.'\n format.html { redirect_to(@pessoa) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @pessoa.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @nostro = Nostro.find(params[:id])\n\n respond_to do |format|\n if @nostro.update_attributes(params[:nostro])\n flash[:notice] = 'Nostro was successfully updated.'\n format.html { redirect_to(@nostro) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @nostro.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @orc_suplementacao = OrcSuplementacao.find(params[:id])\n\n respond_to do |format|\n if @orc_suplementacao.update_attributes(params[:orc_suplementacao])\n flash[:notice] = 'SALVO COM SUCESSO.'\n format.html { redirect_to(@orc_suplementacao) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @orc_suplementacao.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def xml(id)\n http.get(\"/nfse/#{id}/xml\") do |response|\n response.headers.fetch(\"Location\") { \"\" }\n end\n end",
"def update\n @suministro = Suministro.find(params[:id])\n\n respond_to do |format|\n if @suministro.update_attributes(params[:suministro])\n format.html { redirect_to(@suministro, :notice => 'Suministro was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @suministro.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(uri, doc = nil, options = {})\n execute(uri, :put, options, doc)\n end",
"def update\n @estoques = Estoque.find(params[:id])\n\n respond_to do |format|\n if @estoques.update_attributes(params[:estoque])\n flash[:notice] = 'ESTOQUE SALVO COM SUCESSO.'\n format.html { redirect_to(@estoques) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @estoques.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @lancamento = Lancamento.find(params[:id])\n\n respond_to do |format|\n if @lancamento.update_attributes(params[:lancamento])\n flash[:notice] = 'Lancamento foi criado com sucesso!'\n format.html { redirect_to(@lancamento) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lancamento.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @lieu = Lieu.find(params[:id])\n\n respond_to do |format|\n if @lieu.update_attributes(params[:lieu])\n format.html { redirect_to @lieu, notice: 'Lieu was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lieu.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @soiree = Soiree.find(params[:id])\n\n respond_to do |format|\n if @soiree.update_attributes(params[:soiree])\n format.html { redirect_to @soiree, notice: 'Soiree was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @soiree.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @loo.update(loo_params)\n format.html { redirect_to @loo, notice: 'Loo was successfully updated.' }\n format.json { render :show, status: :ok, location: @loo }\n else\n format.html { render :edit }\n format.json { render json: @loo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @lei = Lei.find(params[:id])\n\n respond_to do |format|\n if @lei.update_attributes(params[:lei])\n format.html { redirect_to @lei, notice: 'Lei was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lei.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(path = '/files/', params = {})\n request :put, path, params\n end",
"def update\n @node = Node.scopied.find(params[:id])\n\n respond_to do |format|\n if @node.update_attributes(params[:node])\n format.html { redirect_to(@node, :notice => 'Node was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @node.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(id:, url_variables:, body:)\n ensure_service_document\n end",
"def update\n @usuario = Usuario.find(params[:id])\n #@[email protected]\n respond_to do |format|\n if @usuario.update_attributes(params[:usuario])\n format.html { redirect_to(@usuario, :notice => t('exitom')) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @usuario.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @serie = Serie.find(params[:id])\n\n respond_to do |format|\n if @serie.update_attributes(serie_params)\n format.html { redirect_to(@serie, :notice => 'Serie was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @serie.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @evento = Evento.find(params[:id])\n respond_to do |format|\n if @evento.update_attributes(params[:evento])\n flash[:notice] = 'Evento was successfully updated.'\n format.html { redirect_to(@evento) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @evento.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @evento = Evento.find(params[:id])\n\n respond_to do |format|\n if @evento.update_attributes(params[:evento])\n format.html { redirect_to(@evento, :notice => t('cambio')) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @evento.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def update\n @relatestagiario = Relatestagiario.find(params[:id])\n\n respond_to do |format|\n if @relatestagiario.update_attributes(params[:relatestagiario])\n flash[:notice] = 'RELATÓRIO SALVO COM SUCESSO.'\n format.html { redirect_to(@relatestagiario) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @relatestagiario.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @ordendetalle = Ordendetalle.find(params[:id])\n\n respond_to do |format|\n if @ordendetalle.update_attributes(params[:ordendetalle])\n format.html { redirect_to(@ordendetalle, :notice => 'Ordendetalle was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ordendetalle.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @voluntario = Voluntario.find(params[:id])\n params[:voluntario].delete :inclusoes\n\n respond_to do |format|\n if @voluntario.update_attributes(params[:voluntario])\n format.html { redirect_to(@voluntario, :notice => 'Voluntário atualizado com sucesso.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @voluntario.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def _update(type, current_name, metadata={})\n type = type.to_s.camelize\n request :update do |soap|\n soap.body = {\n :metadata => {\n :current_name => current_name,\n :metadata => prepare(metadata),\n :attributes! => { :metadata => { 'xsi:type' => \"ins0:#{type}\" } }\n }\n }\n end\n end",
"def update\n @articulo = Articulo.find(params[:id])\n\n respond_to do |format|\n if @articulo.update_attributes(params[:articulo])\n flash[:notice] = ''\n format.html { redirect_to(articulos_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @articulo.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @evento = Evento.find(params[:id])\n\n respond_to do |format|\n if @evento.update_attributes(params[:evento])\n format.html { redirect_to(@evento, :notice => 'Evento was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @evento.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @os_type = OsType.find(params[:id])\n\n respond_to do |format|\n if @os_type.update_attributes(params[:os_type])\n format.html { redirect_to @os_type, notice: 'Os type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @os_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @boolio.update( boolio_params )\n format.html { redirect_to @boolio, notice: 'Boolio was successfully updated.' }\n format.json { render :show, status: :ok, location: @boolio }\n else\n format.html { render :edit }\n format.json { render json: @boolio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(path, params = {})\n request(:put, path, params)\n end",
"def put(path, params = {})\n request(:put, path, params)\n end",
"def put(path, params = {})\n request(:put, path, params)\n end"
] | [
"0.6548726",
"0.64226365",
"0.6311103",
"0.6209257",
"0.6071829",
"0.5967112",
"0.57638544",
"0.5714797",
"0.57015836",
"0.5687",
"0.56332886",
"0.562034",
"0.56100273",
"0.560201",
"0.5591202",
"0.55870014",
"0.55684",
"0.55666345",
"0.55553526",
"0.5555261",
"0.5554824",
"0.5551469",
"0.5539224",
"0.55219424",
"0.5513222",
"0.54971105",
"0.5492079",
"0.54917",
"0.54864067",
"0.54835",
"0.54739875",
"0.5473646",
"0.5464597",
"0.54561275",
"0.5454115",
"0.54525995",
"0.5451273",
"0.5439734",
"0.5431564",
"0.5431331",
"0.5426253",
"0.5405236",
"0.5399848",
"0.5393629",
"0.5381121",
"0.5375474",
"0.5374535",
"0.53735936",
"0.5366853",
"0.5355268",
"0.53549516",
"0.5353617",
"0.53489345",
"0.5345964",
"0.5342706",
"0.534063",
"0.5339981",
"0.53376245",
"0.5334825",
"0.5331244",
"0.53287464",
"0.53282046",
"0.5326209",
"0.532011",
"0.5318535",
"0.53146815",
"0.5313403",
"0.53124714",
"0.5310743",
"0.5307276",
"0.5278857",
"0.5267788",
"0.52595645",
"0.52585334",
"0.5255692",
"0.52554214",
"0.52550566",
"0.5254339",
"0.52534777",
"0.52529156",
"0.5247715",
"0.5243076",
"0.52420336",
"0.52405494",
"0.5238307",
"0.52374774",
"0.5236362",
"0.52343524",
"0.5230038",
"0.52240855",
"0.52233535",
"0.52216285",
"0.5221492",
"0.521711",
"0.5216149",
"0.52146286",
"0.5211191",
"0.52088714",
"0.52088714",
"0.52088714"
] | 0.619678 | 4 |
DELETE /leilaos/1 DELETE /leilaos/1.xml | def destroy
@leilao = Leilao.find(params[:id])
@leilao.destroy
respond_to do |format|
format.html { redirect_to(leilaos_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def destroy\n @aisle = Aisle.find(params[:id])\n @aisle.destroy\n\n respond_to do |format|\n format.html { redirect_to(aisles_url) }\n format.xml { head :ok }\n end\n end",
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @estudiante = Estudiante.find(params[:id])\n @estudiante.destroy\n\n respond_to do |format|\n format.html { redirect_to(estudiantes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @estudiante = Estudiante.find(params[:id])\n @estudiante.destroy\n\n respond_to do |format|\n format.html { redirect_to(estudiantes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @relatestagiario = Relatestagiario.find(params[:id])\n @relatestagiario.destroy\n\n respond_to do |format|\n format.html { redirect_to(relatestagiarios_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @direccion = Direccion.find(params[:id])\n @direccion.destroy\n\n respond_to do |format|\n format.html { redirect_to(direccions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @elemento = Elemento.find(params[:id])\n @elemento.destroy\n\n respond_to do |format|\n format.html { redirect_to(elementos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @domino = Domino.find(params[:id])\n @domino.destroy\n\n respond_to do |format|\n format.html { redirect_to(dominos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @lieu = Lieu.find(params[:id])\n @lieu.destroy\n\n respond_to do |format|\n format.html { redirect_to(lieus_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @lien = Lien.find(params[:id])\n @lien.destroy\n\n respond_to do |format|\n format.html { redirect_to(liens_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @lien = Lien.find(params[:id])\n @lien.destroy\n\n respond_to do |format|\n format.html { redirect_to(liens_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @estatu = Estatu.find(params[:id])\n @estatu.destroy\n\n respond_to do |format|\n format.html { redirect_to(estatus_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @dossier = Dossier.find(params[:id])\n @dossier.destroy\n\n respond_to do |format|\n format.html { redirect_to(\"/\") }\n format.xml { head :ok }\n end\n end",
"def delete(id)\n request = Net::HTTP::Delete.new(\"#{@url}/#{id}.xml\")\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n # no response body will be returned\n case response\n when Net::HTTPSuccess\n return \"#{response.code} OK\"\n else\n return \"#{response.code} ERROR\"\n end\n end",
"def destroy\n @documento = @externo.documentos.find(params[:id])\n @documento.destroy\n\n respond_to do |format|\n format.html { redirect_to(documentos_url(@externo)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @recurso = Recurso.find(params[:id])\n @recurso.destroy\n\n respond_to do |format|\n format.html { redirect_to(recursos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @documento = Documento.find(params[:id])\n @documento.destroy\n\n respond_to do |format|\n format.html { redirect_to(documentos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @relatorios = Relatorio.find(params[:id])\n @relatorios.destroy\n\n respond_to do |format|\n format.html { redirect_to(homes_path) }\n format.xml { head :ok }\n end\n end",
"def delete(options={})\n connection.delete(\"/\", @name)\n end",
"def destroy\n @remocao = Remocao.find(params[:id])\n @remocao.destroy\n\n respond_to do |format|\n format.html { redirect_to(remocaos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @adjunto = Adjunto.find(params[:id])\n @adjunto.destroy\n\n respond_to do |format|\n format.html { redirect_to(adjuntos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @orc_ficha = OrcFicha.find(params[:id])\n @orc_ficha.destroy\n\n respond_to do |format|\n format.html { redirect_to(orc_fichas_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @tipo_de_documento = TipoDeDocumento.find(params[:id])\n @tipo_de_documento.destroy\n\n respond_to do |format|\n format.html { redirect_to(tipos_de_documento_url) }\n format.xml { head :ok }\n end\n end",
"def destroy1\n @todo = Todo.find(params[:id])\n @todo.destroy\n\n respond_to do |format|\n format.html { redirect_to(todos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @ordendetalle = Ordendetalle.find(params[:id])\n @ordendetalle.destroy\n\n respond_to do |format|\n format.html { redirect_to(ordendetalles_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @dato = Dato.find(params[:id])\n @dato.destroy\n\n respond_to do |format|\n format.html { redirect_to(datos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @dato = Dato.find(params[:id])\n @dato.destroy\n\n respond_to do |format|\n format.html { redirect_to(datos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\r\n @razdel1 = Razdel1.find(params[:id])\r\n @razdel1.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(razdel1s_url) }\r\n format.xml { head :ok }\r\n end\r\n end",
"def destroy\n @lore = Lore.find(params[:id])\n @lore.destroy\n\n respond_to do |format|\n format.html { redirect_to(lores_url) }\n format.xml { head :ok }\n end\n end",
"def deleteResource(doc, msg_from)\n \n \n begin\n\n puts \"Deleting\"\n\n path = \"\"\n params = {}\n headers = {}\n \n context, path = findContext(doc, path) \n \n # Deleting member from group\n if context == :user_group_member\n params = {}\n else\n raise Exception.new(\"No context given!\")\n end\n \n httpAndNotify(path, params, msg_from, :delete)\n \n rescue Exception => e\n puts \"Problem in parsing data (CREATE) from xml or sending http request to the VR server: \" + e\n puts \" -- line: #{e.backtrace[0].to_s}\"\n end\n \n end",
"def destroy\n @plantilla = Plantilla.find(params[:id])\n @plantilla.destroy\n\n respond_to do |format|\n format.html { redirect_to(plantillas_url) }\n format.xml { head :ok }\n end\n end",
"def delete!\n Recliner.delete(uri)\n end",
"def destroy\n @dossier = Dossier.find(params[:id])\n @dossier.destroy\n\n respond_to do |format|\n format.html { redirect_to(dossiers_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @estacion = Estacion.find(params[:id])\n @estacion.destroy\n\n respond_to do |format|\n format.html { redirect_to(estaciones_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @alumini = Alumini.find(params[:id])\n @alumini.destroy\n\n respond_to do |format|\n format.html { redirect_to(aluminis_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @aauto = Aauto.find(params[:id])\n @aauto.destroy\n\n respond_to do |format|\n format.html { redirect_to(aautos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @oligo = Oligo.find(params[:id])\n @oligo.destroy\n\n respond_to do |format|\n format.html { redirect_to(oligos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @estagio = Estagio.find(params[:id])\n @estagio.destroy\n\n respond_to do |format|\n format.html { redirect_to(estagios_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @relatorio = Relatorio.find(params[:id])\n @relatorio.destroy\n\n respond_to do |format|\n format.html { redirect_to(home_path) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @silo = Silo.find(params[:id])\n @silo.destroy\n\n respond_to do |format|\n format.html { redirect_to(silos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @tipo_restaurante = TipoRestaurante.find(params[:id])\n @tipo_restaurante.destroy\n\n respond_to do |format|\n format.html { redirect_to(tipo_restaurantes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @unidad = Unidad.find(params[:id])\n @unidad.destroy\n\n respond_to do |format|\n format.html { redirect_to(unidades_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @reclamacao = Reclamacao.find(params[:id])\n @reclamacao.destroy\n\n respond_to do |format|\n format.html { redirect_to(reclamacaos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @ficha_tematica = FichaTematica.find(params[:id])\n @ficha_tematica.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_ficha_tematicas_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @suministro = Suministro.find(params[:id])\n @suministro.destroy\n\n respond_to do |format|\n format.html { redirect_to(suministros_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @lotes = Lote.find(params[:id])\n @lotes.destroy\n\n respond_to do |format|\n format.html { redirect_to(lotes_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n start { |connection| connection.request http :Delete }\n end",
"def destroy\n @siaikekka = Siaikekka.find(params[:id])\n @siaikekka.destroy\n\n respond_to do |format|\n format.html { redirect_to(siaikekkas_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @lek = Lek.find(params[:id])\n @lek.destroy\n \n\n respond_to do |format|\n format.html { redirect_to(leks_url) }\n format.xml { head :ok }\n end\n end",
"def delete_all(xpath); end",
"def destroy\n @regiaos = Regiao.find(params[:id])\n @regiaos.destroy\n\n respond_to do |format|\n format.html { redirect_to(homes_path) }\n format.xml { head :ok }\n end\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def destroy\n @conteudo = Conteudo.find(params[:id])\n @conteudo.destroy\nt=0\n respond_to do |format|\n format.html { redirect_to(exclusao_path) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @uitgelicht = Uitgelicht.find(params[:id])\n @uitgelicht.destroy\n\n respond_to do |format|\n format.html { redirect_to(uitgelichts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @nom = Nom.find(params[:id])\n @nom.destroy\n\n respond_to do |format|\n format.html { redirect_to(noms_url) }\n format.xml { head :ok }\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 destroy\n @feria2010observacion = Feria2010observacion.find(params[:id])\n @feria2010observacion.destroy\n\n respond_to do |format|\n format.html { redirect_to(feria2010observaciones_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @reclamo = Reclamo.find(params[:id])\n @reclamo.destroy\n\n respond_to do |format|\n format.html { redirect_to(reclamos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @exalumno = @alumno.exalumno\n @exalumno.destroy\n\n respond_to do |format|\n format.html { redirect_to(alumno_path(@alumno)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @coleccionista = Coleccionista.find(params[:id])\n @coleccionista.destroy\n\n respond_to do |format|\n format.html { redirect_to(coleccionistas_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @vehiculo = Vehiculo.find(params[:id])\n @vehiculo.destroy\n\n respond_to do |format|\n format.html { redirect_to(vehiculos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @expedicao = Expedicao.find(params[:id])\n @expedicao.destroy\n\n respond_to do |format|\n format.html { redirect_to(expedicoes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @t1 = T1.find(params[:id])\n @t1.destroy\n\n respond_to do |format|\n format.html { redirect_to(t1s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @omatsuri = Omatsuri.find(params[:id])\n @omatsuri.destroy\n\n respond_to do |format|\n format.html { redirect_to(omatsuris_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @cliente = Cliente.find(params[:id])\n @cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to(clientes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @cliente = Cliente.find(params[:id])\n @cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to(clientes_url) }\n format.xml { head :ok }\n end\n end",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def delete\n request(:delete)\n end",
"def destroy\n @dokuei = Dokuei.find(params[:id])\n @dokuei.destroy\n\n respond_to do |format|\n format.html { redirect_to(dokueis_url) }\n format.xml { head :ok }\n end\n end",
"def delete(id)\r\n connection.delete(\"/#{@doctype}[@ino:id=#{id}]\")\r\n end",
"def destroy\n @tipo_vehiculo = TipoVehiculo.find(params[:id])\n @tipo_vehiculo.destroy\n\n respond_to do |format|\n format.html { redirect_to(tipo_vehiculos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @receita = Receita.find(params[:id])\n @receita.destroy\n\n respond_to do |format|\n format.html { redirect_to(receitas_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @nomina.destroy\n\n respond_to do |format|\n format.html { redirect_to(nominas_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @path = Path.find(params[:id])\n @path.destroy\n\n respond_to do |format|\n format.html { redirect_to(layer_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @rendezvouz = Rendezvouz.find(params[:id])\n @rendezvouz.destroy\n\n respond_to do |format|\n format.html { redirect_to(rendezvouzs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @calidadtiposdocumento = Calidadtiposdocumento.find(params[:id])\n @calidadtiposdocumento.destroy\n\n respond_to do |format|\n format.html { redirect_to(calidadtiposdocumentos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @iguanasactualizacion = Iguanasactualizacion.find(params[:id])\n @iguanasactualizacion.destroy\n\n respond_to do |format|\n format.html { redirect_to(iguanasactualizaciones_url) }\n format.xml { head :ok }\n end\n end",
"def delete(path)\n request(:delete, path)\n end",
"def destroy\n @leito = Leito.find(params[:id])\n @leito.destroy\n\n respond_to do |format|\n format.html { redirect_to leitos_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @lancamento = Lancamento.find(params[:id])\n @lancamento.destroy\n\n respond_to do |format|\n format.html { redirect_to(lancamentos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @reputacao_veiculo = ReputacaoVeiculo.find(params[:id])\n @reputacao_veiculo.destroy\n\n respond_to do |format|\n format.html { redirect_to(reputacao_veiculos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @daicho = Daicho.find(params[:id])\n @daicho.destroy\n\n respond_to do |format|\n format.html { redirect_to(daichos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @child_dupa2 = ChildDupa2.find(params[:id])\n @child_dupa2.destroy\n\n respond_to do |format|\n format.html { redirect_to(child_dupa2s_url) }\n format.xml { head :ok }\n end\n end",
"def delete(*uris); end",
"def destroy\n @tipo_vinculo = TipoVinculo.find(params[:id])\n @tipo_vinculo.destroy\n\n respond_to do |format|\n format.html { redirect_to(tipo_vinculos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @contrato = Contrato.find(params[:id])\n @contrato.destroy\n\n respond_to do |format|\n format.html { redirect_to(contratos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @asistencia = Asistencia.find(params[:id])\n @asistencia.destroy\n\n respond_to do |format|\n format.html { redirect_to(asistencias_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @tipo_conta = TipoConta.find(params[:id])\n @tipo_conta.destroy\n\n respond_to do |format|\n format.html { redirect_to(tipo_contas_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @estagiarios = Estagiario.find(params[:id])\n @estagiarios.destroy\n\n respond_to do |format|\n format.html { redirect_to(homes_path) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @bairro = Bairro.find(params[:id])\n @bairro.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_bairros_path) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @pessoa = Pessoa.find(params[:id])\n @pessoa.destroy\n\n respond_to do |format|\n format.html { redirect_to(pessoas_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @administrativo = Administrativo.find(params[:id])\n @administrativo.destroy\n\n respond_to do |format|\n format.html { redirect_to(administrativos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @tcliente = Tcliente.find(params[:id])\n @tcliente.destroy\n\n respond_to do |format|\n format.html { redirect_to(tclientes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @oyoyo = Oyoyo.find(params[:id])\n @oyoyo.destroy\n\n respond_to do |format|\n format.html { redirect_to(oyoyos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @cabo_eleitoral = CaboEleitoral.find(params[:id])\n @cabo_eleitoral.destroy\n\n respond_to do |format|\n format.html { redirect_to(cabo_eleitorals_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @documentoclasificacion = Documentoclasificacion.find(params[:id])\n @documentoclasificacion.destroy\n\n respond_to do |format|\n format.html { redirect_to(documentoclasificaciones_url) }\n format.xml { head :ok }\n end\n end"
] | [
"0.6976416",
"0.6762079",
"0.6693905",
"0.6679505",
"0.6605138",
"0.6523554",
"0.6515991",
"0.6515894",
"0.6515249",
"0.6499209",
"0.6494185",
"0.64905745",
"0.64905196",
"0.6454576",
"0.6454576",
"0.64431274",
"0.64132154",
"0.6401562",
"0.6393576",
"0.6376159",
"0.6369727",
"0.6367534",
"0.63669735",
"0.6352765",
"0.63441986",
"0.6338842",
"0.63362575",
"0.6335033",
"0.632415",
"0.631563",
"0.631563",
"0.63130766",
"0.6312096",
"0.63119465",
"0.6308002",
"0.6289726",
"0.6282388",
"0.62727296",
"0.6271244",
"0.6270978",
"0.6270025",
"0.62601817",
"0.6254041",
"0.62473416",
"0.6246727",
"0.6245774",
"0.62396336",
"0.623772",
"0.62375796",
"0.6234692",
"0.6233733",
"0.62297684",
"0.6223945",
"0.6218954",
"0.62109435",
"0.62067616",
"0.6204379",
"0.62039876",
"0.6201014",
"0.619916",
"0.6199064",
"0.61973083",
"0.61957395",
"0.6195609",
"0.6195426",
"0.61936766",
"0.6192705",
"0.6183065",
"0.61787784",
"0.61787784",
"0.6174059",
"0.61722946",
"0.61685777",
"0.6168158",
"0.616427",
"0.6162688",
"0.6161577",
"0.6161257",
"0.61592215",
"0.61526966",
"0.6150941",
"0.6147311",
"0.6145348",
"0.6145334",
"0.61449677",
"0.61426497",
"0.6141678",
"0.6140886",
"0.61408436",
"0.6138494",
"0.61358714",
"0.6135698",
"0.613267",
"0.6129839",
"0.6127252",
"0.6125864",
"0.612457",
"0.61219954",
"0.61193305",
"0.6118853"
] | 0.69837344 | 0 |
Attempt to take 3 observations that would violate system constraints. needs autonomy to manage the capacitor selection need autonomy to make sure capacitors don't go too low. | def medium_test
wait(20) # capture results from the easy test...
5.times do
cmd("CFS CFS_WHE_OBS_START")
wait(20)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def restriction \n end",
"def caloric_requirement\n age = current_age\n bmr = basal_metabolic_rate(age)\n if strength == 1\n caloric_requirement_st1(age, bmr).to_i\n elsif strength == 2\n caloric_requirement_st2(age, bmr).to_i\n else\n caloric_requirement_st3(age, bmr).to_i\n end\n end",
"def confusion?\r\n exist? && restriction >= 1 && restriction <= 3\r\n end",
"def script_Perform3 machine, objs\n #skill, pro, con\n con, pro, skill = machine.pop 3\n if objs[:direct]\n con += objs[:direct].first.trait(skill_defense_for(skill))\n end\n if objs[:instrument]\n pro += objs[:instrument].first.trait(skill_aid_for(skill))\n end\n end",
"def restriction\n end",
"def caloric_requirement_st3(age, bmr)\n case age\n when 0..14\n bmr * 1.85\n when 15..17\n bmr * 1.95\n when 18..69\n bmr * 2.00\n else\n bmr * 1.95\n end\n end",
"def other_dependencies\r\n \r\n if self.client_id.present? && self.facility_id.present?\r\n errors[:base] << \"Both Facility and Client cannot be present at a time\" \r\n end \r\n \r\n if crosswalk_level.present?\r\n conditions = \"\"\r\n if crosswalk_level == \"GLOBAL\"\r\n errors[:base] << \"Facility and Client cannot be set when cross walk level is GLOBAL\" if self.facility_id.present? || self.client_id.present? \r\n if self.id?\r\n conditions = \"reason_code_id = #{self.reason_code_id} && facility_id is null && client_id is null && id != #{self.id}\"\r\n else\r\n conditions = \"reason_code_id = #{self.reason_code_id} && facility_id is null and client_id is null \"\r\n end \r\n \r\n elsif crosswalk_level == \"CLIENT\" \r\n \r\n errors[:base] << \"Only client can be set when cross walk level is CLIENT\" if self.facility_id.present? && self.client_id.blank?\r\n errors[:base] << \"Please select a Client\" if self.client_id.blank? \r\n if self.id?\r\n conditions = \"reason_code_id = #{self.reason_code_id} && client_id = #{self.client_id} && id != #{self.id}\" \r\n else\r\n conditions = \"reason_code_id = #{self.reason_code_id} && client_id = #{self.client_id} \"\r\n end \r\n \r\n elsif crosswalk_level == \"FACILITY\"\r\n if self.id?\r\n conditions = \"reason_code_id = #{self.reason_code_id} && facility_id = #{self.facility_id} && id != #{self.id}\" \r\n else\r\n conditions = \"reason_code_id = #{self.reason_code_id} && facility_id = #{self.facility_id} \"\r\n end \r\n \r\n errors[:base] << \"Only facility can be set when cross walk level is FACILITY\" if self.client_id.present? && self.facility_id.blank?\r\n errors[:base] << \"Please select a Facility\" if self.facility_id.blank?\r\n end\r\n \r\n if errors[:base].empty? && conditions.present? && ReasonCodesClientsFacilitiesSetName.where(conditions).count > 0\r\n additional_info = \"\"\r\n additional_info = \" for the client selected\" if crosswalk_level == \"CLIENT\"\r\n additional_info = \" for the facility selected\" if crosswalk_level == \"Facility\"\r\n errors[:base] << \"A #{crosswalk_level} Level mapping already exists #{additional_info}\";\r\n end\r\n\r\n end\r\n end",
"def hypothesis3(countsXmajor) \n\tcriteria = 0\n\teuks = 0\n\teuks += 1 if countsXmajor['Sr'] >= 0.25\n\teuks += 1 if countsXmajor['Pl'] >= 0.25\n\teuks += 1 if countsXmajor['Op'] >= 0.25\n\teuks += 1 if countsXmajor['EE'] >= 0.25\n\teuks += 1 if countsXmajor['Am'] >= 0.25\n\teuks += 1 if countsXmajor['Ex'] >= 0.25\t\t\n\tcriteria += 1 if countsXmajor['Ba'] >= 0.25 \n\tcriteria += 1 if countsXmajor['Za'] < 0.25 \n\tcriteria += 1 if euks >= 5\n\tif criteria == 3\n\t\treturn 1\n\telse\n\t\treturn 0 \n\tend\nend",
"def handle_incorrect_constraints(specification)\n specification.inject(Mash.new) do |acc, (cb, constraints)|\n constraints = Array(constraints)\n acc[cb] = (constraints.empty? || constraints.size > 1) ? [] : constraints.first\n acc\n end\n end",
"def apply_multizone_vav_outdoor_air_sizing()\n \n OpenStudio::logFree(OpenStudio::Info, 'openstudio.model.Model', 'Started applying HVAC efficiency standards.')\n \n # Multi-zone VAV outdoor air sizing\n self.getAirLoopHVACs.sort.each {|obj| obj.apply_multizone_vav_outdoor_air_sizing} \n\n end",
"def test_extract_preconditions_from_restrictions_ends_concurrent_with\n restrictions = [{ type: \"ECW\", target_id: \"af419470-8365-4dd4-8ab0-8245de8ada73\", negation: false }]\n preconditions = HQMF::PreconditionExtractor.extract_preconditions_from_restrictions(restrictions, @data_criteria_converter_stub)\n preconditions.length.must_equal 1\n preconditions.first.operator.category.must_equal \"TEMPORAL\"\n preconditions.first.operator.type.must_equal \"ECWS\"\n end",
"def assign_bonuses\n allocate_comp_energy\n if self.user_quaffle_allocation > @s_energy\n @uq_bonus = (2 * (self.user_quaffle_allocation - @s_energy) - 1)\n end \n\n if @q_energy > self.user_snitch_allocation \n @cq_bonus = (2 * (@q_energy - self.user_snitch_allocation) - 1)\n end\n\n if self.user_bludger_allocation > @q_energy\n @ub_bonus = (2 * (self.user_bludger_allocation - @q_energy) - 1)\n end\n\n if @b_energy > self.user_quaffle_allocation \n @cb_bonus = (2 * (@b_energy - self.user_quaffle_allocation) - 1)\n end\n\n if self.user_snitch_allocation > @b_energy\n @us_bonus = (2 * (self.user_snitch_allocation - @b_energy) - 1)\n end\n\n if @s_energy > self.user_bludger_allocation\n @cs_bonus = (2 * (self.user_bludger_allocation) - 1)\n end\n end",
"def invention_chance\n\tbase_chance = 0.0\n\tgid = self.item.groupID\n\ttid = self.item.typeID\n\tif gid == 27 || gid == 419 || tid == 22544\n\t\tbase_chance = 0.2\n\telsif gid == 26 || gid == 28 || tid == 22548\n\t\tbase_chance = 0.25\n\telsif gid == 25 || gid == 420 || gid == 513 || tid == 22546\n\t\tbase_chance = 0.3\n\telse\n\t\tbase_chance = 0.4\n\tend\n\n# TODO determine which datacores are needed and the skill level associated with that datacore\n# character = Character.find(char_id)\n# encryption_skill_level = character.skill_level(...)\n# datacore_1_skill_level = character.skill_level(...)\n# datacore_2_skill_level = character.skill_level(...)\n\tencryption_skill_level = 3\n\tdatacore_1_skill_level = 3\n\tdatacore_2_skill_level = 3\n\tmeta_level = 0\n\tdecryptor_modifier = 1.0\n\tbase_chance * (1.0 + (0.01 * encryption_skill_level)) * (1.0 + ((datacore_1_skill_level + datacore_2_skill_level) * (0.1 / (5.0 - meta_level)))) * decryptor_modifier\nend",
"def same_curriculum_and_mandatory\n @problem.avoid(1, :name => \"same_curriculum_and_mandatory\") {\n conjunct{[\n Timetable::Entry.asp(:course_component_id => \"C1\", :weekday_id => \"WD\", :timeframe_id => \"TF\"),\n Timetable::Entry.asp(:course_component_id => \"C2\", :weekday_id => \"WD\", :timeframe_id => \"TF\"),\n CurriculumModuleAssignment.asp(:course_component_id => \"C1\", :curriculum_id => \"Cu\"),\n CurriculumModuleAssignment.asp(:course_component_id => \"C2\", :curriculum_id => \"Cu\"),\n \"C1 != C2\" ]}\n}\n end",
"def agency_abv; end",
"def conflicts\n @grid.values.select { |claims| claims.size > 1 }\n end",
"def update_phase3_enemy_select\n pkmn = @actors[@actor_actions.size]\n skill = pkmn.skills_set[@atk_index]\n if skill.id == 174 and !pkmn.type_ghost? #> Malédiction\n return [pkmn]\n end\n #>Choix automatique en 1v1\n if $game_temp.vs_type == 1 or (@enemy_party.pokemon_alive==1 and $pokemon_party.pokemon_alive==1) or skill.is_no_choice_skill?\n return util_targetselection_automatic(pkmn, skill)\n #>Choix 2v2\n elsif $game_temp.vs_type == 2\n data = update_phase3_pokemon_select_2v2(pkmn, skill)\n return -1 if data == -1\n if data < 2\n return [@enemies[data]]\n end\n return [@actors[data-2]]\n else\n return -1\n end\n\n end",
"def soft_limits_validation(user, params_to_update, owner = user.organization.owner)\n errors = user.errors\n\n soft_geocoding_limit = soft_param_to_boolean(params_to_update[:soft_geocoding_limit])\n if user.soft_geocoding_limit != soft_geocoding_limit && soft_geocoding_limit && !owner.soft_geocoding_limit\n errors.add(:soft_geocoding_limit, \"Organization owner hasn't this soft limit\")\n end\n soft_here_isolines_limit = soft_param_to_boolean(params_to_update[:soft_here_isolines_limit])\n if user.soft_here_isolines_limit != soft_here_isolines_limit && soft_here_isolines_limit && !owner.soft_here_isolines_limit\n errors.add(:soft_here_isolines_limit, \"Organization owner hasn't this soft limit\")\n end\n soft_twitter_datasource_limit = soft_param_to_boolean(params_to_update[:soft_twitter_datasource_limit])\n if user.soft_twitter_datasource_limit != soft_twitter_datasource_limit && soft_twitter_datasource_limit && !owner.soft_twitter_datasource_limit\n errors.add(:soft_twitter_datasource_limit, \"Organization owner hasn't this soft limit\")\n end\n soft_mapzen_routing_limit = soft_param_to_boolean(params_to_update[:soft_mapzen_routing_limit])\n if user.soft_mapzen_routing_limit != soft_mapzen_routing_limit && soft_mapzen_routing_limit && !owner.soft_mapzen_routing_limit\n errors.add(:soft_mapzen_routing_limit, \"Organization owner hasn't this soft limit\")\n end\n\n errors.empty?\n end",
"def allotment_is_not_100\n if not allot_for_item.blank? and not allot_for_const.blank? and not allot_for_research.blank?\n errors.add(:base, I18n.t('activerecord.errors.models.houdd_user.attributes.allotment_is_not_100')) if (allot_for_item + allot_for_const + allot_for_research) != 100\n end\n end",
"def test_extract_preconditions_from_restrictions_starts_concurrent_with\n restrictions = [{ type: \"SCW\", target_id: \"099fe199-fe83-42fa-8e68-c19067499edf\", negation: false }]\n preconditions = HQMF::PreconditionExtractor.extract_preconditions_from_restrictions(restrictions, @data_criteria_converter_stub)\n preconditions.length.must_equal 1\n preconditions.first.operator.category.must_equal \"TEMPORAL\"\n preconditions.first.operator.type.must_equal \"SCWE\"\n end",
"def initial_cut_values\n end",
"def can_define_cutoffs\n if [email protected]? || [email protected] || (@contest.gold_cutoff > 0 && !current_user.sk.root)\n render 'errors/access_refused' and return\n end\n end",
"def has_three_bonus_parts\n # placeholder\n # will fill in if issue of accidentally not associating bonus parts\n # becomes actually problematic\n end",
"def best_consultants_setup\n setup_before_rbc\n @rbc_0 = @rank_by_consulting[0]\n @rbc_1 = @rank_by_consulting[1]\n @rbc_2 = @rank_by_consulting[2]\n @rbc_3 = @rank_by_consulting[3]\n @rbc_0_stud = Student.find(@rbc_0)\n @rbc_1_stud = Student.find(@rbc_1)\n @rbc_2_stud = Student.find(@rbc_2)\n @rbc_3_stud = Student.find(@rbc_3)\n \n # Set all students unqualified to begin with\n ObjectiveStudent.where(:objective => @objective_40).update_all(:points_all_time => 3)\n \n # Stud_0 already has keys\n ObjectiveStudent.find_by(:objective => @objective_40, :user => @rbc_0_stud).update(:points_all_time => 7, :teacher_granted_keys => 2)\n \n # Stud_1 scored 10\n ObjectiveStudent.find_by(:objective => @objective_40, :user => @rbc_1_stud).update(:points_all_time => 10)\n \n # Stud_2 scored 9\n ObjectiveStudent.find_by(:objective => @objective_40, :user => @rbc_2_stud).update(:points_all_time => 9)\n \n # Stud_3 should normally be first choice\n ObjectiveStudent.find_by(:objective => @objective_40, :user => @rbc_3_stud).update(:points_all_time => 7)\n \n # Make sure these students have no teach_request\n [@rbc_0_stud, @rbc_1_stud, @rbc_2_stud, @rbc_3_stud].each do |stud|\n SeminarStudent.find_by(:seminar => @seminar, :user => stud).update(:teach_request => nil)\n end\n \n # Set @objective_40 to priority 5\n set_priority(@objective_40, 5)\n end",
"def case_with_bad_decass_for_timeline_range_checks\n Time.zone = 'EST'\n vet = create_veteran\n cf_judge = User.find_by_css_id(\"BVABDANIEL\") || create(:user, :judge, :with_vacols_judge_record)\n cf_atty = User.find_by_css_id(\"BVABBLOCK\") || create(:user, :with_vacols_attorney_record)\n judge = VACOLS::Staff.find_by_css_id(cf_judge.css_id)\n atty = VACOLS::Staff.find_by_css_id(cf_atty.css_id)\n vc = create(:case, :assigned, user: cf_judge, bfcorlid: \"#{vet.file_number}S\")\n create(:legacy_appeal, vacols_case: vc)\n create(:priorloc, lockey: vc.bfkey, locdin: 5.weeks.ago, locdout: 5.weeks.ago - 1.day, locstout: judge.slogid, locstto: judge.slogid)\n create(:priorloc, lockey: vc.bfkey, locdin: 4.weeks.ago, locdout: 5.weeks.ago, locstout: judge.slogid, locstto: \"CASEFLOW_judge\")\n create(:priorloc, lockey: vc.bfkey, locdin: 3.weeks.ago, locdout: 4.weeks.ago, locstout: \"CASEFLOW_judge\", locstto: judge.slogid)\n create(:priorloc, lockey: vc.bfkey, locdin: 2.weeks.ago, locdout: 3.weeks.ago, locstout: judge.slogid, locstto: atty.slogid)\n create(:priorloc, lockey: vc.bfkey, locdin: 1.week.ago, locdout: 2.weeks.ago, locstout: atty.slogid, locstto: \"CASEFLOW_atty\")\n create(:priorloc, lockey: vc.bfkey, locdin: Time.zone.now, locdout: 1.week.ago, locstout: \"CASEFLOW_atty\", locstto: atty.slogid)\n create(:priorloc, lockey: vc.bfkey, locdout: Time.zone.now, locstout: atty.slogid, locstto: judge.slogid)\n end",
"def plate_assigner ops, available_plates\n if available_plates.nil?\n return nil\n end\n plate_assignments = available_plates.product(*[available_plates] * (ops.size - 1))\n\n show do\n title \"Selecting plates for #{ops.first.output(OUTPUT).sample.name}\"\n\n note \"Click \\'OK\\' to proceed.\"\n warning \"The next few steps may take long to compute. Please be patient. You may have to refresh.\"\n bullet \"Number of requesting operations: #{ops.size}\"\n bullet \"Number of active plates: #{available_plates.size}\"\n bullet \"Number of possible plate assignments: #{plate_assignments.size}\"\n end\n\n\n best_score = nil\n plate_assignments.each do |plates|\n cell_hash = plates.map {|p| [p, p.cell_number]}.to_h\n\n ops.zip(plates).each {|op, plate| op.temporary[:plate] = plate}\n ops.zip(plates).each do |op, plate|\n r = op.temporary[:req_cells]\n would_remain = cell_hash[plate] - r\n if would_remain >= 0\n cell_hash[plate] = would_remain\n else\n op.temporary[:plate] = nil\n end\n end\n\n # delete if no operations use plate\n op_plates = ops.map {|op| op.temporary[:plate]}.compact\n cell_hash.each {|p, r| cell_hash.delete(p) if !op_plates.include?(p)}\n\n num_passed = ops.count {|op| op.temporary[:plate]}\n waste = cell_hash.inject(0) {|sum, (k, v)| sum + v}\n max_waste = cell_hash.inject(0) {|sum, (k, v)| sum + k.cell_number}\n num_plates = cell_hash.size\n delta_conf = cell_hash.inject(0) {|sum, (k, v)| sum + (MAX_CONFLUENCY - k.confluency)}\n\n # ensure there is always a plate\n plates_remaining = 0 # how many plates would be remaining if requestors run\n sample_plates = get_sample_plates ops.first.output(OUTPUT).sample\n plates_remaining += [sample_plates - plates].size.size\n ops.each do |op|\n r = op.temporary[:requestor]\n if r\n plates_remaining += 1 if r.is_a?(Operation) and r.operation_type.name == \"Plate Cells\"\n end\n end\n\n pr = 0\n keep_plate = true\n keep_plate = false if debug\n if keep_plate and plates_remaining == 0\n ops.each { |op| op.temporay[:plate] = nil }\n end\n n = (num_plates - 1.0) / (ops.size - 1)\n n = 0.0 if ops.size == 1 and num_plates == 1\n w = waste * 1.0 / max_waste\n p = (ops.size - num_passed) * 1.0 / ops.size\n d = (delta_conf) * 1.0 / (MAX_CONFLUENCY * cell_hash.size)\n\n # ordered from most to least important\n score_arr = [pr, p, w, n, d]\n if op_plates.empty? or cell_hash.empty?\n score_arr = [1.0] * 4\n end\n op_hash = ops.map {|op| [op, op.temporary[:plate]]}.to_h\n score = [op_hash, score_arr]\n best_score ||= score\n if (score[1] <=> best_score[1]) == -1\n best_score = score\n end\n score\n end\n\n return best_score\n end",
"def moreLicenses\n unless current_user.clearance>=2&¤t_user.organization.numLicenses-current_user.organization.users.length+1>=3\n store_location\n redirect_to current_user\n end\n end",
"def read_residual_mandatory_constraints\n trace :orm, \"Processing non-absorbed mandatory constraints\" do\n @mandatory_constraints_by_rs.each { |role_sequence, x|\n id = x['id']\n # Create a simply-mandatory PresenceConstraint for each mandatory constraint\n name = x[\"Name\"] || ''\n name = nil if name.size == 0\n #puts \"Residual Mandatory #{name}: #{role_sequence.to_s}\"\n\n if (players = role_sequence.all_role_ref.map{|rr| rr.role.object_type}).uniq.size > 1\n join_over, = *ActiveFacts::Metamodel.plays_over(role_sequence.all_role_ref.map{|rr| rr.role}, :proximate)\n raise \"Mandatory join constraint #{name} has incompatible players #{players.map{|o| o.name}.inspect}\" unless join_over\n if players.detect{|p| p != join_over}\n trace :query, \"subtyping step simple mandatory constraint #{name} over #{join_over.name}\"\n players.each_with_index do |player, i|\n next if player != join_over\n # REVISIT: We don't need to make a subtyping step here (from join_over to player)\n end\n end\n end\n\n pc = @constellation.PresenceConstraint(id_of(x))\n pc.vocabulary = @vocabulary\n pc.name = name\n pc.role_sequence = role_sequence\n pc.is_mandatory = true\n pc.min_frequency = 1 \n pc.max_frequency = nil\n pc.is_preferred_identifier = false\n\n (@constraints_by_rs[role_sequence] ||= []) << pc\n @by_id[id] = pc\n }\n end\n end",
"def available_missions\n budget_missions - contracts.independent.includes(:mission).inject([]) do |m, c|\n (c.mission.repeatable? or c.status.to_sym == :failed)? m : m.push(c.mission)\n end.flatten\n end",
"def at_least_one_indicator_target_exist \n #when not even 1 set exist(indicator_desc+target+achievement+progress )\n if half==2 && (indicator_desc_quality.blank? && target_quality.blank? && achievement_quality.blank? && progress_quality.blank?) && (indicator_desc_time.blank? && target_time.blank? && achievement_time.blank? && progress_time.blank?) && (indicator_desc_quantity.blank? && target_quantity.blank? && achievement_quantity.blank? && progress_quantity.blank?) && (indicator_desc_cost.blank? && target_cost.blank? && achievement_cost.blank? && progress_cost.blank?)\n return false \n errors.add(\"aa\",\"error la\")\n# elsif id.nil? && half==2 \n# \n# #when user selected 'Sent to PPP for Report' - with INCOMPLETE NEWly inserted xtvt(not yet saved) - (render fields although record not yet saved due to errors)\n# #RESTRICTIONS : requires 'Target fields' to be completed for repeating fields to be rendered when error occurs\n# if ( !indicator_desc_quality.blank? && !target_quality.blank? && !achievement_quality.blank? && !progress_quality.blank?)\n# return true\n# else\n# return false\n# end\n# if ( !indicator_desc_time.blank? && !target_time.blank? && !achievement_time.blank? && !progress_time.blank?)\n# return true\n# else\n# return false\n# end\n# if ( !indicator_desc_quantity.blank? && !target_quantity.blank? && !achievement_quantity.blank? && progress_quantity.blank?)\n# return true\n# else\n# return false\n# end\n# if ( !indicator_desc_cost.blank? && !target_cost.blank? && !achievement_cost.blank? && !progress_cost.blank?)\n# return true\n# else\n# return false\n# end\n\n elsif half==1 && (indicator_desc_quality.blank? && target_quality.blank?) && (indicator_desc_time.blank? && target_time.blank?) && (indicator_desc_quantity.blank? && target_quantity.blank?) && (indicator_desc_cost.blank? && target_cost.blank?)\n return false\n end\n end",
"def fix_up_controlled_vocabs\n sample_attributes.each do |attribute|\n unless attribute.sample_attribute_type.controlled_vocab?\n attribute.sample_controlled_vocab = nil\n end\n end\n end",
"def compute_qualification(team, pilots, pilot_contests)\n if 3 <= pilots.size\n contests_properties = gather_contest_properties(pilot_contests)\n non_primary_participant_occurrence_count = 0\n three_or_more_pilot_occurrence_count = 0\n contests_properties.each do |contest|\n non_primary_participant_occurrence_count += 1 if contest[:has_non_primary]\n three_or_more_pilot_occurrence_count += 1 if 3 <= contest[:pilot_count]\n end\n team.qualified = 3 <= non_primary_participant_occurrence_count &&\n 3 <= three_or_more_pilot_occurrence_count\n else\n team.qualified = false\n end\nend",
"def hypothesis1(countsXmajor) \n\tcriteria = 0\n\teuks = 0\n\teuks += 1 if countsXmajor['Sr'] >= 0.25\n\teuks += 1 if countsXmajor['Pl'] >= 0.25\n\teuks += 1 if countsXmajor['Op'] >= 0.25\n\teuks += 1 if countsXmajor['EE'] >= 0.25\n\teuks += 1 if countsXmajor['Am'] >= 0.25\n\teuks += 1 if countsXmajor['Ex'] >= 0.25\t\t\n\tcriteria += 1 if countsXmajor['Ba'] >= 0.25 \n\tcriteria += 1 if countsXmajor['Za'] >= 0.25 \n\tcriteria += 1 if euks >= 5\n\tif criteria == 3\n\t\treturn 1\n\telse\n\t\treturn 0 \n\tend\nend",
"def check_for_improper_constructions(infinitive, tense, person, mood, diathesis)\n if (mood == :imperative) && !((person == :second) && (tense == :present))\n raise Verbs::ImproperConstruction, 'The imperative mood requires present tense and second person'\n end\n if (infinitive.to_sym == :be) && (diathesis == :passive)\n raise Verbs::ImproperConstruction, 'There is no passive diathesis for the copula'\n end\n end",
"def constraints; end",
"def constraints; end",
"def constraints; end",
"def set_miscs\n @miscs = policy_scope(Product).where(:linetype => 2).order(:item)\n end",
"def set_variety\n \n if self.rmt_product_type_code == \"orchard_run\"\n\tvariety = Variety.find_by_commodity_group_code_and_commodity_code_and_rmt_variety_code(self.commodity_group_code,self.commodity_code,self.variety_code)\n\t if variety != nil \n\t\t self.variety = variety\n\t\t return true\n\t else\n\t\terrors.add_to_base(\"combination of: 'commodity_group_code' and 'commodity_code' and 'variety_code' is invalid- not found in database\")\n\t\t return false\n\t end\n elsif self.rmt_product_type_code.to_s.upcase == \"PRESORT\"\n\tvariety = Variety.find_by_commodity_group_code_and_commodity_code_and_rmt_variety_code(self.commodity_group_code,self.commodity_code,self.variety_code)\n\t if variety != nil \n\t\t self.variety = variety\n\t\t return true\n\t else\n\t\terrors.add_to_base(\"combination of: 'commodity_group_code' and 'commodity_code' and 'variety_code' is invalid- not found in database\")\n\t\t return false\n\tend\n\t \n else\n \n variety = Variety.find_by_commodity_group_code_and_commodity_code_and_marketing_variety_code(self.commodity_group_code,self.commodity_code,self.variety_code)\n\t if variety != nil \n\t\t self.variety = variety\n\t\t return true\n\t else\n\t\terrors.add_to_base(\"combination of: 'commodity_group_code' and 'commodity_code' and 'variety_code' is invalid- not found in database\")\n\t\t return false\n\tend\n end\nend",
"def ridicule_faultfully_prerevision()\n end",
"def take_decision(estimates, available_combos)\n max_index = estimates.index(estimates.max)\n\n available_combos[max_index].last\n end",
"def affordable_combos\n self.option_prices\n combinations = @option_prices.select{|k,v| v <= to_cents(@budget)}.keys\n unless combinations.empty? then combinations else \"You can't afford anything...\" end\n end",
"def validate_over_1000_vendor_sells\n total_trokaAki = Interaction.by_month.joins(:user =>:roles).where(:user_id => self.user_id, :roles => { :name => \"vendor\"}).group(\"interactions.user_id\").count\n unless total_trokaAki.size == 0\n if total_trokaAki.first.last > 1000\n ValidatorMailer.vendor_over_1000_warning(self.user_id).deliver\n end\n end\n end",
"def setup_cutin\n return unless PONY::ERRNO::check_sequence(current_act)\n #reserved\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n #use the built-in error checking\n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n #assign the user inputs to variables\n eff = runner.getDoubleArgumentValue(\"eff\",user_arguments)\n\n #check the user_name for reasonableness\n if eff <= 0\n runner.registerError(\"Please enter a positive value for Nominal Thermal Efficiency.\")\n return false\n end\n if eff > 1\n runner.registerWarning(\"The requested Nominal Thermal Efficiency must be <= 1\")\n end\n \n #change the efficiency of each boiler\n #loop through all the plant loops in the mode\n model.getPlantLoops.each do |plant_loop|\n #loop through all the supply components on this plant loop\n plant_loop.supplyComponents.each do |supply_component|\n #check if the supply component is a boiler\n if not supply_component.to_BoilerHotWater.empty?\n boiler = supply_component.to_BoilerHotWater.get\n #set the efficiency of the boiler\n boiler.setNominalThermalEfficiency(eff)\n runner.registerInfo(\"set boiler #{boiler.name} efficiency to #{eff}\")\n end\n end\n end\n \n \n=begin \n initial_effs = []\n missing_initial_effs = 0\n\n #find and loop through air loops\n air_loops = model.getAirLoopHVACs\n air_loops.each do |air_loop|\n supply_components = air_loop.supplyComponents\n\n #find two speed dx units on loop\n supply_components.each do |supply_component|\n dx_unit = supply_component.to_CoilCoolingDXTwoSpeed\n if not dx_unit.empty?\n dx_unit = dx_unit.get\n\n #change and report high speed cop\n initial_high_cop = dx_unit.ratedHighSpeedCOP\n if not initial_high_cop.empty?\n runner.registerInfo(\"Changing the Rated High Speed COP from #{initial_high_cop.get} to #{cop_high} for two speed dx unit '#{dx_unit.name}' on air loop '#{air_loop.name}'\")\n initial_high_cop_values << initial_high_cop.get\n dx_unit.setRatedHighSpeedCOP(cop_high)\n else\n runner.registerInfo(\"Setting the Rated High Speed COP to #{cop_high} for two speed dx unit '#{dx_unit.name}' on air loop '#{air_loop.name}. The original object did not have a Rated High Speed COP value'\")\n missing_initial_high_cop = missing_initial_high_cop + 1\n dx_unit.setRatedHighSpeedCOP(cop_high)\n end\n\n #change and report low speed cop\n initial_low_cop = dx_unit.ratedLowSpeedCOP\n if not initial_low_cop.empty?\n runner.registerInfo(\"Changing the Rated Low Speed COP from #{initial_low_cop.get} to #{cop_low} for two speed dx unit '#{dx_unit.name}' on air loop '#{air_loop.name}'\")\n initial_low_cop_values << initial_low_cop.get\n dx_unit.setRatedLowSpeedCOP(cop_low)\n else\n runner.registerInfo(\"Setting the Rated Low Speed COP to #{cop_low} for two speed dx unit '#{dx_unit.name}' on air loop '#{air_loop.name}. The original object did not have a Rated Low Speed COP COP value'\")\n missing_initial_low_cop = missing_initial_low_cop + 1\n dx_unit.setRatedLowSpeedCOP(cop_low)\n end\n\n end #end if not dx_unit.empty?\n\n end #end supply_components.each do\n\n end #end air_loops.each do\n\n #reporting initial condition of model\n runner.registerInitialCondition(\"The starting Rated High Speed COP values range from #{initial_high_cop_values.min} to #{initial_high_cop_values.max}. The starting Rated Low Speed COP values range from #{initial_low_cop_values.min} to #{initial_low_cop_values.max}.\")\n\n #warning if two counts of cop's are not the same\n if not initial_high_cop_values.size + missing_initial_high_cop == initial_low_cop_values.size + missing_initial_low_cop\n runner.registerWarning(\"Something went wrong with the measure, not clear on count of two speed dx objects\")\n end\n\n if initial_high_cop_values.size + missing_initial_high_cop == 0\n runner.registerAsNotApplicable(\"The model does not contain any two speed DX cooling units, the model will not be altered.\")\n return true\n end\n\n #reporting final condition of model\n runner.registerFinalCondition(\"#{initial_high_cop_values.size + missing_initial_high_cop} two speed dx units had their High and Low speed COP values set to #{cop_high} for high, and #{cop_low} for low.\")\n=end\n return true\n\n end",
"def vasca\n\t\treturn ((prot >= 9.0 || prot <= 21.0) && (car >= 54.0 || car <= 66.0) && (lip >= 19.0 || lip <= 31.0))\n\tend",
"def cutoffs\n end",
"def understrain_omnifacial_paroemiac()\n nonsolicitation_manship_podilegous?(unionism)\n end",
"def hypothesis2(countsXmajor) \n\tcriteria = 0\n\teuks = 0\n\teuks += 1 if countsXmajor['Sr'] >= 0.25\n\teuks += 1 if countsXmajor['Pl'] >= 0.25\n\teuks += 1 if countsXmajor['Op'] >= 0.25\n\teuks += 1 if countsXmajor['EE'] >= 0.25\n\teuks += 1 if countsXmajor['Am'] >= 0.25\n\teuks += 1 if countsXmajor['Ex'] >= 0.25\t\t\n\tcriteria += 1 if countsXmajor['Ba'] < 0.25 \n\tcriteria += 1 if countsXmajor['Za'] >= 0.25 \n\tcriteria += 1 if euks >= 5\n\tif criteria == 3\n\t\treturn 1\n\telse\n\t\treturn 0 \n\tend\nend",
"def validate\n self.warnings = ''\n interaction_warning(['nevirapine', 'kaletra', 'lopinavir'], ['rifampacin'])\n interaction_warning(['zidovudine'],['stavudine'],'Error:', 'these drugs cannot be used together.')\n interaction_warning(['carbamazepine'], ['kaletra', 'efavirenz'], 'Caution:',\n 'possible interaction, levels of both drugs may be decreased, avoid combination if possible')\n interaction_warning(['metronidazole', 'tinidazole'], ['kaletra'], 'Caution:',\n 'possible interaction if Kaletra syrup used; disulfiram-type reaction with alcohol in syrup.')\n interaction_warning(['ketoconazole'], ['kaletra', 'efavirenz', 'nevirapine'], 'Caution:',\n 'possible significant interactions. Check reference and consider using fluconazole.')\n interaction_warning(['phenobarbitone'], ['kaletra', 'efavirenz'], 'Caution:',\n 'possible significant interactions. Check reference and avoid combination if possible.')\n interaction_warning(['phenytoin'], ['kaletra', 'efavirenz'], 'Caution:',\n 'possible interaction, levels of ARV may be decreased, avoid combination if possible')\n interaction_warning(['erythromycin'], ['carbamazepine'], 'Caution:',\n 'interaction, levels of CBZ may be increased causing symptoms of nystagmus, nausea, vomiting, and ataxia; avoid combination if possible')\n\n end",
"def fo_tool\n return actor.equips[0] if actor.primary_use == 1\n return actor.equips[1] if actor.primary_use == 2\n return actor.assigned_item if actor.primary_use == 3\n return actor.assigned_item2 if actor.primary_use == 4\n return actor.assigned_item3 if actor.primary_use == 5\n return actor.assigned_item4 if actor.primary_use == 6\n return actor.assigned_skill if actor.primary_use == 7\n return actor.assigned_skill2 if actor.primary_use == 8\n return actor.assigned_skill3 if actor.primary_use == 9\n return actor.assigned_skill4 if actor.primary_use == 10\n end",
"def victory(joueur)\n\t\t# On définit les 8 possibilités de victoires si elles se vérifient les 3 dans la combinaison donnée alors la partie s'arrête\n\t\tif (plateau[0] == joueur.value) && (plateau[1] == joueur.value) && (plateau[2] == joueur.value)\n\t\t\tputs \"#{joueur.name} a eu plus de chance que toi ¯\\_(ツ)_/¯\"\n\t\t\tdisplay\n\t\t\texit\n\n\t\telsif (plateau[3] == joueur.value) && (plateau[4] == joueur.value) && (plateau[5] == joueur.value)\n\t\t\tputs \"#{joueur.name} a eu plus de chance que toi ¯\\_(ツ)_/¯\"\n\t\t\tdisplay\n\t\t\texit\n\t\telsif (plateau[0] == joueur.value) && (plateau[3] == joueur.value) && (plateau[6] == joueur.value)\n\t\t\tputs \"#{joueur.name} a eu plus de chance que toi ¯\\_(ツ)_/¯\"\n\t\t\tdisplay\n\t\t\texit\n\t\telsif (plateau[2] == joueur.value) && (plateau[4] == joueur.value) && (plateau[6] == joueur.value)\n\t\t\tputs \"#{joueur.name} a eu plus de chance que toi ¯\\_(ツ)_/¯\"\n\t\t\tdisplay\n\t\t\texit\n\t\telsif (plateau[0] == joueur.value) && (plateau[4] == joueur.value) && (plateau[8] == joueur.value)\n\t\t\tputs \"#{joueur.name} a eu plus de chance que toi ¯\\_(ツ)_/¯\"\n\t\t\tdisplay\n\t\t\texit\n\t\telsif (plateau[2] == joueur.value) && (plateau[5] == joueur.value) && (plateau[8] == joueur.value)\n\t\t\tputs \"#{joueur.name} a eu plus de chance que toi ¯\\_(ツ)_/¯\"\n\t\t\tdisplay\n\t\t\texit\n\t\telsif (plateau[1] == joueur.value) && (plateau[4] == joueur.value) && (plateau[7] == joueur.value)\n\t\t\tputs \"#{joueur.name} a eu plus de chance que toi ¯\\_(ツ)_/¯\"\n\t\t\tdisplay\n\t\t\texit\n\t\telse\n\t\t\treturn\n\t\tend\n\tend",
"def remove_preconditions_fulfilled_by action\r\n\t\taction[\"effect\"].each do |effect|\r\n\t\t\t@open_preconditions.each { |precon| @open_preconditions.delete(precon) if precon.to_s == effect.to_s }\r\n\t\tend\r\n\tend",
"def select_as_deleted choices\n if !choices.nil?\n operations.select { |op| choices[\"d#{op.output(OUTPUT).item.id}\".to_sym] == \"Yes\" }.each do |op|\n frag = op.output(OUTPUT).item\n op.error :low_concentration, \"The concentration of #{frag} was too low to continue\"\n frag.mark_as_deleted\n end\n end\n \n operations.each do |op|\n op.input(INPUT).item.mark_as_deleted if op.input(INPUT).item\n end\n end",
"def coolest_ability\n coolest_ability = nil\n abilities.each do | current_ability | \n if coolest_ability == nil || current_ability[:coolness] > coolest_ability[:coolness]\n coolest_ability = current_ability\n end\n end\n coolest_ability\n end",
"def assignedto_conditions \n #if category == 5 #KEW-PA 7 (search by : assignedto)\n #[\"assignedto_id=?\", assignedto] unless assignedto.blank? \n #else #KEW-PA 9 (search by : assignedto)\n #[assignedtodetails, assignedto,AssetDefect.all.map(&:asset_id)] unless assignedto.blank? \n #end\n [\"assignedto_id=?\", assignedto] unless assignedto.blank? #use this condition WITH FILTER FOR asset in ASSETDEFECT DB only - in show page.\n end",
"def virus_effects\n range\n predicted_deaths\n speed_of_spread\n end",
"def sufficient_rhizomes_validation\n unless profiles_assigned?\n rhizome_s = recipe.schedule.equipment_profiles.length == 1 ? 'Rhizome' : 'Rhizomes'\n errors.add(:recipe, \"requires #{recipe.schedule.equipment_profiles.length} #{rhizome_s}\")\n end\n end",
"def applyHVACEfficiencyStandard()\n \n sql_db_vars_map = Hash.new()\n\n OpenStudio::logFree(OpenStudio::Info, 'openstudio.model.Model', 'Started applying HVAC efficiency standards.')\n \n # Air Loop Controls\n self.getAirLoopHVACs.sort.each {|obj| obj.apply_standard_controls(self.template, self.climate_zone)} \n\n ##### Apply equipment efficiencies\n \n # Fans\n self.getFanVariableVolumes.sort.each {|obj| obj.setStandardEfficiency(self.template, self.standards)}\n self.getFanConstantVolumes.sort.each {|obj| obj.setStandardEfficiency(self.template, self.standards)}\n self.getFanOnOffs.sort.each {|obj| obj.setStandardEfficiency(self.template, self.standards)}\n self.getFanZoneExhausts.sort.each {|obj| obj.setStandardEfficiency(self.template, self.standards)}\n\n # Unitary ACs\n self.getCoilCoolingDXTwoSpeeds.sort.each {|obj| obj.setStandardEfficiencyAndCurves(self.template, self.standards)}\n self.getCoilCoolingDXSingleSpeeds.sort.each {|obj| sql_db_vars_map = obj.setStandardEfficiencyAndCurves(self.template, self.standards, sql_db_vars_map)}\n\n # Unitary HPs\n self.getCoilHeatingDXSingleSpeeds.sort.each {|obj| sql_db_vars_map = obj.setStandardEfficiencyAndCurves(self.template, self.standards, sql_db_vars_map)}\n \n # Chillers\n self.getChillerElectricEIRs.sort.each {|obj| obj.setStandardEfficiencyAndCurves(self.template, self.standards)}\n \n # Boilers\n self.getBoilerHotWaters.sort.each {|obj| obj.setStandardEfficiencyAndCurves(self.template, self.standards)}\n \n # Water Heaters\n self.getWaterHeaterMixeds.sort.each {|obj| obj.setStandardEfficiency(self.template, self.standards)}\n \n OpenStudio::logFree(OpenStudio::Info, 'openstudio.model.Model', 'Finished applying HVAC efficiency standards.')\n \n end",
"def vote_presence\n unless all_votes_specified? ^ apparent_majority\n errors.add(:base, \"Entweder ein Abstimmungsergebnis oder augenscheinliche Mehrheit auswählen.\")\n end\n if any_votes_specified? and apparent_majority\n errors.add(:base, \"Augenscheinliche Mehrheit und Abstimmungsergebnis nicht möglich.\")\n end\n end",
"def vote_presence\n unless all_votes_specified? ^ apparent_majority\n errors.add(:base, \"Entweder ein Abstimmungsergebnis oder augenscheinliche Mehrheit auswählen.\")\n end\n if any_votes_specified? and apparent_majority\n errors.add(:base, \"Augenscheinliche Mehrheit und Abstimmungsergebnis nicht möglich.\")\n end\n end",
"def arguments(model)\n\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n\t\t# argument for string\n\t\tstring = OpenStudio::Ruleset::OSArgument::makeStringArgument(\"string\", true)\n\t\tstring.setDisplayName(\"Set inputs for equipment containing the string (case sensitive, enter *.* for all):\")\n string.setDefaultValue(\"*.*\")\n\t\targs << string\n\n # PTAC inputs\n'\nZoneHVAC:PackagedTerminalAirConditioner,\n , !- Name\n , !- Availability Schedule Name\n , !- Air Inlet Node Name\n , !- Air Outlet Node Name\n , !- Outdoor Air Mixer Object Type\n , !- Outdoor Air Mixer Name\n , !- Supply Air Flow Rate During Cooling Operation {m3/s}\n , !- Supply Air Flow Rate During Heating Operation {m3/s}\n , !- Supply Air Flow Rate When No Cooling or Heating is Needed {m3/s}\n , !- Outdoor Air Flow Rate During Cooling Operation {m3/s}\n , !- Outdoor Air Flow Rate During Heating Operation {m3/s}\n , !- Outdoor Air Flow Rate When No Cooling or Heating is Needed {m3/s}\n , !- Supply Air Fan Object Type\n , !- Supply Air Fan Name\n , !- Heating Coil Object Type\n , !- Heating Coil Name\n , !- Cooling Coil Object Type\n , !- Cooling Coil Name\n DrawThrough, !- Fan Placement\n , !- Supply Air Fan Operating Mode Schedule Name\n , !- Availability Manager List Name\n 1; !- Design Specification ZoneHVAC Sizing Object Name\n'\n ptac_flow_clg = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('ptac_flow_clg', true)\n ptac_flow_clg.setDisplayName(\"PTAC: Supply Air Flow Rate During Cooling Operation {ft3/min}\")\n ptac_flow_clg.setDefaultValue(-1)\n args << ptac_flow_clg\n\n ptac_flow_htg = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('ptac_flow_htg', true)\n ptac_flow_htg.setDisplayName(\"PTAC: Supply Air Flow Rate During Heating Operation {ft3/min}\")\n ptac_flow_htg.setDefaultValue(-1)\n args << ptac_flow_htg\n\n ptac_flow_no_clg_or_htg = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('ptac_flow_no_clg_or_htg', true)\n ptac_flow_no_clg_or_htg.setDisplayName(\"PTAC: Supply Air Flow Rate When No Cooling or Heating is Needed {ft3/min}\")\n ptac_flow_no_clg_or_htg.setDefaultValue(-1)\n args << ptac_flow_no_clg_or_htg\n\n ptac_oa_clg = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"ptac_oa_clg\",false)\n ptac_oa_clg.setDisplayName(\"PTAC: Outdoor Air Flow Rate During Cooling Operation {ft3/min}\")\n ptac_oa_clg.setDefaultValue(-1)\n args << ptac_oa_clg\n\n ptac_oa_htg = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"ptac_oa_htg\",false)\n ptac_oa_htg.setDisplayName(\"PTAC: Outdoor Air Flow Rate During Heating Operation {ft3/min}\")\n ptac_oa_htg.setDefaultValue(-1)\n args << ptac_oa_htg\n\n ptac_oa_no_clg_or_htg = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"ptac_oa_no_clg_or_htg\",false)\n ptac_oa_no_clg_or_htg.setDisplayName(\"PTAC: Outdoor Air Flow Rate When No Cooling or Heating is Needed {ft3/min}\")\n ptac_oa_no_clg_or_htg.setDefaultValue(-1)\n args << ptac_oa_no_clg_or_htg\n'\n #populate choice argument for schedules in the model\n sch_handles = OpenStudio::StringVector.new\n sch_display_names = OpenStudio::StringVector.new\n\n #putting schedule names into hash\n sch_hash = {}\n model.getSchedules.each do |sch|\n sch_hash[sch.name.to_s] = sch\n end\n\n #looping through sorted hash of schedules\n sch_hash.sort.map do |sch_name, sch|\n if not sch.scheduleTypeLimits.empty?\n unitType = sch.scheduleTypeLimits.get.unitType\n #puts \"#{sch.name}, #{unitType}\"\n if unitType == \"Availability\"\n sch_handles << sch.handle.to_s\n sch_display_names << sch_name\n end\n end\n end\n\n\t\t#argument for schedules\n sched = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"sched\", sch_handles, sch_display_names, false)\n sched.setDisplayName(\"PTAC: Supply Air Fan Operating Mode Schedule Name\")\n args << sched\n'\n # Fan Inputs TODO add additional types when available: OnOff\n'\nFan:ConstantVolume,\n , !- Name\n , !- Availability Schedule Name\n 0.7, !- Fan Total Efficiency\n , !- Pressure Rise {Pa}\n , !- Maximum Flow Rate {m3/s}\n 0.9, !- Motor Efficiency\n 1, !- Motor In Airstream Fraction\n , !- Air Inlet Node Name\n , !- Air Outlet Node Name\n General; !- End-Use Subcategory\n'\n fan_eff_tot = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('fan_eff_tot', true)\n fan_eff_tot.setDisplayName(\"Fan: Fan Total Efficiency\")\n fan_eff_tot.setDefaultValue(-1)\n args << fan_eff_tot\n\n fan_rise = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('fan_rise', true)\n fan_rise.setDisplayName(\"Fan: Pressure Rise {inH2O}\")\n fan_rise.setDefaultValue(-1)\n args << fan_rise\n\n fan_flow = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('fan_flow', true)\n fan_flow.setDisplayName(\"Fan: Maximum Flow Rate {ft3/min}\")\n fan_flow.setDefaultValue(-1)\n args << fan_flow\n\n fan_eff_mot = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('fan_eff_mot', true)\n fan_eff_mot.setDisplayName(\"Fan: Motor Efficiency\")\n fan_eff_mot.setDefaultValue(-1)\n args << fan_eff_mot\n\n # Htg Coil Inputs TODO add additional when available after 1.6.0\n\n hc_ewt = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"hc_ewt\", false)\n hc_ewt.setDisplayName(\"Htg Coil: Rated Inlet Water Temperature {F}\")\n hc_ewt.setDefaultValue(-1)\n args << hc_ewt\n\n hc_eat = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"hc_eat\", false)\n hc_eat.setDisplayName(\"Htg Coil: Rated Inlet Air Temperature {F}\")\n hc_eat.setDefaultValue(-1)\n args << hc_eat\n\n hc_lwt = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"hc_lwt\", false)\n hc_lwt.setDisplayName(\"Htg Coil: Rated Outlet Water Temperature {F}\")\n hc_lwt.setDefaultValue(-1)\n args << hc_lwt\n\n hc_lat = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"hc_lat\", false)\n hc_lat.setDisplayName(\"Htg Coil: Rated Outlet Air Temperature {F}\")\n hc_lat.setDefaultValue(-1)\n args << hc_lat\n\n # Clg Coil Inputs\n'\nCoil:Cooling:DX:SingleSpeed,\n , !- Name\n , !- Availability Schedule Name\n , !- Gross Rated Total Cooling Capacity {W}\n , !- Gross Rated Sensible Heat Ratio\n 3, !- Gross Rated Cooling COP {W/W}\n , !- Rated Air Flow Rate {m3/s}\n 773.3, !- Rated Evaporator Fan Power Per Volume Flow Rate {W/(m3/s)}\n , !- Air Inlet Node Name\n , !- Air Outlet Node Name\n , !- Total Cooling Capacity Function of Temperature Curve Name\n , !- Total Cooling Capacity Function of Flow Fraction Curve Name\n , !- Energy Input Ratio Function of Temperature Curve Name\n , !- Energy Input Ratio Function of Flow Fraction Curve Name\n , !- Part Load Fraction Correlation Curve Name\n , !- Nominal Time for Condensate Removal to Begin {s}\n , !- Ratio of Initial Moisture Evaporation Rate and Steady State Latent Capacity {dimensionless}\n , !- Maximum Cycling Rate {cycles/hr}\n , !- Latent Capacity Time Constant {s}\n , !- Condenser Air Inlet Node Name\n AirCooled, !- Condenser Type\n 0.9, !- Evaporative Condenser Effectiveness {dimensionless}\n , !- Evaporative Condenser Air Flow Rate {m3/s}\n , !- Evaporative Condenser Pump Rated Power Consumption {W}\n , !- Crankcase Heater Capacity {W}\n 10, !- Maximum Outdoor Dry-Bulb Temperature for Crankcase Heater Operation {C}\n , !- Supply Water Storage Tank Name\n , !- Condensate Collection Water Storage Tank Name\n , !- Basin Heater Capacity {W/K}\n 2, !- Basin Heater Setpoint Temperature {C}\n , !- Basin Heater Operating Schedule Name\n , !- Sensible Heat Ratio Function of Temperature Curve Name\n 1; !- Sensible Heat Ratio Function of Flow Fraction Curve Name\n'\n cc_cap = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"cc_cap\", false)\n cc_cap.setDisplayName(\"Clg Coil: Gross Rated Total Cooling Capacity {Btu/h}\")\n cc_cap.setDefaultValue(-1)\n args << cc_cap\n\n cc_shr = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"cc_shr\", false)\n cc_shr.setDisplayName(\"Clg Coil: Gross Rated Sensible Heat Ratio\")\n cc_shr.setDefaultValue(-1)\n args << cc_shr\n\n cc_cop = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"cc_cop\", false)\n cc_cop.setDisplayName(\"Clg Coil: Gross Rated Cooling COP {Btuh/Btuh}\")\n cc_cop.setDefaultValue(-1)\n args << cc_cop\n\n cc_flow = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"cc_flow\", false)\n cc_flow.setDisplayName(\"Clg Coil: Rated Air Flow Rate {ft3/min}\")\n cc_flow.setDefaultValue(-1)\n args << cc_flow\n\n return args\n\n end",
"def vdate_taxcomputation_amount\n \n if(taxOnAggregateInc && !vdate_is_valid_amount_range?(taxOnAggregateInc))\n errors.add(taxOnAggregateInc,'Tax Payable on Aggregate Income is out of valid range.')\n end\n \n if(rebateOnAgriInc && !vdate_is_valid_amount_range?(rebateOnAgriInc))\n errors.add(rebateOnAgriInc,'Rebate on Net Agricultural Income is out of valid range.')\n end\n \n if(totalTaxPayable && !vdate_is_valid_amount_range?(totalTaxPayable))\n errors.add(totalTaxPayable,'Total Tax Payable is out of valid range.')\n end\n \n if(surchargeOnTaxPayable && !vdate_is_valid_amount_range?(surchargeOnTaxPayable))\n errors.add(surchargeOnTaxPayable,'SurCharge on Total Tax is out of valid range.')\n end\n \n if(educationCess && !vdate_is_valid_amount_range?(educationCess))\n errors.add(educationCess,'Education Cess is out of valid range.')\n end\n \n if(grossTaxLiability && !vdate_is_valid_amount_range?(grossTaxLiability))\n errors.add(grossTaxLiability,'Gross Tax Liability is out of valid range.')\n end\n \n if(section89 && !vdate_is_valid_amount_range?(section89))\n errors.add(section89,'Relief under Section 89 is out of valid range.')\n end\n \n if(section90and91 && !vdate_is_valid_amount_range?(section90and91))\n errors.add(section90and91,'Relief under Section 90/91 is out of valid range.')\n end\n \n if(netTaxLiability && !vdate_is_valid_amount_range?(netTaxLiability))\n errors.add(netTaxLiability,'Net Tax Liability is out of valid range.')\n end\n \n if(intrstPayUs234A && !vdate_is_valid_amount_range?(intrstPayUs234A))\n errors.add(intrstPayUs234A,'Interest Payable u/s 234A is out of valid range.')\n end\n \n if(intrstPayUs234B && !vdate_is_valid_amount_range?(intrstPayUs234B))\n errors.add(intrstPayUs234A,'Interest Payable u/s 234B is out of valid range.')\n end\n \n if(intrstPayUs234C && !vdate_is_valid_amount_range?(intrstPayUs234C))\n errors.add(intrstPayUs234C,'Interest Payable u/s 234C is out of valid range.')\n end\n \n if(totalIntrstPay && !vdate_is_valid_amount_range?(totalIntrstPay))\n errors.add(totalIntrstPay,'Total Interest Payable u/s 234 is out of valid range.')\n end \n \n if(totTaxPlusIntrstPay && !vdate_is_valid_amount_range?(totTaxPlusIntrstPay))\n errors.add(totTaxPlusIntrstPay,'Tatal Tax and Interest on delayed tax is out of valid range.')\n end \n \nend",
"def warning_for(category, user_type)\n if user_type == :licensee\n case(category)\n when 'Liability for Defects and Inaccuracies'\n @licence.disclaimer.disclaimer_indemnity\n when 'Licence Change Risks'\n @licence.changes_to_term.licence_changes_effective_immediately\n when 'Licence Termination Risks'\n @licence.termination.termination_discretionary ||\n (@licence.termination.termination_automatic && [email protected]_reinstatement)\n when 'Jurisdictional Legal Risks'\n (@licence.conflict_of_law.forum_of == 'specific') || (@licence.conflict_of_law.forum_of == 'licensor') ||\n (@licence.conflict_of_law.law_of == 'specific') || (@licence.conflict_of_law.law_of == 'licensor')\n when 'Patent Infringement Risks'\n [email protected]_patents_explicitly\n else\n raise 'Unknown license risk category'\n end\n elsif user_type == :licensor\n case(category)\n when 'Liability for Defects and Inaccuracies'\n [email protected]_warranty\n when 'Licence Violation Risks'\n [email protected]_automatic\n when 'Patent Licensing Risks'\n [email protected]_patents_explicitly\n else\n raise 'Unknown license risk category'\n end\n end\n end",
"def NBC_936_2010_RuleSet( ruleType, elements, locale_HDD, cityName )\n\n\n # System data...\n primHeatFuelName = getPrimaryHeatSys( elements )\n secSysType = getSecondaryHeatSys( elements )\n primDHWFuelName = getPrimaryDHWSys( elements )\n\n # Basement, slab, or both in model file?\n # Decide which to use for compliance based on count!\n # ADW May 17 2018: Basements are modified through Opt-H2KFoundation, slabs and crawlspaces through Opt-H2KFoundationSlabCrawl\n # Determine if a crawlspace is present, and if it is, if the crawlspace is heated\n numOfCrawl = 0\n isCrawlHeated = false\n if elements[\"HouseFile/House/Components/Crawlspace\"] != nil\n numOfCrawl += 1\n if elements[\"HouseFile/House/Temperatures/Crawlspace\"].attributes[\"heated\"] =~ /true/\n isCrawlHeated = true\n end\n end\n\n # Choices that do NOT depend on ruleType!\n\n $ruleSetChoices[\"Opt-ACH\"] = \"ACH_NBC\"\n $ruleSetChoices[\"Opt-Baseloads\"] = \"NBC-Baseloads\"\n $ruleSetChoices[\"Opt-ResultHouseCode\"] = \"General\"\n $ruleSetChoices[\"Opt-Temperatures\"] = \"NBC_Temps\"\n if ($PermafrostHash[cityName] == \"continuous\")\n $ruleSetChoices[\"Opt-Specifications\"] = \"NBC_Specs_Perma\"\n else\n $ruleSetChoices[\"Opt-Specifications\"] = \"NBC_Specs_Normal\"\n end\n\n # Heating Equipment performance requirements (Table 9.36.3.10) - No dependency on ruleType!\n if (primHeatFuelName =~ /gas/) != nil # value is \"Natural gas\"\n $ruleSetChoices[\"Opt-HVACSystem\"] = \"NBC-gas-furnace\"\n elsif (primHeatFuelName =~ /Oil/) != nil # value is Oil\n $ruleSetChoices[\"Opt-HVACSystem\"] = \"NBC-oil-heat\"\n elsif (primHeatFuelName =~ /Elect/) != nil # value is \"Electricity\n if secSysType =~ /AirHeatPump/ # TODO: Should we also include WSHP & GSHP in this check?\n $ruleSetChoices[\"Opt-HVACSystem\"] = \"NBC-CCASHP\"\n else\n $ruleSetChoices[\"Opt-HVACSystem\"] = \"NBC-elec-heat\"\n end\n end\n\n # DHW Equipment performance requirements (Table 9.36.4.2)\n if (primDHWFuelName =~ /gas/) != nil\n $ruleSetChoices[\"Opt-DHWSystem\"] = \"NBC-HotWater_gas\"\n elsif (primDHWFuelName =~ /Elect/) != nil\n $ruleSetChoices[\"Opt-DHWSystem\"] = \"NBC-HotWater_elec\"\n elsif (primDHWFuelName =~ /Oil/) != nil\n $ruleSetChoices[\"Opt-DHWSystem\"] = \"NBC-HotWater_oil\"\n end\n\n # Thermal zones and HDD by rule type\n #-------------------------------------------------------------------------\n if ruleType =~ /NBC9_36_noHRV/\n\n # Implement reference ventilation system (HRV with 0% recovery efficiency)\n $ruleSetChoices[\"Opt-HRVonly\"] = \"NBC_noHRV\"\n\n # Zone 4 ( HDD < 3000) without an HRV\n if locale_HDD < 3000\n # Effective thermal resistance of above-ground opaque assemblies (Table 9.36.2.6 A&B)\n $ruleSetChoices[\"Opt-GenericWall_1Layer_definitions\"] = \"NBC_Wall_zone4\"\n $ruleSetChoices[\"Opt-AtticCeilings\"] = \"NBC_Ceiling_zone4\"\n $ruleSetChoices[\"Opt-CathCeilings\"] = \"NBC_FlatCeiling_zone4\"\n $ruleSetChoices[\"Opt-FlatCeilings\"] = \"NBC_FlatCeiling_zone4\"\n\n $ruleSetChoices[\"Opt-ExposedFloor\"] = \"NBC_exposed_zone4\"\n\n # Effective thermal resistance of fenestration (Table 9.36.2.7.(1))\n $ruleSetChoices[\"Opt-CasementWindows\"] = \"NBC-zone4-window\"\n $ruleSetChoices[\"Opt-Doors\"] = \"NBC-zone4-door\"\n $ruleSetChoices[\"Opt-DoorWindows\"] = \"NBC-zone4-Doorwindow\"\n\n # Effective thermal resistance of assemblies below-grade or in contact with the ground (Table 9.36.2.8.A&B)\n $ruleSetChoices[\"Opt-H2KFoundation\"] = \"NBC_BCIN_zone4\"\n if isCrawlHeated\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SCB_zone4\"\n else # There is a crawlspace, but it isn't heated. Treat floor above crawlspace as exposed floor\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SOnly_zone4\" # If there are any slabs, insulate them\n $ruleSetChoices[\"Opt-FloorAboveCrawl\"] = \"NBC_crawlceiling_zone4\"\n end\n\n # Zone 5 ( 3000 < HDD < 3999) without an HRV\n elsif locale_HDD >= 3000 && locale_HDD < 3999\n # Effective thermal resistance of above-ground opaque assemblies (Table 9.36.2.6 A&B)\n $ruleSetChoices[\"Opt-GenericWall_1Layer_definitions\"] = \"NBC_Wall_zone5_noHRV\"\n $ruleSetChoices[\"Opt-FloorHeader\"] = \"NBC_Wall_zone5_noHRV\"\n $ruleSetChoices[\"Opt-AtticCeilings\"] = \"NBC_Ceiling_zone5_noHRV\"\n $ruleSetChoices[\"Opt-CathCeilings\"] = \"NBC_FlatCeiling_zone5\"\n $ruleSetChoices[\"Opt-FlatCeilings\"] = \"NBC_FlatCeiling_zone5\"\n\n $ruleSetChoices[\"Opt-ExposedFloor\"] = \"NBC_exposed_zone5\"\n\n # Effective thermal resistance of fenestration (Table 9.36.2.7.(1))\n $ruleSetChoices[\"Opt-CasementWindows\"] = \"NBC-zone5-window\"\n $ruleSetChoices[\"Opt-Doors\"] = \"NBC-zone5-door\"\n $ruleSetChoices[\"Opt-DoorWindows\"] = \"NBC-zone5-Doorwindow\"\n\n # Effective thermal resistance of assemblies below-grade or in contact with the ground (Table 9.36.2.8.A&B)\n $ruleSetChoices[\"Opt-H2KFoundation\"] = \"NBC_BCIN_zone5_noHRV\"\n if isCrawlHeated\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SCB_zone5_noHRV\"\n else # There is a crawlspace, but it isn't heated. Treat floor above crawlspace as exposed floor\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SOnly_zone5\" # If there are any slabs, insulate them\n $ruleSetChoices[\"Opt-FloorAboveCrawl\"] = \"NBC_crawlceiling_zone5\"\n end\n\n # Zone 6 ( 4000 < HDD < 4999) without an HRV\n elsif locale_HDD >= 4000 && locale_HDD < 4999\n # Effective thermal resistance of above-ground opaque assemblies (Table 9.36.2.6 A&B)\n $ruleSetChoices[\"Opt-GenericWall_1Layer_definitions\"] = \"NBC_Wall_zone6_noHRV\"\n $ruleSetChoices[\"Opt-FloorHeader\"] = \"NBC_Wall_zone6_noHRV\"\n $ruleSetChoices[\"Opt-AtticCeilings\"] = \"NBC_Ceiling_zone6\"\n $ruleSetChoices[\"Opt-CathCeilings\"] = \"NBC_FlatCeiling_zone6\"\n $ruleSetChoices[\"Opt-FlatCeilings\"] = \"NBC_FlatCeiling_zone6\"\n\n $ruleSetChoices[\"Opt-ExposedFloor\"] = \"NBC_exposed_zone6\"\n\n # Effective thermal resistance of fenestration (Table 9.36.2.7.(1))\n $ruleSetChoices[\"Opt-CasementWindows\"] = \"NBC-zone6-window\"\n $ruleSetChoices[\"Opt-Doors\"] = \"NBC-zone6-door\"\n $ruleSetChoices[\"Opt-DoorWindows\"] = \"NBC-zone6-Doorwindow\"\n\n # Effective thermal resistance of assemblies below-grade or in contact with the ground (Table 9.36.2.8.A&B)\n $ruleSetChoices[\"Opt-H2KFoundation\"] = \"NBC_BCIN_zone6_noHRV\"\n if isCrawlHeated\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SCB_zone6_noHRV\"\n else # There is a crawlspace, but it isn't heated. Treat floor above crawlspace as exposed floor\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SOnly_zone6\" # If there are any slabs, insulate them\n $ruleSetChoices[\"Opt-FloorAboveCrawl\"] = \"NBC_crawlceiling_zone6\"\n end\n\n # Zone 7A ( 5000 < HDD < 5999) without an HRV\n elsif locale_HDD >= 5000 && locale_HDD < 5999\n # Effective thermal resistance of above-ground opaque assemblies (Table 9.36.2.6 A&B)\n $ruleSetChoices[\"Opt-GenericWall_1Layer_definitions\"] = \"NBC_Wall_zone7A_noHRV\"\n $ruleSetChoices[\"Opt-FloorHeader\"] = \"NBC_Wall_zone7A_noHRV\"\n $ruleSetChoices[\"Opt-AtticCeilings\"] = \"NBC_Ceiling_zone7A_noHRV\"\n $ruleSetChoices[\"Opt-CathCeilings\"] = \"NBC_FlatCeiling_zone7A\"\n $ruleSetChoices[\"Opt-FlatCeilings\"] = \"NBC_FlatCeiling_zone7A\"\n\n $ruleSetChoices[\"Opt-ExposedFloor\"] = \"NBC_exposed_zone7A\"\n\n # Effective thermal resistance of fenestration (Table 9.36.2.7.(1))\n $ruleSetChoices[\"Opt-CasementWindows\"] = \"NBC-zone7A-window\"\n $ruleSetChoices[\"Opt-Doors\"] = \"NBC-zone7A-door\"\n $ruleSetChoices[\"Opt-DoorWindows\"] = \"NBC-zone7A-Doorwindow\"\n # Effective thermal resistance of assemblies below-grade or in contact with the ground (Table 9.36.2.8.A&B)\n $ruleSetChoices[\"Opt-H2KFoundation\"] = \"NBC_BCIN_zone7A_noHRV\"\n if isCrawlHeated\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SCB_zone7A_noHRV\"\n else # There is a crawlspace, but it isn't heated. Treat floor above crawlspace as exposed floor\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SOnly_zone7A_noHRV\" # If there are any slabs, insulate them\n $ruleSetChoices[\"Opt-FloorAboveCrawl\"] = \"NBC_crawlceiling_zone7A\"\n end\n\n # Zone 7B ( 6000 < HDD < 6999) without an HRV\n elsif locale_HDD >= 6000 && locale_HDD < 6999\n # Effective thermal resistance of above-ground opaque assemblies (Table 9.36.2.6 A&B)\n $ruleSetChoices[\"Opt-GenericWall_1Layer_definitions\"] = \"NBC_Wall_zone7B_noHRV\"\n $ruleSetChoices[\"Opt-FloorHeader\"] = \"NBC_Wall_zone7B_noHRV\"\n $ruleSetChoices[\"Opt-AtticCeilings\"] = \"NBC_Ceiling_zone7B\"\n $ruleSetChoices[\"Opt-CathCeilings\"] = \"NBC_FlatCeiling_zone7B\"\n $ruleSetChoices[\"Opt-FlatCeilings\"] = \"NBC_FlatCeiling_zone7B\"\n\n $ruleSetChoices[\"Opt-ExposedFloor\"] = \"NBC_exposed_zone7B\"\n\n # Effective thermal resistance of fenestration (Table 9.36.2.7.(1))\n $ruleSetChoices[\"Opt-CasementWindows\"] = \"NBC-zone7B-window\"\n $ruleSetChoices[\"Opt-Doors\"] = \"NBC-zone7B-door\"\n $ruleSetChoices[\"Opt-DoorWindows\"] = \"NBC-zone7B-Doorwindow\"\n\n # Effective thermal resistance of assemblies below-grade or in contact with the ground (Table 9.36.2.8.A&B)\n $ruleSetChoices[\"Opt-H2KFoundation\"] = \"NBC_BCIN_zone7B_noHRV\"\n if isCrawlHeated\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SCB_zone7B_noHRV\"\n else # There is a crawlspace, but it isn't heated. Treat floor above crawlspace as exposed floor\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SOnly_zone7B_noHRV\" # If there are any slabs, insulate them\n $ruleSetChoices[\"Opt-FloorAboveCrawl\"] = \"NBC_crawlceiling_zone7B\"\n end\n\n # Zone 8 (HDD <= 7000) without an HRV\n elsif locale_HDD >= 7000\n # Effective thermal resistance of above-ground opaque assemblies (Table 9.36.2.6 A&B)\n $ruleSetChoices[\"Opt-GenericWall_1Layer_definitions\"] = \"NBC_Wall_zone8_noHRV\"\n $ruleSetChoices[\"Opt-FloorHeader\"] = \"NBC_Wall_zone8_noHRV\"\n $ruleSetChoices[\"Opt-AtticCeilings\"] = \"NBC_Ceiling_zone8\"\n $ruleSetChoices[\"Opt-CathCeilings\"] = \"NBC_FlatCeiling_zone8\"\n $ruleSetChoices[\"Opt-FlatCeilings\"] = \"NBC_FlatCeiling_zone8\"\n\n $ruleSetChoices[\"Opt-ExposedFloor\"] = \"NBC_exposed_zone8\"\n\n # Effective thermal resistance of fenestration (Table 9.36.2.7.(1))\n $ruleSetChoices[\"Opt-CasementWindows\"] = \"NBC-zone8-window\"\n $ruleSetChoices[\"Opt-Doors\"] = \"NBC-zone8-door\"\n $ruleSetChoices[\"Opt-DoorWindows\"] = \"NBC-zone8-Doorwindow\"\n\n # Effective thermal resistance of assemblies below-grade or in contact with the ground (Table 9.36.2.8.A&B)\n $ruleSetChoices[\"Opt-H2KFoundation\"] = \"NBC_BCIN_zone8_noHRV\"\n if isCrawlHeated\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SCB_zone8_noHRV\"\n else # There is a crawlspace, but it isn't heated. Treat floor above crawlspace as exposed floor\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SOnly_zone8_noHRV\" # If there are any slabs, insulate them\n $ruleSetChoices[\"Opt-FloorAboveCrawl\"] = \"NBC_crawlceiling_zone8\"\n end\n\n end\n\n #-------------------------------------------------------------------------\n elsif ruleType =~ /NBC9_36_HRV/\n\n # Performance of Heat/Energy-Recovery Ventilator (Section 9.36.3.9.3)\n \t\t$ruleSetChoices[\"Opt-HRVonly\"] = \"NBC_HRV\"\n\n # Zone 4 ( HDD < 3000) without an HRV\n if locale_HDD < 3000\n # Effective thermal resistance of above-ground opaque assemblies (Table 9.36.2.6 A&B)\n $ruleSetChoices[\"Opt-GenericWall_1Layer_definitions\"] = \"NBC_Wall_zone4\"\n $ruleSetChoices[\"Opt-FloorHeader\"] = \"NBC_Wall_zone4\"\n $ruleSetChoices[\"Opt-AtticCeilings\"] = \"NBC_Ceiling_zone4\"\n $ruleSetChoices[\"Opt-CathCeilings\"] = \"NBC_FlatCeiling_zone4\"\n $ruleSetChoices[\"Opt-FlatCeilings\"] = \"NBC_FlatCeiling_zone4\"\n\n $ruleSetChoices[\"Opt-ExposedFloor\"] = \"NBC_exposed_zone4\"\n\n # Effective thermal resistance of fenestration (Table 9.36.2.7.(1))\n $ruleSetChoices[\"Opt-CasementWindows\"] = \"NBC-zone4-window\"\n $ruleSetChoices[\"Opt-Doors\"] = \"NBC-zone4-door\"\n $ruleSetChoices[\"Opt-DoorWindows\"] = \"NBC-zone4-Doorwindow\"\n\n # Effective thermal resistance of assemblies below-grade or in contact with the ground (Table 9.36.2.8.A&B)\n $ruleSetChoices[\"Opt-H2KFoundation\"] = \"NBC_BCIN_zone4\"\n if isCrawlHeated\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SCB_zone4\"\n else # There is a crawlspace, but it isn't heated. Treat floor above crawlspace as exposed floor\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SOnly_zone4\" # If there are any slabs, insulate them\n $ruleSetChoices[\"Opt-FloorAboveCrawl\"] = \"NBC_crawlceiling_zone4\"\n end\n\n # Zone 5 ( 3000 < HDD < 3999) with an HRV\n elsif locale_HDD >= 3000 && locale_HDD < 3999\n # Effective thermal resistance of above-ground opaque assemblies (Table 9.36.2.6 A&B)\n $ruleSetChoices[\"Opt-GenericWall_1Layer_definitions\"] = \"NBC_Wall_zone5_HRV\"\n $ruleSetChoices[\"Opt-FloorHeader\"] = \"NBC_Wall_zone5_HRV\"\n $ruleSetChoices[\"Opt-AtticCeilings\"] = \"NBC_Ceiling_zone5_HRV\"\n $ruleSetChoices[\"Opt-CathCeilings\"] = \"NBC_FlatCeiling_zone5\"\n $ruleSetChoices[\"Opt-FlatCeilings\"] = \"NBC_FlatCeiling_zone5\"\n\n $ruleSetChoices[\"Opt-ExposedFloor\"] = \"NBC_exposed_zone5\"\n\n # Effective thermal resistance of fenestration (Table 9.36.2.7.(1))\n $ruleSetChoices[\"Opt-CasementWindows\"] = \"NBC-zone5-window\"\n $ruleSetChoices[\"Opt-Doors\"] = \"NBC-zone5-door\"\n $ruleSetChoices[\"Opt-DoorWindows\"] = \"NBC-zone5-Doorwindow\"\n\n # Effective thermal resistance of assemblies below-grade or in contact with the ground (Table 9.36.2.8.A&B)\n $ruleSetChoices[\"Opt-H2KFoundation\"] = \"NBC_BCIN_zone5_HRV\"\n if isCrawlHeated\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SCB_zone5_HRV\"\n else # There is a crawlspace, but it isn't heated. Treat floor above crawlspace as exposed floor\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SOnly_zone5\" # If there are any slabs, insulate them\n $ruleSetChoices[\"Opt-FloorAboveCrawl\"] = \"NBC_crawlceiling_zone5\"\n end\n\n # Zone 6 ( 4000 < HDD < 4999) with an HRV\n elsif locale_HDD >= 4000 && locale_HDD < 4999\n # Effective thermal resistance of above-ground opaque assemblies (Table 9.36.2.6 A&B)\n $ruleSetChoices[\"Opt-GenericWall_1Layer_definitions\"] = \"NBC_Wall_zone6_HRV\"\n $ruleSetChoices[\"Opt-FloorHeader\"] = \"NBC_Wall_zone6_HRV\"\n $ruleSetChoices[\"Opt-AtticCeilings\"] = \"NBC_Ceiling_zone6\"\n $ruleSetChoices[\"Opt-CathCeilings\"] = \"NBC_FlatCeiling_zone6\"\n $ruleSetChoices[\"Opt-FlatCeilings\"] = \"NBC_FlatCeiling_zone6\"\n\n $ruleSetChoices[\"Opt-ExposedFloor\"] = \"NBC_exposed_zone6\"\n\n # Effective thermal resistance of fenestration (Table 9.36.2.7.(1))\n $ruleSetChoices[\"Opt-CasementWindows\"] = \"NBC-zone6-window\"\n $ruleSetChoices[\"Opt-Doors\"] = \"NBC-zone6-door\"\n $ruleSetChoices[\"Opt-DoorWindows\"] = \"NBC-zone6-Doorwindow\"\n\n # Effective thermal resistance of assemblies below-grade or in contact with the ground (Table 9.36.2.8.A&B)\n $ruleSetChoices[\"Opt-H2KFoundation\"] = \"NBC_BCIN_zone6_HRV\"\n if isCrawlHeated\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SCB_zone6_HRV\"\n else # There is a crawlspace, but it isn't heated. Treat floor above crawlspace as exposed floor\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SOnly_zone6\" # If there are any slabs, insulate them\n $ruleSetChoices[\"Opt-FloorAboveCrawl\"] = \"NBC_crawlceiling_zone6\"\n end\n\n # Zone 7A ( 5000 < HDD < 5999) with an HRV\n elsif locale_HDD >= 5000 && locale_HDD < 5999\n # Effective thermal resistance of above-ground opaque assemblies (Table 9.36.2.6 A&B)\n $ruleSetChoices[\"Opt-GenericWall_1Layer_definitions\"] = \"NBC_Wall_zone7A_HRV\"\n $ruleSetChoices[\"Opt-FloorHeader\"] = \"NBC_Wall_zone7A_HRV\"\n $ruleSetChoices[\"Opt-AtticCeilings\"] = \"NBC_Ceiling_zone7A_HRV\"\n $ruleSetChoices[\"Opt-CathCeilings\"] = \"NBC_FlatCeiling_zone7A\"\n $ruleSetChoices[\"Opt-FlatCeilings\"] = \"NBC_FlatCeiling_zone7A\"\n\n $ruleSetChoices[\"Opt-ExposedFloor\"] = \"NBC_exposed_zone7A\"\n\n # Effective thermal resistance of fenestration (Table 9.36.2.7.(1))\n $ruleSetChoices[\"Opt-CasementWindows\"] = \"NBC-zone7A-window\"\n $ruleSetChoices[\"Opt-Doors\"] = \"NBC-zone7A-door\"\n $ruleSetChoices[\"Opt-DoorWindows\"] = \"NBC-zone7A-Doorwindow\"\n\n # Effective thermal resistance of assemblies below-grade or in contact with the ground (Table 9.36.2.8.A&B)\n $ruleSetChoices[\"Opt-H2KFoundation\"] = \"NBC_BCIN_zone7A_HRV\"\n if isCrawlHeated\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SCB_zone7A_HRV\"\n else # There is a crawlspace, but it isn't heated. Treat floor above crawlspace as exposed floor\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SOnly_zone7A_HRV\" # If there are any slabs, insulate them\n $ruleSetChoices[\"Opt-FloorAboveCrawl\"] = \"NBC_crawlceiling_zone7A\"\n end\n\n # Zone 7B ( 6000 < HDD < 6999) with an HRV\n elsif locale_HDD >= 6000 && locale_HDD < 6999\n # Effective thermal resistance of above-ground opaque assemblies (Table 9.36.2.6 A&B)\n $ruleSetChoices[\"Opt-GenericWall_1Layer_definitions\"] = \"NBC_Wall_zone7B_HRV\"\n $ruleSetChoices[\"Opt-FloorHeader\"] = \"NBC_Wall_zone7B_HRV\"\n $ruleSetChoices[\"Opt-AtticCeilings\"] = \"NBC_Ceiling_zone7B\"\n $ruleSetChoices[\"Opt-CathCeilings\"] = \"NBC_FlatCeiling_zone7B\"\n $ruleSetChoices[\"Opt-FlatCeilings\"] = \"NBC_FlatCeiling_zone7B\"\n\n $ruleSetChoices[\"Opt-ExposedFloor\"] = \"NBC_exposed_zone7B\"\n\n # Effective thermal resistance of fenestration (Table 9.36.2.7.(1))\n $ruleSetChoices[\"Opt-CasementWindows\"] = \"NBC-zone7B-window\"\n $ruleSetChoices[\"Opt-Doors\"] = \"NBC-zone7B-door\"\n $ruleSetChoices[\"Opt-DoorWindows\"] = \"NBC-zone7B-Doorwindow\"\n\n # Effective thermal resistance of assemblies below-grade or in contact with the ground (Table 9.36.2.8.A&B)\n $ruleSetChoices[\"Opt-H2KFoundation\"] = \"NBC_BCIN_zone7B_HRV\"\n if isCrawlHeated\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SCB_zone7B_HRV\"\n else # There is a crawlspace, but it isn't heated. Treat floor above crawlspace as exposed floor\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SOnly_zone7B_HRV\" # If there are any slabs, insulate them\n $ruleSetChoices[\"Opt-FloorAboveCrawl\"] = \"NBC_crawlceiling_zone7B\"\n end\n\n # Zone 8 (HDD <= 7000) with an HRV\n elsif locale_HDD >= 7000\n # Effective thermal resistance of above-ground opaque assemblies (Table 9.36.2.6 A&B)\n $ruleSetChoices[\"Opt-GenericWall_1Layer_definitions\"] = \"NBC_Wall_zone8_HRV\"\n $ruleSetChoices[\"Opt-FloorHeader\"] = \"NBC_Wall_zone8_HRV\"\n $ruleSetChoices[\"Opt-AtticCeilings\"] = \"NBC_Ceiling_zone8\"\n $ruleSetChoices[\"Opt-CathCeilings\"] = \"NBC_FlatCeiling_zone8\"\n $ruleSetChoices[\"Opt-FlatCeilings\"] = \"NBC_FlatCeiling_zone8\"\n\n $ruleSetChoices[\"Opt-ExposedFloor\"] = \"NBC_exposed_zone8\"\n\n # Effective thermal resistance of fenestration (Table 9.36.2.7.(1))\n $ruleSetChoices[\"Opt-CasementWindows\"] = \"NBC-zone8-window\"\n $ruleSetChoices[\"Opt-Doors\"] = \"NBC-zone8-door\"\n $ruleSetChoices[\"Opt-DoorWindows\"] = \"NBC-zone8-Doorwindow\"\n\n # Effective thermal resistance of assemblies below-grade or in contact with the ground (Table 9.36.2.8.A&B)\n $ruleSetChoices[\"Opt-H2KFoundation\"] = \"NBC_BCIN_zone8_HRV\"\n if isCrawlHeated\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SCB_zone8_HRV\"\n else # There is a crawlspace, but it isn't heated. Treat floor above crawlspace as exposed floor\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SOnly_zone8_HRV\" # If there are any slabs, insulate them\n $ruleSetChoices[\"Opt-FloorAboveCrawl\"] = \"NBC_crawlceiling_zone8\"\n end\n\n end\n end # Check on NBC rule set type\nend",
"def hypothesis6(countsXmajor) \n\tcriteria = 0\n\teuks = 0\n\teuks += 1 if countsXmajor['Sr'] >= 0.25\n\teuks += 1 if countsXmajor['Pl'] >= 0.25\n\teuks += 1 if countsXmajor['Op'] >= 0.25\n\teuks += 1 if countsXmajor['EE'] >= 0.25\n\teuks += 1 if countsXmajor['Am'] >= 0.25\n\teuks += 1 if countsXmajor['Ex'] >= 0.25\t\n\tcriteria += 1 if countsXmajor['Ba'] < 0.25\n\tcriteria += 1 if countsXmajor['Za'] < 0.25\n\tcriteria += 1 if euks >= 5\n\tif criteria == 3\n\t\treturn 1\n\telse\n\t\treturn 0 \n\tend\nend",
"def confidence_avail_db\n\n case hgt_type\n when :regular then [1]\n when :all then [1,0]\n else raise AssertError.new \"\"\n end\n\n end",
"def restriction\r\n states.collect {|state| state.restriction }.push(0).max\r\n end",
"def validate(env, intention, attributes)\n # If AdminSet was selected, look for its PermissionTemplate\n template = PermissionTemplate.find_by!(source_id: attributes[:admin_set_id]) if attributes[:admin_set_id].present?\n\n validate_lease(env, intention, template) &&\n validate_release_type(env, intention, template) &&\n validate_visibility(env, attributes, template) &&\n validate_embargo(env, intention, attributes, template)\n end",
"def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n \n # Make an argument to apply/not apply this measure\n chs = OpenStudio::StringVector.new\n chs << \"TRUE\"\n chs << \"FALSE\"\n apply_measure = OpenStudio::Ruleset::OSArgument::makeChoiceArgument('apply_measure', chs, true)\n apply_measure.setDisplayName(\"Apply Measure?\")\n apply_measure.setDefaultValue(\"TRUE\")\n args << apply_measure\n \n #Argument 1 Type of Chilled Beam System, required, choice, default Active\n beam_options = [\"Active\", \"Passive\"]\n cooled_beam_type = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"cooled_beam_type\", beam_options,true)\n cooled_beam_type.setDisplayName('Select the Type of Chilled Beam to be added and indicate the Thermal Zones that Chilled Beams will be added to. NOTE: Users should confirm subsequent chilled beam model parameters. Defaulted coefficient values may not be representative of actual chilled beam performance')\n cooled_beam_type.setDefaultValue(\"Active\")\n args << cooled_beam_type\n \n #Argument 3 Chilled Water Loop selection or creation \n existing_plant_loops = model.getPlantLoops\n existing_chilled_loops = existing_plant_loops.select{ |pl| pl.sizingPlant.loopType() == \"Cooling\"}\n existing_plant_names = existing_chilled_loops.select{ |pl| not pl.name.empty?}.collect{ |pl| pl.name.get }\n existing_plant_names << \"Create New\"\n existing_plant_loop_name = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"existing_plant_loop_name\", existing_plant_names, true)\n existing_plant_loop_name.setDisplayName('Chilled Water loop serving chilled beams. If \"Create New\" is selected a loop containing an air cooled chiller (COP=3.5) generating chilled water at 57 Deg F will be created. A constant speed pump (with user defined pressure rise) will be created.')\n existing_plant_loop_name.setDefaultValue (\"Create New\")\n args << existing_plant_loop_name\n \n #argument 4, new loop rated pump head type double, required, double, default 60 feet\n new_loop_rated_pump_head = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('new_loop_pump_head', true)\n new_loop_rated_pump_head.setDisplayName('The pump head (in feet of water) that will be assigned to the primary chilled water loop circulation pump. This argument will only be used if a new chilled water plant loop is created.')\n new_loop_rated_pump_head.setDefaultValue (60)\n args<< new_loop_rated_pump_head\n #must check interpretation of the 60 default value for pump head. meant to be 60 feet.\n \n #argument 5. air_loop_name, required, double, default Create New\n air_loops_list = model.getAirLoopHVACs.collect { |l| l.name.get }\n air_loops_list << \"Create New\"\n air_loop_name = OpenStudio::Ruleset::OSArgument::makeChoiceArgument('air_loop_name', air_loops_list, true)\n air_loop_name.setDisplayName('Air loop to serve selected zones by chilled beam units. This should be an air loop configured as a DOAS. If \"Create New\" is selected, an air loop containing a Dual Wheel DOAS system with a chilled water coil served by the user selected chiller plant loop will be created. The DOAS will be configured to deliver a constant temperature of 65 Deg F to connected zones.')\n air_loop_name.setDefaultValue (\"Create New\")\n args << air_loop_name\n \n #argument 5.5 (mislabeled in spec) new airloop fan pressure rise, required, double, default none\n new_airloop_fan_pressure_rise = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('new_airloop_fan_pressure_rise',true)\n new_airloop_fan_pressure_rise.setDisplayName('The pressure rise (inches of water) that will be assigned to the constant speed fans of a new air loop. This pressure rise, which includes the pressure across an energy wheel, will be split evenly between the new supply and exhaust fans.')\n new_airloop_fan_pressure_rise.setDefaultValue(\"5.00\")\n args << new_airloop_fan_pressure_rise\n \n #argument 6 supply air vol flow rate, double, default to -1\n supply_air_vol_flow_rate = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('supply_air_vol_flow_rate',true)\n supply_air_vol_flow_rate.setDisplayName('The combined air flow rate (cfm) of the supply air serving all chilled beams in a zone. Enter -1 to autosize (based on the zone ventilation requirement). If a value is entered, and multiple thermal zones are selected, this value will be hard coded to all selected zones.')\n supply_air_vol_flow_rate.setDefaultValue(\"-1\")\n args << supply_air_vol_flow_rate\n \n #argument 7 max tot chw vol flow rate, required, double, default -1\n max_tot_chw_vol_flow_rate = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('max_tot_chw_vol_flow_rate',true)\n max_tot_chw_vol_flow_rate.setDisplayName('Combined maximum chilled water flow rate (gpm) of all chilled beam units serving a zone. Enter -1 to autosize based on the zone design load. If a value is entered, and multiple thermal zones are selected, this value will be hard coded to all selected zones.')\n max_tot_chw_vol_flow_rate.setDefaultValue(\"-1\")\n args << max_tot_chw_vol_flow_rate\n \n #arg 8 number of beams, required, double, default -1\n number_of_beams = OpenStudio::Ruleset::OSArgument::makeIntegerArgument('number_of_beams',true)\n number_of_beams.setDisplayName('The number of individual chilled beam units serving each zone. Enter -1 to autosize based on a value of 1.11 GPM per chilled beam unit.')\n number_of_beams.setDefaultValue(\"-1\")\n args << number_of_beams\n \n #arg9 beam_length, required, double, defailt -1\n beam_length = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('beam_length',true)\n beam_length.setDisplayName('The length (ft) of an individual beam. Enter -1 to autosize based upon the # of beam units and the zone design sensible cooling load.')\n beam_length.setDefaultValue(\"-1\")\n args << beam_length\n \n #arg10 design_inlet_water_temperature, requried, double, default 59\n design_inlet_water_temperature = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('design_inlet_water_temperature',true)\n design_inlet_water_temperature.setDisplayName('The design inlet water temperature (Deg F) of a beam unit.')\n design_inlet_water_temperature.setDefaultValue(\"59\")\n args << design_inlet_water_temperature\n \n #arg11 design_outlet_water_temperature, required, double, default 62.6\n design_outlet_water_temperature = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('design_outlet_water_temperature',true)\n design_outlet_water_temperature.setDisplayName('The design outlet water temperature )Deg F) of the beam units.')\n design_outlet_water_temperature.setDefaultValue(\"62.6\")\n args << design_outlet_water_temperature\n \n #arg12 coil_surface_area_per_coil_length, required, double, default 17.78\n coil_surface_area_per_coil_length = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('coil_surface_area_per_coil_length',true)\n coil_surface_area_per_coil_length.setDisplayName('Surface area on the air side of the beam per unit beam length (ft^2/ft). This parameter is a unique value representing specific chilled beam products. See E+ Engineering Reference for equation details')\n coil_surface_area_per_coil_length.setDefaultValue(\"17.78\")\n args << coil_surface_area_per_coil_length\n \n #arg13 coefficient_alpha required, double, default 15.3\n coefficient_alpha = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('coefficient_alpha',true)\n coefficient_alpha.setDisplayName('Model parameter alpha (unitless). This parameter is a unique value representing specific chilled beam products. See E+ Engineering Reference for equation details')\n coefficient_alpha.setDefaultValue(\"15.3\")\n args << coefficient_alpha\n \n #arg14 coefficient_n1, required, double, default 0\n coefficient_n1 = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('coefficient_n1',true)\n coefficient_n1.setDisplayName('Model parameter n1 (unitless). This parameter is a unique value representing specific chilled beam products. See E+ Engineering Reference for equation details')\n coefficient_n1.setDefaultValue(\"0\")\n args << coefficient_n1\n \n #arg15 coefficient_n2,required, double, default .84)\n coefficient_n2 = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('coefficient_n2',true)\n coefficient_n2.setDisplayName('Model parameter n2 (unitless). This parameter is a unique value representing specific chilled beam products. See E+ Engineering Reference for equation details')\n coefficient_n2.setDefaultValue(\"0.84\")\n args << coefficient_n2\n\n #arg16 coefficient_n3,required, double, default .84)\n coefficient_n3 = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('coefficient_n3',true)\n coefficient_n3.setDisplayName('Model parameter n3 (unitless). This parameter is a unique value representing specific chilled beam products. See E+ Engineering Reference for equation details')\n coefficient_n3.setDefaultValue(\".12\")\n args << coefficient_n3\n \n #arg17 coefficient_a0,required, double, default .5610)\n coefficient_a0 = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('coefficient_a0',true)\n coefficient_a0.setDisplayName('Model parameter a0 (unitless). This parameter is a unique value representing specific chilled beam products. See E+ Engineering Reference for equation details')\n coefficient_a0.setDefaultValue(\".5610\")\n args << coefficient_a0\n \n #arg18 coefficient_k1,required, double, default .00571)\n coefficient_k1 = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('coefficient_k1',true)\n coefficient_k1.setDisplayName('Model parameter k1 (unitless). This parameter is a unique value representing specific chilled beam products. See E+ Engineering Reference for equation details')\n coefficient_k1.setDefaultValue(\".005710\")\n args << coefficient_k1\n \n #arg19 coefficient_n,required, double, default .40)\n coefficient_n = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('coefficient_n',true)\n coefficient_n.setDisplayName('Model parameter n (unitless). This parameter is a unique value representing specific chilled beam products. See E+ Engineering Reference for equation details')\n coefficient_n.setDefaultValue(\".400\")\n args << coefficient_n\n \n #arg20 coefficient_kin,required, double, default 2.0)\n coefficient_kin = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('coefficient_kin',true)\n coefficient_kin.setDisplayName('Model parameter kin (unitless). This parameter is a unique value representing specific chilled beam products. See E+ Engineering Reference for equation details')\n coefficient_kin.setDefaultValue(\"2.0\")\n args << coefficient_kin\n \n #argument 21 leaving_pipe_inside_dia, required, choice, default \"1/2 type K\"\n pipe_inside_dia_options = [\"1/2 Type K\", \"1/2 Type L\", \"3/4 Type K\", \"3/4 Type L\"]\n leaving_pipe_inside_dia = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"leaving_pipe_inside_dia\", pipe_inside_dia_options,true)\n leaving_pipe_inside_dia.setDisplayName('Diameter (inches) of the chilled beam unit water inlet and outlet pipe connections.')\n leaving_pipe_inside_dia.setDefaultValue(\"1/2 Type K\")\n args << leaving_pipe_inside_dia\n #note: [1/2 TypeK = .527 ] [1/2 Type L = .545] [3/4 type k = .745] [3/4 type l=.785]\n \n return args\n end",
"def control_equipments(floor_number, sub_coridor_number)\n floor = self.hotel.get_floor(floor_number)\n return if floor.nil?\n\n floor.main_coridors.each do |main_coridor| \n @sub_coridor = main_coridor.get_sub_coridor(sub_coridor_number)\n @idle_sub_coridor = main_coridor.get_idle_sub_coridor(sub_coridor_number) \n break if @sub_coridor\n end\n \n (self.hotel.reset_equipments and return )if @sub_coridor.nil?\n\n @sub_coridor.bulb.switch_on!\n @sub_coridor.set_last_operated_at!\n @idle_sub_coridor.ac.switch_off! if floor.is_power_consumption_exceeding?\n\n self.hotel.reset_equipments\n end",
"def virality\n 0\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # Use the built-in error checking \n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # Return N/A if not selected to run\n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\n if run_measure == 0\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\n return true \n end \n \n\n\n \n \n # Load some helper libraries\n require_relative 'resources/RemoveHVAC.Model'\n require_relative 'resources/OsLib_Schedules'\n \n # Extract an HVAC operation and ventilation schedule from\n # airloop serving the most zones in the current model\n air_loop_most_zones = nil\n max_zones = 0\n model.getAirLoopHVACs.each do |air_loop|\n num_zones = air_loop.thermalZones.size\n if num_zones > max_zones\n air_loop_most_zones = air_loop\n max_zones = num_zones\n end\n end\n building_HVAC_schedule = nil\n building_ventilation_schedule = nil\n if air_loop_most_zones\n building_HVAC_schedule = air_loop_most_zones.availabilitySchedule\n if air_loop_most_zones.airLoopHVACOutdoorAirSystem.is_initialized\n building_ventilation_schedule = air_loop_most_zones.airLoopHVACOutdoorAirSystem.get.getControllerOutdoorAir.maximumFractionofOutdoorAirSchedule\n if building_ventilation_schedule.is_initialized\n building_ventilation_schedule = building_ventilation_schedule.get\n end\n end \n end\n if building_HVAC_schedule.nil?\n building_HVAC_schedule = model.alwaysOnDiscreteSchedule\n end\n if building_ventilation_schedule.nil?\n building_ventilation_schedule = model.alwaysOnDiscreteSchedule\n end\n \n # Remove the existing HVAC equipment\n model.removeHVAC\n \n # Make the new schedules\n sch_ruleset_DOAS_setpoint = OsLib_Schedules.createComplexSchedule(model, {\"name\" => \"AEDG DOAS Temperature Setpoint Schedule\",\n \"default_day\" => [\"All Days\",[24,20.0]]})\n \n # Create a chilled water system to serve the DOAS\n chilled_water_plant = OpenStudio::Model::PlantLoop.new(model)\n chilled_water_plant.setName(\"Chilled Water Loop\")\n chilled_water_plant.setMaximumLoopTemperature(98)\n chilled_water_plant.setMinimumLoopTemperature(1)\n loop_sizing = chilled_water_plant.sizingPlant\n loop_sizing.setLoopType(\"Cooling\")\n loop_sizing.setDesignLoopExitTemperature(6.7) \n loop_sizing.setLoopDesignTemperatureDifference(6.7)\n \n # Create a pump\n pump = OpenStudio::Model::PumpVariableSpeed.new(model)\n pump.setRatedPumpHead(149453) #Pa\n pump.setMotorEfficiency(0.9)\n pump.setCoefficient1ofthePartLoadPerformanceCurve(0)\n pump.setCoefficient2ofthePartLoadPerformanceCurve(0.0216)\n pump.setCoefficient3ofthePartLoadPerformanceCurve(-0.0325)\n pump.setCoefficient4ofthePartLoadPerformanceCurve(1.0095)\n \n # Create a chiller\n # Create clgCapFuncTempCurve\n clgCapFuncTempCurve = OpenStudio::Model::CurveBiquadratic.new(model)\n clgCapFuncTempCurve.setCoefficient1Constant(1.05E+00)\n clgCapFuncTempCurve.setCoefficient2x(3.36E-02)\n clgCapFuncTempCurve.setCoefficient3xPOW2(2.15E-04)\n clgCapFuncTempCurve.setCoefficient4y(-5.18E-03)\n clgCapFuncTempCurve.setCoefficient5yPOW2(-4.42E-05)\n clgCapFuncTempCurve.setCoefficient6xTIMESY(-2.15E-04)\n clgCapFuncTempCurve.setMinimumValueofx(0)\n clgCapFuncTempCurve.setMaximumValueofx(20)\n clgCapFuncTempCurve.setMinimumValueofy(0)\n clgCapFuncTempCurve.setMaximumValueofy(50)\n \n # Create eirFuncTempCurve\n eirFuncTempCurve = OpenStudio::Model::CurveBiquadratic.new(model)\n eirFuncTempCurve.setCoefficient1Constant(5.83E-01)\n eirFuncTempCurve.setCoefficient2x(-4.04E-03)\n eirFuncTempCurve.setCoefficient3xPOW2(4.68E-04)\n eirFuncTempCurve.setCoefficient4y(-2.24E-04)\n eirFuncTempCurve.setCoefficient5yPOW2(4.81E-04)\n eirFuncTempCurve.setCoefficient6xTIMESY(-6.82E-04)\n eirFuncTempCurve.setMinimumValueofx(0)\n eirFuncTempCurve.setMaximumValueofx(20)\n eirFuncTempCurve.setMinimumValueofy(0)\n eirFuncTempCurve.setMaximumValueofy(50)\n \n # Create eirFuncPlrCurve\n eirFuncPlrCurve = OpenStudio::Model::CurveQuadratic.new(model)\n eirFuncPlrCurve.setCoefficient1Constant(4.19E-02)\n eirFuncPlrCurve.setCoefficient2x(6.25E-01)\n eirFuncPlrCurve.setCoefficient3xPOW2(3.23E-01)\n eirFuncPlrCurve.setMinimumValueofx(0)\n eirFuncPlrCurve.setMaximumValueofx(1.2)\n \n # Construct chiller\n chiller = OpenStudio::Model::ChillerElectricEIR.new(model,clgCapFuncTempCurve,eirFuncTempCurve,eirFuncPlrCurve)\n chiller.setReferenceCOP(2.93)\n chiller.setCondenserType(\"AirCooled\")\n chiller.setChillerFlowMode(\"ConstantFlow\")\n \n # Create a scheduled setpoint manager\n chilled_water_setpoint_schedule = OsLib_Schedules.createComplexSchedule(model, {\"name\" => \"AEDG CW-Loop-Temp-Schedule\",\n \"default_day\" => [\"All Days\",[24,6.7]]})\n setpoint_manager_scheduled = OpenStudio::Model::SetpointManagerScheduled.new(model,chilled_water_setpoint_schedule)\n # Create a supply bypass pipe\n pipe_supply_bypass = OpenStudio::Model::PipeAdiabatic.new(model)\n # Create a supply outlet pipe\n pipe_supply_outlet = OpenStudio::Model::PipeAdiabatic.new(model)\n # Create a demand bypass pipe\n pipe_demand_bypass = OpenStudio::Model::PipeAdiabatic.new(model)\n # Create a demand inlet pipe\n pipe_demand_inlet = OpenStudio::Model::PipeAdiabatic.new(model)\n # Create a demand outlet pipe\n pipe_demand_outlet = OpenStudio::Model::PipeAdiabatic.new(model)\n \n # Connect supply side components to plant loop\n chilled_water_plant.addSupplyBranchForComponent(chiller)\n chilled_water_plant.addSupplyBranchForComponent(pipe_supply_bypass)\n pump.addToNode(chilled_water_plant.supplyInletNode)\n pipe_supply_outlet.addToNode(chilled_water_plant.supplyOutletNode)\n setpoint_manager_scheduled.addToNode(chilled_water_plant.supplyOutletNode)\n \n # Connect demand side components to plant loop.\n # Water coils are added as they are added to airloops and ZoneHVAC.\n chilled_water_plant.addDemandBranchForComponent(pipe_demand_bypass)\n pipe_demand_inlet.addToNode(chilled_water_plant.demandInletNode)\n pipe_demand_outlet.addToNode(chilled_water_plant.demandOutletNode)\n\n \n \n # Create a hot water system to serve the DOAS\n hot_water_plant = OpenStudio::Model::PlantLoop.new(model)\n hot_water_plant.setName(\"Hot Water Loop\")\n hot_water_plant.setMaximumLoopTemperature(100)\n hot_water_plant.setMinimumLoopTemperature(10)\n loop_sizing = hot_water_plant.sizingPlant\n loop_sizing.setLoopType(\"Heating\")\n loop_sizing.setDesignLoopExitTemperature(82) \n loop_sizing.setLoopDesignTemperatureDifference(11)\n \n # Create a pump\n pump = OpenStudio::Model::PumpVariableSpeed.new(model)\n pump.setRatedPumpHead(119563) #Pa\n pump.setMotorEfficiency(0.9)\n pump.setCoefficient1ofthePartLoadPerformanceCurve(0)\n pump.setCoefficient2ofthePartLoadPerformanceCurve(0.0216)\n pump.setCoefficient3ofthePartLoadPerformanceCurve(-0.0325)\n pump.setCoefficient4ofthePartLoadPerformanceCurve(1.0095)\n \n # Create a boiler\n boiler = OpenStudio::Model::BoilerHotWater.new(model)\n boiler.setNominalThermalEfficiency(0.9)\n \n # Create a scheduled setpoint manager\n # Create a scheduled setpoint manager\n hot_water_setpoint_schedule = OsLib_Schedules.createComplexSchedule(model, {\"name\" => \"AEDG HW-Loop-Temp-Schedule\",\n \"default_day\" => [\"All Days\",[24,67.0]]})\n setpoint_manager_scheduled = OpenStudio::Model::SetpointManagerScheduled.new(model,hot_water_setpoint_schedule)\n \n # Create a supply bypass pipe\n pipe_supply_bypass = OpenStudio::Model::PipeAdiabatic.new(model)\n # Create a supply outlet pipe\n pipe_supply_outlet = OpenStudio::Model::PipeAdiabatic.new(model)\n # Create a demand bypass pipe\n pipe_demand_bypass = OpenStudio::Model::PipeAdiabatic.new(model)\n # Create a demand inlet pipe\n pipe_demand_inlet = OpenStudio::Model::PipeAdiabatic.new(model)\n # Create a demand outlet pipe\n pipe_demand_outlet = OpenStudio::Model::PipeAdiabatic.new(model)\n \n # Connect supply side components to plant loop\n hot_water_plant.addSupplyBranchForComponent(boiler)\n hot_water_plant.addSupplyBranchForComponent(pipe_supply_bypass)\n pump.addToNode(hot_water_plant.supplyInletNode)\n pipe_supply_outlet.addToNode(hot_water_plant.supplyOutletNode)\n setpoint_manager_scheduled.addToNode(hot_water_plant.supplyOutletNode)\n \n # Connect demand side components to plant loop.\n # Water coils are added as they are added to airloops and ZoneHVAC.\n hot_water_plant.addDemandBranchForComponent(pipe_demand_bypass)\n pipe_demand_inlet.addToNode(hot_water_plant.demandInletNode)\n pipe_demand_outlet.addToNode(hot_water_plant.demandOutletNode)\n\n \n # Create a single DOAS system to serve all the zones\n doas_air_loop = OpenStudio::Model::AirLoopHVAC.new(model)\n doas_air_loop.setName(\"DOAS\")\n \n # Modify system sizing properties\n sizing_system = doas_air_loop.sizingSystem\n sizing_system.setCentralCoolingDesignSupplyAirTemperature(12.8)\n sizing_system.setCentralHeatingDesignSupplyAirTemperature(40)\n sizing_system.setTypeofLoadtoSizeOn(\"VentilationRequirement\") #DOAS\n sizing_system.setAllOutdoorAirinCooling(true) #DOAS\n sizing_system.setAllOutdoorAirinHeating(true) #DOAS\n sizing_system.setMinimumSystemAirFlowRatio(0.3) #DCV\n \n # Set availability schedule\n doas_air_loop.setAvailabilitySchedule(building_HVAC_schedule)\n \n # Add each component to this array\n # to be attached to doas air loop later\n air_loop_comps = []\n \n # Create variable speed fan\n fan = OpenStudio::Model::FanVariableVolume.new(model, model.alwaysOnDiscreteSchedule)\n fan.setFanEfficiency(0.69)\n fan.setPressureRise(1125) #Pa\n fan.autosizeMaximumFlowRate()\n fan.setFanPowerMinimumFlowFraction(0.6)\n fan.setMotorEfficiency(0.9)\n fan.setMotorInAirstreamFraction(1.0)\n air_loop_comps << fan \n \n # Create hot water heating coil\n heating_coil = OpenStudio::Model::CoilHeatingWater.new(model, model.alwaysOnDiscreteSchedule)\n air_loop_comps << heating_coil\n \n # Create chilled water cooling coil\n cooling_coil = OpenStudio::Model::CoilCoolingWater.new(model, model.alwaysOnDiscreteSchedule)\n air_loop_comps << cooling_coil\n \n # Create controller outdoor air\n controller_OA = OpenStudio::Model::ControllerOutdoorAir.new(model)\n controller_OA.autosizeMinimumOutdoorAirFlowRate()\n controller_OA.autosizeMaximumOutdoorAirFlowRate()\n \n # Create ventilation schedules and assign to OA controller\n controller_OA.setMinimumFractionofOutdoorAirSchedule(model.alwaysOnDiscreteSchedule)\n controller_OA.setMaximumFractionofOutdoorAirSchedule(model.alwaysOnDiscreteSchedule) \n controller_OA.setHeatRecoveryBypassControlType(\"BypassWhenOAFlowGreaterThanMinimum\")\n \n # Create outdoor air system\n system_OA = OpenStudio::Model::AirLoopHVACOutdoorAirSystem.new(model, controller_OA)\n air_loop_comps << system_OA\n \n # Create ERV\n heat_exchanger = OpenStudio::Model::HeatExchangerAirToAirSensibleAndLatent.new(model)\n heat_exchanger.setAvailabilitySchedule(model.alwaysOnDiscreteSchedule)\n sensible_eff = 0.75\n latent_eff = 0.69\n heat_exchanger.setSensibleEffectivenessat100CoolingAirFlow(sensible_eff)\n heat_exchanger.setSensibleEffectivenessat100HeatingAirFlow(sensible_eff)\n heat_exchanger.setSensibleEffectivenessat75CoolingAirFlow(sensible_eff)\n heat_exchanger.setSensibleEffectivenessat75HeatingAirFlow(sensible_eff)\n heat_exchanger.setLatentEffectivenessat100CoolingAirFlow(latent_eff)\n heat_exchanger.setLatentEffectivenessat100HeatingAirFlow(latent_eff)\n heat_exchanger.setLatentEffectivenessat75CoolingAirFlow(latent_eff)\n heat_exchanger.setLatentEffectivenessat75HeatingAirFlow(latent_eff)\n heat_exchanger.setFrostControlType(\"ExhaustOnly\")\n heat_exchanger.setThresholdTemperature(-12.2)\n heat_exchanger.setInitialDefrostTimeFraction(0.1670)\n heat_exchanger.setRateofDefrostTimeFractionIncrease(0.0240)\n heat_exchanger.setEconomizerLockout(false)\n heat_exchanger.addToNode(system_OA.outboardOANode.get)\n\n # Create scheduled setpoint manager for airloop\n primary_sat_schedule = OsLib_Schedules.createComplexSchedule(model, {\"name\" => \"AEDG Cold Deck Temperature Setpoint Schedule\",\n \"default_day\" => [\"All Days\",[24,12.8]]})\n setpoint_manager = OpenStudio::Model::SetpointManagerScheduled.new(model,primary_sat_schedule)\n \n \n # Connect components to airloop\n # find the supply inlet node of the airloop\n airloop_supply_inlet = doas_air_loop.supplyInletNode\n air_loop_comps.each do |comp|\n comp.addToNode(airloop_supply_inlet)\n if comp.to_CoilHeatingWater.is_initialized\n hot_water_plant.addDemandBranchForComponent(comp)\n comp.controllerWaterCoil.get.setMinimumActuatedFlow(0)\n elsif comp.to_CoilCoolingWater.is_initialized\n chilled_water_plant.addDemandBranchForComponent(comp)\n comp.controllerWaterCoil.get.setMinimumActuatedFlow(0)\n end\n end\n setpoint_manager.addToNode(doas_air_loop.supplyOutletNode)\n \n # Make an air terminal for the doas for each zone\n model.getThermalZones.each do |zone| # TODO more intelligent way to skip attics & plenums\n next if zone.name.get.include?(\"Attic\")\n air_terminal = OpenStudio::Model::AirTerminalSingleDuctVAVNoReheat.new(model, model.alwaysOnDiscreteSchedule)\n doas_air_loop.addBranchForZone(zone, air_terminal.to_StraightComponent)\n end\n \n \n # Create a condenser loop to serve the GSHPs\n gshp_loop = OpenStudio::Model::PlantLoop.new(model)\n gshp_loop.setName(\"AEDG Heat Pump Loop\")\n gshp_loop.setMaximumLoopTemperature(80)\n gshp_loop.setMinimumLoopTemperature(1)\n loop_sizing = gshp_loop.sizingPlant\n loop_sizing.setLoopType(\"Condenser\")\n loop_sizing.setDesignLoopExitTemperature(21)\n loop_sizing.setLoopDesignTemperatureDifference(5) \n \n # Create a pump\n pump = OpenStudio::Model::PumpVariableSpeed.new(model)\n pump.setRatedPumpHead(134508) #Pa\n pump.setMotorEfficiency(0.9)\n pump.setCoefficient1ofthePartLoadPerformanceCurve(0)\n pump.setCoefficient2ofthePartLoadPerformanceCurve(0.0216)\n pump.setCoefficient3ofthePartLoadPerformanceCurve(-0.0325)\n pump.setCoefficient4ofthePartLoadPerformanceCurve(1.0095)\n \n # Create a supply bypass pipe\n pipe_supply_bypass = OpenStudio::Model::PipeAdiabatic.new(model)\n # Create a supply outlet pipe\n pipe_supply_outlet = OpenStudio::Model::PipeAdiabatic.new(model)\n # Create a demand bypass pipe\n pipe_demand_bypass = OpenStudio::Model::PipeAdiabatic.new(model)\n # Create a demand inlet pipe\n pipe_demand_inlet = OpenStudio::Model::PipeAdiabatic.new(model)\n # Create a demand outlet pipe\n pipe_demand_outlet = OpenStudio::Model::PipeAdiabatic.new(model)\n \n # Create setpoint managers\n hp_loop_cooling_sch = OsLib_Schedules.createComplexSchedule(model, {\"name\" => \"AEDG HP-Loop-Clg-Temp-Schedule\",\n \"default_day\" => [\"All Days\",[24,21]]})\n hp_loop_heating_sch = OsLib_Schedules.createComplexSchedule(model, {\"name\" => \"AEDG HP-Loop-Htg-Temp-Schedule\",\n \"default_day\" => [\"All Days\",[24,5]]})\n setpoint_manager_scheduled_loop = OpenStudio::Model::SetpointManagerScheduled.new(model,hp_loop_cooling_sch)\n setpoint_manager_scheduled_cooling = OpenStudio::Model::SetpointManagerScheduled.new(model,hp_loop_cooling_sch)\n setpoint_manager_scheduled_heating = OpenStudio::Model::SetpointManagerScheduled.new(model,hp_loop_heating_sch)\n \n # Connect supply components to plant loop\n gshp_loop.addSupplyBranchForComponent(pipe_supply_bypass)\n pump.addToNode(gshp_loop.supplyInletNode)\n pipe_supply_outlet.addToNode(gshp_loop.supplyOutletNode)\n setpoint_manager_scheduled_loop.addToNode(gshp_loop.supplyOutletNode)\n \n # Connect demand components to plant loop\n gshp_loop.addDemandBranchForComponent(pipe_demand_bypass)\n pipe_demand_inlet.addToNode(gshp_loop.demandInletNode)\n pipe_demand_outlet.addToNode(gshp_loop.demandOutletNode)\n # add additional components according to specific system type\n # add district cooling and heating to supply side\n district_cooling = OpenStudio::Model::DistrictCooling.new(model)\n district_cooling.setNominalCapacity(1000000000000) # large number; no autosizing\n gshp_loop.addSupplyBranchForComponent(district_cooling)\n setpoint_manager_scheduled_cooling.addToNode(district_cooling.outletModelObject.get.to_Node.get)\n district_heating = OpenStudio::Model::DistrictHeating.new(model)\n district_heating.setNominalCapacity(1000000000000) # large number; no autosizing\n district_heating.addToNode(district_cooling.outletModelObject.get.to_Node.get)\n setpoint_manager_scheduled_heating.addToNode(district_heating.outletModelObject.get.to_Node.get)\n\n # Create the WSHP for each zone\n model.getThermalZones.each do |zone|\n next if zone.name.get.include?(\"Attic\") # TODO more intelligent way to skip attics & plenums\n # Create fan\n fan = OpenStudio::Model::FanOnOff.new(model, model.alwaysOnDiscreteSchedule)\n fan.setFanEfficiency(0.5)\n fan.setPressureRise(75) #Pa\n fan.autosizeMaximumFlowRate()\n fan.setMotorEfficiency(0.9)\n fan.setMotorInAirstreamFraction(1.0)\n \n # Create cooling coil and connect to heat pump loop\n cooling_coil = OpenStudio::Model::CoilCoolingWaterToAirHeatPumpEquationFit.new(model)\n cooling_coil.setRatedCoolingCoefficientofPerformance(6.45)\n cooling_coil.setTotalCoolingCapacityCoefficient1(-9.149069561)\n cooling_coil.setTotalCoolingCapacityCoefficient2(10.87814026)\n cooling_coil.setTotalCoolingCapacityCoefficient3(-1.718780157)\n cooling_coil.setTotalCoolingCapacityCoefficient4(0.746414818)\n cooling_coil.setTotalCoolingCapacityCoefficient5(0.0)\n cooling_coil.setSensibleCoolingCapacityCoefficient1(-5.462690012)\n cooling_coil.setSensibleCoolingCapacityCoefficient2(17.95968138)\n cooling_coil.setSensibleCoolingCapacityCoefficient3(-11.87818402)\n cooling_coil.setSensibleCoolingCapacityCoefficient4(-0.980163419)\n cooling_coil.setSensibleCoolingCapacityCoefficient5(0.767285761)\n cooling_coil.setSensibleCoolingCapacityCoefficient6(0.0)\n cooling_coil.setCoolingPowerConsumptionCoefficient1(-3.205409884)\n cooling_coil.setCoolingPowerConsumptionCoefficient2(-0.976409399)\n cooling_coil.setCoolingPowerConsumptionCoefficient3(3.97892546)\n cooling_coil.setCoolingPowerConsumptionCoefficient4(0.938181818)\n cooling_coil.setCoolingPowerConsumptionCoefficient5(0.0)\n gshp_loop.addDemandBranchForComponent(cooling_coil)\n \n # Create heating coil and connect to heat pump loop\n heating_coil = OpenStudio::Model::CoilHeatingWaterToAirHeatPumpEquationFit.new(model)\n heating_coil.setRatedHeatingCoefficientofPerformance(4.0)\n heating_coil.setHeatingCapacityCoefficient1(-1.361311959)\n heating_coil.setHeatingCapacityCoefficient2(-2.471798046)\n heating_coil.setHeatingCapacityCoefficient3(4.173164514)\n heating_coil.setHeatingCapacityCoefficient4(0.640757401)\n heating_coil.setHeatingCapacityCoefficient5(0.0)\n heating_coil.setHeatingPowerConsumptionCoefficient1(-2.176941116)\n heating_coil.setHeatingPowerConsumptionCoefficient2(0.832114286)\n heating_coil.setHeatingPowerConsumptionCoefficient3(1.570743399)\n heating_coil.setHeatingPowerConsumptionCoefficient4(0.690793651)\n heating_coil.setHeatingPowerConsumptionCoefficient5(0.0)\n gshp_loop.addDemandBranchForComponent(heating_coil)\n \n # Create supplemental heating coil\n supplemental_heating_coil = OpenStudio::Model::CoilHeatingElectric.new(model, model.alwaysOnDiscreteSchedule)\n \n # Construct heat pump\n heat_pump = OpenStudio::Model::ZoneHVACWaterToAirHeatPump.new(model,\n model.alwaysOnDiscreteSchedule,\n fan,\n heating_coil,\n cooling_coil,\n supplemental_heating_coil)\n heat_pump.setSupplyAirFlowRateWhenNoCoolingorHeatingisNeeded(OpenStudio::OptionalDouble.new(0))\n heat_pump.setOutdoorAirFlowRateDuringCoolingOperation(OpenStudio::OptionalDouble.new(0))\n heat_pump.setOutdoorAirFlowRateDuringHeatingOperation(OpenStudio::OptionalDouble.new(0))\n heat_pump.setOutdoorAirFlowRateWhenNoCoolingorHeatingisNeeded(OpenStudio::OptionalDouble.new(0))\n \n # Add heat pump to thermal zone\n heat_pump.addToThermalZone(zone)\n end\n \n \n return true\n\n end",
"def variable_operation_and_maintenance_costs\n fetch(:variable_operation_and_maintenance_costs) do\n typical_input *\n variable_operation_and_maintenance_costs_per_typical_input\n end\n end",
"def adjust_infiltration_to_prototype_building_conditions(initial_infiltration_rate_m3_per_s)\n\n # Details of these coefficients can be found in paper\n alpha = 0.22 # unitless - terrain adjustment factor\n intial_pressure_pa = 75.0 # 75 Pa\n uh = 4.47 # m/s - wind speed\n rho = 1.18 # kg/m^3 - air density\n cs = 0.1617 # unitless - positive surface pressure coefficient\n n = 0.65 # unitless - infiltration coefficient\n \n # Calculate the typical pressure - same for all building types\n final_pressure_pa = 0.5 * cs * rho * uh**2\n \n #OpenStudio::logFree(OpenStudio::Debug, \"openstudio.Standards.Space\", \"Final pressure PA = #{final_pressure_pa.round(3)} Pa.\")\n\n adjusted_infiltration_rate_m3_per_s = (1.0 + alpha) * initial_infiltration_rate_m3_per_s * (final_pressure_pa/intial_pressure_pa)**n\n\n return adjusted_infiltration_rate_m3_per_s\n\nend",
"def celebrity; end",
"def celebrity; end",
"def sv_missing_confidence_level # should be removed once the alternative solution is implemented. It is heavily used now.\n confidence_level_array = [93]\n confidence_level_array = confidence_level_array & ConfidenceLevel.where(project_id: self.project_id).pluck(:id)\n soft_validations.add(:base, 'Confidence level is missing') if !confidence_level_array.empty? && (self.confidences.pluck(:confidence_level_id) & confidence_level_array).empty?\n end",
"def rule_3 *cards\n if cards.all?(&:face?)\n puts \"Upping the anti! #{cards.map(&:face?)}\"\n cards.raw_integer_value + 50\n end\n end",
"def arguments(model)\r\n args = OpenStudio::Ruleset::OSArgumentVector.new\r\n \r\n #populate choice argument for air loops in the model\r\n air_loop_handles = OpenStudio::StringVector.new\r\n air_loop_display_names = OpenStudio::StringVector.new\r\n\r\n air_loop_display_names, air_loop_handles = airloop_chooser(model)\r\n\r\n #add building to string vector with air loops\r\n building = model.getBuilding\r\n air_loop_handles.unshift(building.handle.to_s)\r\n air_loop_display_names.unshift(\"*All CAV Air Loops*\")\r\n\r\n #make an argument for air loops\r\n object = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"object\", air_loop_handles, air_loop_display_names,true)\r\n object.setDisplayName(\"Choose an Air Loop to change from CAV to VAV.\")\r\n object.setDefaultValue(\"*All CAV Air Loops*\") #if no air loop is chosen this will run on all air loops\r\n args << object\r\n\r\n #make an argument for cooling type\r\n cooling_coil_options = OpenStudio::StringVector.new\r\n cooling_coil_options << \"Two-Stage Compressor\"\r\n cooling_coil_options << \"Four-Stage Compressor\"\r\n cooling_coil_type = OpenStudio::Ruleset::OSArgument::makeChoiceArgument('cooling_coil_type', cooling_coil_options, true)\r\n cooling_coil_type.setDisplayName(\"Choose the type of cooling coil.\")\r\n cooling_coil_type.setDefaultValue(\"Two-Stage Compressor\")\r\n args << cooling_coil_type\r\n \r\n #make an argument for rated cooling coil EER\r\n rated_cc_eer = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('rated_cc_eer', false)\r\n rated_cc_eer.setDisplayName(\"Rated Cooling Coil EER (EER does NOT include effect of evaporator fan)\")\r\n rated_cc_eer.setDefaultValue(9.7)\r\n args << rated_cc_eer\r\n\r\n #make an argument for 75% cooling coil EER\r\n three_quarter_cc_eer = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('three_quarter_cc_eer', false)\r\n three_quarter_cc_eer.setDisplayName(\"Cooling Coil EER at 75% Capacity (EER does NOT include effect of evaporator fan)\")\r\n three_quarter_cc_eer.setDefaultValue(12.6)\r\n args << three_quarter_cc_eer\r\n\r\n #make an argument for 50% cooling coil EER\r\n half_cc_eer = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('half_cc_eer', false)\r\n half_cc_eer.setDisplayName(\"Cooling Coil EER at 50% Capacity (EER does NOT include effect of evaporator fan)\")\r\n half_cc_eer.setDefaultValue(16.0)\r\n args << half_cc_eer\r\n\r\n #make an argument for 25% cooling coil EER\r\n quarter_cc_eer = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('quarter_cc_eer', false)\r\n quarter_cc_eer.setDisplayName(\"Cooling Coil EER at 25% Capacity (EER does NOT include effect of evaporator fan)\")\r\n quarter_cc_eer.setDefaultValue(17.5)\r\n args << quarter_cc_eer\r\n\r\n #make an argument for heating type\r\n heating_coil_options = OpenStudio::StringVector.new\r\n heating_coil_options << \"Gas Heating Coil\"\r\n heating_coil_options << \"Heat Pump\"\r\n heating_coil_type = OpenStudio::Ruleset::OSArgument::makeChoiceArgument('heating_coil_type', heating_coil_options, true)\r\n heating_coil_type.setDisplayName(\"Choose the type of heating coil.\")\r\n heating_coil_type.setDefaultValue(\"Gas Heating Coil\")\r\n args << heating_coil_type\r\n\r\n #make an argument for rated gas heating coil efficiency\r\n rated_hc_gas_efficiency = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('rated_hc_gas_efficiency', false)\r\n rated_hc_gas_efficiency.setDisplayName(\"Rated Gas Heating Coil Efficiency (0-1.00)\")\r\n rated_hc_gas_efficiency.setDefaultValue(0.80)\r\n args << rated_hc_gas_efficiency\r\n\r\n #make an argument for rated heating coil COP\r\n rated_hc_cop = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('rated_hc_cop', false)\r\n rated_hc_cop.setDisplayName(\"Rated Heating Coil COP (COP does NOT include effect of evaporator fan)\")\r\n rated_hc_cop.setDefaultValue(2.8)\r\n args << rated_hc_cop\r\n\r\n #make an argument for 75% heating coil COP\r\n three_quarter_hc_cop = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('three_quarter_hc_cop', false)\r\n three_quarter_hc_cop.setDisplayName(\"Heating Coil COP at 75% Capacity (COP does NOT include effect of evaporator fan)\")\r\n three_quarter_hc_cop.setDefaultValue(3.7)\r\n args << three_quarter_hc_cop\r\n\r\n #make an argument for 50% heating coil COP\r\n half_hc_cop = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('half_hc_cop', false)\r\n half_hc_cop.setDisplayName(\"Heating Coil COP at 50% Capacity (COP does NOT include effect of evaporator fan)\")\r\n half_hc_cop.setDefaultValue(4.7)\r\n args << half_hc_cop\r\n\r\n #make an argument for 25% heating coil COP\r\n quarter_hc_cop = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('quarter_hc_cop', false)\r\n quarter_hc_cop.setDisplayName(\"Heating Coil COP at 25% Capacity (COP does NOT include effect of evaporator fan)\")\r\n quarter_hc_cop.setDefaultValue(5.1)\r\n args << quarter_hc_cop\r\n \r\n #make an argument for ventilation fan speed fraction\r\n vent_fan_speed = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('vent_fan_speed', false)\r\n vent_fan_speed.setDisplayName(\"Fan speed fraction during ventilation mode.\")\r\n vent_fan_speed.setDefaultValue(0.6)\r\n args << vent_fan_speed\r\n\r\n #make an argument for stage_one cooling fan speed fraction\r\n stage_one_cooling_fan_speed = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('stage_one_cooling_fan_speed', false)\r\n stage_one_cooling_fan_speed.setDisplayName(\"Fan speed fraction during stage one DX cooling.\")\r\n stage_one_cooling_fan_speed.setDefaultValue(0.6)\r\n args << stage_one_cooling_fan_speed\r\n\r\n #make an argument for stage_two cooling fan speed fraction\r\n stage_two_cooling_fan_speed = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('stage_two_cooling_fan_speed', false)\r\n stage_two_cooling_fan_speed.setDisplayName(\"Fan speed fraction during stage two DX cooling.\")\r\n stage_two_cooling_fan_speed.setDefaultValue(0.75)\r\n args << stage_two_cooling_fan_speed\r\n\r\n #make an argument for stage_three cooling fan speed fraction\r\n stage_three_cooling_fan_speed = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('stage_three_cooling_fan_speed', false)\r\n stage_three_cooling_fan_speed.setDisplayName(\"Fan speed fraction during stage three DX cooling. Not used for two-speed systems.\")\r\n stage_three_cooling_fan_speed.setDefaultValue(0.85)\r\n args << stage_three_cooling_fan_speed\r\n\r\n #make an argument for stage_four cooling fan speed fraction\r\n stage_four_cooling_fan_speed = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('stage_four_cooling_fan_speed', false)\r\n stage_four_cooling_fan_speed.setDisplayName(\"Fan speed fraction during stage four DX cooling. Not used for two-speed systems.\")\r\n stage_four_cooling_fan_speed.setDefaultValue(1.0)\r\n args << stage_four_cooling_fan_speed\r\n\r\n #make an argument for stage_one heating fan speed fraction\r\n stage_one_heating_fan_speed = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('stage_one_heating_fan_speed', false)\r\n stage_one_heating_fan_speed.setDisplayName(\"Fan speed fraction during stage one DX heating.\")\r\n stage_one_heating_fan_speed.setDefaultValue(0.6)\r\n args << stage_one_heating_fan_speed\r\n\r\n #make an argument for stage_two heating fan speed fraction\r\n stage_two_heating_fan_speed = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('stage_two_heating_fan_speed', false)\r\n stage_two_heating_fan_speed.setDisplayName(\"Fan speed fraction during stage two DX heating.\")\r\n stage_two_heating_fan_speed.setDefaultValue(0.75)\r\n args << stage_two_heating_fan_speed\r\n\r\n #make an argument for stage_three heating fan speed fraction\r\n stage_three_heating_fan_speed = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('stage_three_heating_fan_speed', false)\r\n stage_three_heating_fan_speed.setDisplayName(\"Fan speed fraction during stage three DX heating. Not used for two-speed systems.\")\r\n stage_three_heating_fan_speed.setDefaultValue(0.85)\r\n args << stage_three_heating_fan_speed\r\n\r\n #make an argument for stage_four heating fan speed fraction\r\n stage_four_heating_fan_speed = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('stage_four_heating_fan_speed', false)\r\n stage_four_heating_fan_speed.setDisplayName(\"Fan speed fraction during stage four DX heating. Not used for two-speed systems.\")\r\n stage_four_heating_fan_speed.setDefaultValue(1.0)\r\n args << stage_four_heating_fan_speed\r\n \r\n return args\r\n end",
"def validates_probability_constraints\n if project_state\n if (project_state.name == 'lead') && (probability >= 1.0)\n errors.add(:base,\n \"Probability of #{probability} is not allowed for the project state #{project_state.name}\")\n end\n\n if (project_state.name == 'offered') && (probability >= 1)\n errors.add(:base,\n \"Probability of #{probability} is not allowed for the project state #{project_state.name}\")\n end\n\n if (project_state.name == 'won') && (probability < 1)\n errors.add(:base,\n \"Probability of #{probability} is not allowed for the project state #{project_state.name}\")\n end\n\n if (project_state.name == 'running') && (probability < 1)\n errors.add(:base,\n \"Probability of #{probability} is not allowed for the project state #{project_state.name}\")\n end\n\n if (project_state.name == 'lost') && (probability > 0)\n errors.add(:base,\n \"Probability of #{probability} is not allowed for the project state #{project_state.name}\")\n end\n\n if (project_state.name == 'closing') && (probability < 1)\n errors.add(:base,\n \"Probability of #{probability} is not allowed for the project state #{project_state.name}\")\n end\n\n if (project_state.name == 'permanent') && (probability < 1)\n errors.add(:base,\n \"Probability of #{probability} is not allowed for the project state #{project_state.name}\")\n end\n end\n end",
"def adjust_for_third_parties!\n third_parties = @parties.select(&:third_party?)\n third_parties.each do |third_party|\n third_party.steal(1.0, coalition_leader(third_party))\n end\n end",
"def applyBadConsequence(m)\n if(m.getBadConsequence.isDeath)\n discardAllTreasures\n else\n decrementLevels(m.getBadConsequence.getLevels)\n pbc=m.getBadConsequence.adjustToFitTreasureLists(@visibleTreasures, @hiddenTreasures)\n setPendingBadConsequence(pbc)\n end\n\n end",
"def eligible_appeals\n active_fully_compensation_appeals.select(&:eligible_for_ramp?)\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # Assign the user inputs to variables\n apply_measure = runner.getStringArgumentValue(\"apply_measure\",user_arguments)\n\n # This measure is not applicable if apply_measure is false\n if apply_measure == \"FALSE\"\n runner.registerAsNotApplicable(\"Not Applicable - User chose not to apply this measure via the apply_measure argument.\")\n return true\n end\n \n # Loop through all air loops\n # and add DCV if applicable\n air_loops = []\n air_loops_already_dcv = []\n air_loops_dcv_added = []\n model.getAirLoopHVACs.each do |air_loop|\n \n air_loops << air_loop\n \n # DCV Not Applicable for AHUs that already have DCV\n # or that have no OA intake.\n controller_oa = nil\n controller_mv = nil\n if air_loop.airLoopHVACOutdoorAirSystem.is_initialized\n oa_system = air_loop.airLoopHVACOutdoorAirSystem.get\n controller_oa = oa_system.getControllerOutdoorAir \n controller_mv = controller_oa.controllerMechanicalVentilation\n if controller_mv.demandControlledVentilation == true\n air_loops_already_dcv << air_loop\n runner.registerInfo(\"DCV not applicable to '#{air_loop.name}' because DCV already enabled.\")\n next\n end\n else\n runner.registerInfo(\"DCV not applicable to '#{air_loop.name}' because it has no OA intake.\")\n next\n end\n\n # DCV Not Applicable to constant volume systems\n # for this particular measure. \n if air_loop.supplyComponents(\"OS:Fan:VariableVolume\".to_IddObjectType).size == 0\n runner.registerInfo(\"DCV not applicable to '#{air_loop.name}' because it is not a VAV system.\")\n next\n end\n \n # DCV is applicable to this airloop\n # Change the min flow rate in the controller outdoor air\n controller_oa.setMinimumOutdoorAirFlowRate(0.0)\n \n # Enable DCV in the controller mechanical ventilation\n controller_mv.setDemandControlledVentilation(true)\n runner.registerInfo(\"Enabled DCV for '#{air_loop.name}'.\")\n air_loops_dcv_added << air_loop\n \n end # Next air loop \n \n # If the model has no air loops, flag as Not Applicable\n if air_loops.size == 0\n runner.registerAsNotApplicable(\"Not Applicable - The model has no air loops.\")\n return true\n end\n \n # If all air loops already have DCV, flag as Not Applicable\n if air_loops_already_dcv.size == air_loops.size\n runner.registerAsNotApplicable(\"Not Applicable - All air loops already have DCV.\")\n return true\n end \n\n # If no air loops are eligible for DCV, flag as Not Applicable\n if air_loops_dcv_added.size == 0\n runner.registerAsNotApplicable(\"Not Applicable - DCV was not applicable to any air loops in the model.\")\n return true\n end\n\n # Report the initial condition\n runner.registerInitialCondition(\"Model has #{air_loops.size} air loops, #{air_loops_already_dcv.size} of which already have DCV enabled.\")\n \n # Report the final condition\n runner.registerFinalCondition(\"#{air_loops_dcv_added.size} air loops had DCV enabled.\")\n \n return true\n\n end",
"def systolic_and_diastolic_present_together\n unless (self.systolic_bp && self.diastolic_bp ||\n !self.systolic_bp && !self.diastolic_bp)\n self.errors[:base] << 'Systolic and Diastolic blood pressure must be entered together'\n end\n end",
"def calculate_item_liability(item_attributes)\n calculate_item_gross(item_attributes)\n end",
"def actual_level_of_effort_only_on_completion\n if actual_level_of_effort.nil? && status == \"completed\"\n errors.add(:status, \"must have actual level of effort if complete\")\n elsif !actual_level_of_effort.nil?\n if !(1..10).to_a.include?(actual_level_of_effort) && status == \"completed\"\n errors.add(:actual_level_of_effort, I18n.t('errors.messages.inclusion'))\n elsif status != \"completed\"\n errors.add(:actual_level_of_effort, \"cannot have actual level of effort if not complete\")\n end\n end\n end",
"def handle_completly_uncontested!\n\n # sole party get three seats\n sole_party = @parties.first\n sole_party.award(3)\n\n # TODO: fix this demeter violation\n other_major = sole_party.null_opposing_major\n other_major.award(1)\n @parties << other_major\n\n # one seat to third party\n # TODO: fix this demeter violation\n third_party = sole_party.null_coalition_minor\n third_party.award(1)\n @parties << third_party\n end",
"def check_critical_effects(user, item)\n check_effects(user.effect_objects, \"crit_attack\", user, item)\n end",
"def applyBadConsequence(m)\n badConsequence = m.getBadConsequence\n nLevels = badConsequence.getLevels\n decrementLevels(nLevels)\n pendingBad = badConsequence.adjustToFitTreasureLists(@visibleTreasures, @hiddenTreasures)\n setPendingBadConsequence(pendingBad)\n \n end",
"def date_range_integrity\n super\n\n # TODO: remove this after tie-in to Settings\n return\n\n open_enrollment_term_maximum = Settings.aca.shop_market.open_enrollment.maximum_length.months.months\n if open_enrollment_term.end > (open_enrollment_term.begin + open_enrollment_term_maximum)\n errors.add(:open_enrollment_term, \"may not exceed #{open_enrollment_term_maximum} months\")\n end\n\n open_enrollment_term_earliest_begin = effective_term.begin - open_enrollment_term_maximum\n if open_enrollment_term.begin < open_enrollment_term_earliest_begin\n errors.add(:open_enrollment_begin_on, \"may not begin more than #{open_enrollment_term_maximum} months sooner than effective date\") \n end\n\n initial_application_earliest_start_date = effective_term.begin + Settings.aca.shop_market.initial_application.earliest_start_prior_to_effective_on.months.months\n if initial_application_earliest_start_date > TimeKeeper.date_of_record\n errors.add(:effective_term, \"may not start application before #{initial_application_earliest_start_date.to_date} with #{effective_term.begin} effective date\")\n end\n\n if !['canceled', 'suspended', 'terminated','termination_pending'].include?(aasm_state)\n benefit_term_minimum = Settings.aca.shop_market.benefit_period.length_minimum.year.years\n if end_on != (effective_term.begin + benefit_term_minimum - 1.day)\n errors.add(:effective_term, \"application term period should be #{duration_in_days(benefit_term_minimum)} days\")\n end\n end\n end",
"def max_autonomy\n fuel_data = current_fuel_data\n\n (capacity * fuel_data[:autonomy]).to_f\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n #use the built-in error checking\n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n #assume the occ sensors will last the full analysis\n expected_life = 25\n \n #assign the user inputs to variables\n space_type_object = runner.getOptionalWorkspaceObjectChoiceValue(\"space_type\",user_arguments,model)\n percent_runtime_reduction = runner.getDoubleArgumentValue(\"percent_runtime_reduction\",user_arguments)\n material_and_installation_cost_per_space = runner.getDoubleArgumentValue(\"material_and_installation_cost_per_space\",user_arguments)\n\n #check the space_type for reasonableness and see if measure should run on space type or on the entire building\n apply_to_building = false\n space_type = nil\n if space_type_object.empty?\n handle = runner.getStringArgumentValue(\"space_type\",user_arguments)\n if handle.empty?\n runner.registerError(\"No space type was chosen.\")\n else\n runner.registerError(\"The selected space type with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n end\n return false\n else\n if not space_type_object.get.to_SpaceType.empty?\n space_type = space_type_object.get.to_SpaceType.get\n elsif not space_type_object.get.to_Building.empty?\n apply_to_building = true\n else\n runner.registerError(\"Script Error - argument not showing up as space type or building.\")\n return false\n end\n end\n \n #check arguments for reasonableness\n if percent_runtime_reduction >= 100\n runner.registerError(\"Percent runtime reduction must be less than 100.\")\n return false\n end\n\n #find all the original schedules (before occ sensors installed)\n original_lts_schedules = []\n if apply_to_building #apply to the whole building\n \n model.getLightss.each do |light_fixture|\n if light_fixture.schedule.is_initialized\n original_lts_schedules << light_fixture.schedule.get\n end\n end\n else #apply to the a specific space type\n #do the lights assigned to the space type itself\n space_type.lights.each do |light_fixture|\n if light_fixture.schedule.is_initialized\n original_lts_schedules << light_fixture.schedule.get\n end\n end\n #do the lights in each space of the selected space type\n space_type.spaces.each do |space|\n space.lights.each do |light_fixture|\n if light_fixture.schedule.is_initialized\n original_lts_schedules << light_fixture.schedule.get\n end\n end \n end\n end\n \n #make copies of all the original lights schedules, reduced to include occ sensor impact\n original_schs_new_schs = {}\n original_lts_schedules.uniq.each do |orig_sch|\n #TODO skip non-schedule-ruleset schedules\n \n #copy the original schedule\n new_sch = orig_sch.clone.to_ScheduleRuleset.get\n #reduce each value in each profile (except the design days) by the specified amount\n runner.registerInfo(\"Reducing values in '#{orig_sch.name}' schedule by #{percent_runtime_reduction}% to represent occ sensor installation.\")\n day_profiles = []\n day_profiles << new_sch.defaultDaySchedule\n new_sch.scheduleRules.each do |rule|\n day_profiles << rule.daySchedule\n end\n multiplier = (100 - percent_runtime_reduction)/100\n day_profiles.each do |day_profile|\n #runner.registerInfo(\"#{day_profile.name}\")\n times_vals = day_profile.times.zip(day_profile.values)\n #runner.registerInfo(\"original time/values = #{times_vals}\")\n times_vals.each do |time,val|\n day_profile.addValue(time, val * multiplier)\n end\n #runner.registerInfo(\"new time/values = #{day_profile.times.zip(day_profile.values)}\")\n end \n #log the relationship between the old sch and the new, reduced sch\n original_schs_new_schs[orig_sch] = new_sch\n #runner.registerInfo(\"***\")\n end\n \n #replace the old schedules with the new schedules\n spaces_sensors_added_to = []\n if apply_to_building #apply to the whole building\n runner.registerInfo(\"Adding occupancy sensors to whole building\")\n model.getLightss.each do |light_fixture|\n next if light_fixture.schedule.empty?\n lights_sch = light_fixture.schedule.get\n new_sch = original_schs_new_schs[lights_sch]\n if new_sch\n runner.registerInfo(\"Added occupancy sensor for '#{light_fixture.name}'\")\n light_fixture.setSchedule(new_sch)\n spaces_sensors_added_to << light_fixture.space\n end\n end\n else #apply to the a specific space type\n #do the lights assigned to the space type itself\n runner.registerInfo(\"Adding occupancy sensors to space type '#{space_type.name}'\")\n space_type.lights.each do |light_fixture|\n next if light_fixture.schedule.empty?\n lights_sch = light_fixture.schedule.get\n new_sch = original_schs_new_schs[lights_sch]\n if new_sch\n runner.registerInfo(\"Added occupancy sensor for '#{light_fixture.name}'\")\n light_fixture.setSchedule(new_sch)\n spaces_sensors_added_to << light_fixture.space\n end\n end\n #do the lights in each space of the selected space type\n space_type.spaces.each do |space|\n runner.registerInfo(\"Adding occupancy sensors to space '#{space.name}\")\n space.lights.each do |light_fixture|\n next if light_fixture.schedule.empty?\n lights_sch = light_fixture.schedule.get\n new_sch = original_schs_new_schs[lights_sch]\n if new_sch\n runner.registerInfo(\"Added occupancy sensor for '#{light_fixture.name}'\")\n light_fixture.setSchedule(new_sch)\n spaces_sensors_added_to << light_fixture.space\n end\n end \n end\n end \n \n #report if the measure is not applicable\n num_sensors_added = spaces_sensors_added_to.uniq.size\n if spaces_sensors_added_to.size == 0\n runner.registerAsNotApplicable(\"This measure is not applicable because there were no lights in the specified areas of the building.\")\n return true\n end\n \n #report initial condition\n runner.registerInitialCondition(\"The building has several areas where occupancy sensors could be used to reduce lighting energy by turning off the lights while no occupants are present.\") \n \n #add cost of adding occ sensors\n if material_and_installation_cost_per_space != 0\n cost = OpenStudio::Model::LifeCycleCost.createLifeCycleCost(\"Add #{material_and_installation_cost_per_space} Occ Sensors to the Building\", model.getBuilding, material_and_installation_cost_per_space * num_sensors_added, \"CostPerEach\", \"Construction\", expected_life, 0)\n if cost.empty?\n runner.registerError(\"Failed to add costs.\")\n end\n end \n \n #report final condition\n if apply_to_building\n runner.registerFinalCondition(\"Add occupancy sensors to #{num_sensors_added} spaces in the building. The total cost to perform this is $#{material_and_installation_cost_per_space.round} per space, for a total cost of $#{(material_and_installation_cost_per_space * num_sensors_added).round}\")\n else\n runner.registerFinalCondition(\"Add occupancy sensors to #{num_sensors_added} #{space_type.name} spaces in the building. The total cost to perform this is $#{material_and_installation_cost_per_space.round} per space, for a total cost of $#{(material_and_installation_cost_per_space * num_sensors_added).round}\")\n end\n \n return true\n \n end",
"def collegiate_rivals\n end",
"def no_advantage_check\n $game_temp.advantage = false if $game_temp.no_advantage or not Allow_Advantage\n $game_temp.disvantage = false if $game_temp.no_disvantage or not Allow_Disvantage\n $game_temp.pre_emptive = false if $game_temp.no_pre_emptive or not Allow_Pre_Emptive\n $game_temp.surprised = false if $game_temp.no_surprised or not Allow_Surprised\n $game_temp.raid_attack = false if $game_temp.no_raid_attack or not Allow_Raid_Attack\n $game_temp.back_attack = false if $game_temp.no_back_attack or not Allow_Back_Attack\n $game_temp.invert_postion = ($game_temp.back_attack and Invert_Back_Attack)\n end",
"def test_ut_t2_ars_arc_015\n # pu admin\n current_user = User.find_by_id(PU_ADMIN_ID)\n # pj ars\n pu_id = PrivilegesUsers.find_all_by_user_id(current_user.id)[0].pu_id\n pu_pj = Pu.find_by_id(pu_id).pjs[0]\n ars = Pj.find_by_id(pu_pj.id).analyze_rule_configs[0]\n #\n assert ars.editable?(current_user,pu_id,nil)\n end",
"def ratings_cannot_be_out_of_order\n check_ratings(throwing_ratings, 'throwing')\n check_ratings(fielding_ratings, 'fielding')\n check_ratings(running_ratings, 'running')\n check_ratings(hitting_ratings, 'hitting')\n end",
"def resuspension(collection, items, bio_reps)\n \n samp_id_to_item_hash = samp_id_to_item_hash(items)\n \n media_vol = ((items.length * bio_reps * (WELL_VOL + 5))/1000.0).round(2) # a little extra media per well to not run out in reservoir \n \n rc_list = collection.get_non_empty\n \n # add well for GFP positive control - H9\n rc_list.push(find_rc_from_alpha_coord(alpha_coord=POSITIVE_GFP_WELL).flatten)\n \n show do\n title \"Fill 96 Well Plate for Inoculation\"\n separator\n check \"Grab a clean Black Costar 96 Well Clear Flat Bottom Plate and label: #<b>#{collection}</b>\"\n note \"You can find the plates <b>#{PLT_LOC}</b>\"\n check \"You will need <b>#{media_vol.to_f} mLs</b> of SC media\"\n separator\n note \"Follow table below and fill 96 well plate with the following volume of SC media:\"\n table highlight_alpha_rc(collection, rc_list){|r,c| \"#{WELL_VOL}µl\"}\n end\n \n take(items, interactive: true)\n \n show do\n title \"Inoculate 96 Well Plate\"\n \n note \"Using a P20 pipette set to 5 µl, pick a single colony from the plate and resuspend it in the corresponding well.\"\n separator\n note \"Follow table below and inoculate the 96 well plate with single colonies corresponding to the item id:\"\n table highlight_alpha_non_empty(collection){|r,c| samp_id_to_item_hash[collection.matrix[r][c]]} \n # check \"<b>Finally, place clear lid on top and tape shut before placing it on the plate shaker.</b>\"\n end\n \n # Adding controls to plate\n need_to_create_new_control_plate = adding_positive_gfp_control(collection, well=POSITIVE_GFP_WELL) # YG_Controls\n \n collection.move \"30 C incubator; Plate Shaker @ 800rpm\"\n release([collection], interactive: true)\n return need_to_create_new_control_plate\n end",
"def test_ut_t2_ars_arc_013\n # pu admin\n current_user = User.find_by_id(PU_ADMIN_ID)\n # pu ars\n pu_id = PrivilegesUsers.find_all_by_user_id(current_user.id)[0].pu_id\n ars = Pu.find_by_id(pu_id).analyze_rule_configs[0]\n #\n assert ars.editable?(current_user,pu_id,nil)\n end",
"def not_very_effective?\n @effectiveness > 0 && @effectiveness < 1\n end"
] | [
"0.5359062",
"0.528268",
"0.52245426",
"0.5198735",
"0.51801103",
"0.5132356",
"0.51121503",
"0.51114583",
"0.5086593",
"0.5052438",
"0.5048837",
"0.5040801",
"0.4977414",
"0.4968954",
"0.4964098",
"0.49550056",
"0.4899717",
"0.48882034",
"0.48688716",
"0.4868648",
"0.4863882",
"0.48616764",
"0.48605838",
"0.48439106",
"0.48408797",
"0.48285183",
"0.4822988",
"0.48221156",
"0.4822039",
"0.48072398",
"0.47928622",
"0.47905636",
"0.47785488",
"0.47775918",
"0.47722974",
"0.47722974",
"0.47722974",
"0.4770001",
"0.47622132",
"0.475695",
"0.47558275",
"0.47523665",
"0.47328374",
"0.47235507",
"0.47220543",
"0.47215092",
"0.47167182",
"0.47136065",
"0.47127908",
"0.47078836",
"0.46950948",
"0.46947846",
"0.46884304",
"0.4683131",
"0.4676077",
"0.46701694",
"0.4668139",
"0.4661318",
"0.46579978",
"0.4654377",
"0.4654377",
"0.4652186",
"0.4646802",
"0.4638137",
"0.4637315",
"0.4635781",
"0.46243727",
"0.46217683",
"0.46187156",
"0.46187025",
"0.46163136",
"0.46153602",
"0.46149287",
"0.4613667",
"0.46103135",
"0.46041086",
"0.46041086",
"0.4599033",
"0.45989606",
"0.45946345",
"0.45937526",
"0.45923874",
"0.45919824",
"0.45904475",
"0.45874307",
"0.4583466",
"0.4582501",
"0.45799994",
"0.45794138",
"0.45748112",
"0.45718473",
"0.4568804",
"0.45648912",
"0.45632625",
"0.4559775",
"0.45589924",
"0.4552439",
"0.45521146",
"0.45500278",
"0.4549352",
"0.45485863"
] | 0.0 | -1 |
Attempt to take 3 observations while simultaneously injecting commands to handle heaters and louvers manually. | def hard_test
wait(10) # let some capacitor get up some charge.
5.times do
wait(5)
cmd("CFS CFS_WHE_OBS_START")
wait(5)
cmd("CFS CFS_WHE_HTR_ON")
wait(5)
cmd("CFS CFS_WHE_LOUVER_CLOSE")
wait(5)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_phase3_basic_command\n # If B button was pressed\n if Input.trigger?(Input::B)\n # Play cancel SE\n $game_system.se_play($data_system.cancel_se)\n # Go to command input for previous actor\n phase3_prior_actor\n return\n end\n # If C button was pressed\n if Input.trigger?(Input::C)\n # Branch by actor command window cursor position\n case @actor_command_window.index\n when 0 # attack\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Set action\n @active_battler.current_action.kind = 0\n @active_battler.current_action.basic = 0\n # Start enemy selection\n start_enemy_select\n when 1 # skill\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Set action\n @active_battler.current_action.kind = 1\n # Start skill selection\n start_skill_select\n when 2 # guard\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Set action\n @active_battler.current_action.kind = 0\n @active_battler.current_action.basic = 1\n # Go to command input for next actor\n phase3_next_actor\n when 3 # item\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Set action\n @active_battler.current_action.kind = 2\n # Start item selection\n start_item_select\n end\n return\n end\n end",
"def update_phase3_basic_command\r\n # If B button was pressed\r\n if Input.trigger?(Input::B)\r\n # Play cancel SE\r\n $game_system.se_play($data_system.cancel_se)\r\n # Go to command input for previous actor\r\n phase3_prior_actor\r\n return\r\n end\r\n # If C button was pressed\r\n if Input.trigger?(Input::C)\r\n # Branch by actor command window cursor position\r\n case @actor_command_window.index\r\n when 0 # attack\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Set action\r\n @active_battler.current_action.kind = 0\r\n @active_battler.current_action.basic = 0\r\n # Start enemy selection\r\n start_enemy_select\r\n when 1 # skill\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Set action\r\n @active_battler.current_action.kind = 1\r\n # Start skill selection\r\n start_skill_select\r\n when 2 # guard\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Set action\r\n @active_battler.current_action.kind = 0\r\n @active_battler.current_action.basic = 1\r\n # Go to command input for next actor\r\n phase3_next_actor\r\n when 3 # item\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Set action\r\n @active_battler.current_action.kind = 2\r\n # Start item selection\r\n start_item_select\r\n end\r\n return\r\n end\r\n end",
"def script_Perform3 machine, objs\n #skill, pro, con\n con, pro, skill = machine.pop 3\n if objs[:direct]\n con += objs[:direct].first.trait(skill_defense_for(skill))\n end\n if objs[:instrument]\n pro += objs[:instrument].first.trait(skill_aid_for(skill))\n end\n end",
"def phase3_command_guard\r\n # Set action\r\n @active_battler.current_action.kind = 0\r\n @active_battler.current_action.basic = 1\r\n # Go to command input for next actor\r\n phase3_next_actor\r\n end",
"def phase3_prior_actor\n # Loop\n begin\n # Actor blink effect OFF\n if @active_battler != nil\n @active_battler.blink = false\n end\n # If first actor\n if @actor_index == 0\n # Start party command phase\n start_phase2\n return\n end\n # Return to actor index\n @actor_index -= 1\n @active_battler = $game_party.actors[@actor_index]\n @active_battler.blink = true\n # Once more if actor refuses command input\n end until @active_battler.inputable?\n # Set up actor command window\n phase3_setup_command_window\n end",
"def phase3_prior_actor\r\n # Loop\r\n begin\r\n # Actor blink effect OFF\r\n if @active_battler != nil\r\n @active_battler.blink = false\r\n end\r\n # If first actor\r\n if @actor_index == 0\r\n # Start party command phase\r\n start_phase2\r\n return\r\n end\r\n # Return to actor index\r\n @actor_index -= 1\r\n @active_battler = $game_party.actors[@actor_index]\r\n @active_battler.blink = true\r\n # Once more if actor refuses command input\r\n end until @active_battler.inputable?\r\n # Set up actor command window\r\n phase3_setup_command_window\r\n end",
"def combination_step3_part2(active)\n for battler in active.combination_battlers\n now_action(battler)\n if battler.now_action != nil\n set_actions(battler, active)\n set_movement(battler)\n set_hit_number(battler)\n set_action_plane(battler)\n battler_effect_update(battler)\n battler.current_phase = 'Phase 3-3'\n end\n end\n active.current_phase = 'Phase 3-3' if active.now_action.nil?\n end",
"def update_phase3_basic_command\n # If B button was pressed\n if Input.trigger?(Input::B)\n # Play cancel SE\n $game_system.se_play($data_system.decision_se)\n # Go to command input for previous actor\n phase3_prior_actor\n return\n end\n # If C button was pressed\n if Input.trigger?(Input::C)\n # Return if Disabled Command\n if phase3_basic_command_disabled?\n # Play buzzer SE\n $game_system.se_play($data_system.buzzer_se)\n return\n end\n # Set Action Made Flag\n @active_battler.current_action.action_made = true\n # Command Input\n phase3_basic_command_input\n return\n end\n end",
"def phase_three\n puts \"Phase 3 has been started\"\n\n 7.times do\n immune = @borneo.individual_immunity_challenge\n puts \"#{immune} wins the immunity\".blue\n\t\tvoted_off_contestant = @merge_tribe.tribal_council(immune: immune)\n\t\[email protected]_member voted_off_contestant\n\t\tputs \"#{voted_off_contestant}! is OUT!\".red\n end\nend",
"def phase3_prior_actor\n # Set Action To Wait\n @active_battler.current_action.kind = 0\n @active_battler.current_action.basic = 3\n # Reset Blink\n @active_battler.blink = false\n # Start Phase 4\n start_phase4\n end",
"def update_phase3_basic_command\r\n # If B button was pressed\r\n if Input.trigger?(Input::B)\r\n # Play cancel SE\r\n $game_system.se_play($data_system.cancel_se)\r\n # Go to command input for previous actor\r\n phase3_prior_actor\r\n return\r\n end\r\n # If C button was pressed\r\n if Input.trigger?(Input::C)\r\n # Return if Disabled Command\r\n if phase3_basic_command_disabled?\r\n # Play buzzer SE\r\n $game_system.se_play($data_system.buzzer_se)\r\n return\r\n end\r\n # Command Input\r\n phase3_basic_command_input\r\n return\r\n end\r\n end",
"def phase3_basic_command_input\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Branch by actor command window cursor position\r\n case @actor_command_window.command\r\n when SDK::Scene_Commands::Scene_Battle::Attack # attack\r\n phase3_command_attack\r\n when SDK::Scene_Commands::Scene_Battle::Skill # skill\r\n phase3_command_skill\r\n when SDK::Scene_Commands::Scene_Battle::Guard # guard\r\n phase3_command_guard\r\n when SDK::Scene_Commands::Scene_Battle::Item # item\r\n phase3_command_item\r\n end\r\n end",
"def start_phase3\r\n # Shift to phase 3\r\n @phase = 3\r\n # Set actor as unselectable\r\n @actor_index = -1\r\n @active_battler = nil\r\n # Go to command input for next actor\r\n phase3_next_actor\r\n end",
"def phase3_setup_command_window\n $game_temp.battle_actor_index = @actor_index\n @status_window.refresh\n large_party_phase3_setup_command_window\n @actor_command_window.x = 0 #(@actor_index%10) * 10 #was mod4, was 40\n end",
"def start_phase3\n # Shift to phase 3\n @phase = 3\n # If won, or if lost : end method\n return if judge\n # Set Battler As Unselectable\n @active_battler = nil\n @actor_index = -1\n # Clear main phase flag\n $game_temp.battle_main_phase = false\n # Go to command input for next actor\n phase3_next_actor\n end",
"def phase3_command_attack\r\n # Set action\r\n @active_battler.current_action.kind = 0\r\n @active_battler.current_action.basic = 0\r\n # Start enemy selection\r\n start_enemy_select\r\n end",
"def phase3_prior_actor\n begin\n @active_battler.blink = false if @active_battler != nil\n @active_battler.current_action.clear\n return start_phase2 if @actor_index == 0\n @actor_index -= 1\n @active_battler = $game_party.actors[@actor_index]\n @active_battler.union_members.clear\n @active_battler.blink = true\n end until @active_battler.inputable?\n phase3_setup_command_window\n end",
"def start_phase3\n @phase = 3\n actor=@actors[@actor_actions.size]\n #>Test du forçage de lutte\n if(BattleEngine::_lutte?(actor))\n @actor_actions.push([0,nil,util_targetselection_automatic(actor, phase3_struggle_move),actor])\n update_phase2_next_act\n return\n elsif(actor.battle_effect.has_encore_effect?)\n @actor_actions.push([0,actor.skills_set.index(actor.battle_effect.encore_skill).to_i,\n util_targetselection_automatic(actor, actor.battle_effect.encore_skill),actor])\n end\n @mega_evolve_window.show if BattleEngine.can_pokemon_mega_evolve?(actor, $bag)\n\n #>Récupération de l'index d'une attaque \"valide\"\n @atk_index = 0\n if USE_ALPHA_25_UI\n @skill_choice_ui.reset(@actors[@actor_actions.size])\n @skill_choice_ui.visible = true\n @message_window.visible = false\n else\n 4.times do |i|\n skill=actor.skills_set[i]\n @atk_index=i if skill and skill.id==actor.last_skill.to_i.abs\n end\n @skill_selector.update_text(@atk_index, @actors[@actor_actions.size])\n @skill_selector.visible = true\n end\n #@message_window.visible = false\n 0 while get_action\n\n launch_phase_event(3, true)\n end",
"def combination_step3_part3(active)\n battlers_current_phase(active, 'Phase 4-1')\n for battler in active.combination_battlers\n next if battler.now_action.nil?\n battler.target_battlers = active.target_battlers\n action_anime(battler) if battler.hit_animation\n end\n end",
"def execute_sequence\n case @acts[0]\n when SEQUENCE_POSE; setup_pose\n when SEQUENCE_MOVE; setup_move\n when SEQUENCE_SLIDE; setup_slide\n when SEQUENCE_RESET; setup_reset\n when SEQUENCE_MOVE_TO_TARGET; setup_move_to_target\n when SEQUENCE_SCRIPT; setup_eval_script\n when SEQUENCE_WAIT; @acts[1].times { method_wait }\n when SEQUENCE_DAMAGE; setup_damage\n when SEQUENCE_CAST; setup_cast\n when SEQUENCE_VISIBLE; @visible = @acts[1]\n when SEQUENCE_SHOW_ANIMATION; setup_anim\n when SEQUENCE_AFTERIMAGE; @afterimage = @acts[1]\n when SEQUENCE_FLIP; setup_flip\n when SEQUENCE_ACTION; setup_action\n when SEQUENCE_PROJECTILE_SETUP; setup_projectile\n when SEQUENCE_PROJECTILE; show_projectile\n when SEQUENCE_LOCK_Z; @lock_z = @acts[1]\n when SEQUENCE_ICON; setup_icon\n when SEQUENCE_SOUND; setup_sound\n when SEQUENCE_IF; setup_branch\n when SEQUENCE_TIMED_HIT; setup_timed_hit\n when SEQUENCE_SCREEN; setup_screen\n when SEQUENCE_ADD_STATE; setup_add_state\n when SEQUENCE_REM_STATE; setup_rem_state \n when SEQUENCE_CHANGE_TARGET; setup_change_target\n when SEQUENCE_TARGET_MOVE; setup_target_move\n when SEQUENCE_TARGET_SLIDE; setup_target_slide\n when SEQUENCE_TARGET_RESET; setup_target_reset\n when SEQUENCE_BLEND; @blend = @acts[1]\n when SEQUENCE_FOCUS; setup_focus\n when SEQUENCE_UNFOCUS; setup_unfocus\n when SEQUENCE_TARGET_LOCK_Z; setup_target_z\n # New update list v1.1\n when SEQUENCE_ANIMTOP; setup_anim_top\n when SEQUENCE_FREEZE; $game_temp.global_freeze = @acts[1]\n when SEQUENCE_CSTART; setup_cutin\n when SEQUENCE_CFADE; setup_cutin_fade\n when SEQUENCE_CMOVE; setup_cutin_slide\n when SEQUENCE_TARGET_FLIP; setup_targets_flip\n when SEQUENCE_PLANE_ADD; setup_add_plane\n when SEQUENCE_PLANE_DEL; setup_del_plane\n when SEQUENCE_BOOMERANG; @proj_setup[PROJ_BOOMERANG] = true\n when SEQUENCE_PROJ_AFTERIMAGE; @proj_setup[PROJ_AFTERIMAGE] = true\n when SEQUENCE_BALLOON; setup_balloon_icon\n # New update list v1.2\n when SEQUENCE_LOGWINDOW; setup_log_message\n when SEQUENCE_LOGCLEAR; get_scene.log_window.clear\n when SEQUENCE_AFTINFO; setup_aftinfo\n when SEQUENCE_SMMOVE; setup_smooth_move\n when SEQUENCE_SMSLIDE; setup_smooth_slide\n when SEQUENCE_SMTARGET; setup_smooth_move_target\n when SEQUENCE_SMRETURN; setup_smooth_return\n # New update list v1.3 + v1.3b + v1.3c\n when SEQUENCE_LOOP; setup_loop\n when SEQUENCE_WHILE; setup_while\n when SEQUENCE_COLLAPSE; tsbs_perform_collapse_effect\n when SEQUENCE_FORCED; setup_force_act\n when SEQUENCE_ANIMBOTTOM; setup_anim_bottom\n when SEQUENCE_CASE; setup_switch_case\n when SEQUENCE_INSTANT_RESET; setup_instant_reset\n when SEQUENCE_ANIMFOLLOW; setup_anim_follow\n when SEQUENCE_CHANGE_SKILL; setup_change_skill\n when SEQUENCE_CHECKCOLLAPSE; setup_check_collapse\n when SEQUENCE_RESETCOUNTER; get_scene.damage.reset_value\n when SEQUENCE_FORCEHIT; @force_hit = default_true\n when SEQUENCE_SLOWMOTION; setup_slow_motion\n when SEQUENCE_TIMESTOP; setup_timestop\n when SEQUENCE_ONEANIM; $game_temp.one_animation_flag = true\n when SEQUENCE_PROJ_SCALE; setup_proj_scale\n when SEQUENCE_COMMON_EVENT; setup_tsbs_common_event\n when SEQUENCE_GRAPHICS_FREEZE; Graphics.freeze\n when SEQUENCE_GRAPHICS_TRANS; setup_transition\n # New update list v1.4\n when SEQUENCE_FORCEDODGE; @force_evade = default_true\n when SEQUENCE_FORCEREFLECT; @force_reflect = default_true\n when SEQUENCE_FORCECOUNTER; @force_counter = default_true\n when SEQUENCE_FORCECRITICAL; @force_critical = default_true\n when SEQUENCE_FORCEMISS; @force_miss = default_true\n when SEQUENCE_BACKDROP; setup_backdrop\n when SEQUENCE_BACKTRANS; setup_backdrop_transition\n when SEQUENCE_REVERT_BACKDROP; $game_temp.backdrop.revert;Fiber.yield\n when SEQUENCE_TARGET_FOCUS; @focus_target = @acts[1]\n when SEQUENCE_SCREEN_FADEOUT; setup_screen_fadeout\n when SEQUENCE_SCREEN_FADEIN; setup_screen_fadein\n when SEQUENCE_CHECK_COVER; setup_check_cover\n when SEQUENCE_STOP_MOVEMENT; stop_all_movements\n when SEQUENCE_ROTATION; setup_rotation\n when SEQUENCE_FADEIN; setup_fadein\n when SEQUENCE_FADEOUT; setup_fadeout\n when SEQUENCE_IMMORTALING; setup_immortaling\n when SEQUENCE_END_ACTION; setup_end_action\n when SEQUENCE_SHADOW_VISIBLE; $game_temp.shadow_visible = default_true\n when SEQUENCE_AUTOPOSE; setup_autopose\n when SEQUENCE_ICONFILE; @icon_file = @acts[1] || ''\n when SEQUENCE_IGNOREFLIP; @ignore_flip_point = default_true\n # Interesting on addons?\n else; custom_sequence_handler\n end\n end",
"def summon_part3(battler)\n set_summon_actors(battler)\n for actor in $game_party.actors\n next if not Summon_Skill[battler.summoning][0][4] and not $game_party.removed_actors.include?(actor)\n unless actor.dead? and not check_include(actor, 'NOCOLLAPSE')\n actor.invisible = true\n actor.defense_pose = false\n actor.invisible_action = true if battler == actor\n end\n end\n battler.wait_time = 16\n battler.current_phase = 'Summon 4'\n end",
"def play_3_note_chord(note_one, note_two, note_three)\n play note_one\n play note_two\n play note_three\nend",
"def do_command0\n data = nil\n call_scene(WantedDataScene) { |scene| data = scene.wanted_data }\n return unless data.is_a?(Array)\n\n list = Core.get_pokemon_list(data)\n return display_message(ext_text(8997, 8)) if list.first == 'nothing'\n\n pokemon_list = list.collect { |i| Core.download_pokemon(i).to_pokemon }\n return display_message(ext_text(8997, 9)) if pokemon_list.include?(nil)\n\n loop do\n break unless (index = select_pokemon(pokemon_list))\n\n wanted_data = Core.download_wanted_data(list[index])\n return display_message(ext_text(8997, 11)) if wanted_data.empty?\n next unless confirm_wanted_data(wanted_data)\n break unless (choice = choose_pokemon)\n\n pkmn = choice >= 31 ? $actors[choice - 31] : $storage.info(choice - 1)\n next display_message(ext_text(8997, 12)) unless pokemon_matching_requirements?(pkmn, wanted_data)\n\n return GTS.finish_trade(pkmn, pokemon_list[index], true, choice, list[index])\n end\n end",
"def execute\n if inquisition.buff_remaining == 0\n guardian_of_ancient_kings.attempt\n inquisition.attempt\n end\n\n # Cast Crusader Strike if we dont have 3 HP\n if holy_power < 3\n crusader_strike.attempt\n end\n\n # If I have less than 3 seconds of Inquisition left, refresh regardless\n # of current level of holy power\n if inquisition.buff_remaining < 3\n guardian_of_ancient_kings.attempt\n inquisition.attempt\n end\n\n # Cast TV if we can\n if has_holy_power(3)\n use_trinkets\n avenging_wrath.attempt \n if(zealotry.usable?)\n zealotry.attempt\n heroism.attempt\n end\n templars_verdict.attempt\n end\n\n # If Crusader Strike will be up shortly, just wait for it\n return if crusader_strike.cooldown_remaining <= 0.1\n\n exorcism.attempt\n hammer_of_wrath.attempt \n\n # If Crusader Strike will be up shortly, just wait for it\n return if crusader_strike.cooldown_remaining <= @delay\n\n judgement.attempt \n holy_wrath.attempt\n consecration.attempt if @consecrate\n end",
"def setup_pose\n return TSBS.error(@acts[0], 3, @used_sequence) if @acts.size < 4\n @battler_index = @acts[1] # Battler index\n @anim_cell = @acts[2] # Change cell\n if @anim_cell.is_a?(Array)\n row = (@anim_cell[0] - 1) * MaxRow\n col = @anim_cell[1] - 1\n @anim_cell = row + col\n end\n @icon_key = @acts[4] if @acts[4] # Icon call\n @icon_key = @acts[5] if @acts[5] && flip # Icon call\n @acts[3].times do # Wait time\n method_wait\n end\n end",
"def phase3_command_skill\r\n # Set action\r\n @active_battler.current_action.kind = 1\r\n # Start skill selection\r\n start_skill_select\r\n end",
"def setup_autopose\n return TSBS.error(@acts[0], 3, @used_sequence) if @acts.size < 4\n @battler_index = @acts[1]\n initial_cell = (@acts[2] - 1) * MaxRow\n @autopose.clear\n MaxCol.times do |i|\n @autopose += Array.new(@acts[3]) { initial_cell + i}\n end\n end",
"def update_party_command_selection\n if Input.trigger?(Input::C)\n case @party_command_window.command\n when :fight # Fight\n Sound.play_decision\n @status_window.index = @actor_index = -1\n next_actor\n when :escape # Escape\n if $game_troop.can_escape == false\n Sound.play_buzzer\n return\n end\n Sound.play_decision\n process_escape\n when :formation\n Sound.play_decision\n @party_command_window.setup_commands(:formation)\n @party_command_window.refresh\n when :for_forward\n $game_party.do_mass_move(:formation, :forward)\n @party_command_window.setup_commands(:standard)\n @party_command_window.refresh\n when :for_backward\n $game_party.do_mass_move(:formation, :backward)\n @party_command_window.setup_commands(:standard)\n @party_command_window.refresh\n when :for_invert\n $game_party.do_mass_move(:formation, :invert)\n @party_command_window.setup_commands(:standard)\n @party_command_window.refresh\n when :for_reverse\n $game_party.do_mass_move(:formation, :reverse)\n @party_command_window.setup_commands(:standard)\n @party_command_window.refresh\n when :for_cancel\n Sound.play_decision\n @party_command_window.setup_commands(:standard)\n @party_command_window.refresh\n end\n elsif Input.trigger?(Input::B)\n case @party_command_window.last_setup\n when :formation\n Sound.play_cancel\n @party_command_window.setup_commands(:standard)\n @party_command_window.refresh\n end\n end\n end",
"def sequence_step3_part1(battler)\n if cant_use_sequence(battler)\n reset_atb(battler) if $atoa_script['Atoa ATB']\n battler.current_phase = 'Phase 5-1'\n battler.action_scope = 0\n return\n end\n action_start_anime(battler)\n battler.current_phase = 'Phase 3-2'\n end",
"def set_command_objects\n puts \"@input before set_command_object: #{@input}\"\n command_objects = []\n \n @input.each do |name|\n if command_objects.length < 1 || @command_word == \"combine\" && command_objects.length < 2\n if name_is_valid_object_name?(name)\n command_objects << $game.get_object_by_name(name)\n \n end\n end\n end \n\n \n @command_object_1, @command_object_2 = command_objects\n puts \"@input after set_command_object: #{@input}\"\n puts \"@object_1 and @object_2: #{@command_object_1.to_s + \", \" + @command_object_2.to_s}.\"\n end",
"def update_command_selection()\n if Input.trigger?(Input::B)\n Sound.play_cancel\n quit_command()\n \n elsif Input.trigger?(Input::C)\n if @actor.fix_equipment\n Sound.play_buzzer\n else\n case @command_window.index\n when 0 # Equip\n Sound.play_decision\n equip_command()\n when 1 # Optimize\n Sound.play_decision\n optimize_command()\n when 2 # Remove\n Sound.play_decision\n remove_command()\n when 3 # Remove All\n Sound.play_decision\n removeAll_command()\n end\n end\n \n elsif Input.trigger?(Input::R)\n Sound.play_cursor\n next_actor\n elsif Input.trigger?(Input::L)\n Sound.play_cursor\n prev_actor\n end\n \n end",
"def phase_two\n puts \"Phase 2 has been started\"\n\n 3.times do\n immune = @borneo.individual_immunity_challenge\n puts \"#{immune} win the immunity\".blue\n voted_off_contestant = @merge_tribe.tribal_council({immune: immune})\n puts \"#{voted_off_contestant} is OUT!\".red\n end\nend",
"def process_initial_commands\n #in the game class\n case \n when play?\n game = Game.new(instream, outstream, display)\n game.start\n \n when instructions?\n display.game_objective1 # give the user instructions\n display.game_objective2\n\n when quit? # run the loop below until the user says to quit\n outstream.puts display.quit.magenta\n\n else # for anything else\n outstream.puts display.invalid_option\n end\n end",
"def four_four\n sample :drum_heavy_kick\n sleep 1\n sample :drum_snare_hard\n sleep 1\nend",
"def four_four\n sample :drum_heavy_kick\n sleep 1\n sample :drum_snare_hard\n sleep 1\nend",
"def test_multi_repl_commands\n Hatchet::AnvilApp.new(\"rails3_mri_193\", buildpack: @buildpack_path).deploy do |app|\n app.add_database\n\n assert_raise ReplRunner::UnregisteredCommand do\n app.run(\"ls\", 2) do |ls| # will return right away, should raise error\n ls.run(\"cat\")\n end\n end\n\n rand(3..7).times do\n app.run(\"rails console\") do |console|\n console.run(\"`ls`\")\n console.run(\"'foo' * 5\") {|r| assert_match \"foofoofoofoofoo\", r }\n console.run(\"'hello ' + 'world'\") {|r| assert_match \"hello world\", r }\n end\n end\n\n rand(3..7).times do\n app.run(\"bash\") do |bash|\n bash.run(\"ls\") { |r| assert_match \"Gemfile\", r }\n end\n end\n end\n end",
"def update_command_selection()\n if Input.trigger?(Input::B)\n Sound.play_cancel\n quit_command()\n elsif Input.trigger?(Input::C)\n case @command_window.index\n when 0 # Buy\n Sound.play_decision\n buy_command()\n update_item_stats(@buy_window.selected_item.item)\n @buy_window.update_items_activity($game_party.gold)\n when 1 # Sell\n if $game_temp.shop_purchase_only\n Sound.play_buzzer\n else\n Sound.play_decision\n sell_command()\n if @sell_window.selected_item != nil\n update_item_stats(@sell_window.selected_item.item)\n else\n update_item_stats(nil) \n end\n end\n when 2 # Equip\n Sound.play_decision\n equip_command()\n when 3 # Quit\n Sound.play_decision\n quit_command()\n end\n end\n end",
"def setup_cutin_fade\n return TSBS.error(@acts[0], 2, @used_sequence) if @acts.size < 3\n get_spriteset.cutin.fade(@acts[1], @acts[2])\n end",
"def pass_out_characters_and_coins\n if self.players.size == 2 && @settings.include?(:twoplayer)\n side_decks = [[], []]\n # Uh this is kinda wonky.\n # Oh Well YOLT (You only live twice) in Coup.\n 5.times {\n side_decks[0] << self.draw_cards(1)[0]\n side_decks[1] << self.draw_cards(1)[0]\n self.deck.rotate!\n }\n end\n\n self.deck.shuffle!\n\n # assign loyalties\n self.players.each_with_index do |player, index|\n if self.players.size == 2\n if @settings.include?(:twoplayer)\n player.receive_characters(self.draw_cards(1))\n player.receive_side_characters(*side_decks[index].shuffle)\n else\n player.receive_characters(self.draw_cards(2))\n end\n # first player gets 1 coin and second gets 2.\n player.give_coins(index + 1)\n else\n player.receive_characters(self.draw_cards(2))\n player.give_coins(2)\n end\n end\n end",
"def update_phase3\n # If enemy arrow is enabled\n if @enemy_arrow != nil\n update_phase3_enemy_select\n # If actor arrow is enabled\n elsif @actor_arrow != nil\n update_phase3_actor_select\n # If skill window is enabled\n elsif @skill_window != nil\n update_phase3_skill_select\n # If item window is enabled\n elsif @item_window != nil\n update_phase3_item_select\n # If actor command window is enabled\n elsif @actor_command_window.active\n update_phase3_basic_command\n end\n end",
"def combination_step4_part3(active)\n @status_window.refresh if status_need_refresh\n return unless all_throw_end(active)\n steal_action_result(active) unless active.steal_action\n for battler in active.combination_battlers\n battler.mirage = false\n battler.critical_hit = false\n reset_random(battler)\n end\n have_no_hits = true\n for battler in active.combination_battlers\n next if battler.now_action.nil?\n have_no_hits = false if battler.current_action.hit_times > 0 and battler.current_action.move_times > 0\n end\n if have_no_hits \n check_action_hit_times(active)\n else\n battler_movement_update(active)\n end\n end",
"def update_command_selection\n if Input.trigger?(Input::B)\n Sound.play_cancel\n $scene = Scene_Map.new\n elsif Input.trigger?(Input::C)\n if $game_party.members.size == 0 and @command_window.index < 4\n Sound.play_buzzer\n return\n elsif $game_system.save_disabled and @command_window.index == 4\n Sound.play_buzzer\n return\n end\n Sound.play_decision\n case @command_window.index\n when 0 # Item\n $scene = Scene_Item.new\n when 1,2,3 # Skill, equipment, status\n start_actor_selection\n when 4 # Save\n $scene = Scene_File.new(true, false, false, 4)\n when 5 # Save\n $scene = Scene_File.new(false, false, false, 5)\n when 6 # End Game\n $scene = Scene_End.new\n end\n end\n end",
"def do_twice(what1, what2, what3)\n 2.times do\n what1.call\n what2.call\n what3.call\n end\nend",
"def cooperation_step3_part1(active)\n if member_in_action(active)\n reset_atb(active) if $atoa_script['Atoa ATB']\n return\n end\n index = 0\n for battler in active.combination_battlers\n set_actions(battler, active)\n battler.cooperation_index = index\n index += 1\n now_action(battler)\n next if battler.now_action.nil?\n if cant_use_cooperation(battler)\n break_cooperation(battler)\n reset_atb(active) if $atoa_script['Atoa ATB']\n active.current_phase = 'Phase 5-1' \n active.action_scope = 0\n return\n end\n end\n for battler in active.combination_battlers\n action_start_anime_combination(battler, active.combination_id)\n end\n freeze_atb(active) if $atoa_script['Atoa ATB']\n battlers_current_phase(active, 'Phase 3-2')\n end",
"def do_stuff more_actions=[], num_actions=5\n actions = []\n num_actions.times do\n actions.push ((['move', 'eat', 'nap'] + more_actions).sample)\n end\n actions.each do |action|\n m = method action\n m.call\n end\n puts \"#{@name} is done doing stuff!\"\n end",
"def do_command1\n display_message_and_wait(ext_text(8997, 13))\n return unless (choice = choose_pokemon)\n return unless (pkmn = choice >= 31 ? $actors[choice - 31] : $storage.info(choice - 1))\n\n list = Core.get_pokemon_list_from_wanted(pkmn)\n return display_message(ext_text(8997, 8)) if list.first == 'nothing'\n\n pokemon_list = list.collect { |i| Core.download_pokemon(i).to_pokemon }\n return display_message(ext_text(8997, 9)) if pokemon_list.include?(nil)\n\n loop do\n break unless (index = select_pokemon(pokemon_list))\n\n wanted_data = Core.download_wanted_data(list[index])\n return display_message(ext_text(8997, 11)) if wanted_data.empty?\n\n display_message_and_wait(ext_text(8997, 14))\n break unless confirm_wanted_data(wanted_data)\n\n return GTS.finish_trade(pkmn, pokemon_list[index], true, choice, list[index])\n end\n end",
"def SS1_2 args\r\n\t#If randomNumber is 0 (not yet defined), generate it\r\n\tif args.state.randomNumber == 0\r\n\t\targs.state.randomNumber = generateRandom args\r\n\t\targs.state.spaces_moved = 0\r\n\tend \r\n\r\n\t#Eliminates random rolls (for testing purposes)\r\n\t#args.state.randomNumber = 1\r\n\r\n\targs.outputs.borders << [540, 365, 200, 40]\r\n\targs.outputs.labels << [547, 397, \"You rolled a #{args.state.randomNumber}\", 4]\r\n\t\r\n\targs.state.tick_timer ||= args.state.tick_count\r\n\r\n\t#Waits two seconds\r\n\tif args.state.spaces_moved !=args.state.randomNumber && args.state.tick_count >= (args.state.tick_timer + 30)\r\n\t\t#After generating randomNumber, move characters one space per tick run\r\n\t\tcase args.state.player_turn\r\n\t\t\twhen 1\r\n\t\t\t\t#Adds to counter\r\n\t\t\t\targs.state.spaces_moved += 1\r\n\t\t\t\t#Move Toad one space\r\n\t\t\t\targs.state.Toad_XCoord, args.state.Toad_YCoord, args.state.Toad_board_movement_style = shift_character args, args.state.Toad_XCoord, args.state.Toad_YCoord, args.state.Toad_board_movement_style\r\n\t\t\t\t#Displays Toad \r\n\t\t\t\targs.outputs.sprites << [args.state.Toad_XCoord, args.state.Toad_YCoord, args.state.size, args.state.size, \"sprites/Toad.png\"]\r\n\t\t\twhen 2\r\n\t\t\t\t#Adds to counter\r\n\t\t\t\targs.state.spaces_moved += 1\r\n\t\t\t\t#Move Cat one space\r\n\t\t\t\targs.state.Cat_XCoord, args.state.Cat_YCoord, args.state.Cat_board_movement_style = shift_character args, args.state.Cat_XCoord, args.state.Cat_YCoord, args.state.Cat_board_movement_style\r\n\t\t\t\t\r\n\t\t\t\t#Displays Cat\r\n\t\t\t\targs.outputs.sprites << [args.state.Cat_XCoord, args.state.Cat_YCoord, args.state.size, args.state.size, \"sprites/Cat.png\"]\r\n\t\tend\r\n\r\n\t\targs.state.tick_timer = args.state.tick_count\r\n\tend\r\n\r\n\t#After moving characters finished, transition to SS3\r\n\tif args.state.spaces_moved == args.state.randomNumber && args.state.tick_count >= (args.state.tick_timer + 60)\r\n\t\targs.state.last_mouse_click = nil\r\n\t\targs.state.pos = nil\r\n\t\targs.state.screen_select = 1.3\r\n\tend\r\nend",
"def phase2_command_fight\r\n # Start actor command phase\r\n start_phase3\r\n end",
"def create_many_intents\n intents = []\n @switches.each do |sw|\n rest = @switches - [sw]\n intents = _create_intent sw, rest, intents\nputs intents.size\n post_slice intents\n end\n post_slice intents, true\n end",
"def do_action\n if self.affects == \"world\" then\n player_tile = self.character.tile\n\n # an aoe effect is represented as a list of objects,\n # each one representing the effect on one tile\n ITEM_PROPERTIES[self.item_type][\"aoe\"].each do |aoe|\n dx = aoe[\"xCoordPlus\"]\n dy = aoe[\"yCoordPlus\"]\n tile_becomes = aoe[\"tileBecomes\"]\n Tile.tile_at(player_tile.x + dx, player_tile.y + dy).become tile_becomes\n end\n\n elsif self.affects == \"player\" then\n\n dx = self.moves_player_x\n dy = self.moves_player_y\n\n # Move me to the place this item takes me\n if (dx != 0 or dy != 0) then\n target_tile = Tile.tile_at(self.character.tile.x + dx,\n self.character.tile.y + dy)\n if target_tile\n self.character.tile = target_tile\n end\n end\n\n self.character.heal(self.health_effect)\n self.character.charge(self.battery_effect)\n end\n\n if self.consumable then\n self.character.item = nil\n self.destroy\n end\n\n end",
"def input args\n if args.state.inputlist.length > 5\n args.state.inputlist.pop\n end\n\n should_process_special_move = (args.inputs.keyboard.key_down.j) ||\n (args.inputs.keyboard.key_down.k) ||\n (args.inputs.keyboard.key_down.a) ||\n (args.inputs.keyboard.key_down.d) ||\n (args.inputs.controller_one.key_down.y) ||\n (args.inputs.controller_one.key_down.x) ||\n (args.inputs.controller_one.key_down.left) ||\n (args.inputs.controller_one.key_down.right)\n\n if (should_process_special_move)\n if (args.inputs.keyboard.key_down.j && args.inputs.keyboard.key_down.k) ||\n (args.inputs.controller_one.key_down.x && args.inputs.controller_one.key_down.y)\n args.state.inputlist.unshift(\"shield\")\n elsif (args.inputs.keyboard.key_down.k || args.inputs.controller_one.key_down.y) &&\n (args.state.inputlist[0] == \"forward-attack\") && ((args.state.tick_count - args.state.lastpush) <= 15)\n args.state.inputlist.unshift(\"dash-attack\")\n args.state.player.dx = 20\n elsif (args.inputs.keyboard.key_down.j && args.inputs.keyboard.a) ||\n (args.inputs.controller_one.key_down.x && args.inputs.controller_one.key_down.left)\n args.state.inputlist.unshift(\"back-attack\")\n elsif ( args.inputs.controller_one.key_down.x || args.inputs.keyboard.key_down.j)\n args.state.inputlist.unshift(\"forward-attack\")\n elsif (args.inputs.keyboard.key_down.k || args.inputs.controller_one.key_down.y) &&\n (args.state.player.y > 128)\n args.state.inputlist.unshift(\"dair\")\n elsif (args.inputs.keyboard.key_down.k || args.inputs.controller_one.key_down.y)\n args.state.inputlist.unshift(\"up-attack\")\n elsif (args.inputs.controller_one.key_down.left || args.inputs.keyboard.key_down.a) &&\n (args.state.inputlist[0] == \"<\") &&\n ((args.state.tick_count - args.state.lastpush) <= 10)\n args.state.inputlist.unshift(\"<<\")\n args.state.player.dx = -15\n elsif (args.inputs.controller_one.key_down.left || args.inputs.keyboard.key_down.a)\n args.state.inputlist.unshift(\"<\")\n args.state.timeleft = args.state.tick_count\n elsif (args.inputs.controller_one.key_down.right || args.inputs.keyboard.key_down.d)\n args.state.inputlist.unshift(\">\")\n end\n\n args.state.lastpush = args.state.tick_count\n end\n\n if args.inputs.keyboard.space || args.inputs.controller_one.r2 # if the user presses the space bar\n args.state.player.jumped_at ||= args.state.tick_count # jumped_at is set to current frame\n\n # if the time that has passed since the jump is less than the player's jump duration and\n # the player is not falling\n if args.state.player.jumped_at.elapsed_time < args.state.player_jump_power_duration && !args.state.player.falling\n args.state.player.dy = args.state.player_jump_power # change in y is set to power of player's jump\n end\n end\n\n # if the space bar is in the \"up\" state (or not being pressed down)\n if args.inputs.keyboard.key_up.space || args.inputs.controller_one.key_up.r2\n args.state.player.jumped_at = nil # jumped_at is empty\n args.state.player.falling = true # the player is falling\n end\n\n if args.inputs.left # if left key is pressed\n if args.state.player.dx < -5\n args.state.player.dx = args.state.player.dx\n else\n args.state.player.dx = -5\n end\n\n elsif args.inputs.right # if right key is pressed\n if args.state.player.dx > 5\n args.state.player.dx = args.state.player.dx\n else\n args.state.player.dx = 5\n end\n else\n args.state.player.dx *= args.state.player_speed_slowdown_rate # dx is scaled down\n end\n\n if ((args.state.player.dx).abs > 5) #&& ((args.state.tick_count - args.state.lastpush) <= 10)\n args.state.player.dx *= 0.95\n end\nend",
"def update_phase3\r\n # If enemy arrow is enabled\r\n if @enemy_arrow != nil\r\n update_phase3_enemy_select\r\n # If actor arrow is enabled\r\n elsif @actor_arrow != nil\r\n update_phase3_actor_select\r\n # If skill window is enabled\r\n elsif @skill_window != nil\r\n update_phase3_skill_select\r\n # If item window is enabled\r\n elsif @item_window != nil\r\n update_phase3_item_select\r\n # If actor command window is enabled\r\n elsif @actor_command_window.active\r\n update_phase3_basic_command\r\n end\r\n end",
"def draw3more(deck)\n for i in 1..3\n @cardsShown << deck.draw\n end\n end",
"def dev_commands args\n if args.inputs.keyboard.key_down.m || args.inputs.controller_one.key_down.a\n new_ball args\n end\n\n # commented out because breaks game (type = \"h\")\n # if args.inputs.keyboard.key_down.h || args.inputs.controller_one.key_down.b\n # heavy_ball args\n # end\n\n if args.inputs.keyboard.key_down.one || args.inputs.controller_one.key_down.x\n new_ball1 args\n end\n\n if args.inputs.keyboard.key_down.two || args.inputs.controller_one.key_down.y\n new_ball2 args\n end\n\n if args.inputs.keyboard.key_down.r || args.inputs.controller_one.key_down.start\n reset args\n end\nend",
"def initialize_strategy\n main_position = player.command_centers.first.position\n _, *unscouted_bases = BWTA.start_locations.to_a.map(&:position).sort do |a, b|\n main_position.getDistance(b) <=> main_position.getDistance(a)\n end.reverse\n overlord_target = nil\n\n #Basic Strategy:\n strategy_step \"Every idle worker should mine\" do\n precondition { player.workers.any? &:idle? }\n\n postcondition { false } #this step should be repeated\n\n order do\n center = player.command_centers.first\n\n minerals = state.units.values.select{|u| u.type.mineral_field? }.sort do |a, b|\n b.distance(center) <=> a.distance(center)\n end\n\n player.workers.select(&:idle?).each do |worker|\n worker.mine(minerals.pop)\n end\n end\n end\n\n #When there is less than 5 supply and a spawning pool does not exist, a drone should be spawned\n strategy_step \"Spawn a drone\" do\n precondition { player.minerals >= 50 && player.supply_used < 10 }\n\n postcondition { false } #this step should be repeated\n\n order { spawn UnitType.Zerg_Drone }\n end\n\n #When there is not enough supply an overlord should be spawned\n strategy_step \"Spawn an overlord\" do\n precondition { player.minerals >= 100 && player.supply_total <= player.supply_used && player.larva_available? } #not smart\n\n progresscondition { player.units.values.any? {|unit| unit.has_order? \"Spawn Overlord\" } }\n\n postcondition { false }#this step should be repeated\n\n order { spawn UnitType.Zerg_Overlord }\n end\n\n strategy_step \"Early overlord scout\" do\n overlord = nil\n target = nil\n\n precondition do\n overlords = player.get_all_by_unit_type(UnitType.Zerg_Overlord)\n if overlords.count == 1\n overlord = overlords.first\n target = unscouted_bases.shift\n overlord_target = target\n true\n end\n end\n\n progresscondition { overlord && target }\n\n postcondition { overlord.position == target if overlord }\n\n order { overlord.move(target) if overlord }\n end\n\n strategy_step \"Drone scout\" do\n drone_scout = nil\n target = nil\n\n precondition do\n if player.get_all_by_unit_type(UnitType.Zerg_Spawning_Pool).count > 0 && target = unscouted_bases.shift\n drone_scout = player.workers.first\n true\n end\n end\n\n order do\n # TODO why is if drone_scout necessary?\n drone_scout.move(target) if drone_scout\n end\n end\n\n #At 5 supply, 200 minerals a spawning pool should be made\n strategy_step \"Make a spawning pool at 5 supply\" do\n precondition { player.minerals > 200 && player.supply_total >= 10 }\n\n postcondition { player.units.values.any? {|u| u.type == UnitType.Zerg_Spawning_Pool} }\n\n progresscondition { player.units.values.any? {|u| u.has_order? \"Build SpawningPool\" } }\n\n order do\n player.workers.first.build(UnitType.Zerg_Spawning_Pool, build_location(UnitType.Zerg_Spawning_Pool))\n end\n end\n\n #When there is a spawning pool and enough minerals and supply, a zergling should be made\n strategy_step \"Make zerglings\" do\n precondition { player.minerals > 50 && player.supply_left >= 2 && player.larva_available? }\n\n precondition { player.get_all_by_unit_type(UnitType.Zerg_Spawning_Pool).count > 0 }\n\n postcondition { false } #this step should be repeated\n\n order do\n while (player.minerals > 50 && player.supply_left >= 2 && player.larva_available?) do\n spawn UnitType.Zerg_Zergling #spawn many zerglings in one frame\n end\n end\n end\n\n strategy_step \"Move in!\" do\n precondition { zerglings.count >= 1 && enemy.units.count == 0 }\n\n postcondition { false }\n\n order do\n target = unscouted_bases.shift || overlord_target\n\n zerglings.each do |z|\n puts \"Ordering zerglings to move\"\n z.move(target)\n end\n end\n end\n\n #When there are 5 zerglings, they should attack\n strategy_step \"Attack!\" do\n precondition { zerglings.count >= 5 && enemy.units.count > 0 }\n\n postcondition { false } #just keep on doin' it\n\n order do \n puts \"Ordering zerglings to attack\"\n zerglings.each { |z| attack_nearest_enemy(z) }\n end\n end\n end",
"def update_command_selection()\n if Input.trigger?(Input::B)\n Sound.play_cancel\n quit_command()\n \n elsif Input.trigger?(Input::C)\n case @command_window.index\n when 0 # Equip\n Sound.play_decision\n equip_command()\n update_detail_window(@status_equip_window.selected_item)\n end\n \n elsif Input.trigger?(Input::R)\n Sound.play_cursor\n next_actor_command()\n elsif Input.trigger?(Input::L)\n Sound.play_cursor\n prev_actor_command()\n end\n \n end",
"def runOpen3StuckPrevention(*cmd_and_args, errorPrefix: '', redError: false, retryCount: 5,\n stuckTimeout: 120)\n\n onError 'Empty runOpen3 command' if cmd_and_args.empty?\n\n if !File.exist?(cmd_and_args[0]) || !Pathname.new(cmd_and_args[0]).absolute?\n # check that the command exists if it is not a full path to a file\n requireCMD cmd_and_args[0]\n end\n\n Open3.popen3(*cmd_and_args) do |_stdin, stdout, stderr, wait_thr|\n last_output_time = Time.now\n\n out_thread = Thread.new do\n stdout.each do |line|\n puts line\n last_output_time = Time.now\n end\n end\n\n err_thread = Thread.new do\n stderr.each do |line|\n if redError\n puts((errorPrefix + line).red)\n else\n puts errorPrefix + line\n end\n last_output_time = Time.now\n end\n end\n\n # Handle timeouts\n while wait_thr.join(10).nil?\n\n next unless Time.now - last_output_time >= stuckTimeout\n\n warning \"RubySetupSystem stuck prevention: #{Time.now - last_output_time} elapsed \" \\\n 'since last output from command'\n\n if retryCount > 0\n info 'Restarting it '\n Process.kill('TERM', wait_thr.pid)\n\n sleep(5)\n return runOpen3StuckPrevention(*cmd_and_args, errorPrefix: errorPrefix,\n redError: redError,\n retryCount: retryCount - 1,\n stuckTimeout: stuckTimeout)\n else\n warning 'Restarts exhausted, going to wait until user interrupts us'\n last_output_time = Time.now\n end\n end\n exit_status = wait_thr.value\n\n out_thread.kill\n err_thread.kill\n return exit_status\n end\n\n onError \"Execution shouldn't reach here\"\nend",
"def update_phase3_actor_select\n # Update actor arrow\n @actor_arrow.update\n # If B button was pressed\n if Input.trigger?(Input::B)\n # Play cancel SE\n $game_system.se_play($data_system.cancel_se)\n # End actor selection\n end_actor_select\n return\n end\n # If C button was pressed\n if Input.trigger?(Input::C)\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Set action\n @active_battler.current_action.target_index = @actor_arrow.index\n # End actor selection\n end_actor_select\n # If skill window is showing\n if @skill_window != nil\n # End skill selection\n end_skill_select\n end\n # If item window is showing\n if @item_window != nil\n # End item selection\n end_item_select\n end\n # Go to command input for next actor\n phase3_next_actor\n end\n end",
"def prompt_with_and_then(prompt, items, action)\n choice = `echo \"#{self.send(items)}\" | theme-dmenu -p \"#{prompt}\"`\n if (choice.length > 0)\n out, err, code = Open3.capture3(self.send(action, \"#{mountable_path}/#{choice}\"))\n if (err.length > 0)\n `notify-send -u critical Easymount \"#{err}\"`\n else\n `notify-send Easymount \"#{out}\"`\n end\n end\nend",
"def update_phase3_actor_select\r\n # If B button was pressed\r\n if Input.trigger?(Input::B)\r\n # Play cancel SE\r\n $game_system.se_play($data_system.cancel_se)\r\n # End actor selection\r\n end_actor_select\r\n return\r\n end\r\n # If C button was pressed\r\n if Input.trigger?(Input::C)\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Set action\r\n @active_battler.current_action.target_index = @actor_arrow.index\r\n # End actor selection\r\n end_actor_select\r\n # If skill window is showing\r\n if @skill_window != nil\r\n # End skill selection\r\n end_skill_select\r\n end\r\n # If item window is showing\r\n if @item_window != nil\r\n # End item selection\r\n end_item_select\r\n end\r\n # Go to command input for next actor\r\n phase3_next_actor\r\n end\r\n end",
"def process_commands(*cmds)\n Timeout::timeout(1) do\n send_command(COMMAND_MODE)\n cmds.each {|cmd| send_command(cmd) }\n getc\n end\n end",
"def replaceThree\n # move cards from deck to cardsOnTable\n 3.times{ |c|\n @cardsOnTable.push(@cards.at(c))\n }\n # subtract 3 cards from deck\n 3.times{cards.shift}\n end",
"def runOpen3StuckPrevention(*cmdAndArgs, errorPrefix: \"\", redError: false, retryCount: 5,\n stuckTimeout: 120)\n\n if cmdAndArgs.length < 1\n onError \"Empty runOpen3 command\"\n end\n\n if !File.exists? cmdAndArgs[0] or !Pathname.new(cmdAndArgs[0]).absolute?\n # check that the command exists if it is not a full path to a file\n requireCMD cmdAndArgs[0]\n end\n\n Open3.popen3(*cmdAndArgs) {|stdin, stdout, stderr, wait_thr|\n\n lastOutputTime = Time.now\n\n outThread = Thread.new{\n stdout.each {|line|\n puts line\n lastOutputTime = Time.now\n }\n }\n\n errThread = Thread.new{\n stderr.each {|line|\n if redError\n puts (errorPrefix + line).red\n else\n puts errorPrefix + line\n end\n lastOutputTime = Time.now\n }\n }\n\n # Handle timeouts\n while wait_thr.join(10) == nil\n\n if Time.now - lastOutputTime >= stuckTimeout\n warning \"RubySetupSystem stuck prevention: #{Time.now - lastOutputTime} elapsed \" +\n \"since last output from command\"\n\n if retryCount > 0\n info \"Restarting it \"\n Process.kill(\"TERM\", wait_thr.pid)\n\n sleep(5)\n return runOpen3StuckPrevention(*cmdAndArgs, errorPrefix: errorPrefix,\n redError: redError, retryCount: retryCount - 1,\n stuckTimeout: stuckTimeout)\n else\n warning \"Restarts exhausted, going to wait until user interrupts us\"\n lastOutputTime = Time.now\n end\n end\n end\n exit_status = wait_thr.value\n\n outThread.kill\n errThread.kill\n return exit_status\n }\n\n onError \"Execution shouldn't reach here\"\n \nend",
"def update_phase3_item_select\n # Make item window visible\n @item_window.visible = true\n # Update item window\n @item_window.update\n # If B button was pressed\n if Input.trigger?(Input::B)\n # Play cancel SE\n $game_system.se_play($data_system.cancel_se)\n # End item selection\n end_item_select\n return\n end\n # If C button was pressed\n if Input.trigger?(Input::C)\n # Get currently selected data on the item window\n @item = @item_window.item\n # If it can't be used\n unless $game_party.item_can_use?(@item.id)\n # Play buzzer SE\n $game_system.se_play($data_system.buzzer_se)\n return\n end\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Set action\n @active_battler.current_action.item_id = @item.id\n # Make item window invisible\n @item_window.visible = false\n # If effect scope is single enemy\n if @item.scope == 1\n # Start enemy selection\n start_enemy_select\n # If effect scope is single ally\n elsif @item.scope == 3 or @item.scope == 5\n # Start actor selection\n start_actor_select\n # If effect scope is not single\n else\n # End item selection\n end_item_select\n # Go to command input for next actor\n phase3_next_actor\n end\n return\n end\n end",
"def do_command2\n $game_temp.num_input_start = GameData::MAX_LEVEL\n $game_temp.num_input_variable_id = Yuki::Var::TMP1\n $game_temp.num_input_digits_max = 3\n display_message(ext_text(8997, 27))\n @wanted_data[1] = $game_variables[Yuki::Var::TMP1] if $game_variables[Yuki::Var::TMP1] > 0\n $game_temp.num_input_start = GameData::MAX_LEVEL\n $game_temp.num_input_variable_id = Yuki::Var::TMP1\n $game_temp.num_input_digits_max = 3\n display_message(ext_text(8997, 28))\n @wanted_data[2] = $game_variables[Yuki::Var::TMP1] if $game_variables[Yuki::Var::TMP1] >= @wanted_data[1]\n end",
"def step_three\n zeros = starred_zeros.select_cells { |cell| cell }\n zeros.each do |zero|\n covered_zeros.set_col(zero[1], true)\n end\n end",
"def prepare_materials(ops, composition)\n # ops.each do |op|\n # add_hidden_input(op, DYE_SAMPLE, dye)\n # add_hidden_input(op, POLYMERASE_SAMPLE, polymerase)\n # end\n\n templates = ops.map { |op| op.input(TEMPLATE).item }\n\n fwd_primers = get_primer_set(ops, FORWARD_PRIMER)\n rev_primers = get_primer_set(ops, REVERSE_PRIMER)\n\n items_to_take = [templates, fwd_primers, rev_primers]\n\n if composition.polymerase.item\n items_to_take << composition.polymerase.item\n end\n\n if composition.dye.item\n items_to_take << composition.dye.item\n end\n\n take(items_to_take.flatten, interactive: true, method: 'boxes')\n\n vortex_samples([fwd_primers, rev_primers, templates])\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n #use the built-in error checking\n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n #assign the user inputs to variables\n eff = runner.getDoubleArgumentValue(\"eff\",user_arguments)\n\n #check the user_name for reasonableness\n if eff <= 0\n runner.registerError(\"Please enter a positive value for Nominal Thermal Efficiency.\")\n return false\n end\n if eff > 1\n runner.registerWarning(\"The requested Nominal Thermal Efficiency must be <= 1\")\n end\n \n #change the efficiency of each boiler\n #loop through all the plant loops in the mode\n model.getPlantLoops.each do |plant_loop|\n #loop through all the supply components on this plant loop\n plant_loop.supplyComponents.each do |supply_component|\n #check if the supply component is a boiler\n if not supply_component.to_BoilerHotWater.empty?\n boiler = supply_component.to_BoilerHotWater.get\n #set the efficiency of the boiler\n boiler.setNominalThermalEfficiency(eff)\n runner.registerInfo(\"set boiler #{boiler.name} efficiency to #{eff}\")\n end\n end\n end\n \n \n=begin \n initial_effs = []\n missing_initial_effs = 0\n\n #find and loop through air loops\n air_loops = model.getAirLoopHVACs\n air_loops.each do |air_loop|\n supply_components = air_loop.supplyComponents\n\n #find two speed dx units on loop\n supply_components.each do |supply_component|\n dx_unit = supply_component.to_CoilCoolingDXTwoSpeed\n if not dx_unit.empty?\n dx_unit = dx_unit.get\n\n #change and report high speed cop\n initial_high_cop = dx_unit.ratedHighSpeedCOP\n if not initial_high_cop.empty?\n runner.registerInfo(\"Changing the Rated High Speed COP from #{initial_high_cop.get} to #{cop_high} for two speed dx unit '#{dx_unit.name}' on air loop '#{air_loop.name}'\")\n initial_high_cop_values << initial_high_cop.get\n dx_unit.setRatedHighSpeedCOP(cop_high)\n else\n runner.registerInfo(\"Setting the Rated High Speed COP to #{cop_high} for two speed dx unit '#{dx_unit.name}' on air loop '#{air_loop.name}. The original object did not have a Rated High Speed COP value'\")\n missing_initial_high_cop = missing_initial_high_cop + 1\n dx_unit.setRatedHighSpeedCOP(cop_high)\n end\n\n #change and report low speed cop\n initial_low_cop = dx_unit.ratedLowSpeedCOP\n if not initial_low_cop.empty?\n runner.registerInfo(\"Changing the Rated Low Speed COP from #{initial_low_cop.get} to #{cop_low} for two speed dx unit '#{dx_unit.name}' on air loop '#{air_loop.name}'\")\n initial_low_cop_values << initial_low_cop.get\n dx_unit.setRatedLowSpeedCOP(cop_low)\n else\n runner.registerInfo(\"Setting the Rated Low Speed COP to #{cop_low} for two speed dx unit '#{dx_unit.name}' on air loop '#{air_loop.name}. The original object did not have a Rated Low Speed COP COP value'\")\n missing_initial_low_cop = missing_initial_low_cop + 1\n dx_unit.setRatedLowSpeedCOP(cop_low)\n end\n\n end #end if not dx_unit.empty?\n\n end #end supply_components.each do\n\n end #end air_loops.each do\n\n #reporting initial condition of model\n runner.registerInitialCondition(\"The starting Rated High Speed COP values range from #{initial_high_cop_values.min} to #{initial_high_cop_values.max}. The starting Rated Low Speed COP values range from #{initial_low_cop_values.min} to #{initial_low_cop_values.max}.\")\n\n #warning if two counts of cop's are not the same\n if not initial_high_cop_values.size + missing_initial_high_cop == initial_low_cop_values.size + missing_initial_low_cop\n runner.registerWarning(\"Something went wrong with the measure, not clear on count of two speed dx objects\")\n end\n\n if initial_high_cop_values.size + missing_initial_high_cop == 0\n runner.registerAsNotApplicable(\"The model does not contain any two speed DX cooling units, the model will not be altered.\")\n return true\n end\n\n #reporting final condition of model\n runner.registerFinalCondition(\"#{initial_high_cop_values.size + missing_initial_high_cop} two speed dx units had their High and Low speed COP values set to #{cop_high} for high, and #{cop_low} for low.\")\n=end\n return true\n\n end",
"def update_phase3_enemy_select\n # Update enemy arrow\n @enemy_arrow.update\n # If B button was pressed\n if Input.trigger?(Input::B)\n # Play cancel SE\n $game_system.se_play($data_system.cancel_se)\n # End enemy selection\n end_enemy_select\n return\n end\n # If C button was pressed\n if Input.trigger?(Input::C)\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Set action\n @active_battler.current_action.target_index = @enemy_arrow.index\n # End enemy selection\n end_enemy_select\n # If skill window is showing\n if @skill_window != nil\n # End skill selection\n end_skill_select\n end\n # If item window is showing\n if @item_window != nil\n # End item selection\n end_item_select\n end\n # Go to command input for next actor\n phase3_next_actor\n end\n end",
"def main\n pr = intro\n operations.group_by {|op| get_parameter(op: op, fv_str: MEASUREMENT_TYPE).to_sym}.each do |measurement_type, ops|\n new_mtype = true\n pr.measurement_type = measurement_type\n ops.group_by {|op| op.input(INPUT).sample.sample_type}.each do |st, ops|\n ops.group_by {|op| op.input(MEDIA).item}.each do |media_item, ops|\n ops.group_by {|op| get_uninitialized_output_object_type(op)}.each do |out_ot, ops|\n ops.make\n ops.group_by {|op| op.output(OUTPUT).collection}.each do |out_collection, ops|\n pr.setup_experimental_measurement(experimental_item: out_collection, output_fv: nil)\n new_mtype = setup_plate_reader_software_env(pr: pr, new_mtype: new_mtype)\n # Gather materials and items\n take_items = [media_item].concat([pr.experimental_item].flatten)\n gather_materials(empty_containers: [pr.measurement_item], transfer_required: pr.transfer_required, new_materials: ['P1000 Multichannel'], take_items: take_items)\n # Prep plate\n display_hash = get_transfer_display_hash(ops: ops, input_str: INPUT, output_str: OUTPUT, dilution_str: DILUTION)\n prefill_plate_w_media(collection: pr.measurement_item, media_sample: media_item.sample, media_vol_ul: nil, display_hash: display_hash) # media_vol_ul must be > 0 to run show block\n take ops.map {|op| op.input(INPUT).item}, interactive: true\n tech_transfer_cultures(collection: pr.measurement_item, display_hash: display_hash)\n tech_add_blanks(pr: pr, blanking_sample: media_item.sample, culture_vol_ul: 0.0, media_vol_ul: 300.0) # Cannot handle a plate without blanks, esp in processing of upload\n \n take_measurement_and_upload_data(pr: pr)\n \n dilution_factor_arr = ops.map {|op| get_dilution_factor(op: op, fv_str: DILUTION)}\n \n process_and_associate_data(pr: pr, ops: ops, blanking_sample: media_item.sample, dilution_factor: dilution_factor_arr)\n end\n keep_p_arr = ops.select {|op| op.input(KEEP_OUT_PLT).val.to_s.downcase == 'yes'}\n (keep_p_arr.empty?) ? pr.measurement_item.mark_as_deleted : pr.measurement_item.location = 'Bench'\n end\n end\n end\n end\n cleaning_up(pr: pr)\n end",
"def mess_with_vars1(one, two, three)\n one = two\n two = three\n three = one\nend",
"def update_phase4_step3\n if @active_battler.current_action.kind == 0 and\n @active_battler.current_action.basic == 0\n # in this one... we have our weapon animations... for player and monster\n if @active_battler.is_a?(Game_Actor)\n @spriteset.actor_sprites[@active_battler.index].pose(@weapon_sprite)\n elsif @active_battler.is_a?(Game_Enemy)\n @spriteset.enemy_sprites[@active_battler.index].enemy_pose(@weapon_sprite_enemy)\n end\n end\n if @animation1_id == 0\n @active_battler.white_flash = true\n else\n @active_battler.animation_id = @animation1_id\n @active_battler.animation_hit = true\n end\n @phase4_step = 4\n end",
"def update_phase3_enemy_select\r\n # If B button was pressed\r\n if Input.trigger?(Input::B)\r\n # Play cancel SE\r\n $game_system.se_play($data_system.cancel_se)\r\n # End enemy selection\r\n end_enemy_select\r\n return\r\n end\r\n # If C button was pressed\r\n if Input.trigger?(Input::C)\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Set action\r\n @active_battler.current_action.target_index = @enemy_arrow.index\r\n # End enemy selection\r\n end_enemy_select\r\n # If skill window is showing\r\n if @skill_window != nil\r\n # End skill selection\r\n end_skill_select\r\n end\r\n # If item window is showing\r\n if @item_window != nil\r\n # End item selection\r\n end_item_select\r\n end\r\n # Go to command input for next actor\r\n phase3_next_actor\r\n end\r\n end",
"def third_roll(keepers)\n Dice.reroll(keepers)\n end",
"def phase3_setup_command_window\r\n # Disable party command window\r\n @party_command_window.active = false\r\n @party_command_window.visible = false\r\n # Enable actor command window\r\n @actor_command_window.active = true\r\n @actor_command_window.visible = true\r\n # Set actor command window position\r\n @actor_command_window.x = @actor_index * 160\r\n # Set index to 0\r\n @actor_command_window.index = 0\r\n end",
"def phase3_command_item\r\n # Set action\r\n @active_battler.current_action.kind = 2\r\n # Start item selection\r\n start_item_select\r\n end",
"def setup_while\n return TSBS.error(@acts[0], 2, @used_sequence) if @acts.size < 3\n cond = @acts[1]\n action_key = @acts[2]\n actions = (action_key.class == String ? TSBS::AnimLoop[action_key] :\n action_key)\n if actions.nil?\n show_action_error(action_key)\n end\n begin\n while eval(cond)\n exe_act = actions.clone\n until exe_act.empty? || @break_action\n @acts = exe_act.shift\n execute_sequence\n end\n end\n rescue StandardError => err\n display_error(\"[#{SEQUENCE_WHILE},]\",err)\n end\n end",
"def phase3_setup_command_window\n # Disable party command window\n @party_command_window.active = false\n @party_command_window.visible = false\n # Enable actor command window\n @actor_command_window.active = true\n @actor_command_window.visible = true\n # Set actor command window position\n @actor_command_window.x = @actor_index * 160\n # Set index to 0\n @actor_command_window.index = 0\n end",
"def multi_attack_actions(session, battle)\n end",
"def three_statement_command(splitted_input)\n\t\tslot_no = parking_lot\n\t\t\n\t\tpark_check(reg_no: splitted_input[1],\n\t\t\t\t\tcolor: splitted_input[2],\n\t\t\t\t\tslot_no: slot_no)\n\tend",
"def setup_loop\n return TSBS.error(@acts[0], 2, @used_sequence) if @acts.size < 3\n count = @acts[1]\n action_key = @acts[2]\n is_string = action_key.is_a?(String)\n count.times do\n if is_string\n @acts = [:action, action_key]\n execute_sequence\n break if @break_action\n else\n begin\n action_key.each do |action|\n @acts = action\n execute_sequence\n break if @break_action\n end\n rescue\n ErrorSound.play\n text = \"Wrong [:loop] parameter!\"\n msgbox text\n exit\n end\n end\n break if @break_action\n end\n end",
"def roll_three_alt\n puts \"...........\n: * :\n: * :\n: * :\n'''''''''''\n\"\nend",
"def begin_character_selection combined_arguments\n player_list, @my_character_locations = combined_arguments\n\n @players = player_list\n $LOGGER.debug \"Game is moving into character selection phase. Other players are #{@players.inspect}\"\n @mode = :select_characters\n @finalized_players.clear_players\n\n #this is the part where you choose players\n @players.each do |p|\n @finalized_players.set_player_finalized p, false\n end\n end",
"def update_phase3_item_select\r\n # Make item window visible\r\n @item_window.visible = true\r\n # If B button was pressed\r\n if Input.trigger?(Input::B)\r\n # Play cancel SE\r\n $game_system.se_play($data_system.cancel_se)\r\n # End item selection\r\n end_item_select\r\n return\r\n end\r\n # If C button was pressed\r\n if Input.trigger?(Input::C)\r\n # Get currently selected data on the item window\r\n @item = @item_window.item\r\n # If it can't be used\r\n unless $game_party.item_can_use?(@item.id)\r\n # Play buzzer SE\r\n $game_system.se_play($data_system.buzzer_se)\r\n return\r\n end\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Set action\r\n @active_battler.current_action.item_id = @item.id\r\n # Make item window invisible\r\n @item_window.visible = false\r\n @item_window.active = false\r\n # If effect scope is single enemy\r\n if @item.scope == 1\r\n # Start enemy selection\r\n start_enemy_select\r\n # If effect scope is single ally\r\n elsif @item.scope == 3 or @item.scope == 5\r\n # Start actor selection\r\n start_actor_select\r\n # If effect scope is not single\r\n else\r\n # End item selection\r\n end_item_select\r\n # Go to command input for next actor\r\n phase3_next_actor\r\n end\r\n return\r\n end\r\n end",
"def run_commands\n raise \"First command must be: PLACE\" unless (/PLACE/).match @commands.first\n\n\n @commands.each do |cmd|\n @action = cmd.split(\" \").first\n case @action\n when \"PLACE\"\n place = cmd.split(/\\s|\\,/)\n @x = Integer(place[1])\n @y = Integer(place[2])\n raise \"Placement is out of bounds\" unless @tabletop.table_boundary?(@x, @y)\n @direction = place[3].to_s\n raise \"Not a valid direction. Must be either: NORTH, EAST, SOUTH, WEST.\" unless DIRECTIONS.include?(@direction)\n @placed = true\n when \"MOVE\"\n move\n when \"LEFT\"\n rotate_left\n when \"RIGHT\"\n rotate_right\n when \"REPORT\"\n report\n end\n end\n end",
"def update_command\n # If B button was pressed\n if Input.trigger?(Input::B)\n # Play cancel SE\n $game_system.se_play($data_system.cancel_se)\n # Switch to map screen\n $scene = Scene_Map.new\n return\n end\n # If C button was pressed\n if Input.trigger?(Input::C)\n # If command other than save or end game, and party members = 0\n if $game_party.actors.size == 0 and @command_window.index < 4\n # Play buzzer SE\n $game_system.se_play($data_system.buzzer_se)\n return\n end\n # Branch by command window cursor position\n case @command_window.index\n when 0 # item\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Switch to item screen\n $scene = Scene_Item.new\n when 1 # skill\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Make status window active\n @command_window.active = false\n @status_window.active = true\n @status_window.index = 0\n when 2 # equipment\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Make status window active\n @command_window.active = false\n @status_window.active = true\n @status_window.index = 0\n when 3 # piercings\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Make status window active\n @command_window.active = false\n @status_window.active = true\n @status_window.index = 0\n when 5 # status\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Make status window active\n @command_window.active = false\n @status_window.active = true\n @status_window.index = 0\n when 6 # save\n # If saving is forbidden\n if $game_system.save_disabled\n # Play buzzer SE\n $game_system.se_play($data_system.buzzer_se)\n return\n end\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Switch to save screen\n $scene = Scene_Save.new\n when 7 # end game\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Switch to end game screen\n $scene = Scene_End.new\n end\n return\n end\n end",
"def command_use_point\r\r\n if $game_actors[@actor.id].skill_tree[0] == 0 || confirm_skill_add\r\r\n Sound.play_buzzer\r\r\n @confirm.close\r\r\n @confirm.active = false\r\r\n else\r\r\n @skills_icons[@skill_selected].opacity = 255\r\r\n $game_actors[@actor.id].skill_tree[0] -= 1\r\r\n $game_actors[@actor.id].lose_jp(Actor[@actor.id][@skill_selected]['JP'])\r\r\n $game_actors[@actor.id].skill_mult[Actor[@actor.id][@skill_selected]['Skill_id']] += Actor[@actor.id][@skill_selected]['Multiply']\r\r\n $game_actors[@actor.id].skill_tree[Actor[@actor.id][@skill_selected]['Skill_id']] += 1\r\r\n $game_actors[@actor.id].learn_skill(Actor[@actor.id][@skill_selected]['Skill_id'])\r\r\n @info_window.refresh(@actor, @tree)\r\r\n Audio.se_play(\"Audio/SE/Skill3\",75,100)\r\r\n @confirm.close\r\r\n @confirm.active = false\r\r\n if $game_switches[19] # achievement available?\r\r\n #------------------------------------------------------------------------------- \r\r\n # Trophic: Markspony\r\r\n #-------------------------------------------------------------------------------\r\r\n earn_trophic = true\r\r\n for i in 546..561\r\r\n if !$game_actors[@actor.id].skill_learned?(i) && !$ACH_markspony\r\r\n earn_trophic = false\r\r\n break\r\r\n end\r\r\n end\r\r\n \r\r\n if earn_trophic && !$ACH_markspony\r\r\n $ACH_markspony = true\r\r\n GameJolt.award_trophy(\"53491\")\r\r\n p sprintf(\"Achievement unlock - markspony\")\r\r\n $game_system.earn_achievement(:markspony)\r\r\n end\r\r\n #------------------------------------------------------------------------------- \r\r\n # Trophic: Elementalist\r\r\n #------------------------------------------------------------------------------- \r\r\n earn_trophic = true\r\r\n for i in 563..582\r\r\n next if i == 567 || i == 571 || i == 577 || i == 581 \r\r\n if !$game_actors[@actor.id].skill_learned?(i) && !$ACH_elementalist\r\r\n earn_trophic = false\r\r\n break\r\r\n end\r\r\n end\r\r\n \r\r\n if earn_trophic && !$ACH_elementalist\r\r\n $ACH_elementalist = true\r\r\n GameJolt.award_trophy(\"53485\") \r\r\n p sprintf(\"Achievement unlock - elementalist\")\r\r\n $game_system.earn_achievement(:elementalist)\r\r\n end\r\r\n #---------------------------------------------------\r\r\n end\r\r\n end\r\r\n end",
"def user_commands\n puts sep = \"------------------------------------------------------\".colorize(:yellow)\n prompt = TTY::Prompt.new\n commands = [\n {name: 'Place', value: 1},\n {name: 'Move', value: 2},\n {name: 'Left', value: 3},\n {name: 'Right', value: 4},\n {name: 'Report', value: 5},\n {name: 'Execute Selected Commands', value: 6},\n ]\n players_input = prompt.select(\"Select Your Commands:\", commands) \n case players_input\n when 1\n place_command = prompt_place\n @commands_sequence.push(place_command)\n p @commands_sequence\n puts sep\n user_commands\n when 2\n move_command = validate_move\n @commands_sequence.push(move_command)\n p @commands_sequence\n puts sep\n user_commands\n when 3\n left_command = validate_left\n @commands_sequence.push(left_command)\n p @commands_sequence\n puts sep\n user_commands\n when 4\n right_command = validate_right\n @commands_sequence.push(right_command)\n p @commands_sequence\n puts sep\n user_commands\n when 5\n report_command = validate_report\n @commands_sequence.push(report_command)\n p @commands_sequence\n puts sep\n user_commands\n when 6\n legal_commands = valid_commands(@commands_sequence)\n if legal_commands.length == 0\n puts \"Command sequence must begin with a Place Command\".colorize(:red)\n user_commands\n else \n return legal_commands\n end\n end \n end",
"def update_phase3_skill_select\n # Make skill window visible\n @skill_window.visible = true\n # Update skill window\n @skill_window.update\n # If B button was pressed\n if Input.trigger?(Input::B)\n # Play cancel SE\n $game_system.se_play($data_system.cancel_se)\n # End skill selection\n end_skill_select\n return\n end\n # If C button was pressed\n if Input.trigger?(Input::C)\n # Get currently selected data on the skill window\n @skill = @skill_window.skill\n # If it can't be used\n if @skill == nil or not @active_battler.skill_can_use?(@skill.id)\n # Play buzzer SE\n $game_system.se_play($data_system.buzzer_se)\n return\n end\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Set action\n @active_battler.current_action.skill_id = @skill.id\n # Make skill window invisible\n @skill_window.visible = false\n # If effect scope is single enemy\n if @skill.scope == 1\n # Start enemy selection\n start_enemy_select\n # If effect scope is single ally\n elsif @skill.scope == 3 or @skill.scope == 5\n # Start actor selection\n start_actor_select\n # If effect scope is not single\n else\n # End skill selection\n end_skill_select\n # Go to command input for next actor\n phase3_next_actor\n end\n return\n end\n end",
"def phase3_next_actor\n # Loop\n begin\n # Actor blink effect OFF\n if @active_battler != nil\n @active_battler.blink = false\n end\n # If last actor\n if @actor_index == $game_party.actors.size-1\n # Start main phase\n start_phase4\n return\n end\n # Advance actor index\n @actor_index += 1\n @active_battler = $game_party.actors[@actor_index]\n @active_battler.blink = true\n # Once more if actor refuses command input\n end until @active_battler.inputable?\n # Set up actor command window\n phase3_setup_command_window\n end",
"def update_command_selection()\n if Input.trigger?(Input::B)\n Sound.play_cancel\n quit_command()\n \n elsif Input.trigger?(Input::C)\n case @command_window.index\n when 0 # Change\n Sound.play_decision\n change_command()\n when 1 # Order\n Sound.play_decision\n order_command()\n when 2 # Revert\n Sound.play_decision\n revert_command()\n end\n end\n \n end",
"def delay_1() sleep(3) end",
"def update_phase3_skill_select\r\n # Make skill window visible\r\n @skill_window.visible = true\r\n # If B button was pressed\r\n if Input.trigger?(Input::B)\r\n # Play cancel SE\r\n $game_system.se_play($data_system.cancel_se)\r\n # End skill selection\r\n end_skill_select\r\n return\r\n end\r\n # If C button was pressed\r\n if Input.trigger?(Input::C)\r\n # Get currently selected data on the skill window\r\n @skill = @skill_window.skill\r\n # If it can't be used\r\n if @skill == nil or not @active_battler.skill_can_use?(@skill.id)\r\n # Play buzzer SE\r\n $game_system.se_play($data_system.buzzer_se)\r\n return\r\n end\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Set action\r\n @active_battler.current_action.skill_id = @skill.id\r\n # Make skill window invisible\r\n @skill_window.visible = false\r\n @skill_window.active = false\r\n # If effect scope is single enemy\r\n if @skill.scope == 1\r\n # Start enemy selection\r\n start_enemy_select\r\n # If effect scope is single ally\r\n elsif @skill.scope == 3 or @skill.scope == 5\r\n # Start actor selection\r\n start_actor_select\r\n # If effect scope is not single\r\n else\r\n # End skill selection\r\n end_skill_select\r\n # Go to command input for next actor\r\n phase3_next_actor\r\n end\r\n return\r\n end\r\n end",
"def update_command_selection\n if Input.trigger?(Input::B)\n Sound.play_cancel\n $scene = Scene_Map.new\n elsif Input.trigger?(Input::C)\n cwi = @cm_list[@command_window.index]\n if $game_party.members.size == 0 && !CP::MENU_COMMANDS.COMMANDS[cwi].include?(:no1)\n Sound.play_buzzer\n return\n elsif $game_system.save_disabled && CP::MENU_COMMANDS.COMMANDS[cwi].include?(:save)\n Sound.play_buzzer\n return\n end\n Sound.play_decision\n if CP::MENU_COMMANDS.COMMANDS[cwi].size == 2\n $menu_index = @command_window.index\n create_submenu(cwi)\n else\n if CP::MENU_COMMANDS.COMMANDS[cwi][2]\n start_actor_selection\n else\n $menu_index = @command_window.index\n $scene = CP::MENU_COMMANDS.COMMANDS[cwi][1]\n end\n end\n end\n end",
"def update_command\n # If B button was pressed\n if Input.trigger?(Input::B)\n # Play cancel SE\n $game_system.se_play($data_system.cancel_se)\n # Switch to map screen\n $scene = Scene_Map.new\n return\n end\n # If C button was pressed\n if Input.trigger?(Input::C)\n # If command other than save or end game, and party members = 0\n if $game_party.actors.size == 0 and @command_window.index < 4\n # Play buzzer SE\n $game_system.se_play($data_system.buzzer_se)\n return\n end\n # Branch by command sprite cursor position\n case @command_window.index\n when 0 # item\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Switch to item screen\n $scene = Scene_Item.new\n when 1 # skill\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Make status sprite active\n @command_window.active = false\n @status_window.active = true\n @status_window.index = 0\n when 2 # equipment\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Make status sprite active\n @command_window.active = false\n @status_window.active = true\n @status_window.index = 0\n when 3 # status\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Make status sprite active\n @command_window.active = false\n @status_window.active = true\n @status_window.index = 0\n when 4 # save\n # If saving is forbidden\n if $game_system.save_disabled\n # Play buzzer SE\n $game_system.se_play($data_system.buzzer_se)\n return\n end\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Switch to save screen\n $scene = Scene_Save.new\n when 5 # end game\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Switch to end game screen\n $scene = Scene_End.new\n end\n return\n end\n end",
"def load_commands\n command(:linescore) { feed_for_event(_1)&.send_line_score }\n command(:lineups) { feed_for_event(_1)&.send_lineups }\n command(:umpires) { feed_for_event(_1)&.send_umpires }\n\n register_commands_with_arguments\n end",
"def update_command\r\n # If B button was pressed\r\n if Input.trigger?(Input::B)\r\n # Play cancel SE\r\n $game_system.se_play($data_system.cancel_se)\r\n # Switch to map screen\r\n $scene = Scene_Map.new\r\n return\r\n end\r\n # If C button was pressed\r\n if Input.trigger?(Input::C)\r\n # If command other than save or end game, and party members = 0\r\n if $game_party.actors.size == 0 and @command_window.index < 4\r\n # Play buzzer SE\r\n $game_system.se_play($data_system.buzzer_se)\r\n return\r\n end\r\n # Branch by command window cursor position\r\n case @command_window.index\r\n when 0 # item\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Switch to item screen\r\n $scene = Scene_Item.new\r\n when 1 # skill\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Make status window active\r\n @command_window.active = false\r\n @status_window.active = true\r\n @status_window.index = 0\r\n when 2 # equipment\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Make status window active\r\n @command_window.active = false\r\n @status_window.active = true\r\n @status_window.index = 0\r\n when 3 # status\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Make status window active\r\n @command_window.active = false\r\n @status_window.active = true\r\n @status_window.index = 0\r\n when 4 # save\r\n # If saving is forbidden\r\n if $game_system.save_disabled\r\n # Play buzzer SE\r\n $game_system.se_play($data_system.buzzer_se)\r\n return\r\n end\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Switch to save screen\r\n $scene = Scene_Save.new\r\n when 5 # end game\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Switch to end game screen\r\n $scene = Scene_End.new\r\n end\r\n return\r\n end\r\n end",
"def phase3_next_actor\r\n # Loop\r\n begin\r\n # Actor blink effect OFF\r\n if @active_battler != nil\r\n @active_battler.blink = false\r\n end\r\n # If last actor\r\n if @actor_index == $game_party.actors.size-1\r\n # Start main phase\r\n start_phase4\r\n return\r\n end\r\n # Advance actor index\r\n @actor_index += 1\r\n @active_battler = $game_party.actors[@actor_index]\r\n @active_battler.blink = true\r\n # Once more if actor refuses command input\r\n end until @active_battler.inputable?\r\n # Set up actor command window\r\n phase3_setup_command_window\r\n end",
"def do_command2\n id = nil # Local variable needs to exists outside of the block in Ruby 2.x\n loop do\n $game_temp.num_input_start = 0\n $game_temp.num_input_variable_id = Yuki::Var::TMP1\n $game_temp.num_input_digits_max = 8\n display_message_and_wait(ext_text(8997, 15))\n id = $game_variables[Yuki::Var::TMP1]\n return if id < 1\n break if id != $pokemon_party.online_id\n\n display_message(ext_text(8997, 16))\n end\n unless Core.pokemon_uploaded?(id)\n display_message(ext_text(8997, 17))\n return\n end\n gpkmn = Core.download_pokemon(id).to_pokemon\n pokemon_list = [] << gpkmn\n return display_message(ext_text(8997, 10)) unless gpkmn\n\n wanted_data = Core.download_wanted_data(id)\n return display_message(ext_text(8997, 11)) if wanted_data.empty?\n return unless select_pokemon(pokemon_list)\n return unless confirm_wanted_data(wanted_data)\n return unless (choice = choose_pokemon)\n\n pkmn = choice >= 31 ? $actors[choice - 31] : $storage.info(choice - 1)\n return display_message(ext_text(8997, 12)) unless pokemon_matching_requirements?(pkmn, wanted_data)\n\n return GTS.finish_trade(pkmn, gpkmn, true, choice, id)\n end",
"def update_command_selection()\n if Input.trigger?(Input::B)\n Sound.play_cancel\n quit_command()\n\n elsif Input.trigger?(Input::C)\n case @command_window.index\n when 8\n if $game_system.outline_enable == nil ||\n $game_system.outline_enable.size == 0\n Sound.play_buzzer\n else\n Sound.play_decision\n in_game_tutorials_command()\n end\n \n when 9\n Sound.play_decision\n command_to_title()\n else\n Sound.play_decision\n option_command()\n end\n end\n \n end"
] | [
"0.5831192",
"0.579489",
"0.57114065",
"0.5547119",
"0.55374914",
"0.5527577",
"0.54372317",
"0.54234296",
"0.5413138",
"0.5323597",
"0.5283924",
"0.52831274",
"0.52571297",
"0.5256628",
"0.52371",
"0.5200598",
"0.5190458",
"0.51765645",
"0.5168584",
"0.51361436",
"0.5113928",
"0.51130736",
"0.50978714",
"0.50800854",
"0.50756866",
"0.5069835",
"0.50246173",
"0.5017469",
"0.50170517",
"0.5000802",
"0.49900177",
"0.49647808",
"0.4915353",
"0.49149418",
"0.49149418",
"0.48971272",
"0.4891753",
"0.48822823",
"0.487328",
"0.48728254",
"0.4872298",
"0.4857289",
"0.4855131",
"0.48495522",
"0.48465586",
"0.4839459",
"0.48289147",
"0.48220104",
"0.48202908",
"0.48199314",
"0.48193508",
"0.48133996",
"0.48086625",
"0.48049986",
"0.48003465",
"0.47883767",
"0.47852242",
"0.47735685",
"0.47732565",
"0.4758263",
"0.47337383",
"0.47276294",
"0.47167495",
"0.47085124",
"0.47014746",
"0.46932214",
"0.46889696",
"0.4685036",
"0.4678427",
"0.46691298",
"0.46653482",
"0.46650082",
"0.46623224",
"0.46605238",
"0.46582144",
"0.4657756",
"0.4657476",
"0.4655464",
"0.46553427",
"0.46514156",
"0.4645667",
"0.46451634",
"0.46440607",
"0.46411002",
"0.46409768",
"0.46324185",
"0.4630419",
"0.46246713",
"0.46218157",
"0.46217322",
"0.46209317",
"0.4616302",
"0.4609275",
"0.4607001",
"0.4591411",
"0.45879674",
"0.4587202",
"0.45849803",
"0.45841667",
"0.45770487"
] | 0.4775092 | 57 |
Methods for custom attributes | def organizations
orgs = []
Organization.all.each do |o|
orgs.push(Api::V1::OrganizationSerializer.new(o, @instance_options).attributes)
end
orgs
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attr(name); end",
"def attribute(name); end",
"def attr; end",
"def method_missing(method_name, *args, &block)\n return super unless define_attribute_methods\n self.send(method_name, *args, &block)\n end",
"def method_missing(meth, *args, &blk)\n if args.length > 0\n self.class.add_custom_attribute meth\n send meth, *args, &blk\n else\n super meth, *args, &blk\n end\n end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def get_attribute(name); end",
"def get_attribute(name); 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 custom_data\n super.attributes\n end",
"def attr_info; end",
"def register_attributes\n raise \"Not implemented in #{self.class}\"\n end",
"def method_missing(method, *args, &block)\n @attributes.send(method, *args, &block)\n end",
"def is_attribute?; end",
"def method_missing(method, *args, &block)\n @attributes.send(method, *args, &block)\n end",
"def attributes=(_arg0); end",
"def allowed_attributes=(_arg0); end",
"def allowed_attributes=(_arg0); end",
"def method_missing(method_name, *args, &block)\n if method_name.to_s.end_with?('=')\n set_attribute(method_name, *args)\n elsif has_attribute?(method_name)\n get_attribute(method_name)\n else\n super\n end\n end",
"def class_attributes; end",
"def add_attribute(name, &block); end",
"def attributes\n end",
"def method_missing (name, *args, &block)\n add_attribute(name, *args, &block)\n end",
"def method_missing (name, *args, &block)\n add_attribute(name, *args, &block)\n end",
"def method_missing (name, *args, &block)\n add_attribute(name, *args, &block)\n end",
"def super_attr(name, opts={})\n\t\t\t\t\n\t\t\t\t# Defines getter\n\t\t\t\tdefine_method(\"#{name}\") do\n\t\t\t\t\tinstance_variable_get(\"@#{name}\")\n\t\t\t\tend\n\n\t\t\t\t# Defines setter\n\t\t\t\tdefine_method(\"#{name}=\") do |arg|\n\t\t\t\t\t# If the arg is a kind of opts[:type]\n\t\t\t\t\t# it sets the value, otherwise, it will\n\t\t\t\t\t# raise a StandardError.\n\t\t\t\t\tif arg.is_a? opts[:type]\n\t\t\t\t\t\tinstance_variable_set(\"@#{name}\", arg)\n\t\t\t\t\telse\n\t\t\t\t\t\traise StandardError.new(\"The value for #{name} is not a type #{opts[:type]}\")\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\t# If the attribute is required, it will\n\t\t\t\t# push its name to the @@required_attrs array\n\t\t\t\t@@required_attrs << name if opts.has_key?(:required) && opts[:required]\n\n\t\t\tend",
"def html_attributes(attr); end",
"def ext_attr\n attribute_prop(10)\n end",
"def method_missing(method, *args, &block)\n attributes.public_send(method, *args, &block)\n end",
"def attributes(_record)\n raise 'Abstract method attributes should be overriden'\n end",
"def method_missing(meth, *args, &block)\n if attributes.has_key?(meth)\n attributes[meth]\n else\n super\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 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(meth, *args, &block)\n method_name = meth.to_s\n\n assignment = false\n if method_name.last == '=' && args.size == 1\n assignment = true\n method_name = method_name.slice(0, method_name.length - 1) if method_name.length > 0\n end\n\n #Active Record uses this method to cast the type of attributes. Need to implement it for validates_numericality_of.\n if method_name.ends_with? '_before_type_cast'\n method_name.gsub!(/_before_type_cast/, '')\n end\n\n #show?\n if args.size == 0 && !assignment && self.class.base_class.reserved_custom_attributes.include?(method_name)\n res = get_custom_attribute(method_name)\n return res || nil\n end\n\n #create/update?\n # NOTE: we don't check the reserved_custom_attributes on create, because they can\n # technically create any attribute they like\n if assignment && !self.attributes.include?(method_name) && self.class.base_class.reserved_custom_attributes.include?(method_name)\n\n return set_custom_attribute(method_name, args[0])\n end\n\n #fall through\n super(meth, *args, &block)\n end",
"def custom_attributes=(custom_attributes = {})\n @attributes[:custom] = ChartMogul::Utils::JSONParser.typecast_custom_attributes(custom_attributes)\n end",
"def helper_attr(*attrs); end",
"def custom_fields_basic_attributes=(attributes)\n non_relationship_custom_fields.each do |rule|\n name = rule['name']\n type = rule['type'].to_sym\n\n # method of the custom getter\n method_name = \"#{type}_attribute_set\"\n\n self.class.send(method_name, self, name, attributes)\n end\n end",
"def special_attribute(name)\n @special_attributes[name]\n end",
"def print_attribute(*) end",
"def data_attributes\n end",
"def attribute_name=(_arg0); end",
"def attribute_name=(_arg0); end",
"def attribute_name=(_arg0); 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 method_missing(method_name, *args)\n method_match, attribute_name, equal_sign = method_name.to_s.match(/\\A([^=]+)(=)?\\Z/).to_a\n if attribute_name && self.class.valid_attributes.include?(attribute_name.to_sym)\n if equal_sign \n attributes[attribute_name.to_sym] = args.first\n else\n attributes[attribute_name.to_sym]\n end\n else\n super\n end\n end",
"def method_missing(method_name, *args)\n # Return the attribute value\n if @attributes.has_key?(method_name)\n read_attribute(method_name)\n \n # If we predefine an attribute, but we don't have it loaded, return nil\n elsif self.class.predefined_attributes.include?(method_name)\n nil\n \n # Check booleans, attribute_name?\n elsif method_name.to_s =~ /\\?$/\n simple_method_name = method_name.to_s.gsub(/\\?$/, '').to_sym\n @attributes[simple_method_name] == true || @attributes[simple_method_name] == 't' || \n @attributes[simple_method_name] == 'true'\n \n # Method to set attribute, attribute_name=\n elsif method_name.to_s =~ /=$/ && !args.empty?\n write_attribute(method_name.to_s.gsub(/=$/, '').to_sym, args.first)\n \n # Default to raising an error\n else\n default_method_missing(method_name, *args)\n end\n end",
"def method_missing(method, *args, &block)\n unless self.class.attribute_methods_generated?\n self.class.define_attribute_methods\n\n if respond_to_without_attributes?(method)\n send(method, *args, &block)\n else\n super\n end\n else\n super\n end\n end",
"def method_missing(method, *args, &block)\n unless self.class.attribute_methods_generated?\n self.class.define_attribute_methods\n\n if respond_to_without_attributes?(method)\n send(method, *args, &block)\n else\n super\n end\n else\n super\n end\n 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 method_missing(method_name, *args, &block)\n if attrs.keys.include? method_name.to_s\n attrs[method_name.to_s]\n else\n super(method_name)\n end\nend",
"def method_missing(method_name, *args, &block)\n attributes.send(method_name.to_s, *args, &block)\n end",
"def serialize\n super(ATTR_NAME_ARY)\n end",
"def serialize\n super(ATTR_NAME_ARY)\n end",
"def serialize\n super(ATTR_NAME_ARY)\n end",
"def serialize\n super(ATTR_NAME_ARY)\n end",
"def serialize\n super(ATTR_NAME_ARY)\n end",
"def override\n attributes.override\n end",
"def attribute=(_arg0); end",
"def attribute=(_arg0); end",
"def method_missing(method, *args, &block)\n if respond_to_without_attributes?(method, true)\n super\n else\n match = matched_attribute_method(method.to_s)\n match ? attribute_missing(match, *args, &block) : super\n end\n end",
"def attributes(*args)\n args.each { |attr| attribute(attr) }\n end",
"def set_attribute(name, value); end",
"def my_attribute\n @my_attribute\n end",
"def attributes(*args)\n attr_accessor(*args)\n end",
"def attr_reader(*vars)\n super *(add_tracked_attrs(true, false, *vars))\n end",
"def lively_attributes(*args)\n self._active_attributes += args.collect(&:to_s)\n end",
"def method_missing(name, *args, &block)\n @attributes[name]\n end",
"def attr_writer(*vars)\n # avoid tracking attributes that are added by the class_attribute\n # as these are class attributes and not instance attributes.\n tracked_vars = vars.reject {|var| respond_to? var }\n add_tracked_attrs(false, true, *tracked_vars)\n vars.extract_options!\n super\n end",
"def instance_attributes; end",
"def method_missing(name, *args)\n n = name.to_s\n @attr.key?(n) ? @attr[n] : super\n end",
"def method_missing( symbol, *arguments )\n if symbol.to_s =~ /(.+)=/ && arguments.size == 1 then\n @attributes[ $1.to_sym ] = arguments.first\n elsif @attributes.has_key?( symbol ) && arguments.empty? then\n @attributes[ symbol ]\n else\n super symbol, arguments\n end\n end",
"def attributes(*args)\n args.each do |attr|\n attribute(attr)\n end\n end",
"def fetch_custom_attributes\n endpoint = \"/api/#{@version}/custom-attributes/\"\n make_get_request(endpoint)\n end",
"def dom_attribute(name); end",
"def model_attributes\n raise NotImplementedError\n end",
"def attributes=(*args)\n define_dynamic_answer_setters!\n super(*args)\n end",
"def attribute_method\n method_options = options\n\n lambda do |name, type = Object, options = {}|\n super(name, type, method_options.update(options))\n end\n end",
"def method_missing(method_name, *_args)\n if attrs.key?(method_name.to_s)\n attrs[method_name.to_s]\n else\n super(method_name)\n end\n end",
"def define_attributes\n @info.attributes.each do |attr|\n rname = underscore(attr.name)\n self.class.__send__(:define_method, rname) { self[attr.name] } if attr.readable?\n self.class.__send__(:define_method, rname + \"=\") {|v| self[attr.name] = v } if attr.writable?\n end\n end"
] | [
"0.7651348",
"0.764791",
"0.7601169",
"0.7329614",
"0.7284593",
"0.72721165",
"0.72721165",
"0.72721165",
"0.72721165",
"0.72721165",
"0.72721165",
"0.72721165",
"0.7250274",
"0.7250274",
"0.7194783",
"0.7194783",
"0.7194783",
"0.7194783",
"0.7194783",
"0.7194783",
"0.7194783",
"0.7194783",
"0.7194783",
"0.7194783",
"0.7194783",
"0.71642643",
"0.7155104",
"0.71267027",
"0.7071621",
"0.70669967",
"0.7016254",
"0.7009413",
"0.69975877",
"0.69975877",
"0.6982915",
"0.6943739",
"0.6931268",
"0.6915326",
"0.68914545",
"0.68914545",
"0.68914545",
"0.6887119",
"0.6869708",
"0.68590254",
"0.68550557",
"0.68450904",
"0.68413675",
"0.683905",
"0.683905",
"0.683786",
"0.6837608",
"0.68247",
"0.6823451",
"0.6804925",
"0.6766676",
"0.67449945",
"0.6736281",
"0.6736281",
"0.6736281",
"0.6733202",
"0.6732698",
"0.67278713",
"0.6721064",
"0.6721064",
"0.6707302",
"0.6707302",
"0.6707302",
"0.6707302",
"0.6707302",
"0.6707302",
"0.6707302",
"0.6697836",
"0.6680359",
"0.6675441",
"0.6675441",
"0.6675441",
"0.6675441",
"0.6675441",
"0.6663985",
"0.6653029",
"0.6653029",
"0.66354203",
"0.6596575",
"0.6596342",
"0.65926",
"0.6592563",
"0.6591392",
"0.65843207",
"0.65790355",
"0.65653723",
"0.65638804",
"0.65586233",
"0.6553198",
"0.6553012",
"0.6523213",
"0.6515966",
"0.6515641",
"0.65105575",
"0.65094167",
"0.65062755",
"0.650375"
] | 0.0 | -1 |
Store a prefix in the trie, and associate a value with it | def []=(prefix, value)
current = @root
current_prefix = prefix
while current_prefix != ""
current, current_prefix = find_canididate_insertion_node(current, current_prefix)
end
current[:value] = value
return value
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_pattern(prefix, pattern, &block)\n @trie[prefix] ||= {}\n @trie[prefix][pattern] = block\n end",
"def add_word_to_trie(word)\n chars = word.downcase.split('')\n crawl = root\n\n chars.each do |char|\n child = crawl.children\n if child.keys.include?(char)\n crawl = child[char]\n else\n temp = TrieNode.new(char)\n child[char] = temp\n crawl = temp\n end\n end\n crawl.is_end = true\n end",
"def prefix=(value)\n @prefix = value\n end",
"def add_subtree(tree, prefix)\n tree.all_data.each do |entry|\n located_entry = LocatedEntry.new(tree, entry, prefix)\n # universal path that handles also new elements for arrays\n path = \"#{prefix}/#{located_entry.key}[last()+1]\"\n set_new_value(path, located_entry)\n end\n end",
"def insert_letter(letter)\n @node_pointers[letter.to_sym] = TrieNode.new if @node_pointers[letter.to_sym].nil?\n end",
"def prefix=(prefix) @prefix = prefix end",
"def prefix=(value)\n value += '/' if value != '' and value[-1] != '/'\n @prefix = value\n end",
"def prefix(value)\n merge(leprefix: value.to_s)\n end",
"def define_prefixes(prefs)\n\t\t\tprefs.each do |prefix, val|\n\t\t\t @@prefixes[prefix] = RDF::Vocabulary.new(val)\n\t\t\tend\n\t\tend",
"def handle_prefix(client, data)\n prefix, uri = data\n\n topic = @engine.find_or_create_topic(uri)\n client.add_prefix(prefix, topic)\n\n trigger(:prefix, client, prefix, uri)\n end",
"def prefix(value)\n merge(gadrprefix: value.to_s)\n end",
"def insert(word)\n curr = @root\n word.each_char do |char|\n curr = (curr[char] ||= TrieNode.new)\n end\n curr[:_] = true\n end",
"def insert(string)\n temp = @@root\n\n # traverse string char by char because order matters in trie\n string.each_char do |char|\n # if node is not present in trie then create a new node for that char otherwise juse do nothing\n if temp[:nodes][char].nil?\n temp[:nodes][char] = {\n ending: 0,\n nodes: {}\n }\n end\n # update the node to next node\n temp = temp[:nodes][char]\n end\n # finally make the ending +1 with means this string ending here\n temp[:ending] += 1\n end",
"def prefix=(value = '/')\n # Replace :placeholders with '#{embedded options[:lookups]}'\n prefix_call = value.gsub(/:\\w+/) { |key| \"\\#{options[#{key}]}\" }\n\n # Redefine the new methods.\n code = <<-end_code\n def prefix_source() \"#{value}\" end\n def prefix(options={}) \"#{prefix_call}\" end\n end_code\n silence_warnings { instance_eval code, __FILE__, __LINE__ }\n rescue\n logger.error \"Couldn't set prefix: #{$!}\\n #{code}\"\n raise\n end",
"def prefix=(obj)\n obj = obj.split('/') if obj.is_a? String\n @prefix = obj\n end",
"def set_prefix_to(a)\n Kamelopard.id_prefix = a\n end",
"def add_word(word)\n node = @root\n word.each_char do |c|\n node.children[c] ||= TrieNode.new\n node = node.children[c]\n end\n node.is_end = true\n end",
"def add_word(word)\n node = root\n word.chars.each do |c|\n node.children[c] = TrieNode.new unless node.children.key?(c)\n node = node.children[c]\n end\n node.word = true\n end",
"def insert(word)\n tmp = self\n word.split(\"\").each do |char|\n tmp.childs[char] ||= Trie.new\n tmp = tmp.childs[char]\n end\n tmp.isend = true\n nil\n end",
"def [](prefix)\n current = @root\n current_prefix = prefix\n\n while !current.nil? && current_prefix != \"\"\n previous = current\n current, current_prefix = next_node(current, current_prefix)\n end\n\n return current[:value] if current\n return previous[:value]\n end",
"def add(word)\n node = @root\n word.downcase!\n word.each_char do |letter|\n node[letter] ||= Hash.new\n node = node[letter]\n end\n node[:end] = true\n end",
"def build_trie(dictionary)\n trie = TrieNode.new\n File.readlines(dictionary).each do |word|\n trie.insert(word.chomp)\n end\n trie\nend",
"def insert(character, trie)\n found = trie.find do |n|\n n.value == character\n end\n\n add_node(character, trie) unless found\n end",
"def set_if_nil(word, value)\n current = @root\n current_prefix = word\n\n while current_prefix != \"\"\n current, current_prefix = find_canididate_insertion_node(current, current_prefix)\n end\n\n current[:value] ||= value\n return current[:value]\n end",
"def create(key, value)\n redis_key = prefix(key)\n value = Marshal.dump(value)\n @redis.setnx(redis_key, value)\n end",
"def path_prefix=(value); end",
"def from_string(input)\n @prefixes = Prefixes.create(input)\n end",
"def add(key, value)\n @root.add(key.to_s.upcase.split(\"\"), value)\n return self\n end",
"def prefix=(_); end",
"def store *paths, value\n branch = _find_delegate_hash *paths\n _insert_ordered_node branch, paths.last, value\n value\n end",
"def find_prefix(prefix)\n if @trie.children(prefix).length > 0\n return true\n else\n return false\n end\nend",
"def from_hash(hash)\n @prefixes = Prefixes.create(hash[:prefixes])\n end",
"def put(key, value)\n @root = put_rec(@root, key, value, 0)\n end",
"def add(key, value)\n if key.empty?\n @value = value\n else\n letter = key.shift\n if !@children[letter]\n @children[letter] = Node.new()\n end\n @children[letter].add(key, value)\n end\n end",
"def prefix(value)\n merge(aguprefix: value.to_s)\n end",
"def userprefix(value)\n merge(ucuserprefix: value.to_s)\n end",
"def prefix\n @data['prefix']\n end",
"def put(key, value)\n @root = put_node(@root, key, value, 0)\n end",
"def set_prefix\n @prefix = @str[@i_last_real_word...@i]\n end",
"def insert(word)\n children = @root.children\n\n i = 0\n word.split('').each do |c|\n t = nil\n if children[c]\n t = children[c]\n else\n t = TrieNode.new(c)\n children[c] = t\n end\n\n children = t.children\n\n if i == word.size - 1\n t.is_leaf = true\n end\n\n i += 1\n end\n end",
"def put(key, value)\n @root = put_node(@root, key, value)\n end",
"def get_prefixed_words(prefix)\n # FILL ME IN\n # return [@trie.is_word(prefix)]\n prefix_copy = prefix\n answer = []\n current_node = My_trie.root\n # p \"val is: \"\n # p My_trie.root.val\n # return ['alphabet']\n\n while prefix.length > 0\n # p \"node is: \", current_node.keys\n node = current_node.keys[prefix[0]]\n prefix = prefix[1..-1]\n if node\n current_node = node\n else\n return \"Sorry, we can't find any words with that prefix\"\n end\n end\n #we now have the final letter of the prefix as the current node, I hope.\n # p \"CURRENT NODE.VAL: \", current_node.val\n answer = dfs(current_node, prefix_copy[0...-1])\n return answer\n end",
"def store(key, value)\n mon_synchronize do\n node = (@hash[key] ||= Node.new(key))\n node.value = value\n touch(node)\n compact!\n node.value\n end\n end",
"def setnx(key, value); end",
"def setnx(key, value); end",
"def [](prefix)\n @prefixed[prefix] ||= PrefixedWithFallback.new(prefix, self)\n end",
"def put(namespace, key, entry); end",
"def put_rec(node, key, value, d)\n node = Node.new if node.nil?\n if(d == key.length) \n node.value = value\n return node\n end\n c_index = key[d].ord\n node.next[c_index] = put_rec(node.next[c_index], key, value, d+1)\n return node\n end",
"def insert(word)\n current_node = @root\n word.chars.each do |char|\n node = current_node.children[char]\n if !node\n node = TrieNode.new();\n current_node.children[char] = node\n end\n current_node = node\n end\n current_node.end_of_word = true\n end",
"def setnx(key, value)\n node_for(key).setnx(key, value)\n end",
"def add_to_index(name, key, node); end",
"def prefix(new_prefix = nil)\n return @prefix if new_prefix.nil?\n @prefix = new_prefix\n end",
"def []=(node, value)\n return @hash[node.sha1] = value\n end",
"def collect_prefixes hash, prefix\n prefix_matcher = Regexp.new(\"^#{prefix}\")\n hash\n .select { |name| prefix_matcher =~ name }\n .reduce({}) do |memo, name|\n memo[name[0].gsub(prefix_matcher, '')] = name[1]\n memo\n end\nend",
"def add_node(key, val)\n @store.append(key, val)\n end",
"def insert(key, value)\n i = key.hash % @table.size\n node = @table[i]\n while node\n if key == node.key\n node.value = value\n return\n end\n node = node.next\n end\n @table[i] = Node.new(key, value, @table[i])\n @count += 1\n end",
"def add(key, value)\n current_and_parent_pair = find_current_and_parent_nodes(key)\n if current_and_parent_pair[:current]\n # update new value if key exists\n current_and_parent_pair[:current].value = value\n else\n new_node = TreeNode.new(key,value)\n parent = current_and_parent_pair[:parent]\n link_node_to_parent(parent, new_node)\n end\n end",
"def insert(value)\n records << value\n record_id = records.count - 1\n\n trigrams = hash(value)\n trigrams.each do |tri|\n index[tri] ||= []\n index[tri] << record_id\n end\n end",
"def register(actor, prefix = nil)\n @registry.register(actor, prefix)\n end",
"def set_prefix_key(key)\n check_return_code(\n if key\n key += options[:prefix_delimiter]\n raise ArgumentError, \"Max prefix key + prefix delimiter size is #{Lib::MEMCACHED_PREFIX_KEY_MAX_SIZE - 1}\" unless\n key.size < Lib::MEMCACHED_PREFIX_KEY_MAX_SIZE\n Lib.memcached_callback_set(@struct, Lib::MEMCACHED_CALLBACK_PREFIX_KEY, key)\n else\n Lib.memcached_callback_set(@struct, Lib::MEMCACHED_CALLBACK_PREFIX_KEY, \"\")\n end\n )\n end",
"def register_node(address)\n nodes << address.gsub(/\\/.*/, \"\")\n end",
"def add_user(user)\n user = user.strip.downcase\n key = key_for('autocomplete')\n (1..(user.length)).each{ |l|\n prefix = user[0...l]\n @redis.zadd(key,0,prefix)\n }\n @redis.zadd(key,0,user+'*')\n end",
"def prefix\n @obj['prefix']\n end",
"def find_prefix(prefix)\n node = find_word prefix.downcase\n if node.nil?\n [false, false, 0]\n else\n count = node.word_count\n count -= 1 if node.is_word\n [true, node.is_word, count]\n end\n end",
"def insert(word)\n node=@root\n i=0\n while i <word.length \n char=word[i]\n order=char.ord-97\n if node[order].nil?\n node[order]=Hash.new(nil)\n node[order][\"value\"]=false\n end\n node=node[order]\n i+=1\n end\n node[\"value\"]=true\n end",
"def save_triple_p(triple)\n redis.sadd(key_p(triple), value_p(triple))\n end",
"def test_nodesetprefix01\n doc = nil\n docFragment = nil\n element = nil\n elementTagName = nil\n elementNodeName = nil\n appendedChild = nil\n doc = load_document(\"staff\", true)\n docFragment = doc.createDocumentFragment()\n element = doc.createElementNS(\"http://www.w3.org/DOM/Test\", \"emp:address\")\n appendedChild = docFragment.appendChild(element)\n element.prefix = \"dmstc\"\n elementTagName = element.tagName()\n elementNodeName = element.nodeName()\n assert_equal(\"dmstc:address\", elementTagName, \"nodesetprefix01_tagname\")\n assert_equal(\"dmstc:address\", elementNodeName, \"nodesetprefix01_nodeName\")\n \n end",
"def store(keys, val)\n keys = Array(keys).map(&:to_sym)\n\n keys.each do |key|\n @aliases[key] = keys.first\n end\n\n @data[keys.first] = val\n end",
"def resource_prefix=(value)\n @prefix_parameters = nil\n\n resource_prefix_call = value.gsub(/:\\w+/) { |key| \"\\#{URI::DEFAULT_PARSER.escape options[#{key}].to_s}\" }\n\n silence_warnings do\n # Redefine the new methods.\n instance_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1\n def prefix_source() \"#{value}\" end\n def resource_prefix(options={}) \"#{resource_prefix_call}\" end\n RUBY_EVAL\n end\n rescue => e\n logger&.error(\"Couldn't set prefix: #{e}\\n #{code}\")\n raise\n end",
"def search(dataset, prefix)\n tree = dataset.root\n prefix.each_char do |ch|\n node = tree.find_child(ch)\n\n if node\n tree = node\n else\n return nil\n end\n end\n\n get_leaves(tree)\nend",
"def set(full_key, node)\n key_part, rest = full_key.split('.', 2)\n child = key_to_node[key_part]\n if rest\n unless child\n child = Node.new(key: key_part)\n append! child\n end\n child.children ||= []\n child.children.set rest, node\n dirty!\n else\n remove! child if child\n append! node\n end\n node\n end",
"def store(key = nil, value = nil)\n return @store if key.nil?\n raise \"Cannot store key '#{key}' since it is not a stored need of #{self.class}.\" unless stores?(key)\n\n @store[key] = value\n\n ivar = \"@#{key}\"\n instance_variable_set(ivar, value)\n @root.instance_variable_set(ivar, value) if !root? && @root.stores?(key)\n\n update\n end",
"def store_value(timestamp, key, value)\n # Prepend the timestamp so we always have unique values\n @redis.zadd(key, timestamp, \"#{timestamp}:#{value}\")\n end",
"def add(word)\n \t\tif word.length > 0 # there was a zero length char after this, idk\n if @children[word[0,1]] # if current letter exists in hash, add to it\n\t @children[word[0,1]].add(word[1, word.length])\n\t\t\t\t@children[word[0,1]].word = true if (word.length == 1)\n\t else # if the letter doesn't exist, create it\n\t @children[word[0,1]] = LetterTree.new(word[1, word.length])\n\t\t\t\t@children[word[0,1]].word = true if (word.length == 1)\n\t end\n\t\tend\n\tend",
"def store(key, value, label=nil)\n super(key, value)\n \n if label\n @label_map[label] = key\n @key_map[key] = label\n end\n end",
"def []=(key, value)\n root_node._hash = nil # reset pre-calculated roothash\n node = root_node\n ba_key = Bitarray.new(key)\n\n # finds or creates the node\n 1.upto(KEY_SIZE) do |depth|\n bit = ba_key[depth - 1]\n node =\n if bit == 0\n # 0, descend left\n node.left ||= (node.left = Node.new(key, depth))\n else\n # 1, descend right\n node.right ||= (node.right = Node.new(key, depth))\n end\n end\n node.value = value\n end",
"def path_prefix=(value)\n if value\n value.chomp! \"/\"\n value.replace \"/#{value}\" if value !~ /^\\//\n end\n @path_prefix = value\n end",
"def set_value(node, path, value)\n path = path.to_s.split('.') unless path.is_a?(Array)\n\n path[0..-2].each_index { |i|\n key = path[i]\n if node.is_a?(Hash)\n key = key.to_sym\n unless node.has_key?(key)\n node[key] = attempt_key_to_int(path[i + 1]).nil? ? {} : []\n end\n node = node[key]\n elsif node.is_a?(Array)\n key = key_to_int(key)\n if key < node.length && -node.length < key\n node = node[key]\n else\n entry = attempt_key_to_int(path[i + 1]).nil? ? {} : []\n if key < -node.length\n node.unshift(entry)\n else\n node[key] = entry\n end\n node = entry\n end\n else\n raise WAB::TypeError, \"Can not set a member of an #{node.class}.\"\n end\n }\n\n key = path[-1]\n\n if node.is_a?(Hash)\n node[key.to_sym] = value\n elsif node.is_a?(Array)\n key = key_to_int(key)\n if key < -node.length\n node.unshift(value)\n else\n node[key] = value\n end\n else\n raise WAB::TypeError, \"Can not set a member of an #{node.class}.\"\n end\n value\n end",
"def sfa_add_namespace(prefix, urn)\n @@sfa_namespaces[prefix] = urn\n end",
"def hsetnx(key, field, value)\n node_for(key).hsetnx(key, field, value)\n end",
"def insert(word)\n node = @root\n word.each_char do |c|\n node[c] ||= {}\n node = node[c]\n end\n node[END_OF_WORD] = END_OF_WORD\n end",
"def add(key, value)\n new_nodelet = TreeNode.new(key, value)\n\n if @root.nil?\n @root = new_nodelet \n else \n @root = add_helper(@root, new_nodelet)\n end \n end",
"def prefix(name, iri = nil)\n name = name.to_s.empty? ? nil : (name.respond_to?(:to_sym) ? name.to_sym : name.to_s.to_sym)\n iri.nil? ? prefixes[name] : prefixes[name] = iri\n end",
"def startsortkeyprefix(value)\n merge(cmstartsortkeyprefix: value.to_s)\n end",
"def prefix(*ps)\n set :prefixes, ps.map { |p| ::File.join(\"/\", p) }\n end",
"def set(item, node)\n\t\t\t@hash[item] = node\n\t\tend",
"def add(key, value)\n @root = add_helper(@root, key, value)\n end",
"def load_prefixes\n if !self.data[\"rdf_prefix_path\"].nil?\n begin\n prefix_file=File.new(File.join(@base, 'rdf-data', self.data[\"rdf_prefix_path\"].strip)).readlines\n self.data[\"rdf_prefixes\"] = prefix_file.join(\" \")\n self.data[\"rdf_prefix_map\"] = Hash[ *(prefix_file.collect { |v|\n arr = v.split(\":\",2)\n [arr[0][7..-1].strip, arr[1].strip[1..-2]]\n }.flatten)]\n rescue Errno::ENOENT => ex\n Jekyll.logger.error(\"context: #{@resource} template: #{@template} file not found: #{File.join(@base, 'rdf-data', self.data[\"rdf_prefix_path\"])}\")\n end\n end\n end",
"def set(oid,value)\n roid=self.oid2roid(oid)\n validate_roid(roid)\n roid_first=roid.first\n if roid.size>1\n @nodes[roid_first]=self.class.new(self.oid + [roid_first]) if not @nodes[roid_first]\n node=@nodes[roid_first]\n return node.set(oid,value)\n end\n return @nodes[roid_first]=value\n end",
"def search_prefixes(data)\n _search_prefixes(data, SEARCHABLE)\n end",
"def populate_suffix_trie_from(string)\n (0..string.length - 1).each do |i|\n insert_substring_starting_at(i, string)\n end\n end",
"def prefix(name, uri = nil)\n name = name.to_s.empty? ? nil : (name.respond_to?(:to_sym) ? name.to_sym : name.to_s.to_sym)\n uri.nil? ? prefixes[name] : prefixes[name] = (uri.respond_to?(:to_sym) ? uri.to_sym : uri.to_s.to_sym)\n end",
"def find(prefix)\n prefix.downcase!\n @base.each_key do |name|\n if name.start_with? prefix\n puts base[name].to_s()\n end\n end\n end",
"def []=(key, value)\n\n @buckets[index(key, size)].add_to_tail(Node.new(key, value))\n @num_items += 1\n\n resize if load_factor > @max_load_factor\n end",
"def save_triple_sp(triple)\n redis.sadd(key_sp(triple), value_sp(triple))\n end",
"def insert_into_bucket(value, bucket)\n @table[bucket] = value\n @count += 1\n maybe_rehash\n end",
"def add_namespace(ns, prefix = \"unknown#{rand 65536}\")\n return nil if ns.nil? || ns.empty?\n unless namespaces.key? ns\n namespaces[ns] = prefix\n return prefix\n end\n end",
"def populate_suffix_trie_from(string)\n for i in 0..(string.length - 1)\n self.insert_substring_starting_at(i, string)\n end\n end",
"def add(key, value)\n @root = add_helper(@root, key, value)\n end",
"def add(key, value)\n @root = add_helper(@root, key, value)\n end"
] | [
"0.6257317",
"0.6109661",
"0.60767347",
"0.60545164",
"0.6041448",
"0.5992668",
"0.5987903",
"0.5943061",
"0.58996505",
"0.5882091",
"0.58446103",
"0.581478",
"0.5721165",
"0.5716789",
"0.5713481",
"0.5680035",
"0.56740385",
"0.56301206",
"0.5627325",
"0.55971026",
"0.55749345",
"0.55740887",
"0.556647",
"0.55582607",
"0.553484",
"0.55338824",
"0.5531129",
"0.55153435",
"0.55144507",
"0.5504057",
"0.5502494",
"0.54936105",
"0.54657876",
"0.5463753",
"0.54493463",
"0.5402635",
"0.5400143",
"0.53669226",
"0.53383744",
"0.532803",
"0.53232867",
"0.52960783",
"0.52880204",
"0.52867186",
"0.52867186",
"0.5276631",
"0.5271852",
"0.5269958",
"0.52560484",
"0.5255571",
"0.5237263",
"0.5234116",
"0.52336276",
"0.5192986",
"0.518178",
"0.5144223",
"0.5127239",
"0.51211685",
"0.51109475",
"0.51006776",
"0.50990885",
"0.5082066",
"0.5080269",
"0.50649786",
"0.50487024",
"0.5046002",
"0.5036806",
"0.503666",
"0.50325704",
"0.50325537",
"0.5010139",
"0.5008653",
"0.50033724",
"0.50003034",
"0.49977985",
"0.49902648",
"0.49867153",
"0.49731612",
"0.49708378",
"0.4970688",
"0.49624133",
"0.4950321",
"0.49425384",
"0.4938497",
"0.4935992",
"0.49288684",
"0.49254695",
"0.49225563",
"0.49218455",
"0.49161914",
"0.4915738",
"0.4915459",
"0.49115032",
"0.49016005",
"0.48971933",
"0.489554",
"0.48947242",
"0.4891835",
"0.48902223",
"0.48902223"
] | 0.7424172 | 0 |
Perform a prefix search. Will return the value associated with the longest prefix | def [](prefix)
current = @root
current_prefix = prefix
while !current.nil? && current_prefix != ""
previous = current
current, current_prefix = next_node(current, current_prefix)
end
return current[:value] if current
return previous[:value]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def longest_prefix(str, pos= 0, len= -1, match_prefix= false)\n end",
"def find_prefix(prefix)\n node = find_word prefix.downcase\n if node.nil?\n [false, false, 0]\n else\n count = node.word_count\n count -= 1 if node.is_word\n [true, node.is_word, count]\n end\n end",
"def search_prefixes(str, pos= 0, len= -1)\n end",
"def longest_prefix(strings)\n length = strings.min_by { |string| string.length }.length\n strings = strings.sort!\n substring = \"\"\n \n i = 0\n while i <= length\n if strings[0][0..i] == strings[-1][0..i]\n substring = strings[0][0..i]\n end\n i += 1\n end\n \n return substring\nend",
"def prefixsearch(prefix, limit: 'max', &processor)\n list(@api.query.generator(:prefixsearch).search(prefix), limit, &processor)\n end",
"def find_prefix(word)\n prefix = ''\n i = 0\n while starts_with(prefix)\n prefix += word[i]\n i += 1\n end\n prefix.slice(0, prefix.length - 1)\n end",
"def longest_prefix(strings)\n same = true\n index = 0\n\n while same \n array_characters = strings.map do |string|\n string[index]\n end\n\n current = 0\n until array_characters.length - 1 < current\n if array_characters[current] == array_characters[0]\n current += 1\n else\n same = false\n end\n end\n index += 1\n end \n\n if same == true\n return strings.first[0..index]\n else\n return strings.first[0...index] \n end\nend",
"def longest_prefix(strings)\n return \"\" if strings.empty?\n prefix = \"\"\n smallest_word = strings.min_by { |word| word.length } # start with smallest word\n for i in 0..smallest_word.length-1\n if strings.all? { |word| word[i] == smallest_word[i] } # if the index matches the same index of the other words\n prefix += smallest_word[i] # then append the index value to the prefix\n else\n break # otherwise index is not in all words, so stop\n end\n end\n return prefix\nend",
"def longest_prefix(strings)\n # raise NotImplementedError, \"Not implemented yet\"\n\n if strings.first.length == 0\n return strings\n end\n\n prefix = \"\"\n i = 0\n\n min = strings.min_by{|s| s.length}\n while i < min.length \n strings.each do |string|\n if min[i] != string[i] \n return prefix\n end\n end\n prefix += min[i]\n i +=1\n end \n return prefix\n end",
"def longest_prefix(strings)\n # raise NotImplementedError, \"Not implemented yet\"\n longest_prefix = \"\"\n idx = 0\n letter = strings[0][idx]\n\n until letter == nil\n strings.each do |string|\n if string[idx] != letter\n return longest_prefix\n end\n end\n longest_prefix += letter\n idx += 1\n letter = strings[0][idx]\n end\n return longest_prefix\nend",
"def get_prefixed_words(prefix)\n # FILL ME IN\n # return [@trie.is_word(prefix)]\n prefix_copy = prefix\n answer = []\n current_node = My_trie.root\n # p \"val is: \"\n # p My_trie.root.val\n # return ['alphabet']\n\n while prefix.length > 0\n # p \"node is: \", current_node.keys\n node = current_node.keys[prefix[0]]\n prefix = prefix[1..-1]\n if node\n current_node = node\n else\n return \"Sorry, we can't find any words with that prefix\"\n end\n end\n #we now have the final letter of the prefix as the current node, I hope.\n # p \"CURRENT NODE.VAL: \", current_node.val\n answer = dfs(current_node, prefix_copy[0...-1])\n return answer\n end",
"def longest_prefix(strings)\n # raise NotImplementedError, \"Not implemented yet\"\n common_prefix = \"\"\n if strings.empty?\n return common_prefix\n end\n\n strings[0].each_char.with_index do |char, index|\n (1...strings.size).each do |arr_position|\n if char != strings[arr_position][index]\n return common_prefix\n end\n end\n common_prefix << char\n end\n\n return common_prefix\nend",
"def find_prefix(prefix)\n if @trie.children(prefix).length > 0\n return true\n else\n return false\n end\nend",
"def longest_common_prefix_horizontal_scan(strs)\n return '' if strs.empty?\n\n prefix = strs[0]\n strs.each do |word|\n until word.start_with?(prefix)\n prefix = prefix[0, prefix.length - 1]\n\n break if prefix == ''\n end\n end\n\n prefix\nend",
"def longest_prefix(strings)\n return \"\" if strings.empty? \n index = 0\n min = strings.min_by{|s| s.length} # find the shortest string\n longest_prefix = \"\"\n while index < min.length # keep running based on the length of the sortest the string \n strings.each do |string|\n if min[index] != string[index] # if the it's not equal, return the \"\"\n return longest_prefix\n end\n end\n longest_prefix += min[index]\n index +=1\n end \n return longest_prefix\nend",
"def longest_prefix(strings)\n word_array = strings[0].split(\"\")\n length = strings.length\n\n prefix = \"\"\n\n word_array.each_with_index do |letter,letter_index|\n count_words_with_letter = 0\n\n (length - 1).times do |i|\n if (strings[i+1].split(\"\"))[letter_index] == letter \n count_words_with_letter += 1\n else\n return prefix\n end\n end\n\n if count_words_with_letter = length-1\n prefix += letter\n end\n end\n\n return prefix\nend",
"def longest_prefix(strings)\n min = strings.min \n max = strings.max\n string_pre = min.size.times do |i| \n break i if min[i] != max[i]\n end\n min[0...string_pre]\nend",
"def longest_prefix(strings)\n initial_match = ''\n length = strings[0].length\n length.times do |letter|\n if strings[0][letter] == strings[1][letter]\n initial_match.concat(strings[0][letter])\n end\n end\n \n strings.each do |word|\n match = ''\n initial_match.length.times do |letter|\n if initial_match[letter] == word[letter]\n match.concat(word[letter])\n end\n end\n initial_match = match\n end\n \n return initial_match\nend",
"def longest_prefix(strings)\n strings.each do |string|\n if string.length == 0\n return \"\"\n end \n end \n prefix = strings[0]\n (1...strings.length).each do |n|\n (0...prefix.length).each do |i|\n if strings[n][i] != prefix[i]\n if i == 0\n prefix = \"\"\n break\n else \n prefix = prefix[0...i]\n break\n end \n end \n end \n end \n return prefix\nend",
"def longest_prefix(strings)\n if strings.length < 2\n raise ArgumentError\n else\n prefix = \"\"\n l = 0\n (strings.min.length).times do\n s = 0\n track = 0\n (strings.length - 1).times do\n if strings[s][l] == strings [(s+1)][l]\n track += 1\n else\n break\n end\n s += 1\n end\n if track == (strings.length - 1)\n prefix << strings.min[l]\n else\n break\n end\n l += 1\n end\n return prefix\n end\nend",
"def longest_prefix(strings)\n # Return an empty string \"\" if no common prefix\n\n # shortest string in array\n prefix = strings.min_by(&:length)\n\n for string in strings\n for j in 0...prefix.length\n if prefix[j] != string[j]\n # update prefix from start, up until j (not including)\n prefix = prefix.slice(0, j)\n break\n end\n end\n end\n\n return prefix\nend",
"def longest_prefix(strings)\n index = 0 \n prefix = \"\"\n all_true = false \n st = strings.min_by(&:length) \n st.split(\"\").each do |char| \n strings.each do |string| #string.split.each do char???\n if string.split(\"\")[index] == char\n all_true = true \n else\n all_true = false\n end\n end\n\n if all_true == false \n return prefix\n end \n if all_true == true\n prefix += char\n end\n index += 1\n end \n return prefix\nend",
"def longest_prefix(strings)\n words = strings.length\n min_characters = (strings.min_by{|string|string.length}).length\n prefix = \"\"\n\n min_characters.times do |j|\n letter = strings[0][j]\n\n words.times do |i|\n return prefix if strings[i][j] != letter\n end\n\n prefix += letter\n end\n\n return prefix\nend",
"def longest_prefix(name)\n @symbols.longest_prefix(to_name(name))\n end",
"def longest_prefix(strings)\n prefix = \"\"\n\n i = 0\n char = strings[0][i]\n\n while char != nil\n strings.each do |string|\n if string[i] != char\n return prefix\n end\n end\n\n prefix += char\n i += 1\n char = strings[0][i]\n end\n \n return prefix\nend",
"def longest_prefix(strings)\n return \"\" if strings.empty? == true\n \n longest_prefix = strings[0].chars\n strings.each do |string|\n holder = string.chars\n longest_prefix = holder & longest_prefix\n end\n\n return longest_prefix.join\n \n\nend",
"def longest_prefix(strings)\n if strings.length == 1\n return strings\n end\n\n prefix = \"\"\n str_index = 0\n\n\n until (strings[0][str_index] != strings[1][str_index]) || (strings[0][str_index] == nil && strings[1][str_index] == nil)\n prefix += strings[0][str_index]\n str_index += 1\n end\n\n strings.each do |string|\n return \"\" if prefix[0] != string[0]\n\n prefix.length.times do |i|\n if prefix[i] != string[i]\n prefix = prefix[0...i]\n break\n end\n end\n end\n return prefix\nend",
"def find_by_prefix(start_key, reverse)\n dir = dir_for_reverse(reverse)\n x = anchor(reverse)\n # if no prefix given, just return a first node\n !start_key and return node_next(x, 0, dir)\n \n level = node_level(x)\n while level > 0\n level -= 1\n xnext = node_next(x, level, dir)\n if reverse\n # Note: correct key CAN be greater than start_key in this case \n # (like \"bb\" > \"b\", but \"b\" is a valid prefix for \"bb\")\n while node_compare2(xnext, start_key) > 0\n x = xnext\n xnext = node_next(x, level, dir)\n end\n else\n while node_compare(xnext, start_key) < 0\n x = xnext\n xnext = node_next(x, level, dir)\n end\n end\n end\n xnext == anchor(!reverse) and return nil\n node_key(xnext)[0, start_key.size] != start_key and return nil\n xnext\n end",
"def get_matching_strings(prefix)\n puts \"Matching for #{prefix}\"\n ptr = @root\n for i in 0..prefix.size-1\n ptr = ptr.children[prefix[i]]\n return nil unless ptr\n end\n arr = []\n arr << prefix if ptr.is_leaf\n arr << get_strings(ptr, prefix)\n arr\n end",
"def longest_prefix(strings)\n\n # Assign relevant variables\n winning_ticket = \"\"\n i = 0 \n fastest_furthest = strings[0][i]\n\n # Account for non-nil values and return method result \n while fastest_furthest != nil\n strings.each do |string|\n unless string[i] == fastest_furthest\n return winning_ticket\n end \n end \n winning_ticket += fastest_furthest\n i += 1\n fastest_furthest = strings[0][i]\n end\n return winning_ticket\nend",
"def longest_prefix(strings)\n common_string = \"\"\n if strings.length == 0\n return common_string\n end\n \n shortest_element = strings.min\n shortest_element_length = shortest_element.length\n i = 0\n while i < shortest_element_length\n char = shortest_element[i]\n strings.each do |string|\n if char != string[i]\n return common_string\n end\n end\n common_string += char\n i += 1\n end\n \n return common_string\nend",
"def search(dataset, prefix)\n tree = dataset.root\n prefix.each_char do |ch|\n node = tree.find_child(ch)\n\n if node\n tree = node\n else\n return nil\n end\n end\n\n get_leaves(tree)\nend",
"def longest_prefix(strings)\n template = strings[0]\n i = 0\n \n until template[i].nil? do\n comparison_result = true\n strings[1..].each do |word|\n \n if word[i] != template[i]\n comparison_result = false\n break\n end \n\n end\n\n if comparison_result\n i += 1\n else \n break\n end\n end\n return template[0, i]\nend",
"def longest_prefix(strings)\n strings_in_common = \"\"\n #checking if array is emptyh\n if strings.length == 0\n return strings_in_common\n end\n\n shortest_string = strings.min(){|a, b| a.length <=> b.length}.chars\n\n i = 0\n while i < shortest_string.length\n letter = shortest_string[i]\n strings.each do |string|\n if letter != string.chars[i]\n return strings_in_common\n end\n end\n strings_in_common += letter\n i += 1\n end\n return strings_in_common\nend",
"def find_words_starting_with(prefix)\n # keeps track of unvisited nodes\n stack = []\n words = []\n # keeps track of the current string\n prefix_stack = []\n\n stack << find_word(prefix)\n prefix_stack << prefix.chars.take(prefix.size - 1)\n\n return [] unless stack.first\n\n until stack.empty?\n node = stack.pop\n\n prefix_stack.pop and next if node == :guard_node\n\n prefix_stack << node.value\n stack << :guard_node\n\n words << prefix_stack.join if node.word\n\n node.next.each { |n| stack << n }\n end\n\n words\n end",
"def find(prefix)\n prefix.downcase!\n @base.each_key do |name|\n if name.start_with? prefix\n puts base[name].to_s()\n end\n end\n end",
"def longest_prefix(strings)\n prefix = ->s1, s2 { s1.each_char.zip(s2.each_char)\n .take_while { |c1, c2| c1 == c2 }\n .map(&:first).join }\n \n strings.reduce(&prefix)\nend",
"def starts_with(prefix)\n curr = @root\n prefix.each_char.all? do |char|\n curr = curr[char]\n end \n end",
"def common_prefix(words)\n longest = ''\n\n shortest_word = words.min\n (0...shortest_word.length).each do |stop_index|\n sequence = shortest_word[0..stop_index]\n\n match = words.all? do |word|\n word[0..stop_index] == sequence\n end\n\n longest = sequence if match\n end\n\n longest\nend",
"def longest_prefix(strings)\n strings_in_common = \"\"\n #checking if array is emptyh\n if strings.length == 0\n return strings_in_common\n end\n shortest_string = strings.min(){|a, b| a.length <=> b.length}.chars\n i = 0\n while i < shortest_string.length\n letter = shortest_string[i]\n strings.each do |string|\n if letter != string.chars[i]\n return strings_in_common\n end\n end\n strings_in_common += letter\n i += 1\n end\n return strings_in_common\nend",
"def longest_prefix(array)\n first_string = array.shift\n prefix = ''\n index = 0\n \n while true\n if array.all? { |string| string[index] == first_string[index]}\n prefix << first_string[index]\n else\n break\n end\n index += 1\n end\n prefix\nend",
"def find(prefix)\n\t\tfound_entries = entries.select do |key, value|\n\t\t\tkey[0...prefix.length] == prefix\n\t\tend\n\tend",
"def prefix_match(prefix)\n val = []\n database.each do |k, v|\n if k.downcase.start_with?(prefix)\n val.push(v)\n end\n end\n if val.size == 0\n val = ['Key Not Found!']\n end\n val\n end",
"def longest_common_prefix(strings, prefix = '')\n return strings.first if strings.size <= 1\n\n first = strings[0][0,1] or return prefix\n tails = strings[1..-1].inject([strings[0][1..-1]]) do |tails, string|\n if string[0,1] != first\n return prefix\n else\n tails << string[1..-1]\n end\n end\n\n longest_common_prefix(tails, prefix + first)\n end",
"def longest_prefix(strings)\n temp = strings[0].chars\n \n strings.each_with_index do |value, i|\n value.length.times do |i|\n if value[i] != temp[i]\n temp[i] = nil\n end\n end\n end\n \n nil_location = temp.index(nil) || temp.length\n return temp.take(nil_location).join\nend",
"def prefixes(max_length:)\n names = %w()\n (names.select { |name| name.length <= max_length }.map { |name| str(name) }.reduce(:|) || str('1')).as(:prefix)\n end",
"def get_prefixed_words(prefix)\n # FILL ME IN\n unless valid_word?(prefix)\n return \"Invalid input (string should only consist of letters).\"\n end\n output = findWords(prefix)\n if output.length() == 0\n return \"No prefixed words found!\"\n end\n output\n end",
"def longest_prefix(strings)\n loops = (strings.length) - 1\n comparison_word = strings[0]\n \n loops.times do |i|\n prefix = \"\"\n counter = 0\n \n strings[i + 1].each_char do |letter|\n if letter == comparison_word[counter]\n prefix<<(letter)\n end\n counter += 1\n end\n comparison_word = prefix\n end\n \n return comparison_word\nend",
"def longest_prefix(strings)\n arr_length = strings.length\n word_length = strings[0].length\n \n result = \"\"\n \n word_length.times do |i|\n \n current_letter = strings[0][i]\n \n arr_length.times do |j|\n if strings[j][i] != current_letter\n return result\n end\n end\n \n result << current_letter # for future reference: push is O(1)\n end\n \n return result\nend",
"def longest_common_prefix(strs)\n prefix = \"\"\n return prefix if strs.empty?\n\n (0...strs[0].length).each do |i|\n (1...strs.length).each do |j|\n return prefix if !strs[j][i] || strs[j][i] != strs[0][i]\n end\n\n prefix += strs[0][i]\n end\n\n prefix\nend",
"def search(word)\n search_prefix(root, word, 0)\n end",
"def starts_with(prefix)\n search_arr(prefix.chars)\n end",
"def findWords(prefix)\n words = []\n prefix_node = search(prefix)\n unless prefix_node\n return words\n end\n\n autocomplete(prefix_node, prefix, words)\n words - [prefix]\n end",
"def exact_beginning_length(search_word, string)\n regexp = Regexp.new(\"(?:\\\\b\" + search_word.gsub(/(?!^)./){ |e| \"#{Regexp.escape(e)}?\"}, \"i\")\n return ((string.scan(regexp) || [\"\"]).max{ |a, b| a.length <=> b.length} || 0) / search_word.length\n end",
"def search_prefix(prefix)\n current_node = @root_node\n i = 0\n while i < prefix.length\n node = current_node.children[prefix[i]]\n if node.nil?\n return false\n end\n current_node = node\n i += 1\n end\n # we return true if we have successfully iterated through the prefix\n true\n end",
"def match(prefix)\n result = []\n current = @root\n current_prefix = prefix\n\n while current != nil && current_prefix != \"\"\n previous, previous_prefix = current, current_prefix\n current, current_prefix = next_node(current, current_prefix)\n end\n\n unless current\n if current_prefix\n return []\n else\n next_nodes = previous[:nodes].select { |prefix, node| prefix.start_with?(previous_prefix) }.values\n end\n else\n next_nodes = [current]\n end\n\n until next_nodes.empty?\n current = next_nodes.pop\n result << current[:value]\n current[:nodes].each { |prefix, node| next_nodes.push(node) }\n end\n\n return result.compact\n end",
"def search_prefixes(data)\n _search_prefixes(data, SEARCHABLE)\n end",
"def longest_common_prefix (array_of_strings)\n\n # Establish default value\n lcp = \"\"\n\n # Get the length of the shortest string\n min_length =\n if array_of_strings.size.zero?\n 0\n else\n array_of_strings.min_by(&:length).size\n end\n\n # Go through all of the strings, but not past the length of the shortest string\n min_length.times do |i|\n\n # If all of the strings have the same character at this index,\n # then it's part of the LCP\n chars_at_index = array_of_strings.map { |s| s[i] }\n\n if chars_at_index.uniq.count == 1\n lcp += chars_at_index[0]\n else\n break\n end\n\n end\n\n # Return\n return lcp\n\nend",
"def icl_find( args )\n prefix = args.downcase\n @foodDB.foodbase.each_key do | item |\n check = item.downcase\n if (check.index(prefix) == 0)\n icl_print( @foodDB.get(item) )\n end\n end\n end",
"def longest_prefix(array_of_strings)\n prefix = \"\"\n\n #error checking if array is empty, return strings in common init to empty\n if array_of_strings.length == 0\n return prefix\n end\n # puts \"array of strings here #{array_of_strings}\"\n\n #find longest string\n longest_length = 0\n longest_string = \"\"\n array_of_strings.each do |string|\n if string.length > longest_length\n longest_length = string.length\n longest_string = string\n end\n end\n\n # puts \"longest string #{longest_string}\" #doggo\n #turn longest string into array\n longest_string_array = longest_string.chars\n # puts longest_string_array\n\n #start loop\n i = 0\n while i < longest_string_array.length #[d,o,g,g,o]\n longest_letter = longest_string_array[i]\n j = 0 #start another loop to access words: [\"dogs\", \"doggo\", \"dot\"]\n while j < array_of_strings.length\n #turn array of strings into array of array of chars for each word\n word = array_of_strings[j].chars #[d,o,g,s]\n puts \"Starting #{word}\"\n\n #get i th letter in word, needs to be i not j \n word_letter = word[i] \n\n #compare longest string array at index 0 to words at index 0\n puts \"Comparing #{i} #{longest_letter} : #{word_letter}\"\n if longest_letter != word_letter #d == d \n return prefix\n end\n j += 1\n end\n #finished with j loop without breaking, save prefix BEFORE moving onto next letter comparisons\n prefix = prefix + longest_string_array[i] # d\n puts \"prefix: #{prefix}\"\n\n i += 1\n end\n return prefix\nend",
"def knuthMorrisPrattStringSearch(text, pattern, prefixTable)\n return nil if pattern.nil? or text.nil?\n n = text.length\n m = pattern.length\n q = k = 0\n while (k + q < n)\n if pattern[q] == text[q+k]\n if q == (m - 1)\n return k\n end\n q += 1\n else\n k = k + q - prefixTable[q]\n if prefixTable[q] > -1\n q = prefixTable[q]\n else\n q = 0\n end\n end\n end\nend",
"def longest_prefix(strings)\n longest_prefix = \"\"\n num_letters = strings[0].length\n \n num_letters.times do |i|\n status = true\n check_letter = strings[0][i]\n strings.each do |string|\n if string[i] != check_letter\n status = false\n end\n end\n if status == true\n longest_prefix += check_letter\n end\n end\n \n return longest_prefix\nend",
"def build_prefix\n @prefix = @str[@i_last_real_word...@i]\n end",
"def prefix_limit\n limit = ideal_prefix_limit\n \n # extend the limit if the text after the substring is too short\n unless @options[:prefix] || full_text_after_substring_uses_ideal_suffix_limit?\n limit += ideal_suffix_limit - full_text_after_substring.unpack( \"U*\" ).size\n end\n \n limit\n end",
"def common_prefix(words)\n smallest_string= words.min_by{|word| word.size}\n\n result = \"\"\n\n smallest_string.chars.each_with_index do |current_char, current_index|\n if words.all?{|word| word[current_index] == current_char}\n result << current_char\n else\n return result\n end\n end\n result\nend",
"def shared_prefix(a, b)\n shared_prefix_length = [a.length, b.length].min\n while shared_prefix_length >= 0\n a_prefix = a[0..shared_prefix_length]\n b_prefix = b[0..shared_prefix_length]\n return a_prefix if a_prefix == b_prefix\n\n shared_prefix_length -= 1\n end\n\n return nil\n end",
"def longest_common_prefix(strings)\n split_strings = []\n output_string = \"\"\n strings.map do |string|\n split_strings << string.split('')\n end\n\n split_strings.each_with_index do |word, index|\n word.each_with_index do |letter, i|\n loop do\n if word[i] == split_strings[index + 1][i]\n output_string << letter\n require 'pry'; binding.pry\n elsif word[i] != split_strings[index + 1][i]\n break\n end\n end\n end\n end\n # output_string\n # require 'pry'; binding.pry\nend",
"def longest_common_prefix(arr)\n result = \"\"\n return result if arr.length == 0 || arr[0].length == 0\n\n i = 0\n fin = false\n\n until fin\n letter = arr[0][i]\n arr.each { |str| fin = true if i >= str.length || str[i] != letter }\n result += letter unless fin\n i += 1\n end\n\n result\nend",
"def districts_by_prefix(districts, prefix)\n name_eng = case prefix\n when :hk\n \"Hong Kong Island\"\n when :kln\n \"Kowloon\"\n when :nt\n \"New Territories\"\n when :is\n \"Islands\"\n else\n nil\n end\n \n districts.select{|district| district.name_eng == name_eng}.first if name_eng\nend",
"def find_scene(prefix)\n\t\t\treturn @scenes[prefix] if @scenes.include? prefix\n\n\t\t\tprefix = prefix.downcase\n\t\t\[email protected]{|id, scene|\n\t\t\t\tscene.name.downcase.start_with?(prefix)\n\t\t\t}.values.max_by{|s|\n\t\t\t\ts.name\n\t\t\t}\n\t\tend",
"def solution(a)\n shortest = a.min_by &:length\n maxlen = shortest.length\n maxlen.downto(0) do |len|\n 0.upto(maxlen - len) do |start|\n substr = shortest[start,len]\n return substr if a.all?{|str| str.include? substr }\n end\n end\nend",
"def linear_search(fishies)\n longest = 0\n big_fish = nil\n fishies.each do |fish|\n if fish.length > longest\n longest = fish.length\n big_fish = fish\n end\n end\n big_fish\nend",
"def kmpPrefixTable(pattern)\n return nil if pattern.nil?\n prefixTable = [-1,0]\n m = pattern.length\n q = 2\n k = 0\n while q < m\n if pattern[q-1] == pattern[k]\n k += 1\n prefixTable[q] = k\n q += 1\n elsif k > 0\n k = prefixTable[k]\n else\n prefixTable[q] = 0\n q += 1\n end\n end\n return prefixTable\nend",
"def get_prefixed_words(prefix)\n return Lexicon.scan(prefix)\n end",
"def starts_with(prefix)\n extract.grep(/^#{prefix}/)\n end",
"def starts_with(prefix)\n node=@root\n i=0\n while i <prefix.length \n char=prefix[i]\n order=char.ord-97\n return false if node[order].nil?\n node=node[order]\n i+=1\n end\n true\n end",
"def full_text_before_substring_uses_ideal_prefix_limit?\n full_text_before_substring.unpack( \"U*\" ).size >= ideal_prefix_limit\n end",
"def prefix\n match(/Prefix\\s+:\\s+([^\\s])/)\n end",
"def longest_common_prefix(s1, s2, max = nil)\n l1, l2 = s1.size, s2.size\n min = l1 < l2 ? l1 : l2\n min = min < max ? min : max if max\n min.times do |i|\n return s1.slice(0, i) if s1[i] != s2[i]\n end\n return s1.slice(0, min)\n end",
"def find_elem(line, index = 1)\n delim = line.chomp.split(' ')\n prefix = delim[index]\nend",
"def command_find(prefix)\n items = @database.find_matches(prefix)\n items.each { |i|\n puts i.to_s\n }\n end",
"def startsortkeyprefix(value)\n merge(cmstartsortkeyprefix: value.to_s)\n end",
"def next_part_with_prefix(prefix, suffix)\n num = @parts.select { |n, _| n.start_with?(prefix) && n.end_with?(suffix) }\n .map { |n, _| n[prefix.length..-1][0..-(suffix.size + 1)].to_i }\n .max\n num = (num || 0) + 1\n \"#{prefix}#{num}#{suffix}\"\n end",
"def prefix_key\n if @struct.prefix_key.size > 0\n @struct.prefix_key[0..-1 - options[:prefix_delimiter].size]\n else\n \"\"\n end\n end",
"def prefix(value)\n merge(leprefix: value.to_s)\n end",
"def find_short(string)\n string.split.map(&:length).sort.first\nend",
"def match_prefix(prefix)\n consume(self.class.cached_matcher([:prefix, prefix]){/#{prefix}([^\\\\\\/]+)/})\n end",
"def longest_repeated_substring(string)\n\n size = string.length\n\n # put every possible suffix into an array\n suffixes = Array.new(size)\n size.times do |i|\n suffixes[i] = string.slice(i, size)\n end\n\n # sort the array of suffixes, so common substrings (i.e., prefixes\n # of suffixes) will be found in neighboring elements of the array\n suffixes.sort!\n\n best = \"\"\n at_least_size = 1 # the size to meet or exceed to be the new best\n distance = nil\n neighbors_to_check = 1\n\n # compare pairs of consecutive suffixes and see how much initial\n # commonality there is\n # (size - 1).times do |i|\n (1...size).each do |i|\n # p [i, neighbors_to_check]\n s1 = suffixes[i]\n\n # generally we will only need to compare the ith item and the one\n # preceding it; however if we were in a position to reject a long\n # enough common substring due to overlap issues, then we may have\n # to compare an ith item with additional preceding items;\n # neighbors_to_check tracks how many neighbors we need to check\n neighbors_to_check.downto(1) do |neighbor|\n s2 = suffixes[i - neighbor]\n\n # make sure that these to suffixes further apart than the size\n # of the current best; we don't explicitly track the index of\n # these suffixes, but since all suffixes go to the end of the\n # initial string, the size can be used as a proxy\n distance = (s1.size - s2.size).abs\n if distance < at_least_size\n if s1.size >= at_least_size &&\n s2.size >= at_least_size &&\n s1.slice(0, at_least_size) == s2.slice(0, at_least_size)\n neighbors_to_check = max(neighbors_to_check, neighbor + 1)\n else\n neighbors_to_check = neighbor\n end\n next\n end\n\n # if neighboring suffixes don't at least match as far as the best,\n # no need to check more carefully\n unless s1.slice(0, at_least_size) == s2.slice(0, at_least_size)\n neighbors_to_check = neighbor\n next\n end\n\n # get the longest common prefix that's no larger than distance,\n # since at that point the substrings overlap\n best = longest_common_prefix(s1, s2, distance)\n at_least_size = best.size + 1\n if best.size == distance\n neighbors_to_check = max(neighbors_to_check, neighbor + 1)\n else\n neighbors_to_check = neighbor\n end\n end\n end\n\n best.strip\n end",
"def getPrefix(parent)\n prefix = \"\"\n subst_Pfix = Constants::SUBST_PFIX.invert\n substituents = processParentString(parent)\n return unless substituents.size > 0\n substNames = {}\n substituents.each do | atom, substs |\n substs.each do | subst |\n substNames[atom] = [] unless substNames[atom] != nil\n substNames[atom].push(subst.getSubstName)\n end\n end\n occurrences = {}\n substNames.each do | atom, nameArr |\n nameArr.each do | substName |\n occurrences[substName] = [] unless occurrences[substName] != nil \n occurrences[substName].concat(parent.each_index.select { |p_idx| parent[p_idx] == atom})\n end\n end\n alphabetize = occurrences.keys.sort\n alphabetize.each_index do | idx |\n if idx > 0 then prefix += \"-\" end\n substName = alphabetize[idx]\n occurrences[substName].sort!\n occurrences[substName].each_index do |occr|\n if occr > 0 then prefix += \",\" end\n prefix += (occurrences[substName][occr] + 1).to_s\n end\n prefix += \"-\"\n if occurrences[substName].length > 1 then\n if occurrences[substName].length > subst_Pfix.size + 1 then\n prefix += occurrences[substName].length # If prefix isn't implemented, just add number\n else\n prefix += subst_Pfix[occurrences[substName].length]\n end\n end\n prefix += substName\n end\n prefix\n end",
"def get_sub_word(node, prefix)\n return [] if !starts_with(prefix)\n keys = node.children.keys\n result = []\n keys.each do |char|\n if node.children[char].end_of_word\n result << prefix + char\n end\n result.concat(get_sub_word(node.children[char], prefix + char))\n end\n result\n end",
"def search(trie, word, maxCost)\n current_row = (0..word.length).to_a\n results = []\n\n trie.children.each_key do |key|\n search_trie(trie.children[key], key, word, current_row, results, maxCost)\n end\n\n return results\nend",
"def find_common_prefix_length(a, b)\n length = 0\n while (a[length] == b[length])\n length += 1\n end\n\n length\n end",
"def search(word)\n last = word.each_char.inject(@root) do |curr, char|\n curr.is_a?(TrieNode) ? curr[char] : nil\n end \n last && last[:_] || false \n end",
"def search(bases, prefixes, suffixes, remaining_bases) \n# p \"searching: bases #{bases.inspect}, prefixes #{prefixes.inspect}, suffixes #{suffixes.inspect}, remaining #{remaining_bases.inspect}\"\n# sleep 0.1\n\n if remaining_bases.empty? && (suffixes.last == prefixes.first)\n p \"solution: #{bases.inspect}, #{prefixes.inspect}, #{suffixes.inspect}\"\n return prefixes.zip(suffixes).inject(0) {|memo, obj| memo + 100*obj.first + obj.last }\n # {|a,b| 100*a+b}.inject {|a,b| a+b}\n end\n\n remaining_bases.each do |base|\n bases.push(base)\n\n new_remaining_bases = remaining_bases - [base]\n h = choice_hash_for_base(base)\n\n h.each_pair do |prefix, suffix|\n # 1.) if suffixes not empty, check this prefix with last suffix\n if !suffixes.empty? && (suffixes.last != prefix)\n next\n end\n\n prefixes.push(prefix)\n suffixes.push(suffix)\n\n found = search(bases, prefixes, suffixes, new_remaining_bases)\n return found if found\n\n prefixes.pop\n suffixes.pop\n end\n\n bases.pop\n end\n\n return nil\nend",
"def substrings (n, m, prefix, max)\n if n . length == 0 then\n return prefix > -1 &&\n prefix < max &&\n prefix % m == 0 ? 1 : 0\n end\n\n fc = n[0] . to_i\n tail = n[1 .. -1]\n if prefix == -1 then\n n_prefix = fc\n else\n n_prefix = 10 * prefix + fc\n end\n\n return substrings(tail, m, n_prefix, max) +\n substrings(tail, m, prefix, max)\nend",
"def longest_repeated_substring(input)\n len = input.size / 2 # Max size is half total length, since strings cannot overlap\n\n while len > 0\n # Find all substrings of given length\n sub_strings = {}\n for i in 0...input.size-len\n sub_str = input[i..i+len]\n\n if not sub_strings.has_key?(sub_str)\n sub_strings[sub_str] = i+len # Add to list, track end pos for overlaps\n elsif sub_strings[sub_str] < i\n return sub_str # First non-overlapping match ties for longest\n end\n end\n\n len -= 1\n end\n\n nil\nend",
"def prefix_count(default = 1)\n if skip_prefix_count_once\n self.skip_prefix_count_once = false\n update_prefix_arg\n return default\n end\n\n count = prefix_arg || default\n update_prefix_arg\n count\n end",
"def prefix\n regexify(bothify(fetch('aircraft.prefix')))\n end",
"def prefix_count\n count = prefix_arg || 1\n update_prefix_arg(self)\n count\n end",
"def str_str(haystack, needle)\n return 0 if needle.empty?\n pattern_length = needle.length\n i = 0\n while i <= (haystack.length - pattern_length) do\n return i if needle == haystack.slice(i, pattern_length)\n i += 1\n end\n return -1\nend"
] | [
"0.7384357",
"0.71830565",
"0.6922366",
"0.68519425",
"0.6821444",
"0.67653644",
"0.67599136",
"0.6738252",
"0.6723146",
"0.67081183",
"0.66819835",
"0.6673414",
"0.6670009",
"0.6650048",
"0.6625341",
"0.66021806",
"0.6599446",
"0.6592044",
"0.65887475",
"0.65446365",
"0.6522153",
"0.64860547",
"0.6473032",
"0.64432657",
"0.6424333",
"0.6392864",
"0.6380542",
"0.63701445",
"0.6339739",
"0.6333893",
"0.6311683",
"0.62963635",
"0.62899345",
"0.62549394",
"0.6249004",
"0.6245812",
"0.6242573",
"0.6236043",
"0.6231569",
"0.62234765",
"0.6213156",
"0.6206371",
"0.6203665",
"0.6198355",
"0.6191034",
"0.61541545",
"0.6151062",
"0.6121189",
"0.6065776",
"0.60432845",
"0.60273445",
"0.60270435",
"0.60222554",
"0.5991476",
"0.59914577",
"0.59575105",
"0.59550554",
"0.5948342",
"0.59436744",
"0.5938216",
"0.5935406",
"0.592859",
"0.5925444",
"0.5912092",
"0.58674604",
"0.5863607",
"0.58582133",
"0.58073586",
"0.5781769",
"0.5773114",
"0.57236546",
"0.57145196",
"0.5710122",
"0.5696448",
"0.5655416",
"0.5652899",
"0.5641244",
"0.56351185",
"0.56265074",
"0.5620024",
"0.5588541",
"0.5572318",
"0.5566946",
"0.55587476",
"0.5545182",
"0.5538491",
"0.55323386",
"0.5517982",
"0.5508247",
"0.55079234",
"0.5506341",
"0.549767",
"0.548558",
"0.5482968",
"0.5478985",
"0.5478817",
"0.5442659",
"0.54354846",
"0.54263",
"0.5421144"
] | 0.572012 | 71 |
Set a value in the trie if it isn't null. Can be used to initialize collections as values | def set_if_nil(word, value)
current = @root
current_prefix = word
while current_prefix != ""
current, current_prefix = find_canididate_insertion_node(current, current_prefix)
end
current[:value] ||= value
return current[:value]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set!(value_obj)\n\t\t\tinsist!()\n\t\t\t@lookup[0...-1].inject(@obj_with_keys) { |deep_obj, this_key|\n\t\t\t\tdeep_obj[this_key]\n\t\t\t}[@lookup[-1]] = value_obj\n\t\tend",
"def set_value(node, path, value)\n path = path.to_s.split('.') unless path.is_a?(Array)\n\n path[0..-2].each_index { |i|\n key = path[i]\n if node.is_a?(Hash)\n key = key.to_sym\n unless node.has_key?(key)\n node[key] = attempt_key_to_int(path[i + 1]).nil? ? {} : []\n end\n node = node[key]\n elsif node.is_a?(Array)\n key = key_to_int(key)\n if key < node.length && -node.length < key\n node = node[key]\n else\n entry = attempt_key_to_int(path[i + 1]).nil? ? {} : []\n if key < -node.length\n node.unshift(entry)\n else\n node[key] = entry\n end\n node = entry\n end\n else\n raise WAB::TypeError, \"Can not set a member of an #{node.class}.\"\n end\n }\n\n key = path[-1]\n\n if node.is_a?(Hash)\n node[key.to_sym] = value\n elsif node.is_a?(Array)\n key = key_to_int(key)\n if key < -node.length\n node.unshift(value)\n else\n node[key] = value\n end\n else\n raise WAB::TypeError, \"Can not set a member of an #{node.class}.\"\n end\n value\n end",
"def _set_value(value)\n if value.is_a? Array\n value.map do |v|\n v.is_a?(Taverna::Baclava::Node) ? v : Node.new(v)\n end\n else\n value.to_s\n end\n end",
"def set(oid,value)\n roid=self.oid2roid(oid)\n validate_roid(roid)\n roid_first=roid.first\n if roid.size>1\n @nodes[roid_first]=self.class.new(self.oid + [roid_first]) if not @nodes[roid_first]\n node=@nodes[roid_first]\n return node.set(oid,value)\n end\n return @nodes[roid_first]=value\n end",
"def set(value)\n mutate build_map(value)\n end",
"def root=(value) @root = value end",
"def root=(value) @root = value end",
"def _init(val, klass)\n @node_count ||= 0\n @root = val ? klass.new(val) : nil\n @node_count += 1 unless val.nil?\n end",
"def node=(val)\r\n case val\r\n when Node, NilClass\r\n @node = val\r\n end\r\n end",
"def value=(val)\r\n @value = val\r\n @candidates = []\r\n @modified = true\r\n end",
"def set_value(input, root)\n\t\treturn root = Node.new(input) if root == nil\n\n\t\tcase input <=> root.value\n\t\twhen -1\n\t\t\treturn root.small_child = Node.new(input, root) if root.small_child == nil\n\t\t\tset_value(input, root.small_child)\n\t\twhen 1\n\t\t\treturn root.big_child = Node.new(input, root) if root.big_child == nil\n\t\t\tset_value(input, root.big_child)\n\t\twhen 0\n\t\t\troot.count += 1\n\t\tend\n\tend",
"def put(key, value = nil)\n @root = _put(@root, key, value)\n end",
"def value=(value)\n self.remove_children :value\n return unless value\n Array(value).each do |val|\n self << (v = XMPPNode.new(:value))\n v.namespace = self.namespace\n v.content = val\n end\n end",
"def set(item, value)\n @items[item] ||= {:value => nil}\n @items[item][:value] = value\n @normalized = false\n value\n end",
"def initialize(value=nil)\n @value = value\n @children = {}\n end",
"def set(key, value)\n arr_pos = to_hash(key)\n list = @array[array_pos]\n node = list.find_by_key(key)\n if node\n node.data = value\n else\n self.put(key, value)\n end\n end",
"def set(object, value); end",
"def value=(value)\n self.remove_children :value\n if value\n self << (v = XMPPNode.new(:value))\n v.namespace = self.namespace\n v << value\n end\n end",
"def set(path, value)\n return aset(nil, value) if path.nil?\n aset(path.split(':'), value)\n end",
"def set_node(val)\n self.node = val\n self\n end",
"def set_node(val)\n self.node = val\n self\n end",
"def value=(v)\n set(v)\n end",
"def []=(leaf_id, new_value)\n \n end",
"def set_root(value)\n\t\t@root = BSTNode.new(value)\n\tend",
"def []=(key, value)\n root_node._hash = nil # reset pre-calculated roothash\n node = root_node\n ba_key = Bitarray.new(key)\n\n # finds or creates the node\n 1.upto(KEY_SIZE) do |depth|\n bit = ba_key[depth - 1]\n node =\n if bit == 0\n # 0, descend left\n node.left ||= (node.left = Node.new(key, depth))\n else\n # 1, descend right\n node.right ||= (node.right = Node.new(key, depth))\n end\n end\n node.value = value\n end",
"def set k,v\n key = k.to_s.to_sym\n v = (v.is_a?(JrdObj) ? v.finish : v) unless v == nil\n @_[key] = v unless v == nil\n @_.delete key if v == nil\n end",
"def []=(index, value)\n node = find_node(index)\n node.value = value\n end",
"def setnx(value)\n if exists?\n false\n else\n set value\n true\n end\n end",
"def initialize(value_)\n @value = value_\n @children = []\n @visited = false\n end",
"def []=(index, value)\n if index < 0 || index > @length - 1\n return nil\n else\n node = @head\n count = 1\n until count > index\n node = node.next\n count += 1\n end\n end\n node.value = value\n end",
"def set_default(value)\r\n\t\tif value.kind_of? Array\r\n\t\t\tself.default_value = value.first\r\n\t\t\tif self.values.empty?\r\n\t\t\t\tvalues.create({ :value => value.first })\r\n\t\t\telse\r\n\t\t\t\t# omg - say this 10x fast... :|\r\n\t\t\t\tself.values.first.value = value.first\r\n\t\t\tend\r\n\t\telse\r\n\t\t\tself.default_value = value\r\n\t\t\tif self.values.empty?\r\n\t\t\t\tvalues.create({ :value => value })\r\n\t\t\telse\r\n\t\t\t\tself.values.first.value = value\r\n\t\t\tend\r\n\t\tend\r\n\tend",
"def set(v)\n @val = v\n end",
"def initialize(value)\n @value = value\n @left = nil\n @right = nil\n end",
"def []=(prefix, value)\n current = @root\n current_prefix = prefix\n\n while current_prefix != \"\"\n current, current_prefix = find_canididate_insertion_node(current, current_prefix)\n end\n\n current[:value] = value\n return value\n end",
"def value=(val); end",
"def initialize(value)\n @parent = nil\n @value = value # from initializer \n @children = []\n end",
"def initialize(value)\n @value = value\n @parent = nil\n @children = []\n end",
"def value=(_); end",
"def initialize(value = nil)\n @value = value\n @left = nil\n @right = nil\n end",
"def set(path, value)\n\n # Verify.\n path = Path.new(path) unless path.kind_of?(Path)\n meta = meta_walk(path)\n if meta and meta.kind_of?(Hash)\n raise Error.new(Error::WrongType, path) if meta[:dir]\n if (t = meta[:type])\n value = convert_to(value, t, path) unless value.kind_of?(t)\n end\n else\n value = value.to_s\n end\n\n # Perform the set.\n key = path.pop\n mmap, cmap = dir_walk(path, DW_Create)\n oldval = cmap[key]\n if (hook = mmap[:on_change])\n value = hook.call(HookSet, cmap, key, oldval, value) || value\n end\n if oldval.respond_to?(:replace): oldval.replace(value)\n else cmap[key] = value end\n [TypeItem, path, key, value]\n\n end",
"def set(key, val)\n return unless val\n db[key] = val\n end",
"def set(path, value)\n key, subkeys = split_path(path)\n if subkeys.any?\n self[key] ||= Droom::LazyHash.new({})\n self[key].set(subkeys, value)\n else\n self[key] = value\n end\n end",
"def []= field, value\n self.removeField(field)\n self.add(field, value) unless value.nil?\n end",
"def setnx(key, value); end",
"def setnx(key, value); end",
"def []= *paths, value\n branch = _find_delegate_hash *paths\n \n if value.kind_of? Hash or value.kind_of? OrderTree and not @no_expand_hash\n value = OrderTree.new(value, @root)\n value.default= self.root.default\n end\n _insert_ordered_node branch, paths.last, value\n value\n end",
"def first= value\n self[0] = value\n end",
"def single_object_db=(v); end",
"def set_collection value\n instance_variable_set(collection_name, value)\n end",
"def []=(key, value, convert = T.unsafe(nil)); end",
"def put(key, value)\n @root = put_rec(@root, key, value, 0)\n end",
"def []=(key, value)\n content = value.nil? ? [] : [value.to_s]\n list_map_db[key] = content\n end",
"def set(key, value)\n @semaphore.synchronize do\n node = Node.new(key, value)\n return false if value.value.length > @max_bytes\n\n if empty?\n @head_node = node\n @tail_node = node\n @hashed_storage[key] = node\n return node\n end\n while value.value.length + used_bytes > @max_bytes\n @hashed_storage.delete(@head_node.key)\n @head_node = @head_node.previous_node\n @head_node.next_node = nil if @head_node \n end\n node.next_node = @tail_node\n @tail_node.previous_node = node\n @tail_node = node\n @hashed_storage[key] = node\n end\n value\n end",
"def set_value(value)\n unless value.kind_of?(String) or value == nil\n raise \"Illegal value passed to set_value!\"\n end\n\n @value = nil\n @value_string = value\n if value and value != \"\"\n @value = SimpleExpression.new(value)\n end\n\n @vartype = nil\n @depends_on = nil\n @diffeq_deps = nil\n end",
"def set_head(value)\n @head = new_node(value)\nend",
"def set(full_key, node)\n key_part, rest = full_key.split('.', 2)\n child = key_to_node[key_part]\n if rest\n unless child\n child = Node.new(key: key_part)\n append! child\n end\n child.children ||= []\n child.children.set rest, node\n dirty!\n else\n remove! child if child\n append! node\n end\n node\n end",
"def set(index, val)\n \n end",
"def initialize(value)\n\t\t@value = value\n\t\t@parent = nil\n\t\t@child_left = nil\n\t\t@child_right = nil\n\tend",
"def initialize(value)\n @value = value\n @children = []\n end",
"def [](value)\n Placeholder.resolve(node_data[value.to_s])\n end",
"def []=(node, value)\n return @hash[node.sha1] = value\n end",
"def value=(value)\n @value = value.nil? ? nil : _set_value(value)\n end",
"def set_value(value)\n if value.is_a? Array\n @map = nil\n @array = ParsedArray.new @global\n @array.abstractArrayItems = []\n value.each do |item|\n array_item = ParsedArrayItem.new @global\n array_item.arrayValueItem = ParsedArrayValueItem.new @global\n array_item.arrayValueItem.primitive = ParsedPrimitive.new(@global)\n array_item.arrayValueItem.primitive.string = ParsedString.new(item)\n array_item.arrayValueItem.primitive.text = item\n @array.abstractArrayItems << array_item\n end\n @valueItem = nil\n @text = @array.extract_hash\n return\n elsif value.is_a?(ParsedPair)\n @map = value.map ? value.map : nil\n @array = value.array ? value.array : nil\n @valueItem = value.valueItem ? value.valueItem : nil\n return\n elsif value.is_a?(TrueClass) || value.is_a?(FalseClass)\n @map = nil\n @array = nil\n @valueItem = ParsedValueItem.new @global\n @valueItem.value = ParsedValue.new @global\n @valueItem.value.primitive = ParsedPrimitive.new(@global)\n if value\n @valueItem.value.primitive.trueVal = ParsedTrue.instance\n else\n @valueItem.value.primitive.falseVal = ParsedFalse.instance\n end\n @valueItem.value.primitive.text = value\n @valueItem.value.text = value\n @text = value\n return\n end\n value = value.extract_hash unless value.is_a?(String) || value.is_a?(Integer)\n @map = nil\n @array = nil\n @valueItem = ParsedValueItem.new @global\n @valueItem.value = ParsedString.new(value)\n @text = value\n end",
"def fill!(value_)\n raise TableLockedError if @parent\n @vals.fill(value_)\n self\n end",
"def put(key, value)\n @root = put_node(@root, key, value, 0)\n end",
"def []=(key, value)\n pair = Pair.new(key,value)\n @tree.add(pair)\n return value\n end",
"def set(v, invalid: false, nil_default: false, **)\n unless v.nil?\n @value = normalize(v)\n @value = nil unless valid?(@value)\n end\n @value ||= (v if invalid) || (default unless nil_default)\n end",
"def set(v, invalid: false, nil_default: false, **)\n unless v.nil?\n @value = normalize(v)\n @value = nil unless valid?(@value)\n Log.warn { \"#{type}: #{v.inspect}: not in #{values}\" } if @value.nil?\n end\n @value ||= (v if invalid) || (default unless nil_default)\n end",
"def set_value!(value)\n # Check and set teh value.\n unless value == nil || value.is_a?(Expression) then\n raise AnyError, \"Invalid class for a constant: #{value.class}\"\n end\n @value = value\n value.parent = self unless value == nil\n end",
"def value=(value)\n if value.is_a?(Array)\n if value.size == 1\n @value = value.first\n else\n fail ArgumentError, 'The argument must either be a string or an array with only one child'\n end\n else\n @value = value\n end\n end",
"def []=(index, value)\n node = get_node_at_index(index)\n node.value = value\n node.value\n end",
"def set(path, value, repair=false)\n raise WAB::Error, 'path can not be empty.' if path.empty?\n if value.is_a?(WAB::Data)\n value = value.native\n elsif repair\n value = fix_value(value)\n else\n validate_value(value)\n end\n node = @root\n Utils.set_value(node, path, value)\n end",
"def set_nil(value)\n value.nil? ? NullObject.instance : value\n end",
"def set(key, value); end",
"def set(key, value); end",
"def put(key, value)\n @root = put_node(@root, key, value)\n end",
"def initialize(value = nil) \n @value = value\n @parent = nil\n @left_child = nil\n @right_child = nil\n end",
"def set_item(value = nil, **opt)\n value ||= default\n cache_write(value, **opt) && value if value\n end",
"def []=(key_obj, value_obj)\n\t\t\t# Dial the key to be set - @lookup can never be empty\n\t\t\tdial!(key_obj)\n\t\t\t# Set the value\n\t\t\treturn set!(value_obj)\n\t\tend",
"def initialize(value)\n value==nil ? raise : #throw an exception if there were no value\n @value=value\n @node_to_go=nil\n rescue\n puts \"There is no such number\"\n end",
"def fill(value)\n map! { |_| value }\n self\n end",
"def initialize(value, hash_value = nil)\n store_in_self(value, hash_value) if value\n @left = EmptyNode.new\n @right = EmptyNode.new\n end",
"def node=(_); end",
"def node=(_); end",
"def root=(value)\n @root = value\n end",
"def initialize(value)\n\t\t\t@value = value.join.to_s if value.is_a?(Array)\n\t\t\t@node0,@node1,@node2,@node3 = nil\n\t\t\t@node4,@node5,@node6,@node7 = nil\n\t\t\t@nodes = []\n\t\tend",
"def set_value(owner, value)\n values = value.to_s.split(/ +/)\n \n @properties.each_index do |index|\n break if index > values.length-1\n subproperties = @properties[index]\n\n subproperties.each do |subproperty|\n owner.set_property_value(subproperty, values[index])\n end\n end\n end",
"def node=(val)\n attributes['node'] = val\n end",
"def node=(val)\n attributes['node'] = val\n end",
"def set_tail(value)\nlast_node(head).next_node = new_node(value)\n end",
"def []=(key, value); end",
"def []=(key, value); end",
"def []=(key, value); end",
"def []=(key, value); end",
"def []=(key, value); end",
"def []=(key, value); end",
"def []=(key, value); end",
"def []=(key, value); end",
"def []=(key, value); end",
"def []=(key, value); end"
] | [
"0.6495417",
"0.642123",
"0.6335264",
"0.62533474",
"0.59544724",
"0.59496105",
"0.59496105",
"0.5929919",
"0.58415437",
"0.5804963",
"0.57917076",
"0.57859576",
"0.57849115",
"0.5783281",
"0.57791805",
"0.57625985",
"0.57564473",
"0.57271314",
"0.57152843",
"0.5704708",
"0.5704708",
"0.57004833",
"0.5700363",
"0.5694211",
"0.56798786",
"0.56755483",
"0.567462",
"0.5658153",
"0.5648781",
"0.5631132",
"0.5629779",
"0.5620808",
"0.56198204",
"0.56056684",
"0.560428",
"0.55964637",
"0.55482453",
"0.5547848",
"0.5542999",
"0.55299735",
"0.54946965",
"0.54901636",
"0.5481507",
"0.5479159",
"0.5479159",
"0.547182",
"0.5450102",
"0.54464483",
"0.5445288",
"0.54336673",
"0.5429669",
"0.54286385",
"0.542676",
"0.54170483",
"0.54168725",
"0.53928095",
"0.53904325",
"0.5389558",
"0.5388827",
"0.5387394",
"0.5385638",
"0.53821546",
"0.53795594",
"0.5374057",
"0.5373713",
"0.5371642",
"0.53714466",
"0.5369899",
"0.5344239",
"0.53422695",
"0.53365165",
"0.5334087",
"0.5331375",
"0.5319866",
"0.5319866",
"0.53084993",
"0.52961373",
"0.5291445",
"0.5282619",
"0.52821827",
"0.52797824",
"0.5277755",
"0.52660394",
"0.52660394",
"0.52656054",
"0.5260256",
"0.52585894",
"0.52530015",
"0.52530015",
"0.52485317",
"0.52484006",
"0.52484006",
"0.52484006",
"0.52484006",
"0.52484006",
"0.52484006",
"0.52484006",
"0.52484006",
"0.52484006",
"0.52484006"
] | 0.72538346 | 0 |
Perform a prefix search, and return all values in the trie that have this prefix | def match(prefix)
result = []
current = @root
current_prefix = prefix
while current != nil && current_prefix != ""
previous, previous_prefix = current, current_prefix
current, current_prefix = next_node(current, current_prefix)
end
unless current
if current_prefix
return []
else
next_nodes = previous[:nodes].select { |prefix, node| prefix.start_with?(previous_prefix) }.values
end
else
next_nodes = [current]
end
until next_nodes.empty?
current = next_nodes.pop
result << current[:value]
current[:nodes].each { |prefix, node| next_nodes.push(node) }
end
return result.compact
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_matching_strings(prefix)\n puts \"Matching for #{prefix}\"\n ptr = @root\n for i in 0..prefix.size-1\n ptr = ptr.children[prefix[i]]\n return nil unless ptr\n end\n arr = []\n arr << prefix if ptr.is_leaf\n arr << get_strings(ptr, prefix)\n arr\n end",
"def find(prefix)\n\t\tfound_entries = entries.select do |key, value|\n\t\t\tkey[0...prefix.length] == prefix\n\t\tend\n\tend",
"def get_prefixed_words(prefix)\n # FILL ME IN\n # return [@trie.is_word(prefix)]\n prefix_copy = prefix\n answer = []\n current_node = My_trie.root\n # p \"val is: \"\n # p My_trie.root.val\n # return ['alphabet']\n\n while prefix.length > 0\n # p \"node is: \", current_node.keys\n node = current_node.keys[prefix[0]]\n prefix = prefix[1..-1]\n if node\n current_node = node\n else\n return \"Sorry, we can't find any words with that prefix\"\n end\n end\n #we now have the final letter of the prefix as the current node, I hope.\n # p \"CURRENT NODE.VAL: \", current_node.val\n answer = dfs(current_node, prefix_copy[0...-1])\n return answer\n end",
"def prefix_match(prefix)\n val = []\n database.each do |k, v|\n if k.downcase.start_with?(prefix)\n val.push(v)\n end\n end\n if val.size == 0\n val = ['Key Not Found!']\n end\n val\n end",
"def search_prefixes(data)\n _search_prefixes(data, SEARCHABLE)\n end",
"def find_prefix(prefix)\n if @trie.children(prefix).length > 0\n return true\n else\n return false\n end\nend",
"def search(dataset, prefix)\n tree = dataset.root\n prefix.each_char do |ch|\n node = tree.find_child(ch)\n\n if node\n tree = node\n else\n return nil\n end\n end\n\n get_leaves(tree)\nend",
"def findWords(prefix)\n words = []\n prefix_node = search(prefix)\n unless prefix_node\n return words\n end\n\n autocomplete(prefix_node, prefix, words)\n words - [prefix]\n end",
"def search_prefix(prefix)\n current_node = @root_node\n i = 0\n while i < prefix.length\n node = current_node.children[prefix[i]]\n if node.nil?\n return false\n end\n current_node = node\n i += 1\n end\n # we return true if we have successfully iterated through the prefix\n true\n end",
"def prefixsearch(prefix, limit: 'max', &processor)\n list(@api.query.generator(:prefixsearch).search(prefix), limit, &processor)\n end",
"def find_prefix(prefix)\n node = find_word prefix.downcase\n if node.nil?\n [false, false, 0]\n else\n count = node.word_count\n count -= 1 if node.is_word\n [true, node.is_word, count]\n end\n end",
"def starts_with(prefix)\n curr = @root\n prefix.each_char.all? do |char|\n curr = curr[char]\n end \n end",
"def starts_with(prefix)\n search_arr(prefix.chars)\n end",
"def find(prefix)\n prefix.downcase!\n @base.each_key do |name|\n if name.start_with? prefix\n puts base[name].to_s()\n end\n end\n end",
"def find_words_starting_with(prefix)\n # keeps track of unvisited nodes\n stack = []\n words = []\n # keeps track of the current string\n prefix_stack = []\n\n stack << find_word(prefix)\n prefix_stack << prefix.chars.take(prefix.size - 1)\n\n return [] unless stack.first\n\n until stack.empty?\n node = stack.pop\n\n prefix_stack.pop and next if node == :guard_node\n\n prefix_stack << node.value\n stack << :guard_node\n\n words << prefix_stack.join if node.word\n\n node.next.each { |n| stack << n }\n end\n\n words\n end",
"def starts_with(prefix)\n extract.grep(/^#{prefix}/)\n end",
"def starts_with(prefix)\n current = @root\n prefix.chars.each do |c|\n current = current.siblings.find { |node| node.val == c }\n return false unless current\n end\n\n true\n end",
"def collect_prefixes hash, prefix\n prefix_matcher = Regexp.new(\"^#{prefix}\")\n hash\n .select { |name| prefix_matcher =~ name }\n .reduce({}) do |memo, name|\n memo[name[0].gsub(prefix_matcher, '')] = name[1]\n memo\n end\nend",
"def search_prefixes(str, pos= 0, len= -1)\n end",
"def find(prefix)\n # Iterate over BasicFoods for prefix\n @basic_foods.keys.each do |name|\n if name.downcase.start_with? prefix.downcase # convert both to downcase as case insensitive\n print(name)\n end\n end\n # Iterate over Recipes for prefix\n @recipes.keys.each do |name|\n if name.downcase.start_with? prefix.downcase # convert both to downcase as case insensitive\n print(name)\n end\n end\n end",
"def starts_with(prefix)\n node=@root\n i=0\n while i <prefix.length \n char=prefix[i]\n order=char.ord-97\n return false if node[order].nil?\n node=node[order]\n i+=1\n end\n true\n end",
"def regular_and_lowercase_search_prefixes(data)\n search_prefixes(data) + lowercase_search_prefixes(data)\n end",
"def get_prefixes\n find_all{|entry| entry.type==Morpheme::PREFIX}\n end",
"def starts_with(prefix)\n node = @root\n prefix.each_char do |c|\n node = node[c]\n return false if node.nil?\n end\n true\n end",
"def lowercase_search_prefixes(data)\n _search_prefixes(data.downcase, LOWERCASE_SEARCHABLE)\n end",
"def search(word)\n search_prefix(root, word, 0)\n end",
"def starts_with(prefix)\n current_node = @root\n prefix.chars.each do |char|\n if !current_node.children[char]\n return false\n break\n else\n current_node = current_node.children[char]\n end\n end\n true\n end",
"def starts_with(prefix)\n if search_node(prefix) == nil\n return false\n else\n return true\n end\n end",
"def find_prefix(word)\n prefix = ''\n i = 0\n while starts_with(prefix)\n prefix += word[i]\n i += 1\n end\n prefix.slice(0, prefix.length - 1)\n end",
"def get_sub_word(node, prefix)\n return [] if !starts_with(prefix)\n keys = node.children.keys\n result = []\n keys.each do |char|\n if node.children[char].end_of_word\n result << prefix + char\n end\n result.concat(get_sub_word(node.children[char], prefix + char))\n end\n result\n end",
"def find_by_prefix(start_key, reverse)\n dir = dir_for_reverse(reverse)\n x = anchor(reverse)\n # if no prefix given, just return a first node\n !start_key and return node_next(x, 0, dir)\n \n level = node_level(x)\n while level > 0\n level -= 1\n xnext = node_next(x, level, dir)\n if reverse\n # Note: correct key CAN be greater than start_key in this case \n # (like \"bb\" > \"b\", but \"b\" is a valid prefix for \"bb\")\n while node_compare2(xnext, start_key) > 0\n x = xnext\n xnext = node_next(x, level, dir)\n end\n else\n while node_compare(xnext, start_key) < 0\n x = xnext\n xnext = node_next(x, level, dir)\n end\n end\n end\n xnext == anchor(!reverse) and return nil\n node_key(xnext)[0, start_key.size] != start_key and return nil\n xnext\n end",
"def starts_with(prefix)\n pnt = @r\n prefix.chars.each do |x|\n return false if !pnt[x]\n pnt = pnt[x]\n end\n return true\n end",
"def icl_find( args )\n prefix = args.downcase\n @foodDB.foodbase.each_key do | item |\n check = item.downcase\n if (check.index(prefix) == 0)\n icl_print( @foodDB.get(item) )\n end\n end\n end",
"def search(trie, word, maxCost)\n current_row = (0..word.length).to_a\n results = []\n\n trie.children.each_key do |key|\n search_trie(trie.children[key], key, word, current_row, results, maxCost)\n end\n\n return results\nend",
"def command_find(prefix)\n items = @database.find_matches(prefix)\n items.each { |i|\n puts i.to_s\n }\n end",
"def search(prefix)\n log \"retrieving container listing from #{container_path} items starting with #{prefix}\"\n list(prefix: prefix)\n end",
"def [](prefix)\n current = @root\n current_prefix = prefix\n\n while !current.nil? && current_prefix != \"\"\n previous = current\n current, current_prefix = next_node(current, current_prefix)\n end\n\n return current[:value] if current\n return previous[:value]\n end",
"def find_by_prefix(prefix)\n @machines.each do |uuid, data|\n return data.merge(\"id\" => uuid) if uuid.start_with?(prefix)\n end\n\n nil\n end",
"def districts_by_prefix(districts, prefix)\n name_eng = case prefix\n when :hk\n \"Hong Kong Island\"\n when :kln\n \"Kowloon\"\n when :nt\n \"New Territories\"\n when :is\n \"Islands\"\n else\n nil\n end\n \n districts.select{|district| district.name_eng == name_eng}.first if name_eng\nend",
"def search(word)\n last = word.each_char.inject(@root) do |curr, char|\n curr.is_a?(TrieNode) ? curr[char] : nil\n end \n last && last[:_] || false \n end",
"def get_prefixed_words(prefix)\n # FILL ME IN\n unless valid_word?(prefix)\n return \"Invalid input (string should only consist of letters).\"\n end\n output = findWords(prefix)\n if output.length() == 0\n return \"No prefixed words found!\"\n end\n output\n end",
"def keys\n store.keys.select { |k| k.match(/^#{prefix}/) and self[k] }\n end",
"def keys\n store.keys.select{ |k| k.match(/^#{prefix}/) and self[k] }\n end",
"def get_prefixed_words(prefix)\n return Lexicon.scan(prefix)\n end",
"def _search_prefixes(data, search_type)\n @key_map.map do |key_id, (key, _)|\n Base64.urlsafe_encode64(_search_prefix(data, search_type, key_id, key))\n end\n end",
"def items(prefix = '')\n queue = []\n collect(\n _get(@root, prefix, 0),\n prefix,\n queue\n )\n queue\n end",
"def tags_with_prefix(prefix)\n prefix = prefix.strip\n\n bind_variables = { tag_prefix: \"\\\"#{prefix}%\" }\n\n parameritized_query = <<~SQL\n SELECT json_agg(tag) AS matching_tags\n FROM\n (SELECT distinct jsonb_array_elements(tags) AS tag FROM #{table_name} ORDER BY tag) tags\n WHERE tag::text like :tag_prefix\n SQL\n\n query = ActiveRecord::Base.sanitize_sql([parameritized_query, bind_variables])\n results = ActiveRecord::Base.connection.exec_query(query).to_a.first.try(:[], 'matching_tags')\n\n JSON.parse(results || '[]')\n end",
"def prefix_search\n @tags = Tag.where(\"name LIKE :prefix\", prefix: \"#{params.permit(:s)[:s]}%\")\n render json: @tags.collect{|tag| tag.strip}\n end",
"def starts_with(prefix)\n !!find(prefix)\n end",
"def completion(prefix)\n return COMMANDS.grep(/^#{Regexp.escape(prefix)}/)\n end",
"def match_prefix(prefix)\n consume(self.class.cached_matcher([:prefix, prefix]){/#{prefix}([^\\\\\\/]+)/})\n end",
"def unweighted_suggestions(node, prefix, suggestions)\n return [] if node == nil\n suggestions << prefix if node.flag\n if node.has_children?\n node.children.keys.each do |letter|\n word = prefix \n word += letter\n suggest_node = node.children[letter]\n unweighted_suggestions(suggest_node, word, suggestions)\n end\n end\n return suggestions\n end",
"def ls(prefix)\n list_objects(prefix).contents.map(&:key)\n end",
"def search(start_key, end_key, limit, offset, reverse, with_keys)\n offset ||= 0\n \n start_node = find_by_prefix(start_key, reverse)\n !start_node and return []\n \n start_node = skip_nodes(start_node, offset, reverse)\n !start_node and return []\n \n collect_values(start_node, end_key, limit, reverse, with_keys)\n end",
"def starts_with(prefix)\r\n n = start_with_helper(prefix)\r\n return !n.nil?\r\n end",
"def findPrefix( foodDB )\n puts \"Enter the prefix of the food entry.\"\n prefix = STDIN.gets.chomp!.strip\n puts \"\\n\" + foodDB.findAll( prefix )\nend",
"def search keyword\n result = Set.new\n matched = Array.new\n @frame_tree_root_node.each{|node|\n if node.content =~ /#{keyword}/i\n matched << node.name\n end\n } \n @frame_tree_root_node.each{|node|\n if node.is_root?\n result << node.name\n elsif matched.include? node.name\n result << node.name #add id\n node.parentage.each{|item|\n result << item.name\n }\n end\n }\n @frame_tree_root_node.print_tree\n result\n end",
"def find_by_starts_with(name)\n return nil unless name.present?\n names.select {|e| e.starts_with?(name)}\n end",
"def search_trie(node, letter, word, previous_row, results, maxCost)\n columns = word.length\n current_row = [previous_row[0] + 1]\n\n # Build matrix row\n 1.upto(columns).each do |col|\n insertCost = current_row[col - 1] + 1\n deleteCost = previous_row[col] + 1\n subCost = previous_row[col - 1]\n\n subCost += 1 unless word[col - 1] == letter\n current_row << [insertCost, deleteCost, subCost].min\n end\n\n # If the last value in the row is less than or equal to the maxCost\n # and there is a word in the node, add it to the result.\n if current_row.last <= maxCost && !node.word.nil?\n results << node.word\n end\n\n # If there is a value in the row that is less than or equal to the\n # maxCost, recursively search the branches of the node.\n if current_row.min <= maxCost\n node.children.each_key do |key|\n search_trie(node.children[key], key, word, current_row, results, maxCost)\n end\n end\nend",
"def prefixes\n @prefixes ||= Hash[namespaces.sort_by { |k, v| k }.uniq { |k, v| v }].invert\n end",
"def words_with_prefix(prefix, words)\n raise NotImplementedError # TODO\nend",
"def searchForValueStartingAt(xml, toStartAt, nodeName, index)\n count = 0\n size = xml.children.size #((Integer)rolle.get(\"childCount\")).intValue();\n for j in 0..size do\n value = xml.children[j]\n if value.name == toStartAt\n return searchForValueAtPos(values,nodeName,index)\n else\n countVals = value.children.size\n for k in 0..countVals do\n #String value = searchForValueStartingAt((Hashtable)values.get(new Integer(k)),nodeName,toStartAt,index);\n valSt = searchForValueStartingAt(value.children[k], toStartAt, nodeName, index)\n if valSt == \"\"\n return valSt\n end\n end\n end\n end\n return \"\"\n end",
"def search(needle)\n tmp = @root\n needle.split(\"\").each do |char|\n if (tmp.childrens.key?(char))\n tmp = tmp.childrens[char]\n if (tmp.childrens.empty? && tmp.final == true)\n return true\n else\n return false\n end\n else\n return false\n end\n end\n end",
"def starts_with?(prefix)\n prefix = prefix.to_s\n self[0, prefix.length] == prefix\n end",
"def search(word)\n node=@root\n i=0\n while i <word.length \n char=word[i]\n order=char.ord-97\n return false if node[order].nil?\n node=node[order]\n i+=1\n end\n return node[\"value\"] \n end",
"def match(wallet, prefix, details)\n found = []\n @pgsql.exec('SELECT * FROM callback WHERE wallet = $1 AND prefix = $2', [wallet, prefix]).each do |r|\n next unless Regexp.new(r['regexp']).match?(details)\n id = @pgsql.exec(\n 'INSERT INTO match (callback) VALUES ($1) ON CONFLICT (callback) DO NOTHING RETURNING id',\n [r['id'].to_i]\n )\n next if id.empty?\n mid = id[0]['id'].to_i\n found << mid\n @log.info(\"Callback ##{r['id']} just matched in #{wallet}/#{prefix} with \\\"#{details}\\\", match ##{mid}\")\n end\n found\n end",
"def prefix\n @data['prefix']\n end",
"def knuthMorrisPrattStringSearch(text, pattern, prefixTable)\n return nil if pattern.nil? or text.nil?\n n = text.length\n m = pattern.length\n q = k = 0\n while (k + q < n)\n if pattern[q] == text[q+k]\n if q == (m - 1)\n return k\n end\n q += 1\n else\n k = k + q - prefixTable[q]\n if prefixTable[q] > -1\n q = prefixTable[q]\n else\n q = 0\n end\n end\n end\nend",
"def all_prefixes(browser)\n assert_valid_browser browser\n data = browser_data(browser)\n prefixes = [\"-#{data[\"prefix\"]}\"]\n if data[\"prefix_exceptions\"]\n prefixes += data[\"prefix_exceptions\"].values.uniq.map{|p| \"-#{p}\"}\n end\n prefixes\n end",
"def search(value)\n return @searchMethods.searchAtTree(value, @root)\n end",
"def get_keys(hsh, prefix = \"\")\n keys = []\n\n hsh.each do |k, v|\n if v.is_a? Hash\n subprefix = k\n subprefix = prefix + \"-\" + subprefix unless prefix.empty?\n keys += get_keys(v, subprefix)\n else\n key = prefix + \"-\" + k unless prefix.empty?\n keys << key\n end\n end\n\n keys\nend",
"def prefix?(prefix)\n @prefix_history.any? { |p| p[:local].to_s.start_with?(prefix.to_s) }\n end",
"def get_completions(prefix)\n return []\n end",
"def add_pattern(prefix, pattern, &block)\n @trie[prefix] ||= {}\n @trie[prefix][pattern] = block\n end",
"def evaluate_prefix(file_path)\n lines = File.readlines(file_path)\n lines.map(&:strip!)\n\n results = []\n\n lines.each do |line|\n results << calculate_prefix(line)\n end\n\n results.join(\"\\n\")\nend",
"def createPrefixTable(pattern)\n if (!pattern) then\n return\n end\n\n prefix = Array.new((pattern.length),0)\n j = 0\n prefix[0] = 0\n\n for i in 1...(pattern.length)\n if pattern[i] == pattern[j]\n prefix[i] = j\n j = j+1\n else\n while true\n j = prefix[j]\n if j == 0 then\n break\n end\n if pattern[i] == pattern[j]\n prefix[i] = prefix[j]\n break\n end\n end\n end\n end\n return prefix\nend",
"def keys\n out = [ ]\n @source.keys.each do |key|\n if key.starts_with?(@prefix)\n out << key[@prefix.length..-1]\n else\n out << key\n end\n end\n out\n end",
"def search(word)\n node = @root\n word.each_char { |c|\n unless node.children.key?(c)\n return nil\n end\n node = node.children[c]\n }\n return node\n end",
"def search_for(term)\n results = Friendship.find_by_sql(query(term))\n\n results.map do |result|\n members = Member.where(id: result.path).order(\"array_position(array[#{result.path.join(',')}]::bigint[], members.id)\")\n members.map(&:full_name).join('->')\n end\n end",
"def match_string( tree, string )\n # puts \"Checking for `#{string}` in tree (#{tree}).\"\n\n if tree.empty?\n # puts \"Tree is empty, returning empty\"\n return [ ]\n\n elsif string.empty?\n # puts \"No search string, returning empty\"\n return [ ]\n\n else\n matches = [ ]\n\n tree.each do |key,val|\n # puts \"Checking for `#{string}` in `#{key}` branch.\"\n\n simdex = string.simdex(key)\n\n if 0 < simdex\n if string == key\n # puts \"Matched full word! #{string} is #{key}\"\n # matches = collect_keys(val, key).unshift(key)\n return collect_keys(val, key).unshift(key)\n # puts \"Got matches: #{matches}\"\n\n else\n leaf = string.leaf(simdex)\n # puts \"Got leaf #{leaf}\"\n\n check = match_string(val, leaf)\n # puts \"Got check: #{check}\"\n\n if !check.empty?\n # matches = (check.map { |m| key + m })\n return check.map { |m| key + m }\n # puts \"New matches: #{matches}\"\n end\n end\n\n # break\n\n else\n check = match_string(val, string)\n\n if !check.empty?\n matches += check\n end\n end\n end\n\n # if matches.empty?\n # # puts \"No matches (#{string})\"\n # else\n # # puts \"Returning matches (#{string}): #{matches}\"\n # end\n\n return matches\n end\n end",
"def kmpPrefixTable(pattern)\n return nil if pattern.nil?\n prefixTable = [-1,0]\n m = pattern.length\n q = 2\n k = 0\n while q < m\n if pattern[q-1] == pattern[k]\n k += 1\n prefixTable[q] = k\n q += 1\n elsif k > 0\n k = prefixTable[k]\n else\n prefixTable[q] = 0\n q += 1\n end\n end\n return prefixTable\nend",
"def prefix\n match(/Prefix\\s+:\\s+([^\\s])/)\n end",
"def ls_dir(prefix)\n list_objects(prefix).common_prefixes.map(&:prefix)\n end",
"def search(search_string)\n queue=search_string.split '/'\n current_term=queue.shift\n return [self] if current_term.nil? #If for some reason nothing is given in the search string\n matches=[]\n if current_term=='*'\n\t\t\t\tnew_matches=self.children.values\n\t\t\t\tnew_matches.sort! {|a, b| a.node_name <=> b.node_name} rescue nil #is this evil?\n matches.concat new_matches\n elsif current_term[/\\d+/]==current_term\n matches << @children[current_term.to_i]\n else\n matches << @children[current_term.to_sym]\n end\n if queue.empty?\n return matches.flatten.compact\n else\n return matches.collect {|match| match.search(queue.join('/'))}.flatten.compact\n end\n end",
"def is_prefix?(word)\n Constants::PREFIXES.key?(word.downcase)\n end",
"def find_all(name, prefix = T.unsafe(nil), partial = T.unsafe(nil), details = T.unsafe(nil), key = T.unsafe(nil), locals = T.unsafe(nil)); end",
"def list(prefix)\n response = client.list_objects(\n :bucket => bucket,\n :prefix => prefix)\n\n contents = response.contents[1..-1] ## Drop the first item. This is the prefix folder\n return [] if contents.nil?\n\n contents.map { |o| ::File.basename(o.key) }\n end",
"def autocomplete(curr_node, curr_path, word_list)\n if curr_node.is_word\n word_list << curr_path\n end\n\n # recursively visit each child in the node's children => all prefixed words\n curr_node.children.each_value { |child| \n autocomplete(child, curr_path + child.val, word_list)\n }\n end",
"def traverse\n @result.clear\n @queue.clear\n\n @queue.enqueue(@node)\n @result.push @node\n\n\n while not @queue.empty?\n node = @queue.dequeue\n return @result unless node\n # puts \"Visiting node: #{node}\"\n return node if (@search and node==@search)\n node && node.children.each do |node|\n unless @result.include?(node)\n @result.push(node)\n @queue.enqueue(node)\n end\n end\n end\n return result\n end",
"def namespaces_by_prefix\n form_data = { 'action' => 'query', 'meta' => 'siteinfo', 'siprop' => 'namespaces' }\n res = make_api_request(form_data)\n REXML::XPath.match(res, \"//ns\").inject(Hash.new) do |namespaces, namespace|\n prefix = namespace.attributes[\"canonical\"] || \"\"\n namespaces[prefix] = namespace.attributes[\"id\"].to_i\n namespaces\n end\n end",
"def search(term)\n all.select do |unit|\n unit.aliases.any? { |str| Regexp.new(term).match(str) }\n end\n end",
"def local_prefixes\n []\n end",
"def search(bases, prefixes, suffixes, remaining_bases) \n# p \"searching: bases #{bases.inspect}, prefixes #{prefixes.inspect}, suffixes #{suffixes.inspect}, remaining #{remaining_bases.inspect}\"\n# sleep 0.1\n\n if remaining_bases.empty? && (suffixes.last == prefixes.first)\n p \"solution: #{bases.inspect}, #{prefixes.inspect}, #{suffixes.inspect}\"\n return prefixes.zip(suffixes).inject(0) {|memo, obj| memo + 100*obj.first + obj.last }\n # {|a,b| 100*a+b}.inject {|a,b| a+b}\n end\n\n remaining_bases.each do |base|\n bases.push(base)\n\n new_remaining_bases = remaining_bases - [base]\n h = choice_hash_for_base(base)\n\n h.each_pair do |prefix, suffix|\n # 1.) if suffixes not empty, check this prefix with last suffix\n if !suffixes.empty? && (suffixes.last != prefix)\n next\n end\n\n prefixes.push(prefix)\n suffixes.push(suffix)\n\n found = search(bases, prefixes, suffixes, new_remaining_bases)\n return found if found\n\n prefixes.pop\n suffixes.pop\n end\n\n bases.pop\n end\n\n return nil\nend",
"def perform\n @timeout_start = Time.now\n puts \"Searching for #{@target}\"\n prime = SearchEntry.new(nil, @target, whole_trie, nil)\n debug \"priming: #{prime}\"\n debug ''\n ticked = 0\n frontier.push prime, prime.score\n\n @results = Set.new\n\n begin\n search_entry = frontier.pop\n @visited.push search_entry, search_entry.score\n\n status = \"#{@visited.size}/#{@frontier.size} - #{search_entry}\"\n debug status\n\n seconds_since_start = (Time.now - @timeout_start).to_i\n if seconds_since_start > ticked\n puts status\n ticked += 1\n end\n\n\n # If we've reached the end of a word, continue with a pointer to the\n # top of the whole trie and enqueue this in the frontier\n if search_entry.subtrie[:terminal]\n new_entry = SearchEntry.new(\n '',\n search_entry.target,\n whole_trie,\n search_entry,\n )\n debug \"+ found terminal entry: #{new_entry}\"\n frontier.push(new_entry, new_entry.score)\n end\n\n search_entry.subtrie.each do |key, subtrie|\n next if key == :path\n next if key == :depth\n next if key == :terminal\n\n new_entry = SearchEntry.new(\n \"#{search_entry.match}#{key}\",\n @target,\n subtrie,\n search_entry.previous_entry,\n )\n debug \"- iterating: #{search_entry.match.inspect}+#{key.inspect} #{new_entry}\"\n frontier.push(new_entry, new_entry.score)\n end\n end until frontier.empty? || timeout? #&& collected?)\n\n require 'pry'\n binding.pry\n nil\n end",
"def prefix\n @obj['prefix']\n end",
"def complete_token(complete_ary, prefix)\n complete_ary.select { |cmd| cmd.to_s.start_with?(prefix) }.sort\n end",
"def search(pattern)\n # Initialize loop variables\n cursor = nil\n list = []\n\n # Scan and capture matching keys\n client.with do |conn|\n while cursor != 0\n scan = conn.scan(cursor || 0, match: pattern)\n list += scan[1]\n cursor = scan[0].to_i\n end\n end\n\n list\n end",
"def prefixes\n prefix.split(NAMESPACE_PATTERN)\n end",
"def prefixes\n prefix.split(NAMESPACE_PATTERN)\n end",
"def prefix\n fetch_sample(PREFIXES)\n end"
] | [
"0.7765639",
"0.7521391",
"0.75053906",
"0.7404824",
"0.74030316",
"0.73121566",
"0.71918255",
"0.71758324",
"0.71754545",
"0.71599686",
"0.7131109",
"0.7068194",
"0.6899894",
"0.6880155",
"0.6787459",
"0.66669923",
"0.6611561",
"0.66041136",
"0.6597065",
"0.6502491",
"0.6486207",
"0.64514256",
"0.64428735",
"0.64290345",
"0.6327591",
"0.62778306",
"0.6268826",
"0.6217778",
"0.61913073",
"0.61744064",
"0.61261797",
"0.61172587",
"0.61147964",
"0.61070675",
"0.6040336",
"0.6033521",
"0.5949851",
"0.58453876",
"0.58304006",
"0.58286995",
"0.5816052",
"0.5802967",
"0.57818335",
"0.5752825",
"0.56932557",
"0.567992",
"0.56609625",
"0.5646657",
"0.56316453",
"0.55737305",
"0.55725914",
"0.5554181",
"0.5543374",
"0.5506471",
"0.5458582",
"0.5346448",
"0.5341548",
"0.5336734",
"0.5332437",
"0.5326383",
"0.5317509",
"0.53126293",
"0.5293389",
"0.5287958",
"0.5274982",
"0.5273788",
"0.52530766",
"0.52427816",
"0.52415735",
"0.5236642",
"0.5188264",
"0.51787466",
"0.51622415",
"0.51458144",
"0.51447153",
"0.51300436",
"0.5128648",
"0.51278913",
"0.5116677",
"0.5110312",
"0.5099059",
"0.5093948",
"0.50893754",
"0.508563",
"0.5082627",
"0.5079408",
"0.50586176",
"0.50404555",
"0.50371057",
"0.5030946",
"0.5021702",
"0.50163716",
"0.50108474",
"0.50075424",
"0.49952215",
"0.4987464",
"0.49845126",
"0.4982262",
"0.4982262",
"0.49589428"
] | 0.7594333 | 1 |
get the node for insertion, splitting intermediary nodes as necessary | def find_canididate_insertion_node(current, key)
if current[:key_length].nil?
new_node = insert_node(current, key)
current[:key_length] = key.length
return new_node, ""
end
# check if we have an existing shared prefix already
current_key = key[0...current[:key_length]]
# look for an existing key path
if current[:nodes].has_key?(current_key)
return current[:nodes][current_key], key[current_key.length..-1]
end
# search for a shared prefix, and split all the nodes if necessary
current[:nodes].keys.each do |prefix|
common_prefix = shared_prefix(key, prefix)
next unless common_prefix
new_key_length = common_prefix.length
split_nodes(current, new_key_length)
return current[:nodes][common_prefix], key[new_key_length..-1]
end
# potentially split all other keys
if current_key.length < current[:key_length]
split_nodes(current, current_key.length)
end
new_node = insert_node(current, current_key)
return new_node, key[current_key.length..-1]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert(node, &block); end",
"def insert(node, &block); end",
"def insert_node\n insert_node_helper(@root)\n end",
"def insert_predecessor\n insert_node('insert_predecessor')\n end",
"def insert_node(index, word, definition)\n node_before_index = find_node(index - 1)\n node_at_current_index = find_node(index)\n new_node = Node.new(word, definition, node_at_current_index)\n node_before_index.next_node = new_node\n @counter += 1\n end",
"def insert( data, node = @root, prev_node = nil, child = \"\" ) \n return prev_node.right_child = Node.new( data ) if node.nil? && child == 'right'\n return prev_node.left_child = Node.new( data ) if node.nil? && child == 'left'\n \n if node.data == data\n return node\n elsif data > node.data\n insert(data, node.right_child, prev_node = node, child = 'right')\n elsif data < node.data\n insert(data, node.left_child, prev_node = node, child = 'left')\n end \n end",
"def insert(node)\n @prv.nxt = node.first if @prv\n node.first.prv = @prv\n node.last.nxt = self\n node\n end",
"def insert_node(index, word, definition)\n\n counter = 0\n current_node = @head\n previous_node = nil\n\n until counter == index do\n previous_node = current_node\n current_node = current_node.next\n counter += 1\n end\n\n # insert and point to node that was just bumped back\n new_node = Node.new(word, definition, current_node)\n # redirect previous node pointer to the inserted node\n previous_node.next = new_node\n\n end",
"def insert_child\n insert_node('insert_child')\n end",
"def insert(node, position)\n node_before_position = index(position-1)\n node_at_position = index(position)\n node_before_position.next = node\n node.next = node_at_position\n @size += 1\n node\n # returns inserted node\n end",
"def insert(word)\r\n n = @root\r\n word.chars.each_with_index do |chr, i|\r\n if !n.next.has_key?(chr)\r\n n.next[chr] = Node.new\r\n end\r\n n = n.next[chr]\r\n end\r\n #puts \"insert n=#{n}\"\r\n\r\n n.is_end = true\r\n end",
"def insert(key,value)\n tree = insert_help(key,value)\n if tree.kick?\n tree.to_tree\n else\n tree\n end\n end",
"def insert(word)\n nodes_c = word.chars.map { |c| Node.new(c) }\n\n current = @root\n nodes_c.each do |node|\n existing_node = current.siblings.find { |s| s.val == node.val }\n\n if existing_node\n current = existing_node\n else\n current.siblings << node\n current = node\n end\n end\n\n current.end = true\n end",
"def insert(node, root=nil, &block)\n return super(node, root) do | inserted_node | \n inserted_node.update_left_size(nil, 1) unless inserted_node.nil?\n block.call(inserted_node) if block\n end\n end",
"def insert_node(cur_node, parent_node, value)\n node = nil\n \n if cur_node.nil?\n\tnode = Node.new(value)\n node.children = Array.new(2, nil)\n\tnode.parent = parent_node\n return node\n end\n \n if value < cur_node.value\n node = insert_node(cur_node.children[0], cur_node, value)\n\tcur_node.children[0] ||= node\n else\n node = insert_node(cur_node.children[1], cur_node, value)\n\tcur_node.children[1] ||= node\n end\n \n node\nend",
"def insert_at(index)\n at(index)\n temp = @current_node.next\n blankNode = Node.new('Inserted Node')\n @current_node.next = blankNode\n blankNode.next = temp\n end",
"def insert(key, node = root)\n return node if node.data == key\n if child_count(node) == 0\n key < node.data ? node.left = Node.new(key) : node.right = Node.new(key)\n else\n insert(key, left_right(key, node))\n end\n end",
"def insert_node (insert_mode)\n reference_node = Node.find(params[:id])\n if !reference_node\n render_reference_node_error\n return\n end\n\n node_to_insert = Node.find(params[:node][:id])\n if !node_to_insert\n render_node_to_insert_error\n return\n end\n\n reference_node.send(insert_mode, node_to_insert)\n\n respond_to do |format|\n format.json { render json: node_to_insert, status: :created, location: node_to_insert }\n end\n end",
"def insert_after(child1, child2); end",
"def insert_before(child1, child2); end",
"def node_insertion_helper(current_node, value)\n\t\t\t#if there is no node in the root, the root value is assigned to the incoming node\n\t\tif current_node == nil\n\t\t\tcurrent_node = Node.new(value)\n\n\t\t\t#if the value of the incoming node less than the current node value\n\t\t\t\t#the current nodes left value becomes the new node value\n\t\t\t\t\t#however before the node is inserted the current node value is compared again to the new node value, this process will repeat until the current_node's value is nil\n\t\telsif current_node.data > value\n\t\t\tp current_node.left = node_insertion_helper(current_node.left, value)\n\t\telse current_node.data < value\n\t\t\tp current_node.right = node_insertion_helper(current_node.right, value)\n\t\tend\n\t\treturn current_node\n\tend",
"def insert(value)\n current_node = @root\n until current_node.nil?\n if current_node.data < value\n if current_node.right_child.nil?\n current_node.right_child = Node.new(value)\n break\n end\n current_node = current_node.right_child\n elsif current_node.data > value\n if current_node.left_child.nil?\n current_node.left_child = Node.new(value)\n break\n end\n current_node = current_node.left_child\n else\n puts 'Input error'\n break\n end\n end\n end",
"def insert_into(destination, node)\n var = destination.to_s\n\n eval(%Q{\n if @#{var}.nil?\n # not trying to insert into left or right\n @#{var} = node\n else\n # insert into left or right\n @#{var}.insert(node)\n end\n })\n end",
"def insert(p0, p1) end",
"def insert(key, value = nil)\n node = @root\n if node.full? \n @root = Btree::Node.new(@degree)\n @root.add_child(node)\n @root.split(@root.children.size - 1)\n #puts \"After split, root = #{@root.inspect}\"\n # split child(@root, 1)\n node = @root\n end\n node.insert(key, value)\n @size += 1\n return self\n end",
"def node_insert_after!(x, prev, level)\n netx = node_next(prev, level) # 'next' is a reserved word in ruby\n \n # forward links\n x[0][level] = netx\n prev[0][level] = x\n \n # backward links\n x[3][level] = prev\n netx[3][level] = x\n end",
"def insertAfter(node, new_node)\n end",
"def insert(x, node=self)\n if node.nil? \n node = Node.new(x, self)\n elsif node.val.nil?\n node.val = x\n elsif x < node.val\n if node.left.nil?\n node.left = Node.new(x, node)\n else\n node.left.val = x\n end\n elsif x > node.val\n if node.right.nil?\n node.right = Node.new(x, node)\n else\n node.right.val = x\n end\n end\n return node\n end",
"def insert(position, surname)\n new_node = Node.new(surname)\n current = self[position-1] #self is [] method\n add_to_count\n saved_node = current.next_node\n current.next_node = new_node\n new_node.next_node = saved_node\n return new_node\n end",
"def insert_child(c)\n if @children.include?(c)\n return @children[c]\n else\n @children[c] = TrieNode.new(c)\n return @children[c]\n end\n end",
"def insert_node( word, definition, index )\n\n\t\tcount = 0\n\t\tcurrent_node = @head\n\t\tlast_node = nil\n\n\n\t\tlast_node, count = find_node( index )\n\t\tcurrent_node = last_node.next\n\n\t\tif last_node.next.nil?\n\n\t\t\tadd_node( word, definition )\n\n\t\telse\n\n\t\t\tnew_node = Node.new( word, definition )\n\t\t\tnew_node.next = current_node\n\t\t\tlast_node.next = new_node\n\n\t\t\tputs \"Inserted #{new_node.word} at index: #{count}\"\n\n\t\tend\n\n\tend",
"def insert_at(i,data)\n if i<0 || i>= @size\n \treturn nil\n end\n node=Node.new\n node.value=data\n if i==0\n \tnode.next_node=@root\n \t@root=node\n else\n pre_node=at(i-1)\n node.next_node=pre_node.next_node\n pre_node.next_node=node\n end\n @size+=1\n end",
"def insert(insert_value)\n if insert_value == value\n return self\n elsif value > insert_value\n if left_child.nil?\n self.left_child = self.class.new(insert_value)\n return left_child\n else\n return self.left_child.insert(insert_value)\n end\n elsif value < insert_value\n if right_child.nil?\n self.right_child = self.class.new(insert_value)\n return right_child\n else\n return self.right_child.insert(insert_value)\n end\n end\n end",
"def insert (node, splice_position)\n _insert(node, splice_position)\n\n delete_old_nodes\n\n node\n end",
"def insert(node, identifier = nil)\n if identifier\n insert_after(node, identifier)\n else \n node.next = @first_node\n @first_node = node\n end\n end",
"def test_insert_returns_1_when_2_nodes_added\n @tree.insert(\"b\")\n return_value = @tree.insert(\"a\")\n assert_equal 1, return_value\n end",
"def insert_before value\n node = Node.new value, self, @prv\n @prv.nxt = node if @prv\n @prv = node\n end",
"def insert(node)\n case @value <=> node.value\n when 1\n # alphabetically greater than, insert to left\n insert_into(:left, node)\n when 0\n # same value, so increase count of `self` node\n @count += 1\n when -1\n # alphabetically less than, insert to right\n insert_into(:right, node)\n end\n end",
"def insert_at(data, index)\n\t\t@current_node = at(index)\n\t\t@insert_node = Node.new(data, @current_node)\n\n\t\t#Handeling the case that user inserts a node at head position (even though prepend exists for that)\n\t\tif @current_node != @head\n\t\t\t@old_link_node = at(index - 1)\n\t\t\t@old_link_node.next_node = @insert_node\n\t\telse\n\t\t\t@head = @insert_node\n\t\tend\n\tend",
"def insert_before_node(node, to_insert)\n return unless node\n\n new_node = Node.new(to_insert, node.prev, node)\n\n if node.prev\n node.prev.next = new_node\n end\n\n if node == @head\n @head = new_node\n end\n\n node.prev = new_node\n @length += 1\n return new_node\n end",
"def insert(current_node = root, value)\n # compare nodes,decide if left or right \n return nil if value == current_node.value\n\n if value < current_node.value\n current_node.left.nil? ? current_node.left = Node.new(value) : insert(current_node.left, value)\n else\n current_node.right.nil? ? current_node.right = Node.new(value) : insert(current_node.right, value)\n end\n end",
"def insert(element)\n i = element.hash % @table.size\n node = @table[i]\n while node\n if element == node.item\n node.item = element\n return element\n end\n node = node.next\n end\n @table[i] = Node.new(element,@table[i])\n @count += 1\n return element\n end",
"def insert_at(index, e)\n push e if index > @length - 1\n node = get_node index\n insert_node_between node.prev, node, ListNode.new(e)\n end",
"def insert_one(aliment)\n\t\tnode = Node.new(aliment, nil, nil)\n\t\tif(empty)\n\t\t\t@head = node\n\t\t\t@tail = node\n\t\telse\n\t\t\tnode[\"prev\"] = @tail\n\t\t\t@tail[\"next\"] = node\n\t\t\t@tail = node\n\t\tend\n\t\t@size += 1\n\tend",
"def insert_successor\n insert_node('insert_successor')\n end",
"def insert_helper(current_node, key)\n return Node.new(key) if nil == current_node\n\n v = current_node.value\n\n if v == key\n return current_node\n elsif v > key\n current_node.left_node = insert_helper(current_node.left_node, key)\n elsif v < key\n current_node.right_node = insert_helper(current_node.right_node, key)\n end\n current_node\n end",
"def insert_node(tree_node, value)\r\n\r\n # Base Case: Found a space\r\n if tree_node.nil?\r\n tree_node = Node.new(value)\r\n\r\n elsif tree_node.value == value\r\n tree_node.value = value\r\n elsif tree_node.value < value\r\n tree_node.right = insert_node(tree_node.right, value)\r\n else\r\n tree_node.left = insert_node(tree_node.left, value)\r\n end\r\n tree_node\r\n end",
"def insert_identifier(opts={})\n type = nil\n if !opts[:identifierType].nil?\n type = opts[:identifierType]\n end\n value = nil\n if !opts[:identifierValue].nil?\n value = opts[:identifierValue]\n end\n node = MedusaPremis::Datastream::AgentDs.identifier_template(type, value)\n nodeset = self.find_by_terms(:identifier)\n\n unless nodeset.nil?\n if nodeset.empty?\n self.ng_xml.root.add_child(node)\n index = 0\n else\n nodeset.after(node)\n index = nodeset.length\n end\n # deprecated... \n # self.dirty = true\n end\n return node, index\n end",
"def insert(index, content)\n\t\tif index==1 and @length!=0\n\t\t\tnode = Node.new(content, nil, @first)\n\t\t\t@first = node\n\t\telsif @length+1==index\n\t\t\tpush(content)\n\t\telse\n\t\t\ttmp = get(index)\n\t\t\tnode = Node.new(content, tmp.back, tmp)\n\t\t\ttmp.back.front = node\n\t\t\ttmp.back = node\n\t\tend\n\t\t@length+=1\n\tend",
"def insertion(value)\n insertion_recursion(value, @root)\n end",
"def insert_node(word, definition, index)\n node = Node.new(word, definition, nil)\n if index == 0\n node.next = @head\n @head = node\n else\n counter = 0\n current_node = @head\n prev_node = nil\n while counter < index\n prev_node = current_node\n current_node = current_node.next\n counter += 1\n end\n node.next = current_node\n prev_node.next = node\n puts \"Inserting node at index #{index} with value: #{node.word}\"\n end\n end",
"def insert_identifier(opts={})\n type = nil\n if !opts[:identifierType].nil?\n type = opts[:identifierType]\n end\n value = nil\n if !opts[:identifierValue].nil?\n value = opts[:identifierValue]\n end\n node = MedusaPremis::Datastream::RepresentationObjectDs.identifier_template(type, value)\n nodeset = self.find_by_terms(:identifier)\n\n unless nodeset.nil?\n if nodeset.empty?\n self.ng_xml.root.add_child(node)\n index = 0\n else\n nodeset.after(node)\n index = nodeset.length\n end\n # deprecated...\n # self.dirty = true\n end\n return node, index\n end",
"def insert_before(value)\n node = Node(value)\n node.next = self\n node\n end",
"def insert_after(value)\n node = Node(value)\n @next = node\n node\n end",
"def insert_head (value) # Insertar desde la cabeza\n\t nodo=Node.new(value,nil,nil)\n nodo.nest = @head\n @head = nodo # el head ahora apunta a este nodo\n if (@tail == nil)\n @tail = nodo\n end\n nodo.prev = nil\n if (nodo.nest != nil)\n nodo.nest.prev = nodo\n end\n end",
"def insert_after(value)\n node = DoublyLinkedListNode(value)\n\n # Need to implement this\n\n node\n end",
"def insert_beginning(*val)\n \n val.each do |nuevo_nodo|\n \n if @head != nil\n \n @head.previous = nuevo_nodo\n nuevo_nodo.next = @head\n @head = nuevo_nodo\n else\n @head = nuevo_nodo\n end\n @num_nodos += 1\n \n end\n end",
"def insert(str)\n child_node = get_or_create str[0]\n if str.length == 1 # terminal condition\n child_node.end_of_word!\n else\n child_node.insert str[1..-1] # recursively call itself on the child node\n end\n end",
"def insert_after( node, value )\n # Find the specified node, and add a new node\n # with the given value between that found node\n # and the next\n\n end",
"def insert(word)\n w = word.chars\n w.push('end')\n node = @root\n # Add 'bridge' for each element.\n w.each do |key|\n node[key] ||= {}\n node = node[key]\n end\n \n end",
"def insert_node(new_node_val)\n new_node = Node.new(new_node_val)\n @nodes << new_node\n @_node_map[new_node_val] = new_node\n new_node\n end",
"def insert(value)\n node = Node.new(value)\n current = @anchor.next_node\n while current != @anchor\n if @comparator.call(node.value, current.value)\n return node.insert_before(current)\n end\n current = current.next_node\n end\n node.insert_before(@anchor)\n end",
"def insert_after value\n node = Node.new value, @nxt, self\n @nxt.prv = node if @nxt\n @nxt = node\n end",
"def insert_nodes_only(items, location, target, contexts)\n \n puts @location_path_processor.get_node(location).to_s\n \n #sort items the way they should be stored\n #so for BEFORE, INTO and AS LAST INTO (which are the same) we dont need to sort anything\n #for AFTER and AS FIRST INTO should be sorted reversely because we are going to insert them sequentially\n # - always AFTER the location or AS FIRST in the location\n reverse_specific_items = Proc.new { |item_array, specific_target|\n case specific_target\n when ExpressionModule::InsertExprHandle::TARGET_AFTER, ExpressionModule::InsertExprHandle::TARGET_INTO_FIRST\n item_array.reverse!\n end\n }\n reverse_specific_items.call(items, target)\n \n items.each { |item|\n case item.type\n #adding relative or previously loaded var\n when ExpressionModule::RelativePathExpr, ExpressionModule::VarRef\n extended_keys_to_insert = []\n contexts.each { |context|\n case item.type\n when ExpressionModule::RelativePathExpr\n extended_keys_to_insert.concat(@path_solver.solve(item, context))\n when ExpressionModule::VarRef\n extended_keys_to_insert.concat(context.variables[item.var_name])\n else\n raise StandardError, \"impossible\"\n end\n }\n reverse_specific_items.call(extended_keys_to_insert, target)\n add_elements(extended_keys_to_insert, location, target)\n \n #adding constructor\n when ExpressionModule::CompAttrConstructor\n case target\n when ExpressionModule::InsertExprHandle::TARGET_BEFORE, ExpressionModule::InsertExprHandle::TARGET_AFTER \n add_attribute(item, Transformer::KeyElementBuilder.build_from_s(location.key_builder, location.parent_key))\n else\n add_attribute(item, location.key_element_builder)\n end\n \n \n when ExpressionModule::DirElemConstructor\n contexts.each { |context|\n add_node(item.nokogiri_node(@path_solver, context), location, target)\n }\n \n \n when ExpressionModule::StringLiteral\n contexts.each { |context|\n add_text(item.text, location, target)\n }\n \n \n end\n }\n end",
"def insert(num)\n\t\tnode = @root\n\t\tuntil node.key == num\n\t\t\tif (num > node.key)\n\t\t\t\tif (node.right.nil?)\n\t\t\t\t\tnew_node = Node.new(key: num, parent: node)\n\t\t\t\t\tnode.right = new_node\n\t\t\t\t\tnode = new_node\n\t\t\t\telse\n\t\t\t\t\tnode = node.right\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tif (node.left.nil?)\n\t\t\t\t\tnew_node = Node.new(key: num, parent: node)\n\t\t\t\t\tnode.left = new_node\n\t\t\t\t\tnode = new_node\n\t\t\t\telse\n\t\t\t\t\tnode = node.left\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def insert_node_between(a, b, new_one)\n a.next = new_one\n new_one.prev = a\n new_one.next = b\n b.prev = new_one\n @length += 1\n end",
"def insert(new_node)\n\n if self.root.nil?\n self.root = new_node\n self.size = 1\n return {root: new_node.value, size: self.size}\n end\n\n current = self.root\n\n until current.nil?\n if current.value == new_node.value\n return \"{value} already present in tree\"\n elsif current.value < new_node.value && current.right.nil?\n current.right = new_node\n new_node.parent = current\n self.size += 1\n elsif current.value > new_node.value && current.left.nil?\n current.left = new_node\n new_node.parent = current\n self.size += 1\n elsif current.value < new_node.value\n current = current.right\n elsif current.value > new_node.value\n current = current.left\n end\n end\n end",
"def insert(elt)\n x = Node.new(elt)\n @head = meld_roots(@head, x)\n @size += 1\n end",
"def insert(idx, node)\n if idx.zero?\n add_first(node)\n return\n end\n\n iterate do |curr_node, count|\n if count == idx - 1\n old_next = curr_node.next_node\n curr_node.next_node = node\n node.next_node = old_next\n old_next.prev_node = node unless old_next.nil?\n node.prev_node = curr_node\n\n return\n end\n end\n end",
"def insert_at(index, node_value)\n if index == 0\n node = Node.new(node_value)\n node.next_node = @head\n @head = node\n else\n target = at(index)\n if target.nil?\n append(node_value)\n else\n node = Node.new(node_value)\n pre_target = at(index - 1)\n node.next_node = target\n pre_target.next_node = node\n end\n end\n\n node\n end",
"def test_insert_node_to_left_of_root\n @tree.insert(\"b\")\n @tree.insert(\"a\")\n refute_equal nil, @tree.root.left\n end",
"def insert(data)\n node = Node.new(data)\n\n if @size == 0\n @root = node\n else\n parent = @root\n\n loop do\n if data <= parent.value\n if !parent.left # found a leaf node\n parent.left = node # insert here\n break\n else\n parent = parent.left\n end\n else # data > node.value\n if !parent.right # found a leaf node\n parent.right = node # insert here\n break\n else\n parent = parent.right\n end\n end\n end\n end\n\n @size += 1\n end",
"def insert(word)\n return false if word.length == 0\n \n puts \"\\n>> inserting word /#{word}/\"\n \n if root.children.empty?\n node = Node.new(word, root)\n puts \"[1] insert /#{word}/ as child of root\"\n root.children[word[0]] = node\n else\n children_key = word[0]\n target_child = root.children[children_key]\n \n puts \"[2] target_child is /#{target_child.string}/\"\n \n while target_child do\n puts \"------ A new loop of target_child --------\"\n target_length = target_child.string.length\n word_length = word.length\n \n # compare the two strings to find common part\n common_string = \"\"\n # the index of last character that is in common string\n final_index = -1\n \n 0.upto(target_length-1) do |index|\n if index > word_length - 1\n # if current index exceeds the length of word\n break\n end\n \n if target_child.string[index] == word[index]\n # this character is common\n common_string += word[index]\n final_index = index\n else\n break\n end\n end\n \n if final_index == -1\n # no common string, then attach new_node directly\n new_node = Node.new(word, target_child.parent)\n target_child.parent.children[word[0]] = new_node\n elsif final_index == target_length - 1\n # if the target_child is totally covered \n if final_index < word_length - 1\n # and if the word is not totally covered\n diff_in_word = word[(final_index+1)..(word_length-1)]\n \n if target_child.children[diff_in_word[0]]\n # if the word is not fully traversed, then update target_child and go on doing the loop\n target_child = target_child.children[word[final_index+1]]\n word = word[(final_index+1)..(word_length-1)]\n \n puts \"[3] next target_child is /#{target_child.string}/; and word becomes /#{word}/\"\n else\n new_node = Node.new(diff_in_word, target_child)\n target_child.children[diff_in_word[0]] = new_node\n \n puts \"[4] add new node /#{new_node.string}/ as child of /#{target_child.string}/\"\n break\n end\n else\n # if the word is totally covered, make target_child a leaf\n target_child.leaf = true\n puts \"[5] there is a new word that ends at existing /#{target_child.string}/ (no extra node needed)\"\n break\n end\n elsif final_index < target_length -1\n # if the target_child is not totally covered \n common_node = Node.new(common_string, target_child.parent)\n puts \"[6] make common node /#{common_node.string}/\"\n \n diff_in_target = target_child.string[(final_index+1)..(target_length-1)]\n puts \"[7] update current target_child to diff_in_target /#{diff_in_target}/ as child of common_node: /#{common_node.string}/\"\n target_child.string = diff_in_target\n target_child.parent.children[common_string[0]] = common_node\n target_child.parent = common_node\n common_node.children[diff_in_target[0]] = target_child \n \n if final_index == word_length - 1 \n # if the word is totally covered\n # make it a leaf, to specify there is word that ends here\n common_node.leaf = true\n puts \"[8] there is a new word that ends at /#{common_node.string}/\"\n break\n elsif final_index < word_length - 1\n diff_in_word = word[(final_index+1)..(word_length-1)] \n new_node = Node.new(diff_in_word, common_node)\n common_node.children[diff_in_word[0]] = new_node\n puts \"[9] add diff_in_word /#{diff_in_word}/ as child of common_node: /#{common_node.string}/\"\n break\n end\n end \n end\n end\n end",
"def insert_element(line_number, line_content, in_element=nil)\n\t\tto_modify = {modify_nodes: [], add_nodes: [], remove_nodes: [], modify_edges: [], remove_edges: [], add_edges: []}\n\n\t\tordering = get_ordering\n\t\tfirst_char = get_text_from_regexp(line_content, /[ ,\\t]*(.)/)\n\n\t\t#node\n\t\tif first_char == \".\"\n\t\t\t#shouldn't need this\n\t\t\tif in_element != nil && in_element.is_a?(Node) #only use the in_el if it's not nil and the right type\n\t\t\t\tnew_node = in_element\n\t\t\telse #to be safe, generally do a new one.\n\t\t\t\tnew_node = Node.new\n\t\t\tend\n\t\t\tbuild_node(new_node, line_content)\n\t\t\tnew_node.save\n\n\t\t\t#update the ordering\n\t\t\tordering.insert(line_number, ObjectPlace.new(\"Node\", new_node.id))\n\t\t\tset_order(ordering)\n\n\t\t\t#FIND PARENT\n\t\t\tif new_node.depth != 0 #if it's not a base element, give it a parent\n\t\t\t\tparent_node = find_element_parent(new_node.depth, line_number, ordering)\n\t\t\t\tif parent_node != nil #only give it a parent if it actually has one\n\t\t\t\t\trelation = Link.new(child_id: new_node.id, parent_id: parent_node.id, work_id: self.id)\n\t\t\t\t\trelation.save\n\t\t\t\tend\n\t\t\t#else\n\t\t\t#\trelation = Link.new(child_id: new_node.id, parent_id: nil, work_id:self.id) #empty initial relationship\n\t\t\tend\n\n\t\t\towner_id = nil\n\t\t\tremove_edges = []\n\n\t\t\t#FIND CHILDREN, ADOPT THEM (FROM EXISTING PARENT)\n\t\t\tchildren = find_element_children(line_number, new_node.depth, ordering)\n\t\t\tchildren.each do |child|\n\t\t\t\t#removes the old edges\n\t\t\t\tif child[:node].is_a?(Node) #add the old edges to be removed, since that connection is broken\n\t\t\t\t\told_parent_edge = child[:node].parent_relationships.find_by link_collection_id: nil #doesn't mess with ones that have link_coll\n\t\t\t\t\tif old_parent_edge != nil\n\t\t\t\t\t\tremove_edges.append(old_parent_edge.to_cytoscape_hash)\n\t\t\t\t\t\t#remove_edges.append({ id: old_parent_edge.id, source: old_parent_edge.parent_id.to_s, target: old_parent_edge.child_id.to_s })\n\t\t\t\t\tend\n\n\t\t\t\telsif child[:node].is_a?(Note)\n\t\t\t\t\towner_id = child[:node].node_id\n\t\t\t\tend\n\n\t\t\t\tchange_parent(child[:node], new_node)\n\t\t\t\t#updates the now changed parents if necessary\n\t\t\t\tif owner_id != nil #if there's a real parent at the end, modify it in the graph\n\t\t\t\t\tnode_hash = Node.find(owner_id).to_cytoscape_hash\n\t\t\t\t\tto_modify[:modify_nodes].append(node_hash[:node])\n\t\t\t\t\tnode_hash[:edges].each do |edge|\n\t\t\t\t\t\tto_modify[:modify_edges].append(edge)\n\t\t\t\t\tend\n\t\t\t\t\n\t\t\t\telsif child[:node].is_a?(LinkCollection)\n\t\t\t\t\t#if it's a link collection, remove all those links, gonna reassign\n\t\t\t\t\tchild[:node].links.each do |link|\n\t\t\t\t\t\tto_modify[:modify_edges].append(link.to_cytoscape_hash)\n\t\t\t\t\t\t#remove_edges.append({ id: link.id, source: link.parent_id.to_s, target: link.child_id.to_s })\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\towner_id = nil #resets it to make the above check false for non-nodes\n\t\t\tend\n\n\t\t\t#new_node.combine_notes\n\t\t\tto_modify[:add_nodes].append(new_node.to_cytoscape_hash[:node])\n\t\t\tto_modify[:add_edges] = new_node.to_cytoscape_hash[:edges]\n\t\t\tto_modify[:remove_edges] = remove_edges\n\n\t\t\treturn to_modify\n\n\t\t#note\n\t\telsif first_char == '-'\n\t\t\tif in_element != nil && in_element.is_a?(Note) #only use the in_el if it's not nil and the right type\n\t\t\t\tnew_note = in_element\n\t\t\telse\n\t\t\t\tnew_note = Note.new\n\t\t\tend\n\n\t\t\tbuild_note(new_note, line_content)\n\t\t\tnew_note.save\n\t\t\tordering.insert(line_number, ObjectPlace.new(\"Note\", new_note.id))\n\t\t\tset_order(ordering)\n\n\t\t\t#FIND PARENT\n\t\t\tparent_node = find_element_parent(new_note.depth, line_number, ordering)\n\t\t\tif parent_node != nil #if it has a parent, set it. ignore otherwise\n\t\t\t\tnew_note.node_id = parent_node.id\n\t\t\t\tnew_note.save\n\t\t\t#\tparent_node.combine_notes\n\t\t\t#else\n\t\t\t#\tnew_note.node_id = nil\n\t\t\t#\tnew_note.save\n\t\t\telse\n\t\t\t\tnew_note.save\n\t\t\tend\n\t\t\tif parent_node != nil #if it actually has a parent\n\t\t\t\tto_modify[:modify_nodes].append(parent_node.to_cytoscape_hash[:node])\n\t\t\t\tto_modify[:modify_edges] = parent_node.to_cytoscape_hash[:edges]\n\t\t\tend\n\t\t\t#to_modify[:remove_edges] = []\n\t\t\treturn to_modify\n\t\n\t\t#link collection\n\t\telsif first_char == ':'\n\t\t\t#build link collection\n\t\t\tlink_coll = self.link_collections.build\n\n\t\t\t#get its depth\n\t\t\twhitespace = get_text_from_regexp(line_content, /(.*):/)\n\t\t\tlink_coll_depth = (whitespace.length)/3 #+2?\n\n\t\t\t#get its parent node\n\t\t\tordering.insert(line_number, ObjectPlace.new(\"LinkCollection\", nil))\n\t\t\tset_order(ordering)\n\t\t\tparent_node = find_element_parent(link_coll_depth, line_number, ordering)\n\n\t\t\t#this function builds all the links, plus if any are defined to a non-existing node, it adds and returns it\n\t\t\tbuild_link_collection(link_coll, line_content, parent_node)\n\n\t\t\t#build its child links\n\t\t\tlink_names = get_text_from_regexp(line_content, /:(.*)/)\n\t\t\tnew_nodes = link_coll.set_links(link_names)\n\n\t\t\t#adds any newly created links to be returned\n\t\t\tif link_coll.links != nil && link_coll.links.any?\n\t\t\t\tlink_coll.links.each do |link|\n\t\t\t\t\tto_modify[:add_edges].append(link.to_cytoscape_hash)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\t#adds any newly added nodes to be returned\n\t\t\tnew_nodes.each do |node|\n\t\t\t\tto_modify[:add_nodes].append(node.to_cytoscape_hash[:node])\n\t\t\tend\n\t\t\n\t\t\t#update id in ordering, pull it again to start in case it's been changed\n\t\t\tordering = get_ordering\n\t\t\tordering[line_number].id = link_coll.id\n\t\t\tset_order(ordering)\n\t\t\treturn to_modify\n\n\t\t#place holder\n\t\telse\n\t\t\tplace_holder = self.place_holders.create(text:line_content)\n\t\t\tordering.insert(line_number, ObjectPlace.new(\"PlaceHolder\", place_holder.id))\n\t\t\tset_order(ordering)\n\t\t\treturn {}\n\t\tend\n\tend",
"def relational\r\n node = add()\r\n\r\n loop do\r\n if consume(\"<\")\r\n node = new_binary(ND_LT, node, add())\r\n elsif consume(\"<=\")\r\n node = new_binary(ND_LE, node, add())\r\n elsif consume(\">\")\r\n node = new_binary(ND_LT, add(), node)\r\n elsif consume(\">=\")\r\n node = new_binary(ND_LE ,add(), node)\r\n else\r\n return node\r\n end\r\n end\r\nend",
"def insert_at(node, index)\n target = self.at(index)\n target_prev = target.prev\n set_next_and_prev(target_prev, node)\n set_next_and_prev(node, target)\n self.size += 1\n end",
"def insert(word, definition, index)\n new_node = Node.new(word, definition, nil)\n count = 2\n current_node = @head\n next_node = @head.next\n while count < index\n current_node = current_node.next\n next_node = next_node.next\n count += 1\n end\n new_node.next = next_node\n current_node.next = new_node\n end",
"def insert(data)\n @head = Node.new(data, @head)\n end",
"def insert(node,path)\n if path[:edge_list].empty?\n path[:edge_list] << [node,node]\n else\n deleted_edge = path[:edge_list].min_by{|edge| distance(edge.first,node) + distance(node,edge.last) - distance(edge.first,edge.last)}\n deleted_distance = distance(deleted_edge.first,deleted_edge.last)\n path[:edge_list].delete(deleted_edge)\n path[:edge_list] << [deleted_edge.first,node]\n path[:edge_list] << [node, deleted_edge.last]\n path[:length] += (distance(deleted_edge.first,node) + distance(node,deleted_edge.last) - distance(deleted_edge.first,deleted_edge.last))\n end\n end",
"def prepend_child(node_or_tags); end",
"def prepend_child(node_or_tags); end",
"def insert_linking_identifier(opts={})\n node = Medusa::Premis::Agent.linking_identifier_template\n nodeset = self.find_by_terms(:linkingIdentifier)\n\n unless nodeset.nil?\n if nodeset.empty?\n self.ng_xml.root.add_child(node)\n index = 0\n else\n nodeset.after(node)\n index = nodeset.length\n end\n self.dirty = true\n end\n\n return node, index\n end",
"def insert_at(index, value)\n node = Node.new\n node.value = value\n counter = 0\n current_node = @head\n until counter == index\n previous_node = current_node\n current_node = current_node.next_node\n counter += 1\n end\n previous_node.next_node = node\n node.next_node = current_node\n end",
"def test_insert_adds_node_left_of_left_of_root\n @tree.insert(\"c\")\n @tree.insert(\"b\")\n @tree.insert(\"a\")\n refute_equal nil, @tree.root.left.left\n end",
"def insertion(val, rel, recursive = T.unsafe(nil), list = T.unsafe(nil)); end",
"def insert_after(idx, data)\n curr_node = node_at(idx)\n fail ArgumentError, \"index is out of range\" unless curr_node\n new_node = Node.new(data)\n new_node.next_node = curr_node.next_node\n curr_node.next_node = new_node\n end",
"def insert(loc, data)\n if @head.data == nil\n @head = Node.new(data)\n else\n counter = 1\n node = @head\n until counter == loc\n node = node.next_node\n counter += 1\n end\n new_node = Node.new(data)\n new_node.next_node = node.next_node\n node.next_node = new_node\n end\n end",
"def insert_before(node, obj)\n obj = obj.value if obj.is_a?(Node)\n node = Node.new(obj)\n\n if @head == node\n @head = new_node\n new_node.next = node\n else\n previous = node.previous\n previous.next = new_node\n new_node.previous = previous\n new_node.next = node\n end\n self\n end",
"def insert_after prev_node, new_data\n # 1. check if the given prev_node exists\n if prev_node == nil\n puts \"the given previous node cannot be NULL\"\n end\n # 2. Create new node\n # 3. Put in the data\n new_node = Node.new(new_data)\n # 4. Make next of new Node as next of prev_node\n new_node.next_node = prev_node.next_node\n # 5. make next of prev_node as new_node\n prev_node.next_node = new_node\n # 6. Make prev_node ass previous of new_node\n new_node.prev_node = prev_node\n # 7. Change previous of new_nodes's next node\n if new_node.next_node != nil\n new_node.next_node.prev_node = new_node\n end\n end",
"def insertBack(object=nil) #we need more of these\n tempNode = Node.new(object)\n tempNode.next = @last\n tempNode.prev = @last.prev\n @last.prev.next = tempNode\n @last.prev = tempNode\n @size += 1\n return @last.prev \n \n end",
"def insert(node, value)\n if node.left.nil? && value < node.val\n return node.left = TreeNode.new(value)\n elsif node.right.nil? && value > node.val\n return node.right = TreeNode.new(value)\n end\n\n insert(node.left, value) if value < node.val\n insert(node.right, value) if value > node.val\n\n return node\nend",
"def add_node(node); end",
"def insert(element)\n [email protected]\n\n @store[@store.length]=element\n return if insertindex==1\n\n #For even inserts parent index is insertedindex/2-1 otherwise its juts insertedindex/2\n\n parentindex=insertindex/2\n\n #Incase it does not fit in(violating Heap Property)\n while insertindex!=1 && @store[parentindex] > @store[insertindex]\n swap(parentindex,insertindex)\n insertindex=parentindex\n parentindex=insertindex/2\n end\n\n end",
"def insert(value)\n\t\tcurrent_node = @head \n\t\tif current_node.value >= value \n\t\t\t@head = Node.new(value, current_node)\n\t\tend \n\t\tuntil current_node.next_node.value =< value \n\t\t\tbreak if current_node.next_node == nil \n\t\t\tcurrent_node = current_node.next_node\n\t\tend \n\t\tcurrent_node.next_node = Node.new(value, current_node.next_node)\n\tend",
"def insert(value, node = root)\n return nil if value == node.data\n \n if value < node.data\n node.left.nil? ? node.left = Node.new(value) : insert(value, node.left)\n else\n node.right.nil? ? node.right = Node.new(value) : insert(value, node.right)\n end\n end",
"def moved_node\n current_tree.find(node_2.id)\n end",
"def preceding(node); end",
"def insert_after( node, value )\n # Find the specified node, and add a new node\n # with the given value between that found node\n # and the next\n node = find node\n node_after = node.next\n node_inserted = Node.new value\n node.next = node_inserted\n node_inserted.next = node_after\n node_inserted\n end",
"def search_path_for_insert_position(start_node_index, end_node_index, key_value)\n \n if start_node_index >= end_node_index\n return start_node_index\n end\n \n if parent_index(end_node_index) == start_node_index\n #if only two elements in the path\n #use the end one as the midpoint\n mid = end_node_index\n else\n #calculate the mid point of the path\n mid_advances = 0.5 * height_of_heap(start_node_index, end_node_index)\n mid = end_node_index\n mid_advances.floor.downto(1) do |i|\n mid = parent_index(mid)\n end\n end\n\n if self[mid - 1] > key_value\n search_path_for_insert_position(next_child_in_path(start_node_index, end_node_index), end_node_index, key_value)\n elsif self[mid - 1] < key_value\n search_path_for_insert_position(start_node_index, parent_index(mid), key_value)\n else\n #we've found the insert position \n mid \n end \n end",
"def insert( new_key )\n if new_key <= @key\n @left.nil? ? @left = Node.new( new_key ) : @left.insert( new_key )\n elsif new_key > @key\n @right.nil? ? @right = Node.new( new_key ) : @right.insert( new_key )\n end\n end"
] | [
"0.6867058",
"0.6867058",
"0.65956396",
"0.629302",
"0.6283602",
"0.6233717",
"0.61871123",
"0.61863637",
"0.6173093",
"0.615837",
"0.61381793",
"0.61224467",
"0.61005735",
"0.6075693",
"0.606866",
"0.6068604",
"0.6068337",
"0.605623",
"0.60474813",
"0.60417694",
"0.601125",
"0.6002367",
"0.59931916",
"0.59898657",
"0.59835285",
"0.59783506",
"0.59745973",
"0.5966259",
"0.5952922",
"0.5928511",
"0.5919192",
"0.59037447",
"0.5900907",
"0.5894053",
"0.5892253",
"0.5871806",
"0.5864233",
"0.5863836",
"0.5859836",
"0.58487564",
"0.58290213",
"0.58232284",
"0.57995844",
"0.5795137",
"0.57903767",
"0.57837236",
"0.5780214",
"0.57715416",
"0.57482827",
"0.57459015",
"0.57359046",
"0.573581",
"0.57348216",
"0.572453",
"0.5723435",
"0.5715344",
"0.57097304",
"0.56953967",
"0.569227",
"0.56910264",
"0.5664519",
"0.5661168",
"0.565778",
"0.5656673",
"0.56425357",
"0.5638995",
"0.5634438",
"0.5631789",
"0.56241864",
"0.56127334",
"0.5608333",
"0.560583",
"0.56054634",
"0.5602867",
"0.5601926",
"0.55978954",
"0.5588247",
"0.5577445",
"0.5576019",
"0.5569862",
"0.5569862",
"0.5564879",
"0.5564079",
"0.55621606",
"0.55558974",
"0.55536735",
"0.5542635",
"0.55416745",
"0.5540488",
"0.5536822",
"0.5536584",
"0.5529486",
"0.5521636",
"0.5518051",
"0.55171394",
"0.5508504",
"0.5502909",
"0.55001295",
"0.5491681",
"0.54902637"
] | 0.63288593 | 3 |
split all the branches in the given root to the given length | def split_nodes(root, new_length)
old_nodes = root[:nodes]
split_length = root[:key_length] - new_length
root[:key_length] = new_length
root[:nodes] = {}
old_nodes.each do |key, old|
new_node = insert_node(root, key[0...new_length])
new_node[:nodes][key[new_length..-1]] = old
new_node[:key_length] = split_length
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cut(num_segments)\n t = direction*(1.0/num_segments)\n ret = [@root]\n num_segments.times do |i|\n ret << @root + t*(i + 1)\n end\n ret\n end",
"def convert_linked_list_to_balanced_BST(head, length)\n \n # trivial case\n # return immediately\n if head.nil? || length == 0\n return nil\n end\n\n puts \"working on head = #{head.value}\" if $debug\n \n left_half_size = (length - 1) / 2\n right_half_size = length - 1 - left_half_size\n puts \"left_half_size = #{left_half_size} right_half_size = #{right_half_size}\" if $debug\n \n root = head\n i = 0\n while i < left_half_size\n puts \"shift to #{root.value}\" if $debug\n root = root.right\n i += 1\n end\n \n # now leaf_tail points to the end of left sub-list\n puts \"splitting on root = #{root.value}\" if $debug\n \n # convert the left sub-list\n left_child = convert_linked_list_to_balanced_BST(head, left_half_size)\n # convert the right sub-list\n right_child = convert_linked_list_to_balanced_BST(root.right, right_half_size)\n # connect children to their paret\n root.left = left_child\n root.right = right_child\n puts \"build up sub-tree rooted on #{root.value}\" if $debug\n # return the root of BST\n return root\nend",
"def root_branches\n @root_branches = branches.select(&:root?)\n end",
"def split(grid, n)\n grid.split('/').each_slice(n).map do |rows|\n results = Array.new(rows.first.length / n) {[]}\n rows.map {|row| row.split('').each_slice(n).each_with_index {|r, i| results[i] << r.join('')}}\n results.map {|r| r.join('/')}\n end\nend",
"def half_nodes_count(root)\n if root.nil?\n puts 'Empty tree'\n return\n end\n half_nodes_count = 0\n queue = QueueWithLinkedList.new\n queue.enqueue(root)\n while !queue.isEmpty?\n node = queue.dequeue\n half_nodes_count += 1 if ((node.left && !node.right) || (!node.left && node.right))\n queue.enqueue(node.left) if node.left\n queue.enqueue(node.right) if node.right\n end\n half_nodes_count\n end",
"def build_tree(tree_size, input)\n nodes = Array.new(tree_size) { Node.new(nil, nil, nil) }\n\n tree_size.times do |i|\n line = input.next\n val, left, right = line.chomp.split.map(&:to_i)\n nodes[i].val = val\n nodes[i].left = nodes[left] unless left == -1\n nodes[i].right = nodes[right] unless right == -1\n end\n \n nodes.first\nend",
"def random_tree\n\t\t#range of possible angle separations between branches\n\t\t#big range seems to be ok, 30 to 60 works nice\n\t\t$angle_of_separation = (30..60).to_a\n\t\t#range of possible shrinkage values, will have a decimal in front of it\n\t\t#shrink determines how short each branch is\n\t\t$shrink_range = (4..6).to_a\n\t\t#split determines how many levels of branches there are\n\t\t#below 5 makes a pretty weak tree\n\t\t#above 7 makes a big blob of black\n\t\t$split_range = (5..7).to_a\n\t\t\n\t\t#Determines how many branches the current one splits off into\n\t\t$num_splits = rand(4)+2\n\t\t\n\t\t#how long the \"trunk\" is, height is 600\n\t\t#this gets ugly above 250\n\t\t$trunk = (150..250).to_a\n\t\t\n\t\t#pick a random number from the split range to be used as the number of splits\n\t\t$split_range = $split_range[rand($split_range.length)]\n\t\t#as a decimal, find the factor we will multiply future branches by\n\t\t@shrink = \"0.#{$shrink_range[rand($shrink_range.length)]}\".to_f\n\t\t#pick a random value for the angle of separation from the range\n\t\t$angle_of_separation = $angle_of_separation[rand($angle_of_separation.length)]\n\t\t\n\t\t#make a multidimensional array for branches\n\t\t@branches = []\n\t\t#start at the bottom, but not all the way down\n\t\t#move @x to the top of the trunk, ready for next branches\n\t\t@branches << [ [[@x, Height - @bot_margin], [@x, Height - $trunk[rand($trunk.length)]]] ] \n\t\t\n\t\tputs \"This output is from Random Tree\"\n\t\tputs \"Number of splits: #{$num_splits}\"\n\t\tputs \"Angle of separation: #{$angle_of_separation}\"\n\t\tputs \"Shrink range: #{$shrink_range[0]} to #{$shrink_range[$shrink_range.length-1]}\"\n\t\tputs \"Split range: #{$split_range}\"\n\t\tputs \"Initial branch length: #{$trunk[0]} to #{$trunk[$trunk.length-1]}\"\n\t\t\n\t end",
"def number_of_half_nodes_in_binary_tree(root)\n return 0 if !root\n count = 0\n queue = Queue.new()\n queue.enqueue(root)\n while(!queue.is_empty?)\n node = queue.dequeue\n\n count += 1 if (node.left_child && !node.right_child) || (!node.left_child && node.right_child)\n\n queue.enqueue(node.left_child) if node.left_child\n queue.enqueue(node.right_child) if node.right_child\n end\n count\nend",
"def build_tree(arr)\n if arr.empty?\n return nil\n end\n\n mid = arr.length/2\n root = Node.new(arr[mid])\n\n root.left = build_tree(arr[0...mid])\n root.right = build_tree(arr[(mid+1)..-1])\n\n root\nend",
"def left_child(root, length)\n child = root * 2 + 1\n if child < length\n return child\n end\n return\nend",
"def build_tree(s)\n bytes = s.bytes\n uniq_b = bytes.uniq\n nodes = uniq_b.map { |byte| Leaf.new(byte, bytes.count(byte)) }\n until nodes.length == 1\n node1 = nodes.delete(nodes.min_by(&:count))\n node2 = nodes.delete(nodes.min_by(&:count))\n nodes << Node.new(node1, node2, node1.count + node2.count)\n end\n nodes.fetch(0)\nend",
"def split(band, state=Children, depth=0, chars_parsed=0)\n\n\n $logger.debug \"Depth: #{depth.to_s} Chars: #{chars_parsed.to_s}\".magenta\n $logger.debug \"About to parse: #{band.string[chars_parsed..-1]}\".magenta\n\n delimiter = ','.ord\n name = \"\"\n items = state.new\n $logger.debug \"Created new Stack: '#{items.class.name}::#{items.inspect}'.\".magenta\n\n stopper = state.stopper ? state.stopper.chr : nil\n starter = state.starter ? state.starter.chr : nil\n\n\n while(car = band.getbyte) do\n chars_parsed += 1\n $logger.debug \"Processing: #{car.chr.light_yellow}\".green\n\n if letter? car\n $logger.debug \"LETTER\".yellow\n name << car\n else\n if car == delimiter\n $logger.debug \"SEPARATOR\".yellow\n items.push name\n name = \"\"\n else \n $logger.debug \"DELIMITER\".yellow\n if Token.have_starter? car\n scope = Token.starters[car]\n new_stopper = scope.stopper ? scope.stopper.chr : nil\n $logger.debug \"New unit: #{scope.name} will end with '#{new_stopper}'\"\n if !name.is_a? String or ( name.is_a? String and !name.strip.empty?)\n items.push name\n name = \"\"\n end\n name = split(band, scope, depth + 1, chars_parsed )\n $logger.debug \"Result: \" + \"[#{name.inspect}]\".light_yellow\n $logger.debug \"Back in stack: \" + \"#{items.inspect}\".light_cyan\n $logger.debug \"End of unit: #{state.name} will end with '#{state.stopper}'. Current char: '#{car.chr}'\"\n end\n if Token.have_stopper? car\n unless state.stopper == car\n $logger.debug \"Received '#{car.chr}'. Waiting for '#{stopper}' in #{state.name}.\".light_yellow\n raise MatchError, \n (\"Match Error. Extra '#{car.chr}' \" + \n \"in character #{chars_parsed.to_s}. \" + \n \"Waiting for '#{stopper}'.\").light_red\n end \n $logger.debug \"Reached '#{car.chr}'. End of unit '#{state.name}'.\"\n items.push name\n return items \n\n end\n end\n end\n end \n\n if depth > 0 \n raise UnterminatedString, \n \"Missing delimiters. Parsing finished with depth = '#{depth.to_s}'.\".light_red\n end\n items.push name unless name.empty?# flush the last name\n items\n\n end",
"def split_into_parts(*sizes); end",
"def buildTree(node,arr)\n node.value = arr.shift\n size = (arr.size/2.0).round\n if size > 0\n left, right = arr.each_slice( size ).to_a\n if left and left.count > 0\n node.left = TreeNode.new\n buildTree(node.left, left)\n end\n if right and right.count > 0\n node.right = TreeNode.new\n buildTree(node.right, right)\n end\n end\nend",
"def splitting(arr, size)\n total = 0\n final_array = []\n until total >= arr.length\n part_of_arr = arr[total..total + 1]\n final_array << part_of_arr\n total += size\n end\n return final_array\nend",
"def split\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 38 )\n\n\n return_value = SplitReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n\n root_0 = nil\n\n __K_SPLIT197__ = nil\n __LPAR198__ = nil\n __RPAR200__ = nil\n __Identificador201__ = nil\n __EOL203__ = nil\n string199 = nil\n var_local202 = nil\n\n\n tree_for_K_SPLIT197 = nil\n tree_for_LPAR198 = nil\n tree_for_RPAR200 = nil\n tree_for_Identificador201 = nil\n tree_for_EOL203 = nil\n\n begin\n root_0 = @adaptor.create_flat_list\n\n\n # at line 184:4: K_SPLIT LPAR string RPAR ( Identificador | var_local ) EOL\n __K_SPLIT197__ = match( K_SPLIT, TOKENS_FOLLOWING_K_SPLIT_IN_split_872 )\n if @state.backtracking == 0\n tree_for_K_SPLIT197 = @adaptor.create_with_payload( __K_SPLIT197__ )\n @adaptor.add_child( root_0, tree_for_K_SPLIT197 )\n\n end\n\n __LPAR198__ = match( LPAR, TOKENS_FOLLOWING_LPAR_IN_split_874 )\n if @state.backtracking == 0\n tree_for_LPAR198 = @adaptor.create_with_payload( __LPAR198__ )\n @adaptor.add_child( root_0, tree_for_LPAR198 )\n\n end\n\n @state.following.push( TOKENS_FOLLOWING_string_IN_split_876 )\n string199 = string\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, string199.tree )\n end\n\n __RPAR200__ = match( RPAR, TOKENS_FOLLOWING_RPAR_IN_split_878 )\n if @state.backtracking == 0\n tree_for_RPAR200 = @adaptor.create_with_payload( __RPAR200__ )\n @adaptor.add_child( root_0, tree_for_RPAR200 )\n\n end\n\n # at line 184:29: ( Identificador | var_local )\n alt_28 = 2\n look_28_0 = @input.peek( 1 )\n\n if ( look_28_0 == Identificador )\n alt_28 = 1\n elsif ( look_28_0 == DOUBLEDOT )\n alt_28 = 2\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n\n\n raise NoViableAlternative( \"\", 28, 0 )\n\n end\n case alt_28\n when 1\n # at line 184:30: Identificador\n __Identificador201__ = match( Identificador, TOKENS_FOLLOWING_Identificador_IN_split_881 )\n if @state.backtracking == 0\n tree_for_Identificador201 = @adaptor.create_with_payload( __Identificador201__ )\n @adaptor.add_child( root_0, tree_for_Identificador201 )\n\n end\n\n\n when 2\n # at line 184:44: var_local\n @state.following.push( TOKENS_FOLLOWING_var_local_IN_split_883 )\n var_local202 = var_local\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, var_local202.tree )\n end\n\n\n end\n __EOL203__ = match( EOL, TOKENS_FOLLOWING_EOL_IN_split_886 )\n if @state.backtracking == 0\n tree_for_EOL203 = @adaptor.create_with_payload( __EOL203__ )\n @adaptor.add_child( root_0, tree_for_EOL203 )\n\n end\n\n\n # - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n\n if @state.backtracking == 0\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\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\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 38 )\n\n\n end\n\n return return_value\n end",
"def split\n [self[0,self.length/2], self[self.length/2,self.length]]\nend",
"def / len\n a = []\n each_with_index do |x,i|\n a << [] if i % len == 0\n a.last << x\n end\n a\n end",
"def test_each_leaf\n setup_test_tree\n\n nodes = []\n @root.each_leaf { |node| nodes << node }\n\n assert_equal(3, nodes.length, \"Should have THREE LEAF NODES\")\n assert(!nodes.include?(@root), \"Should not have root\")\n assert(nodes.include?(@child1), \"Should have child 1\")\n assert(nodes.include?(@child2), \"Should have child 2\")\n assert(!nodes.include?(@child3), \"Should not have child 3\")\n assert(nodes.include?(@child4), \"Should have child 4\")\n end",
"def split_old_bin(table, new_table, i, node, node_hash, forwarder); end",
"def bst_sequences(root)\n\nend",
"def solution(t)\n # write your code in Ruby 2.2\n depth = 0\n childs = []\n\n childs << t.l if t.l\n childs << t.r if t.r\n\n while not childs.empty? do\n depth += 1\n\n cc = []\n childs.each do |t|\n cc << t.l if t.l\n cc << t.r if t.r\n end\n\n childs = cc\n end\n\n depth\nend",
"def split!(side)\n raise ArgumentError, \"bad split\" unless int?(side)\n i = self[side]\n self[side] = Pair.new.tap do |child|\n child.depth = depth + 1\n child.parent = self\n child.parent_side = side\n child.left = i/2\n child.right = i - child.left\n end\n nil\n end",
"def visit_path_to_root(leaf_id)\n node = @leaf_count + leaf_id\n while node > 0\n yield node\n node = HashTree.parent(node)\n end\n self\n end",
"def draw_tree(pen, length)\n\tangle = 20\n\tmin_length = 4\n\tshrink_rate = 0.7\n\treturn if length < min_length\n\tpen.move length\n\tpen.turn_left angle\n\tdraw_tree pen, length * shrink_rate\n\tpen.turn_right angle * 2\n\tdraw_tree pen, length * shrink_rate\n\tpen.turn_left angle\n\tpen.move -length\nend",
"def cutTree(array)\n if array.sort == array\n return array.length\n end\n array_copied = array.dup\n i = 0\n count = 0\n while i <= array.length\n array = array_copied.dup\n array.delete_at(i)\n if (array == array.sort)\n count += 1\n end\n i += 1\n end\n return count\nend",
"def build_tree( arr, first_index = 0, last_index = arr.length - 1 )\n return nil if first_index > last_index\n \n middle_of_array = (first_index + last_index)/2\n \n root = Node.new(arr[middle_of_array])\n \n root.left_child = build_tree(arr, first_index, middle_of_array - 1)\n root.right_child = build_tree(arr, middle_of_array + 1, last_index)\n \n return root \n end",
"def display_tree(an_array)\r\n an_array.length\r\n count = 1\r\n (count - 1).upto(count) do\r\n end\r\nend",
"def clean_tree(branch)\n\n branch.children = branch.children.inject(Children.new(branch)) do |r, c|\n cc = if c.name == 'sequence' and c.children.size == 1\n c.children.first\n else\n c\n end\n r << clean_tree(cc)\n end\n\n branch\n end",
"def renumber_full_tree\n indexes = []\n n = 1\n transaction do\n for r in roots # because we may have virtual roots\n n = 1 + r.calc_numbers(n, indexes)\n end\n for i in indexes\n base_set_class.update_all(\"#{left_col_name} = #{i[:lft]}, #{right_col_name} = #{i[:rgt]}\", \"#{self.class.primary_key} = #{i[:id]}\")\n end\n end\n ## reload?\n end",
"def custom_tree\n\t\t#if they haven't made a shrink range/trunk yet, make one for them\n\t\tif $shrink_range.empty?\n\t\t\t$shrink_Range = (4..6).to_a\n\t\tend\n\t\tif $trunk.empty?\n\t\t\t$trunk = (175..250).to_a\n\t\tend\n\t\t\n\t\t@shrink = \"0.#{$shrink_range[0]}\".to_f\n\t\t#Height is 600, so y is in (0,600)\n\t\t$angle_of_separation = (@window.mouse_y / 10).to_i #this gives max of 60 degree angle, min of 0 (line)\n\t\t\n\t\t@branches = []\n\t\t@branches << [ [[@x, Height - @bot_margin], [@x, Height - $trunk[0]]] ]\n\t\t#Width is 800, so x is in (0,800)\n\t\t$num_splits = (((@window.mouse_x) / 100).to_i)+2 #this gives max of 8+2=10 splits, min of 2\n\t\t\n\t\tputs \"This output is from Custom Tree\"\n\t\tputs \"Number of splits: #{$num_splits}\"\t\n\t\tputs \"Angle of separation: #{$angle_of_separation}\"\n\t\tputs \"Shrink range: #{$shrink_range[0]} to #{$shrink_range[$shrink_range.length-1]}\"\n\t\tputs \"Split range: #{$split_range}\"\t\t\n\t\tputs \"Initial branch length: #{$trunk[0]} to #{$trunk[$trunk.length-1]}\"\n\t end",
"def split codons, is_splitter_func\n list = []\n node = []\n codons.each_with_index do | c, pos |\n # p [c,pos]\n if is_splitter_func.call(c)\n node.push c\n size = node.size\n # p node\n list.push FrameCodonSequence.new(node,pos+1-size) if size > @min_size_codons\n node = []\n end\n node.push c # always push boundary codon\n end\n list\n end",
"def build_tree(arr)\n\ntree = []\n\ntree.push(Node.new(arr[0]))\n\n arr[1..-1].each do |i|\n new_node = Node.new(i)\n\n condition = false\n current = tree[0]\n until condition == true\n if i > current.value && current.find_right_child.count == 0\n new_node.create_parent(current)\n current.create_right_child(new_node)\n tree.push(new_node)\n condition = true\n elsif i < current.value && current.find_left_child.count == 0\n new_node.create_parent(current)\n current.create_left_child(new_node)\n tree.push(new_node)\n condition = true\n elsif i > current.value && current.find_right_child.count == 1\n current = current.find_right_child[0]\n elsif i < current.value && current.find_left_child.count == 1\n current = current.find_left_child[0]\n end\n end\n end\n tree\nend",
"def challenge4\n\t@size = length(@rootNode)\n\tputs \"Challenge #4 solution: \"\n\tputs \"Number of nodes in tree: \" + @size.to_s\n\tputs \"-----------------------------------\"\nend",
"def renumber_full_tree\n indexes = []\n n = 1\n transaction do\n for r in roots # because we may have virtual roots\n n = r.calc_numbers(n, indexes)\n end\n for i in indexes\n base_set_class.update_all(\"#{left_col_name} = #{i[:lft]}, #{right_col_name} = #{i[:rgt]}\", \"#{self.class.primary_key} = #{i[:id]}\")\n end\n end\n ## reload?\n end",
"def build_tree(item_list = @sorted_list,root_node = nil)\n #sorted root sorts and removes duplicates from the item list\n if (item_list[0] == nil)\n return nil\n else\n start = 0\n end_of_item_list = item_list.length - 1\n mid = (start + item_list.length) / 2\n #set the root node then start creating a tree node for the left and right side of the array\n #Then after that branch is created attach it to the correct position\n root_node = Node.new(item_list[item_list.length/2])\n root_node.right = build_tree(item_list[0,mid],root_node) \n root_node.left = build_tree(item_list[mid+1,end_of_item_list],root_node)\n return root_node\n end\n \n end",
"def build_tree array\n\t\t@root = Node.new array[0]\n\t\t@nodes += 1\n\t\tarray[1..-1].each do |var|\n\t\t\tinsert(@root,var)\n\t\tend\n\tend",
"def chunked_repo_sets \n all_repositories = Dir.entries(OBSERVATIONS_DIR).select{|x| x != '.' && x != '..' && x != '.DS_Store'}.map{|x| \"#{OBSERVATIONS_DIR}/\" + x}\n stride = 500\n start_i = 0\n end_i = stride - 1\n repo_count = all_repositories.size\n repo_sets = Array.new\n while start_i < repo_count do\n end_i = repo_count - 1 if end_i >= repo_count\n next_set = all_repositories[start_i..end_i]\n repo_sets << next_set\n start_i = end_i + 1\n end_i += stride\n end\n repo_sets\nend",
"def right_child(root, length)\n child = root * 2 + 2\n if child < length\n return child\n end\n return\nend",
"def bfs\n return [] unless @root\n q = [@root]\n out = []\n\n until q.empty? do\n current = q.shift\n out << { key: current.key, value: current.value }\n q << current.left if current.left\n q << current.right if current.right\n end\n\n return out\n end",
"def construct_tree(arr)\n root = TreeNode.new(arr.shift)\n xtd = [root]\n while !xtd.empty? && !arr.empty?\n cur_node = xtd.shift\n a, b = arr.shift(2) # doesn't matter if arr.size < 2. in this case, a, b might be nil\n cur_node.left = a.nil? ? nil : TreeNode.new(a)\n cur_node.right = b.nil? ? nil : TreeNode.new(b)\n xtd << cur_node.left unless cur_node.left.nil?\n xtd << cur_node.right unless cur_node.right.nil?\n end\n root\nend",
"def parse_branches\n branches = []\n\n pos = @s.pos\n res = parse_seq\n if res\n branches << res\n else\n @s.pos = pos\n return branches\n end\n\n while @s.scan(/\\s*\\|\\s*/)\n branches << expect(:parse_seq)\n end\n Branches.new branches\n end",
"def all_branches\n %x( git branch ).gsub!('*', '').gsub!(' ', '').split(\"\\n\")\nend",
"def _num_of_children(root)\n return [ 0, nil, nil ] if root.nil?\n #\n n = root.lnode.nil? ? 0 : 1\n n += root.rnode.nil? ? 0 : 1\n [n, root.lnode, root.rnode]\n end",
"def subtrees!\n trees = Array.new\n subtrees {|tree| trees.push(tree)}\n return trees\n end",
"def setBredthLevels\n stack = []\n queue = []\n level = 0\n\n queue.push(@root)\n\n while(queue.size != 0)\n node = queue.shift\n\n stack.append([node.name, node.level])\n\n node.children.each_with_index do |child, i|\n level += 1 if i == 0\n child.level = level\n queue.push(child)\n end\n end\n\n return stack\n end",
"def build_tree(arr, root, i, n)\n\tif i < n\n\t\troot = TreeNode.new(arr[i])\n\t\troot.left = build_tree(arr, root.left, i*2+1, n)\n\t\troot.right = build_tree(arr, root.right, i*2+2, n)\n\tend\n\treturn root\nend",
"def test_split_block_length\n in_str = \"0|abcd|you>me(100)|100.200|sdfg\"\n out_arr = [\"0\", \"abcd\", \"you>me(100)\", \"100.200\", \"sdfg\"]\n assert_equal out_arr, split_block(in_str)\n end",
"def calc_tree\n tree = []\n n = 1\n while n <= @n\n result = []\n result = [[0, 1]] if n == 1\n tree.each do |row|\n line1 = []\n line2 = []\n row.each_with_index do |elem, i|\n line1 << \"#{elem}0\" if i.positive?\n line2 << \"#{elem}0\" if i.zero?\n line2 << \"#{elem}1\"\n end\n result << line1 unless row.count == 1\n result << line2\n end\n tree = result\n n += 1\n end\n tree\n end",
"def branches; end",
"def split_into_runs par\n sor=0\n sor_level=par['level']\n run = Hash.new\n run['sor']=sor\n chars=par['characters']\n len=chars.length\n par['runs']=Array.new\n 0.upto(len - 1) do |index|\n char=chars[index]\n next unless char['level']\n if char['level'] != sor_level\n run['sor']=sor\n run['sorType']=chars[sor]['level'].odd? ? 'R' : 'L'\n run['eor']=index\n run['eorType']=chars[index]['level'].odd? ? 'R' : 'L'\n sor=index\n par['runs'].push run\n run=Hash.new\n sor_level=char['level']\n end\n end # upto\n run['sor']=sor\n run['sorType']=chars[sor]['level'].odd? ? 'R' : 'L'\n run['eor']=len\n run['eorType']=par['level'].odd? ? 'R' : 'L'\n par['runs'].push run\n end",
"def make_tree(pre, inord)\n return if pre.size == 0\n root_node = Node.new(pre[0])\n idx = inord.index(pre[0])\n root_node.left = make_tree(pre[1..idx], inord[0...idx])\n root_node.right = make_tree(pre[idx+1...pre.size], inord[idx+1...inord.size])\n return root_node\nend",
"def split_number(number, length)\n [number[0...length], number[length..-1]]\n end",
"def build_tree(arr)\n #take array, turn into bt with node objs\n return nil if arr.empty?\n\n mid = (arr.size - 1)/2\n current_node = Node.new(arr[mid])\n\n current_node.left = build_tree(arr[0...mid])\n current_node.right = build_tree(arr[(mid+1)..-1])\n \n current_node\n end",
"def half_size!\n new_stack = Array.new(@stack.length/2)\n new_stack.each_index { |i| new_stack[i] = @stack[i] }\n @stack = new_stack\n end",
"def find_longest_path_length_to_leaf(source)\n longest = 0\n\n find_leaves.each do |a_leaf|\n begin\n temp_result = find_longest_path_length(source,a_leaf)\n rescue\n temp_result = 0\n end\n\n longest = [longest, temp_result].max if temp_result\n end\n\n longest\n end",
"def render\n path = [[root,0]]\n current_height = 0\n\n while (current, height = path.shift)\n next if nil_node_proc.call(current)\n # don't print empty leafs\n next if height >= max_height\n\n # height increased: we print the / \\ separator\n if height > current_height\n current_height += 1\n print_height_separator(current_height)\n end\n\n current.render(padding(height))\n\n # navigate left\n if !nil_node_proc.call(current.l)\n path.push([current.l, height + 1])\n elsif height < max_height\n path.push([EmptyNode.from_node(current), height + 1])\n end\n\n # navigate right\n if !nil_node_proc.call(current.r)\n path.push([current.r, height + 1])\n elsif height < max_height\n path.push([EmptyNode.from_node(current), height + 1])\n end\n end\n puts \"\\n\"\n end",
"def divide_if_needed(defer_update = false)\n if children.size > MAX_SIZE\n raise \"node is not lowest level and can therefore not be divided: #{self}\" unless lowest_level?\n @children = (0...MAX_SIZE).collect do |i|\n leaves = children.find_all {|leaf| leaf.shash_array[level] == i}\n NonLeafNode.new(self, leaves)\n end\n children.each {|child| child.divide_if_needed(defer_update)}\n end\n update_shash(false) unless defer_update\n end",
"def bit_split(x, lens)\n ret = []\n lens.each {|l|\n ret << (x & ((1 << l)-1))\n x >>= l\n }\n ret\n end",
"def splitDirectory(directory, array, hash)\n array.each do |num|\n splitData(directory, hash[num])\n end\nend",
"def build_tree(data, parent = nil)\n return if data.size.zero?\n center = half(data)\n value = data[center]\n @depth_first << value\n\n # Recusion to split halves until zero then execute logic\n build_tree(l_half = data[0...center], value)\n build_tree(r_half = data[center + 1..-1], value)\n\n # Node creation and set node properties\n l_child = l_half[half(l_half)]\n r_child = r_half[half(r_half)]\n Node.new(value, parent, l_child, r_child)\n end",
"def build_tree(arr)\n @root = insert_node(nil, arr.shift)\n arr.each { |value| insert_node(@root, value) }\n end",
"def break_off_crumbs(uri)\n crumbs = []\n split_uri = uri.split('/')\n split_uri.each_with_index do |crumb, i|\n crumbs << make_crumb([split_uri[0..i].join('/')])\n end\n crumbs\n end",
"def make_binary_tree(sorted_array)\n if sorted_array.length == 0\n return nil\n elsif sorted_array.length == 1\n return TreeNode.new(sorted_array[0])\n end\n divide_index = sorted_array.length / 2\n tree_node = TreeNode.new(sorted_array[divide_index])\n tree_node.left = make_binary_tree(sorted_array[0..divide_index-1])\n tree_node.right = make_binary_tree(sorted_array[divide_index+1..sorted_array.length-1])\n return tree_node\nend",
"def question_2(array)\n bst = BST.new\n mid_element = array[array.length/2] #get the middle element of the array\n bst.insert(mid_element) #insert the middle into bst\n array.delete_at(array.length/2) # delete the middle value of the array\n array.each do |el| #iterate through the rest of the array and insert\n bst.insert(el)\n end\nend",
"def grow_tree(root, nodes, adopt_fn)\n kids = nodes.select { |w| adopt_fn.call(root, w) }\n branches = kids.map { |k| grow_tree(k, nodes - [root], adopt_fn) }\n { root => branches.reduce(&:merge) }\nend",
"def split_top(n=nil)\n results = []\n tail = self\n while true\n head, new_tail = tail.chdir('*')\n results << head\n if new_tail.empty?\n return results\n end\n if tail == new_tail\n raise InfinitePathSetError.new(self)\n end\n tail = new_tail\n end\n results\n end",
"def build_tree(array)\n\t\t@root_node = Node.new(array[array.length / 2])\n\t\tarray[array.length / 2] = nil\n\t\tcounter = 0\n\t\tuntil counter == array.length\n\t\t\tset_value(array[counter], @root_node) if array[counter] != nil\n\t\t\tcounter += 1\n\t\tend\n\n\tend",
"def minimum_tree_for_leafs(ids)\n # 1. Find all ids in leafs id_path\n # 2. Fetch those ids by tree depth order.\n id_in = ids.join(',')\n leafs = self.find(:all, :conditions => \"id in (#{id_in})\")\n id_paths = leafs.collect{ |l| l.id_path }\n id_in_paths = id_paths.join(',')\n self.find(:all, :conditions => \"id in (#{id_in_paths})\", :order => \"id_path asc\")\n end",
"def build_tree(list)\n root = Node.new(list[0], nil)\n list[1...list.length].each do |item|\n current_node = root\n while !item.nil?\n if item > current_node.value\n if current_node.right_child.nil?\n current_node.right_child = Node.new(item, current_node)\n item = nil\n else\n current_node = current_node.right_child\n end\n elsif item < current_node.value\n if current_node.left_child.nil?\n current_node.left_child = Node.new(item, current_node)\n item = nil\n else\n current_node = current_node.left_child\n end\n else\n item = nil\n end\n end\n end\n root\nend",
"def split_in_chunks(data)\n result = []\n\n index = 0\n while index != data.size\n remaining = (data.size - index)\n if remaining > DATA_CHUNK_SIZE\n result << data[index, DATA_CHUNK_SIZE]\n index += DATA_CHUNK_SIZE\n else\n result << data[index, remaining]\n index = data.size\n end\n end\n result\n end",
"def possible_branch_nodes\r\n max_depth = max_category_depth\r\n article_categories.select {|ac| ac.parent_id.nil? || (ac.depth < max_depth)}\r\n end",
"def bfs\n return [] if @root.nil?\n end",
"def split_blocks(array)\n array.inject( [ [] ] ) do |array_of_blocks, val|\n if val == -1\n array_of_blocks << [-1]\n array_of_blocks << [] \n else \n array_of_blocks[-1] << val\n end\n array_of_blocks\n end\nend",
"def all\n root.branch\n end",
"def build_tree(arr, start_index = 0, end_index = arr.length - 1)\n return nil if start_index > end_index\n\n mid = (start_index + end_index) / 2\n curr_root = arr[mid].is_a?(Node) ? arr[mid] : Node.new(arr[mid])\n curr_root.left = build_tree(arr, start_index, mid - 1)\n curr_root.right = build_tree(arr, mid + 1, end_index)\n curr_root\n end",
"def build_tree(arr)\n @root = Node.new(arr.shift)\n arr.each { |data| insert_data(data, @root) }\n end",
"def build_tree_unsorted(arr)\n root = nil\n arr.each do |item|\n root = insert_tree(item, root)\n end\n\n root\nend",
"def split(position)\n end",
"def split(position)\n end",
"def grow( )\n\t\tnew_leaves = [ ]\n\t\[email protected] do |leaf|\n\t\t\tif @forward\n\t\t\t\tsearch = lambda { |song| leaf.song.last == song.first }\n\t\t\telse\n\t\t\t\tsearch = lambda { |song| leaf.song.first == song.last }\n\t\t\tend\n\t\t\t$songs.find_all(&search).each do |next_song|\n\t\t\t\tnew_leaves << leaf.add_next(next_song)\n\t\t\tend\n\t\tend\n\t\t@leaves = new_leaves\n\tend",
"def binary_tree_paths(root)\n paths = []\n binary_tree_paths_recursive(root, [], paths)\n\n paths.map do |path|\n path.join(\"->\")\n end\nend",
"def level_order_bottom(root)\n res = []\n return res if root.nil?\n\n queue = [root]\n until queue.empty?\n cur = []\n\n queue.length.times do \n node = queue.shift()\n cur << node.val\n queue << node.left if node.left\n queue << node.right if node.right\n end\n res << cur\n end\n res.reverse!\nend",
"def bfs_helper(node, list, level)\n return list if node.nil?\n \n # creating array of arrays for each level in tree\n list[level] = [] if list[level].nil?\n list[level] << {key: node.key, value: node.value}\n\n bfs_helper(node.left, list, level + 1)\n bfs_helper(node.right, list, level + 1)\n end",
"def joker_split\n jokers_loci = self.find_jokers\n \n top_pos = jokers_loci.min\n \n cards_above = @deck.slice!(0,top_pos)\n \n jokers_loci = self.find_jokers\n bottom_pos = jokers_loci.max\n cards_below = @deck.slice!(bottom_pos+1,52) # 52 is max possible cards below last card\n \n @deck.insert(0, cards_below) if (cards_below)\n @deck.insert(-1, cards_above) if (cards_above)\n @deck.flatten! \n end",
"def split; end",
"def branches(*nodes)\n branches = []\n nodes = [changelog.tip] if nodes.empty?\n # for each node, find its first parent (adam and eve, basically)\n # -- that's our branch!\n nodes.each do |node|\n t = node\n # traverse the tree, staying to the left side\n # node\n # / \\\n # parent1 parent2\n # .... ....\n # This will get us the first parent. When it's finally NULL_ID,\n # we have a root -- this is the basis for our branch.\n loop do\n parents = changelog.parents_for_node t\n if parents[1] != NULL_ID || parents[0] == NULL_ID\n branches << [node, t, *parents]\n break\n end\n t = parents.first # get the first parent and start again\n end\n end\n \n branches\n end",
"def setup_test_tree\n @root << @child1\n @root << @child2\n @root << @child3 << @child4\n end",
"def build_tree(array)\n return nil if array.empty?\n\n mid = (array.length - 1) / 2\n node = Node.new(array[mid])\n node.left = build_tree(array[0...mid])\n node.right = build_tree(array[mid+1..-1])\n node\n end",
"def build_move_tree\n arr = [root_node]\n nodes = []\n\n until arr.empty?\n this_pos = arr.shift\n arr += new_move_positions(this_pos)\n nodes << PolyTreeNode.new(this_pos)\n end\n\n nodes\n end",
"def build_tree(array)\n return nil if array.empty?\n \n middle = (array.size - 1) / 2\n root_node = Node.new(array[middle])\n \n root_node.left = build_tree(array[0...middle])\n root_node.right = build_tree(array[(middle + 1)..-1])\n \n root_node\n end",
"def kth_to_last_node(i, root)\n nodes = [root]\n current = root\n\n while current = current.next\n nodes << current\n if nodes.length > i\n nodes.shift\n end\n end\n\n nodes.first\nend",
"def build_move_tree\n queue = [@root_node]\n until queue.empty?\n current_node = queue.shift\n possible_positions = new_move_positions(current_node.value) #[]\n possible_positions.each do |position| #[1,2]\n child_node = PolyTreeNode.new(position) #node object(value = 1,2)\n child_node.parent = current_node\n current_node.add_child(child_node)\n queue << child_node\n end\n end\n end",
"def test_breadth_each\n j = Tree::TreeNode.new(\"j\")\n f = Tree::TreeNode.new(\"f\")\n k = Tree::TreeNode.new(\"k\")\n a = Tree::TreeNode.new(\"a\")\n d = Tree::TreeNode.new(\"d\")\n h = Tree::TreeNode.new(\"h\")\n z = Tree::TreeNode.new(\"z\")\n\n # The expected order of response\n expected_array = [j,\n f, k,\n a, h, z,\n d]\n\n # Create the following Tree\n # j <-- level 0 (Root)\n # / \\\n # f k <-- level 1\n # / \\ \\\n # a h z <-- level 2\n # \\\n # d <-- level 3\n j << f << a << d\n f << h\n j << k << z\n\n # Create the response\n result_array = Array.new\n j.breadth_each { |node| result_array << node.detached_copy }\n\n expected_array.each_index do |i|\n assert_equal(expected_array[i].name, result_array[i].name) # Match only the names.\n end\n end",
"def build_move_tree # Node[0,0]\n @root_node = PolyTreeNode.new(@start_pos)\n tree = [@root_node] #after first round tree = []\n while !tree.empty?\n #after line 39 => tree => [N(v(2,1)), N(v(1,2))]\n res = tree.shift #tree = [] # res => TreeNode with the value of [2,1]\n positions = new_move_positions(res.value) # positions => [[0,2],[1,3], [3,3], [4,2], [5,0]]\n #tree => [N(v(1,2))]\n positions.each do |n| # n=> [2,1]\n nd = PolyTreeNode.new(n) # nd=> Node with with the value of [2,1]\n res.add_child(nd)\n tree << nd\n end # tree => [N(v(1,2)),N [0,2],[1,3], [3,3], [4,2], [5,0]]\n end\n end",
"def trim_tree\n\t\t@corridor_seeds.each { |seed| check_branch(corridor_map[seed]) }\n\tend",
"def split_into_chunks_of(chunk_size, suffix_length = 3)\n if chunk_size.is_a?(Integer) && suffix_length.is_a?(Integer)\n @splitter = Splitter.new(self, chunk_size, suffix_length)\n else\n raise Error, <<-EOS\n Invalid arguments for #split_into_chunks_of()\n +chunk_size+ (and optional +suffix_length+) must be Integers.\n EOS\n end\n end",
"def build_tree_2(data_array)\n root = nil\n \n data_array.each do |elem|\n node = insert_node(root, nil, elem) \n\troot ||= node\n end\n \n root\nend",
"def branches\n if ancestor_ids.empty? then\n nil\n else\n read_attribute(self.base_class.structure_column).to_s.split(',')\n end\n end",
"def bfs(tree)\n Enumerator.new do |yielder|\n queue = [tree]\n while !queue.empty?\n node = queue.shift\n children = node[1..-1]\n yielder << node.first\n children.each do |child|\n queue << child\n end\n end\n end\nend"
] | [
"0.59835863",
"0.59456754",
"0.58433086",
"0.57731164",
"0.55377686",
"0.55249125",
"0.54187435",
"0.53409517",
"0.5265363",
"0.5238305",
"0.5237193",
"0.52317846",
"0.5231493",
"0.5222523",
"0.5216074",
"0.52154464",
"0.52142787",
"0.52111673",
"0.5108704",
"0.5107876",
"0.5107541",
"0.50935835",
"0.5087353",
"0.5079088",
"0.50752807",
"0.5057127",
"0.5053349",
"0.5052466",
"0.50417495",
"0.50364256",
"0.50266564",
"0.5020269",
"0.5009153",
"0.5002034",
"0.5001959",
"0.49935466",
"0.4984069",
"0.49803337",
"0.49699378",
"0.49636936",
"0.4957103",
"0.4953925",
"0.4952707",
"0.49500617",
"0.49453908",
"0.49334136",
"0.49314752",
"0.49300265",
"0.49292672",
"0.49259016",
"0.49168852",
"0.49148536",
"0.49114475",
"0.4910938",
"0.49083602",
"0.49069023",
"0.49063092",
"0.49037078",
"0.48986447",
"0.48878065",
"0.48869303",
"0.48842898",
"0.48837933",
"0.4882323",
"0.488105",
"0.48697126",
"0.4869386",
"0.48652413",
"0.48644468",
"0.4858262",
"0.48568887",
"0.48435885",
"0.48413733",
"0.48408917",
"0.48389995",
"0.48369873",
"0.4836427",
"0.4835897",
"0.48232424",
"0.48232424",
"0.4802935",
"0.4799915",
"0.47913575",
"0.47859767",
"0.47810733",
"0.47780013",
"0.4777669",
"0.47757125",
"0.4764547",
"0.47626072",
"0.47623375",
"0.47582078",
"0.4757795",
"0.4756549",
"0.47551346",
"0.47506395",
"0.47501674",
"0.47496784",
"0.4747627",
"0.47471067"
] | 0.63477045 | 0 |
find the next node from the current one based on the given key | def next_node(current, key)
return nil, nil unless current[:key_length]
next_key = key[0...current[:key_length]]
if current[:nodes].has_key?(next_key)
return current[:nodes][next_key], key[next_key.length..-1]
else
return nil, nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_key key\n node = self.head\n while node\n return node if node.key == key\n nc = node.child \n while nc\n return nc if nc.key == key\n ncs = nc.sibling\n while ncs \n return ncs if ncs.key == key\n ncs = ncs.sibling\n end\n nc = nc.child\n end\n node = node.sibling\n end\n end",
"def search key, lambda = {}\n node = head\n while node.next_ != nil && node.key != key\n node = node.next_\n end\n node\n end",
"def search key\r\n #start searching from the head (if the head is NULL, get out of the function and return NULL)\r\n node = @head\r\n #while there's still any unsearched node in the list (you haven't reach the end of the list) and the wanted node hasn't been found\r\n while (node != nil) && (node.get_value != key)\r\n #search the wanted node linearly using the next pointer\r\n node = node.get_next_node\r\n #You MUST keep the order of the logical checking or you'll get an error for trying to check the key of NULL\r\n end\r\n #return a pointer to the wanted node (if no node with the key appears in the list, this will return NULL)\r\n return node\r\n end",
"def get_node(key); 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 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(key)\r\n \t\t\t# Start at beginning of the List\r\n \t\t\tcurrent = @head\r\n \t\t\t# Go through list until nil\r\n\t\t\twhile current\r\n\t\t\t\t# If matching key is found return value at node\r\n\t\t\t\tif current.key == key\r\n\t\t\t\t\treturn current.value\r\n\t\t\t\tend\r\n\t\t\t\t# Go to next node\r\n\t\t\t\tcurrent = current.next\r\n\t\t\tend\r\n \t\tend",
"def find(key)\n if @root == nil\n return nil\n elsif @root.key == key\n return @root.value\n else\n current_node = @root\n while current_node != nil\n if key == current_node.key\n return current_node.value\n elsif key <= current_node.key\n current_node = current_node.left\n else\n current_node = current_node.right\n end\n end\n end \n end",
"def find(key)\n return nil if @root == nil\n\n current = @root\n\n until current == nil\n if key == current.key\n return current.value\n elsif key < current.key\n current = current.left\n else\n current = current.right\n end\n end\n\n return nil\n end",
"def [](key)\n index = self.index(key, @items.length)\n if !@items[index].nil?\n current = @items[index].head\n until current.nil?\n if current.key === key\n return current.value\n else\n current = current.next\n end\n end\n end\n end",
"def [](key)\n if @items[index(key,size)] != nil\n current = @items[index(key, size)].head #chooses head node\n while current != nil\n if current.key == key\n return current.value\n else\n current = current.next\n end\n end\n end\n end",
"def next_key\n @next && @next.key\n end",
"def find(key)\n current = @root\n\n while current != nil\n if current.key > key\n current = current.left\n elsif current.key < key\n current = current.right\n else\n return current.value\n end\n end\n return nil\n end",
"def find(key)\n find_node(checked_get_node(key))\n end",
"def find(key)\n return nil if @root.nil?\n\n current = @root\n\n while current != nil\n if key == current.key\n return current.value\n elsif key < current.key\n current = current.left\n else\n current = current.right\n end \n end \n\n return nil\n end",
"def get(key)\n found = @hash[key]\n\n if found\n @list.move_node_to_head(found)\n return found\n end\n\n -1\n end",
"def find(key)\n x = find_nearest_node(key)\n return node_value(x) if node_compare(x, key) == 0\n nil # nothing found\n end",
"def find(key)\n x = find_nearest_node(key)\n return node_value(x) if node_compare(x, key) == 0\n nil # nothing found\n end",
"def fetch_node(key)\n node = fetch_node_nt(key)\n raise unless node\n node\n end",
"def find_node(key)\n return nil if @root == nil\n node = @root.find_vertical(key)\n (node.nil? || node.value.nil? ? nil : node)\n end",
"def find_node(search_key)\n x = @header\n @level.downto(0) do |i|\n #puts \"on level #{i}\"\n while x.forward[i] and x.forward[i].key < search_key\n #puts \"walked node #{x.key} on level #{i}\"\n x = x.forward[i]\n end\n end \n x = x.forward[0] if x.forward[0].key == search_key\n return x\n end",
"def find(key)\n return nil if @root.nil?\n current = @root\n while current != nil\n if key == current.key\n return current.value\n elsif key > current.key \n current = current.right\n else\n current = current.left\n end\n end\n end",
"def find(key)\n return nil if @root.nil?\n\n current = @root\n while current\n if key > current.key\n current = current.right\n elsif key < current.key\n current = current.left\n else\n return current.value\n end\n end\n\n return nil\n end",
"def find_helper(current_node, key)\n return nil if current_node.nil?\n return current_node if current_node.value == key\n\n if key < current_node.value\n return find_helper(current_node.left_node, key)\n else\n return find_helper(current_node.right_node, key)\n end\n end",
"def find_key(key)\n leaf, stack = walk_towards_key(key)\n return nil if leaf && leaf.peek_item.key != key\n leaf\n end",
"def get(key)\n i = key.hash % @table.size\n node = @table[i]\n while node\n return node.value if key == node.key\n node = node.next\n end\n nil\n end",
"def find(key)\n current_and_parent_pair = find_current_and_parent_nodes(key)\n if current_and_parent_pair[:current] \n return current_and_parent_pair[:current].value\n else\n return nil\n end\n end",
"def peek_item(key)\n leaf = find_key(key)\n return nil unless leaf\n leaf.peek_item\n end",
"def findKey( node, key)\n index = 0\n while (index < node.n && node.keys[index] < key) \n\t\t\tindex += 1\n end\n return index\n end",
"def find(key, current = @root)\n if @root == nil\n return nil\n elsif key == current.key\n return current.value\n elsif key <= current.key\n find(key, current.left)\n else\n find(key, current.right)\n end\n end",
"def find(key)\n if @root.nil?\n return nil\n end\n\n current_node = @root\n\n while current_node != nil\n if current_node.key == key\n return current_node.value\n elsif current_node.key < key\n current_node = current_node.right\n elsif current_node.key > key\n current_node = current_node.left\n end\n end\n print \"No value found\"\n end",
"def get(key)\n node = @node_map[key]\n if node\n # clip us out of the chain\n clip_node_from_list(node)\n insert_node_at_head(node)\n node.val\n else\n -1\n end\n end",
"def find(key)\n current_node = @root \n return find_helper(current_node, key)\n end",
"def find_helper(current_node, key)\n return nil if current_node.nil?\n return current_node.value if current_node.key == key\n\n if key < current_node.key\n current_node = find_helper(current_node.left, key)\n else\n current_node = find_helper(current_node.right, key)\n end\n end",
"def walk_towards_key(key)\n stack = []\n\n # Start with root node\n in_node = root\n node_id = NodeID.new\n\n # Iterate until node is no longer inner\n while in_node.inner?\n stack.push [in_node, node_id]\n\n return nil, stack if v2? && in_node.common_prefix?(key)\n\n # Select tree branch which has key\n # we are looking for, ensure it is not empty\n branch = node_id.select_branch(key)\n return nil, stack if in_node.empty_branch?(branch)\n\n # Descend to branch node\n in_node = descend_throw in_node, branch\n if v2?\n if in_node.inner?\n node_id = NodeID.new :depth => in_node.depth,\n :key => in_node.common\n else\n node_id = NodeID.new :depth => 64,\n :key => in_node.key\n end\n\n else\n # Get ID of branch node\n node_id = node_id.child_node_id branch\n end\n end\n\n # Push final node (assumably corresponding to key)\n stack.push [in_node, node_id]\n\n # Return final node (corresponding to key) and stack\n return in_node, stack\n end",
"def node_for(path_or_key)\n key = PathEx::Key.new(path_or_key)\n return nil if key.blank?\n\n child = self.children.find { |c| c.name == key.head }\n child.nil? ? nil : key.has_tail? ? child.node_for(key.tail) : child\n end",
"def find(key, current=@root)\n return unless current\n\n return current.value if current.key == key\n return find(key, current.left) if key < current.key\n return find(key, current.right) if key > current.key\n end",
"def find(key)\n return if !@root\n curr = @root\n while curr \n if curr.key == key\n return curr.value\n elsif curr.key > key\n curr = curr.left\n else\n curr = curr.right\n end\n end\n return false\n end",
"def find(key, node=@root)\n return nil if @root.nil?\n\n if key < node.key\n find(key, node.left)\n elsif key > node.key\n find(key, node.right)\n else\n return node.value\n end\n end",
"def get_with_found(key)\n current_node = @root\n while current_node && current_node.key != key\n if current_node.key > key\n current_node = current_node.left\n elsif current_node.key < key\n current_node = current_node.right\n end\n end\n\n if current_node.nil?\n return [false, nil]\n else\n return [true, current_node.value]\n end\n end",
"def [](key)\n current_node = @buckets[index(key, size)].head\n if !current_node\n #raise InvalidKeyError \"Cannot retrieve that item - not instantiated\"\n return nil\n end\n while current_node.key != key\n current_node = current_node.next\n break unless current_node\n end\n\n if !current_node\n #raise InvalidKeyError \"Cannot retrieve that item - not instantiated\"\n return nil\n end\n\n return current_node.value\n end",
"def find_helper(current_node, key)\n return if current_node.nil?\n \n if key < current_node.key\n current_node.left = find_helper(current_node.left, key)\n elsif key > current_node.key\n current_node.right = find_helper(current_node.right, key)\n else\n return current_node.value\n end\n \n end",
"def find_recursive(current, key)\n return nil if current.nil?\n\n return current.value if key == current.key\n\n if key < current.key\n find_recursive(current.left, key)\n elsif key > current.key\n find_recursive(current.right, key)\n end\n end",
"def next\n return nil unless @node\n @node = @node.next\n while @index < @table.size and @node == nil\n @index += 1\n @node = @table[@index]\n end\n @node == nil ? nil : (@is_value ? @node.value : @node.key)\n end",
"def find(key)\n node = find_node(key)\n (node == nil ? nil : node.value)\n end",
"def find(key, node = root)\n return nil if node.nil?\n if key == node.data\n return node\n else\n find(key, left_right(key, node))\n end\n end",
"def search( key, node=@root )\n return nil if node.nil?\n if key < node.key\n search( key, node.left )\n elsif key > node.key\n search( key, node.right )\n else\n return node\n end\n end",
"def retrieve(key)\n found_element = @lookup[key]\n\n if found_element\n prev_elem = found_element.prev_elem\n Element.swap found_element.prev_elem, found_element\n @head = found_element if found_element.prev_elem.nil?\n @tail = prev_elem if prev_elem&.next_elem.nil?\n found_element.read\n end\n end",
"def find(key)\n if empty?\n nil\n else\n if @val[0] == key\n @val\n elsif @val[0] < key && @right!=nil\n @right.find(key)\n elsif @left!=nil\n @left.find(key)\n else\n nil\n end\n end\n end",
"def find_node(calling_node, key)\n @router.touch(calling_node)\n return @router.get_closest_nodes(key)\n end",
"def prev node_or_key\n key = String.new\n case node_or_key\n when Node\n key = node_or_key.key\n when String\n key = node_or_key\n else\n p \"only accept String or Node type\"\n end\n\n prev = node = @head\n while node.next_ != nil && node.key != key\n prev = node\n node = node.next_\n end\n prev == node ? nil : prev\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_helper(node, key)\n if node.nil?\n return nil\n elsif node.key == key\n return node.value\n elsif key < node.key\n return find_helper(node.left, key)\n elsif key > node.key\n return find_helper(node.right, key)\n end\nend",
"def find(key)\n root = root? key.slice(0)\n [].tap { |a| root and probe(0, root, key[1..-1], a) }\n # generate_result([], key) { |rkey, r| r.first.prepend(rkey) }\n end",
"def retrieve key\n\t\tnode = traverse @root, key\n\t\tnode.key\n\tend",
"def next(node)\n @path[@path.index(node) + 1]\n end",
"def get(key)\n @nodes[hash(Zlib::crc32(key), @nodes.size)]\n end",
"def find(key)\n if @root.nil?\n return nil\n elsif @root.key == key\n return @root.value\n else\n find_helper(@root, key)\n end\n end",
"def select_node(data,key,value)\n data.each_key do |k|\n if data[k].has_key?(key)\n if data[k][key] == value\n return k\n end\n end\n end\nend",
"def next_item\n return nil if @link == nil\n link.kernel.select {|item| item.rule == @rule}.first\n end",
"def get(key)\n return -1 if !(@hash.has_key?(key))\n\n @dlink.move_to_head key\n @hash[key]\n end",
"def help_find(current, key)\n return nil if current.nil? \n\n if current.key == key \n return current.value \n elsif current.key < key \n current = current.right \n else \n current = current.left \n end \n\n return help_find(current,key)\n end",
"def get_node(string_key)\n pos = self.get_node_pos(string_key)\n return nil if pos.nil?\n\n return @ring[@_sorted_keys[pos]]\n end",
"def get(key)\n node_for(key).get(key)\n end",
"def get(key)\n node = @cache[key]\n return -1 if node.nil?\n move_to_head(node)\n node.value\n end",
"def get(key)\n node = node_for_key(key)\n node.read(&@block)\n end",
"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 find_entry(key)\n key_hash = key.hash\n\n entry = @entries[key_index(key_hash)]\n while entry\n if entry.match? key, key_hash\n return entry\n end\n entry = entry.next\n end\n end",
"def find(key)\n if root.nil?\n return nil\n else\n root.find(key)\n end\n end",
"def node_for_key(key, src_destination = nil)\n return self.src_destination_hash.delete(key) if self.src_destination_hash.key?(key)\n self.src_destination_hash[key] = ::SortFlightTickets::Node.new(key, src_destination)\n end",
"def find_helper(current_node, search)\n return nil if current_node.nil?\n \n if current_node.key == search\n return current_node\n elsif current_node.key > search\n find_helper(current_node.left, search)\n else\n find_helper(current_node.right, search)\n end\n end",
"def find_helper(current_node, target)\n if current_node == nil\n return current_node \n end\n\n if current_node.key == target\n return current_node.value\n end\n\n if target < current_node.key\n find_helper(current_node.left, target)\n else\n find_helper(current_node.right, target)\n end\n end",
"def find(key)\n # If we are already on nil, just add it here\n return nil if @root.nil?\n #Return the root value if it is the value we are looking for\n return @root.value if @root.key == key\n #Otherwise, call in reinforcements\n return find_helper(@root, key)\n end",
"def get(key)\n node = @map[key]\n return -1 if node.nil?\n @list.remove_node(node)\n @list.add_front(node)\n return node.value\n end",
"def find(key)\n return nil if @root.nil?\n return find_helper(@root, key)\n end",
"def move_to_end(key)\n return unless key? key\n\n @semaphore.synchronize do\n node = @hashed_storage[key]\n @head_node = node.previous_node if @head_node == node\n node.previous_node.next_node = node.next_node if node.previous_node\n node.next_node.previous_node = node.previous_node if node.next_node\n node.previous_node = nil\n node.next_node = @tail_node\n @tail_node.previous_node = node\n @tail_node = node\n end\n end",
"def node(key)\n @network.node(@values[key])\n end",
"def get_next()\n return @next_node\n end",
"def find(key)\n return self if @name == key\n @children.each do |child|\n next unless child.respond_to?(:find)\n match = child.find(key)\n return match unless match.nil?\n end\n nil\n end",
"def search(key)\n return binary(0, @keys.size-1, key)\n end",
"def find_canididate_insertion_node(current, key)\n if current[:key_length].nil?\n new_node = insert_node(current, key)\n current[:key_length] = key.length\n return new_node, \"\"\n end\n\n # check if we have an existing shared prefix already\n current_key = key[0...current[:key_length]]\n\n # look for an existing key path\n if current[:nodes].has_key?(current_key)\n return current[:nodes][current_key], key[current_key.length..-1]\n end\n\n # search for a shared prefix, and split all the nodes if necessary\n current[:nodes].keys.each do |prefix|\n common_prefix = shared_prefix(key, prefix)\n next unless common_prefix\n\n new_key_length = common_prefix.length\n\n split_nodes(current, new_key_length)\n return current[:nodes][common_prefix], key[new_key_length..-1]\n end\n\n # potentially split all other keys\n if current_key.length < current[:key_length]\n split_nodes(current, current_key.length)\n end\n\n new_node = insert_node(current, current_key)\n return new_node, key[current_key.length..-1]\n end",
"def include?(key)\n current = @head\n while current.next_node != nil\n return true if current.value == key\n current = current.next_node\n end\n\n return true if current.value == key\n\n false\n end",
"def find(key)\n return find_helper(@root, key)\n end",
"def find(key)\n return find_helper(@root, key)\n end",
"def find(key)\n return find_helper(@root, key)\n end",
"def find(key)\n return find_helper(@root, key)\n end",
"def find(key)\n return find_helper(@root, key)\n end",
"def find_parent(current_node, key)\n return nil if current_node.nil?\n\n if current_node.left && (current_node.left.key == key) || current_node.right && (current_node.right.key == key)\n return current_node\n end\n\n if key < current_node.key\n current_node = find_parent(current_node.left, key)\n else\n current_node = find_parent(current_node.right, key)\n end\n end",
"def get(key)\n n = @store[key]\n if n\n remove_node_from_store_links(n)\n append_to_tail(n)\n n.val\n else\n -1\n end\n end",
"def find_next node\r\n return if node == nil\r\n\r\n if node.left != nil\r\n return node.left\r\n end\r\n\r\n node.right\r\nend",
"def next\n return nil unless @node\n @node = @node.next\n while @index < @table.size and @node == nil\n @index += 1\n @node = @table[@index]\n end\n return @node == nil ? nil : @node.item\n end",
"def closest_element(root, key)\n raise \"Please enter a tree with at least one node\" if root.nil?\n\n closest_node, min_diff = root, (key - root.value).abs\n\n find_closest = lambda do |node|\n return unless node\n if (key - node.value).abs < min_diff\n closest_node, min_diff = node, (key - node.value).abs\n end\n\n if key == node.value\n closest_node, min_diff = node, (key - node.value).abs\n return\n end\n\n if node.value < key\n find_closest.call(node.right)\n else\n find_closest.call(node.left)\n end\n end\n\n find_closest.call(root)\n\n closest_node.value\nend",
"def get(key)\n node = @table[key]\n return -1 if node.nil?\n\n make_most_recent_used(node)\n node.value\n end",
"def find(key)\n find_helper(@root, key)\n end",
"def find(key)\n find_helper(@root, key)\n end",
"def find(key_sequence)\n key_sequence=KeyMapNode.arrayify(key_sequence)\n return nil if key_sequence.length < @key_sequence.length\n if key_sequence.length > @key_sequence.length\n\n if self.key_sequence[0..@key_sequence.length-1]==@key_sequence\n @children.each do | child|\n result =child.find(key_sequence)\n return result if result\n end\n end\n \n elsif @key_sequence==key_sequence\n\n \n return self\n end\n \n return nil\n end",
"def find(key)\n if !contains?(key)\n return nil\n end\n\n @semaphore.synchronize {\n @internal_clock += 1\n previous_data = @key_data[key]\n update_access_time_locked(key, @internal_clock, previous_data.access_time)\n\n return previous_data.value\n }\n end",
"def get_next_node(node)\n i = node.number + 1\n i = 0 if i >= nodes.size\n get_node(i)\n end",
"def next_node\n @current_node = @current_node.children[0]\n end"
] | [
"0.7783391",
"0.7575067",
"0.7539671",
"0.7466803",
"0.73225266",
"0.7304928",
"0.7287149",
"0.72754735",
"0.7262475",
"0.7243163",
"0.72368056",
"0.7192649",
"0.7173257",
"0.7171666",
"0.7145616",
"0.7129102",
"0.7111854",
"0.7111854",
"0.7099636",
"0.7062841",
"0.7040026",
"0.7033875",
"0.70331925",
"0.69672424",
"0.69475424",
"0.694676",
"0.69351274",
"0.6932098",
"0.6918064",
"0.68981284",
"0.68849057",
"0.68770194",
"0.68519074",
"0.684763",
"0.681903",
"0.6816277",
"0.6806309",
"0.6802761",
"0.67995965",
"0.6758722",
"0.6754303",
"0.67222786",
"0.67081094",
"0.66967654",
"0.66944546",
"0.6685149",
"0.66575617",
"0.664955",
"0.66054153",
"0.6514789",
"0.65101177",
"0.65057564",
"0.65057564",
"0.64871526",
"0.6479977",
"0.6473134",
"0.64507157",
"0.64177805",
"0.6405648",
"0.638937",
"0.6381708",
"0.6375816",
"0.63467467",
"0.63335407",
"0.6297671",
"0.6291082",
"0.6285594",
"0.6274792",
"0.6243045",
"0.6242859",
"0.6242051",
"0.6218005",
"0.6211009",
"0.6209809",
"0.6208407",
"0.6205996",
"0.6205511",
"0.6201789",
"0.61977947",
"0.6195294",
"0.619387",
"0.61854994",
"0.6136557",
"0.61193085",
"0.61193085",
"0.61193085",
"0.61193085",
"0.61193085",
"0.61043614",
"0.60978305",
"0.6094084",
"0.60798454",
"0.6078916",
"0.6076652",
"0.6075669",
"0.6075669",
"0.6065541",
"0.60627306",
"0.6062247",
"0.605062"
] | 0.8200249 | 0 |
finds a shared prefix between the two strings, or nil if there isn't any | def shared_prefix(a, b)
shared_prefix_length = [a.length, b.length].min
while shared_prefix_length >= 0
a_prefix = a[0..shared_prefix_length]
b_prefix = b[0..shared_prefix_length]
return a_prefix if a_prefix == b_prefix
shared_prefix_length -= 1
end
return nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def common_prefix(a,b)\n return '' if b.nil?\n 0.upto(a.length) {|i|\n return (i == 0 ? \"\" : a[0..i-1]) if a[0..i] != b[0..i]\n }\n ''\nend",
"def common_prefix(words)\n smallest_string= words.min_by{|word| word.size}\n\n result = \"\"\n\n smallest_string.chars.each_with_index do |current_char, current_index|\n if words.all?{|word| word[current_index] == current_char}\n result << current_char\n else\n return result\n end\n end\n result\nend",
"def longest_common_prefix(s1, s2, max = nil)\n l1, l2 = s1.size, s2.size\n min = l1 < l2 ? l1 : l2\n min = min < max ? min : max if max\n min.times do |i|\n return s1.slice(0, i) if s1[i] != s2[i]\n end\n return s1.slice(0, min)\n end",
"def diff_trim_common_prefix(text1, text2)\n if (common_length = diff_common_prefix(text1, text2)).nonzero?\n common_prefix = text1[0...common_length]\n text1 = text1[common_length..]\n text2 = text2[common_length..]\n end\n\n [common_prefix, text1, text2]\n end",
"def common_prefix_length str1, str2\n l = 0\n s1 = str1.size\n s2 = str2.size\n for i in (0...min(min(s1,s2),4)) do\n if str1[i].eql?(str2[i])\n l += 1\n else\n break\n end\n end\n l\n end",
"def find_prefix(word)\n prefix = ''\n i = 0\n while starts_with(prefix)\n prefix += word[i]\n i += 1\n end\n prefix.slice(0, prefix.length - 1)\n end",
"def longest_common_prefix(strings, prefix = '')\n return strings.first if strings.size <= 1\n\n first = strings[0][0,1] or return prefix\n tails = strings[1..-1].inject([strings[0][1..-1]]) do |tails, string|\n if string[0,1] != first\n return prefix\n else\n tails << string[1..-1]\n end\n end\n\n longest_common_prefix(tails, prefix + first)\n end",
"def find_common_prefix_length(a, b)\n length = 0\n while (a[length] == b[length])\n length += 1\n end\n\n length\n end",
"def common_prefix(words)\n longest = ''\n\n shortest_word = words.min\n (0...shortest_word.length).each do |stop_index|\n sequence = shortest_word[0..stop_index]\n\n match = words.all? do |word|\n word[0..stop_index] == sequence\n end\n\n longest = sequence if match\n end\n\n longest\nend",
"def longest_common_prefix(strs)\n prefix = \"\"\n return prefix if strs.empty?\n\n (0...strs[0].length).each do |i|\n (1...strs.length).each do |j|\n return prefix if !strs[j][i] || strs[j][i] != strs[0][i]\n end\n\n prefix += strs[0][i]\n end\n\n prefix\nend",
"def diff_trimCommonPrefix(text1, text2)\n if (common_length = diff_commonPrefix(text1, text2)).nonzero?\n common_prefix = text1[0...common_length]\n text1 = text1[common_length..-1]\n text2 = text2[common_length..-1]\n end\n\n return [common_prefix, text1, text2]\n end",
"def longest_prefix(strings)\n # raise NotImplementedError, \"Not implemented yet\"\n common_prefix = \"\"\n if strings.empty?\n return common_prefix\n end\n\n strings[0].each_char.with_index do |char, index|\n (1...strings.size).each do |arr_position|\n if char != strings[arr_position][index]\n return common_prefix\n end\n end\n common_prefix << char\n end\n\n return common_prefix\nend",
"def longest_common_prefix_horizontal_scan(strs)\n return '' if strs.empty?\n\n prefix = strs[0]\n strs.each do |word|\n until word.start_with?(prefix)\n prefix = prefix[0, prefix.length - 1]\n\n break if prefix == ''\n end\n end\n\n prefix\nend",
"def shortest_common_prefix(arr)\n arr.inject do |pfx,str|\n pfx = pfx.chop while pfx != str[0...pfx.length]; pfx\n end\n end",
"def exact_commom_prefix paths\n home = Dir.home\n paths = paths.map do |path|\n new_path = path.sub!(home, '~') if path.start_with?(home)\n # handle '/xxx'\n new_path.nil? ? path.split('/') : new_path.split('/')\n end\n paths.sort! {|x, y| y.size <=> x.size }\n # indicate if we have found common preifx or just ignore all the case\n has_commom_prefix = false\n common_prefix = paths.reduce do |prefix, path|\n common_prefix = prefix\n prefix.each_with_index do |v, i|\n if v != path[i]\n common_prefix = prefix[0...i]\n break\n end\n end\n # common_prefix should longer than '~/' and '/'\n if common_prefix.size > 1\n has_commom_prefix = true\n common_prefix\n else\n # if there is not commom prefix between two path, just ignore it\n prefix\n end\n end\n has_commom_prefix && common_prefix.size > 1 ? common_prefix.join('/') : ''\n end",
"def longest_prefix(strings)\n # Return an empty string \"\" if no common prefix\n\n # shortest string in array\n prefix = strings.min_by(&:length)\n\n for string in strings\n for j in 0...prefix.length\n if prefix[j] != string[j]\n # update prefix from start, up until j (not including)\n prefix = prefix.slice(0, j)\n break\n end\n end\n end\n\n return prefix\nend",
"def longest_prefix(strings)\n common_string = \"\"\n if strings.length == 0\n return common_string\n end\n \n shortest_element = strings.min\n shortest_element_length = shortest_element.length\n i = 0\n while i < shortest_element_length\n char = shortest_element[i]\n strings.each do |string|\n if char != string[i]\n return common_string\n end\n end\n common_string += char\n i += 1\n end\n \n return common_string\nend",
"def search_prefixes(str, pos= 0, len= -1)\n end",
"def common_prefix(array)\n result = []\n max_index = array.min_by { |string| string.size }.size\n (0...max_index).each do |index|\n current_char = array[0][index]\n if array.all? { |str| str[index] == current_char }\n result << current_char\n else\n return result.join('')\n end\n end\n result.join('')\nend",
"def longest_prefix(strings)\n # raise NotImplementedError, \"Not implemented yet\"\n\n if strings.first.length == 0\n return strings\n end\n\n prefix = \"\"\n i = 0\n\n min = strings.min_by{|s| s.length}\n while i < min.length \n strings.each do |string|\n if min[i] != string[i] \n return prefix\n end\n end\n prefix += min[i]\n i +=1\n end \n return prefix\n end",
"def common_substrings(string_one, string_two)\n if string_one.length <= string_two.length\n longer_string = string_two\n shorter_string = string_one\n else\n longer_string = string_one\n shorter_string = string_two\n end\n\n\n length = shorter_string.length\n until length == 0\n shorter_string_subs = []\n (0..shorter_string.length - length).each do |start|\n sub = shorter_string[start...start + length]\n return sub if longer_string.include?(sub)\n end\n\n length -= 1\n end\n return \"\"\nend",
"def longest_prefix(strings)\n strings_in_common = \"\"\n #checking if array is emptyh\n if strings.length == 0\n return strings_in_common\n end\n shortest_string = strings.min(){|a, b| a.length <=> b.length}.chars\n i = 0\n while i < shortest_string.length\n letter = shortest_string[i]\n strings.each do |string|\n if letter != string.chars[i]\n return strings_in_common\n end\n end\n strings_in_common += letter\n i += 1\n end\n return strings_in_common\nend",
"def longest_prefix(strings)\n strings_in_common = \"\"\n #checking if array is emptyh\n if strings.length == 0\n return strings_in_common\n end\n\n shortest_string = strings.min(){|a, b| a.length <=> b.length}.chars\n\n i = 0\n while i < shortest_string.length\n letter = shortest_string[i]\n strings.each do |string|\n if letter != string.chars[i]\n return strings_in_common\n end\n end\n strings_in_common += letter\n i += 1\n end\n return strings_in_common\nend",
"def longest_common_substring(str1, str2)\r\n shortest = str1.length < str2.length ? str1 : str2\r\n longest = shortest == str1 ? str2 : str1\r\n curr_length, finish, start_idx = shortest.length - 1, shortest.length - 1, 0\r\n until curr_length == -1 do\r\n substr = shortest[start_idx..finish]\r\n return substr if longest.include?(substr)\r\n if finish == shortest.length - 1\r\n curr_length -= 1\r\n start_idx = 0\r\n finish = curr_length\r\n else\r\n start_idx += 1\r\n finish += 1\r\n end\r\n end\r\n ''\r\nend",
"def longest_common_prefix (array_of_strings)\n\n # Establish default value\n lcp = \"\"\n\n # Get the length of the shortest string\n min_length =\n if array_of_strings.size.zero?\n 0\n else\n array_of_strings.min_by(&:length).size\n end\n\n # Go through all of the strings, but not past the length of the shortest string\n min_length.times do |i|\n\n # If all of the strings have the same character at this index,\n # then it's part of the LCP\n chars_at_index = array_of_strings.map { |s| s[i] }\n\n if chars_at_index.uniq.count == 1\n lcp += chars_at_index[0]\n else\n break\n end\n\n end\n\n # Return\n return lcp\n\nend",
"def longest_prefix(strings)\n prefix = ->s1, s2 { s1.each_char.zip(s2.each_char)\n .take_while { |c1, c2| c1 == c2 }\n .map(&:first).join }\n \n strings.reduce(&prefix)\nend",
"def remove_prefix(other)\n tail = dup\n Pointer.new(other).to_a.each do |segment|\n return nil unless tail.shift == segment\n end\n tail\n end",
"def longest_common_prefix(strings)\n split_strings = []\n output_string = \"\"\n strings.map do |string|\n split_strings << string.split('')\n end\n\n split_strings.each_with_index do |word, index|\n word.each_with_index do |letter, i|\n loop do\n if word[i] == split_strings[index + 1][i]\n output_string << letter\n require 'pry'; binding.pry\n elsif word[i] != split_strings[index + 1][i]\n break\n end\n end\n end\n end\n # output_string\n # require 'pry'; binding.pry\nend",
"def longest_prefix(strings)\n return \"\" if strings.empty?\n prefix = \"\"\n smallest_word = strings.min_by { |word| word.length } # start with smallest word\n for i in 0..smallest_word.length-1\n if strings.all? { |word| word[i] == smallest_word[i] } # if the index matches the same index of the other words\n prefix += smallest_word[i] # then append the index value to the prefix\n else\n break # otherwise index is not in all words, so stop\n end\n end\n return prefix\nend",
"def two_strings a,b\n s1 = a.chars.uniq\n s2 = b.chars.uniq\n substring = false\n\n s2.each do |letter|\n if s1.include? letter\n substring = true\n break\n end\n end\n puts substring ? 'YES' : 'NO' \nend",
"def longest_shared_substring s1, s2\n sufs1 = all_suffixes(s1)\n root = SuffixTreeNode.new\n sufs1.each{|s| root.add(s)}\n sufs2 = all_suffixes(s2)\n best = []\n sufs2.each do |s|\n nxt = root.overlay(s)\n best = nxt if nxt.length > best.length\n end\n best\nend",
"def find_prefix(prefix)\n node = find_word prefix.downcase\n if node.nil?\n [false, false, 0]\n else\n count = node.word_count\n count -= 1 if node.is_word\n [true, node.is_word, count]\n end\n end",
"def start_of_word(a, b)\n return a.chars.first(b).join\nend",
"def common_substrings(str1, str2)\n a_one = str1.split(//)\n a_two = str2.split(//)\n\n a_common = []\n indexed = 0\n\n a_two.each do |i|\n if i == a_one[indexed]\n a_common << i\n else\n a_common << \" \"\n end\n indexed+= 1\n end\n\n stripped = a_common.join.strip\n substrings = stripped.split(/ /)\n longest_substring = \"\"\n\n substrings.each do |i|\n if i.length > longest_substring.length\n longest_substring = i\n else \n nil\n end\n\n end\n longest_substring\nend",
"def str_index_of(str1, str2)\n if str_include(str1, str2)\n get_index(str1, str2)\n else\n return -1\n end\nend",
"def knuthMorrisPrattStringSearch(text, pattern, prefixTable)\n return nil if pattern.nil? or text.nil?\n n = text.length\n m = pattern.length\n q = k = 0\n while (k + q < n)\n if pattern[q] == text[q+k]\n if q == (m - 1)\n return k\n end\n q += 1\n else\n k = k + q - prefixTable[q]\n if prefixTable[q] > -1\n q = prefixTable[q]\n else\n q = 0\n end\n end\n end\nend",
"def longest_prefix(strings)\n if strings.length < 2\n raise ArgumentError\n else\n prefix = \"\"\n l = 0\n (strings.min.length).times do\n s = 0\n track = 0\n (strings.length - 1).times do\n if strings[s][l] == strings [(s+1)][l]\n track += 1\n else\n break\n end\n s += 1\n end\n if track == (strings.length - 1)\n prefix << strings.min[l]\n else\n break\n end\n l += 1\n end\n return prefix\n end\nend",
"def is_prefix?(word)\n Constants::PREFIXES.key?(word.downcase)\n end",
"def longest_prefix(strings)\n same = true\n index = 0\n\n while same \n array_characters = strings.map do |string|\n string[index]\n end\n\n current = 0\n until array_characters.length - 1 < current\n if array_characters[current] == array_characters[0]\n current += 1\n else\n same = false\n end\n end\n index += 1\n end \n\n if same == true\n return strings.first[0..index]\n else\n return strings.first[0...index] \n end\nend",
"def longest_prefix(strings)\n length = strings.min_by { |string| string.length }.length\n strings = strings.sort!\n substring = \"\"\n \n i = 0\n while i <= length\n if strings[0][0..i] == strings[-1][0..i]\n substring = strings[0][0..i]\n end\n i += 1\n end\n \n return substring\nend",
"def longest_prefix(strings)\n if strings.length == 1\n return strings\n end\n\n prefix = \"\"\n str_index = 0\n\n\n until (strings[0][str_index] != strings[1][str_index]) || (strings[0][str_index] == nil && strings[1][str_index] == nil)\n prefix += strings[0][str_index]\n str_index += 1\n end\n\n strings.each do |string|\n return \"\" if prefix[0] != string[0]\n\n prefix.length.times do |i|\n if prefix[i] != string[i]\n prefix = prefix[0...i]\n break\n end\n end\n end\n return prefix\nend",
"def longest_prefix(strings)\n return \"\" if strings.empty? \n index = 0\n min = strings.min_by{|s| s.length} # find the shortest string\n longest_prefix = \"\"\n while index < min.length # keep running based on the length of the sortest the string \n strings.each do |string|\n if min[index] != string[index] # if the it's not equal, return the \"\"\n return longest_prefix\n end\n end\n longest_prefix += min[index]\n index +=1\n end \n return longest_prefix\nend",
"def longest_prefix(strings)\n initial_match = ''\n length = strings[0].length\n length.times do |letter|\n if strings[0][letter] == strings[1][letter]\n initial_match.concat(strings[0][letter])\n end\n end\n \n strings.each do |word|\n match = ''\n initial_match.length.times do |letter|\n if initial_match[letter] == word[letter]\n match.concat(word[letter])\n end\n end\n initial_match = match\n end\n \n return initial_match\nend",
"def prefix\n regexify(bothify(fetch('aircraft.prefix')))\n end",
"def longest_shared_substrings s1, s2, from = 0, to = ([s1.length, s2.length].min - 1)\n if from == to\n return common_kmers(to, s1, s2)\n elsif from == to - 1\n a = common_kmers(from, s1, s2)\n b = common_kmers(to, s1, s2)\n b = a if b.empty?\n return b\n end\n mid = from + ((to - from) / 2)\n kmers = common_kmers(mid, s1, s2)\n if kmers.empty?\n return longest_shared_substrings(s1, s2, from, mid)\n else\n return longest_shared_substrings(s1, s2, mid, to)\n end\nend",
"def coinc?( word, base )\r\n\t# output: nil - no coincedence, 0 - from beginning, >0 - prefix exists\r\n\treturn word.index(base)\r\nend",
"def shortest_nonshared_substrings s1, s2\n i = 1\n distinct = Set.new\n while i < [s1.length, s2.length].min and distinct.empty?\n distinct = distinct_kmers(i, s1, s2)\n i += 1\n end\n distinct\nend",
"def longest_prefix(strings)\n index = 0 \n prefix = \"\"\n all_true = false \n st = strings.min_by(&:length) \n st.split(\"\").each do |char| \n strings.each do |string| #string.split.each do char???\n if string.split(\"\")[index] == char\n all_true = true \n else\n all_true = false\n end\n end\n\n if all_true == false \n return prefix\n end \n if all_true == true\n prefix += char\n end\n index += 1\n end \n return prefix\nend",
"def common_substrings(string_one, string_two)\n longest_str = \"\"\n strs = string_one.length < string_two.length ? [string_one, string_two] : [string_two, string_one]\n (1..strs[0].length).each do |cur_size|\n strs[0].split(\"\").each_index do |index|\n break if index + cur_size >= strs[0].length \n cur_str = strs[0][index...index+cur_size]\n longest_str = strs[1].include?(cur_str) ? cur_str : longest_str\n end\n end\n longest_str\nend",
"def starts_with(prefix)\n curr = @root\n prefix.each_char.all? do |char|\n curr = curr[char]\n end \n end",
"def commonChild(s1, s2)\n #ABCDEFG\n #ABDCLFG\n # regex search using * between each character and see what is the longest match you can make\n #A*B*C*D*E*F*G\n #ABCFG\n \nend",
"def closest_string_in_front(key_string, sub_string)\n\n\t\tpositions = []\n\t\tlast_pos = nil\n\t\tmy_string = \" \" + to_str\n\t\tkey_pos = my_string.index(key_string)\n\t\tif key_pos.nil?\n\t\t\t#puts \"WARNING: closest_string_in_front PASSED A string THAT DID NOT INCLUDE key_string\"\n\t\t\treturn nil\n\t\telse\n\t\t\tmy_string = my_string.slice(0..key_pos+1)\n\t\tend\n\n\t\twhile (last_pos = my_string.index(sub_string, (last_pos ? last_pos + 1 : 0)))\n\t\t\tpositions << last_pos\n\t\tend\n\n\t\tif positions != []\n\t\t\treturn_string = my_string[key_pos-positions.map{|p| (p-key_pos).abs}.min..key_pos-1]\n\t\t\treturn return_string.match(sub_string).to_s\n\t\telse\n\t\t\treturn nil\n\t\tend\n\tend",
"def longest_prefix(strings)\n return \"\" if strings.empty? == true\n \n longest_prefix = strings[0].chars\n strings.each do |string|\n holder = string.chars\n longest_prefix = holder & longest_prefix\n end\n\n return longest_prefix.join\n \n\nend",
"def longest_common_substring(str1, str2)\n length = str1.length\n longest_substring = \"\"\n (0..length).each do |i|\n (i + 1..length).each do |j|\n if j - i - 1 > longest_substring.length\n substring = str1[i...j]\n longest_substring = substring if str2.include?(substring) && substring.length > longest_substring.length\n end\n end\n end\n longest_substring\nend",
"def longest_prefix(strings)\n\n # Assign relevant variables\n winning_ticket = \"\"\n i = 0 \n fastest_furthest = strings[0][i]\n\n # Account for non-nil values and return method result \n while fastest_furthest != nil\n strings.each do |string|\n unless string[i] == fastest_furthest\n return winning_ticket\n end \n end \n winning_ticket += fastest_furthest\n i += 1\n fastest_furthest = strings[0][i]\n end\n return winning_ticket\nend",
"def words_with_prefix(prefix, words)\n raise NotImplementedError # TODO\nend",
"def diff_trim_common_suffix(text1, text2)\n if (common_length = diff_common_suffix(text1, text2)).nonzero?\n common_suffix = text1[-common_length..]\n text1 = text1[0...-common_length]\n text2 = text2[0...-common_length]\n end\n\n [common_suffix, text1, text2]\n end",
"def starts_with(prefix)\n extract.grep(/^#{prefix}/)\n end",
"def longest_prefix(strings)\n template = strings[0]\n i = 0\n \n until template[i].nil? do\n comparison_result = true\n strings[1..].each do |word|\n \n if word[i] != template[i]\n comparison_result = false\n break\n end \n\n end\n\n if comparison_result\n i += 1\n else \n break\n end\n end\n return template[0, i]\nend",
"def get_matching_strings(prefix)\n puts \"Matching for #{prefix}\"\n ptr = @root\n for i in 0..prefix.size-1\n ptr = ptr.children[prefix[i]]\n return nil unless ptr\n end\n arr = []\n arr << prefix if ptr.is_leaf\n arr << get_strings(ptr, prefix)\n arr\n end",
"def longest_common_substring(str1, str2)\n longest_substring = \"\"\n\n start_idx = 0\n while start_idx < str1.length\n # don't consider substrings that would be too short to beat\n # current max.\n len = longest_substring.length + 1\n\n while (start_idx + len) <= str1.length\n end_idx = start_idx + len\n substring = str1[start_idx...end_idx]\n longest_substring = substring if str2.include?(substring)\n\n len += 1\n end\n\n start_idx += 1\n end\n\n longest_substring\nend",
"def shared_characters(a, b)\n raise unless a.size == b.size\n a.zip(b).select {|x,y| x == y }.map(&:first)\nend",
"def longest_prefix(str, pos= 0, len= -1, match_prefix= false)\n end",
"def calculate_prefix(current_tuple, last_tuple)\n return [] if last_tuple.nil?\n prefix = []\n last_matched_index = nil\n 0.upto(number_of_dimensions) do |i|\n if current_tuple[i] == last_tuple[i]\n prefix << current_tuple[i]\n else\n break\n end\n end\n prefix\n end",
"def uncommon_substring_core(needle, max)\n (0..max).find do |n|\n reg = /^#{'.' * n}(.*)/\n needle.map{|s| s[reg, 1][0,1] }.uniq.size > 1\n end\n end",
"def longest_prefix(strings)\n strings.each do |string|\n if string.length == 0\n return \"\"\n end \n end \n prefix = strings[0]\n (1...strings.length).each do |n|\n (0...prefix.length).each do |i|\n if strings[n][i] != prefix[i]\n if i == 0\n prefix = \"\"\n break\n else \n prefix = prefix[0...i]\n break\n end \n end \n end \n end \n return prefix\nend",
"def longest_prefix(strings)\n prefix = \"\"\n\n i = 0\n char = strings[0][i]\n\n while char != nil\n strings.each do |string|\n if string[i] != char\n return prefix\n end\n end\n\n prefix += char\n i += 1\n char = strings[0][i]\n end\n \n return prefix\nend",
"def prefix\n match(/Prefix\\s+:\\s+([^\\s])/)\n end",
"def longest_common_substring(str1, str2)\n substrings1 = substrings(str1)\n substrings2 = substrings(str2)\n return '' if substrings2.empty? || substrings1.empty?\n common_substrings = substrings1 & substrings2\n common_substrings.max_by { |word| word.length }\nend",
"def get_prefixed_words(prefix)\n # FILL ME IN\n unless valid_word?(prefix)\n return \"Invalid input (string should only consist of letters).\"\n end\n output = findWords(prefix)\n if output.length() == 0\n return \"No prefixed words found!\"\n end\n output\n end",
"def longest_prefix(strings)\n # raise NotImplementedError, \"Not implemented yet\"\n longest_prefix = \"\"\n idx = 0\n letter = strings[0][idx]\n\n until letter == nil\n strings.each do |string|\n if string[idx] != letter\n return longest_prefix\n end\n end\n longest_prefix += letter\n idx += 1\n letter = strings[0][idx]\n end\n return longest_prefix\nend",
"def efficient_common_substrings(str1, str2)\n max = \"\"\n (0...str1.length).each do |index|\n (index + 1...str1.length).each do |j|\n substr = str1[(index..j)]\n if (max.length <= substr.length) && str2.include?(substr)\n max = substr\n end\n end\n end\n max\nend",
"def diff_trimCommonSuffix(text1, text2)\n if (common_length = diff_commonSuffix(text1, text2)).nonzero?\n common_suffix = text1[-common_length..-1]\n text1 = text1[0...-common_length]\n text2 = text2[0...-common_length]\n end\n\n return [common_suffix, text1, text2]\n end",
"def starts_with(prefix)\n search_arr(prefix.chars)\n end",
"def starts_with(prefix)\n !!find(prefix)\n end",
"def longest_common_substring(str1, str2)\n longest = \"\"\n\n start_idx = 0\n while start_idx < str1.length\n # don't consider strings too short to be longest\n len = longest.length + 1\n\n while (start_idx + len) <= str1.length\n end_idx = start_idx + len\n substring = str1[start_idx...end_idx]\n longest = substring if str2.include?(substring)\n\n len += 1\n end\n\n start_idx += 1\n end\n\n longest\nend",
"def find(prefix)\n prefix.downcase!\n @base.each_key do |name|\n if name.start_with? prefix\n puts base[name].to_s()\n end\n end\n end",
"def longest_common_prefix(arr)\n result = \"\"\n return result if arr.length == 0 || arr[0].length == 0\n\n i = 0\n fin = false\n\n until fin\n letter = arr[0][i]\n arr.each { |str| fin = true if i >= str.length || str[i] != letter }\n result += letter unless fin\n i += 1\n end\n\n result\nend",
"def twoStrings(s1, s2)\n freq = Hash.new\n\n # 1) store characters frequency in first word\n for i in 0...(s1.length)\n freq[s1[i]] = 1\n end\n\n # 2) check if the second word has the common characters\n for i in 0...(s2.length)\n return \"YES\" unless freq[s2[i]].nil?\n end\n\n return \"NO\"\nend",
"def districts_by_prefix(districts, prefix)\n name_eng = case prefix\n when :hk\n \"Hong Kong Island\"\n when :kln\n \"Kowloon\"\n when :nt\n \"New Territories\"\n when :is\n \"Islands\"\n else\n nil\n end\n \n districts.select{|district| district.name_eng == name_eng}.first if name_eng\nend",
"def longest_prefix(strings)\n min = strings.min \n max = strings.max\n string_pre = min.size.times do |i| \n break i if min[i] != max[i]\n end\n min[0...string_pre]\nend",
"def longest_prefix(strings)\n temp = strings[0].chars\n \n strings.each_with_index do |value, i|\n value.length.times do |i|\n if value[i] != temp[i]\n temp[i] = nil\n end\n end\n end\n \n nil_location = temp.index(nil) || temp.length\n return temp.take(nil_location).join\nend",
"def is_substring?(s1, s2) \n return s1.include?(s2)\nend",
"def find_longest_common_substring(s1, s2)\n if (s1 == \"\" || s2 == \"\")\n return \"\"\n end\n m = Array.new(s1.length){ [0] * s2.length }\n longest_length, longest_end_pos = 0,0\n (0 .. s1.length - 1).each do |x|\n (0 .. s2.length - 1).each do |y|\n if s1[x] == s2[y]\n m[x][y] = 1\n if (x > 0 && y > 0)\n m[x][y] += m[x-1][y-1]\n end\n if m[x][y] > longest_length\n longest_length = m[x][y]\n longest_end_pos = x\n end\n end\n end\n end\n return s1[longest_end_pos - longest_length + 1 .. longest_end_pos]\n end",
"def longest_prefix(strings)\n words = strings.length\n min_characters = (strings.min_by{|string|string.length}).length\n prefix = \"\"\n\n min_characters.times do |j|\n letter = strings[0][j]\n\n words.times do |i|\n return prefix if strings[i][j] != letter\n end\n\n prefix += letter\n end\n\n return prefix\nend",
"def str_start_with (orig_string, little_string)\n return !orig_string.match(/\\A#{Regexp.escape(little_string)}/).nil?\nend",
"def test_String_004_prefix\n \n puts2(\"\")\n puts2(\"#######################\")\n puts2(\"Testcase: test_String_004_prefix\")\n puts2(\"#######################\")\n \n sMyFile = \"some_long_filename.log\"\n puts2(\"\\nReturn the file name without its extension for: \" + sMyFile)\n sMyFilePrefix = sMyFile.prefix(\".\")\n puts2(\"File name: \" + sMyFilePrefix)\n #\n sMyEmailAddress = \"[email protected]\"\n puts2(\"\\nReturn the user account of the Email address: \" + sMyEmailAddress)\n sMyUserAccount = sMyEmailAddress.prefix(\"@\")\n puts2(\"User account: \" + sMyUserAccount)\n \n sMyString = \"This is a test\"\n puts2(\"\\nReturn the first word in the string: \" + sMyString)\n sMyFirstWord = sMyString.prefix(\" \")\n puts2(\"First word: \" + sMyFirstWord)\n \n sMyString = \" String with leading & trailing white space \"\n puts2(\"\\nReturn the first word of the String: \" + sMyString)\n sMyFirstWord = sMyString.prefix(\" \")\n puts2(\"First word: \" + sMyFirstWord)\n \n sMyString = \" No delimiter specified \"\n puts2(\"\\nReturn the whole String if: \" + sMyString)\n sMyFirstWord = sMyString.prefix(\"\")\n puts2(\"String: \" + sMyFirstWord)\n \n sMyString = \" Multiple delimiter-characters that are in the specified string \"\n puts2(\"\\nReturn the first word of the String: \" + sMyString)\n sMyFirstWord = sMyString.prefix(\" #\")\n puts2(\"First word: \" + sMyFirstWord)\n \n sMyString = \" Delimiter character is NOT in the string \"\n puts2(\"\\nReturn the whole String if: \" + sMyString)\n sMyFirstWord = sMyString.prefix(\".\")\n puts2(\"String: \" + sMyFirstWord)\n \n end",
"def matches?(str1, str2)\n str1.start_with?(str2) || str2.start_with?(str1)\n end",
"def longest_prefix(strings)\n loops = (strings.length) - 1\n comparison_word = strings[0]\n \n loops.times do |i|\n prefix = \"\"\n counter = 0\n \n strings[i + 1].each_char do |letter|\n if letter == comparison_word[counter]\n prefix<<(letter)\n end\n counter += 1\n end\n comparison_word = prefix\n end\n \n return comparison_word\nend",
"def customStartWith(string, substring)\n result = false\n substrLen = substring.length\n target = string[0, substrLen]\n result = true if substring == target\n result\nend",
"def custom_start_with?(string, substring)\n array_of_strings = string.split(\" \")\n array_of_strings.first == substring ? true : false\nend",
"def user\n @prefix =~ PREFIX_PAT and $2\n end",
"def use_prefix\n prefix, @prefix = @prefix, nil\n @res << prefix if prefix\n\n prefix\n end",
"def solution(a)\n shortest = a.min_by &:length\n maxlen = shortest.length\n maxlen.downto(0) do |len|\n 0.upto(maxlen - len) do |start|\n substr = shortest[start,len]\n return substr if a.all?{|str| str.include? substr }\n end\n end\nend",
"def common_substrings(string1, string2)\n string2.downcase.chars.each do |char|\n return false if string2.count(char) > string1.downcase.count(char)\n end\n true\nend",
"def checking_dictionary_for_word_match\n @prefix = @str[@i_last_real_word...@i]\n \n if valid_word?(@prefix)\n if @skip_counter > 0\n @skip_counter -= 1\n else\n @words[i] = @prefix\n @i_last_real_word = @i\n end\n end\n end",
"def str_str(haystack, needle)\n return 0 if needle == \"\"\n return -1 unless haystack.include?(needle)\n haystack.index(needle)\nend",
"def twoStrings(s1, s2)\n require 'set'\n set1 = Set.new(s1.chars)\n set2 = Set.new(s2.chars)\n if set1.intersect? set2\n return \"YES\"\n else\n return \"NO\"\n end\nend",
"def first_wa(strings)\n strings.find do |string|\n string[0] ==\"w\" && string[1] == \"a\"\n end\nend",
"def twoStrings(s1, s2)\n s1.split(\"\").each { |x| return \"YES\"if s2.include?(x) }\nreturn \"NO\"\nend"
] | [
"0.79685265",
"0.71222836",
"0.69956446",
"0.69941056",
"0.6879243",
"0.6851252",
"0.6795426",
"0.6791654",
"0.6774552",
"0.67604685",
"0.67096066",
"0.6635475",
"0.66062385",
"0.6604037",
"0.6500269",
"0.64965665",
"0.64592725",
"0.64484715",
"0.6447398",
"0.6424874",
"0.64087474",
"0.63945603",
"0.639282",
"0.6318721",
"0.6284356",
"0.62634313",
"0.625622",
"0.6253037",
"0.6251774",
"0.6188699",
"0.6165869",
"0.6154867",
"0.6144548",
"0.6141433",
"0.6094864",
"0.60911626",
"0.60617006",
"0.60414803",
"0.6016985",
"0.59988785",
"0.59987354",
"0.5993991",
"0.5969586",
"0.5968819",
"0.5963232",
"0.5958824",
"0.593822",
"0.59169483",
"0.59037316",
"0.58387864",
"0.58017254",
"0.57870245",
"0.5784961",
"0.57696414",
"0.5766521",
"0.57655585",
"0.57616526",
"0.57568234",
"0.57547414",
"0.5751688",
"0.5749743",
"0.5741864",
"0.5741498",
"0.5736113",
"0.5727513",
"0.5726826",
"0.5721166",
"0.57133657",
"0.57115155",
"0.571026",
"0.57020766",
"0.57011724",
"0.56848204",
"0.56781125",
"0.56780916",
"0.5668645",
"0.56653136",
"0.5661692",
"0.565888",
"0.56506526",
"0.56349164",
"0.56189",
"0.5616403",
"0.5611872",
"0.5603842",
"0.55944407",
"0.55930877",
"0.5588399",
"0.5556394",
"0.5548589",
"0.55417806",
"0.55411565",
"0.55367404",
"0.55363226",
"0.5533396",
"0.55310273",
"0.55306053",
"0.5519413",
"0.5514709",
"0.5503859"
] | 0.83040935 | 0 |
Enable or disable maintenance mode. This endpoint only works on the local agent. | def enable enable=true, reason=nil, options=nil
raw = @conn.put do |req|
url = ["/v1/agent/maintenance"]
url << use_named_parameter('enable', enable.to_s)
url << use_named_parameter('reason', reason) unless reason.nil?
url << use_named_parameter('dc', options[:dc]) if options and options[:dc]
req.url concat_url url
end
if raw.status == 200
@raw = raw
return true
else
raise Diplomat::UnknownStatus, "status #{raw.status}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def maintenance_mode(primitive)\n retry_command {\n pcs 'property', 'set', \"maintenance-mode=#{primitive}\"\n }\n end",
"def activate_maintenance_mode\n return unless maintenance && pending_migrations?\n callback(:activate_maintenance_mode) do\n notify(:activate_maintenance_mode)\n heroku.app_maintenance_on\n end\n end",
"def maintenance(enable, service = nil, reason = nil)\n if service.nil?\n url = build_agent_url('maintenance')\n else\n if service.instance_of?(Consul::Model::Service)\n service = service.id\n end\n raise ArgumentError.new \"Unable to create request for #{service}\" unless service.respond_to?(:to_str)\n url = build_service_url(\"maintenance/#{service}\")\n end\n params = {:enable => enable}\n params[:reason] = reason unless reason.nil?\n _get url, params\n end",
"def enable(enable = true, reason = nil, options = {})\n custom_params = []\n custom_params << use_named_parameter('enable', enable.to_s)\n custom_params << use_named_parameter('reason', reason) if reason\n custom_params << use_named_parameter('dc', options[:dc]) if options[:dc]\n raw = send_put_request(@conn, ['/v1/agent/maintenance'], options, nil, custom_params)\n\n return_status = raw.status == 200\n raise Diplomat::UnknownStatus, \"status #{raw.status}: #{raw.body}\" unless return_status\n\n return_status\n end",
"def maintenance(service_id, options = { enable: true })\n custom_params = []\n custom_params << [\"enable=#{options[:enable]}\"]\n custom_params << [\"reason=#{options[:reason].split(' ').join('+')}\"] if options[:reason]\n maintenance = send_put_request(@conn, [\"/v1/agent/service/maintenance/#{service_id}\"],\n options, nil, custom_params)\n maintenance.status == 200\n end",
"def disable_maintenance_page?\n enable_maintenance_page?\n end",
"def maintenance\n end",
"def maintenance_status\n get \"/setup/api/maintenance\", password_hash\n end",
"def start_maintenance\n return true if maint_mode?\n\n Instance.running_for_profile(self).map {|i| i.stop}\n maint_mode = true\n self.save!\n sleep 2\n\n self.start_instance\n end",
"def enable_maintenance_page?\n maintenance_on_restart? || (migrate? && maintenance_on_migrate?)\n end",
"def set_maintenance_status(maintenance)\n queries = password_hash\n queries[:query][:maintenance] = \"#{maintenance.to_json}\"\n post \"/setup/api/maintenance\", queries\n end",
"def maintenance(mode, sites, env)\n\t\trun_cap(\"\", env, \"mysite:maintenance\", \"#{mode},#{sites.join(',')}\")\n\tend",
"def bypass_maintenance?\n !!runopts(:bypass_maintenance)\n end",
"def in_maintenance_mode?\n @admin.isMasterInMaintenanceMode\n end",
"def on\n heroku 'maintenance:on'\n end",
"def deactivate_maintenance_mode\n return unless pending_migrations?\n callback(:deactivate_maintenance_mode) do\n notify(:deactivate_maintenance_mode)\n heroku.app_maintenance_off\n end\n end",
"def stop_maintenance\n return true unless maint_mode?\n\n Instance.running_for_profile(self).map {|i| i.stop}\n maint_mode = false\n self.save!\n end",
"def check_maintenance_mode()\n versioning = AppParameter.find_by_code( AppParameter::PARAM_VERSIONING_CODE )\n if versioning.a_bool?\n logger.info('--- MAINTENANCE MODE IS ON! ---')\n respond_to do |format|\n format.html do\n # Do just a redirect (avoid an infinite loop of redirections):\n redirect_to( controller: 'home', action: 'maintenance' ) unless (params[:controller] == 'home') && (params[:action] == 'maintenance')\n end\n format.json { render json: {maintenance: true} and return }\n end\n end\n end",
"def show_maintenance_mode_page\n \n # read plugin settings\n settings = MaintenanceModeFunctions.get_maintenance_plugin_settings\n \n # only activate maintenance message if maintenance mode is activated or if we're in the middle of a scheduled maintenance \n if settings[:maintenance_active] || MaintenanceModeFunctions.is_now_scheduled_maintenance\n # and only activate it for non-admin users (or sudoers if 'redmine_sudo' plugin is installed)\n unless User.current.admin? || (Redmine::Plugin.installed?(\"redmine_sudo\") && User.current.sudoer?)\n logout_user if User.current.logged?\n require_login unless params[:controller] == \"account\" && params[:action] == \"login\"\n return false\n end\n end\n end",
"def enforce_maintenance_mode\n return if !ENV['MAINTENANCE_MODE'] && Rails.configuration.published_locales.include?(I18n.locale)\n return if %w[sessions switch_user].include? controller_name\n return if current_user.present?\n\n redirect_to maintenance_path, status: :see_other\n end",
"def enforce_maintenance_mode\n return if !ENV['MAINTENANCE_MODE'] && Rails.configuration.published_locales.include?(I18n.locale)\n return if %w[sessions switch_user].include? controller_name\n return if current_user.present?\n\n redirect_to maintenance_path, status: :see_other\n end",
"def check_for_maintenance_mode\n if current_site.maintenance_mode?\n unless admin_signed_in? && current_admin.has_privileges_for?(current_site)\n raise MaintenanceModeError.new\n end\n end\n end",
"def set_maintenance\n @maintenance = Maintenance.find(params[:id])\n end",
"def set_maintenance\n @maintenance = Maintenance.find(params[:id])\n end",
"def set_maintenance\n @maintenance = Maintenance.find(params[:id])\n end",
"def set_maintenance\n @maintenance = Maintenance.find(params[:id])\n end",
"def set_maintenance\n @maintenance = Maintenance.find(params[:id])\n end",
"def set_device_maintenance\n @device_maintenance = DeviceMaintenance.find(params[:id])\n end",
"def enable\n @service.disabled = false\n end",
"def enable_offline_mode\n @offline_handler.enable if @options[:offline_queueing]\n end",
"def check_maintenance_page\n if ENV.key? 'VEC_MAINTENANCE_UNDERWAY'\n redirect_to \"/maintenance.html\"\n end\n end",
"def skip_maintenance\n runopts(:skip_maintenance) || 0\n end",
"def set_online_status\n self.online_status = \"offline\"\n end",
"def enable\n exclusively do\n @enabled = true\n @manual_toggle = true\n end\n\n save_state\n\n sync_control do\n start_upkeep unless upkeep_running?\n end\n end",
"def set_maintenance\n @maintenance = Maintenance.find(params[:id])\n end",
"def disable_perishable_token_maintenance?\n self.class.disable_perishable_token_maintenance == true\n end",
"def action_x\n play_decision_se\n @compact_mode = (@compact_mode == :enabled ? :disabled : :enabled)\n update_info_visibility\n update_info\n end",
"def maintenance\n @maintenance ||= Maintenance.new(self)\n end",
"def maintenance_options\n data[:maintenance_options]\n end",
"def forceupdate()\n rc = offline\n return rc if OpenNebula.is_error?(rc)\n\n enable\n end",
"def maintenance_mode?\n if ENV[\"MAINTENANCE_MODE\"] == \"true\"\n render \"errors/greenlight_error\", status: 503, formats: :html,\n locals: {\n status_code: 503,\n message: I18n.t(\"errors.maintenance.message\"),\n help: I18n.t(\"errors.maintenance.help\"),\n }\n end\n\n maintenance_string = @settings.get_value(\"Maintenance Banner\").presence || Rails.configuration.maintenance_window\n if maintenance_string.present?\n flash.now[:maintenance] = maintenance_string unless cookies[:maintenance_window] == maintenance_string\n end\n end",
"def set_online\n if @_config_service\n @_config_service.set_online\n else\n @log.warn(3202, \"Client is configured to use the `LOCAL_ONLY` override behavior, thus `set_online()` has no effect.\")\n end\n end",
"def turn_on!\n @turned_off = false\n end",
"def disable_alert_feature \n put(\"/globalsettings.json/alerts/disable\")\nend",
"def off\n heroku 'maintenance:off'\n end",
"def conditional_requests= enabled\n @agent.conditional_requests = enabled\n end",
"def disable_offline_mode\n @offline_handler.disable if @options[:offline_queueing]\n end",
"def EnableDisable\n # Workaround for bug #61055:\n Builtins.y2milestone(\"Enabling service %1\", \"network\")\n cmd = \"cd /; /sbin/insserv -d /etc/init.d/network\"\n SCR.Execute(path(\".target.bash\"), cmd)\n\n nil\n end",
"def set_offline\n @_config_service.set_offline if @_config_service\n end",
"def disable\n run \"#{try_sudo} /sbin/chkconfig httpd off\"\n end",
"def set_ac_maintenance\n @ac_maintenance = AcMaintenance.find(params[:id])\n end",
"def systemctl_change_enable(action)\n output = systemctl(action, @resource[:name])\n rescue\n raise Puppet::Error, \"Could not #{action} #{self.name}: #{output}\", $!.backtrace\n ensure\n @cached_enabled = nil\n end",
"def monitor_system\n if @is_fire || @is_power_outage || @is_mechanical_failure\n \n @status = \"offline\"\n for column in @column_list do\n column.status = \"offline\"\n for elevator in column.elevator_list do\n elevator.status = \"offline\"\n end\n end\n puts \"Battery #{@id} has been shut down for maintenance. Sorry for the inconvenience\"\n exit()\n end\n end",
"def toggle_availability\n if @chef.availability == true\n @chef.availability = false\n else\n @chef.availability = true\n end\n end",
"def enable\n CircleCi.request(conf, \"#{base_path}/enable\").post\n end",
"def offline()\n set_status(\"OFFLINE\")\n end",
"def disable_perishable_token_maintenance(value = nil)\n rw_config(:disable_perishable_token_maintenance, value, false)\n end",
"def EnableDisableNow\n if Modified()\n # Stop should be called before, but when the service\n # were not correctly started until now, stop may have\n # no effect.\n # So let's kill all processes in the network service\n # cgroup to make sure e.g. dhcp clients are stopped.\n RunSystemCtl(@cur_service_id_name, \"kill\")\n\n if @new_service_id_name == \"network\"\n RunSystemCtl(@cur_service_id_name, \"disable\")\n else\n RunSystemCtl(@new_service_id_name, \"--force enable\")\n end\n @cur_service_id_name = Service.GetServiceId(\"network\")\n @new_service_id_name = @cur_service_id_name\n end\n\n nil\n end",
"def set_maintenance_type\n @maintenance_type = MaintenanceType.find(params[:id])\n end",
"def enable\n run \"#{try_sudo} /sbin/chkconfig httpd on\"\n end",
"def disable\n disable_features :all\n end",
"def maintenance_actions\n\t\t\tif is_mortgaged?\n\t\t\t\t\t\tif @owner.decide(:consider_unmortgage, property: self).is_yes? and @owner.balance > cost\n\t\t\t\t\t\t\tunmortgage!\n\t\t\t\t\t\tend\n\t\t\tend\n\t\t\tsuper\n\t\tend",
"def keep_alive= enable\n @agent.keep_alive = enable\n end",
"def disable\n @service.disabled = true\n end",
"def enable_alert_feature \n put(\"/globalsettings.json/alerts/enable\")\nend",
"def enable\n @enabled = true\n end",
"def toggle!\n if status\n off!\n return false\n else\n on!\n return true\n end\n end",
"def enable!\n @active = true\n change_status(:wait)\n end",
"def disable\n exclusively do\n @enabled = false\n @manual_toggle = true\n end\n\n save_state\n sync_control { stop_upkeep }\n end",
"def service_enable!()\n @service = TAC_PLUS_AUTHEN_SVC_ENABLE\n end",
"def disable_on_production\n redirect_to home_path, alert: \"This action is currently disabled\" if Rails.env.production?\n end",
"def disable\n {\n method: \"Performance.disable\"\n }\n end",
"def list_maintenance(opts = {})\n data, _status_code, _headers = list_maintenance_with_http_info(opts)\n return data\n end",
"def switch!\n solr_endpoint.switch!\n fcrepo_endpoint.switch!\n redis_endpoint.switch!\n data_cite_endpoint.switch!\n switch_host!(cname)\n setup_tenant_cache(cache_api?) if self.class.column_names.include?('settings')\n end",
"def toggle_host_status\n if !self.host.listings.empty?\n self.host.update(host: true)\n else\n self.host.update(host: false)\n end\n end",
"def conditional_requests=(enabled); end",
"def cleaner_chore_switch(enableDisable)\n @admin.cleanerChoreSwitch(java.lang.Boolean.valueOf(enableDisable))\n end",
"def enable!\n self.enabled = true\n end",
"def toggle_admin\n do_toggle_role :admin\n end",
"def create_maintenance(body, opts = {})\n data, _status_code, _headers = create_maintenance_with_http_info(body, opts)\n return data\n end",
"def mark_as_offensive\n self.update_attribute(:status, 1)\n end",
"def switchDisconnectionON\n send(:SET_DISCONNECT, \"#{Experiment.ID}\", \"#{NodeHandler.instance.expFileURL}\", \"#{OmlApp.getServerAddr}\", \"#{OmlApp.getServerPort}\")\n end",
"def turn_on!\n set_power!(:on)\n end",
"def disable!\n @active = false\n change_status(:disabled)\n end",
"def enable\n end",
"def enable_manual_mode(temperature_request)\n serialized_auth_params = parameterize(auth_params)\n raw_response = connection.put \"/api/v2/homes/#{home_id}/zones/1/overlay?#{serialized_auth_params}\",\n manual_mode_request_params(temperature_request)\n if raw_response.success?\n SuccessResponse.new(raw_response.body)\n else\n ErrorResponse.new(raw_response.body)\n end\n end",
"def disable\n debug \"Call 'disable' for Pacemaker service '#{name}' on node '#{hostname}'\"\n unmanage_primitive name\n end",
"def set_contest_mode\n post(\"/api/set_contest_mode\", id: fullname, state: true)\n end",
"def site_enabled?\n unless current_account.site_enabled? || request.params['slug'] == 'coming_soon'\n unless user_signed_in? && (current_user.is_admin? || current_user.has_role?(:beta))\n redirect_to \"/#{current_account.preferred_default_locale}/coming_soon\"\n\n return false\n end\n end\n\n if current_account.site_maintenance?\n unless user_signed_in? && (current_user.is_admin? || current_user.has_role?(:beta))\n render text: '', layout: 'dm_core/maintenance'\n\n false\n end\n end\n end",
"def flag_xms_system_to_be_normal \n put(\"/globalsettings.json/xms/normal\")\nend",
"def enable\n end",
"def disabled?\n !Agent.config[:agent_enabled]\n end",
"def deactivate!\n update(status: false)\n end",
"def set_enabled\n\t\t\tself.enabled = true\n\t\tend",
"def get_maintenances()\n results = @zabbix.raw_api(\"maintenance.get\", {\"output\" => \"extend\", \"selectHosts\" => \"extend\", \"selectGroups\" => \"extend\"} )\n pp results\n end",
"def set_car_maintenance\n @car_maintenance = CarMaintenance.find(params[:id])\n authorize @car_maintenance\n end",
"def index\n permission_denied if !is_adm?\n @maintenance_requests = MaintenanceRequest.where(\"app_status = 0\")\n end",
"def toggle_admin\n self.is_admin = !self.is_admin\n save!(:validate => false)\n end",
"def normalizer_switch(enableDisable)\n @admin.normalizerSwitch(java.lang.Boolean.valueOf(enableDisable))\n end",
"def toggle(status)\n log_power_relay_connection(:toggle) do\n toggled_status = relay_connection.toggle(outlet, status)\n if secondary_outlet\n secondary_toggled_status = relay_connection.toggle(secondary_outlet, status)\n handle_mismatch_status(status, toggled_status) if toggled_status != secondary_toggled_status\n end\n toggled_status\n end\n end"
] | [
"0.7179096",
"0.69145447",
"0.6753331",
"0.670682",
"0.66946447",
"0.66529024",
"0.65764844",
"0.65567106",
"0.6490434",
"0.6470255",
"0.64409876",
"0.6370464",
"0.6296074",
"0.62374806",
"0.6174633",
"0.6159143",
"0.6152293",
"0.6128881",
"0.6074654",
"0.60273826",
"0.60273826",
"0.6019395",
"0.60007566",
"0.60007566",
"0.60007566",
"0.60007566",
"0.60007566",
"0.58820724",
"0.5869894",
"0.5842723",
"0.5823634",
"0.5813193",
"0.5788549",
"0.5788285",
"0.5772236",
"0.5764431",
"0.5741596",
"0.5736002",
"0.57269335",
"0.5704949",
"0.56715167",
"0.56592065",
"0.5627424",
"0.56052625",
"0.5598478",
"0.55885845",
"0.55558294",
"0.5548515",
"0.5539989",
"0.55342287",
"0.55322075",
"0.55302674",
"0.55234224",
"0.54944456",
"0.54864347",
"0.5473247",
"0.5472858",
"0.54598373",
"0.54548204",
"0.543931",
"0.54215217",
"0.54174227",
"0.5408861",
"0.5400003",
"0.5390257",
"0.5374732",
"0.53596586",
"0.53583664",
"0.5321658",
"0.5318758",
"0.5310578",
"0.5294931",
"0.52948064",
"0.5273556",
"0.5264676",
"0.5263541",
"0.5262128",
"0.52453816",
"0.52288187",
"0.522577",
"0.5221161",
"0.52058345",
"0.5204856",
"0.51879185",
"0.5174756",
"0.51664376",
"0.51590925",
"0.51559156",
"0.5155587",
"0.51518065",
"0.51516104",
"0.5149177",
"0.51404583",
"0.51316714",
"0.51294005",
"0.51177007",
"0.5116791",
"0.5107279",
"0.5106638",
"0.5092859"
] | 0.6822855 | 2 |
/FIX FOR AN ISSUE WITH MINITEST AND RAILS 4 | def admin?
@current_user && @current_user.has_role?(:admin)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ordered_railties; end",
"def ordered_railties; end",
"def migration_railties; end",
"def migration_railties; end",
"def dev_minor() end",
"def appraisals; end",
"def appraisals; end",
"def production_curtailment; end",
"def on_307; on_330; end",
"def orm_patches_applied; end",
"def version_helper; end",
"def version_helper; end",
"def version_helper; end",
"def version_helper; end",
"def railties_order; end",
"def railties_order; end",
"def upgrade_app_explain; \"Check for updates to Hobix.\"; end",
"def before_bootstrap; end",
"def ridicule_faultfully_prerevision()\n end",
"def target_version; end",
"def allow_production; end",
"def allow_production=(_arg0); end",
"def before_setup; end",
"def lybunt_setup\n end",
"def conscientious_require; end",
"def autorun; end",
"def patch_version; end",
"def sitemaps; end",
"def site_cleaner; end",
"def bump_patch_version; end",
"def blog_on_upgrade(plugin)\r\n end",
"def major_version; end",
"def supported_by_rails?\n ::Rails::VERSION::MAJOR.to_i < 4\n end",
"def view_with_check_option_support\n # :nocov:\n :local if server_version >= 90400\n # :nocov:\n end",
"def before_lint; end",
"def http_minor; end",
"def one_gradable_ex_only\n end",
"def version_mismatch_detected\n end",
"def prerelease_specs; end",
"def bump_major_version; end",
"def def_version; end",
"def default_version; end",
"def rails_3\n defined?(ActiveRecord::VERSION) && ActiveRecord::VERSION::MAJOR >= 3\nend",
"def orm_patches_applied=(_arg0); end",
"def vendor; end",
"def server_version; end",
"def palladius_version\n\t:TODO\nend",
"def target_mysql_version; end",
"def pre_install; end",
"def silence_deprecations; end",
"def private; end",
"def before_resolution\n end",
"def hijacked; end",
"def prepare_for_installation; end",
"def major; end",
"def major; end",
"def major; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def refutal()\n end",
"def meteorite; end",
"def minor_version; end",
"def before_run; end",
"def development\r\n\r\n end",
"def server_errors; end",
"def camaleon_pagenotfound_on_upgrade(plugin)\n end",
"def raise_deprecations; end",
"def libs; end",
"def romeo_and_juliet; end",
"def active_record_at_least_4?\n defined?(::ActiveRecord) && ::ActiveRecord::VERSION::MAJOR >= 4\nend",
"def rails_quirks(config, &block)\n # Rails 4 no longer allows constant syntax in routing. \n # https://github.com/bploetz/versionist/issues/39\n # call underscore on the module so it adheres to this convention\n config[:module] = config[:module].underscore if Rails::VERSION::MAJOR >= 4\n end",
"def fallbacks; end",
"def fallbacks; end",
"def before_dispatch(env); end",
"def target_mysql_version=(_arg0); end",
"def handle_post_mortem; end",
"def before_bootstrap\n end",
"def relative_permalinks_are_deprecated; end",
"def middlewares_stack; end",
"def dependencies; end"
] | [
"0.5719549",
"0.5719549",
"0.55357546",
"0.55357546",
"0.54979336",
"0.5453287",
"0.5453287",
"0.5435803",
"0.5413073",
"0.5394526",
"0.5381407",
"0.5381407",
"0.5381407",
"0.5381407",
"0.53382653",
"0.53382653",
"0.53343225",
"0.5322545",
"0.5305532",
"0.5281019",
"0.5275196",
"0.52687657",
"0.52686626",
"0.523682",
"0.52200675",
"0.5202475",
"0.5194528",
"0.5163998",
"0.5156829",
"0.51539814",
"0.51478875",
"0.5142011",
"0.5137897",
"0.51334023",
"0.51302445",
"0.5122514",
"0.51196265",
"0.5107984",
"0.50861996",
"0.5077048",
"0.50748616",
"0.5061428",
"0.5055564",
"0.5041014",
"0.50399345",
"0.5038276",
"0.5030073",
"0.50205916",
"0.50130045",
"0.4980441",
"0.49760628",
"0.49749273",
"0.49696648",
"0.49610272",
"0.49561885",
"0.49561885",
"0.49561885",
"0.49535438",
"0.49535438",
"0.49535438",
"0.49535438",
"0.49535438",
"0.49535438",
"0.49535438",
"0.49535438",
"0.49535438",
"0.49535438",
"0.49535438",
"0.49535438",
"0.49535438",
"0.49535438",
"0.49535438",
"0.49535438",
"0.49535438",
"0.49535438",
"0.49535438",
"0.49535438",
"0.49535438",
"0.49535438",
"0.49535438",
"0.49451122",
"0.49434933",
"0.49245247",
"0.49234822",
"0.4922346",
"0.49214557",
"0.4918368",
"0.49142873",
"0.49061444",
"0.48965293",
"0.48908505",
"0.48855236",
"0.48816356",
"0.48816356",
"0.48783427",
"0.48745388",
"0.48736325",
"0.4867186",
"0.48580536",
"0.4852048",
"0.48506108"
] | 0.0 | -1 |
GET /comments GET /comments.json | def index
cr = current_rulemaking
conditions = get_conditions
if conditions[0].empty?
c = cr.comments.all
else
#do left outer join in case there are no conditions on suggested_changes
c = cr.comments.where("id IN (?)", cr.comments.left_outer_joins(:suggested_changes).where(conditions).select(:id))
end
c = c.order(:order_in_list)
respond_to do |format|
format.html {
@total_comments = cr.comments.count
@total_commenters = cr.comments.sum(:num_commenters)
@filtered = !conditions[0].empty?
@filter_querystring = remove_empty_elements(filter_params_all)
@comments = c.page(params[:page]).per_page(10)
}
format.xlsx {
@comments = c
response.headers['Content-Disposition'] = 'attachment; filename="comments.xlsx"'
}
format.csv {
stream_csv(c)
}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def comments\n client.get(\"/#{id}/comments\")\n end",
"def comments\n @list.client.get(\"#{url}/comments\")\n end",
"def comments\n @list.client.get(\"#{url}/comments\")\n end",
"def comments\n render json: @post.comments\n end",
"def list\n comments = Comment.where(post: @post)\n render json: comments, status: 200\n end",
"def comments; rest_query(:comment); end",
"def comments\n @article = Article.find(params[:id])\n @comments = @article.comments\n\n respond_to do |format|\n format.html \n format.json { render json: @comments, status: :ok }\n end\n end",
"def index\n @comments = Comment.all\n render json: @comments\n end",
"def show\n user = User.find_by({token: env['HTTP_TOKEN']})\n render json: user.comments.find(params[:id])\n end",
"def show\n # comment = Comment.find_comment\n render json: @comment\n end",
"def index\n comments = @project.comments\n render json: comments\n end",
"def show\n @comments = @post.comments\n respond_to do |format|\n format.html\n format.json\n end\n end",
"def comments(options={})\n parse_comments(request(singular(id) + \"comments\", options))\n end",
"def index\n @comments = DiscussionComment.all\n render json: @comments\n end",
"def show\n comment = Comment.find(params[:id])\n render json: comment, status: 200\n end",
"def index\n @comments = @commentable.comments\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @comments }\n end\n end",
"def all_comments\n render :json => User.find(params[:user_id]).comments\n end",
"def index\n #@comments = Comment.all\n comments = @blog.comments\n render json: comments, status: :ok\n end",
"def index\n @post = Post.find_by_id(params[:post_id])\n if @post.nil?\n return render json: { error: \"Post not found\" }, status: :not_found\n end\n render json: @post.comments,status: 200\n end",
"def show\n @comment = Comment.find(params[:id])\n render json:@comment\n end",
"def show\n render json: @comment\n end",
"def show\n comment = Comment.find_by(id: params[:id])\n render json: comment\n end",
"def show\n render json: comment\n end",
"def GetComments id,params = {}\n\n params = params.merge(path: \"tickets/#{id}/comments.json\")\n APICall(params)\n\n end",
"def index\n @post = Post.find(params[:post_id])\n @comments = @post.comments\n\n render json: @comments, include: ['user']\n end",
"def show\n comment = Comment.find(params[:id])\n render json: comment, status: :ok\n end",
"def index\n @comments = Comment.where('user_id = ?', current_user.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @comments }\n end\n end",
"def index\n if params[:comment_id].nil?\n render json: {\n comments: @card.comments.paginate(page: params[:page], per_page: 3)\n }, statues: :ok\n else\n @comment = Comment.find(params[:comment_id])\n render json: {\n comment: @comment,\n replaies: @comment.replaies.paginate(page: params[:page], per_page: 3)\n }, statues: :ok\n end\n end",
"def comments(options = {})\n comments_resource(options)\n end",
"def show\n @comment = @commentable.comments.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def index\n logger.info(\"comments got index! #{params}\");\n @comments = Comment.find_by_post_id(params[:post_id])\n respond_with @comments\n end",
"def index\n @comments = Comment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @comments }\n end\n end",
"def index\n @comments = Comment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @comments }\n end\n end",
"def index\n @comments = Comment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @comments }\n end\n end",
"def comments(options = {})\n urn = options.delete(:urn)\n path = \"/socialActions/#{urn}/comments\"\n get(path, options)\n end",
"def get_comments(user_name)\n uri = create_api_uri(@@base_uri, user_name, 'getComments')\n return get(uri)\n end",
"def comments(options={})\n self.class.parse_comments(request(singular(user_id) + \"/comments\", options))\n end",
"def index\n comments = @post.comments\n render json: { comments: comments }\n #loop through comments and find first and last name by user_id\n #User.find....etc\n end",
"def show\n @post = Post.find(params[:id])\n @comments = Comment.where(:post_id => params[:id]).order(\"id desc\")\n @comments = @comments.page(params[:page]).per(20)\n @comment = Comment.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def index\n if params[:_post_id]\n post_comments = PostComment.where(post_id: params[:_post_id])\n render json: post_comments.as_json(\n include: { user: { only: [:name, :id] } },\n except: [:post_id, :user_id]),\n status: :ok\n else\n render json: @current_user.post_comments.as_json(\n include: { post: { only: [:title, :id, :excerpt] } },\n except: [:user_id, :post_id]),\n status: :ok\n end\n end",
"def show\n @comment = @posting.comments.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def get_comment(comment_id)\n get(\"comments/#{comment_id}\")\n end",
"def show\n @post = Post.find(params[:id])\n @comments = @post.comments.order('created_at DESC')\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def comments\n Birdman::ApiPaginatedCollection.new(\"movies/#{id}/comments\")\n end",
"def get_comments(parameters = {})\n if @answer_comments_url\n hash,url =request(@answer_comments_url, parameters)\n Comments.new hash, url\n else\n nil\n end\n end",
"def show\n render json: { comment: @comment, replaies: @comment.replaies }, status: :ok\n end",
"def index\n @comments = @post.comments.order(created_at: :desc)\n render json: @comments, status: :ok\n\n end",
"def show\n @comment = Comment.find(params[:id])\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def index\n @comments = @complaint.comments\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @comments }\n format.js\n end\n end",
"def index\n event = Event.find(params[:event_id])\n render json: event.comments, status: :ok\n end",
"def index\n @comments = @entry.comments\n respond_with(@comments)\n end",
"def show\n logger.info(\"comments got show! #{params}\");\n @comments = Comment.find_by_post_id(params[:post_id])\n respond_with @comments\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n render json: @comment, status: :ok\n\n end",
"def comments\n expose Challenge.comments(@oauth_token, params[:challenge_id].strip)\n end",
"def show\n @comment = Comment.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n \tend\n end",
"def comments_for(url)\n get_data(\"comments/show/#{FORMAT}?url=#{url}\")\n end",
"def index\n @comments = Comment.order(\"created_at DESC\")\n render json: @comments, status: :ok\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @comment }\n end\n end",
"def comments(options={})\n parse_comments(request(singular(answer_id) + \"/comments\", options))\n end",
"def show\n @comment = Comment.new\n @comments = Comment.get_post_comments @post\n if session[:comment_errors]\n session[:comment_errors].each {|error, error_message| @comment.errors.add error, error_message}\n session.delete :comment_errors\n end\n respond_to do |format|\n format.html\n format.json { render :json => {:post => @post, :comments => @comments, :status => 200} }\n end\n end",
"def show\n if @comment.nil?\n render json: {error: \"Not Found\"}, status: :not_found\n else\n render json: @comment, status: :ok\n end\n end",
"def comment(options)\n get(\"/content/items/#{options.delete(:item)}/comments/#{options[:id]}\",options)\n end",
"def index\n post = Post.find(params[:post_id])\n comments = post.comments.order(updated_at: :desc)\n @comment = Comment.new\n\n @comments = comments.map do |comment|\n {\n content: comment.content,\n created_at: comment.created_at.strftime('%Y-%m-%d %H:%M:%S')\n }\n end\n\n render json: {\n data: {\n comments: @comments,\n new_comment: @comment,\n }\n }\n end",
"def comments\n @data['comments']\n end",
"def comments\n @data['comments']\n end",
"def comments\n @data['comments']\n end",
"def details(id, params = {})\n wrike.execute(:get, api_url(\"comments/#{id}\"), params)\n end",
"def show\n render json: { blog: @blog, comments: @blog.comments }\n end",
"def show\n recipe = Recipe.find_by_id(params[:id])\n\n respond_to do |format|\n if recipe\n @comments = []\n comments = recipe.comments\n for comment in comments\n comment_user = comment.user\n @comments << { :user => comment_user, :profile_picture => comment_user.profile_picture.url, :comment => comment }\n end\n\n format.json { render :json => @comments }\n else\n format.json { render :status => 404, :json => { :message => \"No such Recipe\"}}\n end\n end\n end",
"def gist_comments(id)\n get \"/gists/#{id}/comments\"\n end",
"def show\n @comments = @servidor.comments.order(\"id DESC\").page(params[:page]).per(3)\n end",
"def get_comments_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: NotesApi#get_comments ...\"\n end\n \n # verify the required parameter 'id' is set\n fail \"Missing the required parameter 'id' when calling get_comments\" if id.nil?\n \n # resource path\n path = \"/Notes/{id}/Comments\".sub('{format}','json').sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'updated_after_utc'] = opts[:'updated_after_utc'] if opts[:'updated_after_utc']\n query_params[:'skip'] = opts[:'skip'] if opts[:'skip']\n query_params[:'top'] = opts[:'top'] if opts[:'top']\n query_params[:'count_total'] = opts[:'count_total'] if opts[:'count_total']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, 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 => 'Array<APIComment>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: NotesApi#get_comments\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def comments(options = {})\n options = { query: options } if options.any?\n @party.get(\"forms/#{@id}/comments\", options)['Comments']\n end",
"def comments(options={})\n @comments ||= self.class.parse_comments(request(singular(question_id) + \"/comments\", options))\n end",
"def moment_comments(moment_id)\n get(\"/v1/moments/#{moment_id}/comments\")\n end",
"def show\n @comment = @song.comments.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @post = Post.find(params[:id], include: :comments, order: 'comments.id')\n @comment = Comment.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end"
] | [
"0.8573962",
"0.7837408",
"0.7837408",
"0.7555969",
"0.75293446",
"0.75213426",
"0.74966145",
"0.739651",
"0.7300984",
"0.729431",
"0.7285037",
"0.72734404",
"0.72714454",
"0.7247879",
"0.724236",
"0.7208452",
"0.72043866",
"0.71849746",
"0.7177853",
"0.71577495",
"0.715637",
"0.71523017",
"0.7151779",
"0.7122801",
"0.7119892",
"0.70823574",
"0.70677185",
"0.706358",
"0.7045548",
"0.7043117",
"0.70078856",
"0.7007218",
"0.7007218",
"0.7007218",
"0.6973575",
"0.6969643",
"0.69535303",
"0.6948626",
"0.6906692",
"0.6902268",
"0.6884187",
"0.6880588",
"0.68654644",
"0.68513423",
"0.68475986",
"0.6832113",
"0.6828179",
"0.6827886",
"0.682376",
"0.6817521",
"0.6814513",
"0.6810818",
"0.6797189",
"0.679708",
"0.679708",
"0.679708",
"0.679708",
"0.679708",
"0.679708",
"0.679708",
"0.679708",
"0.679708",
"0.679708",
"0.679708",
"0.679708",
"0.679708",
"0.679708",
"0.679708",
"0.679708",
"0.679708",
"0.679708",
"0.679708",
"0.679708",
"0.679708",
"0.67914844",
"0.6790401",
"0.6785833",
"0.67549706",
"0.6751294",
"0.6745202",
"0.6745202",
"0.6745202",
"0.6737495",
"0.6727641",
"0.67110837",
"0.66982234",
"0.6685779",
"0.6673027",
"0.6673027",
"0.6673027",
"0.6669462",
"0.6666116",
"0.66634387",
"0.6663246",
"0.6642118",
"0.6635168",
"0.66337067",
"0.66208297",
"0.6613603",
"0.6613087",
"0.660651"
] | 0.0 | -1 |
GET /comments/1 GET /comments/1.json | def show
get_filtering_and_next_and_previous
@change_log_entries = current_rulemaking.change_log_entries.where(comment: @comment).order(created_at: :desc).page(params[:page]).per_page(10)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def comments\n client.get(\"/#{id}/comments\")\n end",
"def comments\n @list.client.get(\"#{url}/comments\")\n end",
"def comments\n @list.client.get(\"#{url}/comments\")\n end",
"def comments\n @article = Article.find(params[:id])\n @comments = @article.comments\n\n respond_to do |format|\n format.html \n format.json { render json: @comments, status: :ok }\n end\n end",
"def show\n comment = Comment.find(params[:id])\n render json: comment, status: 200\n end",
"def comments; rest_query(:comment); end",
"def comments\n render json: @post.comments\n end",
"def show\n @comment = Comment.find(params[:id])\n render json:@comment\n end",
"def show\n user = User.find_by({token: env['HTTP_TOKEN']})\n render json: user.comments.find(params[:id])\n end",
"def show\n # comment = Comment.find_comment\n render json: @comment\n end",
"def show\n comment = Comment.find_by(id: params[:id])\n render json: comment\n end",
"def show\n @comment = @commentable.comments.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n comment = Comment.find(params[:id])\n render json: comment, status: :ok\n end",
"def show\n @comments = @post.comments\n respond_to do |format|\n format.html\n format.json\n end\n end",
"def index\n @comments = @commentable.comments\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @comments }\n end\n end",
"def index\n @post = Post.find_by_id(params[:post_id])\n if @post.nil?\n return render json: { error: \"Post not found\" }, status: :not_found\n end\n render json: @post.comments,status: 200\n end",
"def index\n comments = @project.comments\n render json: comments\n end",
"def index\n @comments = DiscussionComment.all\n render json: @comments\n end",
"def show\n @comment1 = Comment1.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment1 }\n end\n end",
"def index\n @comments = Comment.all\n render json: @comments\n end",
"def get_comment(comment_id)\n get(\"comments/#{comment_id}\")\n end",
"def index\n if params[:comment_id].nil?\n render json: {\n comments: @card.comments.paginate(page: params[:page], per_page: 3)\n }, statues: :ok\n else\n @comment = Comment.find(params[:comment_id])\n render json: {\n comment: @comment,\n replaies: @comment.replaies.paginate(page: params[:page], per_page: 3)\n }, statues: :ok\n end\n end",
"def list\n comments = Comment.where(post: @post)\n render json: comments, status: 200\n end",
"def show\n @comment = @posting.comments.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def index\n #@comments = Comment.all\n comments = @blog.comments\n render json: comments, status: :ok\n end",
"def show\n @post = Post.find(params[:id])\n @comments = Comment.where(:post_id => params[:id]).order(\"id desc\")\n @comments = @comments.page(params[:page]).per(20)\n @comment = Comment.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n render json: comment\n end",
"def show\n render json: @comment\n end",
"def GetComments id,params = {}\n\n params = params.merge(path: \"tickets/#{id}/comments.json\")\n APICall(params)\n\n end",
"def index\n comments = @post.comments\n render json: { comments: comments }\n #loop through comments and find first and last name by user_id\n #User.find....etc\n end",
"def show\n @comment = Comment.find(params[:id])\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def all_comments\n render :json => User.find(params[:user_id]).comments\n end",
"def get_comment\n @comment = Comment.find(params[:id])\n end",
"def comment\n Comment.find(params[:id])\n end",
"def show\n @comment = Comment.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n \tend\n end",
"def index\n @comments = Comment.where('user_id = ?', current_user.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @comments }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def comments_for(url)\n get_data(\"comments/show/#{FORMAT}?url=#{url}\")\n end",
"def comments(options={})\n parse_comments(request(singular(id) + \"comments\", options))\n end",
"def index\n @comments = Comment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @comments }\n end\n end",
"def index\n @comments = Comment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @comments }\n end\n end",
"def index\n @comments = Comment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @comments }\n end\n end",
"def show\n render json: { comment: @comment, replaies: @comment.replaies }, status: :ok\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @comment }\n end\n end",
"def index\n logger.info(\"comments got index! #{params}\");\n @comments = Comment.find_by_post_id(params[:post_id])\n respond_with @comments\n end",
"def details(id, params = {})\n wrike.execute(:get, api_url(\"comments/#{id}\"), params)\n end",
"def comments\n Birdman::ApiPaginatedCollection.new(\"movies/#{id}/comments\")\n end",
"def show\n @post = Post.find(params[:id])\n @comments = @post.comments.order('created_at DESC')\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @comments = Recipe.find(params[:recipe_id]).comments.all\n @comment = Recipe.find(params[:recipe_id]).comments.find(params[:id]) \n if @comment \n respond_to do |f|\n f.html {render :index}\n f.json {render json: @comment}\n end\n else\n @comments\n respond_to do |f|\n f.html {render :index}\n f.json {render json: @comments}\n end\n end\n end",
"def show\n @comments = @servidor.comments.order(\"id DESC\").page(params[:page]).per(3)\n end",
"def index\n @post = Post.find(params[:post_id])\n @comments = @post.comments\n\n render json: @comments, include: ['user']\n end",
"def comment(options)\n get(\"/content/items/#{options.delete(:item)}/comments/#{options[:id]}\",options)\n end",
"def show\n @comment = @song.comments.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find_by_permalink(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def index\n @comments = @entry.comments\n respond_with(@comments)\n end",
"def index\n @comments = @post.comments.order(created_at: :desc)\n render json: @comments, status: :ok\n\n end",
"def show\n @post = Post.find(params[:id], include: :comments, order: 'comments.id')\n @comment = Comment.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n render json: @comment, status: :ok\n\n end",
"def show\n @new_comment = Comment.build_from(@post, \"\")\n\n render json: @post, status: 200\n\n\n end",
"def show\n recipe = Recipe.find_by_id(params[:id])\n\n respond_to do |format|\n if recipe\n @comments = []\n comments = recipe.comments\n for comment in comments\n comment_user = comment.user\n @comments << { :user => comment_user, :profile_picture => comment_user.profile_picture.url, :comment => comment }\n end\n\n format.json { render :json => @comments }\n else\n format.json { render :status => 404, :json => { :message => \"No such Recipe\"}}\n end\n end\n end",
"def index\n @comments = @complaint.comments\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @comments }\n format.js\n end\n end",
"def index\n comments = list.comments.desc(:created_at)\n comments = comments[5, (comments.length-1)]\n\n render json: comments\n end",
"def show\n @comments = Comment.where(post_id: params[:id])\n end",
"def gist_comments(id)\n get \"/gists/#{id}/comments\"\n end",
"def show\n logger.info(\"comments got show! #{params}\");\n @comments = Comment.find_by_post_id(params[:post_id])\n respond_with @comments\n end",
"def index\n event = Event.find(params[:event_id])\n render json: event.comments, status: :ok\n end",
"def show\n if @comment.nil?\n render json: {error: \"Not Found\"}, status: :not_found\n else\n render json: @comment, status: :ok\n end\n end",
"def comments\n expose Challenge.comments(@oauth_token, params[:challenge_id].strip)\n end",
"def index\n @comments = Comment.order(\"created_at DESC\")\n render json: @comments, status: :ok\n end",
"def get_comments(user_name)\n uri = create_api_uri(@@base_uri, user_name, 'getComments')\n return get(uri)\n end",
"def index\n if params[:_post_id]\n post_comments = PostComment.where(post_id: params[:_post_id])\n render json: post_comments.as_json(\n include: { user: { only: [:name, :id] } },\n except: [:post_id, :user_id]),\n status: :ok\n else\n render json: @current_user.post_comments.as_json(\n include: { post: { only: [:title, :id, :excerpt] } },\n except: [:user_id, :post_id]),\n status: :ok\n end\n end",
"def view_comment\n @comment = Comment.find(params[:id])\n end",
"def show\n @comment_relationship = CommentRelationship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment_relationship }\n end\n end",
"def index\n # @post = Post.find(params[:post_id])\n @comments = @post.comments\n end",
"def index\n @comments = @commentable.comments\n end",
"def show\n @messages_comment = MessagesComment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @messages_comment }\n end\n end",
"def show\n @comment = @complaint.comments.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @comment }\n format.js\n end\n end",
"def show\n #@post = Post.find(params[:id])\n @comment = Comment.new\n @comment_container_id_prefix = COMMENT_CONTAINER_ID_PREFIX\n respond_to do |format|\n format.html\n format.json { render json: @post, except: :updated_at, :include => {:user => {:only => [:name]}}}\n end\n end"
] | [
"0.82821167",
"0.74428797",
"0.74428797",
"0.7435283",
"0.74061906",
"0.7305913",
"0.7283544",
"0.7258592",
"0.72560287",
"0.72484696",
"0.7243203",
"0.7219824",
"0.7219523",
"0.7218877",
"0.7174389",
"0.7158426",
"0.71583927",
"0.71185815",
"0.711669",
"0.710114",
"0.71007395",
"0.70947987",
"0.70777875",
"0.7061423",
"0.70478845",
"0.70425916",
"0.702815",
"0.70109457",
"0.6991476",
"0.69748074",
"0.69611824",
"0.6952931",
"0.6952265",
"0.6913634",
"0.6913084",
"0.6906848",
"0.68979174",
"0.68979174",
"0.68979174",
"0.68979174",
"0.68979174",
"0.68979174",
"0.68979174",
"0.68979174",
"0.68979174",
"0.68979174",
"0.68979174",
"0.68979174",
"0.68979174",
"0.68979174",
"0.68979174",
"0.68979174",
"0.68979174",
"0.68979174",
"0.68979174",
"0.68979174",
"0.68979174",
"0.68976206",
"0.68811107",
"0.6878177",
"0.6866972",
"0.6866972",
"0.6866972",
"0.6865512",
"0.6861285",
"0.6861285",
"0.6861285",
"0.68585694",
"0.68560964",
"0.6851094",
"0.6829041",
"0.682315",
"0.68061686",
"0.6804166",
"0.6793837",
"0.6787325",
"0.67831755",
"0.67663115",
"0.6765632",
"0.6759219",
"0.6746523",
"0.6740265",
"0.67244303",
"0.6720426",
"0.67131984",
"0.6705833",
"0.66964877",
"0.66928446",
"0.66880786",
"0.6683499",
"0.6683431",
"0.66689175",
"0.6668772",
"0.66339755",
"0.66250896",
"0.6619791",
"0.6619633",
"0.66194606",
"0.6619031",
"0.6618492",
"0.6614356"
] | 0.0 | -1 |
POST /comments POST /comments.json | def create
# we only get here if this comment is being manually entered.
@comment = Comment.new(comment_params)
c_max = current_rulemaking.comments.maximum(:order_in_list)
next_order_in_list = (c_max.nil? ? 0 : c_max) + 1
@comment.order_in_list = next_order_in_list
@comment.rulemaking = current_rulemaking
@comment.manually_entered = true
respond_to do |format|
if @comment.save
suggested_change_change_hash = save_suggested_changes
save_change_log(current_user,{comment: @comment, suggested_change_changes: suggested_change_change_hash, action_type: 'create'})
format.html { redirect_to edit_comment_path(@comment), notice: 'Comment was successfully created.' }
format.json { render :show, status: :created, location: @comment }
else
set_select_options
format.html { render :new }
format.json { render json: @comment.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @comment = @post.comments.new(comment_params)\n if @comment.save\n render json: @comment, status: :created\n else\n render json: @comment.errors, status: :unprocessable_entity\n end\n\n end",
"def comment options={}\n client.post(\"/#{id}/comments\", options)\n end",
"def create\n post = Post.find(params[:post_id])\n @comment = post.comments.new(comment_params)\n if @comment.save\n render json: {\n data: @comment\n }\n else\n render json: {\n errors: @comment.errors\n }\n end\n end",
"def create\n puts params.to_json\n @post = Post.find(params[:comment][:post_id])\n @comment = @post.comments.build(comment_params)\n if @comment.save\n redirect_to root_path\n end\n end",
"def create\n comment = Comment.new(comment_params)\n\n post = Post.find(params[:comment][:post_id])\n post.data[\"comments\"] = post.data[\"comments\"] + 1\n\n if comment.save && post.save\n render json: {\n status: \"success\",\n data: {\n comment: comment.as_json(include: {\n user: {\n only: [:id, :name, :avatar]\n }\n }),\n comments: post.data[\"comments\"]\n }\n }, status: :ok\n else\n render json: comment.errors, status: 404\n end\n end",
"def create\n @comment = Comment.new(params[:comment])\n @comment.save\n respond_with(@post, @comment)\n end",
"def create\n json_create_and_sanitize(comment_params, Comment)\n end",
"def create\n comment = Comment.new(create_params)\n comment.post = @post\n if comment.save\n render json: comment, status: 200\n else\n render json: comment.errors, status: 403\n end\n\n end",
"def create\n # get the post\n @post = Post.find_by_id(params[:post_id])\n if @post.nil?\n return render json: { error: \"Post not found\" }, status: :not_found\n end\n # create post to comment\n @comment = @post.comments.create(body: params[:body])\n # associate comment before save(comment cannot be saved without user_id)\n @comment.user = @current_user\n # save comment\n if @comment.save\n render json: @comment, status: :ok\n else\n render json: { errors: { status: \"400\",\n title: \"Bad request\",\n details: @comment.errors\n }\n }, status: :bad_request\n end\n end",
"def create\n @new_comment = post.comments.new(comment_params)\n @new_comment.user = current_user\n\n respond_to do |format|\n if @new_comment.save\n format.html { redirect_to post, notice: I18n.t('controllers.comments.created') }\n format.json { render :show, status: :created, location: post }\n else\n format.html { redirect_to post, alert: I18n.t('controllers.comments.error') }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @comment = Comment.new({user_id: params[:user_id], announcement_id: params[:announcement_id], description: params[:description]})\n @comment.save\n render json:@comment\n end",
"def create\n @comment = @noticia.comments.create(comment_params)\n\n if @comment.save\n render json: @comment, status: :created\n else\n render json: @comment.errors, status: :unprocessable_entity\n end\n end",
"def create\n #if @user && @user.posts.include(@post)\n @comment = @post.comments.create!(comment_params)\n json_response(@comment, :created)\n end",
"def create\n @comment = Comment.new(comment_params)\n\n respond_to do |format|\n if @comment.save\n format.json { render :show, status: :created, location: @comment }\n else\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @comment = current_user.comments.new(comment_params)\n @comment.user_id = current_user.id\n if @comment.save\n render json: @comment\n else\n render :json => @comment.errors\n end\n end",
"def create\n comment = @project.comments.build(comment_params)\n\n if comment.save\n render json: comment \n else\n render json: { message: 'Error: Failed to add comment.'}\n end\n end",
"def create\n @comment = @user.comments.build(@json['comment'])\n update_values :@comment, @json['comment']\n end",
"def create\n @post = Post.where(id: params[:post_id]).first\n @comment = @post.comments.new(params[:comment])\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @post, notice: 'Comment was successfully created.' }\n format.json { render json: @comment, status: :created, location: @comment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def comments\n render json: @post.comments\n end",
"def create\n @blogpost = Blogpost.find(params[:blogpost_id])\n\n @comment = @blogpost.comments.create(comment_params)\n render json: @comment\n end",
"def create\n @comment = Comment.new(comment_params)\n respond_to do |format|\n if @comment.save\n format.json {\n render json: {status:0, msg:\"success\"} \n }\n else\n \tformat.json { \n render json: {status:-1, msg:\"failed\"} \n }\n end\n end\n end",
"def create\n @radio = Radio.find(params[:radio_id])\n comment = @radio.comments.create({:body => params[:comment], :user_id => current_user.id});\n respond_to do |format|\n format.json { render :json => to_commentDTO(comment), :status => :ok }\n end\n end",
"def create\n @comment = Comment.new(params[:comment])\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to comments_url, notice: 'Comment was successfully created.' }\n format.json { render json: @comment, status: :created, location: @comment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n session = UserSession.find_by_authentication_token(params[:authentication_token])\n user = session.user\n \n respond_to do |format|\n if user\n @comment = Comment.new(:user_id => user.id, :recipe_id => params[:recipe_id], :text => params[:text])\n \n if @comment.save\n recipe = Recipe.find_by_id([params[:recipe_id]])\n\n @comments = recipe.fetch_comments\n format.json { render :json => { :comments => @comments, :message => \"success\"} }\n else\n format.json { render :status => 500, :json => { :message => \"There was an error uploading your comment.\" }}\n end\n else\n format.json { render :json => { :message => \"Invalid authentication token\"}} \n end\n end\n end",
"def create\n @comment = Comment.new(post_params)\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to root_path, notice: 'Post was successfully created.' }\n format.json { render root_path, status: :created, location: @comment }\n else\n format.html { render :new }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.find(params[:post_id])\n @comment = @post.comments.build(params[:comment])\n respond_to do |format|\n if @comment.save\n format.json { render :json => @comment }\n else\n format.json { render :json => @comment.errors, :status => :unprocessable_entity}\n end\n end\n #respond_with(@post,@post.comments.create(params[:comment]))\n end",
"def comments\n client.get(\"/#{id}/comments\")\n end",
"def create\n \tnew_comment = params.require(:comment).permit(:body)\n \tpost = Post.find(params[:post_id])\n \tcomment = post.comments.create(new_comment)\n\n \tredirect_to post_comment_path(post, comment)\n end",
"def create\n @comment = @secret.comments.build(comment_params)\n @comment.user_id = current_user.id.to_s\n if @comment.save\n comment = CommentModel.new(@comment, current_user)\n render json: comment\n else\n render json: @comment.errors, status: :unprocessable_entity\n end\n end",
"def create\n @comment = Comment.new(comment_params)\n @comment.user_id = @current_user.json_hash[:id]\n @comment.dinner_id = params[:id]\n if @comment.valid?\n @comment.save\n render json: @comment.comment_info\n else\n puts @comment.errors.messages.inspect\n render status: :bad_request, json: {\n errors: @comment.errors.messages\n }\n end\n end",
"def create\n @comment = Comment.new(comment_params)\n @comment.user = current_user\n if @comment.save\n render json: @comment\n # redirect_to recipe_path(@comment.recipe.id, @comment)\n else\n render \"recipes/show\"\n end\n end",
"def create\n @comment = Comment.new(comment_params)\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @comment, notice: 'Comment was successfully created.' }\n format.json { render :show, status: :created, location: @comment }\n else\n format.html { render :new }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @comment = Comment.new(comment_params)\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @comment, notice: 'Comment was successfully created.' }\n format.json { render :show, status: :created, location: @comment }\n else\n format.html { render :new }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @comment = Comment.new(comment_params)\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @comment, notice: 'Comment was successfully created.' }\n format.json { render :show, status: :created, location: @comment }\n else\n format.html { render :new }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @comment = Comment.new(comment_params)\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @comment, notice: 'Comment was successfully created.' }\n format.json { render :show, status: :created, location: @comment }\n else\n format.html { render :new }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @comment = Comment.create(content: params[:content])\n current_user.comments << @comment\n current_user.save\n\n idea = Idea.find(params[:ideaId])\n idea.comments << @comment\n idea.comments.order(\"created_at DESC\")\n idea.save\n respond_to do |format|\n format.json {render json: @comment}\n end\n end",
"def create\n @comment = Comment.new(params[:comment])\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to admin_comments_url, notice: 'Comment was successfully created.' }\n format.json { render json: @comment, status: :created, location: @comment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @comment = current_user.comments.build(comment_params)\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to \"/posts/#{@comment.post_id}\" }\n format.json { render :show, status: :created, location: @comment }\n else\n errors = @comment.errors.full_messages.join('! ')\n format.html { redirect_to \"/posts/#{@comment.post_id}\", alert: \"Comment was failly created!\\n#{errors}!\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n\n\n end",
"def create\n @comment = @parent.comments.new(params[:comment])\n @comment.user_id = session[:user_id]\n\n respond_to do |format|\n if @comment.save\n @comment.update_post\n format.html { redirect_to post_path(@comment.post), notice: 'Comment was successfully created.' }\n format.json { render json: @comment, status: :created, location: @comment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @comment = Comment.new(comment_params)\n\n respond_to do |format|\n if @comment.save\n post_comment(@comment)\n format.html { redirect_to @comment.article, notice: 'Comment was successfully created.' }\n format.json { render action: 'show', status: :created, location: @comment }\n else\n format.html { render action: 'new' }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @comment = Comment.new(\n name: params[:name],\n content: params[:content],\n post: Post.find(params[:post_id])\n )\n # @comment = Comment.new(comment_params)\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @comment.post, notice: \"comment was created.\" }\n else\n puts @comment.errors\n format.html { redirect_to post_path(params[:post_id]) }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n #@comment = Comment.new(comment_params)\n @comment = @blog.comments.new(comment_params)\n \n if @comment.save\n render json: @comment, status: :created\n else\n render json: {\n error: @comment.errors.full_messages\n }, status: :unprocessable_entity\n end\n end",
"def create\n @comment = @post.comments.build(comment_params)\n @comment.user_id = current_user.id\n @comment.post_id = @post.id\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @post, notice: 'Comment was successfully created.' }\n format.json { render :show, status: :created, location: @comment }\n else\n format.html { render :new }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_comments\n end",
"def create_comments\n end",
"def create_comments\n end",
"def create\n @comment = Comment.new(comment_params)\n @post = Post.find(@comment.post_id)\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @post, notice: 'Comment was successfully created.' }\n format.json { render :show, status: :created, location: @comment }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @comment = Comment.new\n @comment.content = params[:content]\n @comment.post_id = params[:post_id]\n @comment.user_id = current_user.id\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to root_path, notice: \"Comment was successfully created.\" }\n format.json { render :show, status: :created, location: @comment }\n else\n format.html { redirect_to root_path, notice: \"Por favor añada contenido a su comentario.\" }\n end\n end\n end",
"def create\n comment = Comment.new(params[:comment])\n @entry.comments << comment if comment.valid?\n respond_with(comment, location: redirect_to_index)\n end",
"def create\n\n \t\t\t@comment = Comment.new comment_params\n\n @comment.user_id = current_user.id\n\n \t\t\tif @comment.save\n\n \t\t\t\trender json: @comment,status: :created\n\n \t\t\telse\n\n \t\t\t\trender json: {error: true,errors: @comment.errors},status: :unprocessable_entity\n\n \t\t\tend\n\n \t\tend",
"def show\n @new_comment = Comment.build_from(@post, \"\")\n\n render json: @post, status: 200\n\n\n end",
"def create\n if params.present?\n Comment.create(name: params[:author], description: params[:text], rating: params[:rating])\n end\n render json: {success: \"Sucessfully Commented\"}\n end",
"def create_comment\n unless user_signed_in?\n render status: 403, json: { message: 'Please sign in to add a comment.' }\n end\n\n comment_params = params.permit(:content, :id)\n new_comment = Comment.create!(\n content: comment_params.require(:content),\n post_id: comment_params.require(:id),\n user_id: current_user.id\n )\n render status: :created, json: new_comment\n end",
"def create\n @comment = Comment.new(params[:comment])\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @comment.generic_item, :notice => t('notice.successfully_created') }\n format.json { render :json => @comment, :status => :created, :location => @comment }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @comment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\r\n\t\t#create new comment\r\n\t\t@comment = Comment.new(comment_params)\r\n\t\tif @comment.save\r\n\t\t\t#if save success send js handles the rest\r\n\t\t\t@post = @comment.post\r\n\t\t\trespond_to :js\r\n\t\telse\r\n\t\t\t# if fails alert user\r\n\t\t\tflash[:alert] = \"Something went wrong\"\r\n\t\tend\r\n\tend",
"def create\n @comment = Comment.new(params[:comment])\n @posts = Post.find_all_by_id(@comment.post_id)\n @comment.user_id = session[:user_logged_in]\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @posts, notice: 'Comment was successfully created.' }\n format.json { render json: @comment, status: :created, location: @comment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @comment = Comment.new(params[:comment]) #has a hash called comment, passes initial values\n\n respond_to do |format|\n if @comment.save # Goes in here and saves it to the DB\n format.html { redirect_to @comment, notice: 'Comment was successfully created.' }\n format.json { render json: @comment, status: :created, location: @comment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n :authenticate_user!\n @comment = Comment.create!(comment_params)\n respond_with @comment\n end",
"def create\n @comment = current_user.comments.build(params[:comment])\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @comment, notice: 'Comment was successfully created.' }\n format.json { render json: @comment, status: :created, location: @comment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @comment = @repository.comments.new(params.require(:comment).permit(:body))\n @comment.author = current_user\n authorize @comment\n\n if @comment.save\n respond_with(@comment)\n else\n respond_with @comment.errors, status: :unprocessable_entity\n end\n end",
"def create\n @comment = @idea.comments.build(comment_params)\n @comment.user = current_user\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @idea, notice: 'Your comment has been recorded' }\n format.json { render action: 'show', status: :created, comment: @comment }\n else\n format.html { render action: 'new' }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def comment_params\n if request.format.json?\n return params.permit(:post_id, :body)\n end\n params.require(:comment).permit(:user_id, :post_id, :body)\n end",
"def create_comment(comment)\n post_params = {\n :body => comment.post_json,\n :headers => Logan::Client.headers.merge({'Content-Type' => 'application/json'})\n }\n\n response = Logan::Client.post \"/projects/#{@project_id}/todos/#{@id}/comments.json\", post_params\n Logan::Comment.new response\n end",
"def create\n @post = Post.find(params[:post_id])\n @comment = @post.comments.create(params[:comment])\n @comment.researcher = logged_in_researcher\n\n if @comment.save\n respond_to do |format|\n format.html { redirect_to post_path(@post), :notice => \"Comment was successfully added.\" }\n format.xml { render :xml => @comment, :status => :created, :location => @comment}\n format.json { render :json=> @comment, :status => :created, :location => @comment}\n end\n else\n respond_to do |format|\n format.html { redirect_to post_path(@post), :alert => \"Failed to add comment: #{@comment.errors.full_messages.join(', ')}\" }\n format.xml { render :xml => @comment.errors, :status => :unprocessable_entity }\n format.json { render :json=> @comment.errors, :status => :unprocessable_entity }\n end \n end\n end",
"def create\n @comment = @question.comments.create(comment_params)\n redirect_to question_path(@question)\n end",
"def post_comment(comment, poi=\"4f4f4c27d4374e800100001d\")\n uri = URI.parse(\"http://mashweb.fokus.fraunhofer.de:3008/api/comment\")\n response = Net::HTTP.post_form(uri, {\n :title => 'Autocomment',\n :body => comment\n })\n end",
"def create\n @comment = Comment.new(params[:comment])\n\t\[email protected]_id = session[:userid]\n @comment.save\n\t\trespond_with @comment, :location => @comment.post\n end",
"def create\n @comment = @issue.comments.new(comment_params)\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @issue_path, notice: 'Comment is succesfully created.' }\n format.json { render :show, status: :created, location: @comment }\n else\n format.html { render :new }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@comment = Comment.new()\n\t\[email protected] = params[:comment] \n\t\[email protected] = current_user\n\t\[email protected]\n\t\t\n\t\t@resource_comment = ResourceComment.new()\n\t\t@resource_comment.resource_path = params[:path]\n\t\t@resource_comment.comment_id = @comment.id\n\t\t@resource_comment.save\n\t\tif(@resource_comment)\n\t\t\trespond_with(@comment)\n\t\telse\n\t\t\trender json: {error: \"something went wrong while creating resource comment\"}\n\t\tend\n end",
"def create\n comment = Comment.new(params[:comment])\n @articles_comments_service.create_comment(comment)\n end",
"def create\n @user = User.find(params[:user_id])\n @comment = @user.comments.build(params[:comment])\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to user_path(@user.id), notice: 'Your comment has been submitted' }\n format.json { render json: @comment, status: :created, location: @comment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @comment_node = CommentNode.new(params[:comment_node])\n\n respond_to do |format|\n if @comment_node.save\n format.html { redirect_to @comment_node, :notice => 'Comment node was successfully created.' }\n format.json { render :json => @comment_node, :status => :created, :location => @comment_node }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @comment_node.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @comment = current_user.comments.new(comment_params)\n @comment.post_id = params['post_id']\n # @comment.parent_id = params[:parent_id]\n\n respond_to do |format|\n if @comment.save\n flash[:notice] = t('comment.create_success_mesg')\n @post = Post.find(params['post_id'])\n @all_comments = @post.comments.paginate(page: params[:page])\n format.html\n format.json { render :show, status: :created, location: @comment }\n format.js\n else\n flash[:notice] = t('comment.create_unsuccessful_msg')\n format.html\n format.json {\n render json: @comment.errors, status: :unprocessable_entity\n }\n format.js \n end\n end\n end",
"def create\n @post = Post.find(params[:post_id])\n @comment = @post.comments.create(comment_params)\n redirect_to post_path(@post)\n end",
"def post_comment(request)\n data, _status_code, _headers = post_comment_with_http_info(request)\n request_token if _status_code == 401\n data\n end",
"def comment #create comment\n comment = Comment.new\n if comment.create_comment(params[:body], params[:video_id])#calling create_comment method of Comment model\n respond_with do |format|\n format.json {render :json => {:success => true, :message => \"comment successfully posted\"}}\n end\n else\n respond_with do |format|\n format.json {render :json => {:success => false}}\n end\n end\n end",
"def index\n post = Post.find(params[:post_id])\n comments = post.comments.order(updated_at: :desc)\n @comment = Comment.new\n\n @comments = comments.map do |comment|\n {\n content: comment.content,\n created_at: comment.created_at.strftime('%Y-%m-%d %H:%M:%S')\n }\n end\n\n render json: {\n data: {\n comments: @comments,\n new_comment: @comment,\n }\n }\n end",
"def new_comment(name, discussion_id)\n response = self.class.post(\n @@base_uri + @@comments_uri,\n body: {\"comment\":{\"body\":name,\"discussion_id\":discussion_id,\"document_ids\":[]}}.to_json,\n headers: @headers\n )\n return response\n end",
"def create\n @comment = Comment.new :body => params[:comment][:body],\n :issue => false\n @comment.polycomment_type = params[:polycomment_type]\n @comment.polycomment_id = params[:polycomment_id]\n @comment.user_id = current_user.id \n if @comment.save\n #flash[:notice] = 'Your comment was posted!'\n redirect_to :back\n else\n flash[:alert] = 'Something went wrong, try reposting your comment.'\n end\n end",
"def create\n @post = Post.find(params[:post_id])\n @comment = @post.comments.create!(comment_params)\n\n redirect_to post_path(@post)\n end",
"def create\n @comment = Comment.new(comment_params)\n @comment.save\n end",
"def create\n @comment = @post.comments.build(params[:comment])\n \n respond_to do |format|\n if @comment.save\n flash[:notice] = 'Post was successfully created.'\n format.html { redirect_to(posts_url) }\n format.xml { render :xml => @comment, :status => :created, :location => @comment }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @comment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n user = User.find_by({token: env['HTTP_TOKEN']})\n comment = user.comments.find(params[:id])\n comment.update(comment_params)\n render json: comment\n end",
"def comments\n @article = Article.find(params[:id])\n @comments = @article.comments\n\n respond_to do |format|\n format.html \n format.json { render json: @comments, status: :ok }\n end\n end",
"def add\n @comment = Comment.new(params[:comment])\n\n respond_to do |format|\n if @comment.save\n # format.html { redirect_to comments_url, notice: 'Comment was successfully created.' }\n format.json { render json: @comment, status: :created, location: @comment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @task_comment = Task::Comment.new(task_comment_params)\n\n respond_to do |format|\n if @task_comment.save\n format.html { redirect_to @task_comment, notice: \"Comment was successfully created.\" }\n format.json { render :show, status: :created, location: @task_comment }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @task_comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.find(params[:post_id])\n @comment = @post.comments.new(comment_params)\n @comment.user_id = current_user.id\n @comment.save\n\n respond_to do |format|\n format.js\n end\n end",
"def create\n @comment = Comment.new(comment_params)\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @comment.article, notice: 'Comment was successfully created.' }\n format.json { render :show, status: :created, location: @comment }\n else\n format.html { render :new }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @article.comments << Comment.new(comment_params)\n\n respond_to do |format|\n if @article.save\n format.html { redirect_to article_show_path(@article), notice: 'Comment was successfully created.' }\n format.json { render :show, status: :created, location: @article }\n else\n format.html { render :new }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end",
"def comment_creation_params\n params.require(:comment).permit(:cardset_id, :card_id, :user_id, :user_name, :posttime, :body, :status)\n end",
"def create\n @commentable = find_commentable\n @comment = @commentable.comments.build(params[:comment]) do |comment|\n comment.access = current_access\n end\n if @comment.save\n flash.now[:notice] = t('comment.added')\n Rails.logger.info @comment.inspect\n @counter = @commentable.comments.count\n respond_with @comment\n else\n Rails.logger.info @comment.errors.messages\n flash.now[:error] = t('comment.added.error')\n end\n end",
"def create\n \t# collects nested attributes, for post & comment, from params\n new_post = params.require(:post).permit(:body, :link, comments_attributes: [:body])\n\n \tpost = Post.create(new_post)\n \tredirect_to post_path(post.id)\n end",
"def new\n @comment = @commentable.comments.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n end",
"def create \n @comment = @post.comments.new(params[:comment])\n @comment.user_id = current_user.id\n respond_to do |format|\n if @comment.save\n format.js { \n flash[:notice] = 'Comment was successfully created.' \n }\n else\n format.js { \n flash[:error] = @comment.errors.full_messages.join('<br/>')\n }\n end\n end\n @comments = @post.comments.created_at_order\n end",
"def create_comment\n @user = User.find(params[:user_id])\n @message = Message.find(params[:message_id])\n @comment = @message.comments.create(params.permit(:content))\n @comment.user = @user\n @comment.user_name = @user.id\n @comment.user_avatar = @user.id\n\n if @comment.save\n response = { \"code\" => 1, \"msg\" => \"Comment Created Successfully\" }\n else\n response = { \"code\" => 0, \"msg\" => \"Comment Can't be created\" }\n end\n\n render json: response\n end",
"def add_new_comment\n\t# Get the object that you want to comment\n\tcommentable = Post.find(params[:id])\n\n\t# Create a comment with the user submitted content\n\tcomment = Comment.new(comment_params)\n\t# Add the comment\n\tcommentable.comments << comment\n\t@comments = commentable.comments\n respond_to do |format|\n\t format.html { redirect_to root_path }\n\t format.js\n\tend\n end",
"def create\n @post = Post.find params[:id]\n @comment = @post.comments.create comment_params\n @comment.user_id = current_user.id\n\n if @comment.save\n redirect_to \"/post/\" + params[:id]\n else\n flash[:danger] = \"No success\"\n redirect_to \"/\"\n end\n end",
"def create\n @comment = @parent.comments.build(comment_params_with_user)\n authorize @comment\n\n if @comment.save\n CommentCreatedMailJob.perform_later(@comment)\n render json: @comment, serializer: CommentSerializer, status: :created\n else\n render_error :unprocessable_entity, @comment.errors\n end\n end",
"def comment_params\n params.require(:comment).permit(:body, :request_id)\n end",
"def create\n @comment = @secret.comments.build(comment_params)\n @comment.user_id = @user.id\n respond_to do |format|\n if @comment.save\n format.html { redirect_to [@user, @secret], notice: 'Secret was successfully created.' }\n format.json { render action: 'show', status: :created, location: @comment }\n else\n format.html { render action: 'new' }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @submission = Submission.find(params[:submission_id])\n @scomment = @submission.comments.build(comment_params)\n if @scomment.save\n render json: @scomment.as_json(except: [:updated_at]), status: :created\n else\n render json: @scomment.errors, status: :unprocessable_entity\n end\n #@comment.user = current_user\n\n #respond_to do |format|\n # if comment_params[:title].present? && comment_params[:body].present?\n # if @comment.save\n # format.html { redirect_to @submission, notice: 'Comment was successfully created.' }\n # #format.json { render :show, status: :created, location: @comment }\n # else\n # format.html { render :new }\n # #format.json { render json: @comment.errors, status: :unprocessable_entity }\n # end\n # else\n # format.html { redirect_to @submission, notice: 'Debe llenar los campos.' }\n # end\n #end\n end"
] | [
"0.7513347",
"0.74232185",
"0.73758155",
"0.72379327",
"0.7206818",
"0.7087521",
"0.70696557",
"0.70558655",
"0.7049475",
"0.699036",
"0.69837004",
"0.6967921",
"0.6959057",
"0.6911904",
"0.69105834",
"0.68748885",
"0.6873017",
"0.6823846",
"0.6813315",
"0.6789194",
"0.6786503",
"0.67637914",
"0.6723796",
"0.6719274",
"0.6713536",
"0.6704816",
"0.6680538",
"0.667007",
"0.66676444",
"0.66524523",
"0.6648984",
"0.6645204",
"0.6645204",
"0.6645204",
"0.6645204",
"0.66200674",
"0.66090393",
"0.6591229",
"0.6584598",
"0.658101",
"0.6576306",
"0.6564505",
"0.6552106",
"0.6550677",
"0.6550677",
"0.6550677",
"0.65382046",
"0.65371263",
"0.65357924",
"0.6514364",
"0.64976215",
"0.64927286",
"0.64908665",
"0.6479775",
"0.64726067",
"0.64584184",
"0.6433041",
"0.6425122",
"0.64170754",
"0.6398987",
"0.6397322",
"0.63865435",
"0.63862616",
"0.63850904",
"0.6382393",
"0.6375477",
"0.637108",
"0.636993",
"0.63659465",
"0.6361696",
"0.63289815",
"0.6322738",
"0.63223463",
"0.6299431",
"0.6293635",
"0.62927634",
"0.62863815",
"0.62831557",
"0.6278487",
"0.627372",
"0.6268722",
"0.62643933",
"0.6260533",
"0.6254038",
"0.62499315",
"0.62476695",
"0.62476027",
"0.62458843",
"0.6240965",
"0.62341315",
"0.6233819",
"0.6232643",
"0.6230304",
"0.6224807",
"0.62242913",
"0.622293",
"0.6210621",
"0.62100685",
"0.6207884",
"0.62001896",
"0.61995524"
] | 0.0 | -1 |
PATCH/PUT /comments/1 PATCH/PUT /comments/1.json | def update
respond_to do |format|
if @comment.update(comment_params)
suggested_change_change_hash = save_suggested_changes
save_change_log(current_user,{comment: @comment, suggested_change_changes: suggested_change_change_hash, action_type: 'edit'})
@filter_querystring = remove_empty_elements(filter_params_all)
format.html { redirect_to edit_comment_path(@comment,@filter_querystring), notice: 'Comment was successfully updated.' }
format.json { render :show, status: :ok, location: @comment }
else
set_select_options
format.html { render :edit }
format.json { render json: @comment.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n json_update_and_sanitize(comment, comment_params, Comment)\n end",
"def update\n @comment = Comment.find(params[:comment_id])\n @comment.update(comment_params)\n render json: @comment\n end",
"def update\n user = User.find_by({token: env['HTTP_TOKEN']})\n comment = user.comments.find(params[:id])\n comment.update(comment_params)\n render json: comment\n end",
"def update\n @comment = Comment.find(params[:id])\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.json { render :json => @comment }\n else\n format.json { render :json => @comment.errors, :status => :unprocessable_entity}\n end\n end\n #respond_with(@post,@post.comments.update(params[:id],params[:comment]))\n end",
"def update\n comment = Comment.find(params[:id])\n if comment.update(params_comment)\n render json: comment, status: 200\n else\n render json: comment.errors, status: 422\n end\n\n end",
"def update\n\n if @comment.update(comment_params)\n render json: @comment, status: :ok\n else\n render json: @comment.errors, status: :unprocessable_entity\n\n end\n\n\n end",
"def update\n if @comment.update(comment_params)\n render json: @comment, status: :ok\n else\n render json: @comment.errors, status: :unprocessable_entity\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n authorize @comment\n if @comment.update(comment_params)\n render 'api/v1/comments/show', status: :success\n else\n render json: @comment.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @comment.update(comment_params)\n head :no_content\n else\n render json: @comment.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @comment.update(comment_params)\n head :no_content\n else\n render json: @comment.errors, status: :unprocessable_entity\n end\n end",
"def update\n #respond_to do |format|\n if @comment.update(comment_params)\n render json: @comment.as_json(except: [:updated_at]), status: :ok\n else\n # format.html { render :edit }\n render json: @comment.errors, status: :unprocessable_entity\n # end\n end\n end",
"def update\n @comment1 = Comment1.find(params[:id])\n\n respond_to do |format|\n if @comment1.update_attributes(params[:comment1])\n format.html { redirect_to @comment1, notice: 'Comment1 was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment1.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @comment.update(comment_params)\n render json: @comment, serializer: CommentSerializer\n else\n render_error :unprocessable_entity, @comment.errors\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n @comment.user_id = params[:user_id]\n @comment.announcement_id = params[:announcement_id]\n @comment.description = params[:description]\n @comment.save\n render json:@comment\n end",
"def update\n authorize [:api, :v1, @requesting_object]\n ticket = ServiceTicket.where(\n client_key: params['avatar_key'],\n id: params['id']\n ).first\n if params['comment_text']\n ticket.comments << Comment.new(author: params['avatar_name'],\n text: params['comment_text'])\n end\n ticket.update(status: params['status']) if params['status']\n render json: { message: 'OK' }, status: :ok\n end",
"def update\n if @comment.update_attributes(comment_params)\n render json: @comment, status: :ok\n else\n render json: {error: \"Not found\"}, status: :not_found\n end\n end",
"def update\n #if @user && @user.posts.include(@post)\n @comment.update(comment_params)\n json_response(@comment)\n end",
"def update\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, :notice => 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @comment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, :notice => 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @comment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n if @comment.update(comment_params)\n render json: {status: \"success\", data: {comment: @comment}}, status: :ok\n else\n render json: @comment.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment.generic_item, :notice => t('notice.successfully_updated') }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @comment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.xml { head :ok }\n format.json { head :ok } \n else\n format.xml { render :xml => @comment.errors, :status => :unprocessable_entity }\n format.json { render :json => @comment.errors, :status => :unprocessable_entity } \n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, notice: 'comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, :notice => 'Comment was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @comment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, :notice => 'Comment was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @comment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_pull_request_comment(repo, comment_id, body, options = {})\n options.merge! :body => body\n patch(\"#{Repository.path repo}/pulls/comments/#{comment_id}\", options)\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :json => {:comment => @comment, :status => 200} }\n else\n format.html { render :edit }\n format.json { render :json => {:comment => @comment, :status => 400 } }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment1.update(comment1_params)\n format.html { redirect_to @comment1, notice: 'Comment1 was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment1 }\n else\n format.html { render :edit }\n format.json { render json: @comment1.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @comment.update(comment_params)\n render json: {status: 'Comment was successfully updated.'}, status: :201\n else\n render json: { message: \"Error. Error. Please try again.\"}, status: 400\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to project_sprint_user_story_comments_path, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = current_user.comments.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to post_path(@comment.post), notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t respond_to do |format|\n\t if @comment.update(comment_params)\n\t format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n\t format.json { head :no_content }\n\t else\n\t format.html { render action: 'comment' }\n\t format.json { render json: @comment.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n @posts = Post.find_by_id(@comment.post_id)\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @posts, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to admin_comments_url, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_answer_comment.update(api_v1_answer_comment_params)\n format.html { redirect_to @api_v1_answer_comment, notice: 'Answer comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_answer_comment }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_answer_comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n if @comment.update(comment_params)\n\n render json: @comment,status: :ok\n\n else\n\n render json: {error: true,errors: @comment.errors},status: :unprocessable_entity\n\n end\n\n \t\tend",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_back(fallback_location: root_path, notice: t('comment.update_msg')) }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json {\n render json: @comment.errors, status: :unprocessable_entity\n }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, notice: 'Note was successfully updated.' }\n format.js { head :ok }\n else\n format.html { render action: \"edit\" }\n format.js { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch!\n request! :patch\n end",
"def update\n # @comment = Comment.find(params[:id])\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, notice: t(\"actions.updated\", model: t(\"activerecord.models.#{controller_name.singularize.gsub(\" \", \"\")}\"))}\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, \tºlocation: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n isadmin\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n# @comment.delete_empty_notes\n @comment.set_flag(params[:flag])\n format.html { redirect_to homework_comments_url(), notice: 'Comment was successfully updated.' }\n format.js {render :index}\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to [@section, @commentable, :comments], notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment.update(comment_params)\n end",
"def edit\n respond_with @comment\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @issue_path, notice: 'Comment is sucesfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n redirect_to \"/home/index\"\n #@comment = Comment.find(params[:id])\n #respond_to do |format|\n #if @comment.update_attributes(params[:comment])\n #format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n #format.json { head :ok }\n #else\n #format.html { render action: \"edit\" }\n #format.json { render json: @comment.errors, status: :unprocessable_entity }\n #end\n #end\n end",
"def update\n @comment = Comment.find(params[:id])\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to post_comment_path(@post, @comment), notice: \"Comment was successfully updated.\" }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to post_path(@comment.post, :anchor => \"comment_#{@comment.id}\"), :notice => t(\"messages.comments.updated\") }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @comment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment.submission }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = @posting.comments.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n #@comment.create_activity :update, owner: current_user\n format.html { redirect_to postings_path, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def comments_put(resource, comment)\n merged_options = options.merge({ resource: resource, comment: comment })\n response = RestClient.post endpoint(\"/comments/put\"), merged_options\n parse_response(response)\n end",
"def update \n commentable = find_commentable_object\n @comment = Comment.find(params[:id])\n \n respond_with do |format|\n if @comment.update_attributes(params[:comment])\n @comment.pending_for_moderation\n @comment_updated = @comment\n @comment = Comment.new\n \n flash.now[:notice] = 'Comment was successfully updated.'\n else\n flash.now[:alert] = 'Comment was not successfully updated.'\n end\n end\n \n # respond_to do |format|\n # if @comment.update_attributes(params[:comment])\n # format.html { redirect_to(@post, :notice => 'Comment was successfully updated.') }\n # format.xml { head :ok }\n # else\n # format.html { render :action => \"edit\" }\n # format.xml { render :xml => @comment.errors, :status => :unprocessable_entity }\n # end\n # end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was fail updated.' }\n format.json { render :show, status: :ok, location: @comment }\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize(comment)\n if comment.update(comment_params)\n render json: { message: \"Feedback successfully updated!\", error: false}\n else\n render json: { message: \"Sorry, feedback could was not updated. Please try again.\", error: true }\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment.snippet, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render @comment.snippet }\n format.json { render json: @comment.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 update\n @comment = @complaint.comments.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to([@comment.complaint, @comment], :notice => 'Su comentario ha sido actualizado.') }\n format.json { head :ok }\n format.js\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @comment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n return forbidden unless user_owns_comment\n return bad_request(@comment.errors.full_messages) unless @comment.update_attributes(text: comment_params[:text])\n\n render json: {data: {message: 'The comment has been updated'}}, status: :ok\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Zmodyfikowano komentarz.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment.blog}\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment.update_attributes(params[:comment])\n respond_with(@comment, location: redirect_to_index)\n end",
"def update\n respond_to do |format|\n if @recipe_comment.update(recipe_comment_params)\n format.html { redirect_to @recipe_comment, notice: 'Recipe comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe_comment }\n else\n format.html { render :edit }\n format.json { render json: @recipe_comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_review_comment(repo, comment_id, body, options = {})\n opts = options.dup\n opts[:body] = body\n patch \"#{Repository.path repo}/pulls/comments/#{comment_id}\", opts\n end",
"def update\r\n\t\t@comment = Comment.find(obfuscate_decrypt(params[:id], session))\r\n\t\t@commentable = @comment.commentable\r\n\r\n bOK = false\r\n if params[:commit] == \"Cancel\"\r\n # if user clicks \"Cancel\", reload the page with original data\r\n bOK = true\r\n else\r\n # make database updates before reloading the page\r\n bOK = update_options\r\n if bOK\r\n bOK = @comment.update_attributes(params[:comment])\r\n end\r\n end\r\n\r\n\t\trespond_to do |format|\r\n\t\t\tif bOK\r\n flash[:edit_comment_errors] = nil\r\n @comment = Comment.find(obfuscate_decrypt(params[:id], session))\r\n @option_ids = @comment.comment_options.pluck('option_id')\r\n @comment_option_lookups = CommentOptionLookup.order\r\n @this_comment = @comment.comment\r\n format.html { redirect_to flowsheet_user_patient_path(obfuscate_encrypt(@comment.commentable.patient_id, session)), notice: 'Comment was successfully updated.' }\r\n\t\t\t\tformat.json { head :ok }\r\n\t\t\t\tformat.js\r\n else\r\n flash[:edit_comment_errors] = @comment.errors.full_messages\r\n\t\t\t\tformat.html { redirect_to flowsheet_user_patient_path(obfuscate_encrypt(@comment.commentable.patient_id, session)), notice: \"There were problems updating your comment. Please try again:\" }\r\n\t\t\t\tformat.json { render json: @comment.errors, status: :unprocessable_entity }\r\n\t\t\t\tformat.js { render action: 'edit' }\r\n\t\t\tend\r\n\t\tend\r\n\tend"
] | [
"0.72262836",
"0.7067242",
"0.70644766",
"0.70267683",
"0.68851054",
"0.6778662",
"0.673702",
"0.67316365",
"0.6723994",
"0.6723994",
"0.66953856",
"0.66685724",
"0.6661655",
"0.6639885",
"0.66343516",
"0.66292053",
"0.66050345",
"0.65994745",
"0.6597625",
"0.6597625",
"0.6596884",
"0.6592554",
"0.6589391",
"0.6578913",
"0.6576758",
"0.6576758",
"0.6572667",
"0.6571773",
"0.65682405",
"0.65682405",
"0.65682405",
"0.65496004",
"0.6542806",
"0.6541075",
"0.6541075",
"0.6541075",
"0.6541075",
"0.6541075",
"0.6541075",
"0.6541075",
"0.6541075",
"0.6541075",
"0.653933",
"0.6530288",
"0.65233415",
"0.6517975",
"0.6501014",
"0.6501014",
"0.6489255",
"0.64890176",
"0.6471021",
"0.6468038",
"0.64564574",
"0.64528286",
"0.6433247",
"0.64303184",
"0.64283174",
"0.64231765",
"0.6416272",
"0.6416272",
"0.6416272",
"0.6416272",
"0.6416272",
"0.6416272",
"0.6416272",
"0.6416272",
"0.6416272",
"0.6416272",
"0.6416272",
"0.6416272",
"0.6416272",
"0.6416272",
"0.6416272",
"0.6416272",
"0.6416272",
"0.6410572",
"0.64030486",
"0.6401995",
"0.63753486",
"0.63669807",
"0.6356098",
"0.6355399",
"0.6334998",
"0.633285",
"0.63299364",
"0.6322344",
"0.6320188",
"0.6313472",
"0.63088924",
"0.6307379",
"0.62951237",
"0.62943274",
"0.6286603",
"0.6280981",
"0.6275025",
"0.6264845",
"0.6260108",
"0.62558734",
"0.62440044",
"0.62350297",
"0.62290096"
] | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_comment
@comment = current_rulemaking.comments.find_by(id: params[:id])
if @comment.nil?
respond_to do |format|
format.html { redirect_to comments_url, alert: "Comment #{params[:id]} was not found." }
format.json { head :no_content }
end
end
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 comment_params
params.require(:comment).permit(:source_id, :first_name, :last_name, :email, :organization, :state, :comment_text, :attachment_name, :attachment_url, :num_commenters, :summary, :comment_status_type_id, :notes, :manually_entered, :comment_data_source_id, attached_files: [])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def valid_params_request?; end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def filtering_params\n params.permit(:email)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def 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 valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\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 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 maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\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 url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\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 droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\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.6980957",
"0.6783065",
"0.6747844",
"0.6741468",
"0.67356336",
"0.6592548",
"0.65036845",
"0.64978707",
"0.64825076",
"0.64795035",
"0.64560914",
"0.64397955",
"0.6379666",
"0.6376688",
"0.6366702",
"0.6319728",
"0.6300833",
"0.6300629",
"0.6294277",
"0.6293905",
"0.6291174",
"0.62905735",
"0.6283171",
"0.6242344",
"0.62403613",
"0.6218049",
"0.62143815",
"0.62104696",
"0.61949855",
"0.6178671",
"0.6176147",
"0.6173327",
"0.6163395",
"0.6153005",
"0.6151833",
"0.6147288",
"0.61224324",
"0.6118827",
"0.61075264",
"0.61054534",
"0.6092497",
"0.6080082",
"0.60710967",
"0.60627776",
"0.60219413",
"0.60175914",
"0.60153484",
"0.60107356",
"0.60081726",
"0.60081726",
"0.60013986",
"0.6000165",
"0.59978646",
"0.59936947",
"0.59925723",
"0.5992084",
"0.59796256",
"0.5967569",
"0.5960056",
"0.59589803",
"0.5958441",
"0.5958401",
"0.5952607",
"0.5952406",
"0.5944409",
"0.59391016",
"0.593842",
"0.593842",
"0.5933845",
"0.59312123",
"0.5926475",
"0.59248453",
"0.59179676",
"0.59109294",
"0.59101623",
"0.5908172",
"0.59058356",
"0.5899052",
"0.5897749",
"0.5896101",
"0.58942914",
"0.58939576",
"0.5892063",
"0.5887407",
"0.588292",
"0.58797663",
"0.587367",
"0.58681566",
"0.5868038",
"0.5866578",
"0.58665025",
"0.58655846",
"0.58640826",
"0.5863465",
"0.5862226",
"0.586065",
"0.58581287",
"0.5854443",
"0.5854172",
"0.58507544",
"0.5849934"
] | 0.0 | -1 |
GET /election/new form for creating a new voting group | def new
@group = LunchGroup.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @election = Election.new\n @election.choices.build\n @election.choices.each do |choice|\n choice.election_id = @election.id\n end\n respond_with @election\n\tend",
"def new\n @group = @authorized_group\n @candidate = @group.candidates.build \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @candidate }\n end\n end",
"def new\n @election = Election.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @election }\n end\n end",
"def new\n @election_type = ElectionType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @election_type }\n end\n end",
"def create\n @election = Election.new(election_params)\n respond_to do |format|\n if @election.save\n format.html { redirect_to [:admin, @election], notice: 'Election was successfully created.' }\n format.json { render :show, status: :created, location: @election }\n else\n format.html { render :new }\n format.json { render json: @election.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n Group.rebuild! if nil.|Group.find(:first).rgt\n\t @group = Group.new\n\t @groups = current_user.get_unique_group_branches.map {|g| g.get_self_and_children?}.flatten\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def create\n\t\trequire_admin!\n\t\t@election = Election.new(election_params)\n\n\t\trespond_to do |format|\n\t\t\tif @election.save\n\t\t\t\tformat.html { redirect_to @election, notice: 'Election was successfully created.' }\n\t\t\t\tformat.json { render :show, status: :created, location: @election }\n\t\t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @election.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def create\n @election = Election.new(election_params)\n\n respond_to do |format|\n if @election.save\n format.html { redirect_to @election, notice: 'Election was successfully created.' }\n format.json { render :show, status: :created, location: @election }\n else\n format.html { render :new }\n format.json { render json: @election.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @election = Election.new(election_params)\n\n respond_to do |format|\n if @election.save\n format.html { redirect_to @election, notice: 'Election was successfully created.' }\n format.json { render :show, status: :created, location: @election }\n else\n format.html { render :new }\n format.json { render json: @election.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.find(params[:group_id])\n @candidate = @group.candidates.build(params[:candidate])\n if @candidate.save\n redirect_to group_candidates_url(@group)\n else\n render :action => \"new\"\n end\n end",
"def create\n @election = Election.new(params[:election])\n\n respond_to do |format|\n if @election.save\n flash[:notice] = 'Election was successfully created.'\n format.html { redirect_to(@election) }\n format.xml { render :xml => @election, :status => :created, :location => @election }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @election.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @evaluation = Evaluation.new\n @group = Group.find params[:group_id]\n end",
"def new\n @breadcrumb = 'create'\n @ratio_group = RatioGroup.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ratio_group }\n end\n end",
"def create\n @election = Election.new(election_params)\n\n respond_to do |format|\n if @election.save\n format.html { redirect_to @election, notice: \"Election was successfully created.\" }\n format.json { render :show, status: :created, location: @election }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @election.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @title = \"Добавление возрастной группы\"\n @age_group = AgeGroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @age_group }\n end\n end",
"def create\n # Create election from parameters\n @election = Election.new(params[:election])\n user_id = params[:election][:user_id]\n if user_id == \"\"\n flash[:error] = \"You may choose owner for election\"\n redirect_back_or_default(:action => 'new')\n return\n end\n @election.owner = ::User.find(user_id)#current_user\n\n faculty_id = params[:election][:faculty_id]\n # validate\n if faculty_id == \"\"\n flash[:error] = \"You may choose faculty for election\"\n redirect_back_or_default(:action => 'new')\n return\n end\n\n faculty_num = Faculty.find(@election.faculty_id).num\n\n # Get votes by faculty\n voters = Array.new\n voters = ::User.find_users_by_faculty(faculty_num)\n\n # Validates existence of voters\n if voters.empty?\n flash[:error] = \"The are no registered students on a faculty\"\n redirect_back_or_default(:action => 'new')\n return\n end\n\n # Create voting ballots\n ballots = Array.new\n voters.each do |voter|\n ballot = Ballot.new_from_params(voter, @election)\n ballots << ballot\n end\n\n # Save the records to the database\n begin\n Election.transaction do\n @election.save!\n ballots.each {|b| b.save!}\n end\n rescue Exception\n render :action => :new and return\n end\n\n flash[:notice] = \"Election created successfully\"\n redirect_to(object_url(@election))\n end",
"def new\n @group = Group.find(params[:group_id])\n @survey = @group.surveys.find(params[:survey_id])\n @survey_candidate = @survey.survey_candidates.build\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @survey_candidate }\n end\n end",
"def new\n @exercise = Exercise.find(params[:exercise_id])\n load_course\n I18n.locale = @course_instance.locale || I18n.locale\n @is_teacher = @course.has_teacher(current_user)\n\n return access_denied unless logged_in? || @course_instance.submission_policy == 'unauthenticated'\n\n @group = Group.new(:min_size => @exercise.groupsizemin, :max_size => @exercise.groupsizemax)\n @group_members = []\n\n # Add current user\n if logged_in? && !@is_teacher\n member = GroupMember.new(:email => current_user.email)\n member.user = current_user\n @group_members << member\n end\n\n # Create group member slots\n (@group.max_size - @group_members.size).times do |i|\n @group_members << GroupMember.new()\n end\n\n log \"create_group view #{params[:exercise_id]}\"\n end",
"def new\n @group = Group.new(:owner => current_user)\n authorize @group, :new?\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def new #:nodoc:\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.haml\n # format.xml { render :xml => @group }\n end\n end",
"def new\n save_navi_state(['groups_title', 'new_group'])\n @group = Group.new\n end",
"def new\n @esol_group = EsolGroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @esol_group }\n end\n end",
"def new\n\t\t@group = Group.new\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.xml { render :xml => @group }\n\t\t\tformat.json { render :json => @group }\n\t\tend\n\tend",
"def new\n\t\t@group = Group.new\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.xml { render :xml => @group }\n\t\t\tformat.json { render :json => @group }\n\t\tend\n\tend",
"def new\n @group = current_user.groups.build\n\n respond_to :html\n end",
"def new\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.haml\n format.js # new.js.rjs\n format.xml { render :xml => @group }\n format.json { render :json => @group }\n end\n end",
"def new\n @group = Group.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @group }\n end\n end",
"def new\n @group = Group.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @group }\n end\n end",
"def new\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @group }\n end\n end",
"def new\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @group }\n end\n end",
"def new\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @group }\n end\n end",
"def new\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @group }\n end\n end",
"def new\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @group }\n end\n end",
"def new\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @group }\n end\n end",
"def new\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @group }\n end\n end",
"def new\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @group }\n end\n end",
"def new\n # Not generally used. Most people want to vote via AJAX calls.\n end",
"def new\n @group = Group.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def new\n @volunteer = Volunteer.new\n @groups = Group.find(:all)\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @volunteer }\n end\n end",
"def new\n @election = Election.find(params[:election_id])\n @race = @election.races.build\n @race.race_candidates.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @race }\n end\n end",
"def new\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @group }\n end\n end",
"def new\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @group }\n end\n end",
"def new\n @group = GROUP.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def new\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @group }\n end\n end",
"def new\n @pgroup = Pgroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pgroup }\n end\n end",
"def new\n @pgroup = Pgroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pgroup }\n end\n end",
"def new\n @agent_group = AgentGroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @agent_group }\n end\n end",
"def new\n @group = current_user.groups.new\n end",
"def create\n @group = Group.find(params[:group_id])\n @survey = @group.surveys.find(params[:survey_id])\n @survey_candidate = @survey.survey_candidates.build(params[:survey_candidate])\n if @survey_candidate.save\n redirect_to group_survey_survey_candidates_url(@group, @survey)\n else\n render :action => \"new\"\n end\n end",
"def new\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @group }\n format.xml { render xml: @group }\n end\n end",
"def new\n @vgroup = Vgroup.new\n\n @vgroup.enrollments << Enrollment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @vgroup }\n end\n end",
"def new\n @group = current_user.created_groups.new\n end",
"def new\n @questionnaire_group = QuestionnaireGroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @questionnaire_group }\n end\n end",
"def new\n add_breadcrumb \"Social\", social_path()\n add_breadcrumb \"Create group\"\n \n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def create\n @election_type = ElectionType.new(params[:election_type])\n\n respond_to do |format|\n if @election_type.save\n format.html { redirect_to @election_type, notice: 'Election type was successfully created.' }\n format.json { render json: @election_type, status: :created, location: @election_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @election_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @group = Group.new \n end",
"def new\n\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n format.json { render :json => @group }\n end\n end",
"def new\n @title = \"Добавление группы характеристик\"\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @group }\n end\n end",
"def new\n @group = Group.new\n respond_to do |format|\n #format.html # new.html.erb\n format.json { render json: @group }\n end\n end",
"def new\n @slicegroup = Slicegroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @slicegroup }\n end\n end",
"def new\n @reagent_group = ReagentGroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @reagent_group }\n end\n end",
"def new\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def new\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def new\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def new\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def new\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def new\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def new\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def new\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def new\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def new\n vgroup_id = params[:id]\n @vgroup = Vgroup.find(vgroup_id)\n @enumbers = @vgroup.enrollments\n params[:new_appointment_vgroup_id] = vgroup_id\n @visit = Visit.new\n @visit.enrollments << Enrollment.new\n @visit.user = current_user\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @visit }\n end\n end",
"def new\n vgroup_id = params[:id]\n @vgroup = Vgroup.find(vgroup_id)\n @enumbers = @vgroup.enrollments\n params[:new_appointment_vgroup_id] = vgroup_id\n @visit = Visit.new\n @visit.enrollments << Enrollment.new\n @visit.user = current_user\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @visit }\n end\n end",
"def new\n @group.parent_id = params[:group_id]\n \n add_breadcrumb 'Your hubs', :hubs_path\n add_breadcrumb @hub.name, hub_path(@hub)\n unless params[:group_id]\n add_breadcrumb 'New group', new_hub_group_path(@hub)\n else\n add_breadcrumb 'New sub group', hub_group_subgroup_path(@hub, @group.parent)\n end\n \n append_title 'New group'\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @group }\n end\n end",
"def new\n @giving_group = GivingGroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @giving_group }\n end\n end",
"def new\n @group = Group.new\n \n respond_to do |format|\n format.html\n format.xml { render :xml => @group.to_xml }\n end\n end",
"def new\n @group = Group.new\n \n respond_to do |format|\n format.html\n format.xml { render :xml => @group.to_xml }\n end\n end",
"def create\n respond_to do |format|\n if election.save\n format.html { redirect_to(election, flash: { success: 'Election created.' }) }\n format.xml { render :xml => election, :status => :created, :location => election }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => election.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @group = Group.new\n end",
"def new\n @group = Group.new\n end",
"def new\n @group = Group.new\n end",
"def new\n @group = Group.new\n end",
"def new\n @group = Group.new\n end",
"def new\n @group = Group.new\n @title = 'Create Group'\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def new\n @group = SuperSimpleCms::Group.new\n\n respond_to do |format|\n format.html {render :template=>'admin/groups/new'}\n format.js {render :template=>'admin/groups/new', :layout=>false}\n format.xml { render :xml => @group }\n end\n end",
"def new\n @post = Post.new(group_id: params[:group_id])\n respond_with @post\n end",
"def new\n @group = Group.new\n render json: @group\n end",
"def new\n @group = Group.new\n\n respond_to do |format|\n #format.html # new.html.erb\n #format.xml { render :xml => @group }\n format.js { render :action => 'new' }\n end\n end",
"def new\n\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def new\n @group = Group.new\n\n render json: @group\n end",
"def new\n @provider_group = ProviderGroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @provider_group }\n end\n end",
"def new\n authorize UserGroup\n if params.dig(:user_group, :institution_id).blank?\n render plain: \"Missing institution ID\", status: :bad_request\n return\n end\n render partial: \"user_groups/form\",\n locals: { user_group: UserGroup.new(user_group_params) }\n end",
"def new\n @groups = Group.all\n respond_to do |format|\n format.html # new.html.haml\n format.xml { render :xml => @person }\n format.json { render :json => @person }\n end\n end",
"def new\n @vote = @change.votes.new\n\n respond_to do |format|\n format.html # new.html.erb\n end\n end",
"def new\n @group_area = GroupArea.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @group_area }\n end\n end",
"def new\n\t\t# no code needed here; all handled in the view\n\tend",
"def new\n @group = Group.new\n @membership = Membership.new\n @group_permission = GroupPermission.new\n @metro_areas = MetroArea.find(:all)\n @states = State.find(:all)\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def create\n @group = @form.group.descendants.where.not(type: Form::CollectionGroup).find(params[:id])\n @model = build_form_model(@group)\n model_params = params.fetch(:form, {}).permit!\n @instance = @model.new model_params\n if @instance.valid?\n render :create\n else\n render :show\n end\n end",
"def create\n @group = Group.new(new_group_params)\n if @group.save\n redirect_to groups_url\n else\n render :template => \"groups/new\"\n end\n end",
"def newAluGroup\n @competence_group = CompetenceGroup.new\n\t\t@competence_group.competence_id = params[:competence_id]\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @competence_group }\n end\n end",
"def new\n \t@group = Group.new\n end",
"def new\n @group_collaborator = GroupCollaborator.new\n\n\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @group_collaborator }\n end\n end"
] | [
"0.74072677",
"0.6935537",
"0.6881596",
"0.6813523",
"0.67439014",
"0.67144424",
"0.6675272",
"0.66682315",
"0.66682315",
"0.66286516",
"0.66273093",
"0.6608924",
"0.6560848",
"0.6559121",
"0.65434533",
"0.6537528",
"0.65373564",
"0.6520924",
"0.64808667",
"0.6469617",
"0.64287436",
"0.64249295",
"0.6402148",
"0.6402148",
"0.6399157",
"0.6379603",
"0.63709736",
"0.6342743",
"0.6335497",
"0.6335497",
"0.6335497",
"0.6335497",
"0.6335497",
"0.6335497",
"0.6335497",
"0.6335497",
"0.6329459",
"0.631663",
"0.63133365",
"0.63084835",
"0.63083744",
"0.63083744",
"0.62885284",
"0.6285161",
"0.6284199",
"0.6284199",
"0.62739307",
"0.62640786",
"0.62464666",
"0.62383914",
"0.62213236",
"0.6215253",
"0.62113214",
"0.6211169",
"0.620843",
"0.620275",
"0.61936164",
"0.6193207",
"0.6192718",
"0.6191654",
"0.617274",
"0.61725825",
"0.61725825",
"0.61725825",
"0.61725825",
"0.61725825",
"0.61725825",
"0.61725825",
"0.61725825",
"0.61725825",
"0.61674273",
"0.61674273",
"0.6164826",
"0.6142466",
"0.6141016",
"0.6141016",
"0.6140789",
"0.6135718",
"0.6135718",
"0.6135718",
"0.6135718",
"0.6135718",
"0.61298215",
"0.6117387",
"0.61172384",
"0.6116516",
"0.61122745",
"0.6109902",
"0.60911757",
"0.6086103",
"0.6078214",
"0.60768306",
"0.60765517",
"0.6072072",
"0.6064444",
"0.60604095",
"0.60558623",
"0.60292506",
"0.6022472",
"0.6020769",
"0.6020204"
] | 0.0 | -1 |
POST /election actually creates a new voting group | def create
LunchGroup.transaction do
@group = LunchGroup.new(:name=>params[:name])
@group.prefs = params[:prefs]
if success = @group.save
@admin_user = GroupMember.new(:email=>prefs[:admin_email])
@group.add_admin @admin_user
end
end
if success
flash[:notice] = "New group was created!"
respond_to do |format|
format.html {redirect_to :show}
format.json{render :json=>{success:true} }
end
else
flash[:notice] = "Please fix the errors."
respond_to do |format|
format.html {render :new}
format.json{render :json=>{success:false, :errors=>@group.errors} }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @election = Election.new(election_params)\n respond_to do |format|\n if @election.save\n format.html { redirect_to [:admin, @election], notice: 'Election was successfully created.' }\n format.json { render :show, status: :created, location: @election }\n else\n format.html { render :new }\n format.json { render json: @election.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @election = Election.new(election_params)\n\n respond_to do |format|\n if @election.save\n format.html { redirect_to @election, notice: 'Election was successfully created.' }\n format.json { render :show, status: :created, location: @election }\n else\n format.html { render :new }\n format.json { render json: @election.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @election = Election.new(election_params)\n\n respond_to do |format|\n if @election.save\n format.html { redirect_to @election, notice: 'Election was successfully created.' }\n format.json { render :show, status: :created, location: @election }\n else\n format.html { render :new }\n format.json { render json: @election.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # Create election from parameters\n @election = Election.new(params[:election])\n user_id = params[:election][:user_id]\n if user_id == \"\"\n flash[:error] = \"You may choose owner for election\"\n redirect_back_or_default(:action => 'new')\n return\n end\n @election.owner = ::User.find(user_id)#current_user\n\n faculty_id = params[:election][:faculty_id]\n # validate\n if faculty_id == \"\"\n flash[:error] = \"You may choose faculty for election\"\n redirect_back_or_default(:action => 'new')\n return\n end\n\n faculty_num = Faculty.find(@election.faculty_id).num\n\n # Get votes by faculty\n voters = Array.new\n voters = ::User.find_users_by_faculty(faculty_num)\n\n # Validates existence of voters\n if voters.empty?\n flash[:error] = \"The are no registered students on a faculty\"\n redirect_back_or_default(:action => 'new')\n return\n end\n\n # Create voting ballots\n ballots = Array.new\n voters.each do |voter|\n ballot = Ballot.new_from_params(voter, @election)\n ballots << ballot\n end\n\n # Save the records to the database\n begin\n Election.transaction do\n @election.save!\n ballots.each {|b| b.save!}\n end\n rescue Exception\n render :action => :new and return\n end\n\n flash[:notice] = \"Election created successfully\"\n redirect_to(object_url(@election))\n end",
"def create\n @election = Election.new(election_params)\n\n respond_to do |format|\n if @election.save\n format.html { redirect_to @election, notice: \"Election was successfully created.\" }\n format.json { render :show, status: :created, location: @election }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @election.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\trequire_admin!\n\t\t@election = Election.new(election_params)\n\n\t\trespond_to do |format|\n\t\t\tif @election.save\n\t\t\t\tformat.html { redirect_to @election, notice: 'Election was successfully created.' }\n\t\t\t\tformat.json { render :show, status: :created, location: @election }\n\t\t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @election.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def create\n @group = Group.find(params[:group_id])\n @candidate = @group.candidates.build(params[:candidate])\n if @candidate.save\n redirect_to group_candidates_url(@group)\n else\n render :action => \"new\"\n end\n end",
"def create\n @election = Election.new(params[:election])\n\n respond_to do |format|\n if @election.save\n flash[:notice] = 'Election was successfully created.'\n format.html { redirect_to(@election) }\n format.xml { render :xml => @election, :status => :created, :location => @election }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @election.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @election = Election.find(params[:election][:id])\n\n @ballot = Ballot.new\n @election.ballots << @ballot\n\n if params[:commit] == \"Spoil Ballot\"\n @ballot.votes << Vote.new(:choice_id => 0, :result => 1, :election_id => @election.id)\n elsif @election.method == \"single_choice\"\n @ballot.votes << Vote.new(:choice_id => params[:vote_single][:choice_id], :result => 1, :election_id => @election.id)\n else #preferential and multiple choice elections\n \t @votes = @election.votes.build params[:vote].values\n @votes.each do |v|\n v.ballot_id = @ballot.id\n #@votes = @ballot.votes.build params[:vote].values\n end\n\n @election.voters << current_voter\n\n if @election.save\n if params[:commit] == \"Spoil Ballot\"\n flash[:notice] = 'Ballot was succesfully spoiled.'\n else\n flash[:notice] = 'Vote was successfully cast.'\n end\n redirect_to(\"/\")\n else\n render :action => \"new\"\n end\n\n end\n\nend",
"def create\n @group = Group.find(params[:group_id])\n @survey = @group.surveys.find(params[:survey_id])\n @survey_candidate = @survey.survey_candidates.build(params[:survey_candidate])\n if @survey_candidate.save\n redirect_to group_survey_survey_candidates_url(@group, @survey)\n else\n render :action => \"new\"\n end\n end",
"def create\n args = election_params.slice(:eligible_seats, :title, :description, :election_type, :scope_type, :scope_id_region)\n if election_params[:election_type] != 'resolution'\n args[:preparation_starts_at] = parse_datetime_params(election_params, :preparation_starts_at)\n args[:preparation_ends_at] = parse_datetime_params(election_params, :preparation_ends_at)\n end\n args[:voting_starts_at] = parse_datetime_params(election_params, :voting_starts_at)\n args[:voting_ends_at] = parse_datetime_params(election_params, :voting_ends_at)\n \n\n @election = Election.new(args)\n @election.ballot_box\n @election.participant_list\n @election.candidate_list\n\n #vygeneruje novy par verejny/soukromy klic \n public_key, private_key = Encryption::Keypair.generate( 4096 )\n\n @election.public_key = public_key.to_s\n @shown_private_key = private_key.to_s\n \n \n \n\n saved = (@election.save && @election.ballot_box.save && @election.participant_list.save && @election.candidate_list.save && @election.election_protocol.save)\n\n if saved then\n if @election.election_type != 'resolution' then\n ElectionTransitionWorker.perform_at(@election.preparation_starts_at, @election.id.to_s, :start_preparation!)\n ElectionTransitionWorker.perform_at(@election.preparation_ends_at, @election.id.to_s, :stop_preparation!)\n end\n ElectionTransitionWorker.perform_at(@election.voting_starts_at, @election.id.to_s, :start_voting!)\n ElectionTransitionWorker.perform_at(@election.voting_ends_at, @election.id.to_s, :stop_voting!)\n end\n\n respond_to do |format|\n if saved\n format.html { render :show_created, notice: 'Volby byly vytvořeny.'}\n format.json { render :show, status: :created, location: @election }\n else\n format.html { render :new }\n format.json { render json: @election.errors, status: :unprocessable_entity }\n end\n end\n @shown_private_key = nil\n end",
"def new\n @election = Election.new\n @election.choices.build\n @election.choices.each do |choice|\n choice.election_id = @election.id\n end\n respond_with @election\n\tend",
"def create\n @election_type = ElectionType.new(params[:election_type])\n\n respond_to do |format|\n if @election_type.save\n format.html { redirect_to @election_type, notice: 'Election type was successfully created.' }\n format.json { render json: @election_type, status: :created, location: @election_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @election_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item_group = ItemGroup.new(params[:item_group])\n @item_group.user = request.user\n\n respond_to do |format|\n if @item_group.save\n format.html { redirect_to new_item_path(group_key:@item_group.key), notice: 'Question was successfully created. Want to add something for people to vote on?' }\n format.json { render json: @item_group, status: :created, location: @item_group }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n respond_to do |format|\n if election.save\n format.html { redirect_to(election, flash: { success: 'Election created.' }) }\n format.xml { render :xml => election, :status => :created, :location => election }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => election.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def reviewer_create_group\n\t\t@group = Group.new(params[:group])\n\t\[email protected]_id = nil\n\t\[email protected]\n\t\trespond_to do |form|\n\t\t\tform.js {render \"reviewer_new_group\"}\n\t\tend\n\tend",
"def createGroup(groupName, gid)\r\n uri = sprintf(\"/api/v1/group_categories/%d/groups\", gid) \r\n \r\n dbg(\"POST #{uri}\")\r\n dbg(\"name=#{groupName}\")\r\n newGroup = $canvas.post(uri, {'name' => groupName})\r\n dbg(newGroup)\r\n return newGroup\r\nend",
"def createGroup(groupName, gid)\r\n uri = sprintf(\"/api/v1/group_categories/%d/groups\", gid) \r\n \r\n dbg(\"POST #{uri}\")\r\n dbg(\"name=#{groupName}\")\r\n newGroup = $canvas.post(uri, {'name' => groupName})\r\n dbg(newGroup)\r\n return newGroup\r\nend",
"def create\n @election = Election.new(election_params)\n respond_to do |format|\n if @election.save\n @election.users << current_user #add the current user to the users for this election\n format.html { redirect_to user_elections_path, notice: 'Election was successfully created.' }\n format.json { render :show, status: :created, location: @election }\n else\n format.html { render :new }\n format.json { render json: @election.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @esol_group = EsolGroup.new(params[:esol_group])\n\n respond_to do |format|\n if @esol_group.save\n format.html { redirect_to @esol_group, notice: 'Esol group was successfully created.' }\n format.json { render json: @esol_group, status: :created, location: @esol_group }\n else\n format.html { render action: \"new\" }\n format.json { render json: @esol_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n votes = params[:vote]\n voter = params[:voter_id]\n\n if votes\n votes.each do |k,v|\n @vote = Vote.new({:voter_id => voter,\n :position_id => v,\n :candidate_id => k })\n @vote.save\n end\n end\n\n\n redirect_to '/vote'\n\n #respond_to do |format|\n #if @vote.save\n #format.html { redirect_to @vote, notice: 'Vote was successfully created.' }\n #format.json { render json: @vote, status: :created, location: @vote }\n #else\n #format.html { render action: \"new\" }\n #format.json { render json: @vote.errors, status: :unprocessable_entity }\n #end\n #end\n end",
"def create_group\n params[:new_members] = params[:participants]\n params[:new_admins] = params[:admin_ids]\n conversation = current_user.conversations.new(group_params)\n if conversation.save\n render_conversation(conversation)\n else\n render_error_model(conversation)\n end\n end",
"def create\n @group = Group.new(group_params)\n @group.create_robotsurvey()\n @group.create_signupsurvey()\n @group.create_poststudysurvey()\n respond_to do |format|\n if @group.save\n \n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render action: 'show', status: :created, location: @group }\n else\n format.html { render action: 'new' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @breadcrumb = 'create'\n @ratio_group = RatioGroup.new(params[:ratio_group])\n @ratio_group.created_by = current_user.id if !current_user.nil?\n \n respond_to do |format|\n if @ratio_group.save\n format.html { redirect_to @ratio_group, notice: crud_notice('created', @ratio_group) }\n format.json { render json: @ratio_group, status: :created, location: @ratio_group }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ratio_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(group_params)\n respond_to do |format|\n if @group.save\n @group.memberships.create(user_id: current_user.id, state: \"owner\")\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render action: 'show', status: :created, location: @group }\n else\n format.html { render action: 'new' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new_nodegroup(nodegroup_json)\n nodemgr_rest_call(\"POST\", \"classifier\", \"groups\", $credentials, id=\"\", nodegroup_json)\nend",
"def create\n\t@groupquestion = GroupQuestion.find(params[:group_question_id])\n\t@groupanswer = @groupquestion.groupanswers.build(groupanswer_params)\n\[email protected] = current_user\n\t\tif @groupanswer.save\n\t\t\tflash[:success] = \"answer submitted\"\n\t\t\t\tredirect_to @groupquestion.group\n\t\t\telse\n\t\t\t\tflash[:danger] = \"some error occured\"\n\t\t\t\trender 'new'\n\t\t\tend\n\n end",
"def create\n #get the current group of the logged in user\n #.where returns an array, even if there's only one value\n #In Ruby, the params function can access the path, the url params, or the body for the needed value\n group = current_user.groups.where(id: params[:group_id]).first\n #The .build method is a built in method of ruby where we can add to a collection without saving it just yet\n #So we're adding a new Chore to the chores collection in our postico db without saving it yet\n @v1_chore = group.chores.build(v1_chore_params)\n @v1_chore.completed = false\n @v1_chore.assigned = false\n @v1_chore.pending = false\n @v1_chore.groupname = group.name\n if @v1_chore.save\n render :create, status: :created\n else\n render json: @v1_chore.errors, status: :unprocessable_entity\n\n end\n end",
"def create\n @questionnaire_group = QuestionnaireGroup.new(params[:questionnaire_group])\n\n respond_to do |format|\n if @questionnaire_group.save\n format.html { redirect_to @questionnaire_group, notice: 'Questionnaire group was successfully created.' }\n format.json { render json: @questionnaire_group, status: :created, location: @questionnaire_group }\n else\n format.html { render action: \"new\" }\n format.json { render json: @questionnaire_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @election_user = ElectionUser.new(election_user_params)\n\n respond_to do |format|\n if @election_user.save\n format.html { redirect_to @election_user, notice: 'Election user was successfully created.' }\n format.json { render :show, status: :created, location: @election_user }\n else\n format.html { render :new }\n format.json { render json: @election_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n #logger.info \"Post parameters: #{params}\"\n @group = Group.new(name: params[:group][:name], expiration: params[:group][:expiration], owner: current_user)\n if @group.save\n @group.memberships.create!(user: current_user, admin: true)\n if params[:group][:users]\n params[:group][:users].each do |u|\n @group.memberships.create!(user: User.where(\"id = ? OR email = ?\", u[:id], u[:email]).first, admin:u[:admin])\n end\n end\n render json: @group, status: :created, location: @group\n else\n render json: @group.errors, status: :unprocessable_entity\n end\n end",
"def create\n @eqvgroup = Eqvgroup.new(eqvgroup_params)\n if eqvgroup_params[:number].blank?\n @eqvgroup.number = @eqvgroup.test.eqvgroups.order(:number).last.number + 1\n end\n\n respond_to do |format|\n if @eqvgroup.save\n format.html {\n #redirect_to @eqvgroup, notice: 'Eqvgroup was successfully created.'\n redirect_to :back\n }\n format.json { render :show, status: :created, location: @eqvgroup }\n else\n format.html { render :new }\n format.json { render json: @eqvgroup.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(params[:group])\n @group.tuners << current_tuner\n # For specified users, we need to send an invite out (Make function so that the update funciton may use)\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to(@group, :notice => 'Group was successfully created.') }\n format.xml { render :xml => @group, :status => :created, :location => @group }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n ip = request.location\n @user = current_user\n @group = @user.groups_as_owner.new(params[:group])\n params[:group][:member_ids] = (params[:group][:member_ids] << @group.member_ids).flatten\n @group.school_id = @user.school_id\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render json: @group, status: :created, location: @group }\n else\n format.html { render action: \"new\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(group_params)\n @group.owner = current_user\n\n if @group.save\n @group.add!(current_user)\n \n render json: @group, status: :created, location: @group\n else\n render json: @group.errors, status: :unprocessable_entity\n end\n end",
"def create\n if(params[:group][:name].nil?) or (params[:group][:name] == \"\")\n flash[:notice] = \"Group must have a name and description\"\n redirect_to new_group_path\n else\n \n #create a new group\n @group = Group.new(group_params)\n user = User.find(session[:user_id]) \n respond_to do |format|\n if @group.save\n #generate a code for the group\n o = [('a'..'z'), ('A'..'Z')].map(&:to_a).flatten\n new_code = (0...8).map { o[rand(o.length)] }.join\n @group.update(code: new_code)\n #after group is created add creator to group as leader\n Membership.create!(user_id: session[:user_id], group_id: @group.id, member_type: 'leader', username: user.username)\n format.html {redirect_to @group, notice: \"Group was successfully created.\"}\n format.json {render :show, status: :created, location: @group}\n else\n format.html {render :new, status: :unprocessable_entity}\n format.json {render json: @group.errors, status: :unprocessable_entity}\n end\n end\n end\n end",
"def create\n @group = Group.new(group_params)\n @group.owner = current_user\n @group.users << current_user\n\n respond_to do |format|\n if @group.save\n membership = Membership.find_by_group_id_and_user_id(@group.id, current_user)\n membership.update_attributes :acceptance_status => true\n\n format.html { redirect_to group_path(@group), alert: 'Group was successfully created.' }\n format.json { render action: 'show', status: :created, location: @group }\n else\n format.html { render action: 'new' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @group = @authorized_group\n @candidate = @group.candidates.build \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @candidate }\n end\n end",
"def create\n @group = @current_user.create_group(params[:group])\n # @group = @current_user.groups.build(params[:group])\n # @group = Group.new(params[:group])\n\n respond_to do |format|\n if @group.valid?\n format.html { redirect_to circle_groups_path, notice: 'Group was successfully created.' }\n format.json { render json: @group, status: :created, location: @group }\n else\n format.html { render action: \"new\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @agent_group = AgentGroup.new(params[:agent_group])\n\n respond_to do |format|\n if @agent_group.save\n format.html { redirect_to @agent_group, notice: 'Agent group was successfully created.' }\n format.json { render json: @agent_group, status: :created, location: @agent_group }\n else\n format.html { render action: \"new\" }\n format.json { render json: @agent_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tag_investigation_group = TagInvestigationGroup.new(tag_investigation_group_params)\n\n respond_to do |format|\n if @tag_investigation_group.save\n format.html { redirect_to @tag_investigation_group, notice: 'Tag investigation group was successfully created.' }\n format.json { render :show, status: :created, location: @tag_investigation_group }\n else\n format.html { render :new }\n format.json { render json: @tag_investigation_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @voting = Voting.new(voting_params)\n\n respond_to do |format|\n if @voting.save\n format.html { redirect_to @voting, notice: 'Voting was successfully created.' }\n format.json { render :show, status: :created, location: @voting }\n else\n format.html { render :new }\n format.json { render json: @voting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(permitted_params)\n @group.owner ||= current_user\n authorize @group, :create?\n respond_to do |format|\n if @group.save\n format.html { redirect_to(@group, :notice => 'Group was successfully created.') }\n format.xml { render :xml => @group, :status => :created, :location => @group }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def election_params\n params.require(:election).permit(:title, :start_date, :finish_date, :status, :category_id)\n end",
"def create\n name = params[:name]\n seat = params[:seat]\n desc = params[:desc]\n group_name = params[:group]\n group = Group.where(name:group_name).first\n\n new_ticket = group.tickets.new(name:name,seat:seat,description:desc)\n\n if new_ticket.save\n notice = {\"notice\"=>\"new ticket created successfully.\"}\n puts notice.to_json\n redirect_to \"http://hacked.io/almanac/get-help/submitted\"\n else\n alert = {\"alert\"=>\"ticket was not created. check your params.\"}\n puts alert.to_json\n redirect_to \"http://hacked.io/almanac/get-help/not-submitted\"\n end\n end",
"def create_answer_votes\n\t\tif @answer.vote_not_present?(current_user)\n vote = @answer.votes.new\n vote.user = current_user\n end\n if vote.save\n render json: { success: true,message: \"Vote Successfully Created.\"},:status=>200\n else\n render :json=> { success: false, message: \"Answers are not present\" },:status=> 203\n end\n\tend",
"def new\n @exercise = Exercise.find(params[:exercise_id])\n load_course\n I18n.locale = @course_instance.locale || I18n.locale\n @is_teacher = @course.has_teacher(current_user)\n\n return access_denied unless logged_in? || @course_instance.submission_policy == 'unauthenticated'\n\n @group = Group.new(:min_size => @exercise.groupsizemin, :max_size => @exercise.groupsizemax)\n @group_members = []\n\n # Add current user\n if logged_in? && !@is_teacher\n member = GroupMember.new(:email => current_user.email)\n member.user = current_user\n @group_members << member\n end\n\n # Create group member slots\n (@group.max_size - @group_members.size).times do |i|\n @group_members << GroupMember.new()\n end\n\n log \"create_group view #{params[:exercise_id]}\"\n end",
"def create\n @actors_group = ActorsGroup.new(actors_group_params)\n\n respond_to do |format|\n if @actors_group.save\n format.html { redirect_to @actors_group, notice: 'La catégorie d\\'acteurs a été créée.' }\n format.json { render :show, status: :created, location: @actors_group }\n else\n format.html { render :new }\n format.json { render json: @actors_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_group\n\t\t@group = Group.new(params[:group])\n\t\[email protected]_id = params[:cardsort_id]\n\t\trespond_to do |format|\n\t\t\tif (@group.save)\n\t\t\t\tformat.js {render \"new_group\", :status => :created}\n\t\t\telse\n\t\t\t\tformat.js {render \"new_group\", :status => :ok}\n\t\t\tend\n\t\tend\n\tend",
"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 create\n @evaluation = Evaluation.new(evaluation_params)\n @evaluation.group_id = params[:group_id]\n @evaluation.student_id = current_student.id\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to student_dashboard_path, notice: 'Evaluation was successfully created.' }\n format.json { render :show, status: :created, location: student_dashboard_path }\n else\n format.html { render :new }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n authorize! :create, CompetenceTierGroup\n \n @competence_tier_group = CompetenceTierGroup.new(competence_tier_group_params)\n @competence_tier_group.save!\n render json: {status: :ok}\n end",
"def create\n #should expire groups page cache\n \n # expire the cache of the grouplist of this user\n Rails.cache.delete(Person.groups_cache_key(@current_user.id, session[:cookie]))\n \n @group = Group.new\n begin\n @group = Group.create(params[\"group\"], session[:cookie])\n flash[:notice] = :group_created_successfully\n redirect_to group_path(@group) and return\n rescue RestClient::RequestFailed => e\n @group.add_errors_from(e)\n @group.form_title = params[:group][:title]\n @group.form_description = params[:group][:description]\n render :action => :new and return\n rescue RestClient::Unauthorized => e\n @group.add_errors_from(e)\n @group.form_title = params[:group][:title]\n @group.form_description = params[:group][:description]\n render :action => :new and return \n end\n end",
"def create\n @expense = Expense.new(expense_params)\n @expense.author_id = current_user.id\n\n respond_to do |format|\n if @expense.save\n # p params[:expense][:group_id]\n group_id = params[:expense][:group_id]\n GroupsExpense.create(group_id: group_id, expense_id: @expense.id) if group_id\n\n format.html { redirect_to expenses_path, notice: 'Expense added.' }\n format.json { render :show, status: :created, location: @expense }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(group_params)\n @group.owner = current_user\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to group_path(@group), notice: \"Group was successfully created.\" }\n format.json { render :show, status: :created, location: @group }\n else\n format.html { render :new }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @collection_group = CollectionGroup.new(collection_group_params)\n\n respond_to do |format|\n if @collection_group.save\n format.html { redirect_to @collection_group, notice: 'Collection group was successfully created.' }\n format.json { render action: 'show', status: :created, location: @collection_group }\n else\n format.html { render action: 'new' }\n format.json { render json: @collection_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @admins_election_result = Admins::ElectionResult.new(admins_election_result_params)\n\n respond_to do |format|\n if @admins_election_result.save\n format.html { redirect_to @admins_election_result, notice: 'Election result was successfully created.' }\n format.json { render :show, status: :created, location: @admins_election_result }\n else\n format.html { render :new }\n format.json { render json: @admins_election_result.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.find(params[:group_id])\n @survey = @group.surveys.build(params[:survey])\n @candidates = @group.candidates\n @candidates.each do |candidate|\n survey_candidate = SurveyCandidate.new\n survey_candidate.candidate_id = candidate.id\n survey_candidate.role = 'sr'\n @survey.survey_candidates << survey_candidate\n end\n @survey.report_wday = \"\"\n @survey.report_wday_by_array = params[:report_wday_by_array]\n\n if @survey.save\n redirect_to group_survey_url(@group, @survey)\n else\n render :action => \"new\"\n end\n end",
"def create\n @group = Group.new(params[:group])\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to(view_group_path(@group.label), :notice => 'Group was successfully created.') }\n format.xml { render :xml => @group, :status => :created, :location => @group }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @user = current_user\n @group = Group.new(group_params)\n @group.save\n respond_with(@group)\n end",
"def create\n @group = Group.new(new_group_params)\n if @group.save\n redirect_to groups_url\n else\n render :template => \"groups/new\"\n end\n end",
"def create\n @group = Group.new(group_params)\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Новая группа создана!' }\n format.json { render :show, status: :created, location: @group }\n else\n format.html { render :new }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n flash[:notice] = 'The recipe group was successfully created.' if recipe_group.save\n respond_with(recipe_group, :location => profession_path(profession))\n end",
"def create\n @lection = Lection.new(lection_params)\n @lection = current_user.lections.new(lection_params)\n respond_to do |format|\n if @lection.save\n format.html { redirect_to @lection, notice: 'Lection was successfully created.' }\n format.json { render :show, status: :created, location: @lection }\n else\n format.html { render :new }\n format.json { render json: @lection.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n authorize! :create, Group\n @group = Group.new(group_params)\n @group.creator = current_user\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render action: 'show', status: :created, location: @group }\n else\n format.html { render action: 'new' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(params[:group])\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render json: @group, status: :created, location: @group }\n else\n format.html { render action: \"new\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(params[:group])\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render json: @group, status: :created, location: @group }\n else\n format.html { render action: \"new\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(params[:group])\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render json: @group, status: :created, location: @group }\n else\n format.html { render action: \"new\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(params[:group])\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render json: @group, status: :created, location: @group }\n else\n format.html { render action: \"new\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(params[:group])\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render json: @group, status: :created, location: @group }\n else\n format.html { render action: \"new\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n name = params[:name]\n @group = Group.new(name: name)\n @group.creator_id = @current_user.id\n if @group.save\n @current_user.creator_join!(@group)\n respond_with(@group, only: [:id, :name, :creator_id, :admin_id])\n else\n render_error(404, request.path, 20101, @group.errors.as_json)\n end\n end",
"def create\n @group = Group.new(group_params)\n respond_to do |format|\n if @group.save\n @group.users.push(current_user)\n UserGroup.set_is_admin(@group.id, current_user.id, true)\n invite_members\n format.html { redirect_to @group, notice: t('flash.notice.groups.successfully_created') }\n format.json { render :show, status: :created, location: @group }\n else\n format.html { render :new }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @interest_group = InterestGroup.new(interest_group_params)\n @interest_group.user = current_user\n \n respond_to do |format|\n if @interest_group.save\n format.html { redirect_to @interest_group, notice: 'Interest group was successfully created.' }\n format.json { render :show, status: :created, location: @interest_group }\n else\n format.html { render :new }\n format.json { render json: @interest_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(params[:group])\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, :notice => 'Group was successfully created.' }\n format.json { render :json => @group, :status => :created, :location => @group}\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(params[:group])\n\n respond_to do |format|\n if @group.save\n flash[:success] = \"Группа успешно добавлена.\"\n format.html { redirect_to @group }\n format.json { render json: @group, status: :created, location: @group }\n else\n flash.now[:error] = \"Группа с таким названием не может быть добавлена!\"\n format.html { render action: \"new\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @garden_group = GardenGroup.new(garden_group_params)\n\n respond_to do |format|\n if @garden_group.save\n format.html { redirect_to @garden_group, notice: 'Garden group was successfully created.' }\n format.json { render :show, status: :created, location: @garden_group }\n else\n format.html { render :new }\n format.json { render json: @garden_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(params[:group])\n\t\[email protected]_id = session[:user_id]\n\n respond_to do |format|\n if @group.save\n\n\t\t\t\t@page = Page.create(:owner => @group.id, :category => 'group')\n\t\t\t\t@group_member = GroupMember.create(:group_id => @group.id, :user_id => session[:user_id], :moderator => true)\n format.html { redirect_to groups_url, :notice => 'Group was successfully created.' }\n format.json { render :json => @group, :status => :created, :location => @group }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(group_params)\n #On vérifie que la liste de droits d'un groupe est effacé\n @group.rights.clear\n\n #On ajoute les droits choisis par un utilisateur\n params[:group][:right_ids] ||= []\n params[:group][:right_ids].each do |right|\n if !(right.blank?)\n @group.add_right(Right.find_by_id(right))\n end\n end\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: t('group.created_msg') }\n format.json { render action: 'show', status: :created, location: @group }\n else\n format.html { render action: 'new' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(group_params)\n\n if @group.save\n render_json_message({:success => t('.success')}, 201, {id: @group.id})\n else\n render_json_message({:errors => @group.errors.messages}, 422)\n end\n\n end",
"def create\n @voting = Voting.new(voting_params)\n\n respond_to do |format|\n if @voting.save\n flash[:success] = 'Voting was successfully created.'\n format.html { redirect_to votings_path }\n format.json { render :show, status: :created, location: @voting }\n else\n format.html { render :new }\n format.json { render json: @voting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def atest_ID_25862_new_post_in_group_you_manage()\n login_as_user1\n read_all_updates\n groupName = create_any_new_group(\"Open Group\", \"Family\")\n logout_common\n login_as_user2\n post_to_any_group(\"Family\",groupName)\n logout_common\n login_as_user1\n verify_updates\n end",
"def create\n @group = Group.new(group_params)\n if @group.save\n flash[:success] = \"Group created!\"\n current_user.join(@group)\n @group.promote_to_admin(current_user)\n redirect_to group_url(@group)\n else\n render 'new'\n end\n end",
"def create\n @group = Group.new(group_params)\n\n respond_to do |format|\n if @group.save\n format.json { render json: @group, status: :created }\n else\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(group_params)\n token = params[:token]\n\n # use the user login instance and match emails to find current user\n @user_login = UserLogin.where(token: token).take\n @current_user = User.where(email: @user_login.email).take\n\n respond_to do |format|\n if @group.save\n\n # create a new group membership for new group w/ current user as admin\n @new_membership = GroupMembership.create(group_id: @group.id, user_id: @current_user.id, is_admin: true)\n\n # associate new membership with the group and the user\n @group.group_memberships << @new_membership\n @current_user.group_memberships << @new_membership\n\n format.html { redirect_to group_path(:id => @group.id), notice: 'Group was successfully created.' }\n format.json { render :show, status: :created, location: @group }\n else\n format.html { render :new }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def election_params\n params.require(:election).permit(:voting_start_date, :voting_end_date, :years_range, :win_user)\n end",
"def create\n @deck = Deck.find_or_create_by_quizlet_id params[:deck][:quizlet_id]\n @deck.handle_id = params[:deck][:handle_id]\n\n require \"net/https\"\n require \"uri\"\n uri = URI.parse(\"https://api.quizlet.com/2.0/sets/#{@deck.quizlet_id}?client_id=ABPPhBBUAN&whitespace=1\")\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Get.new(uri.request_uri)\n response = http.request(request)\n @qdeck = JSON.parse response.body\n\n @deck.save\n\n @group = Group.find_or_create_by_deck_id_and_default @deck.id, true\n @group.update_attributes :name => \"Default\"\n\n @deck.title = @qdeck['title']\n @qdeck['terms'].each do |t|\n card = Card.find_or_create_by_quizlet_id t['id']\n card.front = t['term']\n card.back = t['definition']\n @deck.cards << card\n @group.cards << card\n card.save\n end\n\n respond_to do |format|\n if @deck.save\n format.html { redirect_to edit_deck_path(@deck), notice: 'Deck was successfully created.' }\n format.json { render json: @deck, status: :created, location: @deck }\n else\n format.html { render action: \"new\" }\n format.json { render json: @deck.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(group_params)\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Le groupe a été créé.' }\n format.json { render :show, status: :created, location: @group }\n else\n format.html { render :new }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_new_vm_group\n end",
"def create\n @vote = current_user.votes.build(vote_params)\n if @vote.save\n redirect_to @vote, notice: 'Vote was successfully submitted'\n else\n render action: 'new'\n end\n end",
"def create\n if (user_signed_in? && ([2].include?(current_user.role)))\n @cultural_heritage_group = CulturalHeritage::Group.new(params[:cultural_heritage_group])\n @title_view = 'Grupos'\n respond_to do |format|\n if @cultural_heritage_group.save\n format.html { redirect_to(@cultural_heritage_group, :notice => 'Se ha creado correctamente el grupo.') }\n format.xml { render :xml => @cultural_heritage_group, :status => :created, :location => @cultural_heritage_group }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @cultural_heritage_group.errors, :status => :unprocessable_entity }\n end\n end\n else\n respond_to do |format|\n format.html { redirect_to(new_user_session_path) }\n end\n end\n end",
"def create\n begin\n if params[:paper_id]\n # Create a tag for the paper\n paper = Paper.find(params[:paper_id])\n # Authenticate\n club_id = paper.club_id\n else\n club_id = params[:club_id]\n end\n # Authenticate\n club = can_access_club?(club_id)\n # Tag name is lowercase\n name = params[:name].downcase\n # Find or create the tag for the club\n new_tag = Tag.find_or_create_by_club_id_and_name( club_id, \n params[:name] )\n if params[:paper_id]\n new_collection = Collection.find_or_create_by_paper_id_and_tag_id(\n paper.id, new_tag.id)\n end\n render :json => new_tag \n rescue ActiveRecord::RecordNotFound\n error \"Can't access the club or the paper\"\n end\n end",
"def CreateGroup params = {}\n \n APICall(path: 'groups.json',method: 'POST',payload: params.to_json)\n \n end",
"def create\n @api_v1_initiative_group = Api::V1::InitiativeGroup.new(api_v1_initiative_group_params)\n\n respond_to do |format|\n if @api_v1_initiative_group.save\n format.html { redirect_to @api_v1_initiative_group, notice: 'Initiative group was successfully created.' }\n format.json { render :show, status: :created, location: @api_v1_initiative_group }\n else\n format.html { render :new }\n format.json { render json: @api_v1_initiative_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @api_v1_groups_poll = Api::V1::GroupsPoll.new(api_v1_groups_poll_params)\n\n respond_to do |format|\n if @api_v1_groups_poll.save\n format.html { redirect_to @api_v1_groups_poll, notice: 'Groups poll was successfully created.' }\n format.json { render :show, status: :created, location: @api_v1_groups_poll }\n else\n format.html { render :new }\n format.json { render json: @api_v1_groups_poll.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n #logger.info \"Post parameters: #{params}\"\n @group = Group.new(name: params[:group][:name], expiration: params[:group][:expiration])\n if @group.save\n params[:group][:users].each do |u|\n Membership.create(group: @group, user: User.where(\"id = ? OR email = ?\", u[:id], u[:email]).first, admin:u[:admin])\n end\n render json: @group, status: :created, location: @group\n else\n render json: @group.errors, status: :unprocessable_entity\n end\n end",
"def election_params\n params.require(:election).permit(:name, :due_date)\n end",
"def create\n @group = Group.new(group_params)\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to groups_path, notice: 'Group was successfully created.' }\n format.json { render :show, status: :created, location: @group }\n else\n format.html { render :new }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user.create_group!(new_group_params[:group_user_ids], {name: new_group_params[:name]})\n end",
"def create\n @group = Group.new(group_params)\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render :show, status: :created, location: @group }\n else\n format.html { render :new }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(group_params)\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render :show, status: :created, location: @group }\n else\n format.html { render :new }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.new(group_params)\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render :show, status: :created, location: @group }\n else\n format.html { render :new }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.6827538",
"0.6807363",
"0.6807363",
"0.6793103",
"0.6790869",
"0.66477555",
"0.66108686",
"0.65948427",
"0.6532868",
"0.64155406",
"0.63796175",
"0.6314158",
"0.62240416",
"0.6175115",
"0.6120723",
"0.608254",
"0.60743785",
"0.60743785",
"0.6041563",
"0.6004767",
"0.597924",
"0.5960433",
"0.59603554",
"0.5931587",
"0.58830905",
"0.58794165",
"0.5876167",
"0.58685684",
"0.5864575",
"0.5833351",
"0.58170414",
"0.5807548",
"0.5807453",
"0.5798673",
"0.5794003",
"0.57938164",
"0.5793364",
"0.5766495",
"0.5766295",
"0.57645816",
"0.5756234",
"0.57536227",
"0.57376206",
"0.5737511",
"0.57331127",
"0.5731583",
"0.5731319",
"0.5725442",
"0.5719898",
"0.5698172",
"0.5697488",
"0.5692554",
"0.568856",
"0.5672556",
"0.5666257",
"0.566239",
"0.56604224",
"0.56575656",
"0.56554455",
"0.565058",
"0.5648924",
"0.56473964",
"0.56383526",
"0.56327194",
"0.56283545",
"0.56260395",
"0.56260395",
"0.56260395",
"0.56260395",
"0.56260395",
"0.5622224",
"0.56216913",
"0.5612192",
"0.5600968",
"0.5597156",
"0.55890846",
"0.55886394",
"0.55848867",
"0.5581065",
"0.55777",
"0.55775636",
"0.5574739",
"0.55740416",
"0.5571101",
"0.5566549",
"0.5560588",
"0.5557755",
"0.5552379",
"0.55520535",
"0.5551837",
"0.55497694",
"0.5549203",
"0.5548228",
"0.554522",
"0.5544384",
"0.5542489",
"0.5538542",
"0.5533677",
"0.5531708",
"0.5531708",
"0.5531708"
] | 0.0 | -1 |
GET /election/[group_id] form for editing an existing election group | def edit
@group = LunchGroup.find_by_id params[:id]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit\n @group = Group.find(params[:id])\n end",
"def edit\n @group = Group.find(params[:id])\n end",
"def edit\n @group = Group.find_by_id params[:id]\n end",
"def edit\n render partial: \"user_groups/form\",\n locals: { user_group: @user_group }\n end",
"def edit_group(id, options)\n params = get_group(id)\n params.update(options)\n post(EDIT_GROUP_URI, params)\n end",
"def edit_group(id, options)\n params = get_group(id)\n params.update(options)\n post(EDIT_GROUP_URI, params)\n end",
"def edit \n\n @review_group = ReviewGroup.find(params[:id])\n\n end",
"def update\n @group = load_group\n @group_form = group_form\n\n if @group_form.valid? && @group_form.save\n redirect_to(admin_group_path(@group_form.id))\n else\n render :edit\n end\n end",
"def edit\n @group = current_user.created_groups.find(params[:id])\n end",
"def edit\n @iogroup = Iogroup.find(params[:id])\n end",
"def edit_ad_groups\n render partial: \"user_groups/ad_groups_form\",\n locals: { user_group: @user_group }\n end",
"def update\n @esol_group = EsolGroup.find(params[:id])\n\n respond_to do |format|\n if @esol_group.update_attributes(params[:esol_group])\n format.html { redirect_to @esol_group, notice: 'Esol group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @esol_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @group.update_attributes(params[:group])\n flash[:notice] = t(\"group.updated\")\n redirect_to list_groups_path(:page => params[:page])\n return\n end\n\n render :action => :edit\n end",
"def update\n if @group.update(group_params)\n redirect_to @group, notice: 'Group was successfully updated.'\n else\n render :edit\n end\n end",
"def edit\n @item_group= Vger::Resources::Suitability::ItemGroup.find(params[:id])\n respond_to do |format|\n format.html\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to( view_group_path(@group.label), :notice => 'Group was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n Group.rebuild! if nil.|Group.find(:first).rgt\n\t @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def edit\n Log.add_info(request, params.inspect)\n\n @group_id = params[:group_id]\n official_title_id = params[:id]\n SqlHelper.validate_token([@group_id, official_title_id])\n\n unless official_title_id.blank?\n @official_title = OfficialTitle.find(official_title_id)\n end\n\n render(:partial => 'ajax_official_title_form', :layout => (!request.xhr?))\n end",
"def update\n @group = Group.find(params[:group_id])\n @candidate = Candidate.find(params[:id])\n if @candidate.update_attributes(params[:candidate])\n redirect_to group_candidate_url(@group, @candidate)\n else\n render :action => \"edit\"\n end\n end",
"def update\n \n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to(@group, :notice => 'Group was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def edit\n\n # Set the original profession ID attribute to match the profession id of\n # the recipe group.\n @original_profession_id = recipe_group.profession.id\n\n respond_with(recipe_group)\n\n end",
"def update\n @group = Group.find(by_id)\n if @group.update_attributes(group_params)\n flash[:success] = \"Group updated\"\n redirect_to @group\n else\n render 'edit'\n end\n end",
"def edit_hosts\n render partial: \"user_groups/hosts_form\",\n locals: { user_group: @user_group }\n end",
"def update\n respond_to do |format|\n if @eqvgroup.update(eqvgroup_params)\n format.html { redirect_to @eqvgroup, notice: 'Эквивалентная группа обновлена.' }\n format.json { render :show, status: :ok, location: @eqvgroup }\n else\n format.html { render :edit }\n format.json { render json: @eqvgroup.errors, status: :unprocessable_entity }\n end\n end\n end",
"def edit_discussion_group\n if request.post?\n @discussion_group = DiscussionGroup.find(params[:disc_group][:id])\n @notice = @discussion_group.update_attributes(:name => params[:discussion_group][:name], :description => params[:discussion_group][:description], :is_public => params[:discussion_group][:is_public]) ? \"Group updated successfully.\" : activerecord_error_list(@discussion_group.errors)\n #redirect_to :back\n respond_to do |format|\n format.js\n end\n else\n @discussion_group = DiscussionGroup.find(params[:id])\n render :partial => \"edit_discussion_group\"\n end\n end",
"def edit\n respond_to do |format|\n format.html\n format.xml { render :xml => @group.to_xml }\n end\n end",
"def edit\n respond_to do |format|\n format.html\n format.xml { render :xml => @group.to_xml }\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to @group, :notice => 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:success] = \"Группа успешно отредактирована.\"\n format.html { redirect_to @group }\n format.json { head :no_content }\n else\n flash.now[:error] = \"Введены некорректные данные!\"\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n \n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(admin_groups_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n \n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def edit\n @grupo = Grupo.find(params[:id])\n end",
"def edit\n if GroupsController.group_owner? current_user.id, params[:id]\n set_group\n else\n respond_to do |format|\n format.html { redirect_to groups_path, alert: \"Can't Edit. You are not the group owner\" }\n format.json { render json: \"Only owners can edit the respective group page\", status: :unauthorized }\n end\n end\n end",
"def update\n authorize @group\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to group_path(@group), notice: \"Group was successfully updated.\" }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to @group, :notice => 'Group was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n unless @group.update(group_params)\n render :edit and return\n end\n msg = [\"Updated group.\", rebuild_configs].join(\" \")\n redirect_to groups_url, notice: msg\n end",
"def update\n @group = Group.find_by_param(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to(@group, :notice => 'Group was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n if @group.update_attributes(params[:group])\n flash[:notice] = \"Grupo actualizado.\"\n redirect_to groups_path\n else\n render :action => 'edit'\n end\n end",
"def update\n\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to params[:back_to], notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n redirect_to :action => :index and return unless is_owner?\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n if @group.update_attributes(params[:group])\n flash[:notice] = t('flash_msg47')\n @groups = Group.all\n # format.html { redirect_to(@group) }\n # format.xml { head :ok }\n else\n # format.html { render :action => \"edit\" }\n # format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end",
"def update\n @agent_group = AgentGroup.find(params[:id])\n\n respond_to do |format|\n if @agent_group.update_attributes(params[:agent_group])\n format.html { redirect_to @agent_group, notice: 'Agent group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @agent_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :update, @group\n @group.creator = current_user\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n authorize @group, :update?\n respond_to do |format|\n if @group.update_attributes(permitted_params)\n format.html { redirect_to(@group, :notice => 'Group was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def edit_assignment_group(course_id,assignment_group_id,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"course_id is required\" if course_id.nil?\n raise \"assignment_group_id is required\" if assignment_group_id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :course_id => course_id,\n :assignment_group_id => assignment_group_id\n )\n\n # resource path\n path = path_replace(\"/v1/courses/{course_id}/assignment_groups/{assignment_group_id}\",\n :course_id => course_id,\n :assignment_group_id => assignment_group_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:put, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:put, path, query_params, form_params, headers)\n page_params_store(:put, path)\n AssignmentGroup.new(response)\n end",
"def update\n @expensegroup = Expensegroup.find(params[:id])\n\n respond_to do |format|\n if @expensegroup.update_attributes(params[:expensegroup])\n flash[:notice] = 'Expensegroup was successfully updated.'\n format.html { redirect_to(@expensegroup) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @expensegroup.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @reagent_group = ReagentGroup.find(params[:id])\n\n respond_to do |format|\n if @reagent_group.update_attributes(params[:reagent_group])\n format.html { redirect_to @reagent_group, notice: 'Reagent group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @reagent_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update #:nodoc:\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = I18n.t(\"{{value}} was successfully updated.\", :default => \"{{value}} was successfully updated.\", :value => I18n.t(\"Group\", :default => \"Group\"))\n format.html { redirect_to groups_url }\n # format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n # format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if @group.update_attributes(params[:group])\n respond_with(@group, only: [:id, :name, :creator_id, :admin_id])\n else\n render_error(404, request.path, 20103, \"Failed to update group info\")\n end\n end",
"def update\n\t\t@group = Group.find(params[:id])\n\t\[email protected]_accessor(current_user)\n\t\trespond_to do |format|\n\t\t\tif @group.update_attributes(params[:group])\n\t\t\t\tflash[:notice] = t(:ctrl_object_updated, :typeobj => t(:ctrl_group), :ident => @group.name)\n\t\t\t\tshow_\n\t\t\t\tformat.html { render :action => \"show\" }\n\t\t\t\tformat.xml { head :ok }\n\t\t\telse\n\t\t\t\tflash[:error] = t(:ctrl_object_not_updated, :typeobj => t(:ctrl_group), :ident => @group.name, :error => @group.errors.full_messages)\n\t\t\t\tformat.html { render :action => \"edit\" }\n\t\t\t\tformat.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Группа обновлена!' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @lab_group = LabGroup.find(params[:id])\n\n respond_to do |format|\n if @lab_group.update_attributes(params[:lab_group])\n flash[:notice] = 'LabGroup was successfully updated.'\n format.html { redirect_to(@lab_group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lab_group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Course.groups.new(group_params)\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def edit_departments\n render partial: \"user_groups/departments_form\",\n locals: { user_group: @user_group }\n end",
"def update\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to groups_path }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def edit_administering_groups\n render partial: \"units/administering_groups_form\", locals: { unit: @unit }\n end",
"def edit\n @patients_groups = PatientsGroup.find(params[:id])\n @group = Group.find(@patients_groups.group_id)\n @patient = Patient.find(@patients_groups.patient_id)\n session[:return_to] = request.referer\n @title = \"Edit Patient to Group Relationship\"\n end",
"def update\n @employee_group = EmployeeGroup.find(params[:id])\n\n respond_to do |format|\n if @employee_group.update_attributes(params[:employee_group])\n format.html { redirect_to @employee_group, :notice => 'Employee group was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @employee_group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n if @group.update(post_params)\n redirect_to @group\n else\n render :edit, status: :unprocessable_entity\n end\n end",
"def update\n if (user_signed_in? && ([2].include?(current_user.role)))\n @cultural_heritage_group = CulturalHeritage::Group.find(params[:id])\n @title_view = 'Grupos'\n respond_to do |format|\n if @cultural_heritage_group.update_attributes(params[:cultural_heritage_group])\n format.html { redirect_to(@cultural_heritage_group, :notice => 'Se ha actualizado correctamente el grupo.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @cultural_heritage_group.errors, :status => :unprocessable_entity }\n end\n end\n else\n respond_to do |format|\n format.html { redirect_to(new_user_session_path) }\n end\n end\n end",
"def update\n @provider_group = ProviderGroup.find(params[:id])\n\n respond_to do |format|\n if @provider_group.update_attributes(params[:provider_group])\n flash[:notice] = 'ProviderGroup was successfully updated.'\n format.html { redirect_to(@provider_group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @provider_group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\t\t@group = Group.find(params[:id])\n\t\[email protected]_accessor(current_user)\n\t\trespond_to do |format|\n\t\t\tif @group.update_attributes(params[:group])\n\t\t\t\tflash[:notice] = t(:ctrl_object_updated, :typeobj => t(:ctrl_group), :ident => @group.name)\n\t\t\t\tformat.html { redirect_to(@group) }\n\t\t\t\tformat.xml { head :ok }\n\t\t\telse\n\t\t\t\tflash[:error] = t(:ctrl_object_not_updated, :typeobj => t(:ctrl_group), :ident => @group.name)\n\t\t\t\tformat.html { render :action => \"edit\" }\n\t\t\t\tformat.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def update\n respond_to do |format|\n if @group.update(group_params)\n audit(@group, \"update\", @group.name)\n format.html { redirect_to group_path(@group), notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = '{object} was successfully {action}.'[:object_action_notice, \"Group\"[], \"updated\"[]]\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Le groupe a été modifié.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: I18n.t(:group_update) }\n format.json { render :show, status: :ok, location: @group }\n else\n flash[:alert] = @group.errors.full_messages.to_sentence\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(params[:group])\n format.html { redirect_to [@hub, @group], :notice => 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to [@group], notice: 'group was successfully updated.' }\n format.json { render :show, status: :ok, location: [@group] }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @group = GROUP.first_or_get!(params[:id])\n @group.current_user = current_user\n\n @group.update_children((params[:group] || {}).delete(:locales), :locale)\n\n respond_to do |format|\n if @group.update(params[:group]) or not @group.dirty?\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(group_url(@group.id)) }\n format.xml { render :xml => @group }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if GroupsController.group_owner? current_user.id, params[:id]\n set_group\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to group_path(@group), alert: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n else\n respond_to do |format|\n format.html { redirect_to groups_path, alert: \"Not updated. You are not the group owner\" }\n format.json { render json: \"Only owners can edit the respective group page\", status: :unauthorized }\n end\n end\n end",
"def update\n respond_to do |format|\n if @collection_group.update(collection_group_params)\n format.html { redirect_to @collection_group, notice: 'Collection group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @collection_group.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.74375737",
"0.7437421",
"0.7422804",
"0.71681476",
"0.7107561",
"0.7107561",
"0.6987278",
"0.6885471",
"0.6861747",
"0.6794342",
"0.6785728",
"0.6591702",
"0.6539471",
"0.653162",
"0.64831245",
"0.64808255",
"0.6476432",
"0.6471809",
"0.6471157",
"0.6450893",
"0.6439387",
"0.64074117",
"0.64058644",
"0.64001054",
"0.63478976",
"0.6343716",
"0.6343716",
"0.6337917",
"0.63310724",
"0.63261384",
"0.63261384",
"0.63261384",
"0.6312441",
"0.6311987",
"0.6303392",
"0.62951946",
"0.6290965",
"0.6290658",
"0.62880355",
"0.62880355",
"0.6278874",
"0.62769073",
"0.62751013",
"0.6268669",
"0.6268669",
"0.6256645",
"0.6255419",
"0.62507033",
"0.62507033",
"0.62507033",
"0.62507033",
"0.62507033",
"0.62507033",
"0.62501365",
"0.62451905",
"0.6241922",
"0.62317795",
"0.62317795",
"0.62317795",
"0.62317795",
"0.6227056",
"0.6225155",
"0.61855644",
"0.61801875",
"0.6165617",
"0.6155528",
"0.61490595",
"0.6142829",
"0.61302924",
"0.6125988",
"0.6124717",
"0.6124717",
"0.6124717",
"0.6124717",
"0.6124717",
"0.6124717",
"0.6124717",
"0.6124717",
"0.6124717",
"0.6124717",
"0.6124717",
"0.6124717",
"0.6123698",
"0.61122423",
"0.6111037",
"0.6109884",
"0.6109622",
"0.6103765",
"0.61023206",
"0.61002594",
"0.60967386",
"0.6096006",
"0.60915774",
"0.6088529",
"0.6086047",
"0.60806215",
"0.60781485",
"0.60744226",
"0.60651696",
"0.6056923"
] | 0.72705966 | 3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.